twenty-sdk 2.26.0 → 2.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{catalog-sync-BhcRTPpY.js → catalog-sync-Bh6piElD.js} +1 -1
- package/dist/{catalog-sync-CMzypQBt.mjs → catalog-sync-DV73gNDG.mjs} +1 -1
- package/dist/cli/utilities/entity/entity-page-layout-template.d.ts +1 -1
- package/dist/cli.cjs +19 -13
- package/dist/cli.mjs +3261 -3252
- package/dist/define/index.cjs +10 -10
- package/dist/define/index.cjs.map +1 -1
- package/dist/define/index.d.ts +12 -1
- package/dist/define/index.mjs +2462 -2454
- package/dist/define/index.mjs.map +1 -1
- package/dist/front-component/index.cjs.map +1 -1
- package/dist/front-component/index.mjs +1 -1
- package/dist/front-component/index.mjs.map +1 -1
- package/dist/front-component-renderer/build.cjs +1 -1
- package/dist/front-component-renderer/build.mjs +1 -1
- package/dist/{get-front-component-build-plugins-klRAsPTE.mjs → get-front-component-build-plugins-B5IvUvSS.mjs} +1 -1
- package/dist/{get-front-component-build-plugins-C7h3DVdC.js → get-front-component-build-plugins-TJrFS3_p.js} +1 -1
- package/dist/{get-function-input-schema-GNk3NRLJ-BFDLBpFh.mjs → get-function-input-schema-GNk3NRLJ-CVWRriuo.mjs} +1 -1
- package/dist/{login-CAb32cRd.mjs → login-DhEE-uFP.mjs} +3203 -3194
- package/dist/{login-CY_XIBxf.js → login-wTIo0AV7.js} +46 -46
- package/dist/operations.cjs +1 -1
- package/dist/operations.mjs +1 -1
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./get-front-component-build-plugins-C7h3DVdC.js"),t=require("./login-CY_XIBxf.js"),n=require("./isDefined-Dtu5EYqP-Dp026Ry1.js");let r=require("path");r=e.i(r);let i=require("node:fs/promises"),a=require("uuid"),o=require("react");o=e.i(o);let s=require("node:path");s=e.i(s);let c=require("crypto");c=e.i(c);let l=require("node:child_process"),u=require("chalk");u=e.i(u);let d=require("inquirer");d=e.i(d);let f=require("chokidar");f=e.i(f);let p=require("react/jsx-runtime"),m=require("commander"),h=require("util");var g=e=>e&&!e?.startsWith(`/`)?(0,r.join)(t.Ot,e):e,_=(e,t)=>t!==void 0&&t.length>0?`${t}${e}`:e,v=e=>e.replace(/\s+/g,` `).trim(),y=async e=>{let n=(0,r.join)(e,`package.json`);if(await t.ut(n))try{let e=await(0,i.readFile)(n,`utf-8`),t=JSON.parse(e);return t.dependencies?.[`twenty-sdk`]??t.devDependencies?.[`twenty-sdk`]??void 0}catch{return}},b=e=>{let t=e.match(/(\d+)\./);if(t)return parseInt(t[1],10);let n=e.match(/^[~^>=<]*(\d+)$/);return n?parseInt(n[1],10):null},x=async e=>{let n=t.I.version,r=await y(e);if(!n||!r)return;let i=b(n),a=b(r);i===null||a===null||i!==a&&(console.warn(u.default.yellow(`⚠ Version mismatch: your app requires twenty-sdk@${a}.x but the CLI running is v${n}. Major version mismatches may cause unexpected behavior.\n Update with: npm install -g twenty-sdk@${a}`)),console.warn(``))},S=class{async execute(e){e.private?await this.executePrivate(e):await this.executeNpm(e)}async executeNpm(e){let n=e.appPath??t.Ot;await x(n),console.log(u.default.blue(`Publishing to npm...`)),console.log(u.default.gray(`App path: ${n}\n`));let r=await t.L({appPath:n,npmTag:e.tag,onProgress:e=>console.log(u.default.gray(e))});r.success||(console.error(u.default.red(r.error.message)),process.exit(1)),console.log(u.default.green(`✓ Published to npm successfully`))}async executePrivate(e){let n=e.appPath??t.Ot;await x(n);let i=e.remote??t.U.getActiveRemote();console.log(u.default.blue(`Deploying application on ${i}...`)),console.log(u.default.gray(`App path: ${n}\n`));let a=e=>console.log(u.default.gray(e)),o=await t.G({appPath:n,tarball:!0,onProgress:a});o.success||(console.error(u.default.red(o.error.message)),process.exit(1));let s=await t.R({tarballPath:o.data.tarballPath,remote:e.remote,onProgress:a});s.success||(console.error(u.default.red(s.error.message)),process.exit(1));let c=await t.dt(r.default.join(n,`package.json`)).catch(()=>void 0),l=c?.name??s.data.name,d=c?.version??`unknown`;console.log(u.default.green(`\n✓ Published ${l} v${d} to ${i}\n`)),console.log(" To install deployed application: `yarn twenty app:install`")}},C=class{async execute(e){let n=e.appPath??t.Ot;await x(n),await t.y();let r=e.remote??t.U.getActiveRemote();console.log(u.default.blue(`Installing application on ${r}...`)),console.log(u.default.gray(`App path: ${n}\n`));let i=await t.N({appPath:n,remote:e.remote});i.success||(console.error(u.default.red(i.error.message)),process.exit(1)),console.log(u.default.green(`✓ Application installed`))}},w=class{async execute({appPath:e=t.Ot,askForConfirmation:n}){let r=t.U.getActiveRemote();console.log(u.default.blue(`🚀 Uninstall Twenty Application on ${r}`)),console.log(u.default.gray(`📁 App Path: ${e}\n`)),n&&!await this.confirmationPrompt()&&(console.error(u.default.red(`⛔️ Aborting uninstall`)),process.exit(1));let i=await t.v({appPath:e});return i.success?(console.log(u.default.green(`✅ Application uninstalled successfully`)),{success:!0,data:void 0}):(console.error(u.default.red(`❌ Uninstall failed:`),i.error.message),{success:!1,error:i.error.message})}async confirmationPrompt(){let{confirmation:e}=await d.default.prompt([{type:`confirm`,name:`confirmation`,message:`Are you sure you want to uninstall this application?`,default:!1}]);return e}},T=e=>{let t=new S,n=new C,r=new w;e.command(`app:publish [appPath]`).description(`Build and publish to npm (default) or server registry`).option(`--private`,`Push to a Twenty server's registry instead of npm`).option(`-r, --remote <name>`,`Publish to a specific remote (with --private)`).option(`--tag <tag>`,`npm dist-tag (e.g. beta, next)`).action(async(e,n)=>{await t.execute({appPath:g(e),private:n.private,remote:n.remote,tag:n.tag})}),e.command(`app:install [appPath]`).description(`Install a deployed app on the server`).option(`-r, --remote <name>`,`Install on a specific remote`).action(async(e,t)=>{await n.execute({appPath:g(e),remote:t.remote})}),e.command(`app:uninstall [appPath]`).description(`Uninstall app from server`).option(`-y, --yes`,`Skip confirmation prompt`).action(async(e,t)=>{try{let n=await r.execute({appPath:g(e),askForConfirmation:!t?.yes});process.exit(+!n.success)}catch{process.exit(1)}})},E=[`src/application.config.ts`,`src/application-config.ts`,`src/applicationConfig.ts`],D=async e=>{for(let n of E){let i=(0,r.join)(e,n);if(await t.ut(i))return i}return null},O=async e=>{let n=await D(e);if(n===null)throw Error(`Could not find the application config file (expected one of: ${E.join(`, `)}). Create it with defineApplication({ universalIdentifier: ... }) before generating entities.`);let{config:r}=await t.tt({appPath:e,filePath:n});if(!r?.universalIdentifier)throw Error(`defineApplication in ${n} must declare a universalIdentifier before generating entities.`);return r.universalIdentifier},ee=e.n(((e,t)=>{(function(){var n,r=`4.18.1`,i=200,a=`Unsupported core-js use. Try https://npms.io/search?q=ponyfill.`,o=`Expected a function`,s="Invalid `variable` option passed into `_.template`",c="Invalid `imports` option passed into `_.template`",l=`__lodash_hash_undefined__`,u=500,d=`__lodash_placeholder__`,f=1,p=2,m=4,h=1,g=2,_=1,v=2,y=4,b=8,x=16,S=32,C=64,w=128,T=256,E=512,D=30,O=`...`,ee=800,k=16,te=1,A=2,ne=3,j=1/0,M=9007199254740991,N=17976931348623157e292,P=NaN,F=4294967295,I=F-1,re=F>>>1,ie=[[`ary`,w],[`bind`,_],[`bindKey`,v],[`curry`,b],[`curryRight`,x],[`flip`,E],[`partial`,S],[`partialRight`,C],[`rearg`,T]],ae=`[object Arguments]`,oe=`[object Array]`,se=`[object AsyncFunction]`,ce=`[object Boolean]`,L=`[object Date]`,le=`[object DOMException]`,ue=`[object Error]`,de=`[object Function]`,fe=`[object GeneratorFunction]`,pe=`[object Map]`,me=`[object Number]`,he=`[object Null]`,ge=`[object Object]`,_e=`[object Promise]`,ve=`[object Proxy]`,ye=`[object RegExp]`,be=`[object Set]`,xe=`[object String]`,Se=`[object Symbol]`,Ce=`[object Undefined]`,we=`[object WeakMap]`,Te=`[object WeakSet]`,R=`[object ArrayBuffer]`,Ee=`[object DataView]`,De=`[object Float32Array]`,Oe=`[object Float64Array]`,ke=`[object Int8Array]`,Ae=`[object Int16Array]`,je=`[object Int32Array]`,Me=`[object Uint8Array]`,Ne=`[object Uint8ClampedArray]`,Pe=`[object Uint16Array]`,Fe=`[object Uint32Array]`,Ie=/\b__p \+= '';/g,Le=/\b(__p \+=) '' \+/g,Re=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ze=/&(?:amp|lt|gt|quot|#39);/g,Be=/[&<>"']/g,Ve=RegExp(ze.source),He=RegExp(Be.source),Ue=/<%-([\s\S]+?)%>/g,We=/<%([\s\S]+?)%>/g,Ge=/<%=([\s\S]+?)%>/g,Ke=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,qe=/^\w*$/,Je=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ye=/[\\^$.*+?()[\]{}|]/g,Xe=RegExp(Ye.source),Ze=/^\s+/,Qe=/\s/,$e=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,et=/\{\n\/\* \[wrapped with (.+)\] \*/,tt=/,? & /,nt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,rt=/[()=,{}\[\]\/\s]/,it=/\\(\\)?/g,at=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ot=/\w*$/,st=/^[-+]0x[0-9a-f]+$/i,ct=/^0b[01]+$/i,lt=/^\[object .+?Constructor\]$/,z=/^0o[0-7]+$/i,ut=/^(?:0|[1-9]\d*)$/,B=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,dt=/($^)/,ft=/['\n\r\u2028\u2029\\]/g,pt=`\\ud800-\\udfff`,mt=`\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff`,ht=`\\u2700-\\u27bf`,gt=`a-z\\xdf-\\xf6\\xf8-\\xff`,_t=`\\xac\\xb1\\xd7\\xf7`,vt=`\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf`,yt=`\\u2000-\\u206f`,bt=` \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000`,xt=`A-Z\\xc0-\\xd6\\xd8-\\xde`,St=`\\ufe0e\\ufe0f`,Ct=_t+vt+yt+bt,wt=`['’]`,Tt=`[`+pt+`]`,Et=`[`+Ct+`]`,Dt=`[`+mt+`]`,Ot=`\\d+`,kt=`[`+ht+`]`,At=`[`+gt+`]`,jt=`[^`+pt+Ct+Ot+ht+gt+xt+`]`,Mt=`\\ud83c[\\udffb-\\udfff]`,Nt=`(?:`+Dt+`|`+Mt+`)`,Pt=`[^`+pt+`]`,Ft=`(?:\\ud83c[\\udde6-\\uddff]){2}`,It=`[\\ud800-\\udbff][\\udc00-\\udfff]`,Lt=`[`+xt+`]`,Rt=`\\u200d`,zt=`(?:`+At+`|`+jt+`)`,Bt=`(?:`+Lt+`|`+jt+`)`,Vt=`(?:`+wt+`(?:d|ll|m|re|s|t|ve))?`,Ht=`(?:`+wt+`(?:D|LL|M|RE|S|T|VE))?`,Ut=Nt+`?`,Wt=`[`+St+`]?`,Gt=`(?:`+Rt+`(?:`+[Pt,Ft,It].join(`|`)+`)`+Wt+Ut+`)*`,Kt=`\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])`,qt=`\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])`,Jt=Wt+Ut+Gt,Yt=`(?:`+[kt,Ft,It].join(`|`)+`)`+Jt,Xt=`(?:`+[Pt+Dt+`?`,Dt,Ft,It,Tt].join(`|`)+`)`,V=RegExp(wt,`g`),Zt=RegExp(Dt,`g`),Qt=RegExp(Mt+`(?=`+Mt+`)|`+Xt+Jt,`g`),$t=RegExp([Lt+`?`+At+`+`+Vt+`(?=`+[Et,Lt,`$`].join(`|`)+`)`,Bt+`+`+Ht+`(?=`+[Et,Lt+zt,`$`].join(`|`)+`)`,Lt+`?`+zt+`+`+Vt,Lt+`+`+Ht,qt,Kt,Ot,Yt].join(`|`),`g`),en=RegExp(`[`+Rt+pt+mt+St+`]`),tn=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,nn=`Array.Buffer.DataView.Date.Error.Float32Array.Float64Array.Function.Int8Array.Int16Array.Int32Array.Map.Math.Object.Promise.RegExp.Set.String.Symbol.TypeError.Uint8Array.Uint8ClampedArray.Uint16Array.Uint32Array.WeakMap._.clearTimeout.isFinite.parseInt.setTimeout`.split(`.`),rn=-1,an={};an[De]=an[Oe]=an[ke]=an[Ae]=an[je]=an[Me]=an[Ne]=an[Pe]=an[Fe]=!0,an[ae]=an[oe]=an[R]=an[ce]=an[Ee]=an[L]=an[ue]=an[de]=an[pe]=an[me]=an[ge]=an[ye]=an[be]=an[xe]=an[we]=!1;var on={};on[ae]=on[oe]=on[R]=on[Ee]=on[ce]=on[L]=on[De]=on[Oe]=on[ke]=on[Ae]=on[je]=on[pe]=on[me]=on[ge]=on[ye]=on[be]=on[xe]=on[Se]=on[Me]=on[Ne]=on[Pe]=on[Fe]=!0,on[ue]=on[de]=on[we]=!1;var sn={À:`A`,Á:`A`,Â:`A`,Ã:`A`,Ä:`A`,Å:`A`,à:`a`,á:`a`,â:`a`,ã:`a`,ä:`a`,å:`a`,Ç:`C`,ç:`c`,Ð:`D`,ð:`d`,È:`E`,É:`E`,Ê:`E`,Ë:`E`,è:`e`,é:`e`,ê:`e`,ë:`e`,Ì:`I`,Í:`I`,Î:`I`,Ï:`I`,ì:`i`,í:`i`,î:`i`,ï:`i`,Ñ:`N`,ñ:`n`,Ò:`O`,Ó:`O`,Ô:`O`,Õ:`O`,Ö:`O`,Ø:`O`,ò:`o`,ó:`o`,ô:`o`,õ:`o`,ö:`o`,ø:`o`,Ù:`U`,Ú:`U`,Û:`U`,Ü:`U`,ù:`u`,ú:`u`,û:`u`,ü:`u`,Ý:`Y`,ý:`y`,ÿ:`y`,Æ:`Ae`,æ:`ae`,Þ:`Th`,þ:`th`,ß:`ss`,Ā:`A`,Ă:`A`,Ą:`A`,ā:`a`,ă:`a`,ą:`a`,Ć:`C`,Ĉ:`C`,Ċ:`C`,Č:`C`,ć:`c`,ĉ:`c`,ċ:`c`,č:`c`,Ď:`D`,Đ:`D`,ď:`d`,đ:`d`,Ē:`E`,Ĕ:`E`,Ė:`E`,Ę:`E`,Ě:`E`,ē:`e`,ĕ:`e`,ė:`e`,ę:`e`,ě:`e`,Ĝ:`G`,Ğ:`G`,Ġ:`G`,Ģ:`G`,ĝ:`g`,ğ:`g`,ġ:`g`,ģ:`g`,Ĥ:`H`,Ħ:`H`,ĥ:`h`,ħ:`h`,Ĩ:`I`,Ī:`I`,Ĭ:`I`,Į:`I`,İ:`I`,ĩ:`i`,ī:`i`,ĭ:`i`,į:`i`,ı:`i`,Ĵ:`J`,ĵ:`j`,Ķ:`K`,ķ:`k`,ĸ:`k`,Ĺ:`L`,Ļ:`L`,Ľ:`L`,Ŀ:`L`,Ł:`L`,ĺ:`l`,ļ:`l`,ľ:`l`,ŀ:`l`,ł:`l`,Ń:`N`,Ņ:`N`,Ň:`N`,Ŋ:`N`,ń:`n`,ņ:`n`,ň:`n`,ŋ:`n`,Ō:`O`,Ŏ:`O`,Ő:`O`,ō:`o`,ŏ:`o`,ő:`o`,Ŕ:`R`,Ŗ:`R`,Ř:`R`,ŕ:`r`,ŗ:`r`,ř:`r`,Ś:`S`,Ŝ:`S`,Ş:`S`,Š:`S`,ś:`s`,ŝ:`s`,ş:`s`,š:`s`,Ţ:`T`,Ť:`T`,Ŧ:`T`,ţ:`t`,ť:`t`,ŧ:`t`,Ũ:`U`,Ū:`U`,Ŭ:`U`,Ů:`U`,Ű:`U`,Ų:`U`,ũ:`u`,ū:`u`,ŭ:`u`,ů:`u`,ű:`u`,ų:`u`,Ŵ:`W`,ŵ:`w`,Ŷ:`Y`,ŷ:`y`,Ÿ:`Y`,Ź:`Z`,Ż:`Z`,Ž:`Z`,ź:`z`,ż:`z`,ž:`z`,IJ:`IJ`,ij:`ij`,Œ:`Oe`,œ:`oe`,ʼn:`'n`,ſ:`s`},cn={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},ln={"&":`&`,"<":`<`,">":`>`,""":`"`,"'":`'`},un={"\\":`\\`,"'":`'`,"\n":`n`,"\r":`r`,"\u2028":`u2028`,"\u2029":`u2029`},dn=parseFloat,fn=parseInt,H=typeof global==`object`&&global&&global.Object===Object&&global,pn=typeof self==`object`&&self&&self.Object===Object&&self,mn=H||pn||Function(`return this`)(),hn=typeof e==`object`&&e&&!e.nodeType&&e,gn=hn&&typeof t==`object`&&t&&!t.nodeType&&t,_n=gn&&gn.exports===hn,vn=_n&&H.process,yn=function(){try{return gn&&gn.require&&gn.require(`util`).types||vn&&vn.binding&&vn.binding(`util`)}catch{}}(),bn=yn&&yn.isArrayBuffer,xn=yn&&yn.isDate,Sn=yn&&yn.isMap,Cn=yn&&yn.isRegExp,wn=yn&&yn.isSet,Tn=yn&&yn.isTypedArray;function En(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function Dn(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}function U(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}function On(e,t){for(var n=e==null?0:e.length;n--&&t(e[n],n,e)!==!1;);return e}function kn(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(!t(e[n],n,e))return!1;return!0}function An(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function jn(e,t){return!!(e!=null&&e.length)&&Un(e,t,0)>-1}function Mn(e,t,n){for(var r=-1,i=e==null?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}function Nn(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}function Pn(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function Fn(e,t,n,r){var i=-1,a=e==null?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}function In(e,t,n,r){var i=e==null?0:e.length;for(r&&i&&(n=e[--i]);i--;)n=t(n,e[i],i,e);return n}function Ln(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}var Rn=qn(`length`);function zn(e){return e.split(``)}function Bn(e){return e.match(nt)||[]}function Vn(e,t,n){var r;return n(e,function(e,n,i){if(t(e,n,i))return r=n,!1}),r}function Hn(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1}function Un(e,t,n){return t===t?yr(e,t,n):Hn(e,Gn,n)}function Wn(e,t,n,r){for(var i=n-1,a=e.length;++i<a;)if(r(e[i],t))return i;return-1}function Gn(e){return e!==e}function Kn(e,t){var n=e==null?0:e.length;return n?Zn(e,t)/n:P}function qn(e){return function(t){return t==null?n:t[e]}}function Jn(e){return function(t){return e==null?n:e[t]}}function Yn(e,t,n,r,i){return i(e,function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)}),n}function Xn(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}function Zn(e,t){for(var r,i=-1,a=e.length;++i<a;){var o=t(e[i]);o!==n&&(r=r===n?o:r+o)}return r}function Qn(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function $n(e,t){return Nn(t,function(t){return[t,e[t]]})}function er(e){return e&&e.slice(0,Cr(e)+1).replace(Ze,``)}function tr(e){return function(t){return e(t)}}function nr(e,t){return Nn(t,function(t){return e[t]})}function rr(e,t){return e.has(t)}function ir(e,t){for(var n=-1,r=e.length;++n<r&&Un(t,e[n],0)>-1;);return n}function ar(e,t){for(var n=e.length;n--&&Un(t,e[n],0)>-1;);return n}function or(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}var sr=Jn(sn),cr=Jn(cn);function lr(e){return`\\`+un[e]}function ur(e,t){return e==null?n:e[t]}function dr(e){return en.test(e)}function fr(e){return tn.test(e)}function pr(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}function mr(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function hr(e,t){return function(n){return e(t(n))}}function gr(e,t){for(var n=-1,r=e.length,i=0,a=[];++n<r;){var o=e[n];(o===t||o===d)&&(e[n]=d,a[i++]=n)}return a}function _r(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}function vr(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=[e,e]}),n}function yr(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}function br(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}function xr(e){return dr(e)?Tr(e):Rn(e)}function Sr(e){return dr(e)?Er(e):zn(e)}function Cr(e){for(var t=e.length;t--&&Qe.test(e.charAt(t)););return t}var wr=Jn(ln);function Tr(e){for(var t=Qt.lastIndex=0;Qt.test(e);)++t;return t}function Er(e){return e.match(Qt)||[]}function Dr(e){return e.match($t)||[]}var Or=(function e(t){t=t==null?mn:Or.defaults(mn.Object(),t,Or.pick(mn,nn));var Qe=t.Array,nt=t.Date,pt=t.Error,mt=t.Function,ht=t.Math,gt=t.Object,_t=t.RegExp,vt=t.String,yt=t.TypeError,bt=Qe.prototype,xt=mt.prototype,St=gt.prototype,Ct=t[`__core-js_shared__`],wt=xt.toString,Tt=St.hasOwnProperty,Et=0,Dt=function(){var e=/[^.]+$/.exec(Ct&&Ct.keys&&Ct.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}(),Ot=St.toString,kt=wt.call(gt),At=mn._,jt=_t(`^`+wt.call(Tt).replace(Ye,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`),Mt=_n?t.Buffer:n,Nt=t.Symbol,Pt=t.Uint8Array,Ft=Mt?Mt.allocUnsafe:n,It=hr(gt.getPrototypeOf,gt),Lt=gt.create,Rt=St.propertyIsEnumerable,zt=bt.splice,Bt=Nt?Nt.isConcatSpreadable:n,Vt=Nt?Nt.iterator:n,Ht=Nt?Nt.toStringTag:n,Ut=function(){try{var e=es(gt,`defineProperty`);return e({},``,{}),e}catch{}}(),Wt=t.clearTimeout!==mn.clearTimeout&&t.clearTimeout,Gt=nt&&nt.now!==mn.Date.now&&nt.now,Kt=t.setTimeout!==mn.setTimeout&&t.setTimeout,qt=ht.ceil,Jt=ht.floor,Yt=gt.getOwnPropertySymbols,Xt=Mt?Mt.isBuffer:n,Qt=t.isFinite,$t=bt.join,en=hr(gt.keys,gt),tn=ht.max,sn=ht.min,cn=nt.now,ln=t.parseInt,un=ht.random,H=bt.reverse,pn=es(t,`DataView`),hn=es(t,`Map`),gn=es(t,`Promise`),vn=es(t,`Set`),yn=es(t,`WeakMap`),Rn=es(gt,`create`),zn=yn&&new yn,Jn={},yr=zs(pn),Tr=zs(hn),Er=zs(gn),kr=zs(vn),Ar=zs(yn),jr=Nt?Nt.prototype:n,Mr=jr?jr.valueOf:n,Nr=jr?jr.toString:n;function W(e){if(Mu(e)&&!hu(e)&&!(e instanceof Lr)){if(e instanceof Ir)return e;if(Tt.call(e,`__wrapped__`))return Vs(e)}return new Ir(e)}var Pr=function(){function e(){}return function(t){if(!ju(t))return{};if(Lt)return Lt(t);e.prototype=t;var r=new e;return e.prototype=n,r}}();function Fr(){}function Ir(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=n}W.templateSettings={escape:Ue,evaluate:We,interpolate:Ge,variable:``,imports:{_:W}},W.prototype=Fr.prototype,W.prototype.constructor=W,Ir.prototype=Pr(Fr.prototype),Ir.prototype.constructor=Ir;function Lr(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=F,this.__views__=[]}function Rr(){var e=new Lr(this.__wrapped__);return e.__actions__=po(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=po(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=po(this.__views__),e}function zr(){if(this.__filtered__){var e=new Lr(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Br(){var e=this.__wrapped__.value(),t=this.__dir__,n=hu(e),r=t<0,i=n?e.length:0,a=as(0,i,this.__views__),o=a.start,s=a.end,c=s-o,l=r?s:o-1,u=this.__iteratees__,d=u.length,f=0,p=sn(c,this.__takeCount__);if(!n||!r&&i==c&&p==c)return qa(e,this.__actions__);var m=[];outer:for(;c--&&f<p;){l+=t;for(var h=-1,g=e[l];++h<d;){var _=u[h],v=_.iteratee,y=_.type,b=v(g);if(y==A)g=b;else if(!b){if(y==te)continue outer;break outer}}m[f++]=g}return m}Lr.prototype=Pr(Fr.prototype),Lr.prototype.constructor=Lr;function Vr(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Hr(){this.__data__=Rn?Rn(null):{},this.size=0}function Ur(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}function Wr(e){var t=this.__data__;if(Rn){var r=t[e];return r===l?n:r}return Tt.call(t,e)?t[e]:n}function Gr(e){var t=this.__data__;return Rn?t[e]!==n:Tt.call(t,e)}function Kr(e,t){var r=this.__data__;return this.size+=+!this.has(e),r[e]=Rn&&t===n?l:t,this}Vr.prototype.clear=Hr,Vr.prototype.delete=Ur,Vr.prototype.get=Wr,Vr.prototype.has=Gr,Vr.prototype.set=Kr;function qr(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Jr(){this.__data__=[],this.size=0}function Yr(e){var t=this.__data__,n=bi(t,e);return n<0?!1:(n==t.length-1?t.pop():zt.call(t,n,1),--this.size,!0)}function Xr(e){var t=this.__data__,r=bi(t,e);return r<0?n:t[r][1]}function Zr(e){return bi(this.__data__,e)>-1}function Qr(e,t){var n=this.__data__,r=bi(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}qr.prototype.clear=Jr,qr.prototype.delete=Yr,qr.prototype.get=Xr,qr.prototype.has=Zr,qr.prototype.set=Qr;function $r(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ei(){this.size=0,this.__data__={hash:new Vr,map:new(hn||qr),string:new Vr}}function ti(e){var t=Qo(this,e).delete(e);return this.size-=+!!t,t}function ni(e){return Qo(this,e).get(e)}function ri(e){return Qo(this,e).has(e)}function ii(e,t){var n=Qo(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}$r.prototype.clear=ei,$r.prototype.delete=ti,$r.prototype.get=ni,$r.prototype.has=ri,$r.prototype.set=ii;function ai(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new $r;++t<n;)this.add(e[t])}function oi(e){return this.__data__.set(e,l),this}function si(e){return this.__data__.has(e)}ai.prototype.add=ai.prototype.push=oi,ai.prototype.has=si;function ci(e){var t=this.__data__=new qr(e);this.size=t.size}function li(){this.__data__=new qr,this.size=0}function ui(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function di(e){return this.__data__.get(e)}function fi(e){return this.__data__.has(e)}function pi(e,t){var n=this.__data__;if(n instanceof qr){var r=n.__data__;if(!hn||r.length<i-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new $r(r)}return n.set(e,t),this.size=n.size,this}ci.prototype.clear=li,ci.prototype.delete=ui,ci.prototype.get=di,ci.prototype.has=fi,ci.prototype.set=pi;function mi(e,t){var n=hu(e),r=!n&&mu(e),i=!n&&!r&&bu(e),a=!n&&!r&&!i&&qu(e),o=n||r||i||a,s=o?Qn(e.length,vt):[],c=s.length;for(var l in e)(t||Tt.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||ps(l,c)))&&s.push(l);return s}function hi(e){var t=e.length;return t?e[Da(0,t-1)]:n}function gi(e,t){return Is(po(e),Ei(t,0,e.length))}function _i(e){return Is(po(e))}function vi(e,t,r){(r!==n&&!du(e[t],r)||r===n&&!(t in e))&&wi(e,t,r)}function yi(e,t,r){var i=e[t];(!(Tt.call(e,t)&&du(i,r))||r===n&&!(t in e))&&wi(e,t,r)}function bi(e,t){for(var n=e.length;n--;)if(du(e[n][0],t))return n;return-1}function xi(e,t,n,r){return Mi(e,function(e,i,a){t(r,e,n(e),a)}),r}function Si(e,t){return e&&mo(t,Od(t),e)}function Ci(e,t){return e&&mo(t,kd(t),e)}function wi(e,t,n){t==`__proto__`&&Ut?Ut(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function Ti(e,t){for(var r=-1,i=t.length,a=Qe(i),o=e==null;++r<i;)a[r]=o?n:Sd(e,t[r]);return a}function Ei(e,t,r){return e===e&&(r!==n&&(e=e<=r?e:r),t!==n&&(e=e>=t?e:t)),e}function Di(e,t,r,i,a,o){var s,c=t&f,l=t&p,u=t&m;if(r&&(s=a?r(e,i,a,o):r(e)),s!==n)return s;if(!ju(e))return e;var d=hu(e);if(d){if(s=cs(e),!c)return po(e,s)}else{var h=is(e),g=h==de||h==fe;if(bu(e))return no(e,c);if(h==ge||h==ae||g&&!a){if(s=l||g?{}:ls(e),!c)return l?go(e,Ci(s,e)):ho(e,Si(s,e))}else{if(!on[h])return a?e:{};s=us(e,h,c)}}o||=new ci;var _=o.get(e);if(_)return _;o.set(e,s),Wu(e)?e.forEach(function(n){s.add(Di(n,t,r,n,e,o))}):Nu(e)&&e.forEach(function(n,i){s.set(i,Di(n,t,r,i,e,o))});var v=d?n:(u?l?qo:Ko:l?kd:Od)(e);return U(v||e,function(n,i){v&&(i=n,n=e[i]),yi(s,i,Di(n,t,r,i,e,o))}),s}function Oi(e){var t=Od(e);return function(n){return ki(n,e,t)}}function ki(e,t,r){var i=r.length;if(e==null)return!i;for(e=gt(e);i--;){var a=r[i],o=t[a],s=e[a];if(s===n&&!(a in e)||!o(s))return!1}return!0}function Ai(e,t,r){if(typeof e!=`function`)throw new yt(o);return Ms(function(){e.apply(n,r)},t)}function ji(e,t,n,r){var a=-1,o=jn,s=!0,c=e.length,l=[],u=t.length;if(!c)return l;n&&(t=Nn(t,tr(n))),r?(o=Mn,s=!1):t.length>=i&&(o=rr,s=!1,t=new ai(t));outer:for(;++a<c;){var d=e[a],f=n==null?d:n(d);if(d=r||d!==0?d:0,s&&f===f){for(var p=u;p--;)if(t[p]===f)continue outer;l.push(d)}else o(t,f,r)||l.push(d)}return l}var Mi=yo(Vi),Ni=yo(Hi,!0);function Pi(e,t){var n=!0;return Mi(e,function(e,r,i){return n=!!t(e,r,i),n}),n}function Fi(e,t,r){for(var i=-1,a=e.length;++i<a;){var o=e[i],s=t(o);if(s!=null&&(c===n?s===s&&!Ku(s):r(s,c)))var c=s,l=o}return l}function Ii(e,t,r,i){var a=e.length;for(r=td(r),r<0&&(r=-r>a?0:a+r),i=i===n||i>a?a:td(i),i<0&&(i+=a),i=r>i?0:nd(i);r<i;)e[r++]=t;return e}function Li(e,t){var n=[];return Mi(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function Ri(e,t,n,r,i){var a=-1,o=e.length;for(n||=fs,i||=[];++a<o;){var s=e[a];t>0&&n(s)?t>1?Ri(s,t-1,n,r,i):Pn(i,s):r||(i[i.length]=s)}return i}var zi=bo(),Bi=bo(!0);function Vi(e,t){return e&&zi(e,t,Od)}function Hi(e,t){return e&&Bi(e,t,Od)}function Ui(e,t){return An(t,function(t){return Ou(e[t])})}function Wi(e,t){t=Qa(t,e);for(var r=0,i=t.length;e!=null&&r<i;)e=e[Rs(t[r++])];return r&&r==i?e:n}function Gi(e,t,n){var r=t(e);return hu(e)?r:Pn(r,n(e))}function Ki(e){return e==null?e===n?Ce:he:Ht&&Ht in gt(e)?ts(e):Es(e)}function qi(e,t){return e>t}function Ji(e,t){return e!=null&&Tt.call(e,t)}function Yi(e,t){return e!=null&&t in gt(e)}function Xi(e,t,n){return e>=sn(t,n)&&e<tn(t,n)}function Zi(e,t,r){for(var i=r?Mn:jn,a=e[0].length,o=e.length,s=o,c=Qe(o),l=1/0,u=[];s--;){var d=e[s];s&&t&&(d=Nn(d,tr(t))),l=sn(d.length,l),c[s]=!r&&(t||a>=120&&d.length>=120)?new ai(s&&d):n}d=e[0];var f=-1,p=c[0];outer:for(;++f<a&&u.length<l;){var m=d[f],h=t?t(m):m;if(m=r||m!==0?m:0,!(p?rr(p,h):i(u,h,r))){for(s=o;--s;){var g=c[s];if(!(g?rr(g,h):i(e[s],h,r)))continue outer}p&&p.push(h),u.push(m)}}return u}function Qi(e,t,n,r){return Vi(e,function(e,i,a){t(r,n(e),i,a)}),r}function $i(e,t,r){t=Qa(t,e),e=Os(e,t);var i=e==null?e:e[Rs(fc(t))];return i==null?n:En(i,e,r)}function ea(e){return Mu(e)&&Ki(e)==ae}function ta(e){return Mu(e)&&Ki(e)==R}function na(e){return Mu(e)&&Ki(e)==L}function ra(e,t,n,r,i){return e===t?!0:e==null||t==null||!Mu(e)&&!Mu(t)?e!==e&&t!==t:ia(e,t,n,r,ra,i)}function ia(e,t,n,r,i,a){var o=hu(e),s=hu(t),c=o?oe:is(e),l=s?oe:is(t);c=c==ae?ge:c,l=l==ae?ge:l;var u=c==ge,d=l==ge,f=c==l;if(f&&bu(e)){if(!bu(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new ci,o||qu(e)?Ho(e,t,n,r,i,a):Uo(e,t,c,n,r,i,a);if(!(n&h)){var p=u&&Tt.call(e,`__wrapped__`),m=d&&Tt.call(t,`__wrapped__`);if(p||m){var g=p?e.value():e,_=m?t.value():t;return a||=new ci,i(g,_,n,r,a)}}return f?(a||=new ci,Wo(e,t,n,r,i,a)):!1}function aa(e){return Mu(e)&&is(e)==pe}function oa(e,t,r,i){var a=r.length,o=a,s=!i;if(e==null)return!o;for(e=gt(e);a--;){var c=r[a];if(s&&c[2]?c[1]!==e[c[0]]:!(c[0]in e))return!1}for(;++a<o;){c=r[a];var l=c[0],u=e[l],d=c[1];if(s&&c[2]){if(u===n&&!(l in e))return!1}else{var f=new ci;if(i)var p=i(u,d,l,e,t,f);if(!(p===n?ra(d,u,h|g,i,f):p))return!1}}return!0}function sa(e){return!ju(e)||vs(e)?!1:(Ou(e)?jt:lt).test(zs(e))}function ca(e){return Mu(e)&&Ki(e)==ye}function la(e){return Mu(e)&&is(e)==be}function ua(e){return Mu(e)&&Au(e.length)&&!!an[Ki(e)]}function da(e){return typeof e==`function`?e:e==null?Lf:typeof e==`object`?hu(e)?_a(e[0],e[1]):ga(e):Xf(e)}function fa(e){if(!bs(e))return en(e);var t=[];for(var n in gt(e))Tt.call(e,n)&&n!=`constructor`&&t.push(n);return t}function pa(e){if(!ju(e))return Ts(e);var t=bs(e),n=[];for(var r in e)r==`constructor`&&(t||!Tt.call(e,r))||n.push(r);return n}function ma(e,t){return e<t}function ha(e,t){var n=-1,r=_u(e)?Qe(e.length):[];return Mi(e,function(e,i,a){r[++n]=t(e,i,a)}),r}function ga(e){var t=$o(e);return t.length==1&&t[0][2]?Ss(t[0][0],t[0][1]):function(n){return n===e||oa(n,e,t)}}function _a(e,t){return hs(e)&&xs(t)?Ss(Rs(e),t):function(r){var i=Sd(r,e);return i===n&&i===t?wd(r,e):ra(t,i,h|g)}}function va(e,t,r,i,a){e!==t&&zi(t,function(o,s){if(a||=new ci,ju(o))ya(e,t,s,r,va,i,a);else{var c=i?i(As(e,s),o,s+``,e,t,a):n;c===n&&(c=o),vi(e,s,c)}},kd)}function ya(e,t,r,i,a,o,s){var c=As(e,r),l=As(t,r),u=s.get(l);if(u){vi(e,r,u);return}var d=o?o(c,l,r+``,e,t,s):n,f=d===n;if(f){var p=hu(l),m=!p&&bu(l),h=!p&&!m&&qu(l);d=l,p||m||h?hu(c)?d=c:vu(c)?d=po(c):m?(f=!1,d=no(l,!0)):h?(f=!1,d=so(l,!0)):d=[]:Vu(l)||mu(l)?(d=c,mu(c)?d=id(c):(!ju(c)||Ou(c))&&(d=ls(l))):f=!1}f&&(s.set(l,d),a(d,l,i,o,s),s.delete(l)),vi(e,r,d)}function ba(e,t){var r=e.length;if(r)return t+=t<0?r:0,ps(t,r)?e[t]:n}function xa(e,t,n){t=t.length?Nn(t,function(e){return hu(e)?function(t){return Wi(t,e.length===1?e[0]:e)}:e}):[Lf];var r=-1;return t=Nn(t,tr(Zo())),Xn(ha(e,function(e,n,i){return{criteria:Nn(t,function(t){return t(e)}),index:++r,value:e}}),function(e,t){return lo(e,t,n)})}function Sa(e,t){return Ca(e,t,function(t,n){return wd(e,n)})}function Ca(e,t,n){for(var r=-1,i=t.length,a={};++r<i;){var o=t[r],s=Wi(e,o);n(s,o)&&Na(a,Qa(o,e),s)}return a}function wa(e){return function(t){return Wi(t,e)}}function Ta(e,t,n,r){var i=r?Wn:Un,a=-1,o=t.length,s=e;for(e===t&&(t=po(t)),n&&(s=Nn(e,tr(n)));++a<o;)for(var c=0,l=t[a],u=n?n(l):l;(c=i(s,u,c,r))>-1;)s!==e&&zt.call(s,c,1),zt.call(e,c,1);return e}function Ea(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==a){var a=i;ps(i)?zt.call(e,i,1):Wa(e,i)}}return e}function Da(e,t){return e+Jt(un()*(t-e+1))}function Oa(e,t,n,r){for(var i=-1,a=tn(qt((t-e)/(n||1)),0),o=Qe(a);a--;)o[r?a:++i]=e,e+=n;return o}function ka(e,t){var n=``;if(!e||t<1||t>M)return n;do t%2&&(n+=e),t=Jt(t/2),t&&(e+=e);while(t);return n}function Aa(e,t){return Ns(Ds(e,t,Lf),e+``)}function ja(e){return hi(qd(e))}function Ma(e,t){var n=qd(e);return Is(n,Ei(t,0,n.length))}function Na(e,t,r,i){if(!ju(e))return e;t=Qa(t,e);for(var a=-1,o=t.length,s=o-1,c=e;c!=null&&++a<o;){var l=Rs(t[a]),u=r;if(l===`__proto__`||l===`constructor`||l===`prototype`)return e;if(a!=s){var d=c[l];u=i?i(d,l,c):n,u===n&&(u=ju(d)?d:ps(t[a+1])?[]:{})}yi(c,l,u),c=c[l]}return e}var Pa=zn?function(e,t){return zn.set(e,t),e}:Lf,Fa=Ut?function(e,t){return Ut(e,`toString`,{configurable:!0,enumerable:!1,value:Nf(t),writable:!0})}:Lf;function Ia(e){return Is(qd(e))}function La(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var a=Qe(i);++r<i;)a[r]=e[r+t];return a}function Ra(e,t){var n;return Mi(e,function(e,r,i){return n=t(e,r,i),!n}),!!n}function za(e,t,n){var r=0,i=e==null?r:e.length;if(typeof t==`number`&&t===t&&i<=re){for(;r<i;){var a=r+i>>>1,o=e[a];o!==null&&!Ku(o)&&(n?o<=t:o<t)?r=a+1:i=a}return i}return Ba(e,t,Lf,n)}function Ba(e,t,r,i){var a=0,o=e==null?0:e.length;if(o===0)return 0;t=r(t);for(var s=t!==t,c=t===null,l=Ku(t),u=t===n;a<o;){var d=Jt((a+o)/2),f=r(e[d]),p=f!==n,m=f===null,h=f===f,g=Ku(f);if(s)var _=i||h;else _=u?h&&(i||p):c?h&&p&&(i||!m):l?h&&p&&!m&&(i||!g):m||g?!1:i?f<=t:f<t;_?a=d+1:o=d}return sn(o,I)}function G(e,t){for(var n=-1,r=e.length,i=0,a=[];++n<r;){var o=e[n],s=t?t(o):o;if(!n||!du(s,c)){var c=s;a[i++]=o===0?0:o}}return a}function Va(e){return typeof e==`number`?e:Ku(e)?P:+e}function Ha(e){if(typeof e==`string`)return e;if(hu(e))return Nn(e,Ha)+``;if(Ku(e))return Nr?Nr.call(e):``;var t=e+``;return t==`0`&&1/e==-j?`-0`:t}function Ua(e,t,n){var r=-1,a=jn,o=e.length,s=!0,c=[],l=c;if(n)s=!1,a=Mn;else if(o>=i){var u=t?null:Io(e);if(u)return _r(u);s=!1,a=rr,l=new ai}else l=t?[]:c;outer:for(;++r<o;){var d=e[r],f=t?t(d):d;if(d=n||d!==0?d:0,s&&f===f){for(var p=l.length;p--;)if(l[p]===f)continue outer;t&&l.push(f),c.push(d)}else a(l,f,n)||(l!==c&&l.push(f),c.push(d))}return c}function Wa(e,t){t=Qa(t,e);var n=-1,r=t.length;if(!r)return!0;for(;++n<r;){var i=Rs(t[n]);if(i===`__proto__`&&!Tt.call(e,`__proto__`)||(i===`constructor`||i===`prototype`)&&n<r-1)return!1}var a=Os(e,t);return a==null||delete a[Rs(fc(t))]}function Ga(e,t,n,r){return Na(e,t,n(Wi(e,t)),r)}function Ka(e,t,n,r){for(var i=e.length,a=r?i:-1;(r?a--:++a<i)&&t(e[a],a,e););return n?La(e,r?0:a,r?a+1:i):La(e,r?a+1:0,r?i:a)}function qa(e,t){var n=e;return n instanceof Lr&&(n=n.value()),Fn(t,function(e,t){return t.func.apply(t.thisArg,Pn([e],t.args))},n)}function Ja(e,t,n){var r=e.length;if(r<2)return r?Ua(e[0]):[];for(var i=-1,a=Qe(r);++i<r;)for(var o=e[i],s=-1;++s<r;)s!=i&&(a[i]=ji(a[i]||o,e[s],t,n));return Ua(Ri(a,1),t,n)}function Ya(e,t,r){for(var i=-1,a=e.length,o=t.length,s={};++i<a;){var c=i<o?t[i]:n;r(s,e[i],c)}return s}function Xa(e){return vu(e)?e:[]}function Za(e){return typeof e==`function`?e:Lf}function Qa(e,t){return hu(e)?e:hs(e,t)?[e]:Ls(od(e))}var $a=Aa;function eo(e,t,r){var i=e.length;return r=r===n?i:r,!t&&r>=i?e:La(e,t,r)}var to=Wt||function(e){return mn.clearTimeout(e)};function no(e,t){if(t)return e.slice();var n=e.length,r=Ft?Ft(n):new e.constructor(n);return e.copy(r),r}function ro(e){var t=new e.constructor(e.byteLength);return new Pt(t).set(new Pt(e)),t}function io(e,t){var n=t?ro(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function ao(e){var t=new e.constructor(e.source,ot.exec(e));return t.lastIndex=e.lastIndex,t}function oo(e){return Mr?gt(Mr.call(e)):{}}function so(e,t){var n=t?ro(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function co(e,t){if(e!==t){var r=e!==n,i=e===null,a=e===e,o=Ku(e),s=t!==n,c=t===null,l=t===t,u=Ku(t);if(!c&&!u&&!o&&e>t||o&&s&&l&&!c&&!u||i&&s&&l||!r&&l||!a)return 1;if(!i&&!o&&!u&&e<t||u&&r&&a&&!i&&!o||c&&r&&a||!s&&a||!l)return-1}return 0}function lo(e,t,n){for(var r=-1,i=e.criteria,a=t.criteria,o=i.length,s=n.length;++r<o;){var c=co(i[r],a[r]);if(c)return r>=s?c:c*(n[r]==`desc`?-1:1)}return e.index-t.index}function uo(e,t,n,r){for(var i=-1,a=e.length,o=n.length,s=-1,c=t.length,l=tn(a-o,0),u=Qe(c+l),d=!r;++s<c;)u[s]=t[s];for(;++i<o;)(d||i<a)&&(u[n[i]]=e[i]);for(;l--;)u[s++]=e[i++];return u}function fo(e,t,n,r){for(var i=-1,a=e.length,o=-1,s=n.length,c=-1,l=t.length,u=tn(a-s,0),d=Qe(u+l),f=!r;++i<u;)d[i]=e[i];for(var p=i;++c<l;)d[p+c]=t[c];for(;++o<s;)(f||i<a)&&(d[p+n[o]]=e[i++]);return d}function po(e,t){var n=-1,r=e.length;for(t||=Qe(r);++n<r;)t[n]=e[n];return t}function mo(e,t,r,i){var a=!r;r||={};for(var o=-1,s=t.length;++o<s;){var c=t[o],l=i?i(r[c],e[c],c,r,e):n;l===n&&(l=e[c]),a?wi(r,c,l):yi(r,c,l)}return r}function ho(e,t){return mo(e,ns(e),t)}function go(e,t){return mo(e,rs(e),t)}function _o(e,t){return function(n,r){var i=hu(n)?Dn:xi,a=t?t():{};return i(n,e,Zo(r,2),a)}}function vo(e){return Aa(function(t,r){var i=-1,a=r.length,o=a>1?r[a-1]:n,s=a>2?r[2]:n;for(o=e.length>3&&typeof o==`function`?(a--,o):n,s&&ms(r[0],r[1],s)&&(o=a<3?n:o,a=1),t=gt(t);++i<a;){var c=r[i];c&&e(t,c,i,o)}return t})}function yo(e,t){return function(n,r){if(n==null)return n;if(!_u(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=gt(n);(t?a--:++a<i)&&r(o[a],a,o)!==!1;);return n}}function bo(e){return function(t,n,r){for(var i=-1,a=gt(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}function xo(e,t,n){var r=t&_,i=wo(e);function a(){return(this&&this!==mn&&this instanceof a?i:e).apply(r?n:this,arguments)}return a}function So(e){return function(t){t=od(t);var r=dr(t)?Sr(t):n,i=r?r[0]:t.charAt(0),a=r?eo(r,1).join(``):t.slice(1);return i[e]()+a}}function Co(e){return function(t){return Fn(Of(ef(t).replace(V,``)),e,``)}}function wo(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var n=Pr(e.prototype),r=e.apply(n,t);return ju(r)?r:n}}function To(e,t,r){var i=wo(e);function a(){for(var o=arguments.length,s=Qe(o),c=o,l=Xo(a);c--;)s[c]=arguments[c];var u=o<3&&s[0]!==l&&s[o-1]!==l?[]:gr(s,l);return o-=u.length,o<r?K(e,t,Oo,a.placeholder,n,s,u,n,n,r-o):En(this&&this!==mn&&this instanceof a?i:e,this,s)}return a}function Eo(e){return function(t,r,i){var a=gt(t);if(!_u(t)){var o=Zo(r,3);t=Od(t),r=function(e){return o(a[e],e,a)}}var s=e(t,r,i);return s>-1?a[o?t[s]:s]:n}}function Do(e){return Go(function(t){var r=t.length,i=r,a=Ir.prototype.thru;for(e&&t.reverse();i--;){var s=t[i];if(typeof s!=`function`)throw new yt(o);if(a&&!c&&Yo(s)==`wrapper`)var c=new Ir([],!0)}for(i=c?i:r;++i<r;){s=t[i];var l=Yo(s),u=l==`wrapper`?Jo(s):n;c=u&&_s(u[0])&&u[1]==(w|b|S|T)&&!u[4].length&&u[9]==1?c[Yo(u[0])].apply(c,u[3]):s.length==1&&_s(s)?c[l]():c.thru(s)}return function(){var e=arguments,n=e[0];if(c&&e.length==1&&hu(n))return c.plant(n).value();for(var i=0,a=r?t[i].apply(this,e):n;++i<r;)a=t[i].call(this,a);return a}})}function Oo(e,t,r,i,a,o,s,c,l,u){var d=t&w,f=t&_,p=t&v,m=t&(b|x),h=t&E,g=p?n:wo(e);function y(){for(var n=arguments.length,_=Qe(n),v=n;v--;)_[v]=arguments[v];if(m)var b=Xo(y),x=or(_,b);if(i&&(_=uo(_,i,a,m)),o&&(_=fo(_,o,s,m)),n-=x,m&&n<u){var S=gr(_,b);return K(e,t,Oo,y.placeholder,r,_,S,c,l,u-n)}var C=f?r:this,w=p?C[e]:e;return n=_.length,c?_=ks(_,c):h&&n>1&&_.reverse(),d&&l<n&&(_.length=l),this&&this!==mn&&this instanceof y&&(w=g||wo(w)),w.apply(C,_)}return y}function ko(e,t){return function(n,r){return Qi(n,e,t(r),{})}}function Ao(e,t){return function(r,i){var a;if(r===n&&i===n)return t;if(r!==n&&(a=r),i!==n){if(a===n)return i;typeof r==`string`||typeof i==`string`?(r=Ha(r),i=Ha(i)):(r=Va(r),i=Va(i)),a=e(r,i)}return a}}function jo(e){return Go(function(t){return t=Nn(t,tr(Zo())),Aa(function(n){var r=this;return e(t,function(e){return En(e,r,n)})})})}function Mo(e,t){t=t===n?` `:Ha(t);var r=t.length;if(r<2)return r?ka(t,e):t;var i=ka(t,qt(e/xr(t)));return dr(t)?eo(Sr(i),0,e).join(``):i.slice(0,e)}function No(e,t,n,r){var i=t&_,a=wo(e);function o(){for(var t=-1,s=arguments.length,c=-1,l=r.length,u=Qe(l+s),d=this&&this!==mn&&this instanceof o?a:e;++c<l;)u[c]=r[c];for(;s--;)u[c++]=arguments[++t];return En(d,i?n:this,u)}return o}function Po(e){return function(t,r,i){return i&&typeof i!=`number`&&ms(t,r,i)&&(r=i=n),t=ed(t),r===n?(r=t,t=0):r=ed(r),i=i===n?t<r?1:-1:ed(i),Oa(t,r,i,e)}}function Fo(e){return function(t,n){return typeof t==`string`&&typeof n==`string`||(t=rd(t),n=rd(n)),e(t,n)}}function K(e,t,r,i,a,o,s,c,l,u){var d=t&b,f=d?s:n,p=d?n:s,m=d?o:n,h=d?n:o;t|=d?S:C,t&=~(d?C:S),t&y||(t&=~(_|v));var g=[e,t,a,m,f,h,p,c,l,u],x=r.apply(n,g);return _s(e)&&js(x,g),x.placeholder=i,Ps(x,e,t)}function q(e){var t=ht[e];return function(e,n){if(e=rd(e),n=n==null?0:sn(td(n),292),n&&Qt(e)){var r=(od(e)+`e`).split(`e`);return r=(od(t(r[0]+`e`+(+r[1]+n)))+`e`).split(`e`),+(r[0]+`e`+(+r[1]-n))}return t(e)}}var Io=vn&&1/_r(new vn([,-0]))[1]==j?function(e){return new vn(e)}:Gf;function Lo(e){return function(t){var n=is(t);return n==pe?mr(t):n==be?vr(t):$n(t,e(t))}}function Ro(e,t,r,i,a,s,c,l){var u=t&v;if(!u&&typeof e!=`function`)throw new yt(o);var d=i?i.length:0;if(d||(t&=~(S|C),i=a=n),c=c===n?c:tn(td(c),0),l=l===n?l:td(l),d-=a?a.length:0,t&C){var f=i,p=a;i=a=n}var m=u?n:Jo(e),h=[e,t,r,i,a,f,p,s,c,l];if(m&&ws(h,m),e=h[0],t=h[1],r=h[2],i=h[3],a=h[4],l=h[9]=h[9]===n?u?0:e.length:tn(h[9]-d,0),!l&&t&(b|x)&&(t&=~(b|x)),!t||t==_)var g=xo(e,t,r);else g=t==b||t==x?To(e,t,l):(t==S||t==(_|S))&&!a.length?No(e,t,r,i):Oo.apply(n,h);return Ps((m?Pa:js)(g,h),e,t)}function zo(e,t,r,i){return e===n||du(e,St[r])&&!Tt.call(i,r)?t:e}function Bo(e,t,r,i,a,o){return ju(e)&&ju(t)&&(o.set(t,e),va(e,t,n,Bo,o),o.delete(t)),e}function Vo(e){return Vu(e)?n:e}function Ho(e,t,r,i,a,o){var s=r&h,c=e.length,l=t.length;if(c!=l&&!(s&&l>c))return!1;var u=o.get(e),d=o.get(t);if(u&&d)return u==t&&d==e;var f=-1,p=!0,m=r&g?new ai:n;for(o.set(e,t),o.set(t,e);++f<c;){var _=e[f],v=t[f];if(i)var y=s?i(v,_,f,t,e,o):i(_,v,f,e,t,o);if(y!==n){if(y)continue;p=!1;break}if(m){if(!Ln(t,function(e,t){if(!rr(m,t)&&(_===e||a(_,e,r,i,o)))return m.push(t)})){p=!1;break}}else if(!(_===v||a(_,v,r,i,o))){p=!1;break}}return o.delete(e),o.delete(t),p}function Uo(e,t,n,r,i,a,o){switch(n){case Ee:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case R:return!(e.byteLength!=t.byteLength||!a(new Pt(e),new Pt(t)));case ce:case L:case me:return du(+e,+t);case ue:return e.name==t.name&&e.message==t.message;case ye:case xe:return e==t+``;case pe:var s=mr;case be:var c=r&h;if(s||=_r,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=g,o.set(e,t);var u=Ho(s(e),s(t),r,i,a,o);return o.delete(e),u;case Se:if(Mr)return Mr.call(e)==Mr.call(t)}return!1}function Wo(e,t,r,i,a,o){var s=r&h,c=Ko(e),l=c.length;if(l!=Ko(t).length&&!s)return!1;for(var u=l;u--;){var d=c[u];if(!(s?d in t:Tt.call(t,d)))return!1}var f=o.get(e),p=o.get(t);if(f&&p)return f==t&&p==e;var m=!0;o.set(e,t),o.set(t,e);for(var g=s;++u<l;){d=c[u];var _=e[d],v=t[d];if(i)var y=s?i(v,_,d,t,e,o):i(_,v,d,e,t,o);if(!(y===n?_===v||a(_,v,r,i,o):y)){m=!1;break}g||=d==`constructor`}if(m&&!g){var b=e.constructor,x=t.constructor;b!=x&&`constructor`in e&&`constructor`in t&&!(typeof b==`function`&&b instanceof b&&typeof x==`function`&&x instanceof x)&&(m=!1)}return o.delete(e),o.delete(t),m}function Go(e){return Ns(Ds(e,n,tc),e+``)}function Ko(e){return Gi(e,Od,ns)}function qo(e){return Gi(e,kd,rs)}var Jo=zn?function(e){return zn.get(e)}:Gf;function Yo(e){for(var t=e.name+``,n=Jn[t],r=Tt.call(Jn,t)?n.length:0;r--;){var i=n[r],a=i.func;if(a==null||a==e)return i.name}return t}function Xo(e){return(Tt.call(W,`placeholder`)?W:e).placeholder}function Zo(){var e=W.iteratee||Rf;return e=e===Rf?da:e,arguments.length?e(arguments[0],arguments[1]):e}function Qo(e,t){var n=e.__data__;return gs(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function $o(e){for(var t=Od(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,xs(i)]}return t}function es(e,t){var r=ur(e,t);return sa(r)?r:n}function ts(e){var t=Tt.call(e,Ht),r=e[Ht];try{e[Ht]=n;var i=!0}catch{}var a=Ot.call(e);return i&&(t?e[Ht]=r:delete e[Ht]),a}var ns=Yt?function(e){return e==null?[]:(e=gt(e),An(Yt(e),function(t){return Rt.call(e,t)}))}:ep,rs=Yt?function(e){for(var t=[];e;)Pn(t,ns(e)),e=It(e);return t}:ep,is=Ki;(pn&&is(new pn(new ArrayBuffer(1)))!=Ee||hn&&is(new hn)!=pe||gn&&is(gn.resolve())!=_e||vn&&is(new vn)!=be||yn&&is(new yn)!=we)&&(is=function(e){var t=Ki(e),r=t==ge?e.constructor:n,i=r?zs(r):``;if(i)switch(i){case yr:return Ee;case Tr:return pe;case Er:return _e;case kr:return be;case Ar:return we}return t});function as(e,t,n){for(var r=-1,i=n.length;++r<i;){var a=n[r],o=a.size;switch(a.type){case`drop`:e+=o;break;case`dropRight`:t-=o;break;case`take`:t=sn(t,e+o);break;case`takeRight`:e=tn(e,t-o);break}}return{start:e,end:t}}function os(e){var t=e.match(et);return t?t[1].split(tt):[]}function ss(e,t,n){t=Qa(t,e);for(var r=-1,i=t.length,a=!1;++r<i;){var o=Rs(t[r]);if(!(a=e!=null&&n(e,o)))break;e=e[o]}return a||++r!=i?a:(i=e==null?0:e.length,!!i&&Au(i)&&ps(o,i)&&(hu(e)||mu(e)))}function cs(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]==`string`&&Tt.call(e,`index`)&&(n.index=e.index,n.input=e.input),n}function ls(e){return typeof e.constructor==`function`&&!bs(e)?Pr(It(e)):{}}function us(e,t,n){var r=e.constructor;switch(t){case R:return ro(e);case ce:case L:return new r(+e);case Ee:return io(e,n);case De:case Oe:case ke:case Ae:case je:case Me:case Ne:case Pe:case Fe:return so(e,n);case pe:return new r;case me:case xe:return new r(e);case ye:return ao(e);case be:return new r;case Se:return oo(e)}}function ds(e,t){var n=t.length;if(!n)return e;var r=n-1;return t[r]=(n>1?`& `:``)+t[r],t=t.join(n>2?`, `:` `),e.replace($e,`{
|
|
2
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./get-front-component-build-plugins-TJrFS3_p.js"),t=require("./login-wTIo0AV7.js"),n=require("./isDefined-Dtu5EYqP-Dp026Ry1.js");let r=require("path");r=e.i(r);let i=require("node:fs/promises"),a=require("uuid"),o=require("react");o=e.i(o);let s=require("node:path");s=e.i(s);let c=require("crypto");c=e.i(c);let l=require("node:child_process"),u=require("chalk");u=e.i(u);let d=require("inquirer");d=e.i(d);let f=require("chokidar");f=e.i(f);let p=require("react/jsx-runtime"),m=require("commander"),h=require("util");var g=e=>e&&!e?.startsWith(`/`)?(0,r.join)(t.kt,e):e,_=(e,t)=>t!==void 0&&t.length>0?`${t}${e}`:e,v=e=>e.replace(/\s+/g,` `).trim(),y=async e=>{let n=(0,r.join)(e,`package.json`);if(await t.ut(n))try{let e=await(0,i.readFile)(n,`utf-8`),t=JSON.parse(e);return t.dependencies?.[`twenty-sdk`]??t.devDependencies?.[`twenty-sdk`]??void 0}catch{return}},b=e=>{let t=e.match(/(\d+)\./);if(t)return parseInt(t[1],10);let n=e.match(/^[~^>=<]*(\d+)$/);return n?parseInt(n[1],10):null},x=async e=>{let n=t.I.version,r=await y(e);if(!n||!r)return;let i=b(n),a=b(r);i===null||a===null||i!==a&&(console.warn(u.default.yellow(`⚠ Version mismatch: your app requires twenty-sdk@${a}.x but the CLI running is v${n}. Major version mismatches may cause unexpected behavior.\n Update with: npm install -g twenty-sdk@${a}`)),console.warn(``))},S=class{async execute(e){e.private?await this.executePrivate(e):await this.executeNpm(e)}async executeNpm(e){let n=e.appPath??t.kt;await x(n),console.log(u.default.blue(`Publishing to npm...`)),console.log(u.default.gray(`App path: ${n}\n`));let r=await t.L({appPath:n,npmTag:e.tag,onProgress:e=>console.log(u.default.gray(e))});r.success||(console.error(u.default.red(r.error.message)),process.exit(1)),console.log(u.default.green(`✓ Published to npm successfully`))}async executePrivate(e){let n=e.appPath??t.kt;await x(n);let i=e.remote??t.U.getActiveRemote();console.log(u.default.blue(`Deploying application on ${i}...`)),console.log(u.default.gray(`App path: ${n}\n`));let a=e=>console.log(u.default.gray(e)),o=await t.G({appPath:n,tarball:!0,onProgress:a});o.success||(console.error(u.default.red(o.error.message)),process.exit(1));let s=await t.R({tarballPath:o.data.tarballPath,remote:e.remote,onProgress:a});s.success||(console.error(u.default.red(s.error.message)),process.exit(1));let c=await t.dt(r.default.join(n,`package.json`)).catch(()=>void 0),l=c?.name??s.data.name,d=c?.version??`unknown`;console.log(u.default.green(`\n✓ Published ${l} v${d} to ${i}\n`)),console.log(" To install deployed application: `yarn twenty app:install`")}},C=class{async execute(e){let n=e.appPath??t.kt;await x(n),await t.y();let r=e.remote??t.U.getActiveRemote();console.log(u.default.blue(`Installing application on ${r}...`)),console.log(u.default.gray(`App path: ${n}\n`));let i=await t.N({appPath:n,remote:e.remote});i.success||(console.error(u.default.red(i.error.message)),process.exit(1)),console.log(u.default.green(`✓ Application installed`))}},w=class{async execute({appPath:e=t.kt,askForConfirmation:n}){let r=t.U.getActiveRemote();console.log(u.default.blue(`🚀 Uninstall Twenty Application on ${r}`)),console.log(u.default.gray(`📁 App Path: ${e}\n`)),n&&!await this.confirmationPrompt()&&(console.error(u.default.red(`⛔️ Aborting uninstall`)),process.exit(1));let i=await t.v({appPath:e});return i.success?(console.log(u.default.green(`✅ Application uninstalled successfully`)),{success:!0,data:void 0}):(console.error(u.default.red(`❌ Uninstall failed:`),i.error.message),{success:!1,error:i.error.message})}async confirmationPrompt(){let{confirmation:e}=await d.default.prompt([{type:`confirm`,name:`confirmation`,message:`Are you sure you want to uninstall this application?`,default:!1}]);return e}},T=e=>{let t=new S,n=new C,r=new w;e.command(`app:publish [appPath]`).description(`Build and publish to npm (default) or server registry`).option(`--private`,`Push to a Twenty server's registry instead of npm`).option(`-r, --remote <name>`,`Publish to a specific remote (with --private)`).option(`--tag <tag>`,`npm dist-tag (e.g. beta, next)`).action(async(e,n)=>{await t.execute({appPath:g(e),private:n.private,remote:n.remote,tag:n.tag})}),e.command(`app:install [appPath]`).description(`Install a deployed app on the server`).option(`-r, --remote <name>`,`Install on a specific remote`).action(async(e,t)=>{await n.execute({appPath:g(e),remote:t.remote})}),e.command(`app:uninstall [appPath]`).description(`Uninstall app from server`).option(`-y, --yes`,`Skip confirmation prompt`).action(async(e,t)=>{try{let n=await r.execute({appPath:g(e),askForConfirmation:!t?.yes});process.exit(+!n.success)}catch{process.exit(1)}})},E=[`src/application.config.ts`,`src/application-config.ts`,`src/applicationConfig.ts`],D=async e=>{for(let n of E){let i=(0,r.join)(e,n);if(await t.ut(i))return i}return null},O=async e=>{let n=await D(e);if(n===null)throw Error(`Could not find the application config file (expected one of: ${E.join(`, `)}). Create it with defineApplication({ universalIdentifier: ... }) before generating entities.`);let{config:r}=await t.tt({appPath:e,filePath:n});if(!r?.universalIdentifier)throw Error(`defineApplication in ${n} must declare a universalIdentifier before generating entities.`);return r.universalIdentifier},ee=e.n(((e,t)=>{(function(){var n,r=`4.18.1`,i=200,a=`Unsupported core-js use. Try https://npms.io/search?q=ponyfill.`,o=`Expected a function`,s="Invalid `variable` option passed into `_.template`",c="Invalid `imports` option passed into `_.template`",l=`__lodash_hash_undefined__`,u=500,d=`__lodash_placeholder__`,f=1,p=2,m=4,h=1,g=2,_=1,v=2,y=4,b=8,x=16,S=32,C=64,w=128,T=256,E=512,D=30,O=`...`,ee=800,k=16,te=1,A=2,ne=3,j=1/0,M=9007199254740991,N=17976931348623157e292,P=NaN,F=4294967295,I=F-1,re=F>>>1,ie=[[`ary`,w],[`bind`,_],[`bindKey`,v],[`curry`,b],[`curryRight`,x],[`flip`,E],[`partial`,S],[`partialRight`,C],[`rearg`,T]],ae=`[object Arguments]`,oe=`[object Array]`,se=`[object AsyncFunction]`,ce=`[object Boolean]`,L=`[object Date]`,le=`[object DOMException]`,ue=`[object Error]`,de=`[object Function]`,fe=`[object GeneratorFunction]`,pe=`[object Map]`,me=`[object Number]`,he=`[object Null]`,ge=`[object Object]`,_e=`[object Promise]`,ve=`[object Proxy]`,ye=`[object RegExp]`,be=`[object Set]`,xe=`[object String]`,Se=`[object Symbol]`,Ce=`[object Undefined]`,we=`[object WeakMap]`,Te=`[object WeakSet]`,R=`[object ArrayBuffer]`,Ee=`[object DataView]`,De=`[object Float32Array]`,Oe=`[object Float64Array]`,ke=`[object Int8Array]`,Ae=`[object Int16Array]`,je=`[object Int32Array]`,Me=`[object Uint8Array]`,Ne=`[object Uint8ClampedArray]`,Pe=`[object Uint16Array]`,Fe=`[object Uint32Array]`,Ie=/\b__p \+= '';/g,Le=/\b(__p \+=) '' \+/g,Re=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ze=/&(?:amp|lt|gt|quot|#39);/g,Be=/[&<>"']/g,Ve=RegExp(ze.source),He=RegExp(Be.source),Ue=/<%-([\s\S]+?)%>/g,We=/<%([\s\S]+?)%>/g,Ge=/<%=([\s\S]+?)%>/g,Ke=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,qe=/^\w*$/,Je=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ye=/[\\^$.*+?()[\]{}|]/g,Xe=RegExp(Ye.source),Ze=/^\s+/,Qe=/\s/,$e=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,et=/\{\n\/\* \[wrapped with (.+)\] \*/,tt=/,? & /,nt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,rt=/[()=,{}\[\]\/\s]/,it=/\\(\\)?/g,at=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ot=/\w*$/,st=/^[-+]0x[0-9a-f]+$/i,ct=/^0b[01]+$/i,lt=/^\[object .+?Constructor\]$/,z=/^0o[0-7]+$/i,ut=/^(?:0|[1-9]\d*)$/,B=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,dt=/($^)/,ft=/['\n\r\u2028\u2029\\]/g,pt=`\\ud800-\\udfff`,mt=`\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff`,ht=`\\u2700-\\u27bf`,gt=`a-z\\xdf-\\xf6\\xf8-\\xff`,_t=`\\xac\\xb1\\xd7\\xf7`,vt=`\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf`,yt=`\\u2000-\\u206f`,bt=` \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000`,xt=`A-Z\\xc0-\\xd6\\xd8-\\xde`,St=`\\ufe0e\\ufe0f`,Ct=_t+vt+yt+bt,wt=`['’]`,Tt=`[`+pt+`]`,Et=`[`+Ct+`]`,Dt=`[`+mt+`]`,Ot=`\\d+`,kt=`[`+ht+`]`,At=`[`+gt+`]`,jt=`[^`+pt+Ct+Ot+ht+gt+xt+`]`,Mt=`\\ud83c[\\udffb-\\udfff]`,Nt=`(?:`+Dt+`|`+Mt+`)`,Pt=`[^`+pt+`]`,Ft=`(?:\\ud83c[\\udde6-\\uddff]){2}`,It=`[\\ud800-\\udbff][\\udc00-\\udfff]`,Lt=`[`+xt+`]`,Rt=`\\u200d`,zt=`(?:`+At+`|`+jt+`)`,Bt=`(?:`+Lt+`|`+jt+`)`,Vt=`(?:`+wt+`(?:d|ll|m|re|s|t|ve))?`,Ht=`(?:`+wt+`(?:D|LL|M|RE|S|T|VE))?`,Ut=Nt+`?`,Wt=`[`+St+`]?`,Gt=`(?:`+Rt+`(?:`+[Pt,Ft,It].join(`|`)+`)`+Wt+Ut+`)*`,Kt=`\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])`,qt=`\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])`,Jt=Wt+Ut+Gt,Yt=`(?:`+[kt,Ft,It].join(`|`)+`)`+Jt,Xt=`(?:`+[Pt+Dt+`?`,Dt,Ft,It,Tt].join(`|`)+`)`,V=RegExp(wt,`g`),Zt=RegExp(Dt,`g`),Qt=RegExp(Mt+`(?=`+Mt+`)|`+Xt+Jt,`g`),$t=RegExp([Lt+`?`+At+`+`+Vt+`(?=`+[Et,Lt,`$`].join(`|`)+`)`,Bt+`+`+Ht+`(?=`+[Et,Lt+zt,`$`].join(`|`)+`)`,Lt+`?`+zt+`+`+Vt,Lt+`+`+Ht,qt,Kt,Ot,Yt].join(`|`),`g`),en=RegExp(`[`+Rt+pt+mt+St+`]`),tn=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,nn=`Array.Buffer.DataView.Date.Error.Float32Array.Float64Array.Function.Int8Array.Int16Array.Int32Array.Map.Math.Object.Promise.RegExp.Set.String.Symbol.TypeError.Uint8Array.Uint8ClampedArray.Uint16Array.Uint32Array.WeakMap._.clearTimeout.isFinite.parseInt.setTimeout`.split(`.`),rn=-1,an={};an[De]=an[Oe]=an[ke]=an[Ae]=an[je]=an[Me]=an[Ne]=an[Pe]=an[Fe]=!0,an[ae]=an[oe]=an[R]=an[ce]=an[Ee]=an[L]=an[ue]=an[de]=an[pe]=an[me]=an[ge]=an[ye]=an[be]=an[xe]=an[we]=!1;var on={};on[ae]=on[oe]=on[R]=on[Ee]=on[ce]=on[L]=on[De]=on[Oe]=on[ke]=on[Ae]=on[je]=on[pe]=on[me]=on[ge]=on[ye]=on[be]=on[xe]=on[Se]=on[Me]=on[Ne]=on[Pe]=on[Fe]=!0,on[ue]=on[de]=on[we]=!1;var sn={À:`A`,Á:`A`,Â:`A`,Ã:`A`,Ä:`A`,Å:`A`,à:`a`,á:`a`,â:`a`,ã:`a`,ä:`a`,å:`a`,Ç:`C`,ç:`c`,Ð:`D`,ð:`d`,È:`E`,É:`E`,Ê:`E`,Ë:`E`,è:`e`,é:`e`,ê:`e`,ë:`e`,Ì:`I`,Í:`I`,Î:`I`,Ï:`I`,ì:`i`,í:`i`,î:`i`,ï:`i`,Ñ:`N`,ñ:`n`,Ò:`O`,Ó:`O`,Ô:`O`,Õ:`O`,Ö:`O`,Ø:`O`,ò:`o`,ó:`o`,ô:`o`,õ:`o`,ö:`o`,ø:`o`,Ù:`U`,Ú:`U`,Û:`U`,Ü:`U`,ù:`u`,ú:`u`,û:`u`,ü:`u`,Ý:`Y`,ý:`y`,ÿ:`y`,Æ:`Ae`,æ:`ae`,Þ:`Th`,þ:`th`,ß:`ss`,Ā:`A`,Ă:`A`,Ą:`A`,ā:`a`,ă:`a`,ą:`a`,Ć:`C`,Ĉ:`C`,Ċ:`C`,Č:`C`,ć:`c`,ĉ:`c`,ċ:`c`,č:`c`,Ď:`D`,Đ:`D`,ď:`d`,đ:`d`,Ē:`E`,Ĕ:`E`,Ė:`E`,Ę:`E`,Ě:`E`,ē:`e`,ĕ:`e`,ė:`e`,ę:`e`,ě:`e`,Ĝ:`G`,Ğ:`G`,Ġ:`G`,Ģ:`G`,ĝ:`g`,ğ:`g`,ġ:`g`,ģ:`g`,Ĥ:`H`,Ħ:`H`,ĥ:`h`,ħ:`h`,Ĩ:`I`,Ī:`I`,Ĭ:`I`,Į:`I`,İ:`I`,ĩ:`i`,ī:`i`,ĭ:`i`,į:`i`,ı:`i`,Ĵ:`J`,ĵ:`j`,Ķ:`K`,ķ:`k`,ĸ:`k`,Ĺ:`L`,Ļ:`L`,Ľ:`L`,Ŀ:`L`,Ł:`L`,ĺ:`l`,ļ:`l`,ľ:`l`,ŀ:`l`,ł:`l`,Ń:`N`,Ņ:`N`,Ň:`N`,Ŋ:`N`,ń:`n`,ņ:`n`,ň:`n`,ŋ:`n`,Ō:`O`,Ŏ:`O`,Ő:`O`,ō:`o`,ŏ:`o`,ő:`o`,Ŕ:`R`,Ŗ:`R`,Ř:`R`,ŕ:`r`,ŗ:`r`,ř:`r`,Ś:`S`,Ŝ:`S`,Ş:`S`,Š:`S`,ś:`s`,ŝ:`s`,ş:`s`,š:`s`,Ţ:`T`,Ť:`T`,Ŧ:`T`,ţ:`t`,ť:`t`,ŧ:`t`,Ũ:`U`,Ū:`U`,Ŭ:`U`,Ů:`U`,Ű:`U`,Ų:`U`,ũ:`u`,ū:`u`,ŭ:`u`,ů:`u`,ű:`u`,ų:`u`,Ŵ:`W`,ŵ:`w`,Ŷ:`Y`,ŷ:`y`,Ÿ:`Y`,Ź:`Z`,Ż:`Z`,Ž:`Z`,ź:`z`,ż:`z`,ž:`z`,IJ:`IJ`,ij:`ij`,Œ:`Oe`,œ:`oe`,ʼn:`'n`,ſ:`s`},cn={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},ln={"&":`&`,"<":`<`,">":`>`,""":`"`,"'":`'`},un={"\\":`\\`,"'":`'`,"\n":`n`,"\r":`r`,"\u2028":`u2028`,"\u2029":`u2029`},dn=parseFloat,fn=parseInt,H=typeof global==`object`&&global&&global.Object===Object&&global,pn=typeof self==`object`&&self&&self.Object===Object&&self,mn=H||pn||Function(`return this`)(),hn=typeof e==`object`&&e&&!e.nodeType&&e,gn=hn&&typeof t==`object`&&t&&!t.nodeType&&t,_n=gn&&gn.exports===hn,vn=_n&&H.process,yn=function(){try{return gn&&gn.require&&gn.require(`util`).types||vn&&vn.binding&&vn.binding(`util`)}catch{}}(),bn=yn&&yn.isArrayBuffer,xn=yn&&yn.isDate,Sn=yn&&yn.isMap,Cn=yn&&yn.isRegExp,wn=yn&&yn.isSet,Tn=yn&&yn.isTypedArray;function En(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function Dn(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}function U(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}function On(e,t){for(var n=e==null?0:e.length;n--&&t(e[n],n,e)!==!1;);return e}function kn(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(!t(e[n],n,e))return!1;return!0}function An(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function jn(e,t){return!!(e!=null&&e.length)&&Un(e,t,0)>-1}function Mn(e,t,n){for(var r=-1,i=e==null?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}function Nn(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}function Pn(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function Fn(e,t,n,r){var i=-1,a=e==null?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}function In(e,t,n,r){var i=e==null?0:e.length;for(r&&i&&(n=e[--i]);i--;)n=t(n,e[i],i,e);return n}function Ln(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}var Rn=qn(`length`);function zn(e){return e.split(``)}function Bn(e){return e.match(nt)||[]}function Vn(e,t,n){var r;return n(e,function(e,n,i){if(t(e,n,i))return r=n,!1}),r}function Hn(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1}function Un(e,t,n){return t===t?yr(e,t,n):Hn(e,Gn,n)}function Wn(e,t,n,r){for(var i=n-1,a=e.length;++i<a;)if(r(e[i],t))return i;return-1}function Gn(e){return e!==e}function Kn(e,t){var n=e==null?0:e.length;return n?Zn(e,t)/n:P}function qn(e){return function(t){return t==null?n:t[e]}}function Jn(e){return function(t){return e==null?n:e[t]}}function Yn(e,t,n,r,i){return i(e,function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)}),n}function Xn(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}function Zn(e,t){for(var r,i=-1,a=e.length;++i<a;){var o=t(e[i]);o!==n&&(r=r===n?o:r+o)}return r}function Qn(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function $n(e,t){return Nn(t,function(t){return[t,e[t]]})}function er(e){return e&&e.slice(0,Cr(e)+1).replace(Ze,``)}function tr(e){return function(t){return e(t)}}function nr(e,t){return Nn(t,function(t){return e[t]})}function rr(e,t){return e.has(t)}function ir(e,t){for(var n=-1,r=e.length;++n<r&&Un(t,e[n],0)>-1;);return n}function ar(e,t){for(var n=e.length;n--&&Un(t,e[n],0)>-1;);return n}function or(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}var sr=Jn(sn),cr=Jn(cn);function lr(e){return`\\`+un[e]}function ur(e,t){return e==null?n:e[t]}function dr(e){return en.test(e)}function fr(e){return tn.test(e)}function pr(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}function mr(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function hr(e,t){return function(n){return e(t(n))}}function gr(e,t){for(var n=-1,r=e.length,i=0,a=[];++n<r;){var o=e[n];(o===t||o===d)&&(e[n]=d,a[i++]=n)}return a}function _r(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}function vr(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=[e,e]}),n}function yr(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}function br(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}function xr(e){return dr(e)?Tr(e):Rn(e)}function Sr(e){return dr(e)?Er(e):zn(e)}function Cr(e){for(var t=e.length;t--&&Qe.test(e.charAt(t)););return t}var wr=Jn(ln);function Tr(e){for(var t=Qt.lastIndex=0;Qt.test(e);)++t;return t}function Er(e){return e.match(Qt)||[]}function Dr(e){return e.match($t)||[]}var Or=(function e(t){t=t==null?mn:Or.defaults(mn.Object(),t,Or.pick(mn,nn));var Qe=t.Array,nt=t.Date,pt=t.Error,mt=t.Function,ht=t.Math,gt=t.Object,_t=t.RegExp,vt=t.String,yt=t.TypeError,bt=Qe.prototype,xt=mt.prototype,St=gt.prototype,Ct=t[`__core-js_shared__`],wt=xt.toString,Tt=St.hasOwnProperty,Et=0,Dt=function(){var e=/[^.]+$/.exec(Ct&&Ct.keys&&Ct.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}(),Ot=St.toString,kt=wt.call(gt),At=mn._,jt=_t(`^`+wt.call(Tt).replace(Ye,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`),Mt=_n?t.Buffer:n,Nt=t.Symbol,Pt=t.Uint8Array,Ft=Mt?Mt.allocUnsafe:n,It=hr(gt.getPrototypeOf,gt),Lt=gt.create,Rt=St.propertyIsEnumerable,zt=bt.splice,Bt=Nt?Nt.isConcatSpreadable:n,Vt=Nt?Nt.iterator:n,Ht=Nt?Nt.toStringTag:n,Ut=function(){try{var e=es(gt,`defineProperty`);return e({},``,{}),e}catch{}}(),Wt=t.clearTimeout!==mn.clearTimeout&&t.clearTimeout,Gt=nt&&nt.now!==mn.Date.now&&nt.now,Kt=t.setTimeout!==mn.setTimeout&&t.setTimeout,qt=ht.ceil,Jt=ht.floor,Yt=gt.getOwnPropertySymbols,Xt=Mt?Mt.isBuffer:n,Qt=t.isFinite,$t=bt.join,en=hr(gt.keys,gt),tn=ht.max,sn=ht.min,cn=nt.now,ln=t.parseInt,un=ht.random,H=bt.reverse,pn=es(t,`DataView`),hn=es(t,`Map`),gn=es(t,`Promise`),vn=es(t,`Set`),yn=es(t,`WeakMap`),Rn=es(gt,`create`),zn=yn&&new yn,Jn={},yr=zs(pn),Tr=zs(hn),Er=zs(gn),kr=zs(vn),Ar=zs(yn),jr=Nt?Nt.prototype:n,Mr=jr?jr.valueOf:n,Nr=jr?jr.toString:n;function W(e){if(Mu(e)&&!hu(e)&&!(e instanceof Lr)){if(e instanceof Ir)return e;if(Tt.call(e,`__wrapped__`))return Vs(e)}return new Ir(e)}var Pr=function(){function e(){}return function(t){if(!ju(t))return{};if(Lt)return Lt(t);e.prototype=t;var r=new e;return e.prototype=n,r}}();function Fr(){}function Ir(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=n}W.templateSettings={escape:Ue,evaluate:We,interpolate:Ge,variable:``,imports:{_:W}},W.prototype=Fr.prototype,W.prototype.constructor=W,Ir.prototype=Pr(Fr.prototype),Ir.prototype.constructor=Ir;function Lr(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=F,this.__views__=[]}function Rr(){var e=new Lr(this.__wrapped__);return e.__actions__=po(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=po(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=po(this.__views__),e}function zr(){if(this.__filtered__){var e=new Lr(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Br(){var e=this.__wrapped__.value(),t=this.__dir__,n=hu(e),r=t<0,i=n?e.length:0,a=as(0,i,this.__views__),o=a.start,s=a.end,c=s-o,l=r?s:o-1,u=this.__iteratees__,d=u.length,f=0,p=sn(c,this.__takeCount__);if(!n||!r&&i==c&&p==c)return qa(e,this.__actions__);var m=[];outer:for(;c--&&f<p;){l+=t;for(var h=-1,g=e[l];++h<d;){var _=u[h],v=_.iteratee,y=_.type,b=v(g);if(y==A)g=b;else if(!b){if(y==te)continue outer;break outer}}m[f++]=g}return m}Lr.prototype=Pr(Fr.prototype),Lr.prototype.constructor=Lr;function Vr(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Hr(){this.__data__=Rn?Rn(null):{},this.size=0}function Ur(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}function Wr(e){var t=this.__data__;if(Rn){var r=t[e];return r===l?n:r}return Tt.call(t,e)?t[e]:n}function Gr(e){var t=this.__data__;return Rn?t[e]!==n:Tt.call(t,e)}function Kr(e,t){var r=this.__data__;return this.size+=+!this.has(e),r[e]=Rn&&t===n?l:t,this}Vr.prototype.clear=Hr,Vr.prototype.delete=Ur,Vr.prototype.get=Wr,Vr.prototype.has=Gr,Vr.prototype.set=Kr;function qr(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Jr(){this.__data__=[],this.size=0}function Yr(e){var t=this.__data__,n=bi(t,e);return n<0?!1:(n==t.length-1?t.pop():zt.call(t,n,1),--this.size,!0)}function Xr(e){var t=this.__data__,r=bi(t,e);return r<0?n:t[r][1]}function Zr(e){return bi(this.__data__,e)>-1}function Qr(e,t){var n=this.__data__,r=bi(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}qr.prototype.clear=Jr,qr.prototype.delete=Yr,qr.prototype.get=Xr,qr.prototype.has=Zr,qr.prototype.set=Qr;function $r(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ei(){this.size=0,this.__data__={hash:new Vr,map:new(hn||qr),string:new Vr}}function ti(e){var t=Qo(this,e).delete(e);return this.size-=+!!t,t}function ni(e){return Qo(this,e).get(e)}function ri(e){return Qo(this,e).has(e)}function ii(e,t){var n=Qo(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}$r.prototype.clear=ei,$r.prototype.delete=ti,$r.prototype.get=ni,$r.prototype.has=ri,$r.prototype.set=ii;function ai(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new $r;++t<n;)this.add(e[t])}function oi(e){return this.__data__.set(e,l),this}function si(e){return this.__data__.has(e)}ai.prototype.add=ai.prototype.push=oi,ai.prototype.has=si;function ci(e){var t=this.__data__=new qr(e);this.size=t.size}function li(){this.__data__=new qr,this.size=0}function ui(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function di(e){return this.__data__.get(e)}function fi(e){return this.__data__.has(e)}function pi(e,t){var n=this.__data__;if(n instanceof qr){var r=n.__data__;if(!hn||r.length<i-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new $r(r)}return n.set(e,t),this.size=n.size,this}ci.prototype.clear=li,ci.prototype.delete=ui,ci.prototype.get=di,ci.prototype.has=fi,ci.prototype.set=pi;function mi(e,t){var n=hu(e),r=!n&&mu(e),i=!n&&!r&&bu(e),a=!n&&!r&&!i&&qu(e),o=n||r||i||a,s=o?Qn(e.length,vt):[],c=s.length;for(var l in e)(t||Tt.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||ps(l,c)))&&s.push(l);return s}function hi(e){var t=e.length;return t?e[Da(0,t-1)]:n}function gi(e,t){return Is(po(e),Ei(t,0,e.length))}function _i(e){return Is(po(e))}function vi(e,t,r){(r!==n&&!du(e[t],r)||r===n&&!(t in e))&&wi(e,t,r)}function yi(e,t,r){var i=e[t];(!(Tt.call(e,t)&&du(i,r))||r===n&&!(t in e))&&wi(e,t,r)}function bi(e,t){for(var n=e.length;n--;)if(du(e[n][0],t))return n;return-1}function xi(e,t,n,r){return Mi(e,function(e,i,a){t(r,e,n(e),a)}),r}function Si(e,t){return e&&mo(t,Od(t),e)}function Ci(e,t){return e&&mo(t,kd(t),e)}function wi(e,t,n){t==`__proto__`&&Ut?Ut(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function Ti(e,t){for(var r=-1,i=t.length,a=Qe(i),o=e==null;++r<i;)a[r]=o?n:Sd(e,t[r]);return a}function Ei(e,t,r){return e===e&&(r!==n&&(e=e<=r?e:r),t!==n&&(e=e>=t?e:t)),e}function Di(e,t,r,i,a,o){var s,c=t&f,l=t&p,u=t&m;if(r&&(s=a?r(e,i,a,o):r(e)),s!==n)return s;if(!ju(e))return e;var d=hu(e);if(d){if(s=cs(e),!c)return po(e,s)}else{var h=is(e),g=h==de||h==fe;if(bu(e))return no(e,c);if(h==ge||h==ae||g&&!a){if(s=l||g?{}:ls(e),!c)return l?go(e,Ci(s,e)):ho(e,Si(s,e))}else{if(!on[h])return a?e:{};s=us(e,h,c)}}o||=new ci;var _=o.get(e);if(_)return _;o.set(e,s),Wu(e)?e.forEach(function(n){s.add(Di(n,t,r,n,e,o))}):Nu(e)&&e.forEach(function(n,i){s.set(i,Di(n,t,r,i,e,o))});var v=d?n:(u?l?qo:Ko:l?kd:Od)(e);return U(v||e,function(n,i){v&&(i=n,n=e[i]),yi(s,i,Di(n,t,r,i,e,o))}),s}function Oi(e){var t=Od(e);return function(n){return ki(n,e,t)}}function ki(e,t,r){var i=r.length;if(e==null)return!i;for(e=gt(e);i--;){var a=r[i],o=t[a],s=e[a];if(s===n&&!(a in e)||!o(s))return!1}return!0}function Ai(e,t,r){if(typeof e!=`function`)throw new yt(o);return Ms(function(){e.apply(n,r)},t)}function ji(e,t,n,r){var a=-1,o=jn,s=!0,c=e.length,l=[],u=t.length;if(!c)return l;n&&(t=Nn(t,tr(n))),r?(o=Mn,s=!1):t.length>=i&&(o=rr,s=!1,t=new ai(t));outer:for(;++a<c;){var d=e[a],f=n==null?d:n(d);if(d=r||d!==0?d:0,s&&f===f){for(var p=u;p--;)if(t[p]===f)continue outer;l.push(d)}else o(t,f,r)||l.push(d)}return l}var Mi=yo(Vi),Ni=yo(Hi,!0);function Pi(e,t){var n=!0;return Mi(e,function(e,r,i){return n=!!t(e,r,i),n}),n}function Fi(e,t,r){for(var i=-1,a=e.length;++i<a;){var o=e[i],s=t(o);if(s!=null&&(c===n?s===s&&!Ku(s):r(s,c)))var c=s,l=o}return l}function Ii(e,t,r,i){var a=e.length;for(r=td(r),r<0&&(r=-r>a?0:a+r),i=i===n||i>a?a:td(i),i<0&&(i+=a),i=r>i?0:nd(i);r<i;)e[r++]=t;return e}function Li(e,t){var n=[];return Mi(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function Ri(e,t,n,r,i){var a=-1,o=e.length;for(n||=fs,i||=[];++a<o;){var s=e[a];t>0&&n(s)?t>1?Ri(s,t-1,n,r,i):Pn(i,s):r||(i[i.length]=s)}return i}var zi=bo(),Bi=bo(!0);function Vi(e,t){return e&&zi(e,t,Od)}function Hi(e,t){return e&&Bi(e,t,Od)}function Ui(e,t){return An(t,function(t){return Ou(e[t])})}function Wi(e,t){t=Qa(t,e);for(var r=0,i=t.length;e!=null&&r<i;)e=e[Rs(t[r++])];return r&&r==i?e:n}function Gi(e,t,n){var r=t(e);return hu(e)?r:Pn(r,n(e))}function Ki(e){return e==null?e===n?Ce:he:Ht&&Ht in gt(e)?ts(e):Es(e)}function qi(e,t){return e>t}function Ji(e,t){return e!=null&&Tt.call(e,t)}function Yi(e,t){return e!=null&&t in gt(e)}function Xi(e,t,n){return e>=sn(t,n)&&e<tn(t,n)}function Zi(e,t,r){for(var i=r?Mn:jn,a=e[0].length,o=e.length,s=o,c=Qe(o),l=1/0,u=[];s--;){var d=e[s];s&&t&&(d=Nn(d,tr(t))),l=sn(d.length,l),c[s]=!r&&(t||a>=120&&d.length>=120)?new ai(s&&d):n}d=e[0];var f=-1,p=c[0];outer:for(;++f<a&&u.length<l;){var m=d[f],h=t?t(m):m;if(m=r||m!==0?m:0,!(p?rr(p,h):i(u,h,r))){for(s=o;--s;){var g=c[s];if(!(g?rr(g,h):i(e[s],h,r)))continue outer}p&&p.push(h),u.push(m)}}return u}function Qi(e,t,n,r){return Vi(e,function(e,i,a){t(r,n(e),i,a)}),r}function $i(e,t,r){t=Qa(t,e),e=Os(e,t);var i=e==null?e:e[Rs(fc(t))];return i==null?n:En(i,e,r)}function ea(e){return Mu(e)&&Ki(e)==ae}function ta(e){return Mu(e)&&Ki(e)==R}function na(e){return Mu(e)&&Ki(e)==L}function ra(e,t,n,r,i){return e===t?!0:e==null||t==null||!Mu(e)&&!Mu(t)?e!==e&&t!==t:ia(e,t,n,r,ra,i)}function ia(e,t,n,r,i,a){var o=hu(e),s=hu(t),c=o?oe:is(e),l=s?oe:is(t);c=c==ae?ge:c,l=l==ae?ge:l;var u=c==ge,d=l==ge,f=c==l;if(f&&bu(e)){if(!bu(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new ci,o||qu(e)?Ho(e,t,n,r,i,a):Uo(e,t,c,n,r,i,a);if(!(n&h)){var p=u&&Tt.call(e,`__wrapped__`),m=d&&Tt.call(t,`__wrapped__`);if(p||m){var g=p?e.value():e,_=m?t.value():t;return a||=new ci,i(g,_,n,r,a)}}return f?(a||=new ci,Wo(e,t,n,r,i,a)):!1}function aa(e){return Mu(e)&&is(e)==pe}function oa(e,t,r,i){var a=r.length,o=a,s=!i;if(e==null)return!o;for(e=gt(e);a--;){var c=r[a];if(s&&c[2]?c[1]!==e[c[0]]:!(c[0]in e))return!1}for(;++a<o;){c=r[a];var l=c[0],u=e[l],d=c[1];if(s&&c[2]){if(u===n&&!(l in e))return!1}else{var f=new ci;if(i)var p=i(u,d,l,e,t,f);if(!(p===n?ra(d,u,h|g,i,f):p))return!1}}return!0}function sa(e){return!ju(e)||vs(e)?!1:(Ou(e)?jt:lt).test(zs(e))}function ca(e){return Mu(e)&&Ki(e)==ye}function la(e){return Mu(e)&&is(e)==be}function ua(e){return Mu(e)&&Au(e.length)&&!!an[Ki(e)]}function da(e){return typeof e==`function`?e:e==null?Lf:typeof e==`object`?hu(e)?_a(e[0],e[1]):ga(e):Xf(e)}function fa(e){if(!bs(e))return en(e);var t=[];for(var n in gt(e))Tt.call(e,n)&&n!=`constructor`&&t.push(n);return t}function pa(e){if(!ju(e))return Ts(e);var t=bs(e),n=[];for(var r in e)r==`constructor`&&(t||!Tt.call(e,r))||n.push(r);return n}function ma(e,t){return e<t}function ha(e,t){var n=-1,r=_u(e)?Qe(e.length):[];return Mi(e,function(e,i,a){r[++n]=t(e,i,a)}),r}function ga(e){var t=$o(e);return t.length==1&&t[0][2]?Ss(t[0][0],t[0][1]):function(n){return n===e||oa(n,e,t)}}function _a(e,t){return hs(e)&&xs(t)?Ss(Rs(e),t):function(r){var i=Sd(r,e);return i===n&&i===t?wd(r,e):ra(t,i,h|g)}}function va(e,t,r,i,a){e!==t&&zi(t,function(o,s){if(a||=new ci,ju(o))ya(e,t,s,r,va,i,a);else{var c=i?i(As(e,s),o,s+``,e,t,a):n;c===n&&(c=o),vi(e,s,c)}},kd)}function ya(e,t,r,i,a,o,s){var c=As(e,r),l=As(t,r),u=s.get(l);if(u){vi(e,r,u);return}var d=o?o(c,l,r+``,e,t,s):n,f=d===n;if(f){var p=hu(l),m=!p&&bu(l),h=!p&&!m&&qu(l);d=l,p||m||h?hu(c)?d=c:vu(c)?d=po(c):m?(f=!1,d=no(l,!0)):h?(f=!1,d=so(l,!0)):d=[]:Vu(l)||mu(l)?(d=c,mu(c)?d=id(c):(!ju(c)||Ou(c))&&(d=ls(l))):f=!1}f&&(s.set(l,d),a(d,l,i,o,s),s.delete(l)),vi(e,r,d)}function ba(e,t){var r=e.length;if(r)return t+=t<0?r:0,ps(t,r)?e[t]:n}function xa(e,t,n){t=t.length?Nn(t,function(e){return hu(e)?function(t){return Wi(t,e.length===1?e[0]:e)}:e}):[Lf];var r=-1;return t=Nn(t,tr(Zo())),Xn(ha(e,function(e,n,i){return{criteria:Nn(t,function(t){return t(e)}),index:++r,value:e}}),function(e,t){return lo(e,t,n)})}function Sa(e,t){return Ca(e,t,function(t,n){return wd(e,n)})}function Ca(e,t,n){for(var r=-1,i=t.length,a={};++r<i;){var o=t[r],s=Wi(e,o);n(s,o)&&Na(a,Qa(o,e),s)}return a}function wa(e){return function(t){return Wi(t,e)}}function Ta(e,t,n,r){var i=r?Wn:Un,a=-1,o=t.length,s=e;for(e===t&&(t=po(t)),n&&(s=Nn(e,tr(n)));++a<o;)for(var c=0,l=t[a],u=n?n(l):l;(c=i(s,u,c,r))>-1;)s!==e&&zt.call(s,c,1),zt.call(e,c,1);return e}function Ea(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==a){var a=i;ps(i)?zt.call(e,i,1):Wa(e,i)}}return e}function Da(e,t){return e+Jt(un()*(t-e+1))}function Oa(e,t,n,r){for(var i=-1,a=tn(qt((t-e)/(n||1)),0),o=Qe(a);a--;)o[r?a:++i]=e,e+=n;return o}function ka(e,t){var n=``;if(!e||t<1||t>M)return n;do t%2&&(n+=e),t=Jt(t/2),t&&(e+=e);while(t);return n}function Aa(e,t){return Ns(Ds(e,t,Lf),e+``)}function ja(e){return hi(qd(e))}function Ma(e,t){var n=qd(e);return Is(n,Ei(t,0,n.length))}function Na(e,t,r,i){if(!ju(e))return e;t=Qa(t,e);for(var a=-1,o=t.length,s=o-1,c=e;c!=null&&++a<o;){var l=Rs(t[a]),u=r;if(l===`__proto__`||l===`constructor`||l===`prototype`)return e;if(a!=s){var d=c[l];u=i?i(d,l,c):n,u===n&&(u=ju(d)?d:ps(t[a+1])?[]:{})}yi(c,l,u),c=c[l]}return e}var Pa=zn?function(e,t){return zn.set(e,t),e}:Lf,Fa=Ut?function(e,t){return Ut(e,`toString`,{configurable:!0,enumerable:!1,value:Nf(t),writable:!0})}:Lf;function Ia(e){return Is(qd(e))}function La(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var a=Qe(i);++r<i;)a[r]=e[r+t];return a}function Ra(e,t){var n;return Mi(e,function(e,r,i){return n=t(e,r,i),!n}),!!n}function za(e,t,n){var r=0,i=e==null?r:e.length;if(typeof t==`number`&&t===t&&i<=re){for(;r<i;){var a=r+i>>>1,o=e[a];o!==null&&!Ku(o)&&(n?o<=t:o<t)?r=a+1:i=a}return i}return Ba(e,t,Lf,n)}function Ba(e,t,r,i){var a=0,o=e==null?0:e.length;if(o===0)return 0;t=r(t);for(var s=t!==t,c=t===null,l=Ku(t),u=t===n;a<o;){var d=Jt((a+o)/2),f=r(e[d]),p=f!==n,m=f===null,h=f===f,g=Ku(f);if(s)var _=i||h;else _=u?h&&(i||p):c?h&&p&&(i||!m):l?h&&p&&!m&&(i||!g):m||g?!1:i?f<=t:f<t;_?a=d+1:o=d}return sn(o,I)}function G(e,t){for(var n=-1,r=e.length,i=0,a=[];++n<r;){var o=e[n],s=t?t(o):o;if(!n||!du(s,c)){var c=s;a[i++]=o===0?0:o}}return a}function Va(e){return typeof e==`number`?e:Ku(e)?P:+e}function Ha(e){if(typeof e==`string`)return e;if(hu(e))return Nn(e,Ha)+``;if(Ku(e))return Nr?Nr.call(e):``;var t=e+``;return t==`0`&&1/e==-j?`-0`:t}function Ua(e,t,n){var r=-1,a=jn,o=e.length,s=!0,c=[],l=c;if(n)s=!1,a=Mn;else if(o>=i){var u=t?null:Io(e);if(u)return _r(u);s=!1,a=rr,l=new ai}else l=t?[]:c;outer:for(;++r<o;){var d=e[r],f=t?t(d):d;if(d=n||d!==0?d:0,s&&f===f){for(var p=l.length;p--;)if(l[p]===f)continue outer;t&&l.push(f),c.push(d)}else a(l,f,n)||(l!==c&&l.push(f),c.push(d))}return c}function Wa(e,t){t=Qa(t,e);var n=-1,r=t.length;if(!r)return!0;for(;++n<r;){var i=Rs(t[n]);if(i===`__proto__`&&!Tt.call(e,`__proto__`)||(i===`constructor`||i===`prototype`)&&n<r-1)return!1}var a=Os(e,t);return a==null||delete a[Rs(fc(t))]}function Ga(e,t,n,r){return Na(e,t,n(Wi(e,t)),r)}function Ka(e,t,n,r){for(var i=e.length,a=r?i:-1;(r?a--:++a<i)&&t(e[a],a,e););return n?La(e,r?0:a,r?a+1:i):La(e,r?a+1:0,r?i:a)}function qa(e,t){var n=e;return n instanceof Lr&&(n=n.value()),Fn(t,function(e,t){return t.func.apply(t.thisArg,Pn([e],t.args))},n)}function Ja(e,t,n){var r=e.length;if(r<2)return r?Ua(e[0]):[];for(var i=-1,a=Qe(r);++i<r;)for(var o=e[i],s=-1;++s<r;)s!=i&&(a[i]=ji(a[i]||o,e[s],t,n));return Ua(Ri(a,1),t,n)}function Ya(e,t,r){for(var i=-1,a=e.length,o=t.length,s={};++i<a;){var c=i<o?t[i]:n;r(s,e[i],c)}return s}function Xa(e){return vu(e)?e:[]}function Za(e){return typeof e==`function`?e:Lf}function Qa(e,t){return hu(e)?e:hs(e,t)?[e]:Ls(od(e))}var $a=Aa;function eo(e,t,r){var i=e.length;return r=r===n?i:r,!t&&r>=i?e:La(e,t,r)}var to=Wt||function(e){return mn.clearTimeout(e)};function no(e,t){if(t)return e.slice();var n=e.length,r=Ft?Ft(n):new e.constructor(n);return e.copy(r),r}function ro(e){var t=new e.constructor(e.byteLength);return new Pt(t).set(new Pt(e)),t}function io(e,t){var n=t?ro(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function ao(e){var t=new e.constructor(e.source,ot.exec(e));return t.lastIndex=e.lastIndex,t}function oo(e){return Mr?gt(Mr.call(e)):{}}function so(e,t){var n=t?ro(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function co(e,t){if(e!==t){var r=e!==n,i=e===null,a=e===e,o=Ku(e),s=t!==n,c=t===null,l=t===t,u=Ku(t);if(!c&&!u&&!o&&e>t||o&&s&&l&&!c&&!u||i&&s&&l||!r&&l||!a)return 1;if(!i&&!o&&!u&&e<t||u&&r&&a&&!i&&!o||c&&r&&a||!s&&a||!l)return-1}return 0}function lo(e,t,n){for(var r=-1,i=e.criteria,a=t.criteria,o=i.length,s=n.length;++r<o;){var c=co(i[r],a[r]);if(c)return r>=s?c:c*(n[r]==`desc`?-1:1)}return e.index-t.index}function uo(e,t,n,r){for(var i=-1,a=e.length,o=n.length,s=-1,c=t.length,l=tn(a-o,0),u=Qe(c+l),d=!r;++s<c;)u[s]=t[s];for(;++i<o;)(d||i<a)&&(u[n[i]]=e[i]);for(;l--;)u[s++]=e[i++];return u}function fo(e,t,n,r){for(var i=-1,a=e.length,o=-1,s=n.length,c=-1,l=t.length,u=tn(a-s,0),d=Qe(u+l),f=!r;++i<u;)d[i]=e[i];for(var p=i;++c<l;)d[p+c]=t[c];for(;++o<s;)(f||i<a)&&(d[p+n[o]]=e[i++]);return d}function po(e,t){var n=-1,r=e.length;for(t||=Qe(r);++n<r;)t[n]=e[n];return t}function mo(e,t,r,i){var a=!r;r||={};for(var o=-1,s=t.length;++o<s;){var c=t[o],l=i?i(r[c],e[c],c,r,e):n;l===n&&(l=e[c]),a?wi(r,c,l):yi(r,c,l)}return r}function ho(e,t){return mo(e,ns(e),t)}function go(e,t){return mo(e,rs(e),t)}function _o(e,t){return function(n,r){var i=hu(n)?Dn:xi,a=t?t():{};return i(n,e,Zo(r,2),a)}}function vo(e){return Aa(function(t,r){var i=-1,a=r.length,o=a>1?r[a-1]:n,s=a>2?r[2]:n;for(o=e.length>3&&typeof o==`function`?(a--,o):n,s&&ms(r[0],r[1],s)&&(o=a<3?n:o,a=1),t=gt(t);++i<a;){var c=r[i];c&&e(t,c,i,o)}return t})}function yo(e,t){return function(n,r){if(n==null)return n;if(!_u(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=gt(n);(t?a--:++a<i)&&r(o[a],a,o)!==!1;);return n}}function bo(e){return function(t,n,r){for(var i=-1,a=gt(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}function xo(e,t,n){var r=t&_,i=wo(e);function a(){return(this&&this!==mn&&this instanceof a?i:e).apply(r?n:this,arguments)}return a}function So(e){return function(t){t=od(t);var r=dr(t)?Sr(t):n,i=r?r[0]:t.charAt(0),a=r?eo(r,1).join(``):t.slice(1);return i[e]()+a}}function Co(e){return function(t){return Fn(Of(ef(t).replace(V,``)),e,``)}}function wo(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var n=Pr(e.prototype),r=e.apply(n,t);return ju(r)?r:n}}function To(e,t,r){var i=wo(e);function a(){for(var o=arguments.length,s=Qe(o),c=o,l=Xo(a);c--;)s[c]=arguments[c];var u=o<3&&s[0]!==l&&s[o-1]!==l?[]:gr(s,l);return o-=u.length,o<r?K(e,t,Oo,a.placeholder,n,s,u,n,n,r-o):En(this&&this!==mn&&this instanceof a?i:e,this,s)}return a}function Eo(e){return function(t,r,i){var a=gt(t);if(!_u(t)){var o=Zo(r,3);t=Od(t),r=function(e){return o(a[e],e,a)}}var s=e(t,r,i);return s>-1?a[o?t[s]:s]:n}}function Do(e){return Go(function(t){var r=t.length,i=r,a=Ir.prototype.thru;for(e&&t.reverse();i--;){var s=t[i];if(typeof s!=`function`)throw new yt(o);if(a&&!c&&Yo(s)==`wrapper`)var c=new Ir([],!0)}for(i=c?i:r;++i<r;){s=t[i];var l=Yo(s),u=l==`wrapper`?Jo(s):n;c=u&&_s(u[0])&&u[1]==(w|b|S|T)&&!u[4].length&&u[9]==1?c[Yo(u[0])].apply(c,u[3]):s.length==1&&_s(s)?c[l]():c.thru(s)}return function(){var e=arguments,n=e[0];if(c&&e.length==1&&hu(n))return c.plant(n).value();for(var i=0,a=r?t[i].apply(this,e):n;++i<r;)a=t[i].call(this,a);return a}})}function Oo(e,t,r,i,a,o,s,c,l,u){var d=t&w,f=t&_,p=t&v,m=t&(b|x),h=t&E,g=p?n:wo(e);function y(){for(var n=arguments.length,_=Qe(n),v=n;v--;)_[v]=arguments[v];if(m)var b=Xo(y),x=or(_,b);if(i&&(_=uo(_,i,a,m)),o&&(_=fo(_,o,s,m)),n-=x,m&&n<u){var S=gr(_,b);return K(e,t,Oo,y.placeholder,r,_,S,c,l,u-n)}var C=f?r:this,w=p?C[e]:e;return n=_.length,c?_=ks(_,c):h&&n>1&&_.reverse(),d&&l<n&&(_.length=l),this&&this!==mn&&this instanceof y&&(w=g||wo(w)),w.apply(C,_)}return y}function ko(e,t){return function(n,r){return Qi(n,e,t(r),{})}}function Ao(e,t){return function(r,i){var a;if(r===n&&i===n)return t;if(r!==n&&(a=r),i!==n){if(a===n)return i;typeof r==`string`||typeof i==`string`?(r=Ha(r),i=Ha(i)):(r=Va(r),i=Va(i)),a=e(r,i)}return a}}function jo(e){return Go(function(t){return t=Nn(t,tr(Zo())),Aa(function(n){var r=this;return e(t,function(e){return En(e,r,n)})})})}function Mo(e,t){t=t===n?` `:Ha(t);var r=t.length;if(r<2)return r?ka(t,e):t;var i=ka(t,qt(e/xr(t)));return dr(t)?eo(Sr(i),0,e).join(``):i.slice(0,e)}function No(e,t,n,r){var i=t&_,a=wo(e);function o(){for(var t=-1,s=arguments.length,c=-1,l=r.length,u=Qe(l+s),d=this&&this!==mn&&this instanceof o?a:e;++c<l;)u[c]=r[c];for(;s--;)u[c++]=arguments[++t];return En(d,i?n:this,u)}return o}function Po(e){return function(t,r,i){return i&&typeof i!=`number`&&ms(t,r,i)&&(r=i=n),t=ed(t),r===n?(r=t,t=0):r=ed(r),i=i===n?t<r?1:-1:ed(i),Oa(t,r,i,e)}}function Fo(e){return function(t,n){return typeof t==`string`&&typeof n==`string`||(t=rd(t),n=rd(n)),e(t,n)}}function K(e,t,r,i,a,o,s,c,l,u){var d=t&b,f=d?s:n,p=d?n:s,m=d?o:n,h=d?n:o;t|=d?S:C,t&=~(d?C:S),t&y||(t&=~(_|v));var g=[e,t,a,m,f,h,p,c,l,u],x=r.apply(n,g);return _s(e)&&js(x,g),x.placeholder=i,Ps(x,e,t)}function q(e){var t=ht[e];return function(e,n){if(e=rd(e),n=n==null?0:sn(td(n),292),n&&Qt(e)){var r=(od(e)+`e`).split(`e`);return r=(od(t(r[0]+`e`+(+r[1]+n)))+`e`).split(`e`),+(r[0]+`e`+(+r[1]-n))}return t(e)}}var Io=vn&&1/_r(new vn([,-0]))[1]==j?function(e){return new vn(e)}:Gf;function Lo(e){return function(t){var n=is(t);return n==pe?mr(t):n==be?vr(t):$n(t,e(t))}}function Ro(e,t,r,i,a,s,c,l){var u=t&v;if(!u&&typeof e!=`function`)throw new yt(o);var d=i?i.length:0;if(d||(t&=~(S|C),i=a=n),c=c===n?c:tn(td(c),0),l=l===n?l:td(l),d-=a?a.length:0,t&C){var f=i,p=a;i=a=n}var m=u?n:Jo(e),h=[e,t,r,i,a,f,p,s,c,l];if(m&&ws(h,m),e=h[0],t=h[1],r=h[2],i=h[3],a=h[4],l=h[9]=h[9]===n?u?0:e.length:tn(h[9]-d,0),!l&&t&(b|x)&&(t&=~(b|x)),!t||t==_)var g=xo(e,t,r);else g=t==b||t==x?To(e,t,l):(t==S||t==(_|S))&&!a.length?No(e,t,r,i):Oo.apply(n,h);return Ps((m?Pa:js)(g,h),e,t)}function zo(e,t,r,i){return e===n||du(e,St[r])&&!Tt.call(i,r)?t:e}function Bo(e,t,r,i,a,o){return ju(e)&&ju(t)&&(o.set(t,e),va(e,t,n,Bo,o),o.delete(t)),e}function Vo(e){return Vu(e)?n:e}function Ho(e,t,r,i,a,o){var s=r&h,c=e.length,l=t.length;if(c!=l&&!(s&&l>c))return!1;var u=o.get(e),d=o.get(t);if(u&&d)return u==t&&d==e;var f=-1,p=!0,m=r&g?new ai:n;for(o.set(e,t),o.set(t,e);++f<c;){var _=e[f],v=t[f];if(i)var y=s?i(v,_,f,t,e,o):i(_,v,f,e,t,o);if(y!==n){if(y)continue;p=!1;break}if(m){if(!Ln(t,function(e,t){if(!rr(m,t)&&(_===e||a(_,e,r,i,o)))return m.push(t)})){p=!1;break}}else if(!(_===v||a(_,v,r,i,o))){p=!1;break}}return o.delete(e),o.delete(t),p}function Uo(e,t,n,r,i,a,o){switch(n){case Ee:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case R:return!(e.byteLength!=t.byteLength||!a(new Pt(e),new Pt(t)));case ce:case L:case me:return du(+e,+t);case ue:return e.name==t.name&&e.message==t.message;case ye:case xe:return e==t+``;case pe:var s=mr;case be:var c=r&h;if(s||=_r,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=g,o.set(e,t);var u=Ho(s(e),s(t),r,i,a,o);return o.delete(e),u;case Se:if(Mr)return Mr.call(e)==Mr.call(t)}return!1}function Wo(e,t,r,i,a,o){var s=r&h,c=Ko(e),l=c.length;if(l!=Ko(t).length&&!s)return!1;for(var u=l;u--;){var d=c[u];if(!(s?d in t:Tt.call(t,d)))return!1}var f=o.get(e),p=o.get(t);if(f&&p)return f==t&&p==e;var m=!0;o.set(e,t),o.set(t,e);for(var g=s;++u<l;){d=c[u];var _=e[d],v=t[d];if(i)var y=s?i(v,_,d,t,e,o):i(_,v,d,e,t,o);if(!(y===n?_===v||a(_,v,r,i,o):y)){m=!1;break}g||=d==`constructor`}if(m&&!g){var b=e.constructor,x=t.constructor;b!=x&&`constructor`in e&&`constructor`in t&&!(typeof b==`function`&&b instanceof b&&typeof x==`function`&&x instanceof x)&&(m=!1)}return o.delete(e),o.delete(t),m}function Go(e){return Ns(Ds(e,n,tc),e+``)}function Ko(e){return Gi(e,Od,ns)}function qo(e){return Gi(e,kd,rs)}var Jo=zn?function(e){return zn.get(e)}:Gf;function Yo(e){for(var t=e.name+``,n=Jn[t],r=Tt.call(Jn,t)?n.length:0;r--;){var i=n[r],a=i.func;if(a==null||a==e)return i.name}return t}function Xo(e){return(Tt.call(W,`placeholder`)?W:e).placeholder}function Zo(){var e=W.iteratee||Rf;return e=e===Rf?da:e,arguments.length?e(arguments[0],arguments[1]):e}function Qo(e,t){var n=e.__data__;return gs(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function $o(e){for(var t=Od(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,xs(i)]}return t}function es(e,t){var r=ur(e,t);return sa(r)?r:n}function ts(e){var t=Tt.call(e,Ht),r=e[Ht];try{e[Ht]=n;var i=!0}catch{}var a=Ot.call(e);return i&&(t?e[Ht]=r:delete e[Ht]),a}var ns=Yt?function(e){return e==null?[]:(e=gt(e),An(Yt(e),function(t){return Rt.call(e,t)}))}:ep,rs=Yt?function(e){for(var t=[];e;)Pn(t,ns(e)),e=It(e);return t}:ep,is=Ki;(pn&&is(new pn(new ArrayBuffer(1)))!=Ee||hn&&is(new hn)!=pe||gn&&is(gn.resolve())!=_e||vn&&is(new vn)!=be||yn&&is(new yn)!=we)&&(is=function(e){var t=Ki(e),r=t==ge?e.constructor:n,i=r?zs(r):``;if(i)switch(i){case yr:return Ee;case Tr:return pe;case Er:return _e;case kr:return be;case Ar:return we}return t});function as(e,t,n){for(var r=-1,i=n.length;++r<i;){var a=n[r],o=a.size;switch(a.type){case`drop`:e+=o;break;case`dropRight`:t-=o;break;case`take`:t=sn(t,e+o);break;case`takeRight`:e=tn(e,t-o);break}}return{start:e,end:t}}function os(e){var t=e.match(et);return t?t[1].split(tt):[]}function ss(e,t,n){t=Qa(t,e);for(var r=-1,i=t.length,a=!1;++r<i;){var o=Rs(t[r]);if(!(a=e!=null&&n(e,o)))break;e=e[o]}return a||++r!=i?a:(i=e==null?0:e.length,!!i&&Au(i)&&ps(o,i)&&(hu(e)||mu(e)))}function cs(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]==`string`&&Tt.call(e,`index`)&&(n.index=e.index,n.input=e.input),n}function ls(e){return typeof e.constructor==`function`&&!bs(e)?Pr(It(e)):{}}function us(e,t,n){var r=e.constructor;switch(t){case R:return ro(e);case ce:case L:return new r(+e);case Ee:return io(e,n);case De:case Oe:case ke:case Ae:case je:case Me:case Ne:case Pe:case Fe:return so(e,n);case pe:return new r;case me:case xe:return new r(e);case ye:return ao(e);case be:return new r;case Se:return oo(e)}}function ds(e,t){var n=t.length;if(!n)return e;var r=n-1;return t[r]=(n>1?`& `:``)+t[r],t=t.join(n>2?`, `:` `),e.replace($e,`{
|
|
3
3
|
/* [wrapped with `+t+`] */
|
|
4
4
|
`)}function fs(e){return hu(e)||mu(e)||!!(Bt&&e&&e[Bt])}function ps(e,t){var n=typeof e;return t??=M,!!t&&(n==`number`||n!=`symbol`&&ut.test(e))&&e>-1&&e%1==0&&e<t}function ms(e,t,n){if(!ju(n))return!1;var r=typeof t;return(r==`number`?_u(n)&&ps(t,n.length):r==`string`&&t in n)?du(n[t],e):!1}function hs(e,t){if(hu(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||Ku(e)?!0:qe.test(e)||!Ke.test(e)||t!=null&&e in gt(t)}function gs(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function _s(e){var t=Yo(e),n=W[t];if(typeof n!=`function`||!(t in Lr.prototype))return!1;if(e===n)return!0;var r=Jo(n);return!!r&&e===r[0]}function vs(e){return!!Dt&&Dt in e}var ys=Ct?Ou:tp;function bs(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||St)}function xs(e){return e===e&&!ju(e)}function Ss(e,t){return function(r){return r==null?!1:r[e]===t&&(t!==n||e in gt(r))}}function Cs(e){var t=ql(e,function(e){return n.size===u&&n.clear(),e}),n=t.cache;return t}function ws(e,t){var n=e[1],r=t[1],i=n|r,a=i<(_|v|w),o=r==w&&n==b||r==w&&n==T&&e[7].length<=t[8]||r==(w|T)&&t[7].length<=t[8]&&n==b;if(!(a||o))return e;r&_&&(e[2]=t[2],i|=n&_?0:y);var s=t[3];if(s){var c=e[3];e[3]=c?uo(c,s,t[4]):s,e[4]=c?gr(e[3],d):t[4]}return s=t[5],s&&(c=e[5],e[5]=c?fo(c,s,t[6]):s,e[6]=c?gr(e[5],d):t[6]),s=t[7],s&&(e[7]=s),r&w&&(e[8]=e[8]==null?t[8]:sn(e[8],t[8])),e[9]??=t[9],e[0]=t[0],e[1]=i,e}function Ts(e){var t=[];if(e!=null)for(var n in gt(e))t.push(n);return t}function Es(e){return Ot.call(e)}function Ds(e,t,r){return t=tn(t===n?e.length-1:t,0),function(){for(var n=arguments,i=-1,a=tn(n.length-t,0),o=Qe(a);++i<a;)o[i]=n[t+i];i=-1;for(var s=Qe(t+1);++i<t;)s[i]=n[i];return s[t]=r(o),En(e,this,s)}}function Os(e,t){return t.length<2?e:Wi(e,La(t,0,-1))}function ks(e,t){for(var r=e.length,i=sn(t.length,r),a=po(e);i--;){var o=t[i];e[i]=ps(o,r)?a[o]:n}return e}function As(e,t){if(!(t===`constructor`&&typeof e[t]==`function`)&&t!=`__proto__`)return e[t]}var js=Fs(Pa),Ms=Kt||function(e,t){return mn.setTimeout(e,t)},Ns=Fs(Fa);function Ps(e,t,n){var r=t+``;return Ns(e,ds(r,Bs(os(r),n)))}function Fs(e){var t=0,r=0;return function(){var i=cn(),a=k-(i-r);if(r=i,a>0){if(++t>=ee)return arguments[0]}else t=0;return e.apply(n,arguments)}}function Is(e,t){var r=-1,i=e.length,a=i-1;for(t=t===n?i:t;++r<t;){var o=Da(r,a),s=e[o];e[o]=e[r],e[r]=s}return e.length=t,e}var Ls=Cs(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(Je,function(e,n,r,i){t.push(r?i.replace(it,`$1`):n||e)}),t});function Rs(e){if(typeof e==`string`||Ku(e))return e;var t=e+``;return t==`0`&&1/e==-j?`-0`:t}function zs(e){if(e!=null){try{return wt.call(e)}catch{}try{return e+``}catch{}}return``}function Bs(e,t){return U(ie,function(n){var r=`_.`+n[0];t&n[1]&&!jn(e,r)&&e.push(r)}),e.sort()}function Vs(e){if(e instanceof Lr)return e.clone();var t=new Ir(e.__wrapped__,e.__chain__);return t.__actions__=po(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}function Hs(e,t,r){t=(r?ms(e,t,r):t===n)?1:tn(td(t),0);var i=e==null?0:e.length;if(!i||t<1)return[];for(var a=0,o=0,s=Qe(qt(i/t));a<i;)s[o++]=La(e,a,a+=t);return s}function Us(e){for(var t=-1,n=e==null?0:e.length,r=0,i=[];++t<n;){var a=e[t];a&&(i[r++]=a)}return i}function Ws(){var e=arguments.length;if(!e)return[];for(var t=Qe(e-1),n=arguments[0],r=e;r--;)t[r-1]=arguments[r];return Pn(hu(n)?po(n):[n],Ri(t,1))}var Gs=Aa(function(e,t){return vu(e)?ji(e,Ri(t,1,vu,!0)):[]}),Ks=Aa(function(e,t){var r=fc(t);return vu(r)&&(r=n),vu(e)?ji(e,Ri(t,1,vu,!0),Zo(r,2)):[]}),qs=Aa(function(e,t){var r=fc(t);return vu(r)&&(r=n),vu(e)?ji(e,Ri(t,1,vu,!0),n,r):[]});function Js(e,t,r){var i=e==null?0:e.length;return i?(t=r||t===n?1:td(t),La(e,t<0?0:t,i)):[]}function Ys(e,t,r){var i=e==null?0:e.length;return i?(t=r||t===n?1:td(t),t=i-t,La(e,0,t<0?0:t)):[]}function Xs(e,t){return e&&e.length?Ka(e,Zo(t,3),!0,!0):[]}function Zs(e,t){return e&&e.length?Ka(e,Zo(t,3),!0):[]}function Qs(e,t,n,r){var i=e==null?0:e.length;return i?(n&&typeof n!=`number`&&ms(e,t,n)&&(n=0,r=i),Ii(e,t,n,r)):[]}function $s(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:td(n);return i<0&&(i=tn(r+i,0)),Hn(e,Zo(t,3),i)}function ec(e,t,r){var i=e==null?0:e.length;if(!i)return-1;var a=i-1;return r!==n&&(a=td(r),a=r<0?tn(i+a,0):sn(a,i-1)),Hn(e,Zo(t,3),a,!0)}function tc(e){return e!=null&&e.length?Ri(e,1):[]}function nc(e){return e!=null&&e.length?Ri(e,j):[]}function rc(e,t){return e!=null&&e.length?(t=t===n?1:td(t),Ri(e,t)):[]}function ic(e){for(var t=-1,n=e==null?0:e.length,r={};++t<n;){var i=e[t];wi(r,i[0],i[1])}return r}function ac(e){return e&&e.length?e[0]:n}function oc(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:td(n);return i<0&&(i=tn(r+i,0)),Un(e,t,i)}function sc(e){return e!=null&&e.length?La(e,0,-1):[]}var cc=Aa(function(e){var t=Nn(e,Xa);return t.length&&t[0]===e[0]?Zi(t):[]}),lc=Aa(function(e){var t=fc(e),r=Nn(e,Xa);return t===fc(r)?t=n:r.pop(),r.length&&r[0]===e[0]?Zi(r,Zo(t,2)):[]}),uc=Aa(function(e){var t=fc(e),r=Nn(e,Xa);return t=typeof t==`function`?t:n,t&&r.pop(),r.length&&r[0]===e[0]?Zi(r,n,t):[]});function dc(e,t){return e==null?``:$t.call(e,t)}function fc(e){var t=e==null?0:e.length;return t?e[t-1]:n}function pc(e,t,r){var i=e==null?0:e.length;if(!i)return-1;var a=i;return r!==n&&(a=td(r),a=a<0?tn(i+a,0):sn(a,i-1)),t===t?br(e,t,a):Hn(e,Gn,a,!0)}function mc(e,t){return e&&e.length?ba(e,td(t)):n}var hc=Aa(gc);function gc(e,t){return e&&e.length&&t&&t.length?Ta(e,t):e}function _c(e,t,n){return e&&e.length&&t&&t.length?Ta(e,t,Zo(n,2)):e}function vc(e,t,r){return e&&e.length&&t&&t.length?Ta(e,t,n,r):e}var yc=Go(function(e,t){var n=e==null?0:e.length,r=Ti(e,t);return Ea(e,Nn(t,function(e){return ps(e,n)?+e:e}).sort(co)),r});function bc(e,t){var n=[];if(!(e&&e.length))return n;var r=-1,i=[],a=e.length;for(t=Zo(t,3);++r<a;){var o=e[r];t(o,r,e)&&(n.push(o),i.push(r))}return Ea(e,i),n}function xc(e){return e==null?e:H.call(e)}function Sc(e,t,r){var i=e==null?0:e.length;return i?(r&&typeof r!=`number`&&ms(e,t,r)?(t=0,r=i):(t=t==null?0:td(t),r=r===n?i:td(r)),La(e,t,r)):[]}function Cc(e,t){return za(e,t)}function wc(e,t,n){return Ba(e,t,Zo(n,2))}function Tc(e,t){var n=e==null?0:e.length;if(n){var r=za(e,t);if(r<n&&du(e[r],t))return r}return-1}function Ec(e,t){return za(e,t,!0)}function Dc(e,t,n){return Ba(e,t,Zo(n,2),!0)}function Oc(e,t){if(e!=null&&e.length){var n=za(e,t,!0)-1;if(du(e[n],t))return n}return-1}function kc(e){return e&&e.length?G(e):[]}function Ac(e,t){return e&&e.length?G(e,Zo(t,2)):[]}function jc(e){var t=e==null?0:e.length;return t?La(e,1,t):[]}function Mc(e,t,r){return e&&e.length?(t=r||t===n?1:td(t),La(e,0,t<0?0:t)):[]}function Nc(e,t,r){var i=e==null?0:e.length;return i?(t=r||t===n?1:td(t),t=i-t,La(e,t<0?0:t,i)):[]}function Pc(e,t){return e&&e.length?Ka(e,Zo(t,3),!1,!0):[]}function Fc(e,t){return e&&e.length?Ka(e,Zo(t,3)):[]}var Ic=Aa(function(e){return Ua(Ri(e,1,vu,!0))}),Lc=Aa(function(e){var t=fc(e);return vu(t)&&(t=n),Ua(Ri(e,1,vu,!0),Zo(t,2))}),Rc=Aa(function(e){var t=fc(e);return t=typeof t==`function`?t:n,Ua(Ri(e,1,vu,!0),n,t)});function zc(e){return e&&e.length?Ua(e):[]}function Bc(e,t){return e&&e.length?Ua(e,Zo(t,2)):[]}function Vc(e,t){return t=typeof t==`function`?t:n,e&&e.length?Ua(e,n,t):[]}function Hc(e){if(!(e&&e.length))return[];var t=0;return e=An(e,function(e){if(vu(e))return t=tn(e.length,t),!0}),Qn(t,function(t){return Nn(e,qn(t))})}function Uc(e,t){if(!(e&&e.length))return[];var r=Hc(e);return t==null?r:Nn(r,function(e){return En(t,n,e)})}var Wc=Aa(function(e,t){return vu(e)?ji(e,t):[]}),Gc=Aa(function(e){return Ja(An(e,vu))}),Kc=Aa(function(e){var t=fc(e);return vu(t)&&(t=n),Ja(An(e,vu),Zo(t,2))}),qc=Aa(function(e){var t=fc(e);return t=typeof t==`function`?t:n,Ja(An(e,vu),n,t)}),Jc=Aa(Hc);function Yc(e,t){return Ya(e||[],t||[],yi)}function Xc(e,t){return Ya(e||[],t||[],Na)}var Zc=Aa(function(e){var t=e.length,r=t>1?e[t-1]:n;return r=typeof r==`function`?(e.pop(),r):n,Uc(e,r)});function Qc(e){var t=W(e);return t.__chain__=!0,t}function $c(e,t){return t(e),e}function el(e,t){return t(e)}var tl=Go(function(e){var t=e.length,r=t?e[0]:0,i=this.__wrapped__,a=function(t){return Ti(t,e)};return t>1||this.__actions__.length||!(i instanceof Lr)||!ps(r)?this.thru(a):(i=i.slice(r,+r+ +!!t),i.__actions__.push({func:el,args:[a],thisArg:n}),new Ir(i,this.__chain__).thru(function(e){return t&&!e.length&&e.push(n),e}))});function nl(){return Qc(this)}function rl(){return new Ir(this.value(),this.__chain__)}function il(){this.__values__===n&&(this.__values__=$u(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?n:this.__values__[this.__index__++]}}function al(){return this}function ol(e){for(var t,r=this;r instanceof Fr;){var i=Vs(r);i.__index__=0,i.__values__=n,t?a.__wrapped__=i:t=i;var a=i;r=r.__wrapped__}return a.__wrapped__=e,t}function sl(){var e=this.__wrapped__;if(e instanceof Lr){var t=e;return this.__actions__.length&&(t=new Lr(this)),t=t.reverse(),t.__actions__.push({func:el,args:[xc],thisArg:n}),new Ir(t,this.__chain__)}return this.thru(xc)}function cl(){return qa(this.__wrapped__,this.__actions__)}var ll=_o(function(e,t,n){Tt.call(e,n)?++e[n]:wi(e,n,1)});function ul(e,t,r){var i=hu(e)?kn:Pi;return r&&ms(e,t,r)&&(t=n),i(e,Zo(t,3))}function dl(e,t){return(hu(e)?An:Li)(e,Zo(t,3))}var fl=Eo($s),pl=Eo(ec);function ml(e,t){return Ri(Cl(e,t),1)}function hl(e,t){return Ri(Cl(e,t),j)}function gl(e,t,r){return r=r===n?1:td(r),Ri(Cl(e,t),r)}function _l(e,t){return(hu(e)?U:Mi)(e,Zo(t,3))}function vl(e,t){return(hu(e)?On:Ni)(e,Zo(t,3))}var yl=_o(function(e,t,n){Tt.call(e,n)?e[n].push(t):wi(e,n,[t])});function bl(e,t,n,r){e=_u(e)?e:qd(e),n=n&&!r?td(n):0;var i=e.length;return n<0&&(n=tn(i+n,0)),Gu(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&Un(e,t,n)>-1}var xl=Aa(function(e,t,n){var r=-1,i=typeof t==`function`,a=_u(e)?Qe(e.length):[];return Mi(e,function(e){a[++r]=i?En(t,e,n):$i(e,t,n)}),a}),Sl=_o(function(e,t,n){wi(e,n,t)});function Cl(e,t){return(hu(e)?Nn:ha)(e,Zo(t,3))}function wl(e,t,r,i){return e==null?[]:(hu(t)||(t=t==null?[]:[t]),r=i?n:r,hu(r)||(r=r==null?[]:[r]),xa(e,t,r))}var Tl=_o(function(e,t,n){e[+!n].push(t)},function(){return[[],[]]});function El(e,t,n){var r=hu(e)?Fn:Yn,i=arguments.length<3;return r(e,Zo(t,4),n,i,Mi)}function Dl(e,t,n){var r=hu(e)?In:Yn,i=arguments.length<3;return r(e,Zo(t,4),n,i,Ni)}function Ol(e,t){return(hu(e)?An:Li)(e,Jl(Zo(t,3)))}function kl(e){return(hu(e)?hi:ja)(e)}function Al(e,t,r){return t=(r?ms(e,t,r):t===n)?1:td(t),(hu(e)?gi:Ma)(e,t)}function jl(e){return(hu(e)?_i:Ia)(e)}function Ml(e){if(e==null)return 0;if(_u(e))return Gu(e)?xr(e):e.length;var t=is(e);return t==pe||t==be?e.size:fa(e).length}function Nl(e,t,r){var i=hu(e)?Ln:Ra;return r&&ms(e,t,r)&&(t=n),i(e,Zo(t,3))}var Pl=Aa(function(e,t){if(e==null)return[];var n=t.length;return n>1&&ms(e,t[0],t[1])?t=[]:n>2&&ms(t[0],t[1],t[2])&&(t=[t[0]]),xa(e,Ri(t,1),[])}),Fl=Gt||function(){return mn.Date.now()};function Il(e,t){if(typeof t!=`function`)throw new yt(o);return e=td(e),function(){if(--e<1)return t.apply(this,arguments)}}function Ll(e,t,r){return t=r?n:t,t=e&&t==null?e.length:t,Ro(e,w,n,n,n,n,t)}function Rl(e,t){var r;if(typeof t!=`function`)throw new yt(o);return e=td(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=n),r}}var zl=Aa(function(e,t,n){var r=_;if(n.length){var i=gr(n,Xo(zl));r|=S}return Ro(e,r,t,n,i)}),Bl=Aa(function(e,t,n){var r=_|v;if(n.length){var i=gr(n,Xo(Bl));r|=S}return Ro(t,r,e,n,i)});function Vl(e,t,r){t=r?n:t;var i=Ro(e,b,n,n,n,n,n,t);return i.placeholder=Vl.placeholder,i}function Hl(e,t,r){t=r?n:t;var i=Ro(e,x,n,n,n,n,n,t);return i.placeholder=Hl.placeholder,i}function Ul(e,t,r){var i,a,s,c,l,u,d=0,f=!1,p=!1,m=!0;if(typeof e!=`function`)throw new yt(o);t=rd(t)||0,ju(r)&&(f=!!r.leading,p=`maxWait`in r,s=p?tn(rd(r.maxWait)||0,t):s,m=`trailing`in r?!!r.trailing:m);function h(t){var r=i,o=a;return i=a=n,d=t,c=e.apply(o,r),c}function g(e){return d=e,l=Ms(y,t),f?h(e):c}function _(e){var n=e-u,r=e-d,i=t-n;return p?sn(i,s-r):i}function v(e){var r=e-u,i=e-d;return u===n||r>=t||r<0||p&&i>=s}function y(){var e=Fl();if(v(e))return b(e);l=Ms(y,_(e))}function b(e){return l=n,m&&i?h(e):(i=a=n,c)}function x(){l!==n&&to(l),d=0,i=u=a=l=n}function S(){return l===n?c:b(Fl())}function C(){var e=Fl(),r=v(e);if(i=arguments,a=this,u=e,r){if(l===n)return g(u);if(p)return to(l),l=Ms(y,t),h(u)}return l===n&&(l=Ms(y,t)),c}return C.cancel=x,C.flush=S,C}var Wl=Aa(function(e,t){return Ai(e,1,t)}),Gl=Aa(function(e,t,n){return Ai(e,rd(t)||0,n)});function Kl(e){return Ro(e,E)}function ql(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw new yt(o);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(ql.Cache||$r),n}ql.Cache=$r;function Jl(e){if(typeof e!=`function`)throw new yt(o);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}function Yl(e){return Rl(2,e)}var Xl=$a(function(e,t){t=t.length==1&&hu(t[0])?Nn(t[0],tr(Zo())):Nn(Ri(t,1),tr(Zo()));var n=t.length;return Aa(function(r){for(var i=-1,a=sn(r.length,n);++i<a;)r[i]=t[i].call(this,r[i]);return En(e,this,r)})}),Zl=Aa(function(e,t){return Ro(e,S,n,t,gr(t,Xo(Zl)))}),Ql=Aa(function(e,t){return Ro(e,C,n,t,gr(t,Xo(Ql)))}),$l=Go(function(e,t){return Ro(e,T,n,n,n,t)});function eu(e,t){if(typeof e!=`function`)throw new yt(o);return t=t===n?t:td(t),Aa(e,t)}function tu(e,t){if(typeof e!=`function`)throw new yt(o);return t=t==null?0:tn(td(t),0),Aa(function(n){var r=n[t],i=eo(n,0,t);return r&&Pn(i,r),En(e,this,i)})}function nu(e,t,n){var r=!0,i=!0;if(typeof e!=`function`)throw new yt(o);return ju(n)&&(r=`leading`in n?!!n.leading:r,i=`trailing`in n?!!n.trailing:i),Ul(e,t,{leading:r,maxWait:t,trailing:i})}function ru(e){return Ll(e,1)}function iu(e,t){return Zl(Za(t),e)}function au(){if(!arguments.length)return[];var e=arguments[0];return hu(e)?e:[e]}function ou(e){return Di(e,m)}function su(e,t){return t=typeof t==`function`?t:n,Di(e,m,t)}function cu(e){return Di(e,f|m)}function lu(e,t){return t=typeof t==`function`?t:n,Di(e,f|m,t)}function uu(e,t){return t==null||ki(e,t,Od(t))}function du(e,t){return e===t||e!==e&&t!==t}var fu=Fo(qi),pu=Fo(function(e,t){return e>=t}),mu=ea(function(){return arguments}())?ea:function(e){return Mu(e)&&Tt.call(e,`callee`)&&!Rt.call(e,`callee`)},hu=Qe.isArray,gu=bn?tr(bn):ta;function _u(e){return e!=null&&Au(e.length)&&!Ou(e)}function vu(e){return Mu(e)&&_u(e)}function yu(e){return e===!0||e===!1||Mu(e)&&Ki(e)==ce}var bu=Xt||tp,xu=xn?tr(xn):na;function Su(e){return Mu(e)&&e.nodeType===1&&!Vu(e)}function Cu(e){if(e==null)return!0;if(_u(e)&&(hu(e)||typeof e==`string`||typeof e.splice==`function`||bu(e)||qu(e)||mu(e)))return!e.length;var t=is(e);if(t==pe||t==be)return!e.size;if(bs(e))return!fa(e).length;for(var n in e)if(Tt.call(e,n))return!1;return!0}function wu(e,t){return ra(e,t)}function Tu(e,t,r){r=typeof r==`function`?r:n;var i=r?r(e,t):n;return i===n?ra(e,t,n,r):!!i}function Eu(e){if(!Mu(e))return!1;var t=Ki(e);return t==ue||t==le||typeof e.message==`string`&&typeof e.name==`string`&&!Vu(e)}function Du(e){return typeof e==`number`&&Qt(e)}function Ou(e){if(!ju(e))return!1;var t=Ki(e);return t==de||t==fe||t==se||t==ve}function ku(e){return typeof e==`number`&&e==td(e)}function Au(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=M}function ju(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}function Mu(e){return typeof e==`object`&&!!e}var Nu=Sn?tr(Sn):aa;function Pu(e,t){return e===t||oa(e,t,$o(t))}function Fu(e,t,r){return r=typeof r==`function`?r:n,oa(e,t,$o(t),r)}function Iu(e){return Bu(e)&&e!=+e}function Lu(e){if(ys(e))throw new pt(a);return sa(e)}function Ru(e){return e===null}function zu(e){return e==null}function Bu(e){return typeof e==`number`||Mu(e)&&Ki(e)==me}function Vu(e){if(!Mu(e)||Ki(e)!=ge)return!1;var t=It(e);if(t===null)return!0;var n=Tt.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&wt.call(n)==kt}var Hu=Cn?tr(Cn):ca;function Uu(e){return ku(e)&&e>=-M&&e<=M}var Wu=wn?tr(wn):la;function Gu(e){return typeof e==`string`||!hu(e)&&Mu(e)&&Ki(e)==xe}function Ku(e){return typeof e==`symbol`||Mu(e)&&Ki(e)==Se}var qu=Tn?tr(Tn):ua;function Ju(e){return e===n}function Yu(e){return Mu(e)&&is(e)==we}function Xu(e){return Mu(e)&&Ki(e)==Te}var Zu=Fo(ma),Qu=Fo(function(e,t){return e<=t});function $u(e){if(!e)return[];if(_u(e))return Gu(e)?Sr(e):po(e);if(Vt&&e[Vt])return pr(e[Vt]());var t=is(e);return(t==pe?mr:t==be?_r:qd)(e)}function ed(e){return e?(e=rd(e),e===j||e===-j?(e<0?-1:1)*N:e===e?e:0):e===0?e:0}function td(e){var t=ed(e),n=t%1;return t===t?n?t-n:t:0}function nd(e){return e?Ei(td(e),0,F):0}function rd(e){if(typeof e==`number`)return e;if(Ku(e))return P;if(ju(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=ju(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=er(e);var n=ct.test(e);return n||z.test(e)?fn(e.slice(2),n?2:8):st.test(e)?P:+e}function id(e){return mo(e,kd(e))}function ad(e){return e?Ei(td(e),-M,M):e===0?e:0}function od(e){return e==null?``:Ha(e)}var sd=vo(function(e,t){if(bs(t)||_u(t)){mo(t,Od(t),e);return}for(var n in t)Tt.call(t,n)&&yi(e,n,t[n])}),cd=vo(function(e,t){mo(t,kd(t),e)}),ld=vo(function(e,t,n,r){mo(t,kd(t),e,r)}),ud=vo(function(e,t,n,r){mo(t,Od(t),e,r)}),dd=Go(Ti);function fd(e,t){var n=Pr(e);return t==null?n:Si(n,t)}var pd=Aa(function(e,t){e=gt(e);var r=-1,i=t.length,a=i>2?t[2]:n;for(a&&ms(t[0],t[1],a)&&(i=1);++r<i;)for(var o=t[r],s=kd(o),c=-1,l=s.length;++c<l;){var u=s[c],d=e[u];(d===n||du(d,St[u])&&!Tt.call(e,u))&&(e[u]=o[u])}return e}),md=Aa(function(e){return e.push(n,Bo),En(Nd,n,e)});function hd(e,t){return Vn(e,Zo(t,3),Vi)}function gd(e,t){return Vn(e,Zo(t,3),Hi)}function _d(e,t){return e==null?e:zi(e,Zo(t,3),kd)}function J(e,t){return e==null?e:Bi(e,Zo(t,3),kd)}function vd(e,t){return e&&Vi(e,Zo(t,3))}function yd(e,t){return e&&Hi(e,Zo(t,3))}function bd(e){return e==null?[]:Ui(e,Od(e))}function xd(e){return e==null?[]:Ui(e,kd(e))}function Sd(e,t,r){var i=e==null?n:Wi(e,t);return i===n?r:i}function Cd(e,t){return e!=null&&ss(e,t,Ji)}function wd(e,t){return e!=null&&ss(e,t,Yi)}var Td=ko(function(e,t,n){t!=null&&typeof t.toString!=`function`&&(t=Ot.call(t)),e[t]=n},Nf(Lf)),Ed=ko(function(e,t,n){t!=null&&typeof t.toString!=`function`&&(t=Ot.call(t)),Tt.call(e,t)?e[t].push(n):e[t]=[n]},Zo),Dd=Aa($i);function Od(e){return _u(e)?mi(e):fa(e)}function kd(e){return _u(e)?mi(e,!0):pa(e)}function Ad(e,t){var n={};return t=Zo(t,3),Vi(e,function(e,r,i){wi(n,t(e,r,i),e)}),n}function jd(e,t){var n={};return t=Zo(t,3),Vi(e,function(e,r,i){wi(n,r,t(e,r,i))}),n}var Md=vo(function(e,t,n){va(e,t,n)}),Nd=vo(function(e,t,n,r){va(e,t,n,r)}),Pd=Go(function(e,t){var n={};if(e==null)return n;var r=!1;t=Nn(t,function(t){return t=Qa(t,e),r||=t.length>1,t}),mo(e,qo(e),n),r&&(n=Di(n,f|p|m,Vo));for(var i=t.length;i--;)Wa(n,t[i]);return n});function Fd(e,t){return Ld(e,Jl(Zo(t)))}var Id=Go(function(e,t){return e==null?{}:Sa(e,t)});function Ld(e,t){if(e==null)return{};var n=Nn(qo(e),function(e){return[e]});return t=Zo(t),Ca(e,n,function(e,n){return t(e,n[0])})}function Rd(e,t,r){t=Qa(t,e);var i=-1,a=t.length;for(a||(a=1,e=n);++i<a;){var o=e==null?n:e[Rs(t[i])];o===n&&(i=a,o=r),e=Ou(o)?o.call(e):o}return e}function zd(e,t,n){return e==null?e:Na(e,t,n)}function Bd(e,t,r,i){return i=typeof i==`function`?i:n,e==null?e:Na(e,t,r,i)}var Vd=Lo(Od),Hd=Lo(kd);function Ud(e,t,n){var r=hu(e),i=r||bu(e)||qu(e);if(t=Zo(t,4),n==null){var a=e&&e.constructor;n=i?r?new a:[]:ju(e)&&Ou(a)?Pr(It(e)):{}}return(i?U:Vi)(e,function(e,r,i){return t(n,e,r,i)}),n}function Wd(e,t){return e==null?!0:Wa(e,t)}function Gd(e,t,n){return e==null?e:Ga(e,t,Za(n))}function Kd(e,t,r,i){return i=typeof i==`function`?i:n,e==null?e:Ga(e,t,Za(r),i)}function qd(e){return e==null?[]:nr(e,Od(e))}function Jd(e){return e==null?[]:nr(e,kd(e))}function Yd(e,t,r){return r===n&&(r=t,t=n),r!==n&&(r=rd(r),r=r===r?r:0),t!==n&&(t=rd(t),t=t===t?t:0),Ei(rd(e),t,r)}function Xd(e,t,r){return t=ed(t),r===n?(r=t,t=0):r=ed(r),e=rd(e),Xi(e,t,r)}function Zd(e,t,r){if(r&&typeof r!=`boolean`&&ms(e,t,r)&&(t=r=n),r===n&&(typeof t==`boolean`?(r=t,t=n):typeof e==`boolean`&&(r=e,e=n)),e===n&&t===n?(e=0,t=1):(e=ed(e),t===n?(t=e,e=0):t=ed(t)),e>t){var i=e;e=t,t=i}if(r||e%1||t%1){var a=un();return sn(e+a*(t-e+dn(`1e-`+((a+``).length-1))),t)}return Da(e,t)}var Qd=Co(function(e,t,n){return t=t.toLowerCase(),e+(n?$d(t):t)});function $d(e){return Df(od(e).toLowerCase())}function ef(e){return e=od(e),e&&e.replace(B,sr).replace(Zt,``)}function tf(e,t,r){e=od(e),t=Ha(t);var i=e.length;r=r===n?i:Ei(td(r),0,i);var a=r;return r-=t.length,r>=0&&e.slice(r,a)==t}function nf(e){return e=od(e),e&&He.test(e)?e.replace(Be,cr):e}function rf(e){return e=od(e),e&&Xe.test(e)?e.replace(Ye,`\\$&`):e}var af=Co(function(e,t,n){return e+(n?`-`:``)+t.toLowerCase()}),of=Co(function(e,t,n){return e+(n?` `:``)+t.toLowerCase()}),sf=So(`toLowerCase`);function cf(e,t,n){e=od(e),t=td(t);var r=t?xr(e):0;if(!t||r>=t)return e;var i=(t-r)/2;return Mo(Jt(i),n)+e+Mo(qt(i),n)}function lf(e,t,n){e=od(e),t=td(t);var r=t?xr(e):0;return t&&r<t?e+Mo(t-r,n):e}function uf(e,t,n){e=od(e),t=td(t);var r=t?xr(e):0;return t&&r<t?Mo(t-r,n)+e:e}function df(e,t,n){return n||t==null?t=0:t&&=+t,ln(od(e).replace(Ze,``),t||0)}function ff(e,t,r){return t=(r?ms(e,t,r):t===n)?1:td(t),ka(od(e),t)}function pf(){var e=arguments,t=od(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var mf=Co(function(e,t,n){return e+(n?`_`:``)+t.toLowerCase()});function hf(e,t,r){return r&&typeof r!=`number`&&ms(e,t,r)&&(t=r=n),r=r===n?F:r>>>0,r?(e=od(e),e&&(typeof t==`string`||t!=null&&!Hu(t))&&(t=Ha(t),!t&&dr(e))?eo(Sr(e),0,r):e.split(t,r)):[]}var gf=Co(function(e,t,n){return e+(n?` `:``)+Df(t)});function _f(e,t,n){return e=od(e),n=n==null?0:Ei(td(n),0,e.length),t=Ha(t),e.slice(n,n+t.length)==t}function vf(e,t,r){var i=W.templateSettings;r&&ms(e,t,r)&&(t=n),e=od(e),t=ud({},t,i,zo);var a=ud({},t.imports,i.imports,zo),o=Od(a),l=nr(a,o);U(o,function(e){if(rt.test(e))throw new pt(c)});var u,d,f=0,p=t.interpolate||dt,m=`__p += '`,h=_t((t.escape||dt).source+`|`+p.source+`|`+(p===Ge?at:dt).source+`|`+(t.evaluate||dt).source+`|$`,`g`),g=`//# sourceURL=`+(Tt.call(t,`sourceURL`)?(t.sourceURL+``).replace(/\s/g,` `):`lodash.templateSources[`+ ++rn+`]`)+`
|
|
5
5
|
`;e.replace(h,function(t,n,r,i,a,o){return r||=i,m+=e.slice(f,o).replace(ft,lr),n&&(u=!0,m+=`' +
|
|
@@ -20,7 +20,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
20
20
|
`)+m+`return __p
|
|
21
21
|
}`;var v=kf(function(){return mt(o,g+`return `+m).apply(n,l)});if(v.source=m,Eu(v))throw v;return v}function yf(e){return od(e).toLowerCase()}function bf(e){return od(e).toUpperCase()}function xf(e,t,r){if(e=od(e),e&&(r||t===n))return er(e);if(!e||!(t=Ha(t)))return e;var i=Sr(e),a=Sr(t);return eo(i,ir(i,a),ar(i,a)+1).join(``)}function Sf(e,t,r){if(e=od(e),e&&(r||t===n))return e.slice(0,Cr(e)+1);if(!e||!(t=Ha(t)))return e;var i=Sr(e);return eo(i,0,ar(i,Sr(t))+1).join(``)}function Cf(e,t,r){if(e=od(e),e&&(r||t===n))return e.replace(Ze,``);if(!e||!(t=Ha(t)))return e;var i=Sr(e);return eo(i,ir(i,Sr(t))).join(``)}function wf(e,t){var r=D,i=O;if(ju(t)){var a=`separator`in t?t.separator:a;r=`length`in t?td(t.length):r,i=`omission`in t?Ha(t.omission):i}e=od(e);var o=e.length;if(dr(e)){var s=Sr(e);o=s.length}if(r>=o)return e;var c=r-xr(i);if(c<1)return i;var l=s?eo(s,0,c).join(``):e.slice(0,c);if(a===n)return l+i;if(s&&(c+=l.length-c),Hu(a)){if(e.slice(c).search(a)){var u,d=l;for(a.global||(a=_t(a.source,od(ot.exec(a))+`g`)),a.lastIndex=0;u=a.exec(d);)var f=u.index;l=l.slice(0,f===n?c:f)}}else if(e.indexOf(Ha(a),c)!=c){var p=l.lastIndexOf(a);p>-1&&(l=l.slice(0,p))}return l+i}function Tf(e){return e=od(e),e&&Ve.test(e)?e.replace(ze,wr):e}var Ef=Co(function(e,t,n){return e+(n?` `:``)+t.toUpperCase()}),Df=So(`toUpperCase`);function Of(e,t,r){return e=od(e),t=r?n:t,t===n?fr(e)?Dr(e):Bn(e):e.match(t)||[]}var kf=Aa(function(e,t){try{return En(e,n,t)}catch(e){return Eu(e)?e:new pt(e)}}),Af=Go(function(e,t){return U(t,function(t){t=Rs(t),wi(e,t,zl(e[t],e))}),e});function jf(e){var t=e==null?0:e.length,n=Zo();return e=t?Nn(e,function(e){if(typeof e[1]!=`function`)throw new yt(o);return[n(e[0]),e[1]]}):[],Aa(function(n){for(var r=-1;++r<t;){var i=e[r];if(En(i[0],this,n))return En(i[1],this,n)}})}function Mf(e){return Oi(Di(e,f))}function Nf(e){return function(){return e}}function Pf(e,t){return e==null||e!==e?t:e}var Ff=Do(),If=Do(!0);function Lf(e){return e}function Rf(e){return da(typeof e==`function`?e:Di(e,f))}function zf(e){return ga(Di(e,f))}function Bf(e,t){return _a(e,Di(t,f))}var Vf=Aa(function(e,t){return function(n){return $i(n,e,t)}}),Hf=Aa(function(e,t){return function(n){return $i(e,n,t)}});function Uf(e,t,n){var r=Od(t),i=Ui(t,r);n==null&&!(ju(t)&&(i.length||!r.length))&&(n=t,t=e,e=this,i=Ui(t,Od(t)));var a=!(ju(n)&&`chain`in n)||!!n.chain,o=Ou(e);return U(i,function(n){var r=t[n];e[n]=r,o&&(e.prototype[n]=function(){var t=this.__chain__;if(a||t){var n=e(this.__wrapped__);return(n.__actions__=po(this.__actions__)).push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,Pn([this.value()],arguments))})}),e}function Wf(){return mn._===this&&(mn._=At),this}function Gf(){}function Kf(e){return e=td(e),Aa(function(t){return ba(t,e)})}var qf=jo(Nn),Jf=jo(kn),Yf=jo(Ln);function Xf(e){return hs(e)?qn(Rs(e)):wa(e)}function Zf(e){return function(t){return e==null?n:Wi(e,t)}}var Qf=Po(),$f=Po(!0);function ep(){return[]}function tp(){return!1}function np(){return{}}function rp(){return``}function ip(){return!0}function ap(e,t){if(e=td(e),e<1||e>M)return[];var n=F,r=sn(e,F);t=Zo(t),e-=F;for(var i=Qn(r,t);++n<e;)t(n);return i}function op(e){return hu(e)?Nn(e,Rs):Ku(e)?[e]:po(Ls(od(e)))}function sp(e){var t=++Et;return od(e)+t}var cp=Ao(function(e,t){return e+t},0),lp=q(`ceil`),up=Ao(function(e,t){return e/t},1),dp=q(`floor`);function fp(e){return e&&e.length?Fi(e,Lf,qi):n}function pp(e,t){return e&&e.length?Fi(e,Zo(t,2),qi):n}function mp(e){return Kn(e,Lf)}function hp(e,t){return Kn(e,Zo(t,2))}function gp(e){return e&&e.length?Fi(e,Lf,ma):n}function _p(e,t){return e&&e.length?Fi(e,Zo(t,2),ma):n}var vp=Ao(function(e,t){return e*t},1),yp=q(`round`),bp=Ao(function(e,t){return e-t},0);function xp(e){return e&&e.length?Zn(e,Lf):0}function Sp(e,t){return e&&e.length?Zn(e,Zo(t,2)):0}return W.after=Il,W.ary=Ll,W.assign=sd,W.assignIn=cd,W.assignInWith=ld,W.assignWith=ud,W.at=dd,W.before=Rl,W.bind=zl,W.bindAll=Af,W.bindKey=Bl,W.castArray=au,W.chain=Qc,W.chunk=Hs,W.compact=Us,W.concat=Ws,W.cond=jf,W.conforms=Mf,W.constant=Nf,W.countBy=ll,W.create=fd,W.curry=Vl,W.curryRight=Hl,W.debounce=Ul,W.defaults=pd,W.defaultsDeep=md,W.defer=Wl,W.delay=Gl,W.difference=Gs,W.differenceBy=Ks,W.differenceWith=qs,W.drop=Js,W.dropRight=Ys,W.dropRightWhile=Xs,W.dropWhile=Zs,W.fill=Qs,W.filter=dl,W.flatMap=ml,W.flatMapDeep=hl,W.flatMapDepth=gl,W.flatten=tc,W.flattenDeep=nc,W.flattenDepth=rc,W.flip=Kl,W.flow=Ff,W.flowRight=If,W.fromPairs=ic,W.functions=bd,W.functionsIn=xd,W.groupBy=yl,W.initial=sc,W.intersection=cc,W.intersectionBy=lc,W.intersectionWith=uc,W.invert=Td,W.invertBy=Ed,W.invokeMap=xl,W.iteratee=Rf,W.keyBy=Sl,W.keys=Od,W.keysIn=kd,W.map=Cl,W.mapKeys=Ad,W.mapValues=jd,W.matches=zf,W.matchesProperty=Bf,W.memoize=ql,W.merge=Md,W.mergeWith=Nd,W.method=Vf,W.methodOf=Hf,W.mixin=Uf,W.negate=Jl,W.nthArg=Kf,W.omit=Pd,W.omitBy=Fd,W.once=Yl,W.orderBy=wl,W.over=qf,W.overArgs=Xl,W.overEvery=Jf,W.overSome=Yf,W.partial=Zl,W.partialRight=Ql,W.partition=Tl,W.pick=Id,W.pickBy=Ld,W.property=Xf,W.propertyOf=Zf,W.pull=hc,W.pullAll=gc,W.pullAllBy=_c,W.pullAllWith=vc,W.pullAt=yc,W.range=Qf,W.rangeRight=$f,W.rearg=$l,W.reject=Ol,W.remove=bc,W.rest=eu,W.reverse=xc,W.sampleSize=Al,W.set=zd,W.setWith=Bd,W.shuffle=jl,W.slice=Sc,W.sortBy=Pl,W.sortedUniq=kc,W.sortedUniqBy=Ac,W.split=hf,W.spread=tu,W.tail=jc,W.take=Mc,W.takeRight=Nc,W.takeRightWhile=Pc,W.takeWhile=Fc,W.tap=$c,W.throttle=nu,W.thru=el,W.toArray=$u,W.toPairs=Vd,W.toPairsIn=Hd,W.toPath=op,W.toPlainObject=id,W.transform=Ud,W.unary=ru,W.union=Ic,W.unionBy=Lc,W.unionWith=Rc,W.uniq=zc,W.uniqBy=Bc,W.uniqWith=Vc,W.unset=Wd,W.unzip=Hc,W.unzipWith=Uc,W.update=Gd,W.updateWith=Kd,W.values=qd,W.valuesIn=Jd,W.without=Wc,W.words=Of,W.wrap=iu,W.xor=Gc,W.xorBy=Kc,W.xorWith=qc,W.zip=Jc,W.zipObject=Yc,W.zipObjectDeep=Xc,W.zipWith=Zc,W.entries=Vd,W.entriesIn=Hd,W.extend=cd,W.extendWith=ld,Uf(W,W),W.add=cp,W.attempt=kf,W.camelCase=Qd,W.capitalize=$d,W.ceil=lp,W.clamp=Yd,W.clone=ou,W.cloneDeep=cu,W.cloneDeepWith=lu,W.cloneWith=su,W.conformsTo=uu,W.deburr=ef,W.defaultTo=Pf,W.divide=up,W.endsWith=tf,W.eq=du,W.escape=nf,W.escapeRegExp=rf,W.every=ul,W.find=fl,W.findIndex=$s,W.findKey=hd,W.findLast=pl,W.findLastIndex=ec,W.findLastKey=gd,W.floor=dp,W.forEach=_l,W.forEachRight=vl,W.forIn=_d,W.forInRight=J,W.forOwn=vd,W.forOwnRight=yd,W.get=Sd,W.gt=fu,W.gte=pu,W.has=Cd,W.hasIn=wd,W.head=ac,W.identity=Lf,W.includes=bl,W.indexOf=oc,W.inRange=Xd,W.invoke=Dd,W.isArguments=mu,W.isArray=hu,W.isArrayBuffer=gu,W.isArrayLike=_u,W.isArrayLikeObject=vu,W.isBoolean=yu,W.isBuffer=bu,W.isDate=xu,W.isElement=Su,W.isEmpty=Cu,W.isEqual=wu,W.isEqualWith=Tu,W.isError=Eu,W.isFinite=Du,W.isFunction=Ou,W.isInteger=ku,W.isLength=Au,W.isMap=Nu,W.isMatch=Pu,W.isMatchWith=Fu,W.isNaN=Iu,W.isNative=Lu,W.isNil=zu,W.isNull=Ru,W.isNumber=Bu,W.isObject=ju,W.isObjectLike=Mu,W.isPlainObject=Vu,W.isRegExp=Hu,W.isSafeInteger=Uu,W.isSet=Wu,W.isString=Gu,W.isSymbol=Ku,W.isTypedArray=qu,W.isUndefined=Ju,W.isWeakMap=Yu,W.isWeakSet=Xu,W.join=dc,W.kebabCase=af,W.last=fc,W.lastIndexOf=pc,W.lowerCase=of,W.lowerFirst=sf,W.lt=Zu,W.lte=Qu,W.max=fp,W.maxBy=pp,W.mean=mp,W.meanBy=hp,W.min=gp,W.minBy=_p,W.stubArray=ep,W.stubFalse=tp,W.stubObject=np,W.stubString=rp,W.stubTrue=ip,W.multiply=vp,W.nth=mc,W.noConflict=Wf,W.noop=Gf,W.now=Fl,W.pad=cf,W.padEnd=lf,W.padStart=uf,W.parseInt=df,W.random=Zd,W.reduce=El,W.reduceRight=Dl,W.repeat=ff,W.replace=pf,W.result=Rd,W.round=yp,W.runInContext=e,W.sample=kl,W.size=Ml,W.snakeCase=mf,W.some=Nl,W.sortedIndex=Cc,W.sortedIndexBy=wc,W.sortedIndexOf=Tc,W.sortedLastIndex=Ec,W.sortedLastIndexBy=Dc,W.sortedLastIndexOf=Oc,W.startCase=gf,W.startsWith=_f,W.subtract=bp,W.sum=xp,W.sumBy=Sp,W.template=vf,W.times=ap,W.toFinite=ed,W.toInteger=td,W.toLength=nd,W.toLower=yf,W.toNumber=rd,W.toSafeInteger=ad,W.toString=od,W.toUpper=bf,W.trim=xf,W.trimEnd=Sf,W.trimStart=Cf,W.truncate=wf,W.unescape=Tf,W.uniqueId=sp,W.upperCase=Ef,W.upperFirst=Df,W.each=_l,W.eachRight=vl,W.first=ac,Uf(W,function(){var e={};return Vi(W,function(t,n){Tt.call(W.prototype,n)||(e[n]=t)}),e}(),{chain:!1}),W.VERSION=r,U([`bind`,`bindKey`,`curry`,`curryRight`,`partial`,`partialRight`],function(e){W[e].placeholder=W}),U([`drop`,`take`],function(e,t){Lr.prototype[e]=function(r){r=r===n?1:tn(td(r),0);var i=this.__filtered__&&!t?new Lr(this):this.clone();return i.__filtered__?i.__takeCount__=sn(r,i.__takeCount__):i.__views__.push({size:sn(r,F),type:e+(i.__dir__<0?`Right`:``)}),i},Lr.prototype[e+`Right`]=function(t){return this.reverse()[e](t).reverse()}}),U([`filter`,`map`,`takeWhile`],function(e,t){var n=t+1,r=n==te||n==ne;Lr.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:Zo(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}}),U([`head`,`last`],function(e,t){var n=`take`+(t?`Right`:``);Lr.prototype[e]=function(){return this[n](1).value()[0]}}),U([`initial`,`tail`],function(e,t){var n=`drop`+(t?``:`Right`);Lr.prototype[e]=function(){return this.__filtered__?new Lr(this):this[n](1)}}),Lr.prototype.compact=function(){return this.filter(Lf)},Lr.prototype.find=function(e){return this.filter(e).head()},Lr.prototype.findLast=function(e){return this.reverse().find(e)},Lr.prototype.invokeMap=Aa(function(e,t){return typeof e==`function`?new Lr(this):this.map(function(n){return $i(n,e,t)})}),Lr.prototype.reject=function(e){return this.filter(Jl(Zo(e)))},Lr.prototype.slice=function(e,t){e=td(e);var r=this;return r.__filtered__&&(e>0||t<0)?new Lr(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==n&&(t=td(t),r=t<0?r.dropRight(-t):r.take(t-e)),r)},Lr.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Lr.prototype.toArray=function(){return this.take(F)},Vi(Lr.prototype,function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),a=W[i?`take`+(t==`last`?`Right`:``):t],o=i||/^find/.test(t);a&&(W.prototype[t]=function(){var t=this.__wrapped__,s=i?[1]:arguments,c=t instanceof Lr,l=s[0],u=c||hu(t),d=function(e){var t=a.apply(W,Pn([e],s));return i&&f?t[0]:t};u&&r&&typeof l==`function`&&l.length!=1&&(c=u=!1);var f=this.__chain__,p=!!this.__actions__.length,m=o&&!f,h=c&&!p;if(!o&&u){t=h?t:new Lr(this);var g=e.apply(t,s);return g.__actions__.push({func:el,args:[d],thisArg:n}),new Ir(g,f)}return m&&h?e.apply(this,s):(g=this.thru(d),m?i?g.value()[0]:g.value():g)})}),U([`pop`,`push`,`shift`,`sort`,`splice`,`unshift`],function(e){var t=bt[e],n=/^(?:push|sort|unshift)$/.test(e)?`tap`:`thru`,r=/^(?:pop|shift)$/.test(e);W.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(hu(i)?i:[],e)}return this[n](function(n){return t.apply(hu(n)?n:[],e)})}}),Vi(Lr.prototype,function(e,t){var n=W[t];if(n){var r=n.name+``;Tt.call(Jn,r)||(Jn[r]=[]),Jn[r].push({name:t,func:n})}}),Jn[Oo(n,v).name]=[{name:`wrapper`,func:n}],Lr.prototype.clone=Rr,Lr.prototype.reverse=zr,Lr.prototype.value=Br,W.prototype.at=tl,W.prototype.chain=nl,W.prototype.commit=rl,W.prototype.next=il,W.prototype.plant=ol,W.prototype.reverse=sl,W.prototype.toJSON=W.prototype.valueOf=W.prototype.value=cl,W.prototype.first=W.prototype.head,Vt&&(W.prototype[Vt]=al),W})();typeof define==`function`&&typeof define.amd==`object`&&define.amd?(mn._=Or,define(function(){return Or})):gn?((gn.exports=Or)._=Or,hn._=Or):mn._=Or}).call(e)}))(),k=e=>{let t=(0,ee.startCase)(e).toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)},te=/serverVariables\s*:\s*\{/,A=/defineApplication\s*\(\s*\{/,ne=async({projectRoot:e,variables:t})=>{let n=await D(e);if(n===null)return{status:`skipped-no-config`};let r=await(0,i.readFile)(n,`utf8`),a=t.filter(e=>!RegExp(`\\b${e.name}\\s*:`).test(r));if(a.length===0)return{status:`skipped-existing`};let o=j(a);if(te.test(r))return await(0,i.writeFile)(n,r.replace(te,e=>`${e}\n${o}`),`utf8`),{status:`appended`,file:n};if(!A.test(r))return{status:`skipped-no-app-call`};let s=r.replace(/\n(\s*)\}\s*\)\s*;?\s*$/,(e,t)=>`\n${t}${M(a,t)}\n${t}});\n`);return s===r?{status:`skipped-no-app-call`}:(await(0,i.writeFile)(n,s,`utf8`),{status:`created`,file:n})},j=e=>e.map(({name:e,description:t,isSecret:n})=>` ${e}: {\n description: ${JSON.stringify(t)},\n isSecret: ${n},\n isRequired: true,\n },`).join(`
|
|
22
22
|
`),M=(e,t)=>`serverVariables: {\n${e.map(({name:e,description:n,isSecret:r})=>`${t} ${e}: {\n${t} description: ${JSON.stringify(n)},\n${t} isSecret: ${r},\n${t} isRequired: true,\n${t} },`).join(`
|
|
23
|
-
`)}\n${t}},`,N=({data:e})=>{let n=(0,a.v4)(),r=e.description?`\n description: '${e.description}',`:``;if(e.type===t.
|
|
23
|
+
`)}\n${t}},`,N=({data:e})=>{let n=(0,a.v4)(),r=e.description?`\n description: '${e.description}',`:``;if(e.type===t.Ot.RELATION||e.type===t.Ot.MORPH_RELATION){let i=e.onDelete&&e.onDelete!==`None`,o=`import { defineField, FieldType, RelationType${i?`, OnDeleteAction`:``} } from 'twenty-sdk/define';`,s=i?`, onDelete: OnDeleteAction.${e.onDelete}`:``,c=e.type===t.Ot.MORPH_RELATION?`\n morphId: '${(0,a.v4)()}',`:``;return`${o}
|
|
24
24
|
|
|
25
25
|
export default defineField({
|
|
26
26
|
universalIdentifier: '${n}',
|
|
@@ -142,21 +142,27 @@ export default defineCommandMenuItem({
|
|
|
142
142
|
label: '${e}',
|
|
143
143
|
availabilityType: 'GLOBAL',
|
|
144
144
|
});
|
|
145
|
-
`,oe=({name:e,type:
|
|
145
|
+
`,oe=({name:e,type:n})=>{let r=n===t.wt.DASHBOARD?t.Dt.GRID:t.Dt.VERTICAL_LIST;return`import {
|
|
146
|
+
definePageLayout,
|
|
147
|
+
PageLayoutTabLayoutMode,
|
|
148
|
+
PageLayoutType,
|
|
149
|
+
} from 'twenty-sdk/define';
|
|
146
150
|
|
|
147
151
|
export default definePageLayout({
|
|
148
152
|
universalIdentifier: '${(0,a.v4)()}',
|
|
149
153
|
name: '${e}',
|
|
150
|
-
type: PageLayoutType.${
|
|
154
|
+
type: PageLayoutType.${n},
|
|
151
155
|
tabs: [
|
|
152
156
|
{
|
|
153
157
|
universalIdentifier: '${(0,a.v4)()}',
|
|
154
158
|
title: 'Overview',
|
|
159
|
+
position: 0,
|
|
160
|
+
layoutMode: PageLayoutTabLayoutMode.${r},
|
|
155
161
|
widgets: [],
|
|
156
162
|
},
|
|
157
163
|
],
|
|
158
164
|
});
|
|
159
|
-
|
|
165
|
+
`},se=({name:e})=>`import { definePageLayoutTab, PageLayoutTabLayoutMode } from 'twenty-sdk/define';
|
|
160
166
|
|
|
161
167
|
export default definePageLayoutTab({
|
|
162
168
|
universalIdentifier: '${(0,a.v4)()}',
|
|
@@ -327,10 +333,10 @@ export default defineViewField({
|
|
|
327
333
|
isVisible: true,
|
|
328
334
|
size: 150,
|
|
329
335
|
});
|
|
330
|
-
`,he=`src/application.config.ts`,ge=`src`,_e=class{async execute(e,n){try{let a=await O(t.
|
|
331
|
-
`)));break}}buildRecordPageFieldsViewFields(e){let t=[`createdAt`,`updatedAt`,`createdBy`,`updatedBy`].map(e=>({defaultFieldName:e,isVisible:!0,size:200}));return(e?[{fieldMetadataUniversalIdentifier:e,isVisible:!0,size:200},...t]:t).map((e,t)=>({...e,position:t}))}async getEntity(){let{entity:e}=await d.default.prompt([{type:`select`,name:`entity`,message:`What entity do you want to create?`,default:``,choices:Object.values(t.ht)}]);return e}async handleFileExist(){return await d.default.prompt([{type:`confirm`,name:`overwrite`,message:`File already exists. Do you want to overwrite it?`,default:!1}])}async getEntityName(e){let{name:t}=await d.default.prompt([{type:`input`,name:`name`,message:`Enter a name for your new ${e}:`,default:``,validate:t=>t.length===0?`${e} name is required`:!0}]);return t}async getFieldData(){let e=e=>e===t.
|
|
332
|
-
`);let e=p.error.details?.availableFunctions??[];e.length>0?(console.log(u.default.cyan(`Available functions:`)),e.forEach(e=>{console.log(` - ${u.default.white(e.name)} (${e.universalIdentifier})`)})):console.log(u.default.yellow("No functions found for this application. Have you synced your app with `twenty dev`?"));break}case t.J.EXECUTION_FAILED:console.error(u.default.red(`Execution failed:`),p.error.message);break;default:console.error(u.default.red(p.error.message))}process.exit(1)}let m=p.data;console.log(u.default.cyan(`─`.repeat(60))),console.log(u.default.cyan(`Execution Result`)),console.log(u.default.cyan(`─`.repeat(60)));let h=m.status===`SUCCESS`?u.default.green:u.default.red;console.log(`${u.default.bold(`Status:`)} ${h(m.status)}`),console.log(`${u.default.bold(`Duration:`)} ${m.duration}ms\n`),n.t(m.data)&&(console.log(u.default.bold(`Data:`)),console.log(u.default.white(JSON.stringify(m.data,null,2)))),m.error&&(console.log(u.default.bold.red(`Error:`)),console.log(u.default.red(` Type: ${m.error.errorType}`)),console.log(u.default.red(` Message: ${m.error.errorMessage}\n`)),m.error.stackTrace&&(console.log(u.default.gray(`Stack trace:`)),console.log(u.default.gray(m.error.stackTrace)))),m.logs&&(console.log(u.default.bold(`Logs:`)),console.log(u.default.gray(m.logs))),console.log(u.default.cyan(`─`.repeat(60))),m.status!==`SUCCESS`&&process.exit(1)}},be=class{constructor(){this.apiService=new t.z}async execute({appPath:e=t.
|
|
333
|
-
`,u.default.red(`✗ Found ${r.length} type error${r.length===1?``:`s`}`)),process.exit(1)}},Ce=(e,t)=>console.warn(u.default.yellow(`⚠ \`twenty ${e}\` is deprecated. Use \`twenty ${t}\` instead.`)),we=e=>{let t=new ve,n=new Se,r=new be,i=new ye,a=new _e,o=new S,s=new C,c=new w;e.command(`build [appPath]`,{hidden:!0}).option(`--tarball`,`Also pack into a .tgz tarball`).action(async(e,n)=>{Ce(`build`,`dev:build`),await t.execute({appPath:g(e),tarball:n.tarball})}),e.command(`typecheck [appPath]`,{hidden:!0}).action(async e=>{Ce(`typecheck`,`dev:typecheck`),await n.execute({appPath:g(e)})}),e.command(`logs [appPath]`,{hidden:!0}).option(`-u, --functionUniversalIdentifier <functionUniversalIdentifier>`,`Only show logs for the function with this universal ID`).option(`-n, --functionName <functionName>`,`Only show logs for the function with this name`).action(async(e,t)=>{Ce(`logs`,`dev:function:logs`),await r.execute({...t,appPath:g(e)})}),e.command(`exec [appPath]`,{hidden:!0}).option(`--postInstall`,`Execute post-install logic function if defined`).option(`--preInstall`,`Execute pre-install logic function if defined`).option(`-p, --payload <payload>`,`JSON payload to send to the function`,`{}`).option(`-u, --functionUniversalIdentifier <functionUniversalIdentifier>`,`Universal ID of the function to execute`).option(`-n, --functionName <functionName>`,`Name of the function to execute`).action(async(e,t)=>{Ce(`exec`,`dev:function:exec`),!t?.postInstall&&!t?.preInstall&&!t?.functionUniversalIdentifier&&!t?.functionName&&(console.error(u.default.red(`Error: Either --postInstall, --preInstall, --functionName (-n), or --functionUniversalIdentifier (-u) is required.`)),process.exit(1)),await i.execute({...t,payload:t?.payload??`{}`,appPath:g(e)})}),e.command(`add [entityType]`,{hidden:!0}).option(`--path <path>`,`Path in which the entity should be created.`).action(async(e,t)=>{Ce(`add`,`dev:add`),await a.execute(e,t?.path)}),e.command(`publish [appPath]`,{hidden:!0}).option(`--tag <tag>`,`npm dist-tag (e.g. beta, next)`).action(async(e,t)=>{Ce(`publish`,`app:publish`),await o.execute({appPath:g(e),tag:t.tag})}),e.command(`deploy [appPath]`,{hidden:!0}).option(`-r, --remote <name>`,`Deploy to a specific remote`).action(async(e,t)=>{Ce(`deploy`,`app:publish --private`),await o.execute({appPath:g(e),private:!0,remote:t.remote})}),e.command(`install [appPath]`,{hidden:!0}).option(`-r, --remote <name>`,`Install on a specific remote`).action(async(e,t)=>{Ce(`install`,`app:install`),await s.execute({appPath:g(e),remote:t.remote})}),e.command(`uninstall [appPath]`,{hidden:!0}).option(`-y, --yes`,`Skip confirmation prompt`).action(async(e,t)=>{Ce(`uninstall`,`app:uninstall`);try{let n=await c.execute({appPath:g(e),askForConfirmation:!t?.yes});process.exit(+!n.success)}catch{process.exit(1)}}),e.command(`catalog-sync`,{hidden:!0}).option(`-r, --remote <name>`,`Sync on a specific remote`).action(async e=>{Ce(`catalog-sync`,`dev:catalog-sync`);let{CatalogSyncCommand:t}=await Promise.resolve().then(()=>require("./catalog-sync-
|
|
336
|
+
`,he=`src/application.config.ts`,ge=`src`,_e=class{async execute(e,n){try{let a=await O(t.kt),o=e??await this.getEntity(),s=this.getFolderName(o),c=n?(0,r.join)(t.kt,n):(0,r.join)(t.kt,ge,s);await t.lt(c);let{name:l,file:d}=await this.getEntityData(o,a),f=(0,r.join)(c,this.getFileName(l,o));if(await t.ut(f)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,i.writeFile)(f,d),console.log(u.default.green(`✓ Created ${s}:`),u.default.cyan((0,r.relative)(t.kt,f))),o===t.ht.Object&&await this.promptAndCreateObjectCompanions({objectName:l,applicationUniversalIdentifier:a,customPath:n}),o===t.ht.ConnectionProvider&&await this.registerConnectionProviderServerVariables(l)}catch(e){console.error(u.default.red(`Add new entity failed:`),e instanceof Error?e.message:e),process.exit(1)}}async getEntityData(e,n){switch(e){case t.ht.Object:{let e=await this.getObjectData(),t=e.nameSingular,n=(0,a.v4)(),r=(0,a.v4)();return this.lastObjectUniversalIdentifier=n,this.lastNameFieldUniversalIdentifier=r,this.lastObjectLabelSingular=e.labelSingular,{name:t,file:ie({data:e,name:t,universalIdentifier:n,nameFieldUniversalIdentifier:r})}}case t.ht.Field:{let e=await this.getFieldData(),t=e.name;return{name:t,file:N({data:e,name:t})}}case t.ht.LogicFunction:{let t=await this.getEntityName(e);return{name:t,file:I({name:t})}}case t.ht.FrontComponent:{let t=await this.getEntityName(e);return{name:t,file:F({name:t})}}case t.ht.Role:{let t=await this.getEntityName(e);return{name:t,file:L({name:t})}}case t.ht.Skill:{let t=await this.getEntityName(e);return{name:t,file:de({name:t})}}case t.ht.Agent:{let t=await this.getEntityName(e);return{name:t,file:le({name:t})}}case t.ht.ConnectionProvider:{let t=await this.getEntityName(e);return{name:t,file:ue({name:t})}}case t.ht.View:{let e=(await this.getViewData()).name;return{name:e,file:pe({name:e,applicationUniversalIdentifier:n})}}case t.ht.ViewField:return{name:await this.getEntityName(e),file:me({})};case t.ht.NavigationMenuItem:{let t=await this.getEntityName(e);return{name:t,file:re({name:t})}}case t.ht.PageLayout:{let n=await this.getEntityName(e),{type:r}=await d.default.prompt([{type:`select`,name:`type`,message:`Select the page layout type:`,choices:Object.values(t.wt)}]);return{name:n,file:oe({name:n,type:r})}}case t.ht.PageLayoutTab:{let t=await this.getEntityName(e);return{name:t,file:se({name:t})}}case t.ht.CommandMenuItem:{let t=await this.getEntityName(e);return{name:t,file:ae({name:t})}}default:t.vt(e)}}async promptAndCreateObjectCompanions({objectName:e,applicationUniversalIdentifier:n,customPath:o}){let{createCompanions:s}=await d.default.prompt([{type:`confirm`,name:`createCompanions`,message:`Also create a view, navigation menu item, and record page layout for this object? (recommended)`,default:!0}]);if(!s||!this.lastObjectUniversalIdentifier)return;let c=(0,a.v4)(),l=(0,a.v4)(),f=pe({name:`all-${P(e)}`,universalIdentifier:c,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,applicationUniversalIdentifier:n,fields:this.lastNameFieldUniversalIdentifier?[{fieldMetadataUniversalIdentifier:this.lastNameFieldUniversalIdentifier,position:0,isVisible:!0,size:200}]:[]}),p=o?(0,r.join)(t.kt,o):(0,r.join)(t.kt,ge,this.getFolderName(t.ht.View));await t.lt(p);let m=(0,r.join)(p,`all-${P(e)}.ts`);if(await t.ut(m)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,i.writeFile)(m,f),console.log(u.default.green(`✓ Created view:`),u.default.cyan((0,r.relative)(t.kt,m)));let h=this.buildRecordPageFieldsViewFields(this.lastNameFieldUniversalIdentifier),g=pe({name:`${P(e)}-record-page-fields`,universalIdentifier:l,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,applicationUniversalIdentifier:n,type:t.Ct.FIELDS_WIDGET,fields:h}),_=(0,r.join)(p,`${P(e)}-record-page-fields.ts`);if(await t.ut(_)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,i.writeFile)(_,g),console.log(u.default.green(`✓ Created record-page-fields view:`),u.default.cyan((0,r.relative)(t.kt,_)));let v=re({name:e,type:`OBJECT`,targetObjectUniversalIdentifier:this.lastObjectUniversalIdentifier}),y=o?(0,r.join)(t.kt,o):(0,r.join)(t.kt,ge,this.getFolderName(t.ht.NavigationMenuItem));await t.lt(y);let b=(0,r.join)(y,`${P(e)}.ts`);if(await t.ut(b)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,i.writeFile)(b,v),console.log(u.default.green(`✓ Created navigation menu item:`),u.default.cyan((0,r.relative)(t.kt,b)));let x=ce({objectLabelSingular:this.lastObjectLabelSingular??e,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,fieldsWidgetViewUniversalIdentifier:l}),S=o?(0,r.join)(t.kt,o):(0,r.join)(t.kt,ge,this.getFolderName(t.ht.PageLayout));await t.lt(S);let C=(0,r.join)(S,`${P(e)}-record-page-layout.ts`);if(await t.ut(C)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,i.writeFile)(C,x),console.log(u.default.green(`✓ Created record page layout:`),u.default.cyan((0,r.relative)(t.kt,C)))}async registerConnectionProviderServerVariables(e){let n=P(e).toUpperCase().replace(/-/g,`_`),i=[{name:`${n}_CLIENT_ID`,description:`OAuth client ID issued by the third-party provider. Filled in once by the server admin on the application registration.`,isSecret:!1},{name:`${n}_CLIENT_SECRET`,description:`OAuth client secret issued by the third-party provider. Stored encrypted; never echoed in API responses.`,isSecret:!0}],a=await ne({projectRoot:t.kt,variables:i});switch(a.status){case`appended`:case`created`:console.log(u.default.green(`✓ Added ${i.map(e=>e.name).join(` + `)} to defineApplication.serverVariables:`),u.default.cyan((0,r.relative)(t.kt,a.file)));break;case`skipped-existing`:console.log(u.default.dim(` (${i.map(e=>e.name).join(` / `)} already declared on defineApplication.serverVariables)`));break;case`skipped-no-config`:case`skipped-no-app-call`:console.log(u.default.yellow(`! Couldn't auto-update ${he}. Add these manually to defineApplication.serverVariables:\n`+i.map(e=>` ${e.name}: { description: '...', isSecret: ${e.isSecret}, isRequired: true },`).join(`
|
|
337
|
+
`)));break}}buildRecordPageFieldsViewFields(e){let t=[`createdAt`,`updatedAt`,`createdBy`,`updatedBy`].map(e=>({defaultFieldName:e,isVisible:!0,size:200}));return(e?[{fieldMetadataUniversalIdentifier:e,isVisible:!0,size:200},...t]:t).map((e,t)=>({...e,position:t}))}async getEntity(){let{entity:e}=await d.default.prompt([{type:`select`,name:`entity`,message:`What entity do you want to create?`,default:``,choices:Object.values(t.ht)}]);return e}async handleFileExist(){return await d.default.prompt([{type:`confirm`,name:`overwrite`,message:`File already exists. Do you want to overwrite it?`,default:!1}])}async getEntityName(e){let{name:t}=await d.default.prompt([{type:`input`,name:`name`,message:`Enter a name for your new ${e}:`,default:``,validate:t=>t.length===0?`${e} name is required`:!0}]);return t}async getFieldData(){let e=e=>e===t.Ot.RELATION||e===t.Ot.MORPH_RELATION;return d.default.prompt([{type:`input`,name:`name`,message:`Enter a name for your field:`,default:``,validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`label`,message:`Enter a label for your field:`,default:e=>k(e.name),validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`select`,name:`type`,message:`Select the field type:`,choices:Object.values(t.Ot),default:t.Ot.TEXT},{type:`input`,name:`objectUniversalIdentifier`,message:`Enter the universalIdentifier of the object this field belongs to:`,default:`fill-later`,validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`description`,message:`Enter a description for your field (optional):`,default:``},{type:`input`,name:`relationTargetObjectMetadataUniversalIdentifier`,message:`Enter the universalIdentifier of the target object of the relation:`,default:`fill-later`,when:t=>e(t.type),validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`relationTargetFieldMetadataUniversalIdentifier`,message:`Enter the universalIdentifier of the target field on the related object:`,default:`fill-later`,when:t=>e(t.type),validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`select`,name:`relationType`,message:`Select the relation type:`,choices:Object.values(t.Tt),default:t.Tt.ONE_TO_MANY,when:t=>e(t.type)},{type:`select`,name:`onDelete`,message:`Select the onDelete behavior:`,choices:Object.values(t.Et),default:t.Et.CASCADE,when:t=>e(t.type)}])}async getObjectData(){return d.default.prompt([{type:`input`,name:`nameSingular`,message:`Enter a name singular for your object (eg: company):`,default:``,validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`namePlural`,message:`Enter a name plural for your object (eg: companies):`,default:``,validate:(e,t)=>e.trim()===t?.nameSingular.trim()?`Name plural must be different from name singular`:!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`labelSingular`,message:`Enter a label singular for your object:`,default:e=>k(e.nameSingular),validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`labelPlural`,message:`Enter a label plural for your object:`,default:e=>k(e.namePlural),validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0}])}async getViewData(){return d.default.prompt([{type:`input`,name:`name`,message:`Enter a name for your view:`,default:``,validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`objectUniversalIdentifier`,message:`Enter the universalIdentifier of the object this view belongs to:`,default:`fill-later`,validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0}])}getFolderName(e){return`${P(e)}s`}getFileName(e,n){switch(n){case t.ht.FrontComponent:return`${P(e)}.tsx`;default:return`${P(e)}.ts`}}},ve=class{async execute(e){let n=e.appPath??t.kt;await x(n),console.log(u.default.blue(`Building application...`)),console.log(u.default.gray(`App path: ${n}\n`));let r=await t.G({appPath:n,tarball:e.tarball,onProgress:e=>console.log(u.default.gray(e))});r.success||(console.error(u.default.red(r.error.message)),process.exit(1)),console.log(u.default.green(`✓ Build succeeded (${r.data.fileCount} file${r.data.fileCount===1?``:`s`})`)),console.log(u.default.gray(`Output: ${r.data.outputDir}`)),r.data.tarballPath&&console.log(u.default.gray(`Tarball: ${r.data.tarballPath}`))}},ye=class{async execute({appPath:e=t.kt,postInstall:r=!1,preInstall:i=!1,uninstall:a=!1,functionUniversalIdentifier:o,functionName:s,payload:c=`{}`}){let l;try{l=JSON.parse(c)}catch{console.error(u.default.red(`Invalid JSON payload. Please provide valid JSON.`)),process.exit(1)}let d=r?`post install`:i?`pre install`:a?`uninstall`:o??s,f=t.U.getActiveRemote();console.log(u.default.blue(`🚀 Executing function "${d}" on ${f}...`)),console.log(u.default.gray(` Payload: ${JSON.stringify(l)}\n`));let p=await t._(r?{appPath:e,postInstall:!0,payload:l}:i?{appPath:e,preInstall:!0,payload:l}:a?{appPath:e,uninstall:!0,payload:l}:o?{appPath:e,functionUniversalIdentifier:o,payload:l}:{appPath:e,functionName:s,payload:l});if(!p.success){switch(p.error.code){case t.K.MANIFEST_NOT_FOUND:console.error(u.default.red(`Failed to build manifest.`));break;case t.J.FETCH_FUNCTIONS_FAILED:console.error(u.default.red(`Failed to fetch functions:`),p.error.message);break;case t.J.FUNCTION_NOT_FOUND:{console.error(u.default.red(p.error.message),`
|
|
338
|
+
`);let e=p.error.details?.availableFunctions??[];e.length>0?(console.log(u.default.cyan(`Available functions:`)),e.forEach(e=>{console.log(` - ${u.default.white(e.name)} (${e.universalIdentifier})`)})):console.log(u.default.yellow("No functions found for this application. Have you synced your app with `twenty dev`?"));break}case t.J.EXECUTION_FAILED:console.error(u.default.red(`Execution failed:`),p.error.message);break;default:console.error(u.default.red(p.error.message))}process.exit(1)}let m=p.data;console.log(u.default.cyan(`─`.repeat(60))),console.log(u.default.cyan(`Execution Result`)),console.log(u.default.cyan(`─`.repeat(60)));let h=m.status===`SUCCESS`?u.default.green:u.default.red;console.log(`${u.default.bold(`Status:`)} ${h(m.status)}`),console.log(`${u.default.bold(`Duration:`)} ${m.duration}ms\n`),n.t(m.data)&&(console.log(u.default.bold(`Data:`)),console.log(u.default.white(JSON.stringify(m.data,null,2)))),m.error&&(console.log(u.default.bold.red(`Error:`)),console.log(u.default.red(` Type: ${m.error.errorType}`)),console.log(u.default.red(` Message: ${m.error.errorMessage}\n`)),m.error.stackTrace&&(console.log(u.default.gray(`Stack trace:`)),console.log(u.default.gray(m.error.stackTrace)))),m.logs&&(console.log(u.default.bold(`Logs:`)),console.log(u.default.gray(m.logs))),console.log(u.default.cyan(`─`.repeat(60))),m.status!==`SUCCESS`&&process.exit(1)}},be=class{constructor(){this.apiService=new t.z}async execute({appPath:e=t.kt,functionUniversalIdentifier:n,functionName:r}){try{let i=await t.F(e);i||process.exit(1),this.logWatchInfo({appName:i.application.displayName,functionUniversalIdentifier:n,functionName:r}),await this.apiService.subscribeToLogs({applicationUniversalIdentifier:i.application.universalIdentifier,functionUniversalIdentifier:n,functionName:r})}catch(e){console.error(u.default.red(`Watch logs failed:`),e instanceof Error?e.message:e),process.exit(1)}}logWatchInfo({appName:e,functionUniversalIdentifier:n,functionName:r}){let i=e??`Twenty Application`,a=n||r?`function "${n||r}"`:`functions`,o=t.U.getActiveRemote();console.log(u.default.blue(`🚀 Watching ${i} ${a} logs on ${o}:\n`))}},xe=e=>`${u.default.cyan(e.file)}:${u.default.yellow(String(e.line))}:${u.default.yellow(String(e.column+1))} - ${u.default.red(`error`)} ${e.text}`,Se=class{async execute(e){let n=e.appPath??t.kt;console.log(u.default.blue(`Running type check...`)),console.log(u.default.gray(`App path: ${n}\n`));let r=await t.ot(n);r.length===0&&(console.log(u.default.green(`✓ No type errors found`)),process.exit(0));for(let e of r)console.log(xe(e));console.log(`
|
|
339
|
+
`,u.default.red(`✗ Found ${r.length} type error${r.length===1?``:`s`}`)),process.exit(1)}},Ce=(e,t)=>console.warn(u.default.yellow(`⚠ \`twenty ${e}\` is deprecated. Use \`twenty ${t}\` instead.`)),we=e=>{let t=new ve,n=new Se,r=new be,i=new ye,a=new _e,o=new S,s=new C,c=new w;e.command(`build [appPath]`,{hidden:!0}).option(`--tarball`,`Also pack into a .tgz tarball`).action(async(e,n)=>{Ce(`build`,`dev:build`),await t.execute({appPath:g(e),tarball:n.tarball})}),e.command(`typecheck [appPath]`,{hidden:!0}).action(async e=>{Ce(`typecheck`,`dev:typecheck`),await n.execute({appPath:g(e)})}),e.command(`logs [appPath]`,{hidden:!0}).option(`-u, --functionUniversalIdentifier <functionUniversalIdentifier>`,`Only show logs for the function with this universal ID`).option(`-n, --functionName <functionName>`,`Only show logs for the function with this name`).action(async(e,t)=>{Ce(`logs`,`dev:function:logs`),await r.execute({...t,appPath:g(e)})}),e.command(`exec [appPath]`,{hidden:!0}).option(`--postInstall`,`Execute post-install logic function if defined`).option(`--preInstall`,`Execute pre-install logic function if defined`).option(`-p, --payload <payload>`,`JSON payload to send to the function`,`{}`).option(`-u, --functionUniversalIdentifier <functionUniversalIdentifier>`,`Universal ID of the function to execute`).option(`-n, --functionName <functionName>`,`Name of the function to execute`).action(async(e,t)=>{Ce(`exec`,`dev:function:exec`),!t?.postInstall&&!t?.preInstall&&!t?.functionUniversalIdentifier&&!t?.functionName&&(console.error(u.default.red(`Error: Either --postInstall, --preInstall, --functionName (-n), or --functionUniversalIdentifier (-u) is required.`)),process.exit(1)),await i.execute({...t,payload:t?.payload??`{}`,appPath:g(e)})}),e.command(`add [entityType]`,{hidden:!0}).option(`--path <path>`,`Path in which the entity should be created.`).action(async(e,t)=>{Ce(`add`,`dev:add`),await a.execute(e,t?.path)}),e.command(`publish [appPath]`,{hidden:!0}).option(`--tag <tag>`,`npm dist-tag (e.g. beta, next)`).action(async(e,t)=>{Ce(`publish`,`app:publish`),await o.execute({appPath:g(e),tag:t.tag})}),e.command(`deploy [appPath]`,{hidden:!0}).option(`-r, --remote <name>`,`Deploy to a specific remote`).action(async(e,t)=>{Ce(`deploy`,`app:publish --private`),await o.execute({appPath:g(e),private:!0,remote:t.remote})}),e.command(`install [appPath]`,{hidden:!0}).option(`-r, --remote <name>`,`Install on a specific remote`).action(async(e,t)=>{Ce(`install`,`app:install`),await s.execute({appPath:g(e),remote:t.remote})}),e.command(`uninstall [appPath]`,{hidden:!0}).option(`-y, --yes`,`Skip confirmation prompt`).action(async(e,t)=>{Ce(`uninstall`,`app:uninstall`);try{let n=await c.execute({appPath:g(e),askForConfirmation:!t?.yes});process.exit(+!n.success)}catch{process.exit(1)}}),e.command(`catalog-sync`,{hidden:!0}).option(`-r, --remote <name>`,`Sync on a specific remote`).action(async e=>{Ce(`catalog-sync`,`dev:catalog-sync`);let{CatalogSyncCommand:t}=await Promise.resolve().then(()=>require("./catalog-sync-Bh6piElD.js"));await new t().execute({remote:e.remote})})},Te=class{constructor({state:e,notify:t}){this.state=e,this.notify=t}async execute(e){let n=this.state.steps.buildManifest;n.status=`in_progress`,this.state.updatePipeline({status:`building`});let r=[{message:`Building manifest`,status:`info`}],i=await t.$(e.appPath);if(!i.success){for(let e of i.errors)r.push({message:e,status:`error`});return n.output={result:null},n.status=`error`,this.state.updatePipeline({status:`error`}),this.state.applyStepEvents(r),null}if(i.warnings.length>0)for(let e of i.warnings)r.push({message:`⚠ ${e}`,status:`warning`});r.push({message:`Successfully built manifest`,status:`success`});let a={manifest:i.manifest,filePaths:i.filePaths};return n.output={result:a},n.status=`done`,this.state.updatePipeline({appName:i.manifest.application.displayName}),this.state.updateEntitiesFromManifest(i.filePaths),this.state.applyStepEvents(r),a}},R=class{constructor({apiService:e,state:t,notify:n}){this.hasRetried=!1,this.apiService=e,this.state=t,this.notify=n}async execute(){let e=this.state.steps.checkServer,r=await this.apiService.validateAuth();if(!r.serverUp){let n=await t.m();return n&&!this.hasRetried?(this.hasRetried=!0,await new t.U().setConfig({apiUrl:n}),this.execute()):(e.output.errorLogged||(e.output={isReady:!1,errorLogged:!0},e.status=`error`,this.state.applyStepEvents([{message:`Cannot reach Twenty server.
|
|
334
340
|
|
|
335
341
|
Start a local server:
|
|
336
342
|
yarn twenty docker:start
|
|
@@ -339,7 +345,7 @@ export default defineViewField({
|
|
|
339
345
|
yarn twenty docker:status
|
|
340
346
|
|
|
341
347
|
Waiting for server...`,status:`error`}]),this.state.updatePipeline({status:`error`})),!1)}if(!r.authValid)return e.output.errorLogged||(e.output={isReady:!1,errorLogged:!0},e.status=`error`,this.state.applyStepEvents([{message:"Authentication failed. Run `yarn twenty remote:add` to authenticate.",status:`error`}]),this.state.updatePipeline({status:`error`})),!1;let i=e.output.isReady;if(e.output={isReady:!0,errorLogged:!1},e.status=`done`,!n.t(this.state.frontendUrl)){let e=await this.apiService.getWorkspaceFrontendUrl();n.t(e)&&(this.state.frontendUrl=e)}return i||this.notify(),!0}},Ee=class{constructor({clientService:e,configService:t,state:n,notify:r}){this.clientService=e,this.configService=t,this.state=n,this.notify=r}async execute(e){let n=this.state.steps.generateApiClient;n.status=`in_progress`,this.notify();try{let r=await t.f(this.configService,e.tokenSources);await this.clientService.generateCoreClient({appPath:e.appPath,appAccessToken:r}),n.status=`done`}catch(e){this.state.applyStepEvents([{message:`Failed to generate API client: ${e instanceof Error?e.message:String(e)}`,status:`error`}]),n.status=`error`}this.notify()}},De=class{constructor({apiService:e,configService:t,state:n,notify:r}){this.apiService=e,this.configService=t,this.state=n,this.notify=r}async execute(e){try{let n=await t.d(this.apiService,this.configService,{name:e.manifest.application.displayName,universalIdentifier:e.manifest.application.universalIdentifier});this.registrationCredentials={clientId:n.clientId,clientSecret:n.clientSecret},this.state.applyStepEvents([{message:n.isNewRegistration?`App registration created: ${e.manifest.application.displayName}`:`Existing app registration found`,status:n.isNewRegistration?`success`:`info`},...n.isNewRegistration?[{message:`Credentials saved to config.`,status:`info`}]:[]])}catch(e){throw this.state.applyStepEvents([{message:`Failed to register app: ${e instanceof Error?e.message:String(e)}`,status:`error`}]),e}this.notify()}},Oe=class{constructor(e){this.watcher=null,this.appPath=e.appPath,this.fileFolder=e.fileFolder,this.watchPaths=e.watchPaths,this.handleFileBuilt=e.handleFileBuilt}async start(){let e=(await Promise.all(this.watchPaths.map(async e=>{let n=(0,r.join)(this.appPath,e);return await t.ut(n)?n:null}))).filter(e=>e!==null);e.length!==0&&(this.watcher=f.default.watch(e,{awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on(`all`,(e,t)=>{e===`addDir`||e===`unlinkDir`||((e===`add`||e===`change`)&&this.copyAndNotify(t),e===`unlink`&&this.handleUnlink(t))}))}async close(){await this.watcher?.close()}async copyAndNotify(e){let n=(0,r.relative)(this.appPath,e),a=(0,r.join)(t.mt,n),o=(0,r.join)(this.appPath,a);await t.lt((0,r.dirname)(o)),await t.st(e,o);let s=await(0,i.readFile)(o),l=c.default.createHash(`md5`).update(s).digest(`hex`);this.handleFileBuilt({fileFolder:this.fileFolder,builtPath:a,sourcePath:n,checksum:l})}async handleUnlink(e){let n=(0,r.join)(t.mt,(0,r.relative)(this.appPath,e));await t.ft((0,r.join)(this.appPath,n))}},ke=class{constructor(e){this.process=null,this.pendingErrors=[],this.buffer=``,this.hasErrors=!1,this.appPath=e.appPath,this.onErrors=e.onErrors}async start(){let e=s.default.join(this.appPath,`node_modules`,`.bin`,`tsc`);if(!await t.ut(e))return;let n=s.default.join(this.appPath,`tsconfig.json`);this.process=(0,l.spawn)(e,[`--watch`,`--noEmit`,`--pretty`,`false`,`-p`,n],{cwd:this.appPath,stdio:[`ignore`,`pipe`,`pipe`]}),this.process.on(`error`,()=>{this.process=null}),this.process.stdout?.on(`data`,e=>{this.handleOutput(e.toString())}),this.process.stderr?.on(`data`,e=>{this.handleOutput(e.toString())})}close(){this.process?.kill(),this.process=null}handleOutput(e){this.buffer+=e;let t=this.buffer.split(`
|
|
342
|
-
`);this.buffer=t.pop()??``;for(let e of t)this.processLine(e)}processLine(e){if(e.includes(`Starting compilation in watch mode...`)||e.includes(`Starting incremental compilation...`)){this.pendingErrors=[];return}if(e.includes(`Watching for file changes.`)){let e=this.hasErrors;this.hasErrors=this.pendingErrors.length>0,(this.hasErrors||e)&&this.onErrors(this.pendingErrors),this.pendingErrors=[];return}let n=t.at(e);n&&this.pendingErrors.push(n)}},Ae=new Set([`node_modules`,`dist`,`.twenty`]),je=class{constructor(e){this.watcher=null,this.appPath=e.appPath,this.handleChangeDetected=e.handleChangeDetected,this.verbose=e.verbose??!1}async start(){let e=this.appPath;this.watcher=f.default.watch(this.appPath,{ignoreInitial:!this.verbose,ignored:t=>{let n=(0,r.relative)(e,t);if(n===``)return!1;let i=n.split(r.default.sep)[0];return Ae.has(i)||i.startsWith(`.`)},awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on(`all`,(e,n)=>{if(e===`addDir`||e===`unlinkDir`)return;let i=(0,r.relative)(this.appPath,n),a=i.startsWith(t.gt),o=[`package.json`,`yarn.lock`].includes(i);!(i.endsWith(`.ts`)||i.endsWith(`.tsx`))&&!a&&!o||this.handleChangeDetected(i,e)})}async close(){await this.watcher?.close()}},Me=class{constructor(e){this.manifestWatcher=null,this.logicFunctionsWatcher=null,this.frontComponentsWatcher=null,this.assetWatcher=null,this.dependencyWatcher=null,this.tscWatcher=null,this.state=e.state,this.scheduleSync=e.scheduleSync,this.notify=e.notify,this.onFileBuilt=e.onFileBuilt,this.shouldSkipTypecheck=e.shouldSkipTypecheck,this.verbose=e.verbose??!1}async start(){this.state.steps.startWatchers.status=`in_progress`,this.notify(),this.manifestWatcher=new je({appPath:this.state.appPath,handleChangeDetected:this.handleChangeDetected.bind(this),verbose:this.verbose}),await this.manifestWatcher.start()}async handleWatcherRestarts(e){let{logicFunctions:t,frontComponents:n}=e.filePaths;if(!this.state.steps.startWatchers.output.watchersStarted){this.state.steps.startWatchers.output.watchersStarted=!0,this.state.steps.startWatchers.status=`done`,await this.startFileWatchers(t,n);return}this.logicFunctionsWatcher?.shouldRestart(t)&&await this.logicFunctionsWatcher.restart(t),this.frontComponentsWatcher?.shouldRestart(n)&&await this.frontComponentsWatcher.restart(n)}async close(){this.tscWatcher?.close(),await Promise.all([this.manifestWatcher?.close(),this.logicFunctionsWatcher?.close(),this.frontComponentsWatcher?.close(),this.assetWatcher?.close(),this.dependencyWatcher?.close()])}handleChangeDetected(e,t){this.state.addEvent({message:`Change detected: ${e}`,status:`info`,spacingBefore:!0}),t===`unlink`?this.state.removeEntity(e):this.state.updateEntityStatus(e,`building`),this.notify(),this.scheduleSync()}handleFileBuildError(e){this.state.addEvent({message:`Build failed:`,status:`error`});for(let t of e)this.state.addEvent({message:t.error,status:`error`});this.notify()}handleFileBuilt(e){this.verbose&&this.state.addEvent({message:`Successfully built ${e.builtPath}`,status:`success`}),this.state.steps.uploadFiles.output.builtFileInfos.set(e.builtPath,{checksum:e.checksum,builtPath:e.builtPath,sourcePath:e.sourcePath,fileFolder:e.fileFolder,usesSdkClient:e.usesSdkClient}),this.onFileBuilt(e),this.notify(),this.scheduleSync()}async startFileWatchers(e,t){await Promise.all([this.startTscWatcher(),this.startLogicFunctionsWatcher(e),this.startFrontComponentsWatcher(t),this.startAssetWatcher(),this.startDependencyWatcher()])}async startLogicFunctionsWatcher(e){this.logicFunctionsWatcher=t.it({appPath:this.state.appPath,sourcePaths:e,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.logicFunctionsWatcher.start()}async startFrontComponentsWatcher(e){this.frontComponentsWatcher=t.rt({appPath:this.state.appPath,sourcePaths:e,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.frontComponentsWatcher.start()}async startAssetWatcher(){this.assetWatcher=new Oe({appPath:this.state.appPath,fileFolder:t.Ct.PublicAsset,watchPaths:[t.gt],handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.assetWatcher.start()}async startDependencyWatcher(){this.dependencyWatcher=new Oe({appPath:this.state.appPath,fileFolder:t.Ct.Dependencies,watchPaths:[`package.json`,`yarn.lock`],handleFileBuilt:this.handleFileBuilt.bind(this)}),this.dependencyWatcher.start()}async startTscWatcher(){this.tscWatcher=new ke({appPath:this.state.appPath,onErrors:this.handleTypecheckErrors.bind(this)}),await this.tscWatcher.start()}handleTypecheckErrors(e){e.length===0?this.state.addEvent({message:`Typecheck passed`,status:`success`}):this.state.applyStepEvents(e.map(e=>({message:`Type error in ${e.file}(${e.line},${e.column}): ${e.text}`,status:`error`}))),this.notify()}},Ne=50,Pe={create:`created`,update:`updated`,delete:`deleted`},Fe=e=>{if(e.type===`create`)return t.u(e.flatEntity)??`unknown`;let n=t.u(e.flatEntity);return n&&n!==e.universalIdentifier?`${n} (${e.universalIdentifier})`:e.universalIdentifier},Ie=e=>{if(e.type!==`update`||!n.t(e.diff))return``;let t=Object.keys(e.diff);return t.length===0?``:` [${t.join(`, `)}] changed`},Le=e=>{let t=e??[];if(t.length===0)return[{message:`No metadata changes`,status:`info`}];let r={create:0,update:0,delete:0};for(let e of t)r[e.type]+=1;let i=[{message:`Metadata changes: ${[r.create>0?`${r.create} created`:null,r.update>0?`${r.update} updated`:null,r.delete>0?`${r.delete} deleted`:null].filter(n.t).join(`, `)}`,status:`info`}],a=t.slice(0,Ne);for(let e of a){let t=Fe(e),n=Ie(e);i.push({message:` ${Pe[e.type]} ${e.metadataName} ${t}${n}`,status:`info`})}let o=t.length-a.length;return o>0&&i.push({message:` …and ${o} more change(s)`,status:`info`}),i},Re=class{constructor({apiService:e,state:t,notify:n,verbose:r,force:i,interactive:a,onExit:o}){this.apiService=e,this.state=t,this.notify=n,this.verbose=r??!1,this.force=i??!1,this.interactive=a??!1,this.onExit=o}async execute(e){let n=this.state.steps.syncApplication;n.status=`in_progress`,this.state.updatePipeline({status:`syncing`});let r=[],i=t.Q({manifest:e.manifest,builtFileInfos:e.builtFileInfos});if(r.push({message:`Manifest checksums set`,status:`info`}),await t.Z(e.appPath,i),r.push({message:`Manifest saved to output directory`,status:`info`}),!this.force){r.push({message:`Computing metadata plan`,status:`info`});let e=await this.apiService.syncApplication(i,{dryRun:!0});if(!e.success){this.applyFailure(e,r);return}if(t.l(e.data.actions)&&await this.gateDestructiveChange(t.c(e.data.actions),r))return}r.push({message:`Syncing manifest`,status:`info`});let a=await this.apiService.syncApplication(i);if(a.success){r.push(...Le(a.data.actions)),r.push({message:`✓ Synced`,status:`success`}),n.output={syncStatus:`synced`,error:null},n.status=`done`,this.state.updatePipeline({status:`synced`,error:null}),this.state.updateAllEntitiesStatus(`success`),this.state.applyStepEvents(r);return}this.applyFailure(a,r)}async gateDestructiveChange(e,t){let n=this.state.steps.syncApplication,r=(e,r)=>{t.push({message:e,status:`warning`}),n.output={syncStatus:`idle`,error:null},n.status=`done`,this.state.updatePipeline({status:`idle`,error:null}),this.state.applyStepEvents(t),this.onExit?.({code:1,message:r})};return this.interactive?(this.state.applyStepEvents(t),t.length=0,await this.state.requestDestructiveConfirmation(e)?!1:(r(`Declined ${e} destructive change(s)`,`Stopping: declined ${e} destructive change(s). Re-run with \`yarn twenty dev --force\` to apply deletions or \`yarn twenty plan\` to preview changes.`),!0)):(r(`${e} destructive change(s) require --force`,`Stopping: ${e} destructive change(s) need confirmation. Re-run with \`yarn twenty dev --force\` to apply deletions.`),!0)}applyFailure(e,n){let r=this.state.steps.syncApplication,i=this.verbose?null:t.P(e.error);i?(n.push(...i),n.push({message:`Add --verbose to see full error log`,status:`info`})):n.push({message:`Sync failed with error: ${e.message??`Sync failed`}`,status:`error`});let a=t.s(e.message);a&&n.push({message:a,status:`info`});let o=i?i[0].message:`Sync failed`;r.output={syncStatus:`error`,error:o},r.status=`error`,this.state.updatePipeline({status:`error`,error:o}),this.state.updateAllEntitiesStatus(`error`),this.state.applyStepEvents(n)}},ze=class{constructor({state:e,notify:t,verbose:n}){this.uploadedCount=0,this.failedCount=0,this.totalQueued=0,this.state=e,this.notify=t,this.verbose=n??!1}get isInitialized(){return n.t(this.state.steps.uploadFiles.output.fileUploader)}initialize(e){let n=this.state.steps.uploadFiles;n.output={...n.output,fileUploader:new t.o({appPath:e.appPath,applicationUniversalIdentifier:e.universalIdentifier})},n.status=`in_progress`,this.notify(),this.uploadPendingFiles()}uploadFile(e,t,n){let r=this.state.steps.uploadFiles;if(!r.output.fileUploader)return;r.status=`in_progress`,this.totalQueued++,this.verbose&&this.state.addEvent({message:`Uploading ${e}`,status:`info`}),this.state.updateEntityStatus(t,`uploading`),this.notify();let i=r.output.fileUploader.uploadFile({builtPath:e,fileFolder:n}).then(n=>{n.success?(this.uploadedCount++,this.verbose&&this.state.addEvent({message:`Successfully uploaded ${e}`,status:`success`}),this.state.updateEntityStatus(t,`success`)):(this.failedCount++,this.state.addEvent({message:`Failed to upload ${e}: ${n.error}`,status:`error`}))}).catch(t=>{this.failedCount++,this.state.addEvent({message:`Upload failed for ${e}: ${t}`,status:`error`})}).finally(()=>{r.output.activeUploads.delete(i),r.output.activeUploads.size===0&&(this.logUploadSummary(),r.status=`done`,this.notify())});r.output.activeUploads.add(i)}async waitForUploads(){let e=this.state.steps.uploadFiles;for(;e.output.activeUploads.size>0;)await Promise.all(e.output.activeUploads);e.status=`done`,this.notify()}logUploadSummary(){if(this.totalQueued===0){this.resetCounters();return}this.failedCount>0&&this.state.addEvent({message:`Uploaded ${this.uploadedCount}/${this.totalQueued} files (${this.failedCount} failed)`,status:`error`}),this.state.addEvent({message:`Successfully uploaded ${this.uploadedCount} file${this.uploadedCount===1?``:`s`}`,status:`success`}),this.resetCounters()}resetCounters(){this.uploadedCount=0,this.failedCount=0,this.totalQueued=0}uploadPendingFiles(){for(let[e,{fileFolder:t,sourcePath:n}]of this.state.steps.uploadFiles.output.builtFileInfos.entries())this.uploadFile(e,n,t)}},Be=class{constructor(e){this.syncTimer=null,this.serverCheckInterval=null,this.skipTypecheck=!0,this.debounceMs=e.debounceMs??1e3,this.state=e.state,this.verbose=e.verbose??!1,this.apiService=new t.z({disableInterceptors:!0});let n=this.apiService,r=new t.U;this.clientService=new t.h;let i={state:this.state,notify:()=>this.state.notify()};this.checkServerStep=new R({...i,apiService:n}),this.buildManifestStep=new Te(i),this.registerAppStep=new De({...i,apiService:n,configService:r}),this.uploadFilesStep=new ze({...i,verbose:this.verbose}),this.generateApiClientStep=new Ee({...i,clientService:this.clientService,configService:r}),this.syncApplicationStep=new Re({...i,apiService:n,verbose:this.verbose,force:e.force??!1,interactive:e.interactive??!1,onExit:e.onExit}),this.startWatchersStep=new Me({...i,scheduleSync:this.scheduleSync.bind(this),onFileBuilt:this.handleFileBuilt.bind(this),shouldSkipTypecheck:()=>this.skipTypecheck,verbose:this.verbose})}async start(){let e=r.default.join(this.state.appPath,t.mt);await t.lt(e),await t.ct(e),this.state.addEvent({message:`Using remote "${t.U.getActiveRemote()}"`,status:`info`}),this.verbose||this.state.addEvent({message:`Add --verbose to see fully detailed logs`,status:`info`}),this.state.notify(),await this.startWatchersStep.start(),this.serverCheckInterval=setInterval(()=>{this.checkServerHealth()},2e3)}async close(){this.serverCheckInterval&&clearInterval(this.serverCheckInterval),await this.startWatchersStep.close()}getState(){return this.state}handleFileBuilt(e){this.state.steps.uploadFiles.output.fileUploader&&this.uploadFilesStep.uploadFile(e.builtPath,e.sourcePath,e.fileFolder)}async checkServerHealth(){let e=this.state.steps.checkServer.output.isReady;await this.checkServerStep.execute()&&!e&&this.scheduleSync()}scheduleSync(){this.syncTimer&&clearTimeout(this.syncTimer),this.syncTimer=setTimeout(()=>{this.syncTimer=null,this.performSync()},this.debounceMs)}async performSync(){if(!this.state.pipeline.isSyncing){this.state.updatePipeline({isSyncing:!0});try{await this.runSyncPipeline()}catch(e){this.state.addEvent({message:`Sync failed with error: ${t.B(e)}`,status:`error`}),this.state.updatePipeline({status:`error`}),this.state.updateAllEntitiesStatus(`error`)}finally{this.state.updatePipeline({isSyncing:!1})}}}async runSyncPipeline(){if(!await this.checkServerStep.execute())return;this.state.steps.ensureValidTokens.status=`done`;let e=await this.buildManifestStep.execute({appPath:this.state.appPath});if(!e||(await this.startWatchersStep.handleWatcherRestarts(e),!this.uploadFilesStep.isInitialized&&!await this.initializePipeline(e.manifest)))return;let t=this.state.hasObjectsOrFieldsChanged(e.manifest);await this.uploadFilesStep.waitForUploads(),await this.syncApplicationStep.execute({manifest:e.manifest,builtFileInfos:this.state.steps.uploadFiles.output.builtFileInfos,appPath:this.state.appPath}),this.state.steps.syncApplication.output.syncStatus===`synced`&&t&&(await this.generateApiClientStep.execute({appPath:this.state.appPath,tokenSources:this.buildAppTokenSources()}),this.skipTypecheck=!1)}buildAppTokenSources(){let e=this.registerAppStep.registrationCredentials,n=this.state.steps.resolveApplication.output.applicationId;return{credentials:e?.clientSecret?{clientId:e.clientId,clientSecret:e.clientSecret}:void 0,fetchTokenPair:n?t.g(this.apiService,n):void 0}}async initializePipeline(e){await this.registerAppStep.execute({manifest:e});let t=await this.apiService.createDevelopmentApplication({universalIdentifier:e.application.universalIdentifier,name:e.application.displayName});return!t.success||!t.data?(this.state.applyStepEvents([{message:`Failed to install development application`,status:`error`},{message:JSON.stringify(t,null,2),status:`error`}]),this.state.updatePipeline({status:`error`}),!1):(this.state.steps.resolveApplication.output={applicationId:t.data.id,universalIdentifier:t.data.universalIdentifier},this.state.steps.resolveApplication.status=`done`,this.state.applyStepEvents([{message:`Application installed`,status:`success`}]),this.uploadFilesStep.initialize({appPath:this.state.appPath,universalIdentifier:e.application.universalIdentifier}),!0)}},Ve={objects:t.ht.Object,fields:t.ht.Field,logicFunctions:t.ht.LogicFunction,frontComponents:t.ht.FrontComponent,roles:t.ht.Role,skills:t.ht.Skill,connectionProviders:t.ht.ConnectionProvider,views:t.ht.View,viewFields:t.ht.ViewField,navigationMenuItems:t.ht.NavigationMenuItem,pageLayouts:t.ht.PageLayout,pageLayoutTabs:t.ht.PageLayoutTab,commandMenuItems:t.ht.CommandMenuItem},He=200,Ue={pending:[`building`,`uploading`,`success`,`error`],building:[`pending`,`uploading`,`success`,`error`],uploading:[`pending`,`success`,`error`],success:[`pending`,`building`,`uploading`,`error`],error:[`pending`,`building`,`uploading`,`success`]},We=class{constructor(e){this.confirmationResolver=null,this.eventIdCounter=0,this.appPath=e.appPath,this.previousObjectsFieldsFingerprint=null,this.pendingConfirmation=null,this.steps={checkServer:{output:{isReady:!1,errorLogged:!1},status:`idle`},ensureValidTokens:{output:{},status:`idle`},resolveApplication:{output:{applicationId:null,universalIdentifier:null},status:`idle`},buildManifest:{output:{result:null},status:`idle`},uploadFiles:{output:{fileUploader:null,builtFileInfos:new Map,activeUploads:new Set},status:`idle`},generateApiClient:{output:{},status:`idle`},syncApplication:{output:{syncStatus:`idle`,error:null},status:`idle`},startWatchers:{output:{watchersStarted:!1},status:`idle`}},this.pipeline={status:`idle`,isSyncing:!1,error:null,appName:null},this.versionInfo=null,this.entities=new Map,this.events=[]}setVersionInfo(e){this.versionInfo=e,this.notify()}notify(){this.onChange?.()}requestDestructiveConfirmation(e){return new Promise(t=>{this.pendingConfirmation={deleteCount:e},this.confirmationResolver=t,this.notify()})}resolveDestructiveConfirmation(e){let t=this.confirmationResolver;this.pendingConfirmation=null,this.confirmationResolver=null,this.notify(),t?.(e)}updatePipeline(e){Object.assign(this.pipeline,e),this.notify()}applyStepEvents(e){let t=e.map(e=>(this.eventIdCounter+=1,{...e,id:this.eventIdCounter,timestamp:new Date,message:e.message.slice(0,5e3)}));this.events=[...this.events.slice(-(He-t.length)),...t]}addEvent(e){this.applyStepEvents([e])}updateEntityStatus(e,t){let n=new Map(this.entities),r=n.get(e);r?.status&&!Ue[r.status].includes(t)||(n.set(e,r?{...r,status:t}:{name:e,path:e,status:t}),this.entities=n)}removeEntity(e){let t=new Map(this.entities);t.delete(e),this.entities=t}updateAllEntitiesStatus(e){let t=new Map(this.entities);for(let[n,r]of t)t.set(n,{...r,status:e});this.entities=t}updateEntitiesFromManifest(e){let t=new Map;for(let[n,r]of Object.entries(e)){let e=Ve[n];if(e)for(let n of r)t.set(n,e)}let n=new Map(this.entities);for(let[e,r]of n)n.set(e,{...r,type:t.get(e)});for(let[e,r]of t)n.has(e)||n.set(e,{name:e,path:e,type:r,status:`pending`});this.entities=n}hasObjectsOrFieldsChanged(e){let t=JSON.stringify({objects:e.objects,fields:e.fields}),n=t!==this.previousObjectsFieldsFingerprint;return this.previousObjectsFieldsFingerprint=t,n}},Ge={idle:{color:`gray`,icon:`○`},in_progress:{color:`yellow`,icon:`spinner`},uploading:{color:`cyan`,icon:`upload`},done:{color:`green`,icon:`✓`},error:{color:`red`,icon:`✗`}},Ke=e=>({idle:`idle`,in_progress:`in_progress`,done:`done`,error:`error`})[e],qe=e=>({pending:`idle`,building:`in_progress`,uploading:`uploading`,success:`done`,error:`error`})[e],Je=e=>({idle:`idle`,building:`in_progress`,syncing:`in_progress`,synced:`done`,error:`error`})[e],Ye={idle:`Idle`,building:`Building...`,syncing:`Syncing...`,synced:`Synced`,error:`Error`},Xe=[`◐`,`◓`,`◑`,`◒`],Ze=[`↑`,`⇡`,`↑`,`⇡`],Qe={[t.ht.Object]:`Objects`,[t.ht.Field]:`Fields`,[t.ht.LogicFunction]:`Logic functions`,[t.ht.FrontComponent]:`Front components`,[t.ht.CommandMenuItem]:`Command menu items`,[t.ht.Role]:`Roles`,[t.ht.Skill]:`Skills`,[t.ht.View]:`Views`,[t.ht.ViewField]:`View fields`,[t.ht.NavigationMenuItem]:`Navigation menu items`,[t.ht.PageLayout]:`Page layouts`,[t.ht.PageLayoutTab]:`Page layout tabs`,[t.ht.Agent]:`Agents`,[t.ht.ConnectionProvider]:`Connection providers`},$e=Object.keys(Qe),et={info:`gray`,success:`green`,error:`red`,warning:`yellow`},tt=e=>e.toLocaleTimeString(`en-US`,{hour12:!1,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),nt=(e,t=40)=>{if(e.length<=t)return e;let n=e.split(`/`);return n.length<=2?e:`.../${n.slice(-2).join(`/`)}`},rt=e=>{let t=new Map;for(let e of $e)t.set(e,[]);for(let n of e.values()){if(!n.type)continue;let e=t.get(n.type)??[];e.push(n),t.set(n.type,e)}return t},it=[{status:`success`,label:`synced`},{status:`building`,label:`building`},{status:`uploading`,label:`uploading`},{status:`pending`,label:`pending`},{status:`error`,label:`error`}],at=e=>{let t={pending:0,building:0,uploading:0,success:0,error:0};for(let n of e)t[n.status]+=1;return it.filter(({status:e})=>t[e]>0).map(({status:e,label:n})=>({status:e,count:t[e],label:n}))},ot=e=>{let t=e.steps.resolveApplication.output.applicationId;return!n.t(e.frontendUrl)||!n.t(t)?null:`${e.frontendUrl}/settings/applications/${t}`},st=e=>e.some(e=>e===`error`)?`error`:e.some(e=>e===`in_progress`)?`in_progress`:e.every(e=>e===`done`)?`done`:`idle`,ct=e=>{let t=[...e.entities.values()],n=t.some(e=>e.status===`error`),r=t.some(e=>e.status===`building`),i=t.length>0&&t.every(e=>e.status===`uploading`||e.status===`success`),a=n?`error`:r?`in_progress`:i?`done`:`idle`;return[{label:`Application Initialization`,status:st([e.steps.checkServer.status,e.steps.ensureValidTokens.status,e.steps.resolveApplication.status])},{label:`Resources Build`,status:a},{label:`Resources Upload`,status:e.steps.uploadFiles.status},{label:`Manifest Build`,status:e.steps.buildManifest.status},{label:`Application Synchronization`,status:e.steps.syncApplication.status},{label:`Api Client Generation`,status:e.steps.generateApiClient.status}]},lt=120,z=Math.round(200/lt),ut=()=>{let e=Math.floor(Date.now()/lt);return{spinnerFrame:Xe[e%Xe.length],uploadFrame:Ze[Math.floor(e/z)%Ze.length]}},B=e=>{let t=Ge[e];return t.icon===`spinner`?ut().spinnerFrame:t.icon===`upload`?ut().uploadFrame:t.icon},dt=o.default.createContext(null),ft=dt.Provider,pt=()=>{let e=o.default.useContext(dt);if(!e)throw Error(`useInk must be used within InkProvider`);return e},mt=({uiStatus:e})=>{let{Text:t}=pt(),n=B(e),r=Ge[e];return(0,p.jsxs)(t,{color:r.color,children:[n,` `]})},ht=({entity:e})=>{let{Box:t,Text:n}=pt();return(0,p.jsxs)(t,{children:[(0,p.jsx)(mt,{uiStatus:qe(e.status)}),(0,p.jsx)(n,{children:e.name}),e.path!==e.name&&(0,p.jsxs)(n,{dimColor:!0,children:[` (`,nt(e.path),`)`]})]})},gt=({type:e,entities:t})=>{let{Box:n,Text:r}=pt();return t.length===0?null:(0,p.jsxs)(n,{flexDirection:`column`,marginTop:1,children:[(0,p.jsx)(r,{bold:!0,dimColor:!0,children:Qe[e]}),t.map(e=>(0,p.jsx)(ht,{entity:e},e.path))]})},_t=({entities:e})=>{let{Box:t,Text:n}=pt();if(e.length===0)return null;let r=at(e);return(0,p.jsxs)(t,{marginTop:1,children:[(0,p.jsxs)(n,{bold:!0,dimColor:!0,children:[`Entities`,` `]}),r.map((e,r)=>(0,p.jsxs)(t,{children:[r>0&&(0,p.jsx)(n,{dimColor:!0,children:` · `}),(0,p.jsx)(mt,{uiStatus:qe(e.status)}),(0,p.jsxs)(n,{children:[e.count,` `,e.label]})]},e.status))]})},vt=()=>{let{Box:e,Text:t}=pt();return(0,p.jsx)(e,{marginTop:1,children:(0,p.jsxs)(t,{dimColor:!0,children:[(0,p.jsx)(t,{color:Ge.idle.color,children:Ge.idle.icon}),` `,`pending`,` `,(0,p.jsx)(t,{color:Ge.in_progress.color,children:Xe[0]}),` `,`building`,` `,(0,p.jsx)(t,{color:Ge.uploading.color,children:Ze[0]}),` `,`uploading`,` `,(0,p.jsx)(t,{color:Ge.done.color,children:Ge.done.icon}),` `,`success`,` `,(0,p.jsx)(t,{color:Ge.error.color,children:Ge.error.icon}),` `,`error`]})})},yt=7,bt=({versionInfo:e})=>{let{Box:t,Text:n}=pt();if(e===null)return null;let{cliVersion:r,localServerVersion:i,latestServerVersion:a,isMinorOrMajorBehind:o,daysBehind:s}=e,c=o&&s!==null&&s>yt;return(0,p.jsxs)(t,{children:[(0,p.jsx)(n,{dimColor:!0,children:`Versions: `}),(0,p.jsx)(n,{dimColor:!0,children:`CLI `}),(0,p.jsxs)(n,{children:[`v`,r]}),i!==null&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(n,{dimColor:!0,children:` • Server `}),(0,p.jsxs)(n,{color:c?`yellow`:void 0,children:[`v`,i]}),i!==null&&a!==null&&i===a&&(0,p.jsx)(n,{color:`green`,children:` ✓ latest`}),c&&a!==null&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(n,{color:`yellow`,children:[` → v`,a]}),s!==null&&(0,p.jsxs)(n,{dimColor:!0,children:[` (`,s,`d behind)`]})]})]})]})},xt=({state:e})=>{let{Text:t}=pt(),n=Je(e.pipeline.status),r=B(n),i=Ge[n],a=Ye[e.pipeline.status];return(0,p.jsxs)(t,{color:i.color,children:[r,` `,a]})},St=({label:e,status:t})=>{let{Box:n,Text:r}=pt(),i=Ke(t),a=B(i),o=Ge[i];return(0,p.jsxs)(n,{children:[(0,p.jsxs)(r,{dimColor:!0,children:[e,`: `]}),(0,p.jsxs)(r,{color:o.color,children:[a,` `,t.replace(`_`,` `)]})]})},Ct=({state:e,verbose:t=!1})=>{let{Box:n,Text:r}=pt(),i=rt(e.entities),a=ot(e);return(0,p.jsxs)(n,{flexDirection:`column`,borderStyle:`classic`,borderColor:`gray`,paddingX:1,children:[(0,p.jsx)(r,{bold:!0,color:`cyan`,children:`Application`}),(0,p.jsxs)(n,{marginLeft:2,flexDirection:`column`,children:[(0,p.jsxs)(n,{children:[(0,p.jsx)(r,{dimColor:!0,children:`Name: `}),(0,p.jsx)(r,{bold:!0,children:e.pipeline.appName??`Loading...`})]}),(0,p.jsxs)(n,{children:[(0,p.jsx)(r,{dimColor:!0,children:`Overall Status: `}),(0,p.jsx)(xt,{state:e})]}),a&&(0,p.jsxs)(n,{children:[(0,p.jsx)(r,{dimColor:!0,children:`Open:`}),(0,p.jsxs)(r,{bold:!0,color:`cyan`,children:[` `,a]})]}),(0,p.jsx)(bt,{versionInfo:e.versionInfo})]}),(0,p.jsx)(n,{marginLeft:2,flexDirection:`column`,marginTop:1,children:ct(e).map(e=>(0,p.jsx)(St,{label:e.label,status:e.status},e.label))}),(0,p.jsx)(n,{marginLeft:2,flexDirection:`column`,children:t?$e.map(e=>(0,p.jsx)(gt,{type:e,entities:i.get(e)??[]},e)):(0,p.jsx)(_t,{entities:Array.from(e.entities.values())})})]})},wt=({state:e})=>{let{Box:t,Text:n,useInput:r}=pt(),i=e.pendingConfirmation;return r((t,n)=>{if(e.pendingConfirmation){if(t.toLowerCase()===`y`){e.resolveDestructiveConfirmation(!0);return}(t.toLowerCase()===`n`||n.escape)&&e.resolveDestructiveConfirmation(!1)}}),i?(0,p.jsxs)(t,{marginTop:1,flexDirection:`column`,borderStyle:`classic`,borderColor:`red`,paddingX:1,children:[(0,p.jsxs)(n,{color:`red`,bold:!0,children:[`⚠ `,i.deleteCount,` destructive change(s) detected`]}),(0,p.jsxs)(n,{children:[`Apply and DESTROY `,i.deleteCount,` metadata entity(ies)? Press`,` `,(0,p.jsx)(n,{color:`green`,bold:!0,children:`y`}),` `,`to apply,`,` `,(0,p.jsx)(n,{color:`red`,bold:!0,children:`n`}),` `,`to cancel and stop watching.`]})]}):null},Tt=({event:e})=>{let{Box:t,Text:n}=pt(),r=et[e.status],i=tt(e.timestamp);return(0,p.jsxs)(t,{marginTop:+!!e.spacingBefore,children:[(0,p.jsxs)(n,{dimColor:!0,children:[i,` `]}),(0,p.jsx)(n,{color:r,children:e.message})]})},Et=new Set([`building`,`syncing`]),Dt=120,Ot=80,kt=({uiStateManager:e,verbose:t})=>{let{Box:n,Static:r}=pt(),[,i]=(0,o.useReducer)(e=>e+1,0),a=(0,o.useRef)(null),s=(0,o.useRef)(0),c=(0,o.useCallback)(()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,s.current=Date.now(),i()},Ot)},[]);(0,o.useEffect)(()=>e.subscribe(()=>{c()}),[e,c]),(0,o.useEffect)(()=>{let t=setInterval(()=>{let t=e.getSnapshot();Et.has(t.pipeline.status)&&(Date.now()-s.current<Dt||i())},Dt);return()=>clearInterval(t)},[e]),(0,o.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]);let l=e.getSnapshot();return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r,{items:l.events,children:e=>(0,p.jsx)(Tt,{event:e},e.id)}),(0,p.jsxs)(n,{marginTop:1,flexDirection:`column`,children:[(0,p.jsx)(Ct,{state:l,verbose:t}),t&&(0,p.jsx)(vt,{})]}),l.pendingConfirmation&&(0,p.jsx)(wt,{state:l})]})},At=async(e,t=!1)=>{let{render:n,Box:r,Text:i,Static:a,useInput:o}=await import(`ink`),{unmount:s}=n((0,p.jsx)(ft,{value:{Box:r,Text:i,Static:a,useInput:o},children:(0,p.jsx)(kt,{uiStateManager:e,verbose:t})}));return{unmount:s}},jt=class{constructor(e){this.listeners=new Set,this.pendingNotify=!1,this.orchestratorState=e}getSnapshot(){return this.orchestratorState}subscribe(e){return this.listeners.add(e),e(this.orchestratorState),()=>this.listeners.delete(e)}notify(){this.pendingNotify||(this.pendingNotify=!0,queueMicrotask(()=>{this.pendingNotify=!1;for(let e of this.listeners)e(this.orchestratorState)}))}},Mt=class{constructor(){this.orchestrator=null,this.unmountUI=null}async close(){this.unmountUI?.(),await this.orchestrator?.close()}getOrchestrator(){return this.orchestrator}async ensureAuthenticatedBeforeLaunch(){let{serverUp:e,authValid:n}=await new t.z({disableInterceptors:!0}).validateAuth();e&&!n&&await t.V(t.U.getActiveRemote())}async execute(e){let n=e.appPath??t.Ot;await x(n),e.headless&&await t.y(),await this.ensureAuthenticatedBeforeLaunch();let r=new We({appPath:n});if(!e.headless){let n=new jt(r);r.onChange=()=>n.notify();let{unmount:i}=await At(n,e.verbose);this.unmountUI=i,t.b().then(e=>r.setVersionInfo(e))}this.orchestrator=new Be({state:r,verbose:e.verbose,debounceMs:e.debounceMs,force:e.force,interactive:!e.headless&&process.stdout.isTTY===!0,onExit:({code:t,message:n})=>{e.headless||this.close().then(()=>{console.log(u.default.yellow(`\n${n}`)),process.exit(t)})}}),await this.orchestrator.start(),e.headless||this.setupGracefulShutdown()}setupGracefulShutdown(){let e=()=>void this.close().then(()=>process.exit(0));process.on(`SIGINT`,e),process.on(`SIGTERM`,e)}},Nt=async(e,{force:t})=>{if(t)return!0;if(!process.stdout.isTTY)return console.error(u.default.red(`${e} destructive change(s) detected. Run \`yarn twenty plan\` to review them, or re-run with --force to apply non-interactively.`)),!1;let{confirmed:n}=await d.default.prompt([{type:`confirm`,name:`confirmed`,message:`Twenty will DESTROY ${e} metadata entity(ies) (run \`yarn twenty plan\` for details). Do you want to perform these actions?`,default:!1}]);return n},Pt=class{async execute(e){let n=e.appPath??t.Ot,r=e.apply??!1;await x(n);let i=t.U.getActiveRemote();console.log(u.default.blue(`${r?`Applying application manifest`:`Planning application apply`} on ${i}...`)),console.log(u.default.gray(`App path: ${n}\n`));let a=await t.a({appPath:n,verbose:e.verbose,apply:r,force:e.force,onProgress:e=>console.log(u.default.gray(e)),onPlan:e=>console.log(`\n${e}\n`),confirmApply:t=>Nt(t,{force:e.force})});if(a.success||(a.error.code===t.K.APPLY_ABORTED&&(console.log(u.default.yellow(a.error.message)),process.exit(1)),console.error(u.default.red(a.error.message)),process.exit(1)),!r){console.log(u.default.green(`\n✓ Plan complete for ${a.data.applicationDisplayName} — no changes were applied`));return}console.log(u.default.green(`\n✓ Synced ${a.data.applicationDisplayName} (${a.data.fileCount} file${a.data.fileCount===1?``:`s`})`)),console.log(u.default.gray(`Output: ${a.data.outputDir}`))}},Ft=e=>{let t=new be,n=new ye;e.command(`dev:function:logs [appPath]`).description(`Stream logic function logs`).option(`-u, --functionUniversalIdentifier <functionUniversalIdentifier>`,`Only show logs for the function with this universal ID`).option(`-n, --functionName <functionName>`,`Only show logs for the function with this name`).action(async(e,n)=>{await t.execute({...n,appPath:g(e)})}),e.command(`dev:function:exec [appPath]`).description(`Execute a logic function`).option(`--postInstall`,`Execute post-install logic function if defined`).option(`--preInstall`,`Execute pre-install logic function if defined`).option(`--uninstall`,`Execute uninstall logic function if defined`).option(`-p, --payload <payload>`,`JSON payload to send to the function`,`{}`).option(`-u, --functionUniversalIdentifier <functionUniversalIdentifier>`,`Universal ID of the function to execute`).option(`-n, --functionName <functionName>`,`Name of the function to execute`).action(async(e,t)=>{!t?.postInstall&&!t?.preInstall&&!t?.uninstall&&!t?.functionUniversalIdentifier&&!t?.functionName&&(console.error(u.default.red(`Error: Either --postInstall, --preInstall, --uninstall, --functionName (-n), or --functionUniversalIdentifier (-u) is required.`)),process.exit(1)),await n.execute({...t,payload:t?.payload??`{}`,appPath:g(e)})})},It=class{async execute(e){let n=e.appPath??t.Ot,i=(0,r.join)(n,`node_modules`,`twenty-client-sdk`);await t.ut(i)||(console.error(u.default.red(`Cannot find twenty-client-sdk in ${n}.\n\n Install it first:
|
|
348
|
+
`);this.buffer=t.pop()??``;for(let e of t)this.processLine(e)}processLine(e){if(e.includes(`Starting compilation in watch mode...`)||e.includes(`Starting incremental compilation...`)){this.pendingErrors=[];return}if(e.includes(`Watching for file changes.`)){let e=this.hasErrors;this.hasErrors=this.pendingErrors.length>0,(this.hasErrors||e)&&this.onErrors(this.pendingErrors),this.pendingErrors=[];return}let n=t.at(e);n&&this.pendingErrors.push(n)}},Ae=new Set([`node_modules`,`dist`,`.twenty`]),je=class{constructor(e){this.watcher=null,this.appPath=e.appPath,this.handleChangeDetected=e.handleChangeDetected,this.verbose=e.verbose??!1}async start(){let e=this.appPath;this.watcher=f.default.watch(this.appPath,{ignoreInitial:!this.verbose,ignored:t=>{let n=(0,r.relative)(e,t);if(n===``)return!1;let i=n.split(r.default.sep)[0];return Ae.has(i)||i.startsWith(`.`)},awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on(`all`,(e,n)=>{if(e===`addDir`||e===`unlinkDir`)return;let i=(0,r.relative)(this.appPath,n),a=i.startsWith(t.gt),o=[`package.json`,`yarn.lock`].includes(i);!(i.endsWith(`.ts`)||i.endsWith(`.tsx`))&&!a&&!o||this.handleChangeDetected(i,e)})}async close(){await this.watcher?.close()}},Me=class{constructor(e){this.manifestWatcher=null,this.logicFunctionsWatcher=null,this.frontComponentsWatcher=null,this.assetWatcher=null,this.dependencyWatcher=null,this.tscWatcher=null,this.state=e.state,this.scheduleSync=e.scheduleSync,this.notify=e.notify,this.onFileBuilt=e.onFileBuilt,this.shouldSkipTypecheck=e.shouldSkipTypecheck,this.verbose=e.verbose??!1}async start(){this.state.steps.startWatchers.status=`in_progress`,this.notify(),this.manifestWatcher=new je({appPath:this.state.appPath,handleChangeDetected:this.handleChangeDetected.bind(this),verbose:this.verbose}),await this.manifestWatcher.start()}async handleWatcherRestarts(e){let{logicFunctions:t,frontComponents:n}=e.filePaths;if(!this.state.steps.startWatchers.output.watchersStarted){this.state.steps.startWatchers.output.watchersStarted=!0,this.state.steps.startWatchers.status=`done`,await this.startFileWatchers(t,n);return}this.logicFunctionsWatcher?.shouldRestart(t)&&await this.logicFunctionsWatcher.restart(t),this.frontComponentsWatcher?.shouldRestart(n)&&await this.frontComponentsWatcher.restart(n)}async close(){this.tscWatcher?.close(),await Promise.all([this.manifestWatcher?.close(),this.logicFunctionsWatcher?.close(),this.frontComponentsWatcher?.close(),this.assetWatcher?.close(),this.dependencyWatcher?.close()])}handleChangeDetected(e,t){this.state.addEvent({message:`Change detected: ${e}`,status:`info`,spacingBefore:!0}),t===`unlink`?this.state.removeEntity(e):this.state.updateEntityStatus(e,`building`),this.notify(),this.scheduleSync()}handleFileBuildError(e){this.state.addEvent({message:`Build failed:`,status:`error`});for(let t of e)this.state.addEvent({message:t.error,status:`error`});this.notify()}handleFileBuilt(e){this.verbose&&this.state.addEvent({message:`Successfully built ${e.builtPath}`,status:`success`}),this.state.steps.uploadFiles.output.builtFileInfos.set(e.builtPath,{checksum:e.checksum,builtPath:e.builtPath,sourcePath:e.sourcePath,fileFolder:e.fileFolder,usesSdkClient:e.usesSdkClient}),this.onFileBuilt(e),this.notify(),this.scheduleSync()}async startFileWatchers(e,t){await Promise.all([this.startTscWatcher(),this.startLogicFunctionsWatcher(e),this.startFrontComponentsWatcher(t),this.startAssetWatcher(),this.startDependencyWatcher()])}async startLogicFunctionsWatcher(e){this.logicFunctionsWatcher=t.it({appPath:this.state.appPath,sourcePaths:e,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.logicFunctionsWatcher.start()}async startFrontComponentsWatcher(e){this.frontComponentsWatcher=t.rt({appPath:this.state.appPath,sourcePaths:e,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.frontComponentsWatcher.start()}async startAssetWatcher(){this.assetWatcher=new Oe({appPath:this.state.appPath,fileFolder:t.St.PublicAsset,watchPaths:[t.gt],handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.assetWatcher.start()}async startDependencyWatcher(){this.dependencyWatcher=new Oe({appPath:this.state.appPath,fileFolder:t.St.Dependencies,watchPaths:[`package.json`,`yarn.lock`],handleFileBuilt:this.handleFileBuilt.bind(this)}),this.dependencyWatcher.start()}async startTscWatcher(){this.tscWatcher=new ke({appPath:this.state.appPath,onErrors:this.handleTypecheckErrors.bind(this)}),await this.tscWatcher.start()}handleTypecheckErrors(e){e.length===0?this.state.addEvent({message:`Typecheck passed`,status:`success`}):this.state.applyStepEvents(e.map(e=>({message:`Type error in ${e.file}(${e.line},${e.column}): ${e.text}`,status:`error`}))),this.notify()}},Ne=50,Pe={create:`created`,update:`updated`,delete:`deleted`},Fe=e=>{if(e.type===`create`)return t.u(e.flatEntity)??`unknown`;let n=t.u(e.flatEntity);return n&&n!==e.universalIdentifier?`${n} (${e.universalIdentifier})`:e.universalIdentifier},Ie=e=>{if(e.type!==`update`||!n.t(e.diff))return``;let t=Object.keys(e.diff);return t.length===0?``:` [${t.join(`, `)}] changed`},Le=e=>{let t=e??[];if(t.length===0)return[{message:`No metadata changes`,status:`info`}];let r={create:0,update:0,delete:0};for(let e of t)r[e.type]+=1;let i=[{message:`Metadata changes: ${[r.create>0?`${r.create} created`:null,r.update>0?`${r.update} updated`:null,r.delete>0?`${r.delete} deleted`:null].filter(n.t).join(`, `)}`,status:`info`}],a=t.slice(0,Ne);for(let e of a){let t=Fe(e),n=Ie(e);i.push({message:` ${Pe[e.type]} ${e.metadataName} ${t}${n}`,status:`info`})}let o=t.length-a.length;return o>0&&i.push({message:` …and ${o} more change(s)`,status:`info`}),i},Re=class{constructor({apiService:e,state:t,notify:n,verbose:r,force:i,interactive:a,onExit:o}){this.apiService=e,this.state=t,this.notify=n,this.verbose=r??!1,this.force=i??!1,this.interactive=a??!1,this.onExit=o}async execute(e){let n=this.state.steps.syncApplication;n.status=`in_progress`,this.state.updatePipeline({status:`syncing`});let r=[],i=t.Q({manifest:e.manifest,builtFileInfos:e.builtFileInfos});if(r.push({message:`Manifest checksums set`,status:`info`}),await t.Z(e.appPath,i),r.push({message:`Manifest saved to output directory`,status:`info`}),!this.force){r.push({message:`Computing metadata plan`,status:`info`});let e=await this.apiService.syncApplication(i,{dryRun:!0});if(!e.success){this.applyFailure(e,r);return}if(t.l(e.data.actions)&&await this.gateDestructiveChange(t.c(e.data.actions),r))return}r.push({message:`Syncing manifest`,status:`info`});let a=await this.apiService.syncApplication(i);if(a.success){r.push(...Le(a.data.actions)),r.push({message:`✓ Synced`,status:`success`}),n.output={syncStatus:`synced`,error:null},n.status=`done`,this.state.updatePipeline({status:`synced`,error:null}),this.state.updateAllEntitiesStatus(`success`),this.state.applyStepEvents(r);return}this.applyFailure(a,r)}async gateDestructiveChange(e,t){let n=this.state.steps.syncApplication,r=(e,r)=>{t.push({message:e,status:`warning`}),n.output={syncStatus:`idle`,error:null},n.status=`done`,this.state.updatePipeline({status:`idle`,error:null}),this.state.applyStepEvents(t),this.onExit?.({code:1,message:r})};return this.interactive?(this.state.applyStepEvents(t),t.length=0,await this.state.requestDestructiveConfirmation(e)?!1:(r(`Declined ${e} destructive change(s)`,`Stopping: declined ${e} destructive change(s). Re-run with \`yarn twenty dev --force\` to apply deletions or \`yarn twenty plan\` to preview changes.`),!0)):(r(`${e} destructive change(s) require --force`,`Stopping: ${e} destructive change(s) need confirmation. Re-run with \`yarn twenty dev --force\` to apply deletions.`),!0)}applyFailure(e,n){let r=this.state.steps.syncApplication,i=this.verbose?null:t.P(e.error);i?(n.push(...i),n.push({message:`Add --verbose to see full error log`,status:`info`})):n.push({message:`Sync failed with error: ${e.message??`Sync failed`}`,status:`error`});let a=t.s(e.message);a&&n.push({message:a,status:`info`});let o=i?i[0].message:`Sync failed`;r.output={syncStatus:`error`,error:o},r.status=`error`,this.state.updatePipeline({status:`error`,error:o}),this.state.updateAllEntitiesStatus(`error`),this.state.applyStepEvents(n)}},ze=class{constructor({state:e,notify:t,verbose:n}){this.uploadedCount=0,this.failedCount=0,this.totalQueued=0,this.state=e,this.notify=t,this.verbose=n??!1}get isInitialized(){return n.t(this.state.steps.uploadFiles.output.fileUploader)}initialize(e){let n=this.state.steps.uploadFiles;n.output={...n.output,fileUploader:new t.o({appPath:e.appPath,applicationUniversalIdentifier:e.universalIdentifier})},n.status=`in_progress`,this.notify(),this.uploadPendingFiles()}uploadFile(e,t,n){let r=this.state.steps.uploadFiles;if(!r.output.fileUploader)return;r.status=`in_progress`,this.totalQueued++,this.verbose&&this.state.addEvent({message:`Uploading ${e}`,status:`info`}),this.state.updateEntityStatus(t,`uploading`),this.notify();let i=r.output.fileUploader.uploadFile({builtPath:e,fileFolder:n}).then(n=>{n.success?(this.uploadedCount++,this.verbose&&this.state.addEvent({message:`Successfully uploaded ${e}`,status:`success`}),this.state.updateEntityStatus(t,`success`)):(this.failedCount++,this.state.addEvent({message:`Failed to upload ${e}: ${n.error}`,status:`error`}))}).catch(t=>{this.failedCount++,this.state.addEvent({message:`Upload failed for ${e}: ${t}`,status:`error`})}).finally(()=>{r.output.activeUploads.delete(i),r.output.activeUploads.size===0&&(this.logUploadSummary(),r.status=`done`,this.notify())});r.output.activeUploads.add(i)}async waitForUploads(){let e=this.state.steps.uploadFiles;for(;e.output.activeUploads.size>0;)await Promise.all(e.output.activeUploads);e.status=`done`,this.notify()}logUploadSummary(){if(this.totalQueued===0){this.resetCounters();return}this.failedCount>0&&this.state.addEvent({message:`Uploaded ${this.uploadedCount}/${this.totalQueued} files (${this.failedCount} failed)`,status:`error`}),this.state.addEvent({message:`Successfully uploaded ${this.uploadedCount} file${this.uploadedCount===1?``:`s`}`,status:`success`}),this.resetCounters()}resetCounters(){this.uploadedCount=0,this.failedCount=0,this.totalQueued=0}uploadPendingFiles(){for(let[e,{fileFolder:t,sourcePath:n}]of this.state.steps.uploadFiles.output.builtFileInfos.entries())this.uploadFile(e,n,t)}},Be=class{constructor(e){this.syncTimer=null,this.serverCheckInterval=null,this.skipTypecheck=!0,this.debounceMs=e.debounceMs??1e3,this.state=e.state,this.verbose=e.verbose??!1,this.apiService=new t.z({disableInterceptors:!0});let n=this.apiService,r=new t.U;this.clientService=new t.h;let i={state:this.state,notify:()=>this.state.notify()};this.checkServerStep=new R({...i,apiService:n}),this.buildManifestStep=new Te(i),this.registerAppStep=new De({...i,apiService:n,configService:r}),this.uploadFilesStep=new ze({...i,verbose:this.verbose}),this.generateApiClientStep=new Ee({...i,clientService:this.clientService,configService:r}),this.syncApplicationStep=new Re({...i,apiService:n,verbose:this.verbose,force:e.force??!1,interactive:e.interactive??!1,onExit:e.onExit}),this.startWatchersStep=new Me({...i,scheduleSync:this.scheduleSync.bind(this),onFileBuilt:this.handleFileBuilt.bind(this),shouldSkipTypecheck:()=>this.skipTypecheck,verbose:this.verbose})}async start(){let e=r.default.join(this.state.appPath,t.mt);await t.lt(e),await t.ct(e),this.state.addEvent({message:`Using remote "${t.U.getActiveRemote()}"`,status:`info`}),this.verbose||this.state.addEvent({message:`Add --verbose to see fully detailed logs`,status:`info`}),this.state.notify(),await this.startWatchersStep.start(),this.serverCheckInterval=setInterval(()=>{this.checkServerHealth()},2e3)}async close(){this.serverCheckInterval&&clearInterval(this.serverCheckInterval),await this.startWatchersStep.close()}getState(){return this.state}handleFileBuilt(e){this.state.steps.uploadFiles.output.fileUploader&&this.uploadFilesStep.uploadFile(e.builtPath,e.sourcePath,e.fileFolder)}async checkServerHealth(){let e=this.state.steps.checkServer.output.isReady;await this.checkServerStep.execute()&&!e&&this.scheduleSync()}scheduleSync(){this.syncTimer&&clearTimeout(this.syncTimer),this.syncTimer=setTimeout(()=>{this.syncTimer=null,this.performSync()},this.debounceMs)}async performSync(){if(!this.state.pipeline.isSyncing){this.state.updatePipeline({isSyncing:!0});try{await this.runSyncPipeline()}catch(e){this.state.addEvent({message:`Sync failed with error: ${t.B(e)}`,status:`error`}),this.state.updatePipeline({status:`error`}),this.state.updateAllEntitiesStatus(`error`)}finally{this.state.updatePipeline({isSyncing:!1})}}}async runSyncPipeline(){if(!await this.checkServerStep.execute())return;this.state.steps.ensureValidTokens.status=`done`;let e=await this.buildManifestStep.execute({appPath:this.state.appPath});if(!e||(await this.startWatchersStep.handleWatcherRestarts(e),!this.uploadFilesStep.isInitialized&&!await this.initializePipeline(e.manifest)))return;let t=this.state.hasObjectsOrFieldsChanged(e.manifest);await this.uploadFilesStep.waitForUploads(),await this.syncApplicationStep.execute({manifest:e.manifest,builtFileInfos:this.state.steps.uploadFiles.output.builtFileInfos,appPath:this.state.appPath}),this.state.steps.syncApplication.output.syncStatus===`synced`&&t&&(await this.generateApiClientStep.execute({appPath:this.state.appPath,tokenSources:this.buildAppTokenSources()}),this.skipTypecheck=!1)}buildAppTokenSources(){let e=this.registerAppStep.registrationCredentials,n=this.state.steps.resolveApplication.output.applicationId;return{credentials:e?.clientSecret?{clientId:e.clientId,clientSecret:e.clientSecret}:void 0,fetchTokenPair:n?t.g(this.apiService,n):void 0}}async initializePipeline(e){await this.registerAppStep.execute({manifest:e});let t=await this.apiService.createDevelopmentApplication({universalIdentifier:e.application.universalIdentifier,name:e.application.displayName});return!t.success||!t.data?(this.state.applyStepEvents([{message:`Failed to install development application`,status:`error`},{message:JSON.stringify(t,null,2),status:`error`}]),this.state.updatePipeline({status:`error`}),!1):(this.state.steps.resolveApplication.output={applicationId:t.data.id,universalIdentifier:t.data.universalIdentifier},this.state.steps.resolveApplication.status=`done`,this.state.applyStepEvents([{message:`Application installed`,status:`success`}]),this.uploadFilesStep.initialize({appPath:this.state.appPath,universalIdentifier:e.application.universalIdentifier}),!0)}},Ve={objects:t.ht.Object,fields:t.ht.Field,logicFunctions:t.ht.LogicFunction,frontComponents:t.ht.FrontComponent,roles:t.ht.Role,skills:t.ht.Skill,connectionProviders:t.ht.ConnectionProvider,views:t.ht.View,viewFields:t.ht.ViewField,navigationMenuItems:t.ht.NavigationMenuItem,pageLayouts:t.ht.PageLayout,pageLayoutTabs:t.ht.PageLayoutTab,commandMenuItems:t.ht.CommandMenuItem},He=200,Ue={pending:[`building`,`uploading`,`success`,`error`],building:[`pending`,`uploading`,`success`,`error`],uploading:[`pending`,`success`,`error`],success:[`pending`,`building`,`uploading`,`error`],error:[`pending`,`building`,`uploading`,`success`]},We=class{constructor(e){this.confirmationResolver=null,this.eventIdCounter=0,this.appPath=e.appPath,this.previousObjectsFieldsFingerprint=null,this.pendingConfirmation=null,this.steps={checkServer:{output:{isReady:!1,errorLogged:!1},status:`idle`},ensureValidTokens:{output:{},status:`idle`},resolveApplication:{output:{applicationId:null,universalIdentifier:null},status:`idle`},buildManifest:{output:{result:null},status:`idle`},uploadFiles:{output:{fileUploader:null,builtFileInfos:new Map,activeUploads:new Set},status:`idle`},generateApiClient:{output:{},status:`idle`},syncApplication:{output:{syncStatus:`idle`,error:null},status:`idle`},startWatchers:{output:{watchersStarted:!1},status:`idle`}},this.pipeline={status:`idle`,isSyncing:!1,error:null,appName:null},this.versionInfo=null,this.entities=new Map,this.events=[]}setVersionInfo(e){this.versionInfo=e,this.notify()}notify(){this.onChange?.()}requestDestructiveConfirmation(e){return new Promise(t=>{this.pendingConfirmation={deleteCount:e},this.confirmationResolver=t,this.notify()})}resolveDestructiveConfirmation(e){let t=this.confirmationResolver;this.pendingConfirmation=null,this.confirmationResolver=null,this.notify(),t?.(e)}updatePipeline(e){Object.assign(this.pipeline,e),this.notify()}applyStepEvents(e){let t=e.map(e=>(this.eventIdCounter+=1,{...e,id:this.eventIdCounter,timestamp:new Date,message:e.message.slice(0,5e3)}));this.events=[...this.events.slice(-(He-t.length)),...t]}addEvent(e){this.applyStepEvents([e])}updateEntityStatus(e,t){let n=new Map(this.entities),r=n.get(e);r?.status&&!Ue[r.status].includes(t)||(n.set(e,r?{...r,status:t}:{name:e,path:e,status:t}),this.entities=n)}removeEntity(e){let t=new Map(this.entities);t.delete(e),this.entities=t}updateAllEntitiesStatus(e){let t=new Map(this.entities);for(let[n,r]of t)t.set(n,{...r,status:e});this.entities=t}updateEntitiesFromManifest(e){let t=new Map;for(let[n,r]of Object.entries(e)){let e=Ve[n];if(e)for(let n of r)t.set(n,e)}let n=new Map(this.entities);for(let[e,r]of n)n.set(e,{...r,type:t.get(e)});for(let[e,r]of t)n.has(e)||n.set(e,{name:e,path:e,type:r,status:`pending`});this.entities=n}hasObjectsOrFieldsChanged(e){let t=JSON.stringify({objects:e.objects,fields:e.fields}),n=t!==this.previousObjectsFieldsFingerprint;return this.previousObjectsFieldsFingerprint=t,n}},Ge={idle:{color:`gray`,icon:`○`},in_progress:{color:`yellow`,icon:`spinner`},uploading:{color:`cyan`,icon:`upload`},done:{color:`green`,icon:`✓`},error:{color:`red`,icon:`✗`}},Ke=e=>({idle:`idle`,in_progress:`in_progress`,done:`done`,error:`error`})[e],qe=e=>({pending:`idle`,building:`in_progress`,uploading:`uploading`,success:`done`,error:`error`})[e],Je=e=>({idle:`idle`,building:`in_progress`,syncing:`in_progress`,synced:`done`,error:`error`})[e],Ye={idle:`Idle`,building:`Building...`,syncing:`Syncing...`,synced:`Synced`,error:`Error`},Xe=[`◐`,`◓`,`◑`,`◒`],Ze=[`↑`,`⇡`,`↑`,`⇡`],Qe={[t.ht.Object]:`Objects`,[t.ht.Field]:`Fields`,[t.ht.LogicFunction]:`Logic functions`,[t.ht.FrontComponent]:`Front components`,[t.ht.CommandMenuItem]:`Command menu items`,[t.ht.Role]:`Roles`,[t.ht.Skill]:`Skills`,[t.ht.View]:`Views`,[t.ht.ViewField]:`View fields`,[t.ht.NavigationMenuItem]:`Navigation menu items`,[t.ht.PageLayout]:`Page layouts`,[t.ht.PageLayoutTab]:`Page layout tabs`,[t.ht.Agent]:`Agents`,[t.ht.ConnectionProvider]:`Connection providers`},$e=Object.keys(Qe),et={info:`gray`,success:`green`,error:`red`,warning:`yellow`},tt=e=>e.toLocaleTimeString(`en-US`,{hour12:!1,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),nt=(e,t=40)=>{if(e.length<=t)return e;let n=e.split(`/`);return n.length<=2?e:`.../${n.slice(-2).join(`/`)}`},rt=e=>{let t=new Map;for(let e of $e)t.set(e,[]);for(let n of e.values()){if(!n.type)continue;let e=t.get(n.type)??[];e.push(n),t.set(n.type,e)}return t},it=[{status:`success`,label:`synced`},{status:`building`,label:`building`},{status:`uploading`,label:`uploading`},{status:`pending`,label:`pending`},{status:`error`,label:`error`}],at=e=>{let t={pending:0,building:0,uploading:0,success:0,error:0};for(let n of e)t[n.status]+=1;return it.filter(({status:e})=>t[e]>0).map(({status:e,label:n})=>({status:e,count:t[e],label:n}))},ot=e=>{let t=e.steps.resolveApplication.output.applicationId;return!n.t(e.frontendUrl)||!n.t(t)?null:`${e.frontendUrl}/settings/applications/${t}`},st=e=>e.some(e=>e===`error`)?`error`:e.some(e=>e===`in_progress`)?`in_progress`:e.every(e=>e===`done`)?`done`:`idle`,ct=e=>{let t=[...e.entities.values()],n=t.some(e=>e.status===`error`),r=t.some(e=>e.status===`building`),i=t.length>0&&t.every(e=>e.status===`uploading`||e.status===`success`),a=n?`error`:r?`in_progress`:i?`done`:`idle`;return[{label:`Application Initialization`,status:st([e.steps.checkServer.status,e.steps.ensureValidTokens.status,e.steps.resolveApplication.status])},{label:`Resources Build`,status:a},{label:`Resources Upload`,status:e.steps.uploadFiles.status},{label:`Manifest Build`,status:e.steps.buildManifest.status},{label:`Application Synchronization`,status:e.steps.syncApplication.status},{label:`Api Client Generation`,status:e.steps.generateApiClient.status}]},lt=120,z=Math.round(200/lt),ut=()=>{let e=Math.floor(Date.now()/lt);return{spinnerFrame:Xe[e%Xe.length],uploadFrame:Ze[Math.floor(e/z)%Ze.length]}},B=e=>{let t=Ge[e];return t.icon===`spinner`?ut().spinnerFrame:t.icon===`upload`?ut().uploadFrame:t.icon},dt=o.default.createContext(null),ft=dt.Provider,pt=()=>{let e=o.default.useContext(dt);if(!e)throw Error(`useInk must be used within InkProvider`);return e},mt=({uiStatus:e})=>{let{Text:t}=pt(),n=B(e),r=Ge[e];return(0,p.jsxs)(t,{color:r.color,children:[n,` `]})},ht=({entity:e})=>{let{Box:t,Text:n}=pt();return(0,p.jsxs)(t,{children:[(0,p.jsx)(mt,{uiStatus:qe(e.status)}),(0,p.jsx)(n,{children:e.name}),e.path!==e.name&&(0,p.jsxs)(n,{dimColor:!0,children:[` (`,nt(e.path),`)`]})]})},gt=({type:e,entities:t})=>{let{Box:n,Text:r}=pt();return t.length===0?null:(0,p.jsxs)(n,{flexDirection:`column`,marginTop:1,children:[(0,p.jsx)(r,{bold:!0,dimColor:!0,children:Qe[e]}),t.map(e=>(0,p.jsx)(ht,{entity:e},e.path))]})},_t=({entities:e})=>{let{Box:t,Text:n}=pt();if(e.length===0)return null;let r=at(e);return(0,p.jsxs)(t,{marginTop:1,children:[(0,p.jsxs)(n,{bold:!0,dimColor:!0,children:[`Entities`,` `]}),r.map((e,r)=>(0,p.jsxs)(t,{children:[r>0&&(0,p.jsx)(n,{dimColor:!0,children:` · `}),(0,p.jsx)(mt,{uiStatus:qe(e.status)}),(0,p.jsxs)(n,{children:[e.count,` `,e.label]})]},e.status))]})},vt=()=>{let{Box:e,Text:t}=pt();return(0,p.jsx)(e,{marginTop:1,children:(0,p.jsxs)(t,{dimColor:!0,children:[(0,p.jsx)(t,{color:Ge.idle.color,children:Ge.idle.icon}),` `,`pending`,` `,(0,p.jsx)(t,{color:Ge.in_progress.color,children:Xe[0]}),` `,`building`,` `,(0,p.jsx)(t,{color:Ge.uploading.color,children:Ze[0]}),` `,`uploading`,` `,(0,p.jsx)(t,{color:Ge.done.color,children:Ge.done.icon}),` `,`success`,` `,(0,p.jsx)(t,{color:Ge.error.color,children:Ge.error.icon}),` `,`error`]})})},yt=7,bt=({versionInfo:e})=>{let{Box:t,Text:n}=pt();if(e===null)return null;let{cliVersion:r,localServerVersion:i,latestServerVersion:a,isMinorOrMajorBehind:o,daysBehind:s}=e,c=o&&s!==null&&s>yt;return(0,p.jsxs)(t,{children:[(0,p.jsx)(n,{dimColor:!0,children:`Versions: `}),(0,p.jsx)(n,{dimColor:!0,children:`CLI `}),(0,p.jsxs)(n,{children:[`v`,r]}),i!==null&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(n,{dimColor:!0,children:` • Server `}),(0,p.jsxs)(n,{color:c?`yellow`:void 0,children:[`v`,i]}),i!==null&&a!==null&&i===a&&(0,p.jsx)(n,{color:`green`,children:` ✓ latest`}),c&&a!==null&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(n,{color:`yellow`,children:[` → v`,a]}),s!==null&&(0,p.jsxs)(n,{dimColor:!0,children:[` (`,s,`d behind)`]})]})]})]})},xt=({state:e})=>{let{Text:t}=pt(),n=Je(e.pipeline.status),r=B(n),i=Ge[n],a=Ye[e.pipeline.status];return(0,p.jsxs)(t,{color:i.color,children:[r,` `,a]})},St=({label:e,status:t})=>{let{Box:n,Text:r}=pt(),i=Ke(t),a=B(i),o=Ge[i];return(0,p.jsxs)(n,{children:[(0,p.jsxs)(r,{dimColor:!0,children:[e,`: `]}),(0,p.jsxs)(r,{color:o.color,children:[a,` `,t.replace(`_`,` `)]})]})},Ct=({state:e,verbose:t=!1})=>{let{Box:n,Text:r}=pt(),i=rt(e.entities),a=ot(e);return(0,p.jsxs)(n,{flexDirection:`column`,borderStyle:`classic`,borderColor:`gray`,paddingX:1,children:[(0,p.jsx)(r,{bold:!0,color:`cyan`,children:`Application`}),(0,p.jsxs)(n,{marginLeft:2,flexDirection:`column`,children:[(0,p.jsxs)(n,{children:[(0,p.jsx)(r,{dimColor:!0,children:`Name: `}),(0,p.jsx)(r,{bold:!0,children:e.pipeline.appName??`Loading...`})]}),(0,p.jsxs)(n,{children:[(0,p.jsx)(r,{dimColor:!0,children:`Overall Status: `}),(0,p.jsx)(xt,{state:e})]}),a&&(0,p.jsxs)(n,{children:[(0,p.jsx)(r,{dimColor:!0,children:`Open:`}),(0,p.jsxs)(r,{bold:!0,color:`cyan`,children:[` `,a]})]}),(0,p.jsx)(bt,{versionInfo:e.versionInfo})]}),(0,p.jsx)(n,{marginLeft:2,flexDirection:`column`,marginTop:1,children:ct(e).map(e=>(0,p.jsx)(St,{label:e.label,status:e.status},e.label))}),(0,p.jsx)(n,{marginLeft:2,flexDirection:`column`,children:t?$e.map(e=>(0,p.jsx)(gt,{type:e,entities:i.get(e)??[]},e)):(0,p.jsx)(_t,{entities:Array.from(e.entities.values())})})]})},wt=({state:e})=>{let{Box:t,Text:n,useInput:r}=pt(),i=e.pendingConfirmation;return r((t,n)=>{if(e.pendingConfirmation){if(t.toLowerCase()===`y`){e.resolveDestructiveConfirmation(!0);return}(t.toLowerCase()===`n`||n.escape)&&e.resolveDestructiveConfirmation(!1)}}),i?(0,p.jsxs)(t,{marginTop:1,flexDirection:`column`,borderStyle:`classic`,borderColor:`red`,paddingX:1,children:[(0,p.jsxs)(n,{color:`red`,bold:!0,children:[`⚠ `,i.deleteCount,` destructive change(s) detected`]}),(0,p.jsxs)(n,{children:[`Apply and DESTROY `,i.deleteCount,` metadata entity(ies)? Press`,` `,(0,p.jsx)(n,{color:`green`,bold:!0,children:`y`}),` `,`to apply,`,` `,(0,p.jsx)(n,{color:`red`,bold:!0,children:`n`}),` `,`to cancel and stop watching.`]})]}):null},Tt=({event:e})=>{let{Box:t,Text:n}=pt(),r=et[e.status],i=tt(e.timestamp);return(0,p.jsxs)(t,{marginTop:+!!e.spacingBefore,children:[(0,p.jsxs)(n,{dimColor:!0,children:[i,` `]}),(0,p.jsx)(n,{color:r,children:e.message})]})},Et=new Set([`building`,`syncing`]),Dt=120,Ot=80,kt=({uiStateManager:e,verbose:t})=>{let{Box:n,Static:r}=pt(),[,i]=(0,o.useReducer)(e=>e+1,0),a=(0,o.useRef)(null),s=(0,o.useRef)(0),c=(0,o.useCallback)(()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,s.current=Date.now(),i()},Ot)},[]);(0,o.useEffect)(()=>e.subscribe(()=>{c()}),[e,c]),(0,o.useEffect)(()=>{let t=setInterval(()=>{let t=e.getSnapshot();Et.has(t.pipeline.status)&&(Date.now()-s.current<Dt||i())},Dt);return()=>clearInterval(t)},[e]),(0,o.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]);let l=e.getSnapshot();return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r,{items:l.events,children:e=>(0,p.jsx)(Tt,{event:e},e.id)}),(0,p.jsxs)(n,{marginTop:1,flexDirection:`column`,children:[(0,p.jsx)(Ct,{state:l,verbose:t}),t&&(0,p.jsx)(vt,{})]}),l.pendingConfirmation&&(0,p.jsx)(wt,{state:l})]})},At=async(e,t=!1)=>{let{render:n,Box:r,Text:i,Static:a,useInput:o}=await import(`ink`),{unmount:s}=n((0,p.jsx)(ft,{value:{Box:r,Text:i,Static:a,useInput:o},children:(0,p.jsx)(kt,{uiStateManager:e,verbose:t})}));return{unmount:s}},jt=class{constructor(e){this.listeners=new Set,this.pendingNotify=!1,this.orchestratorState=e}getSnapshot(){return this.orchestratorState}subscribe(e){return this.listeners.add(e),e(this.orchestratorState),()=>this.listeners.delete(e)}notify(){this.pendingNotify||(this.pendingNotify=!0,queueMicrotask(()=>{this.pendingNotify=!1;for(let e of this.listeners)e(this.orchestratorState)}))}},Mt=class{constructor(){this.orchestrator=null,this.unmountUI=null}async close(){this.unmountUI?.(),await this.orchestrator?.close()}getOrchestrator(){return this.orchestrator}async ensureAuthenticatedBeforeLaunch(){let{serverUp:e,authValid:n}=await new t.z({disableInterceptors:!0}).validateAuth();e&&!n&&await t.V(t.U.getActiveRemote())}async execute(e){let n=e.appPath??t.kt;await x(n),e.headless&&await t.y(),await this.ensureAuthenticatedBeforeLaunch();let r=new We({appPath:n});if(!e.headless){let n=new jt(r);r.onChange=()=>n.notify();let{unmount:i}=await At(n,e.verbose);this.unmountUI=i,t.b().then(e=>r.setVersionInfo(e))}this.orchestrator=new Be({state:r,verbose:e.verbose,debounceMs:e.debounceMs,force:e.force,interactive:!e.headless&&process.stdout.isTTY===!0,onExit:({code:t,message:n})=>{e.headless||this.close().then(()=>{console.log(u.default.yellow(`\n${n}`)),process.exit(t)})}}),await this.orchestrator.start(),e.headless||this.setupGracefulShutdown()}setupGracefulShutdown(){let e=()=>void this.close().then(()=>process.exit(0));process.on(`SIGINT`,e),process.on(`SIGTERM`,e)}},Nt=async(e,{force:t})=>{if(t)return!0;if(!process.stdout.isTTY)return console.error(u.default.red(`${e} destructive change(s) detected. Run \`yarn twenty plan\` to review them, or re-run with --force to apply non-interactively.`)),!1;let{confirmed:n}=await d.default.prompt([{type:`confirm`,name:`confirmed`,message:`Twenty will DESTROY ${e} metadata entity(ies) (run \`yarn twenty plan\` for details). Do you want to perform these actions?`,default:!1}]);return n},Pt=class{async execute(e){let n=e.appPath??t.kt,r=e.apply??!1;await x(n);let i=t.U.getActiveRemote();console.log(u.default.blue(`${r?`Applying application manifest`:`Planning application apply`} on ${i}...`)),console.log(u.default.gray(`App path: ${n}\n`));let a=await t.a({appPath:n,verbose:e.verbose,apply:r,force:e.force,onProgress:e=>console.log(u.default.gray(e)),onPlan:e=>console.log(`\n${e}\n`),confirmApply:t=>Nt(t,{force:e.force})});if(a.success||(a.error.code===t.K.APPLY_ABORTED&&(console.log(u.default.yellow(a.error.message)),process.exit(1)),console.error(u.default.red(a.error.message)),process.exit(1)),!r){console.log(u.default.green(`\n✓ Plan complete for ${a.data.applicationDisplayName} — no changes were applied`));return}console.log(u.default.green(`\n✓ Synced ${a.data.applicationDisplayName} (${a.data.fileCount} file${a.data.fileCount===1?``:`s`})`)),console.log(u.default.gray(`Output: ${a.data.outputDir}`))}},Ft=e=>{let t=new be,n=new ye;e.command(`dev:function:logs [appPath]`).description(`Stream logic function logs`).option(`-u, --functionUniversalIdentifier <functionUniversalIdentifier>`,`Only show logs for the function with this universal ID`).option(`-n, --functionName <functionName>`,`Only show logs for the function with this name`).action(async(e,n)=>{await t.execute({...n,appPath:g(e)})}),e.command(`dev:function:exec [appPath]`).description(`Execute a logic function`).option(`--postInstall`,`Execute post-install logic function if defined`).option(`--preInstall`,`Execute pre-install logic function if defined`).option(`--uninstall`,`Execute uninstall logic function if defined`).option(`-p, --payload <payload>`,`JSON payload to send to the function`,`{}`).option(`-u, --functionUniversalIdentifier <functionUniversalIdentifier>`,`Universal ID of the function to execute`).option(`-n, --functionName <functionName>`,`Name of the function to execute`).action(async(e,t)=>{!t?.postInstall&&!t?.preInstall&&!t?.uninstall&&!t?.functionUniversalIdentifier&&!t?.functionName&&(console.error(u.default.red(`Error: Either --postInstall, --preInstall, --uninstall, --functionName (-n), or --functionUniversalIdentifier (-u) is required.`)),process.exit(1)),await n.execute({...t,payload:t?.payload??`{}`,appPath:g(e)})})},It=class{async execute(e){let n=e.appPath??t.kt,i=(0,r.join)(n,`node_modules`,`twenty-client-sdk`);await t.ut(i)||(console.error(u.default.red(`Cannot find twenty-client-sdk in ${n}.\n\n Install it first:
|
|
343
349
|
yarn add twenty-client-sdk`)),process.exit(1));let a=await new t.z({disableInterceptors:!0}).validateAuth();a.serverUp||(console.error(u.default.red(`Cannot reach Twenty server.
|
|
344
350
|
|
|
345
351
|
Check your remotes:
|
|
@@ -31379,8 +31385,8 @@ Stack: `+n.stack;r.length>0&&o(`Manipulation error: A syntax error was inserted.
|
|
|
31379
31385
|
`)&&(o=o.replace(/\r?\n$/,``))),kt({insertPos:ze(e,this,this.getChildren()),newText:o,parent:this}),Ye(n,this.getChildren(),e,!0))}};function yn(e,n,r){if(t.errors.throwIfWhitespaceOrNotString(n,`newName`),e.getText()===n)return;let i=e._context.languageService.findRenameLocations(e,r),a=new t.KeyValueCache;for(let e of i)a.getOrCreate(e.getSourceFile(),()=>[]).push(e);for(let[e,t]of a.getEntries())en({sourceFile:e,renameLocations:t,newName:n})}function bn(e,n){let r=ln(e._getWriterWithIndentation(),n),i=e.getFirstChildByKindOrThrow(t.SyntaxKind.OpenBraceToken),a=e.getFirstChildByKindOrThrow(t.SyntaxKind.CloseBraceToken);kt({insertPos:i.getEnd(),newText:r,parent:e,replacing:{textLength:a.getStart()-i.getEnd()}})}function xn(e){return class extends e{getBody(){let e=this.compilerNode.body;if(e==null)throw new t.errors.InvalidOperationError(`Bodied node should have a body.`);return this._getNodeFromCompilerNode(e)}setBodyText(e){return bn(this.getBody(),e),this}getBodyText(){return un(this.getBody())}}}function Sn(e){return class extends e{getBodyOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getBody(),e??`Expected to find the node's body.`,this)}getBody(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.body)}getBodyText(){let e=this.getBody();return e==null?void 0:un(e)}setBodyText(e){return this.addBody(),bn(this.getBodyOrThrow(),e),this}hasBody(){return this.compilerNode.body!=null}addBody(){if(this.hasBody())return this;let e=this.getLastChildByKind(t.SyntaxKind.SemicolonToken);return kt({parent:this,insertPos:e==null?this.getEnd():e.getStart(),newText:this._getWriterWithQueuedIndentation().space().block().toString(),replacing:{textLength:e?.getFullWidth()??0}}),this}removeBody(){let e=this.getBody();return e==null||kt({parent:this,insertPos:e.getPos(),newText:`;`,replacing:{textLength:e.getFullWidth()}}),this}}}function Cn(e){return class extends e{setOrder(e){let n=this.getChildIndex(),r=this.getParentSyntaxList()||this.getParentSyntaxListOrThrow();return t.errors.throwIfOutOfRange(e,[0,r.getChildCount()-1],`order`),n===e||Ft({parent:r,getSiblingFormatting:Te,oldIndex:n,newIndex:e}),this}}}function wn(e){return class extends e{getDecorator(e){return s(this.getDecorators(),e)}getDecoratorOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getDecorator(e),n??(()=>l(`decorator`,e)),this)}getDecorators(){return Tn(this.compilerNode).map(e=>this._getNodeFromCompilerNode(e))}addDecorator(e){return this.insertDecorator(Ae(Tn(this.compilerNode)),e)}addDecorators(e){return this.insertDecorators(Ae(Tn(this.compilerNode)),e)}insertDecorator(e,t){return this.insertDecorators(e,[t])[0]}insertDecorators(e,n){if(t.ArrayUtils.isNullOrEmpty(n))return[];let r=En(this,n),i=this.getDecorators();e=et(e,i.length);let a=Dn(this,i),o=i[e-1],s=Ee({structures:n,newCodes:r,parent:this,indentationText:this.getIndentationText(),getSeparator:()=>a,previousFormattingKind:o==null?_e.None:a,nextFormattingKind:o==null?a:_e.None});return kt({parent:i[0]?.getParentSyntaxListOrThrow()??this.getModifiers()[0]?.getParentSyntaxListOrThrow()??this,insertPos:e===0?(i[0]??this).getStart():i[e-1].getEnd(),newText:s}),Ye(i,this.getDecorators(),e,!1)}set(t){return he(e.prototype,this,t),t.decorators!=null&&(this.getDecorators().forEach(e=>e.remove()),this.addDecorators(t.decorators)),this}getStructure(){return me(e.prototype,this,{decorators:this.getDecorators().map(e=>e.getStructure())})}}}function Tn(e){return t.ts.canHaveDecorators(e)?t.ts.getDecorators(e)??[]:[]}function En(e,t){let n=[];for(let r of t){let t=e._getWriter();e._context.structurePrinterFactory.forDecorator().printText(t,r),n.push(t.toString())}return n}function Dn(e,t){return U(e,t)?_e.Space:_e.Newline}function U(e,n){if(n.length===1){let e=n[0].getPreviousSibling();if(e!=null&&e.getStartLinePos()===n[0].getStartLinePos())return!0}if(n.length<=1)return e.getKind()===t.SyntaxKind.Parameter;let r=n[0].getStartLinePos();for(let e=1;e<n.length;e++)if(n[e].getStartLinePos()!==r)return!1;return!0}function On(e){return class extends e{getDotDotDotTokenOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getDotDotDotToken(),e??`Expected to find a dot dot dot token (...).`,this)}getDotDotDotToken(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.dotDotDotToken)}}}function kn(e){return class extends e{hasExclamationToken(){return this.compilerNode.exclamationToken!=null}getExclamationTokenNode(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.exclamationToken)}getExclamationTokenNodeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getExclamationTokenNode(),e??`Expected to find an exclamation token.`,this)}setHasExclamationToken(e){let n=this.getExclamationTokenNode();if(e===(n!=null))return this;if(e){H.isQuestionTokenable(this)&&this.setHasQuestionToken(!1);let e=this.getFirstChildByKind(t.SyntaxKind.ColonToken);if(e==null)throw new t.errors.InvalidOperationError(`Cannot add an exclamation token to a node that does not have a type.`);kt({insertPos:e.getStart(),parent:this,newText:`!`})}else It({children:[n]});return this}set(t){return he(e.prototype,this,t),t.hasExclamationToken!=null&&this.setHasExclamationToken(t.hasExclamationToken),this}getStructure(){return me(e.prototype,this,{hasExclamationToken:this.hasExclamationToken()})}}}function An(e){return class extends e{hasExportKeyword(){return this.getExportKeyword()!=null}getExportKeyword(){return H.isVariableDeclaration(this)?this.getVariableStatement()?.getExportKeyword():H.isModifierable(this)?this.getFirstModifierByKind(t.SyntaxKind.ExportKeyword):jn()}getExportKeywordOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getExportKeyword(),e??`Expected to find an export keyword.`,this)}hasDefaultKeyword(){return this.getDefaultKeyword()!=null}getDefaultKeyword(){return H.isVariableDeclaration(this)?this.getVariableStatement()?.getDefaultKeyword():H.isModifierable(this)?this.getFirstModifierByKind(t.SyntaxKind.DefaultKeyword):jn()}getDefaultKeywordOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getDefaultKeyword(),e??`Expected to find a default keyword.`,this)}isExported(){if(this.hasExportKeyword())return!0;let e=this.getSymbol(),t=this.getSourceFile().getSymbol();return e==null||t==null?!1:t.getExports().some(t=>t===e||t.getAliasedSymbol()===e)}isDefaultExport(){if(this.hasDefaultKeyword())return!0;let e=this.getSymbol();if(e==null)return!1;let t=this.getSourceFile().getDefaultExportSymbol();return t==null?!1:e===t?!0:e===t.getAliasedSymbol()}isNamedExport(){let e=this.getSymbol(),t=this.getSourceFile().getSymbol();if(e==null||t==null)return!1;return!n()&&t.getExports().some(t=>t===e||t.getAliasedSymbol()===e);function n(){let n=t.getExport(`default`);return n==null?!1:e===n||e===n.getAliasedSymbol()}}}}function jn(){throw new t.errors.NotImplementedError(`Not implemented situation where node was not a ModifierableNode.`)}function Mn(e){return Nn(An(e))}function Nn(e){return class extends e{setIsDefaultExport(e){if(e===this.isDefaultExport())return this;if(e&&!H.isSourceFile(this.getParentOrThrow()))throw new t.errors.InvalidOperationError(`The parent must be a source file in order to set this node as a default export.`);let n=this.getSourceFile(),r=n.getDefaultExportSymbol();if(r!=null&&n.removeDefaultExport(r),!e)return this;if(H.hasName(this)&&i.call(this)){let e=this.getFirstAncestorByKindOrThrow(t.SyntaxKind.SyntaxList),n=this.getName();e.insertChildText(this.getChildIndex()+1,e=>{e.newLine().write(`export default ${n};`)})}else this.addModifier(`export`),this.addModifier(`default`);return this;function i(){return!!(H.isEnumDeclaration(this)||H.isModuleDeclaration(this)||H.isTypeAliasDeclaration(this)||H.isAmbientable(this)&&this.isAmbient())}}setIsExported(e){return H.isSourceFile(this.getParentOrThrow())&&this.toggleModifier(`default`,!1),this.toggleModifier(`export`,e),this}set(t){return he(e.prototype,this,t),t.isExported!=null&&this.setIsExported(t.isExported),t.isDefaultExport!=null&&this.setIsDefaultExport(t.isDefaultExport),this}getStructure(){return me(e.prototype,this,{isExported:this.hasExportKeyword(),isDefaultExport:this.hasDefaultKeyword()})}}}var Pn=class{printTextOrWriterFunc(e,t){typeof t==`string`?e.write(t):t?.(e)}getNewWriter(e){return new i.default(e.getOptions())}getNewWriterWithQueuedChildIndentation(e){let t=new i.default(e.getOptions());return t.queueIndentationLevel(1),t}getText(e,t){let n=this.getNewWriter(e);return this.printTextOrWriterFunc(n,t),n.toString()}getTextWithQueuedChildIndentation(e,t){let n=this.getNewWriterWithQueuedChildIndentation(e);return this.printTextOrWriterFunc(n,t),n.toString()}},Fn=class extends Pn{printText(e,n){let{initializer:r}=n;if(r==null)return;let i=this.getText(e,r);t.StringUtils.isNullOrWhitespace(i)||e.hangingIndent(()=>{e.spaceIfLastNot(),e.write(`= ${i}`)})}},In=class extends Pn{printText(e,t){let n=t.scope;t.isDefaultExport?e.write(`export default `):t.isExported&&e.write(`export `),t.hasDeclareKeyword&&e.write(`declare `),n!=null&&e.write(`${n} `),t.isStatic&&e.write(`static `),t.hasOverrideKeyword&&e.write(`override `),t.isAbstract&&e.write(`abstract `),t.isAsync&&e.write(`async `),t.isReadonly&&e.write(`readonly `),t.hasAccessorKeyword&&e.write(`accessor `)}},Ln=class extends Pn{#e;constructor(e=!1){super(),this.#e=e}printText(e,n){let{returnType:r}=n;if(r==null&&this.#e===!1)return;r??=`void`;let i=this.getText(e,r);t.StringUtils.isNullOrWhitespace(i)||e.hangingIndent(()=>{e.write(`: ${i}`)})}},Rn=class extends Pn{#e;#t;constructor(e,t=!1){super(),this.#t=t,this.#e=e}printText(e,n){let{type:r}=n;if(r==null&&this.#t===!1)return;r??=`any`;let i=this.getText(e,r);t.StringUtils.isNullOrWhitespace(i)||e.hangingIndent(()=>{e.write(`${this.#e} ${i}`)})}},zn=class extends Pn{#e;constructor(e){super(),this.#e=e}printText(e,t){if(t!=null)for(let n=0;n<t.length;n++)e.conditionalBlankLine(n>0),this.#e.printText(e,t[n])}},Bn=class extends Pn{#e;constructor(e){super(),this.#e=e}printText(e,t){Vn(this.#e,e,t,()=>e.spaceIfLastNot())}};function Vn(e,t,n,r){if(n!=null)if(n instanceof Function||typeof n==`string`)e.printText(t,n);else{let i=Array(n.length);for(let a=0;a<n.length;a++){a>0&&r();let o=n[a],s=t.getLength();e.printText(t,o);let c=ke(pe.getLastCharactersToPos(t,s));i[a]=c===-1?!1:c+s}let a=!1;for(let e=i.length-1;e>=0;e--){let n=i[e];n!==!1&&(a?t.unsafeInsert(n,`,`):a=!0)}}}var Hn=class extends Pn{#e;constructor(e){super(),this.#e=e}printText(e,t){Vn(this.#e,e,t,()=>e.newLineIfLastNot())}},Un=class extends Pn{#e;constructor(e){super(),this.#e=e}printText(e,t){if(t!=null)for(let n=0;n<t.length;n++)e.conditionalNewLine(n>0),this.#e.printText(e,t[n])}},Wn=class extends Pn{#e;constructor(e){super(),this.#e=e}printText(e,t){if(t!=null)for(let n=0;n<t.length;n++)e.conditionalWrite(n>0,` `),this.#e.printText(e,t[n])}},Gn=class extends Pn{factory;constructor(e){super(),this.factory=e}printTextWithoutTrivia(e,t){this.printTextInternal(e,t)}printText(e,t){this.printLeadingTrivia(e,t),e.closeComment(),this.printTextInternal(e,t),this.printTrailingTrivia(e,t)}printLeadingTrivia(e,t){let n=t?.leadingTrivia;n&&(this.#e(e,n),e.isInComment()&&e.closeComment())}printTrailingTrivia(e,t){let n=t?.trailingTrivia;n!=null&&this.#e(e,n)}#e(e,t){if(t instanceof Array)for(let n=0;n<t.length;n++)this.printTextOrWriterFunc(e,t[n]),n!==t.length-1&&e.newLineIfLastNot();else this.printTextOrWriterFunc(e,t)}},Kn=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}printGetAndSet(e,t,n,r){t=[...t??[]],n=[...n??[]];for(let i of t){this.#n(e,r),this.#e.printText(e,i);let t=n.findIndex(e=>e.name===i.name);t>=0&&(this.#n(e,r),this.#t.printText(e,n[t]),n.splice(t,1))}for(let t of n)this.#n(e,r),this.#t.printText(e,t)}#n(e,t){e.isAtStartOfFirstLineOfBlock()||(t?e.newLine():e.blankLine())}},qn=class extends Gn{#e;#t=new zn(this);constructor(e,t){super(e),this.#e=t}printTexts(e,t){this.#t.printText(e,t)}printTextInternal(e,n){let r=n.hasDeclareKeyword||this.#e.isAmbient;this.factory.forJSDoc().printDocs(e,n.docs),this.factory.forDecorator().printTexts(e,n.decorators),this.#n(e,n),e.inlineBlock(()=>{this.factory.forPropertyDeclaration().printTexts(e,n.properties),this.#i(e,n),this.#r(e,n,r),this.#a(e,n,r),t.ArrayUtils.isNullOrEmpty(n.methods)||(this.#o(e,r),this.factory.forMethodDeclaration({isAmbient:r}).printTexts(e,n.methods))})}#n(e,n){this.factory.forModifierableNode().printText(e,n),e.write(`class`),t.StringUtils.isNullOrWhitespace(n.name)||e.space().write(n.name),this.factory.forTypeParameterDeclaration().printTextsWithBrackets(e,n.typeParameters),e.space(),e.hangingIndent(()=>{if(n.extends!=null){let r=this.getText(e,n.extends);t.StringUtils.isNullOrWhitespace(r)||e.write(`extends ${r} `)}if(n.implements!=null){let r=n.implements instanceof Array?n.implements.map(t=>this.getText(e,t)).join(`, `):this.getText(e,n.implements);t.StringUtils.isNullOrWhitespace(r)||e.write(`implements ${r} `)}})}#r(e,n,r){if(!t.ArrayUtils.isNullOrEmpty(n.ctors))for(let t of n.ctors)this.#o(e,r),this.factory.forConstructorDeclaration({isAmbient:r}).printText(e,t)}#i(e,n){if(!t.ArrayUtils.isNullOrEmpty(n.staticBlocks))for(let t of n.staticBlocks)this.#o(e,!1),this.factory.forClassStaticBlockDeclaration().printText(e,t)}#a(e,t,n){t.getAccessors==null&&t.setAccessors==null||new Kn(this.factory.forGetAccessorDeclaration({isAmbient:n}),this.factory.forSetAccessorDeclaration({isAmbient:n})).printGetAndSet(e,t.getAccessors,t.setAccessors,n)}#o(e,t){e.isAtStartOfFirstLineOfBlock()||(t?e.newLine():e.blankLine())}};e.StructureKind=void 0,(function(e){e[e.ImportAttribute=0]=`ImportAttribute`,e[e.CallSignature=1]=`CallSignature`,e[e.Class=2]=`Class`,e[e.ClassStaticBlock=3]=`ClassStaticBlock`,e[e.ConstructSignature=4]=`ConstructSignature`,e[e.Constructor=5]=`Constructor`,e[e.ConstructorOverload=6]=`ConstructorOverload`,e[e.Decorator=7]=`Decorator`,e[e.Enum=8]=`Enum`,e[e.EnumMember=9]=`EnumMember`,e[e.ExportAssignment=10]=`ExportAssignment`,e[e.ExportDeclaration=11]=`ExportDeclaration`,e[e.ExportSpecifier=12]=`ExportSpecifier`,e[e.Function=13]=`Function`,e[e.FunctionOverload=14]=`FunctionOverload`,e[e.GetAccessor=15]=`GetAccessor`,e[e.ImportDeclaration=16]=`ImportDeclaration`,e[e.ImportSpecifier=17]=`ImportSpecifier`,e[e.IndexSignature=18]=`IndexSignature`,e[e.Interface=19]=`Interface`,e[e.JsxAttribute=20]=`JsxAttribute`,e[e.JsxSpreadAttribute=21]=`JsxSpreadAttribute`,e[e.JsxElement=22]=`JsxElement`,e[e.JsxSelfClosingElement=23]=`JsxSelfClosingElement`,e[e.JSDoc=24]=`JSDoc`,e[e.JSDocTag=25]=`JSDocTag`,e[e.Method=26]=`Method`,e[e.MethodOverload=27]=`MethodOverload`,e[e.MethodSignature=28]=`MethodSignature`,e[e.Module=29]=`Module`,e[e.Parameter=30]=`Parameter`,e[e.Property=31]=`Property`,e[e.PropertyAssignment=32]=`PropertyAssignment`,e[e.PropertySignature=33]=`PropertySignature`,e[e.SetAccessor=34]=`SetAccessor`,e[e.ShorthandPropertyAssignment=35]=`ShorthandPropertyAssignment`,e[e.SourceFile=36]=`SourceFile`,e[e.SpreadAssignment=37]=`SpreadAssignment`,e[e.TypeAlias=38]=`TypeAlias`,e[e.TypeParameter=39]=`TypeParameter`,e[e.VariableDeclaration=40]=`VariableDeclaration`,e[e.VariableStatement=41]=`VariableStatement`})(e.StructureKind||={});var Jn={hasName(e){return typeof e.name==`string`},isCallSignature(t){return t?.kind===e.StructureKind.CallSignature},isJSDocable(t){switch(t?.kind){case e.StructureKind.CallSignature:case e.StructureKind.Class:case e.StructureKind.ClassStaticBlock:case e.StructureKind.ConstructorOverload:case e.StructureKind.Constructor:case e.StructureKind.ConstructSignature:case e.StructureKind.Enum:case e.StructureKind.EnumMember:case e.StructureKind.ExportAssignment:case e.StructureKind.FunctionOverload:case e.StructureKind.Function:case e.StructureKind.GetAccessor:case e.StructureKind.IndexSignature:case e.StructureKind.Interface:case e.StructureKind.MethodOverload:case e.StructureKind.Method:case e.StructureKind.MethodSignature:case e.StructureKind.Module:case e.StructureKind.Property:case e.StructureKind.PropertySignature:case e.StructureKind.SetAccessor:case e.StructureKind.TypeAlias:case e.StructureKind.VariableStatement:return!0;default:return!1}},isSignatured(t){switch(t?.kind){case e.StructureKind.CallSignature:case e.StructureKind.ConstructorOverload:case e.StructureKind.Constructor:case e.StructureKind.ConstructSignature:case e.StructureKind.FunctionOverload:case e.StructureKind.Function:case e.StructureKind.GetAccessor:case e.StructureKind.MethodOverload:case e.StructureKind.Method:case e.StructureKind.MethodSignature:case e.StructureKind.SetAccessor:return!0;default:return!1}},isParametered(t){switch(t?.kind){case e.StructureKind.CallSignature:case e.StructureKind.ConstructorOverload:case e.StructureKind.Constructor:case e.StructureKind.ConstructSignature:case e.StructureKind.FunctionOverload:case e.StructureKind.Function:case e.StructureKind.GetAccessor:case e.StructureKind.MethodOverload:case e.StructureKind.Method:case e.StructureKind.MethodSignature:case e.StructureKind.SetAccessor:return!0;default:return!1}},isReturnTyped(t){switch(t?.kind){case e.StructureKind.CallSignature:case e.StructureKind.ConstructorOverload:case e.StructureKind.Constructor:case e.StructureKind.ConstructSignature:case e.StructureKind.FunctionOverload:case e.StructureKind.Function:case e.StructureKind.GetAccessor:case e.StructureKind.IndexSignature:case e.StructureKind.MethodOverload:case e.StructureKind.Method:case e.StructureKind.MethodSignature:case e.StructureKind.SetAccessor:return!0;default:return!1}},isTypeParametered(t){switch(t?.kind){case e.StructureKind.CallSignature:case e.StructureKind.Class:case e.StructureKind.ConstructorOverload:case e.StructureKind.Constructor:case e.StructureKind.ConstructSignature:case e.StructureKind.FunctionOverload:case e.StructureKind.Function:case e.StructureKind.GetAccessor:case e.StructureKind.Interface:case e.StructureKind.MethodOverload:case e.StructureKind.Method:case e.StructureKind.MethodSignature:case e.StructureKind.SetAccessor:case e.StructureKind.TypeAlias:return!0;default:return!1}},isClass(t){return t?.kind===e.StructureKind.Class},isClassLikeDeclarationBase(t){return t?.kind===e.StructureKind.Class},isNameable(t){switch(t?.kind){case e.StructureKind.Class:case e.StructureKind.Function:return!0;default:return!1}},isImplementsClauseable(t){return t?.kind===e.StructureKind.Class},isDecoratable(t){switch(t?.kind){case e.StructureKind.Class:case e.StructureKind.GetAccessor:case e.StructureKind.Method:case e.StructureKind.Parameter:case e.StructureKind.Property:case e.StructureKind.SetAccessor:return!0;default:return!1}},isAbstractable(t){switch(t?.kind){case e.StructureKind.Class:case e.StructureKind.GetAccessor:case e.StructureKind.MethodOverload:case e.StructureKind.Method:case e.StructureKind.Property:case e.StructureKind.SetAccessor:return!0;default:return!1}},isAmbientable(t){switch(t?.kind){case e.StructureKind.Class:case e.StructureKind.Enum:case e.StructureKind.FunctionOverload:case e.StructureKind.Function:case e.StructureKind.Interface:case e.StructureKind.Module:case e.StructureKind.Property:case e.StructureKind.TypeAlias:case e.StructureKind.VariableStatement:return!0;default:return!1}},isExportable(t){switch(t?.kind){case e.StructureKind.Class:case e.StructureKind.Enum:case e.StructureKind.FunctionOverload:case e.StructureKind.Function:case e.StructureKind.Interface:case e.StructureKind.Module:case e.StructureKind.TypeAlias:case e.StructureKind.VariableStatement:return!0;default:return!1}},isClassStaticBlock(t){return t?.kind===e.StructureKind.ClassStaticBlock},isStatemented(t){switch(t?.kind){case e.StructureKind.ClassStaticBlock:case e.StructureKind.Constructor:case e.StructureKind.Function:case e.StructureKind.GetAccessor:case e.StructureKind.Method:case e.StructureKind.Module:case e.StructureKind.SetAccessor:case e.StructureKind.SourceFile:return!0;default:return!1}},isConstructorDeclarationOverload(t){return t?.kind===e.StructureKind.ConstructorOverload},isScoped(t){switch(t?.kind){case e.StructureKind.ConstructorOverload:case e.StructureKind.Constructor:case e.StructureKind.GetAccessor:case e.StructureKind.MethodOverload:case e.StructureKind.Method:case e.StructureKind.Property:case e.StructureKind.SetAccessor:return!0;default:return!1}},isConstructor(t){return t?.kind===e.StructureKind.Constructor},isFunctionLike(t){switch(t?.kind){case e.StructureKind.Constructor:case e.StructureKind.Function:case e.StructureKind.GetAccessor:case e.StructureKind.Method:case e.StructureKind.SetAccessor:return!0;default:return!1}},isConstructSignature(t){return t?.kind===e.StructureKind.ConstructSignature},isDecorator(t){return t?.kind===e.StructureKind.Decorator},isEnum(t){return t?.kind===e.StructureKind.Enum},isNamed(t){switch(t?.kind){case e.StructureKind.Enum:case e.StructureKind.Interface:case e.StructureKind.ShorthandPropertyAssignment:case e.StructureKind.TypeAlias:case e.StructureKind.TypeParameter:return!0;default:return!1}},isEnumMember(t){return t?.kind===e.StructureKind.EnumMember},isPropertyNamed(t){switch(t?.kind){case e.StructureKind.EnumMember:case e.StructureKind.GetAccessor:case e.StructureKind.Method:case e.StructureKind.MethodSignature:case e.StructureKind.PropertyAssignment:case e.StructureKind.Property:case e.StructureKind.PropertySignature:case e.StructureKind.SetAccessor:return!0;default:return!1}},isInitializerExpressionable(t){switch(t?.kind){case e.StructureKind.EnumMember:case e.StructureKind.Parameter:case e.StructureKind.Property:case e.StructureKind.PropertySignature:case e.StructureKind.VariableDeclaration:return!0;default:return!1}},isExportAssignment(t){return t?.kind===e.StructureKind.ExportAssignment},isExportDeclaration(t){return t?.kind===e.StructureKind.ExportDeclaration},isExportSpecifier(t){return t?.kind===e.StructureKind.ExportSpecifier},isFunctionDeclarationOverload(t){return t?.kind===e.StructureKind.FunctionOverload},isAsyncable(t){switch(t?.kind){case e.StructureKind.FunctionOverload:case e.StructureKind.Function:case e.StructureKind.MethodOverload:case e.StructureKind.Method:return!0;default:return!1}},isGeneratorable(t){switch(t?.kind){case e.StructureKind.FunctionOverload:case e.StructureKind.Function:case e.StructureKind.MethodOverload:case e.StructureKind.Method:return!0;default:return!1}},isFunction(t){return t?.kind===e.StructureKind.Function},isGetAccessor(t){return t?.kind===e.StructureKind.GetAccessor},isStaticable(t){switch(t?.kind){case e.StructureKind.GetAccessor:case e.StructureKind.MethodOverload:case e.StructureKind.Method:case e.StructureKind.Property:case e.StructureKind.SetAccessor:return!0;default:return!1}},isImportAttribute(t){return t?.kind===e.StructureKind.ImportAttribute},isImportAttributeNamed(t){return t?.kind===e.StructureKind.ImportAttribute},isImportDeclaration(t){return t?.kind===e.StructureKind.ImportDeclaration},isImportSpecifier(t){return t?.kind===e.StructureKind.ImportSpecifier},isIndexSignature(t){return t?.kind===e.StructureKind.IndexSignature},isReadonlyable(t){switch(t?.kind){case e.StructureKind.IndexSignature:case e.StructureKind.Parameter:case e.StructureKind.Property:case e.StructureKind.PropertySignature:return!0;default:return!1}},isInterface(t){return t?.kind===e.StructureKind.Interface},isExtendsClauseable(t){return t?.kind===e.StructureKind.Interface},isTypeElementMembered(t){return t?.kind===e.StructureKind.Interface},isJSDoc(t){return t?.kind===e.StructureKind.JSDoc},isJSDocTag(t){return t?.kind===e.StructureKind.JSDocTag},isJsxAttribute(t){return t?.kind===e.StructureKind.JsxAttribute},isJsxElement(t){return t?.kind===e.StructureKind.JsxElement},isJsxSelfClosingElement(t){return t?.kind===e.StructureKind.JsxSelfClosingElement},isJsxTagNamed(t){return t?.kind===e.StructureKind.JsxSelfClosingElement},isJsxAttributed(t){return t?.kind===e.StructureKind.JsxSelfClosingElement},isJsxSpreadAttribute(t){return t?.kind===e.StructureKind.JsxSpreadAttribute},isMethodDeclarationOverload(t){return t?.kind===e.StructureKind.MethodOverload},isQuestionTokenable(t){switch(t?.kind){case e.StructureKind.MethodOverload:case e.StructureKind.Method:case e.StructureKind.MethodSignature:case e.StructureKind.Parameter:case e.StructureKind.Property:case e.StructureKind.PropertySignature:return!0;default:return!1}},isOverrideable(t){switch(t?.kind){case e.StructureKind.MethodOverload:case e.StructureKind.Method:case e.StructureKind.Parameter:case e.StructureKind.Property:return!0;default:return!1}},isMethod(t){return t?.kind===e.StructureKind.Method},isMethodSignature(t){return t?.kind===e.StructureKind.MethodSignature},isModule(t){return t?.kind===e.StructureKind.Module},isModuleNamed(t){return t?.kind===e.StructureKind.Module},isParameter(t){return t?.kind===e.StructureKind.Parameter},isBindingNamed(t){switch(t?.kind){case e.StructureKind.Parameter:case e.StructureKind.VariableDeclaration:return!0;default:return!1}},isTyped(t){switch(t?.kind){case e.StructureKind.Parameter:case e.StructureKind.Property:case e.StructureKind.PropertySignature:case e.StructureKind.TypeAlias:case e.StructureKind.VariableDeclaration:return!0;default:return!1}},isScopeable(t){return t?.kind===e.StructureKind.Parameter},isPropertyAssignment(t){return t?.kind===e.StructureKind.PropertyAssignment},isProperty(t){return t?.kind===e.StructureKind.Property},isExclamationTokenable(t){switch(t?.kind){case e.StructureKind.Property:case e.StructureKind.VariableDeclaration:return!0;default:return!1}},isPropertySignature(t){return t?.kind===e.StructureKind.PropertySignature},isSetAccessor(t){return t?.kind===e.StructureKind.SetAccessor},isShorthandPropertyAssignment(t){return t?.kind===e.StructureKind.ShorthandPropertyAssignment},isSourceFile(t){return t?.kind===e.StructureKind.SourceFile},isSpreadAssignment(t){return t?.kind===e.StructureKind.SpreadAssignment},isExpressioned(t){return t?.kind===e.StructureKind.SpreadAssignment},isTypeAlias(t){return t?.kind===e.StructureKind.TypeAlias},isTypeParameter(t){return t?.kind===e.StructureKind.TypeParameter},isVariableDeclaration(t){return t?.kind===e.StructureKind.VariableDeclaration},isVariableStatement(t){return t?.kind===e.StructureKind.VariableStatement}};function Yn(n,r){if(t.ArrayUtils.isReadonlyArray(n)){for(let e of n){let t=r(e);if(t)return t}return}switch(n.kind){case e.StructureKind.CallSignature:return Xn(n,r);case e.StructureKind.Class:return tr(n,r);case e.StructureKind.ClassStaticBlock:return ir(n,r);case e.StructureKind.ConstructorOverload:return or(n,r);case e.StructureKind.Constructor:return sr(n,r);case e.StructureKind.ConstructSignature:return lr(n,r);case e.StructureKind.Enum:return ur(n,r);case e.StructureKind.EnumMember:return dr(n,r);case e.StructureKind.ExportAssignment:return fr(n,r);case e.StructureKind.ExportDeclaration:return pr(n,r);case e.StructureKind.FunctionOverload:return mr(n,r);case e.StructureKind.Function:return hr(n,r);case e.StructureKind.GetAccessor:return gr(n,r);case e.StructureKind.ImportDeclaration:return _r(n,r);case e.StructureKind.IndexSignature:return vr(n,r);case e.StructureKind.Interface:return yr(n,r);case e.StructureKind.JSDoc:return xr(n,r);case e.StructureKind.JsxElement:return Sr(n,r);case e.StructureKind.JsxSelfClosingElement:return Cr(n,r);case e.StructureKind.MethodOverload:return Tr(n,r);case e.StructureKind.Method:return Er(n,r);case e.StructureKind.MethodSignature:return Dr(n,r);case e.StructureKind.Module:return Or(n,r);case e.StructureKind.Parameter:return kr(n,r);case e.StructureKind.Property:return Ar(n,r);case e.StructureKind.PropertySignature:return jr(n,r);case e.StructureKind.SetAccessor:return Mr(n,r);case e.StructureKind.SourceFile:return Nr(n,r);case e.StructureKind.TypeAlias:return W(n,r);case e.StructureKind.VariableStatement:return Pr(n,r);default:return}}function Xn(e,t){return Zn(e,t)||Qn(e,t)||er(e,t)}function Zn(t,n){return Ir(t.docs,n,e.StructureKind.JSDoc)}function Qn(e,t){return $n(e,t)}function $n(t,n){return Fr(t.parameters,n,e.StructureKind.Parameter)}function er(t,n){return Ir(t.typeParameters,n,e.StructureKind.TypeParameter)}function tr(e,t){return nr(e,t)}function nr(t,n){return rr(t,n)||er(t,n)||Zn(t,n)||Fr(t.ctors,n,e.StructureKind.Constructor)||Fr(t.staticBlocks,n,e.StructureKind.ClassStaticBlock)||Fr(t.properties,n,e.StructureKind.Property)||Fr(t.getAccessors,n,e.StructureKind.GetAccessor)||Fr(t.setAccessors,n,e.StructureKind.SetAccessor)||Fr(t.methods,n,e.StructureKind.Method)}function rr(t,n){return Fr(t.decorators,n,e.StructureKind.Decorator)}function ir(e,t){return Zn(e,t)||ar(e,t)}function ar(e,t){return Lr(e.statements,t)}function or(e,t){return Qn(e,t)||er(e,t)||Zn(e,t)}function sr(t,n){return cr(t,n)||Fr(t.overloads,n,e.StructureKind.ConstructorOverload)}function cr(e,t){return Qn(e,t)||er(e,t)||Zn(e,t)||ar(e,t)}function lr(e,t){return Zn(e,t)||Qn(e,t)||er(e,t)}function ur(t,n){return Zn(t,n)||Fr(t.members,n,e.StructureKind.EnumMember)}function dr(e,t){return Zn(e,t)}function fr(e,t){return Zn(e,t)}function pr(t,n){return Ir(t.namedExports,n,e.StructureKind.ExportSpecifier)||Fr(t.attributes,n,e.StructureKind.ImportAttribute)}function mr(e,t){return Qn(e,t)||er(e,t)||Zn(e,t)}function hr(t,n){return cr(t,n)||Fr(t.overloads,n,e.StructureKind.FunctionOverload)}function gr(e,t){return rr(e,t)||cr(e,t)}function _r(t,n){return Ir(t.namedImports,n,e.StructureKind.ImportSpecifier)||Fr(t.attributes,n,e.StructureKind.ImportAttribute)}function vr(e,t){return Zn(e,t)}function yr(e,t){return er(e,t)||Zn(e,t)||br(e,t)}function br(t,n){return Fr(t.callSignatures,n,e.StructureKind.CallSignature)||Fr(t.constructSignatures,n,e.StructureKind.ConstructSignature)||Fr(t.getAccessors,n,e.StructureKind.GetAccessor)||Fr(t.indexSignatures,n,e.StructureKind.IndexSignature)||Fr(t.methods,n,e.StructureKind.MethodSignature)||Fr(t.properties,n,e.StructureKind.PropertySignature)||Fr(t.setAccessors,n,e.StructureKind.SetAccessor)}function xr(t,n){return Fr(t.tags,n,e.StructureKind.JSDocTag)}function Sr(e,t){return Lr(e.attributes,t)||Lr(e.children,t)}function Cr(e,t){return wr(e,t)}function wr(e,t){return Lr(e.attributes,t)}function Tr(e,t){return Qn(e,t)||er(e,t)||Zn(e,t)}function Er(t,n){return rr(t,n)||cr(t,n)||Fr(t.overloads,n,e.StructureKind.MethodOverload)}function Dr(e,t){return Zn(e,t)||Qn(e,t)||er(e,t)}function Or(e,t){return Zn(e,t)||ar(e,t)}function kr(e,t){return rr(e,t)}function Ar(e,t){return Zn(e,t)||rr(e,t)}function jr(e,t){return Zn(e,t)}function Mr(e,t){return rr(e,t)||cr(e,t)}function Nr(e,t){return ar(e,t)}function W(e,t){return er(e,t)||Zn(e,t)}function Pr(t,n){return Zn(t,n)||Fr(t.declarations,n,e.StructureKind.VariableDeclaration)}function Fr(e,t,n){if(e!=null)for(let r of e){let e=t(Rr(r,n));if(e)return e}}function Ir(e,t,n){if(!(e==null||!(e instanceof Array))){for(let r of e)if(zr(r)){let e=t(Rr(r,n));if(e)return e}}}function Lr(e,t){if(!(e==null||!(e instanceof Array))){for(let n of e)if(zr(n)){let e=t(n);if(e)return e}}}function Rr(e,t){return e.kind??=t,e}function zr(e){return e!=null&&typeof e.kind==`number`}function Br(e){return e.iterateLastCharCodes(e=>e===o.CLOSE_BRACE?!0:t.StringUtils.isWhitespaceCharCode(e)?void 0:!1)||!1}var Vr=class extends Pn{#e;#t;constructor(e,t){super(),this.#t=e,this.#e=t}printTexts(e,t){if(t!=null)if(typeof t==`string`||t instanceof Function)this.printText(e,t);else for(let n of t)Br(e)?e.blankLineIfLastNot():e.isAtStartOfFirstLineOfBlock()||e.newLineIfLastNot(),this.printText(e,n)}printText(n,r){if(typeof r==`string`||r instanceof Function||r==null){this.printTextOrWriterFunc(n,r);return}switch(r.kind){case e.StructureKind.Method:this.#e.isAmbient||i(),this.#t.forMethodDeclaration(this.#e).printText(n,r);break;case e.StructureKind.Property:this.#t.forPropertyDeclaration().printText(n,r);break;case e.StructureKind.GetAccessor:this.#e.isAmbient||i(),this.#t.forGetAccessorDeclaration(this.#e).printText(n,r);break;case e.StructureKind.SetAccessor:this.#e.isAmbient||i(),this.#t.forSetAccessorDeclaration(this.#e).printText(n,r);break;case e.StructureKind.Constructor:this.#e.isAmbient||i(),this.#t.forConstructorDeclaration(this.#e).printText(n,r);break;case e.StructureKind.ClassStaticBlock:i(),this.#t.forClassStaticBlockDeclaration().printText(n,r);break;default:t.errors.throwNotImplementedForNeverValueError(r)}function i(){n.isAtStartOfFirstLineOfBlock()||n.blankLineIfLastNot()}}},Hr=class extends Gn{constructor(e){super(e)}printTexts(e,t){if(t!=null)for(let n=0;n<t.length;n++)n>0&&e.blankLine(),this.printText(e,t[n])}printTextInternal(e,t){e.write(`static`),e.space().inlineBlock(()=>{this.factory.forStatementedNode({isAmbient:!1}).printText(e,t)})}},Ur=class extends Gn{#e;constructor(e,t){super(e),this.#e=t}printTexts(e,t){if(t!=null)for(let n=0;n<t.length;n++)n>0&&(this.#e.isAmbient?e.newLine():e.blankLine()),this.printText(e,t[n])}printTextInternal(e,n){this.#t(e,r()),this.#n(e,n),this.#e.isAmbient?e.write(`;`):e.space().inlineBlock(()=>{this.factory.forStatementedNode(this.#e).printText(e,n)});function r(){let e=t.ObjectUtils.clone(n.overloads);if(!(e==null||e.length===0)){for(let t of e)N(t,`scope`,n.scope);return e}}}#t(e,t){if(!(t==null||t.length===0))for(let n of t)this.printOverload(e,n),e.newLine()}printOverload(e,t){this.printLeadingTrivia(e,t),this.#n(e,t),e.write(`;`),this.printTrailingTrivia(e,t)}#n(e,t){this.factory.forJSDoc().printDocs(e,t.docs),this.factory.forModifierableNode().printText(e,t),e.write(`constructor`),this.factory.forTypeParameterDeclaration().printTextsWithBrackets(e,t.typeParameters),this.factory.forParameterDeclaration().printTextsWithParenthesis(e,t.parameters)}},Wr=class extends Gn{#e;#t;constructor(e,t){super(e),this.#e=t,this.#t=this.#e.isAmbient?new Un(this):new zn(this)}printTexts(e,t){t!=null&&this.#t.printText(e,t)}printTextInternal(e,t){this.factory.forJSDoc().printDocs(e,t.docs),this.factory.forDecorator().printTexts(e,t.decorators),this.factory.forModifierableNode().printText(e,t),e.write(`get ${t.name}`),this.factory.forTypeParameterDeclaration().printTextsWithBrackets(e,t.typeParameters),this.factory.forParameterDeclaration().printTextsWithParenthesis(e,t.parameters),this.factory.forReturnTypedNode().printText(e,t),this.#e.isAmbient||t.isAbstract?e.write(`;`):e.spaceIfLastNot().inlineBlock(()=>{this.factory.forStatementedNode(this.#e).printText(e,t)})}},Gr=class extends Gn{#e;constructor(e,t){super(e),this.#e=t}printTexts(e,t){if(t!=null)for(let n=0;n<t.length;n++)n>0&&(this.#e.isAmbient?e.newLine():e.blankLine()),this.printText(e,t[n])}printTextInternal(e,n){this.#t(e,n.name,r()),this.#n(e,n.name,n),this.#e.isAmbient||n.isAbstract?e.write(`;`):e.spaceIfLastNot().inlineBlock(()=>{this.factory.forStatementedNode(this.#e).printText(e,n)});function r(){let e=t.ObjectUtils.clone(n.overloads);if(!(e==null||e.length===0)){for(let t of e)N(t,`scope`,n.scope),N(t,`isStatic`,n.isStatic),N(t,`isAbstract`,n.isAbstract),N(t,`hasQuestionToken`,n.hasQuestionToken);return e}}}#t(e,t,n){if(!(n==null||n.length===0))for(let r of n)this.printOverload(e,t,r),e.newLine()}printOverload(e,t,n){this.printLeadingTrivia(e,n),this.#n(e,t,n),e.write(`;`),this.printTrailingTrivia(e,n)}#n(e,t,n){this.factory.forJSDoc().printDocs(e,n.docs),n.decorators!=null&&this.factory.forDecorator().printTexts(e,n.decorators),this.factory.forModifierableNode().printText(e,n),e.conditionalWrite(n.isGenerator,`*`),e.write(t),e.conditionalWrite(n.hasQuestionToken,`?`),this.factory.forTypeParameterDeclaration().printTextsWithBrackets(e,n.typeParameters),this.factory.forParameterDeclaration().printTextsWithParenthesis(e,n.parameters),this.factory.forReturnTypedNode().printText(e,n)}},Kr=class extends Gn{#e=new Un(this);printTexts(e,t){this.#e.printText(e,t)}printTextInternal(e,t){this.factory.forJSDoc().printDocs(e,t.docs),this.factory.forDecorator().printTexts(e,t.decorators),this.factory.forModifierableNode().printText(e,t),e.write(t.name),e.conditionalWrite(t.hasQuestionToken,`?`),e.conditionalWrite(t.hasExclamationToken&&!t.hasQuestionToken,`!`),this.factory.forTypedNode(`:`).printText(e,t),this.factory.forInitializerExpressionableNode().printText(e,t),e.write(`;`)}},qr=class extends Gn{#e;#t;constructor(e,t){super(e),this.#e=t,this.#t=this.#e.isAmbient?new Un(this):new zn(this)}printTexts(e,t){t!=null&&this.#t.printText(e,t)}printTextInternal(e,t){this.factory.forJSDoc().printDocs(e,t.docs),this.factory.forDecorator().printTexts(e,t.decorators),this.factory.forModifierableNode().printText(e,t),e.write(`set ${t.name}`),this.factory.forTypeParameterDeclaration().printTextsWithBrackets(e,t.typeParameters),this.factory.forParameterDeclaration().printTextsWithParenthesis(e,t.parameters),this.factory.forReturnTypedNode().printText(e,t),this.#e.isAmbient||t.isAbstract?e.write(`;`):e.spaceIfLastNot().inlineBlock(()=>{this.factory.forStatementedNode(this.#e).printText(e,t)})}},Jr=class extends Pn{printText(e,t){typeof t==`string`?e.write(t):t(e)}},Yr=class extends Gn{printTexts(e,t){this.#n(e,t,()=>e.newLine())}printTextsInline(e,t){this.#n(e,t,()=>e.space())}printTextInternal(e,t){e.write(`@${t.name}`),this.#e(e,t),this.#t(e,t)}#e(e,t){if(!(t.typeArguments==null||t.typeArguments.length===0)){e.write(`<`);for(let n=0;n<t.typeArguments.length;n++)e.conditionalWrite(n>0,`, `),e.write(this.getTextWithQueuedChildIndentation(e,t.typeArguments[n]));e.write(`>`)}}#t(e,t){if(t.arguments==null)return;e.write(`(`);let n=t.arguments instanceof Array?t.arguments:[t.arguments];for(let t=0;t<n.length;t++)e.conditionalWrite(t>0,`, `),e.write(this.getTextWithQueuedChildIndentation(e,n[t]));e.write(`)`)}#n(e,t,n){if(!(t==null||t.length===0))for(let r of t)this.printText(e,r),n()}},Xr=class extends Gn{printDocs(e,t){if(t!=null)for(let n of t)this.printText(e,n),e.newLine()}printTextInternal(e,t){let n=o(this).split(/\r?\n/),r=n[0].length===0,i=n.length<=1,a=+!!r;if(e.write(`/**`),i?e.space():e.newLine(),i)e.write(n[a]);else for(let t=a;t<n.length;t++)e.write(` *`),n[t].length>0&&e.write(` ${n[t]}`),e.newLine();e.spaceIfLastNot(),e.write(`*/`);function o(n){if(typeof t==`string`)return t;let r=n.getNewWriter(e);return typeof t==`function`?t(r):(t.description&&re(r,t.description),t.tags&&t.tags.length>0&&(r.getLength()>0&&r.newLine(),n.factory.forJSDocTag({printStarsOnNewLine:!1}).printTexts(r,t.tags))),r.toString()}}},Zr=class extends Gn{#e;constructor(e,t){super(e),this.#e=t}printTexts(e,t){if(t!=null)for(let n=0;n<t.length;n++)n>0&&(e.newLine(),e.conditionalWrite(this.#e.printStarsOnNewLine,` * `)),this.printText(e,t[n])}printTextInternal(e,n){let r=i(this).split(/\r?\n/);for(let t=0;t<r.length;t++)t>0&&(e.newLine(),this.#e.printStarsOnNewLine&&e.write(` *`)),r[t].length>0&&(this.#e.printStarsOnNewLine&&t>0&&e.space(),e.write(r[t]));function i(r){if(typeof n==`string`)return n;let i=r.getNewWriter(e);if(typeof n==`function`)n(i);else{n.text&&re(i,n.text);let e=i.toString();i.unsafeInsert(0,`@${n.tagName}`+(e.length>0&&!t.StringUtils.startsWithNewLine(e)?` `:``))}return i.toString()}}},Qr=class extends Gn{#e=new zn(this);printTexts(e,t){this.#e.printText(e,t)}printTextInternal(e,t){this.factory.forJSDoc().printDocs(e,t.docs),this.factory.forModifierableNode().printText(e,t),e.conditionalWrite(t.isConst,`const `),e.write(`enum ${t.name} `).inlineBlock(()=>{this.factory.forEnumMember().printTexts(e,t.members)})}},$r=class extends Gn{#e=new Hn(this);printTexts(e,t){this.#e.printText(e,t)}printTextInternal(e,n){if(n instanceof Function){n(e);return}else if(typeof n==`string`){e.write(n);return}if(this.factory.forJSDoc().printDocs(e,n.docs),ce(n.name)||t.StringUtils.isQuoted(n.name)?e.write(n.name):e.quote(n.name),typeof n.value==`string`){let{value:t}=n;e.hangingIndent(()=>e.write(` = `).quote(t))}else typeof n.value==`number`?e.write(` = ${n.value}`):this.factory.forInitializerExpressionableNode().printText(e,n)}},ei=class extends Pn{#e;#t=new Hn(this);#n={isAmbient:!1};constructor(e){super(),this.#e=e}printTexts(e,t){this.#t.printText(e,t)}printText(n,r){if(typeof r==`string`||r instanceof Function||r==null){this.printTextOrWriterFunc(n,r);return}switch(r.kind){case e.StructureKind.PropertyAssignment:this.#e.forPropertyAssignment().printText(n,r);break;case e.StructureKind.ShorthandPropertyAssignment:this.#e.forShorthandPropertyAssignment().printText(n,r);break;case e.StructureKind.SpreadAssignment:this.#e.forSpreadAssignment().printText(n,r);break;case e.StructureKind.Method:this.#e.forMethodDeclaration(this.#n).printText(n,r);break;case e.StructureKind.GetAccessor:this.#e.forGetAccessorDeclaration(this.#n).printText(n,r);break;case e.StructureKind.SetAccessor:this.#e.forSetAccessorDeclaration(this.#n).printText(n,r);break;default:t.errors.throwNotImplementedForNeverValueError(r)}}},ti=class extends Gn{printTextInternal(e,t){e.hangingIndent(()=>{e.write(`${t.name}: `),re(e,t.initializer)})}},ni=class extends Gn{printTextInternal(e,t){e.write(`${t.name}`)}},ri=class extends Gn{printTextInternal(e,t){e.hangingIndent(()=>{e.write(`...`),re(e,t.expression)})}},ii=class extends Gn{#e;constructor(e,t){super(e),this.#e=t}printTexts(e,t){if(t!=null)for(let n=0;n<t.length;n++){let r=t[n];if(n>0){let i=t[n-1];this.#e.isAmbient||i.hasDeclareKeyword&&r.hasDeclareKeyword?e.newLine():e.blankLine()}this.printText(e,r)}}printTextInternal(e,n){this.#t(e,n.name,r()),this.#n(e,n.name,n),this.#e.isAmbient||n.hasDeclareKeyword?e.write(`;`):e.space().inlineBlock(()=>{this.factory.forStatementedNode({isAmbient:!1}).printText(e,n)});function r(){let e=t.ObjectUtils.clone(n.overloads);if(!(e==null||e.length===0)){for(let t of e)N(t,`hasDeclareKeyword`,n.hasDeclareKeyword),N(t,`isExported`,n.isExported),N(t,`isDefaultExport`,n.isDefaultExport);return e}}}#t(e,t,n){if(!(n==null||n.length===0))for(let r of n)this.printOverload(e,t,r),e.newLine()}printOverload(e,t,n){this.printLeadingTrivia(e,n),this.#n(e,t,n),e.write(`;`),this.printTrailingTrivia(e,n)}#n(e,n,r){this.factory.forJSDoc().printDocs(e,r.docs),this.factory.forModifierableNode().printText(e,r),e.write(`function`),e.conditionalWrite(r.isGenerator,`*`),t.StringUtils.isNullOrWhitespace(n)||e.write(` ${n}`),this.factory.forTypeParameterDeclaration().printTextsWithBrackets(e,r.typeParameters),this.factory.forParameterDeclaration().printTextsWithParenthesis(e,r.parameters),this.factory.forReturnTypedNode().printText(e,r)}},ai=class extends Gn{#e=new Bn(this);printTextsWithParenthesis(e,t){e.write(`(`),t!=null&&this.factory.forParameterDeclaration().printTexts(e,t),e.write(`)`)}printTexts(e,t){t==null||t.length===0||e.hangingIndent(()=>{this.#e.printText(e,t)})}printTextInternal(e,n){if(n.name==null)throw new t.errors.NotImplementedError(`Not implemented scenario where parameter declaration structure doesn't have a name. Please open an issue if you need this.`);this.factory.forDecorator().printTextsInline(e,n.decorators),this.factory.forModifierableNode().printText(e,n),e.conditionalWrite(n.isRestParameter,`...`),e.write(n.name),e.conditionalWrite(n.hasQuestionToken,`?`),this.factory.forTypedNode(`:`,n.hasQuestionToken).printText(e,n),this.factory.forInitializerExpressionableNode().printText(e,n)}},oi=class extends Gn{#e=new Un(this);printTexts(e,t){this.#e.printText(e,t)}printTextInternal(e,t){this.factory.forJSDoc().printDocs(e,t.docs),this.factory.forTypeParameterDeclaration().printTextsWithBrackets(e,t.typeParameters),this.factory.forParameterDeclaration().printTextsWithParenthesis(e,t.parameters),this.factory.forReturnTypedNode(!0).printText(e,t),e.write(`;`)}},si=class extends Gn{#e=new Un(this);printTexts(e,t){this.#e.printText(e,t)}printTextInternal(e,t){this.factory.forJSDoc().printDocs(e,t.docs),e.write(`new`),this.factory.forTypeParameterDeclaration().printTextsWithBrackets(e,t.typeParameters),this.factory.forParameterDeclaration().printTextsWithParenthesis(e,t.parameters),this.factory.forReturnTypedNode().printText(e,t),e.write(`;`)}},ci=class extends Gn{#e=new Un(this);printTexts(e,t){this.#e.printText(e,t)}printTextInternal(e,t){this.factory.forJSDoc().printDocs(e,t.docs),this.factory.forModifierableNode().printText(e,t),e.write(`[${t.keyName||`key`}: ${t.keyType||`string`}]`),this.factory.forReturnTypedNode().printText(e,t),e.write(`;`)}},li=class extends Gn{#e=new zn(this);printTexts(e,t){this.#e.printText(e,t)}printTextInternal(e,n){if(this.factory.forJSDoc().printDocs(e,n.docs),this.factory.forModifierableNode().printText(e,n),e.write(`interface ${n.name}`),this.factory.forTypeParameterDeclaration().printTextsWithBrackets(e,n.typeParameters),e.space(),n.extends!=null){let r=n.extends instanceof Array?n.extends.map(t=>this.getText(e,t)).join(`, `):this.getText(e,n.extends);t.StringUtils.isNullOrWhitespace(r)||e.hangingIndent(()=>e.write(`extends ${r} `))}e.inlineBlock(()=>{this.factory.forTypeElementMemberedNode().printText(e,n)})}},ui=class extends Gn{#e=new Un(this);printTexts(e,t){this.#e.printText(e,t)}printTextInternal(e,t){this.factory.forJSDoc().printDocs(e,t.docs),e.write(t.name),e.conditionalWrite(t.hasQuestionToken,`?`),this.factory.forTypeParameterDeclaration().printTextsWithBrackets(e,t.typeParameters),this.factory.forParameterDeclaration().printTextsWithParenthesis(e,t.parameters),this.factory.forReturnTypedNode().printText(e,t),e.write(`;`)}},di=class extends Gn{#e=new Un(this);printTexts(e,t){this.#e.printText(e,t)}printTextInternal(e,t){this.factory.forJSDoc().printDocs(e,t.docs),this.factory.forModifierableNode().printText(e,t),e.write(t.name),e.conditionalWrite(t.hasQuestionToken,`?`),this.factory.forTypedNode(`:`).printText(e,t),this.factory.forInitializerExpressionableNode().printText(e,t),e.write(`;`)}},fi=class extends Pn{#e;constructor(e){super(),this.#e=e}printText(e,t){this.#e.forCallSignatureDeclaration().printTexts(e,t.callSignatures),this.#n(e,t.constructSignatures),this.#e.forConstructSignatureDeclaration().printTexts(e,t.constructSignatures),this.#n(e,t.indexSignatures),this.#e.forIndexSignatureDeclaration().printTexts(e,t.indexSignatures),this.#t(e,t),this.#n(e,t.properties),this.#e.forPropertySignature().printTexts(e,t.properties),this.#n(e,t.methods),this.#e.forMethodSignature().printTexts(e,t.methods)}#t(e,t){t.getAccessors==null&&t.setAccessors==null||new Kn(this.#e.forGetAccessorDeclaration({isAmbient:!0}),this.#e.forSetAccessorDeclaration({isAmbient:!0})).printGetAndSet(e,t.getAccessors,t.setAccessors,!0)}#n(e,n){!t.ArrayUtils.isNullOrEmpty(n)&&!e.isAtStartOfFirstLineOfBlock()&&e.newLine()}},pi=class extends Pn{#e;constructor(e){super(),this.#e=e}printTexts(e,t){if(t!=null)if(typeof t==`string`||t instanceof Function)this.printText(e,t);else for(let n of t)Br(e)?e.blankLineIfLastNot():e.isAtStartOfFirstLineOfBlock()||e.newLineIfLastNot(),this.printText(e,n)}printText(n,r){if(typeof r==`string`||r instanceof Function||r==null){this.printTextOrWriterFunc(n,r);return}switch(r.kind){case e.StructureKind.PropertySignature:this.#e.forPropertySignature().printText(n,r);break;case e.StructureKind.MethodSignature:this.#e.forMethodSignature().printText(n,r);break;case e.StructureKind.CallSignature:this.#e.forCallSignatureDeclaration().printText(n,r);break;case e.StructureKind.IndexSignature:this.#e.forIndexSignatureDeclaration().printText(n,r);break;case e.StructureKind.ConstructSignature:this.#e.forConstructSignatureDeclaration().printText(n,r);break;default:t.errors.throwNotImplementedForNeverValueError(r)}}},mi=class extends Gn{printTextInternal(n,r){if(i())this.factory.forJsxAttribute().printTextWithoutTrivia(n,r);else if(r.kind===e.StructureKind.JsxSpreadAttribute)this.factory.forJsxSpreadAttribute().printTextWithoutTrivia(n,r);else throw t.errors.throwNotImplementedForNeverValueError(r);function i(t){return r.kind==null||r.kind===e.StructureKind.JsxAttribute}}},hi=class extends Gn{printTextInternal(e,t){typeof t.name==`object`?this.factory.forJsxNamespacedName().printText(e,t.name):e.write(t.name),t.initializer!=null&&e.write(`=`).write(t.initializer)}},gi=class extends Gn{printTextInternal(n,r){i(r)?this.factory.forJsxElement().printText(n,r):r.kind===e.StructureKind.JsxSelfClosingElement?this.factory.forJsxSelfClosingElement().printText(n,r):t.errors.throwNotImplementedForNeverValueError(r);function i(t){return t.kind==null||t.kind===e.StructureKind.JsxElement}}},_i=class extends Gn{printTextInternal(e,t){e.hangingIndent(()=>{e.write(`<${t.name}`),t.attributes&&this.#e(e,t.attributes),e.write(`>`)}),this.#t(e,t.children),e.write(`</${t.name}>`)}#e(e,t){let n=this.factory.forJsxAttributeDecider();for(let r of t)e.space(),n.printText(e,r)}#t(e,t){t!=null&&(e.newLine(),e.indent(()=>{for(let n of t)this.factory.forJsxChildDecider().printText(e,n),e.newLine()}))}},vi=class extends Gn{printTextInternal(e,t){e.write(t.namespace).write(`:`).write(t.name)}},yi=class extends Gn{printTextInternal(e,t){e.hangingIndent(()=>{e.write(`<${t.name}`),t.attributes&&this.#e(e,t.attributes),e.write(` />`)})}#e(e,t){let n=this.factory.forJsxAttributeDecider();for(let r of t)e.space(),n.printText(e,r)}},bi=class extends Gn{printTextInternal(e,t){e.hangingIndent(()=>{e.write(`{`),e.write(`...`),e.write(t.expression),e.write(`}`)})}},xi=class extends Gn{#e=new Un(this);printTexts(e,t){this.#e.printText(e,t)}printTextInternal(e,t){this.factory.forJSDoc().printDocs(e,t.docs),e.write(`export`),t.isExportEquals===!1?e.write(` default `):e.write(` = `),e.write(this.getTextWithQueuedChildIndentation(e,t.expression)).write(`;`)}},Si=class extends Gn{#e=new Un(this);printTexts(e,t){this.#e.printText(e,t)}printTextInternal(e,n){let r=n.moduleSpecifier!=null&&n.moduleSpecifier.length>0;if(n.namedExports!=null&&n.namedExports.length>0&&n.namespaceExport!=null)throw new t.errors.InvalidOperationError(`An export declaration cannot have both a namespace export and a named export.`);e.write(`export`),n.isTypeOnly&&e.write(` type`),n.namedExports!=null&&n.namedExports.length>0?(e.space(),this.factory.forNamedImportExportSpecifier().printTextsWithBraces(e,n.namedExports)):n.namespaceExport==null?r?e.write(` *`):e.write(` {`).conditionalWrite(this.factory.getFormatCodeSettings().insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces,` `).write(`}`):(e.write(` *`),t.StringUtils.isNullOrWhitespace(n.namespaceExport)||e.write(` as ${n.namespaceExport}`)),r&&(e.write(` from `),e.quote(n.moduleSpecifier)),n.attributes&&(e.space(),this.factory.forImportAttribute().printAttributes(e,n.attributes)),e.write(`;`)}},Ci=class extends Gn{#e=new Hn(this);printTexts(e,t){this.#e.printText(e,t)}printAttributes(e,t){t&&(e.write(`with `),e.inlineBlock(()=>{this.printTexts(e,t)}))}printTextInternal(e,t){e.write(t.name),e.write(`: `),e.quote(t.value)}},wi=class extends Gn{#e=new Un(this);printTexts(e,t){this.#e.printText(e,t)}printTextInternal(e,n){let r=n.namedImports!=null&&n.namedImports.length>0;if(r&&n.namespaceImport!=null)throw new t.errors.InvalidOperationError(`An import declaration cannot have both a namespace import and a named import.`);e.write(`import`),n.isTypeOnly&&e.write(` type`),n.defaultImport!=null&&(e.write(` ${n.defaultImport}`),e.conditionalWrite(r||n.namespaceImport!=null,`,`)),n.namespaceImport!=null&&e.write(` * as ${n.namespaceImport}`),n.namedImports!=null&&n.namedImports.length>0&&(e.space(),this.factory.forNamedImportExportSpecifier().printTextsWithBraces(e,n.namedImports)),e.conditionalWrite(n.defaultImport!=null||r||n.namespaceImport!=null,` from`),e.write(` `),e.quote(n.moduleSpecifier),n.attributes&&(e.space(),this.factory.forImportAttribute().printAttributes(e,n.attributes)),e.write(`;`)}},Ti=class extends Gn{#e;#t=new zn(this);constructor(e,t){super(e),this.#e=t}printTexts(e,t){this.#t.printText(e,t)}printTextInternal(n,r){r=this.#n(r),this.factory.forJSDoc().printDocs(n,r.docs),this.factory.forModifierableNode().printText(n,r),r.declarationKind==null||r.declarationKind!==e.ModuleDeclarationKind.Global?n.write(`${r.declarationKind||`namespace`} ${r.name}`):n.write(`global`),r.hasDeclareKeyword&&t.StringUtils.isQuoted(r.name.trim())&&r.hasOwnProperty(t.nameof(r,`statements`))&&r.statements==null?n.write(`;`):(n.write(` `),n.inlineBlock(()=>{this.factory.forStatementedNode({isAmbient:r.hasDeclareKeyword||this.#e.isAmbient}).printText(n,r)}))}#n(n){if(t.StringUtils.isQuoted(n.name.trim())){if(n.declarationKind===e.ModuleDeclarationKind.Namespace)throw new t.errors.InvalidOperationError(`Cannot print a namespace with quotes for namespace with name ${n.name}. Use ModuleDeclarationKind.Module instead.`);n=t.ObjectUtils.clone(n),N(n,`hasDeclareKeyword`,!0),N(n,`declarationKind`,e.ModuleDeclarationKind.Module)}return n}},Ei=class extends Gn{#e=new Bn(this);printTextsWithBraces(e,n){let r=this.factory.getFormatCodeSettings();e.write(`{`);let i=this.getNewWriter(e);this.printTexts(i,n);let a=i.toString();r.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces&&!t.StringUtils.startsWithNewLine(a)&&e.space(),e.write(a),r.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces&&!t.StringUtils.endsWithNewLine(a)&&e.space(),e.write(`}`)}printTexts(e,t){t instanceof Function?this.printText(e,t):this.#e.printText(e,t)}printTextInternal(e,n){let r=this.getNewWriterWithQueuedChildIndentation(e);typeof n==`string`?r.write(n):n instanceof Function?n(r):(n.isTypeOnly&&e.write(`type `),r.write(n.name),t.StringUtils.isNullOrWhitespace(n.alias)||(r.isLastNewLine()||r.space(),r.write(`as ${n.alias}`))),e.write(r.toString())}},Di=class extends Gn{#e;constructor(e,t){super(e),this.#e=t}printTextInternal(e,t){this.factory.forStatementedNode(this.#e).printText(e,t),e.conditionalNewLine(!e.isAtStartOfFirstLineOfBlock()&&!e.isLastNewLine())}},Oi=class extends Pn{#e;#t;constructor(e,t){super(),this.#t=e,this.#e=t}printText(e,t){this.#t.forStatement(this.#e).printTexts(e,t.statements)}},ki=class extends Pn{#e;#t;constructor(e,t){super(),this.#t=e,this.#e=t}printTexts(e,t){if(t!=null)if(typeof t==`string`||t instanceof Function)this.printText(e,t);else for(let n of t)Br(e)?e.blankLineIfLastNot():e.isAtStartOfFirstLineOfBlock()||e.newLineIfLastNot(),this.printText(e,n)}printText(n,r){if(typeof r==`string`||r instanceof Function||r==null){this.printTextOrWriterFunc(n,r);return}switch(r.kind){case e.StructureKind.Function:this.#e.isAmbient||i(),this.#t.forFunctionDeclaration(this.#e).printText(n,r);break;case e.StructureKind.Class:i(),this.#t.forClassDeclaration(this.#e).printText(n,r);break;case e.StructureKind.Interface:i(),this.#t.forInterfaceDeclaration().printText(n,r);break;case e.StructureKind.TypeAlias:this.#t.forTypeAliasDeclaration().printText(n,r);break;case e.StructureKind.VariableStatement:this.#t.forVariableStatement().printText(n,r);break;case e.StructureKind.ImportDeclaration:this.#t.forImportDeclaration().printText(n,r);break;case e.StructureKind.Module:i(),this.#t.forModuleDeclaration(this.#e).printText(n,r);break;case e.StructureKind.Enum:i(),this.#t.forEnumDeclaration().printText(n,r);break;case e.StructureKind.ExportDeclaration:this.#t.forExportDeclaration().printText(n,r);break;case e.StructureKind.ExportAssignment:this.#t.forExportAssignment().printText(n,r);break;default:t.errors.throwNotImplementedForNeverValueError(r)}function i(){n.isAtStartOfFirstLineOfBlock()||n.blankLineIfLastNot()}}};e.VariableDeclarationKind=void 0,(function(e){e.Var=`var`,e.Let=`let`,e.Const=`const`,e.AwaitUsing=`await using`,e.Using=`using`})(e.VariableDeclarationKind||={});var Ai=class extends Gn{#e=new Un(this);printTexts(e,t){this.#e.printText(e,t)}printTextInternal(t,n){this.factory.forJSDoc().printDocs(t,n.docs),t.hangingIndent(()=>{if(this.factory.forModifierableNode().printText(t,n),t.write(`${n.declarationKind||e.VariableDeclarationKind.Let} `),n.declarations.length===0)throw Error(`You must provide at least one declaration when inserting a variable statement.`);this.factory.forVariableDeclaration().printTexts(t,n.declarations),t.write(`;`)})}},ji=class extends Gn{#e=new Un(this);printTexts(e,t){this.#e.printText(e,t)}printTextInternal(e,t){this.factory.forJSDoc().printDocs(e,t.docs),this.factory.forModifierableNode().printText(e,t),e.write(`type ${t.name}`),this.factory.forTypeParameterDeclaration().printTextsWithBrackets(e,t.typeParameters),this.factory.forTypedNode(` =`).printText(e,t),e.write(`;`)}},Mi=class extends Gn{#e=new Bn(this);printTextsWithBrackets(e,t){t==null||t.length===0||(e.write(`<`),this.printTexts(e,t),e.write(`>`))}printTexts(e,t){this.#e.printText(e,t)}printTextInternal(n,r){if(typeof r==`string`){n.write(r);return}n.hangingIndent(()=>{if(r.isConst&&n.write(`const `),r.variance!=null&&((r.variance&e.TypeParameterVariance.In)!==0&&n.write(`in `),(r.variance&e.TypeParameterVariance.Out)!==0&&n.write(`out `)),n.write(r.name),r.constraint!=null){let e=this.getText(n,r.constraint);t.StringUtils.isNullOrWhitespace(e)||n.write(` extends ${e}`)}if(r.default!=null){let e=this.getText(n,r.default);t.StringUtils.isNullOrWhitespace(e)||n.write(` = ${e}`)}})}},Ni=class extends Gn{#e=new Bn(this);printTexts(e,t){this.#e.printText(e,t)}printTextInternal(e,t){e.write(t.name),e.conditionalWrite(t.hasExclamationToken,`!`),this.factory.forTypedNode(`:`).printText(e,t),this.factory.forInitializerExpressionableNode().printText(e,t)}};function Pi(e){return class extends e{getExtends(){return this.getHeritageClauseByKind(t.SyntaxKind.ExtendsKeyword)?.getTypeNodes()??[]}addExtends(e){return this.insertExtends(this.getExtends().length,e)}insertExtends(e,n){let r=this.getExtends(),i=typeof n==`string`;if(typeof n==`string`)t.errors.throwIfWhitespaceOrNotString(n,`texts`),n=[n];else if(n.length===0)return[];let a=this._getWriterWithQueuedChildIndentation();if(new Bn(new Jr).printText(a,n),e=et(e,r.length),r.length>0)jt({parent:this.getHeritageClauseByKindOrThrow(t.SyntaxKind.ExtendsKeyword).getFirstChildByKindOrThrow(t.SyntaxKind.SyntaxList),currentNodes:r,insertIndex:e,newText:a.toString(),useTrailingCommas:!1});else{let e=this.getFirstChildByKindOrThrow(t.SyntaxKind.OpenBraceToken).getStart(),n=/\s/.test(this.getSourceFile().getFullText()[e-1]),r=`extends ${a.toString()} `;n||(r=` `+r),kt({parent:this,insertPos:e,newText:r})}let o=this.getExtends();return i?o[e]:Ye(r,o,e,!1)}removeExtends(e){let n=this.getHeritageClauseByKind(t.SyntaxKind.ExtendsKeyword);if(n==null)throw new t.errors.InvalidOperationError(`Cannot remove an extends when none exist.`);return n.removeExpression(e),this}set(t){return he(e.prototype,this,t),t.extends!=null&&(this.getExtends().forEach(e=>this.removeExtends(e)),this.addExtends(t.extends)),this}getStructure(){return me(e.prototype,this,{extends:this.getExtends().map(e=>e.getText())})}}}function Fi(e){return class extends e{isGenerator(){return this.compilerNode.asteriskToken!=null}getAsteriskToken(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.asteriskToken)}getAsteriskTokenOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getAsteriskToken(),e??`Expected to find an asterisk token.`,this)}setIsGenerator(e){let t=this.getAsteriskToken();return t!=null===e||(t==null?kt({insertPos:Ii(this),parent:this,newText:`*`}):Rt({children:[t],getSiblingFormatting:()=>_e.Space})),this}set(t){return he(e.prototype,this,t),t.isGenerator!=null&&this.setIsGenerator(t.isGenerator),this}getStructure(){return me(e.prototype,this,{isGenerator:this.isGenerator()})}}}function Ii(e){if(e.getKind()===t.SyntaxKind.FunctionDeclaration)return e.getFirstChildByKindOrThrow(t.SyntaxKind.FunctionKeyword).getEnd();let n=e;if(n.getName==null)throw new t.errors.NotImplementedError(`Expected a name node for a non-function declaration.`);return n.getNameNode().getStart()}function Li(e){return class extends e{getHeritageClauses(){return this.compilerNode.heritageClauses?.map(e=>this._getNodeFromCompilerNode(e))??[]}getHeritageClauseByKindOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getHeritageClauseByKind(e),n??(()=>`Expected to have heritage clause of kind ${t.getSyntaxKindName(e)}.`),this)}getHeritageClauseByKind(e){return this.getHeritageClauses().find(t=>t.compilerNode.token===e)}}}function Ri(e){return class extends e{getImplements(){return this.getHeritageClauseByKind(t.SyntaxKind.ImplementsKeyword)?.getTypeNodes()??[]}addImplements(e){return this.insertImplements(this.getImplements().length,e)}insertImplements(e,n){let r=this.getImplements(),i=typeof n==`string`;if(typeof n==`string`)t.errors.throwIfWhitespaceOrNotString(n,`texts`),n=[n];else if(n.length===0)return[];let a=this._getWriterWithQueuedChildIndentation();new Bn(new Jr).printText(a,n);let o=this.getHeritageClauses();if(e=et(e,r.length),r.length>0)jt({parent:this.getHeritageClauseByKindOrThrow(t.SyntaxKind.ImplementsKeyword).getFirstChildByKindOrThrow(t.SyntaxKind.SyntaxList),currentNodes:r,insertIndex:e,newText:a.toString(),useTrailingCommas:!1});else{let e=this.getFirstChildByKindOrThrow(t.SyntaxKind.OpenBraceToken).getStart(),n=/\s/.test(this.getSourceFile().getFullText()[e-1]),r=`implements ${a.toString()} `;n||(r=` `+r),kt({parent:o.length===0?this:o[0].getParentSyntaxListOrThrow(),insertPos:e,newText:r})}let s=this.getImplements();return i?s[0]:Ye(r,s,e,!1)}removeImplements(e){let n=this.getHeritageClauseByKind(t.SyntaxKind.ImplementsKeyword);if(n==null)throw new t.errors.InvalidOperationError(`Cannot remove an implements when none exist.`);return n.removeExpression(e),this}set(t){return he(e.prototype,this,t),t.implements!=null&&(this.getImplements().forEach(e=>this.removeImplements(e)),this.addImplements(t.implements)),this}getStructure(){return me(e.prototype,this,{implements:this.getImplements().map(e=>e.getText())})}}}function zi(e){return class extends e{hasInitializer(){return this.compilerNode.initializer!=null}getInitializerIfKindOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getInitializerIfKind(e),n??`Expected to find an initializer of kind '${t.getSyntaxKindName(e)}'.`,this)}getInitializerIfKind(e){let t=this.getInitializer();if(!(t!=null&&t.getKind()!==e))return t}getInitializerOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getInitializer(),e??`Expected to find an initializer.`,this)}getInitializer(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.initializer)}}}function Bi(e){return Vi(zi(e))}function Vi(e){return class extends e{removeInitializer(){let e=this.getInitializer();return e==null||It({children:[e.getPreviousSiblingIfKindOrThrow(t.SyntaxKind.EqualsToken),e],removePrecedingSpaces:!0}),this}setInitializer(e){let n=I(this._getWriterWithQueuedChildIndentation(),e);t.errors.throwIfWhitespaceOrNotString(n,`textOrWriterFunction`),this.hasInitializer()&&this.removeInitializer();let r=this.getLastChildIfKind(t.SyntaxKind.SemicolonToken);return kt({insertPos:r==null?this.getEnd():r.getPos(),parent:this,newText:` = ${n}`}),this}set(n){return he(e.prototype,this,n),n.initializer==null?n.hasOwnProperty(t.nameof(n,`initializer`))&&this.removeInitializer():this.setInitializer(n.initializer),this}getStructure(){let t=this.getInitializer();return me(e.prototype,this,{initializer:t?t.getText():void 0})}}}function Hi(e){return class extends e{getJsDocs(){return this.compilerNode.jsDoc?.map(e=>this._getNodeFromCompilerNode(e))??[]}addJsDoc(e){return this.addJsDocs([e])[0]}addJsDocs(e){return this.insertJsDocs(Ae(this.compilerNode.jsDoc),e)}insertJsDoc(e,t){return this.insertJsDocs(e,[t])[0]}insertJsDocs(e,n){if(t.ArrayUtils.isNullOrEmpty(n))return[];let r=this._getWriterWithQueuedIndentation();this._context.structurePrinterFactory.forJSDoc().printDocs(r,n),r.write(``);let i=r.toString(),a=this.getJsDocs();return e=et(e,a.length),kt({insertPos:e===a.length?this.getStart():a[e].getStart(),parent:this,newText:i}),Ye(a,this.getJsDocs(),e,!1)}set(t){return he(e.prototype,this,t),t.docs!=null&&(this.getJsDocs().forEach(e=>e.remove()),this.addJsDocs(t.docs)),this}getStructure(){return me(e.prototype,this,{docs:this.getJsDocs().map(e=>e.getStructure())})}}}function Ui(e){return class extends e{getLiteralText(){return this.compilerNode.text}isTerminated(){return!this.compilerNode.isUnterminated}hasExtendedUnicodeEscape(){return this.compilerNode.hasExtendedUnicodeEscape||!1}}}function Wi(e){return class extends e{getModifiers(){return this.getCompilerModifiers().map(e=>this._getNodeFromCompilerNode(e))}getFirstModifierByKindOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getFirstModifierByKind(e),n??(()=>`Expected a modifier of syntax kind: ${t.getSyntaxKindName(e)}`),this)}getFirstModifierByKind(e){for(let t of this.getCompilerModifiers())if(t.kind===e)return this._getNodeFromCompilerNode(t)}hasModifier(e){return typeof e==`string`?this.getModifiers().some(t=>t.getText()===e):this.getCompilerModifiers().some(t=>t.kind===e)}toggleModifier(e,t){return t??=!this.hasModifier(e),t?this.addModifier(e):this.removeModifier(e),this}addModifier(e){let n=this.getModifiers(),r=this.getModifiers().filter(e=>e.getKind()!==t.SyntaxKind.Decorator),i=r.find(t=>t.getText()===e);if(i!=null)return i;let a=c(this),o,s;return r.length===0||a===r[0].getStart()?(s=e+` `,o=a):(s=` `+e,o=a+1),kt({parent:n.length===0?this:n[0].getParentSyntaxListOrThrow(),insertPos:a,newText:s}),this.getModifiers().find(e=>e.getStart()===o);function c(n){let i=a();for(let t of Gi(e))for(let e=0;e<r.length;e++){let n=r[e];if(n.getText()===t){i<n.getEnd()&&(i=n.getEnd());break}}return i;function a(){if(r.length>0)return r[0].getStart();if(n.getKind()===t.SyntaxKind.ArrowFunction)return n.getStart();for(let e of n._getChildrenIterator())if(!(e.getKind()===t.SyntaxKind.SyntaxList||t.ts.isJSDocCommentContainingNode(e.compilerNode)))return e.getStart();return n.getStart()}}}removeModifier(e){let t=this.getModifiers(),n=t.find(t=>t.getText()===e);return n==null?!1:(It({children:[t.length===1?n.getParentSyntaxListOrThrow():n],removeFollowingSpaces:!0}),!0)}getCompilerModifiers(){return this.compilerNode.modifiers??[]}}}function Gi(e){switch(e){case`export`:return[];case`public`:case`protected`:case`private`:return[];case`default`:return[`export`];case`const`:return[`export`];case`declare`:return[`export`,`default`];case`static`:return[`public`,`protected`,`private`];case`override`:return[`public`,`private`,`protected`,`static`];case`abstract`:return[`export`,`default`,`declare`,`public`,`private`,`protected`,`static`,`override`];case`async`:return[`export`,`default`,`declare`,`public`,`private`,`protected`,`static`,`override`,`abstract`];case`readonly`:return[`export`,`default`,`declare`,`public`,`private`,`protected`,`static`,`override`,`abstract`];case`out`:return[`const`,`in`];case`in`:return[`const`];case`accessor`:return[`public`,`private`,`protected`,`declare`,`override`,`static`,`abstract`,`readonly`];default:t.errors.throwNotImplementedForNeverValueError(e)}}function Ki(e){return class extends e{addImportDeclaration(e){return this.addImportDeclarations([e])[0]}addImportDeclarations(e){let n=this._getCompilerStatementsWithComments();return this.insertImportDeclarations(r(),e);function r(){let e=0,r=!0;for(let i=0;i<n.length;i++){let a=n[i];r&&a.kind===t.SyntaxKind.MultiLineCommentTrivia?e=i+1:(r=!1,a.kind===t.SyntaxKind.ImportDeclaration&&(e=i+1))}return e}}insertImportDeclaration(e,t){return this.insertImportDeclarations(e,[t])[0]}insertImportDeclarations(e,n){return this._insertChildren({expectedKind:t.SyntaxKind.ImportDeclaration,index:e,structures:n,write:(e,t)=>{this._standardWrite(e,t,()=>{this._context.structurePrinterFactory.forImportDeclaration().printTexts(e,n)},{previousNewLine:e=>H.isImportDeclaration(e)||D(e.compilerNode),nextNewLine:e=>H.isImportDeclaration(e)})}})}getImportDeclaration(e){return this.getImportDeclarations().find(t());function t(){return typeof e==`string`?t=>t.getModuleSpecifierValue()===e:e}}getImportDeclarationOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getImportDeclaration(e),n??`Expected to find an import with the provided condition.`,this)}getImportDeclarations(){return this.getStatements().filter(H.isImportDeclaration)}addExportDeclaration(e){return this.addExportDeclarations([e])[0]}addExportDeclarations(e){return this.insertExportDeclarations(this.getChildSyntaxListOrThrow().getChildCount(),e)}insertExportDeclaration(e,t){return this.insertExportDeclarations(e,[t])[0]}insertExportDeclarations(e,n){return this._insertChildren({expectedKind:t.SyntaxKind.ExportDeclaration,index:e,structures:n,write:(e,t)=>{this._standardWrite(e,t,()=>{this._context.structurePrinterFactory.forExportDeclaration().printTexts(e,n)},{previousNewLine:e=>H.isExportDeclaration(e)||D(e.compilerNode),nextNewLine:e=>H.isExportDeclaration(e)})}})}getExportDeclaration(e){return this.getExportDeclarations().find(t());function t(){return typeof e==`string`?t=>t.getModuleSpecifierValue()===e:e}}getExportDeclarationOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getExportDeclaration(e),n??`Expected to find an export declaration with the provided condition.`,this)}getExportDeclarations(){return this.getStatements().filter(H.isExportDeclaration)}addExportAssignment(e){return this.addExportAssignments([e])[0]}addExportAssignments(e){return this.insertExportAssignments(this.getChildSyntaxListOrThrow().getChildCount(),e)}insertExportAssignment(e,t){return this.insertExportAssignments(e,[t])[0]}insertExportAssignments(e,n){return this._insertChildren({expectedKind:t.SyntaxKind.ExportAssignment,index:e,structures:n,write:(e,t)=>{this._standardWrite(e,t,()=>{this._context.structurePrinterFactory.forExportAssignment().printTexts(e,n)},{previousNewLine:e=>H.isExportAssignment(e)||D(e.compilerNode),nextNewLine:e=>H.isExportAssignment(e)})}})}getExportAssignment(e){return this.getExportAssignments().find(e)}getExportAssignmentOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getExportAssignment(e),n??`Expected to find an export assignment with the provided condition.`,this)}getExportAssignments(){return this.getStatements().filter(H.isExportAssignment)}getDefaultExportSymbol(){let e=this.getSymbol();if(e!=null)return e.getExport(`default`)}getDefaultExportSymbolOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getDefaultExportSymbol(),e??`Expected to find a default export symbol`)}getExportSymbols(){let e=this.getSymbol();return e==null?[]:this._context.typeChecker.getExportsOfModule(e)}getExportedDeclarations(){let e=new Map,n=this.getExportSymbols();for(let t of n)for(let n of t.getDeclarations()){let i=Array.from(r(n)),a=t.getName(),o=e.get(a);o==null?e.set(t.getName(),i):o.push(...i)}return e;function*r(e){if(H.isExportSpecifier(e))for(let t of e.getLocalTargetDeclarations())yield*r(t);else if(H.isExportAssignment(e)){let r=e.getExpression();if(r==null||r.getKind()!==t.SyntaxKind.Identifier){yield r;return}yield*n(r.getSymbol())}else if(H.isImportSpecifier(e)){let t=e.getNameNode().getSymbol();if(t==null)return;yield*n(t.getAliasedSymbol()||t)}else if(H.isImportClause(e)){let t=e.getDefaultImport();if(t==null)return;let r=t.getSymbol();if(r==null)return;yield*n(r.getAliasedSymbol()||r)}else if(H.isNamespaceImport(e)||H.isNamespaceExport(e)){let t=e.getNameNode().getSymbol();if(t==null)return;yield*n(t.getAliasedSymbol()||t)}else yield e;function*n(e){if(e!=null)for(let t of e.getDeclarations())yield*r(t)}}}removeDefaultExport(e){if(e||=this.getDefaultExportSymbol(),e==null)return this;let n=e.getDeclarations()[0];return n.compilerNode.kind===t.SyntaxKind.ExportAssignment?Rt({children:[n],getSiblingFormatting:()=>_e.Newline}):H.isModifierable(n)&&(n.toggleModifier(`default`,!1),n.toggleModifier(`export`,!1)),this}}}function qi(e){return class extends e{getNameNode(){return this._getNodeFromCompilerNode(this.compilerNode.name)}getName(){return this.getNameNode().getText()}set(t){return he(e.prototype,this,t),t.name!=null&&this.getNameNode().replaceWithText(t.name),this}getStructure(){return me(e.prototype,this,{name:this.getName()})}}}function Ji(e){return class extends e{findReferences(){return this._context.languageService.findReferences(Yi(this))}findReferencesAsNodes(){return this._context.languageService.findReferencesAsNodes(Yi(this))}}}function Yi(e){return H.isIdentifier(e)||H.isStringLiteral(e)?e:e.getNodeProperty(`name`)??(H.isExportable(e)&&e.getDefaultKeyword()||e)}function Xi(e){return class extends e{rename(e,n){return yn(r(this),e,n),this;function r(e){if(H.isIdentifier(e)||H.isPrivateIdentifier(e)||H.isStringLiteral(e))return e;if(e.getNameNode!=null){let n=e.getNameNode();if(t.errors.throwIfNullOrUndefined(n,`Expected to find a name node when renaming.`),H.isArrayBindingPattern(n)||H.isObjectBindingPattern(n))throw new t.errors.NotImplementedError(`Not implemented renameable scenario for ${n.getKindName()}.`);return n}else throw new t.errors.NotImplementedError(`Not implemented renameable scenario for ${e.getKindName()}`)}}}}function Zi(e){return qi(Ji(Xi(e)))}function Qi(e){return qi(Ji(Xi(e)))}function $i(e){return qi(Ji(Xi(e)))}function ea(e){return ta(Ji(Xi(e)))}function ta(e){return class extends e{getNameNode(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.name)}getNameNodeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getNameNode(),e??`Expected to have a name node.`,this)}getName(){return this.getNameNode()?.getText()??void 0}getNameOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getName(),e??`Expected to have a name.`,this)}rename(n){return n===this.getName()?this:t.StringUtils.isNullOrWhitespace(n)?(this.removeName(),this):(this.getNameNode()==null?na(this,n):e.prototype.rename.call(this,n),this)}removeName(){let e=this.getNameNode();return e==null||It({children:[e],removePrecedingSpaces:!0}),this}set(n){if(he(e.prototype,this,n),n.name!=null){t.errors.throwIfWhitespaceOrNotString(n.name,`structure.name`);let e=this.getNameNode();e==null?na(this,n.name):e.replaceWithText(n.name)}else n.hasOwnProperty(t.nameof(n,`name`))&&this.removeName();return this}getStructure(){return me(e.prototype,this,{name:this.getName()})}}}function na(e,n){H.isClassDeclaration(e)||H.isClassExpression(e)?kt({insertPos:e.getFirstChildByKindOrThrow(t.SyntaxKind.ClassKeyword).getEnd(),newText:` `+n,parent:e}):kt({insertPos:e.getFirstChildByKindOrThrow(t.SyntaxKind.OpenParenToken).getStart(),newText:` `+n,parent:e})}function ra(e){return qi(Xi(Ji(e)))}function ia(e){return qi(Ji(Xi(e)))}function aa(e){return class extends e{hasOverrideKeyword(){return this.hasModifier(t.SyntaxKind.OverrideKeyword)}getOverrideKeyword(){return this.getFirstModifierByKind(t.SyntaxKind.OverrideKeyword)}getOverrideKeywordOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getOverrideKeyword(),e??`Expected to find an override keyword.`,this)}setHasOverrideKeyword(e){return this.toggleModifier(`override`,e),this}set(t){return he(e.prototype,this,t),t.hasOverrideKeyword!=null&&this.setHasOverrideKeyword(t.hasOverrideKeyword),this}getStructure(){return me(e.prototype,this,{hasOverrideKeyword:this.hasOverrideKeyword()})}}}function oa(e){return class extends e{getParameter(e){return s(this.getParameters(),e)}getParameterOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getParameter(e),()=>l(`parameter`,e))}getParameters(){return this.compilerNode.parameters.map(e=>this._getNodeFromCompilerNode(e))}addParameter(e){return this.addParameters([e])[0]}addParameters(e){return this.insertParameters(Ae(this.compilerNode.parameters),e)}insertParameter(e,t){return this.insertParameters(e,[t])[0]}insertParameters(e,n){if(t.ArrayUtils.isNullOrEmpty(n))return[];let r=this.getParameters(),i=this.getFirstChildByKindOrThrow(t.SyntaxKind.OpenParenToken).getNextSiblingIfKindOrThrow(t.SyntaxKind.SyntaxList);e=et(e,r.length);let a=this._getWriterWithQueuedChildIndentation();return this._context.structurePrinterFactory.forParameterDeclaration().printTexts(a,n),jt({parent:i,currentNodes:r,insertIndex:e,newText:a.toString(),useTrailingCommas:!1}),Ye(r,this.getParameters(),e,!1)}set(t){return he(e.prototype,this,t),t.parameters!=null&&(this.getParameters().forEach(e=>e.remove()),this.addParameters(t.parameters)),this}getStructure(){return me(e.prototype,this,{parameters:this.getParameters().map(e=>e.getStructure())})}}}function sa(e){return class extends e{hasQuestionDotToken(){return this.compilerNode.questionDotToken!=null}getQuestionDotTokenNode(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.questionDotToken)}getQuestionDotTokenNodeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getQuestionDotTokenNode(),e??`Expected to find a question dot token.`,this)}setHasQuestionDotToken(e){let n=this.getQuestionDotTokenNode();if(e===(n!=null))return this;return e?H.isPropertyAccessExpression(this)?this.getFirstChildByKindOrThrow(t.SyntaxKind.DotToken).replaceWithText(`?.`):kt({insertPos:r.call(this),parent:this,newText:`?.`}):H.isPropertyAccessExpression(this)?n.replaceWithText(`.`):It({children:[n]}),this;function r(){if(H.isCallExpression(this))return this.getFirstChildByKindOrThrow(t.SyntaxKind.OpenParenToken).getStart();if(H.isElementAccessExpression(this))return this.getFirstChildByKindOrThrow(t.SyntaxKind.OpenBracketToken).getStart();t.errors.throwNotImplementedForSyntaxKindError(this.compilerNode.kind)}}set(t){return he(e.prototype,this,t),t.hasQuestionDotToken!=null&&this.setHasQuestionDotToken(t.hasQuestionDotToken),this}getStructure(){return me(e.prototype,this,{hasQuestionDotToken:this.hasQuestionDotToken()})}}}function ca(e){return class extends e{hasQuestionToken(){return this.compilerNode.questionToken!=null}getQuestionTokenNode(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.questionToken)}getQuestionTokenNodeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getQuestionTokenNode(),e??`Expected to find a question token.`,this)}setHasQuestionToken(e){let n=this.getQuestionTokenNode();if(e===(n!=null))return this;return e?(H.isExclamationTokenable(this)&&this.setHasExclamationToken(!1),kt({insertPos:r.call(this),parent:this,newText:`?`})):It({children:[n]}),this;function r(){if(H.hasName(this))return this.getNameNode().getEnd();let e=this.getFirstChildByKind(t.SyntaxKind.ColonToken);if(e!=null)return e.getStart();let n=this.getLastChildByKind(t.SyntaxKind.SemicolonToken);return n==null?this.getEnd():n.getStart()}}set(t){return he(e.prototype,this,t),t.hasQuestionToken!=null&&this.setHasQuestionToken(t.hasQuestionToken),this}getStructure(){return me(e.prototype,this,{hasQuestionToken:this.hasQuestionToken()})}}}function la(e){return class extends e{isReadonly(){return this.getReadonlyKeyword()!=null}getReadonlyKeyword(){return this.getFirstModifierByKind(t.SyntaxKind.ReadonlyKeyword)}getReadonlyKeywordOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getReadonlyKeyword(),e??`Expected to find a readonly keyword.`,this)}setIsReadonly(e){return this.toggleModifier(`readonly`,e),this}set(t){return he(e.prototype,this,t),t.isReadonly!=null&&this.setIsReadonly(t.isReadonly),this}getStructure(){return me(e.prototype,this,{isReadonly:this.isReadonly()})}}}function ua(e){return class extends e{getReturnType(){return this.getSignature().getReturnType()}getReturnTypeNode(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.type)}getReturnTypeNodeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getReturnTypeNode(),e??`Expected to find a return type node.`,this)}setReturnType(e){let n=I(this._getWriterWithQueuedChildIndentation(),e);if(t.StringUtils.isNullOrWhitespace(n))return this.removeReturnType();let r=this.getReturnTypeNode();if(r!=null)return r.getText()!==n&&r.replaceWithText(n),this;return kt({parent:this,insertPos:i(this).getEnd(),newText:`: ${n}`}),this;function i(e){return e.getKind()===t.SyntaxKind.IndexSignature?e.getFirstChildByKindOrThrow(t.SyntaxKind.CloseBracketToken):e.getFirstChildByKindOrThrow(t.SyntaxKind.CloseParenToken)}}removeReturnType(){let e=this.getReturnTypeNode();return e==null||It({children:[e.getPreviousSiblingIfKindOrThrow(t.SyntaxKind.ColonToken),e],removePrecedingSpaces:!0}),this}getSignature(){let e=this._context.typeChecker.getSignatureFromNode(this);if(e==null)throw new t.errors.NotImplementedError(`Expected the node to have a signature.`);return e}set(n){return he(e.prototype,this,n),n.returnType==null?n.hasOwnProperty(t.nameof(n,`returnType`))&&this.removeReturnType():this.setReturnType(n.returnType),this}getStructure(){let t=this.getReturnTypeNode();return me(e.prototype,this,{returnType:t?t.getText({trimLeadingIndentation:!0}):void 0})}}}function da(n){return class extends n{getScope(){let t=fa(this);if(t!=null)return t;if(H.isParameterDeclaration(this)&&this.isReadonly())return e.Scope.Public}setScope(e){return pa(this,e),this}getScopeKeyword(){return this.getModifiers().find(e=>{let t=e.getText();return t===`public`||t===`protected`||t===`private`})}hasScopeKeyword(){return this.getScopeKeyword()!=null}set(e){return he(n.prototype,this,e),e.hasOwnProperty(t.nameof(e,`scope`))&&this.setScope(e.scope),this}getStructure(){return me(n.prototype,this,{scope:this.getScope()})}}}function fa(n){let r=n.getCombinedModifierFlags();if((r&t.ts.ModifierFlags.Private)!==0)return e.Scope.Private;if((r&t.ts.ModifierFlags.Protected)!==0)return e.Scope.Protected;if((r&t.ts.ModifierFlags.Public)!==0)return e.Scope.Public}function pa(t,n){t.toggleModifier(`public`,n===e.Scope.Public),t.toggleModifier(`protected`,n===e.Scope.Protected),t.toggleModifier(`private`,n===e.Scope.Private)}function ma(n){return class extends n{getScope(){return fa(this)||e.Scope.Public}setScope(e){return pa(this,e),this}hasScopeKeyword(){return fa(this)!=null}set(e){return he(n.prototype,this,e),e.hasOwnProperty(t.nameof(e,`scope`))&&this.setScope(e.scope),this}getStructure(){return me(n.prototype,this,{scope:this.hasScopeKeyword()?this.getScope():void 0})}}}function ha(e){return ua(oa(e))}function ga(e){return class extends e{isStatic(){return this.hasModifier(t.SyntaxKind.StaticKeyword)}getStaticKeyword(){return this.getFirstModifierByKind(t.SyntaxKind.StaticKeyword)}getStaticKeywordOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getStaticKeyword(),e??`Expected to find a static keyword.`,this)}setIsStatic(e){return this.toggleModifier(`static`,e),this}set(t){return he(e.prototype,this,t),t.isStatic!=null&&this.setIsStatic(t.isStatic),this}getStructure(){return me(e.prototype,this,{isStatic:this.isStatic()})}}}function _a(e){return class extends e{insertText(e,t){return this.replaceText([e,e],t),this}removeText(e,t){return e==null?this.replaceText(va(this),``):this.replaceText([e,t],``),this}replaceText(e,n){let r=this.getChildSyntaxListOrThrow(),i=va(this),a=e[0],o=e[1];return s(),kt({insertPos:a,newText:I(this._getWriter(),n),parent:r.getParentOrThrow(),replacing:{textLength:o-a,nodes:[r]}}),this;function s(){if(c(a),c(o),a>o)throw new t.errors.ArgumentError(`range`,`Cannot specify a start position greater than the end position.`)}function c(e){if(!(e>=i[0]&&e<=i[1]))throw new t.errors.InvalidOperationError(`Cannot insert or replace text outside the bounds of the node. Expected a position between [${i[0]}, ${i[1]}], but received ${e}.`)}}}}function va(e){let n=a(),r=H.isSourceFile(n)?void 0:n.getPreviousSiblingIfKind(t.SyntaxKind.OpenBraceToken),i=r==null?void 0:n.getNextSiblingIfKind(t.SyntaxKind.CloseBraceToken);if(r!=null&&i!=null)return[r.getEnd(),i.getStart()];return[n.getPos(),n.getEnd()];function a(){return H.isSourceFile(e)?e:e.getChildSyntaxListOrThrow()}}function ya(e){return class extends e{getTypeArguments(){return this.compilerNode.typeArguments==null?[]:this.compilerNode.typeArguments.map(e=>this._getNodeFromCompilerNode(e))}addTypeArgument(e){return this.addTypeArguments([e])[0]}addTypeArguments(e){return this.insertTypeArguments(this.getTypeArguments().length,e)}insertTypeArgument(e,t){return this.insertTypeArguments(e,[t])[0]}insertTypeArguments(e,n){if(t.ArrayUtils.isNullOrEmpty(n))return[];let r=this.getTypeArguments();return e=et(e,r.length),r.length===0?kt({insertPos:this.getFirstChildByKindOrThrow(t.SyntaxKind.Identifier).getEnd(),parent:this,newText:`<${n.join(`, `)}>`}):jt({parent:this.getFirstChildByKindOrThrow(t.SyntaxKind.LessThanToken).getNextSiblingIfKindOrThrow(t.SyntaxKind.SyntaxList),currentNodes:r,insertIndex:e,newText:n.join(`, `),useTrailingCommas:!1}),Ye(r,this.getTypeArguments(),e,!1)}removeTypeArgument(e){let n=this.getTypeArguments();if(n.length===0)throw new t.errors.InvalidOperationError(`Cannot remove a type argument when none exist.`);let r=typeof e==`number`?i(e):e;if(n.length===1){let e=n[0].getParentSyntaxListOrThrow();It({children:[e.getPreviousSiblingIfKindOrThrow(t.SyntaxKind.LessThanToken),e,e.getNextSiblingIfKindOrThrow(t.SyntaxKind.GreaterThanToken)]})}else Ut(r);return this;function i(e){return n[et(e,n.length-1)]}}}}function ba(e){return class extends e{getTypeNode(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.type)}getTypeNodeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getTypeNode(),e??`Expected to find a type node.`,this)}setType(e){let n=I(this._getWriterWithQueuedChildIndentation(),e);if(t.StringUtils.isNullOrWhitespace(n))return this.removeType();let r=this.getTypeNode();if(r!=null&&r.getText()===n)return this;let i=xa(this),a=this.getFirstChildByKind(i),o,s;return a==null?(o=c(this),s=(i===t.SyntaxKind.EqualsToken?` = `:`: `)+n):(o=r.getStart(),s=n),kt({parent:this,insertPos:o,newText:s,replacing:{textLength:r==null?0:r.getWidth()}}),this;function c(e){let n=e.getFirstChildByKind(t.SyntaxKind.Identifier)??e.getFirstChildByKind(t.SyntaxKind.ArrayBindingPattern)??e.getFirstChildIfKindOrThrow(t.SyntaxKind.ObjectBindingPattern,`A first child of the kind Identifier, ArrayBindingPattern, or ObjectBindingPattern was expected.`),r=n.getNextSibling();return(l(r)?r:n).getEnd()}function l(e){if(e==null)return!1;let n=e.getKind();return n===t.SyntaxKind.QuestionToken||n===t.SyntaxKind.ExclamationToken}}set(n){return he(e.prototype,this,n),n.type==null?n.hasOwnProperty(t.nameof(n,`type`))&&this.removeType():this.setType(n.type),this}removeType(){if(this.getKind()===t.SyntaxKind.TypeAliasDeclaration)throw new t.errors.NotSupportedError(`Cannot remove the type of a type alias. Use ${t.nameof(`setType`)} instead.`);let e=this.getTypeNode();return e==null||It({children:[e.getPreviousSiblingIfKindOrThrow(xa(this)),e],removePrecedingSpaces:!0}),this}getStructure(){let t=this.getTypeNode();return me(e.prototype,this,{type:t?t.getText({trimLeadingIndentation:!0}):void 0})}}}function xa(e){switch(e.getKind()){case t.SyntaxKind.TypeAliasDeclaration:return t.SyntaxKind.EqualsToken;default:return t.SyntaxKind.ColonToken}}function Sa(e){return class extends e{addMember(e){return this.addMembers([e])[0]}addMembers(e){return this.insertMembers(Ae(this.getMembersWithComments()),e)}insertMember(e,t){return this.insertMembers(e,[t])[0]}insertMembers(e,t){return Pt({getIndexedChildren:()=>this.getMembersWithComments(),index:e,parent:this,write:e=>{e.newLineIfLastNot();let n=this._getWriter();this._context.structurePrinterFactory.forTypeElementMember().printTexts(n,t),e.write(n.toString()),e.newLineIfLastNot()}})}addConstructSignature(e){return this.addConstructSignatures([e])[0]}addConstructSignatures(e){return this.insertConstructSignatures(Ae(this.getMembersWithComments()),e)}insertConstructSignature(e,t){return this.insertConstructSignatures(e,[t])[0]}insertConstructSignatures(e,n){return Ca({thisNode:this,index:e,structures:n,expectedKind:t.SyntaxKind.ConstructSignature,createStructurePrinter:()=>this._context.structurePrinterFactory.forConstructSignatureDeclaration()})}getConstructSignature(e){return this.getConstructSignatures().find(e)}getConstructSignatureOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getConstructSignature(e),n??`Expected to find a construct signature with the provided condition.`,this)}getConstructSignatures(){return this.compilerNode.members.filter(e=>e.kind===t.SyntaxKind.ConstructSignature).map(e=>this._getNodeFromCompilerNode(e))}addCallSignature(e){return this.addCallSignatures([e])[0]}addCallSignatures(e){return this.insertCallSignatures(Ae(this.getMembersWithComments()),e)}insertCallSignature(e,t){return this.insertCallSignatures(e,[t])[0]}insertCallSignatures(e,n){return Ca({thisNode:this,index:e,structures:n,expectedKind:t.SyntaxKind.CallSignature,createStructurePrinter:()=>this._context.structurePrinterFactory.forCallSignatureDeclaration()})}getCallSignature(e){return this.getCallSignatures().find(e)}getCallSignatureOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getCallSignature(e),n??`Expected to find a call signature with the provided condition.`,this)}getCallSignatures(){return this.compilerNode.members.filter(e=>e.kind===t.SyntaxKind.CallSignature).map(e=>this._getNodeFromCompilerNode(e))}addIndexSignature(e){return this.addIndexSignatures([e])[0]}addIndexSignatures(e){return this.insertIndexSignatures(Ae(this.getMembersWithComments()),e)}insertIndexSignature(e,t){return this.insertIndexSignatures(e,[t])[0]}insertIndexSignatures(e,n){return Ca({thisNode:this,index:e,structures:n,expectedKind:t.SyntaxKind.IndexSignature,createStructurePrinter:()=>this._context.structurePrinterFactory.forIndexSignatureDeclaration()})}getIndexSignature(e){return this.getIndexSignatures().find(e)}getIndexSignatureOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getIndexSignature(e),n??`Expected to find a index signature with the provided condition.`,this)}getIndexSignatures(){return this.compilerNode.members.filter(e=>e.kind===t.SyntaxKind.IndexSignature).map(e=>this._getNodeFromCompilerNode(e))}addMethod(e){return this.addMethods([e])[0]}addMethods(e){return this.insertMethods(Ae(this.getMembersWithComments()),e)}insertMethod(e,t){return this.insertMethods(e,[t])[0]}insertMethods(e,n){return Ca({thisNode:this,index:e,structures:n,expectedKind:t.SyntaxKind.MethodSignature,createStructurePrinter:()=>this._context.structurePrinterFactory.forMethodSignature()})}getMethod(e){return s(this.getMethods(),e)}getMethodOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getMethod(e),()=>l(`interface method signature`,e))}getMethods(){return this.compilerNode.members.filter(e=>e.kind===t.SyntaxKind.MethodSignature).map(e=>this._getNodeFromCompilerNode(e))}addProperty(e){return this.addProperties([e])[0]}addProperties(e){return this.insertProperties(Ae(this.getMembersWithComments()),e)}insertProperty(e,t){return this.insertProperties(e,[t])[0]}insertProperties(e,n){return Ca({thisNode:this,index:e,structures:n,expectedKind:t.SyntaxKind.PropertySignature,createStructurePrinter:()=>this._context.structurePrinterFactory.forPropertySignature()})}getProperty(e){return s(this.getProperties(),e)}getPropertyOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getProperty(e),()=>l(`interface property signature`,e))}getProperties(){return this.compilerNode.members.filter(e=>e.kind===t.SyntaxKind.PropertySignature).map(e=>this._getNodeFromCompilerNode(e))}addGetAccessor(e){return this.addGetAccessors([e])[0]}addGetAccessors(e){let t=[];for(let n of e){let e=this.getSetAccessor(n.name),r=e==null?Ae(this.getMembersWithComments()):e.getChildIndex();t.push(this.insertGetAccessor(r,n))}return t}insertGetAccessor(e,t){return this.insertGetAccessors(e,[t])[0]}insertGetAccessors(e,n){return Ca({thisNode:this,index:e,structures:n,expectedKind:t.SyntaxKind.GetAccessor,createStructurePrinter:()=>this._context.structurePrinterFactory.forGetAccessorDeclaration({isAmbient:!0})})}getGetAccessor(e){return s(this.getGetAccessors(),e)}getGetAccessorOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getGetAccessor(e),()=>l(`interface get accessor`,e))}getGetAccessors(){return this.compilerNode.members.filter(e=>e.kind===t.SyntaxKind.GetAccessor).map(e=>this._getNodeFromCompilerNode(e))}addSetAccessor(e){return this.addSetAccessors([e])[0]}addSetAccessors(e){let t=[];for(let n of e){let e=this.getGetAccessor(n.name),r=e==null?Ae(this.getMembersWithComments()):e.getChildIndex()+1;t.push(this.insertSetAccessor(r,n))}return t}insertSetAccessor(e,t){return this.insertSetAccessors(e,[t])[0]}insertSetAccessors(e,n){return Ca({thisNode:this,index:e,structures:n,expectedKind:t.SyntaxKind.SetAccessor,createStructurePrinter:()=>this._context.structurePrinterFactory.forSetAccessorDeclaration({isAmbient:!0})})}getSetAccessor(e){return s(this.getSetAccessors(),e)}getSetAccessorOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getSetAccessor(e),()=>l(`interface set accessor`,e))}getSetAccessors(){return this.compilerNode.members.filter(e=>e.kind===t.SyntaxKind.SetAccessor).map(e=>this._getNodeFromCompilerNode(e))}getMembers(){return this.compilerNode.members.map(e=>this._getNodeFromCompilerNode(e))}getMembersWithComments(){let e=this.compilerNode;return T.getContainerArray(e,this._sourceFile.compilerNode).map(e=>this._getNodeFromCompilerNode(e))}set(t){return he(e.prototype,this,t),t.callSignatures!=null&&(this.getCallSignatures().forEach(e=>e.remove()),this.addCallSignatures(t.callSignatures)),t.constructSignatures!=null&&(this.getConstructSignatures().forEach(e=>e.remove()),this.addConstructSignatures(t.constructSignatures)),t.indexSignatures!=null&&(this.getIndexSignatures().forEach(e=>e.remove()),this.addIndexSignatures(t.indexSignatures)),t.properties!=null&&(this.getProperties().forEach(e=>e.remove()),this.addProperties(t.properties)),t.getAccessors!=null&&(this.getGetAccessors().forEach(e=>e.remove()),this.addGetAccessors(t.getAccessors)),t.setAccessors!=null&&(this.getSetAccessors().forEach(e=>e.remove()),this.addSetAccessors(t.setAccessors)),t.methods!=null&&(this.getMethods().forEach(e=>e.remove()),this.addMethods(t.methods)),this}getStructure(){return me(e.prototype,this,{callSignatures:this.getCallSignatures().map(e=>e.getStructure()),constructSignatures:this.getConstructSignatures().map(e=>e.getStructure()),getAccessors:this.getGetAccessors().map(e=>e.getStructure()),indexSignatures:this.getIndexSignatures().map(e=>e.getStructure()),methods:this.getMethods().map(e=>e.getStructure()),properties:this.getProperties().map(e=>e.getStructure()),setAccessors:this.getSetAccessors().map(e=>e.getStructure())})}}}function Ca(e){return Nt({getIndexedChildren:()=>e.thisNode.getMembersWithComments(),parent:e.thisNode,index:e.index,structures:e.structures,expectedKind:e.expectedKind,write:(t,n)=>{t.newLineIfLastNot(),e.createStructurePrinter().printTexts(t,e.structures),t.newLineIfLastNot()}})}function wa(e){return class extends e{getTypeParameter(e){return s(this.getTypeParameters(),e)}getTypeParameterOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getTypeParameter(e),()=>l(`type parameter`,e))}getTypeParameters(){let e=this.compilerNode.typeParameters;return e==null?[]:e.map(e=>this._getNodeFromCompilerNode(e))}addTypeParameter(e){return this.addTypeParameters([e])[0]}addTypeParameters(e){return this.insertTypeParameters(Ae(this.compilerNode.typeParameters),e)}insertTypeParameter(e,t){return this.insertTypeParameters(e,[t])[0]}insertTypeParameters(e,n){if(t.ArrayUtils.isNullOrEmpty(n))return[];let r=this.getTypeParameters(),i=this._getWriterWithQueuedChildIndentation(),a=this._context.structurePrinterFactory.forTypeParameterDeclaration();return e=et(e,r.length),a.printTexts(i,n),r.length===0?kt({insertPos:Ta(this),parent:this,newText:`<${i.toString()}>`}):jt({parent:this.getFirstChildByKindOrThrow(t.SyntaxKind.LessThanToken).getNextSiblingIfKindOrThrow(t.SyntaxKind.SyntaxList),currentNodes:r,insertIndex:e,newText:i.toString(),useTrailingCommas:!1}),Ye(r,this.getTypeParameters(),e,!1)}set(t){return he(e.prototype,this,t),t.typeParameters!=null&&(this.getTypeParameters().forEach(e=>e.remove()),this.addTypeParameters(t.typeParameters)),this}getStructure(){return me(e.prototype,this,{typeParameters:this.getTypeParameters().map(e=>e.getStructure())})}}}function Ta(e){let n=e;if(n.getNameNode!=null)return n.getNameNode().getEnd();if(H.isCallSignatureDeclaration(e)||H.isFunctionTypeNode(e))return e.getFirstChildByKindOrThrow(t.SyntaxKind.OpenParenToken).getStart();throw new t.errors.NotImplementedError(`Not implemented scenario inserting type parameters for node with kind ${e.getKindName()}.`)}function Ea(e){return class extends e{unwrap(){V(this)}}}var Da=class extends H{getElements(){return this.compilerNode.elements.map(e=>this._getNodeFromCompilerNode(e))}},Oa=(e=>On(Bi(Zi(e))))(H),ka=class extends Oa{getPropertyNameNodeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getPropertyNameNode(),e??`Expected to find a property name node.`,this)}getPropertyNameNode(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.propertyName)}},Aa=class extends H{getElements(){return this.compilerNode.elements.map(e=>this._getNodeFromCompilerNode(e))}};function ja(e){return class extends e{isAbstract(){return this.getAbstractKeyword()!=null}getAbstractKeyword(){return this.getFirstModifierByKind(t.SyntaxKind.AbstractKeyword)}getAbstractKeywordOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getAbstractKeyword(),e??`Expected to find an abstract keyword.`,this)}setIsAbstract(e){return this.toggleModifier(`abstract`,e),this}set(t){return he(e.prototype,this,t),t.isAbstract!=null&&this.setIsAbstract(t.isAbstract),this}getStructure(){return me(e.prototype,this,{isAbstract:this.isAbstract()})}}}var Ma=class extends H{getContextualType(){return this._context.typeChecker.getContextualType(this)}},Na=Ma,Pa=class extends Na{getLeft(){return this._getNodeFromCompilerNode(this.compilerNode.left)}getOperatorToken(){return this._getNodeFromCompilerNode(this.compilerNode.operatorToken)}getRight(){return this._getNodeFromCompilerNode(this.compilerNode.right)}},Fa=Pa,Ia=class extends Fa{getOperatorToken(){return this._getNodeFromCompilerNode(this.compilerNode.operatorToken)}},La=Ia,Ra=class extends La{getLeft(){return this._getNodeFromCompilerNode(this.compilerNode.left)}},za=class extends Ma{},Ba=class extends za{},G=class extends Ba{},Va=class extends G{},Ha=class extends Va{},Ua=class extends Ha{getElements(){return this.compilerNode.elements.map(e=>this._getNodeFromCompilerNode(e))}addElement(e,t){return this.addElements([e],t)[0]}addElements(e,t){return this.insertElements(this.compilerNode.elements.length,e,t)}insertElement(e,t,n){return this.insertElements(e,[t],n)[0]}insertElements(e,n,r={}){let i=this.getElements();e=et(e,i.length);let a=l(this),o=a?this._getWriterWithChildIndentation():this._getWriterWithQueuedChildIndentation(),s=new Jr;return(a?new Hn(s):new Bn(s)).printText(o,n),c(this);function c(n){return jt({parent:n.getFirstChildByKindOrThrow(t.SyntaxKind.SyntaxList),currentNodes:i,insertIndex:e,newText:o.toString(),useNewLines:a,useTrailingCommas:a&&n._context.manipulationSettings.getUseTrailingCommas()}),Ye(i,n.getElements(),e,!1)}function l(e){if(r.useNewLines!=null)return r.useNewLines;if(i.length>1)return t();return e.getStartLineNumber()!==e.getEndLineNumber();function t(){let e=i[0].getStartLineNumber();for(let t=1;t<i.length;t++){let n=i[t].getStartLineNumber();if(e===n)return!1;e=n}return!0}}}removeElement(e){let n=this.getElements();if(n.length===0)throw new t.errors.InvalidOperationError(`Cannot remove an element when none exist.`);Ut(typeof e==`number`?r(e):e);function r(e){return n[et(e,n.length-1)]}}};function Wa(e){return class extends e{getExpression(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.expression)}getExpressionOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getExpression(),e??`Expected to find an expression.`,this)}getExpressionIfKind(e){let t=this.getExpression();return t?.getKind()===e?t:void 0}getExpressionIfKindOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getExpressionIfKind(e),n??`An expression with the kind kind ${t.getSyntaxKindName(e)} was expected.`,this)}}}function Ga(e){return class extends e{getExpression(){return this._getNodeFromCompilerNode(this.compilerNode.expression)}getExpressionIfKind(e){let{expression:t}=this.compilerNode;return t.kind===e?this._getNodeFromCompilerNode(t):void 0}getExpressionIfKindOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getExpressionIfKind(e),n??`An expression of the kind ${t.getSyntaxKindName(e)} was expected.`,this)}setExpression(e){return this.getExpression().replaceWithText(e,this._getWriterWithQueuedChildIndentation()),this}set(t){return he(e.prototype,this,t),t.expression!=null&&this.setExpression(t.expression),this}}}function Ka(e){return Ga(e)}function qa(e){return Ga(e)}function Ja(e){return Ga(e)}function Ya(e){return Ga(e)}function Xa(e){return Ga(e)}var Za=(e=>ba(Ka(e)))(Ma),Qa=class extends Za{},$a=Xa(za),eo=class extends $a{},to=(e=>ya(an(sa(Ja(e)))))(G),no=class extends to{getReturnType(){return this._context.typeChecker.getTypeAtLocation(this)}},ro=Ma,io=class extends ro{getElements(){return this.compilerNode.elements.map(e=>this._getNodeFromCompilerNode(e))}},ao=Ma,oo=class extends ao{getCondition(){return this._getNodeFromCompilerNode(this.compilerNode.condition)}getQuestionToken(){return this._getNodeFromCompilerNode(this.compilerNode.questionToken)}getWhenTrue(){return this._getNodeFromCompilerNode(this.compilerNode.whenTrue)}getColonToken(){return this._getNodeFromCompilerNode(this.compilerNode.colonToken)}getWhenFalse(){return this._getNodeFromCompilerNode(this.compilerNode.whenFalse)}},so=Xa(za),co=class extends so{},lo=(e=>sa(Ja(e)))(Va),uo=class extends lo{getArgumentExpression(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.argumentExpression)}getArgumentExpressionOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getArgumentExpression(),e??`Expected to find an argument expression.`,this)}},fo=Ha,po=class extends fo{},mo=Ui(Ha),ho=class extends mo{},go=ra(Ha),_o=class extends go{getKeywordToken(){return this.compilerNode.keywordToken}},vo=(e=>ya(an(Ja(e))))(Ha),yo=class extends vo{},bo=Ka(G),xo=class extends bo{},So=class extends H{remove(){Ut(this)}},Co=class extends So{},wo=Ia,To=class extends wo{getLeft(){return this._getNodeFromCompilerNode(this.compilerNode.left)}},Eo=Ha,Do=class extends Eo{getPropertyOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getProperty(e),()=>l(`property`,e))}getProperty(e){let n;return n=typeof e==`string`?n=>n[t.nameof(`getName`)]==null?!1:n.getName()===e:e,this.getProperties().find(n)}getProperties(){return this.compilerNode.properties.map(e=>this._getNodeFromCompilerNode(e))}getPropertiesWithComments(){return T.getContainerArray(this.compilerNode,this.getSourceFile().compilerNode).map(e=>this._getNodeFromCompilerNode(e))}#e(){return T.getContainerArray(this.compilerNode,this.getSourceFile().compilerNode).length}addProperty(e){return this.insertProperties(this.#e(),[e])[0]}addProperties(e){return this.insertProperties(this.#e(),e)}insertProperty(e,t){return this.insertProperties(e,[t])[0]}insertProperties(e,t){let n=this.getPropertiesWithComments();e=et(e,n.length);let r=this._getWriterWithChildIndentation();return this._context.structurePrinterFactory.forObjectLiteralExpressionProperty().printTexts(r,t),jt({parent:this.getChildSyntaxListOrThrow(),currentNodes:n,insertIndex:e,newText:r.toString(),useNewLines:!0,useTrailingCommas:this._context.manipulationSettings.getUseTrailingCommas()}),Ye(n,this.getPropertiesWithComments(),e,!0)}addPropertyAssignment(e){return this.addPropertyAssignments([e])[0]}addPropertyAssignments(e){return this.insertPropertyAssignments(this.#e(),e)}insertPropertyAssignment(e,t){return this.insertPropertyAssignments(e,[t])[0]}insertPropertyAssignments(e,t){return this.#t(e,t,()=>this._context.structurePrinterFactory.forPropertyAssignment())}addShorthandPropertyAssignment(e){return this.addShorthandPropertyAssignments([e])[0]}addShorthandPropertyAssignments(e){return this.insertShorthandPropertyAssignments(this.#e(),e)}insertShorthandPropertyAssignment(e,t){return this.insertShorthandPropertyAssignments(e,[t])[0]}insertShorthandPropertyAssignments(e,t){return this.#t(e,t,()=>this._context.structurePrinterFactory.forShorthandPropertyAssignment())}addSpreadAssignment(e){return this.addSpreadAssignments([e])[0]}addSpreadAssignments(e){return this.insertSpreadAssignments(this.#e(),e)}insertSpreadAssignment(e,t){return this.insertSpreadAssignments(e,[t])[0]}insertSpreadAssignments(e,t){return this.#t(e,t,()=>this._context.structurePrinterFactory.forSpreadAssignment())}addMethod(e){return this.addMethods([e])[0]}addMethods(e){return this.insertMethods(this.#e(),e)}insertMethod(e,t){return this.insertMethods(e,[t])[0]}insertMethods(e,t){return this.#t(e,t,()=>this._context.structurePrinterFactory.forMethodDeclaration({isAmbient:!1}))}addGetAccessor(e){return this.addGetAccessors([e])[0]}addGetAccessors(e){return this.insertGetAccessors(this.#e(),e)}insertGetAccessor(e,t){return this.insertGetAccessors(e,[t])[0]}insertGetAccessors(e,t){return this.#t(e,t,()=>this._context.structurePrinterFactory.forGetAccessorDeclaration({isAmbient:!1}))}addSetAccessor(e){return this.addSetAccessors([e])[0]}addSetAccessors(e){return this.insertSetAccessors(this.#e(),e)}insertSetAccessor(e,t){return this.insertSetAccessors(e,[t])[0]}insertSetAccessors(e,t){return this.#t(e,t,()=>this._context.structurePrinterFactory.forSetAccessorDeclaration({isAmbient:!1}))}#t(e,n,r){e=et(e,this.#e());let i=this._getWriterWithChildIndentation(),a=new Hn(r()),o=this.getPropertiesWithComments();return a.printText(i,n),jt({parent:this.getFirstChildByKindOrThrow(t.SyntaxKind.SyntaxList),currentNodes:o,insertIndex:e,newText:i.toString(),useNewLines:!0,useTrailingCommas:this._context.manipulationSettings.getUseTrailingCommas()}),Ye(o,this.getPropertiesWithComments(),e,!1)}},Oo=(e=>zi(ca(ia(e))))(So),ko=class extends Oo{removeInitializer(){let e=this.getInitializerOrThrow(),n=e.getPreviousSiblingIfKindOrThrow(t.SyntaxKind.ColonToken),r=this.getChildIndex(),i=this._sourceFile.getFullText(),a=this.getStart(),o=i.substring(a,n.getPos())+i.substring(e.getEnd(),this.getEnd()),s=this.getParentSyntaxList()||this.getParentOrThrow();return kt({insertPos:a,newText:o,parent:s,replacing:{textLength:this.getWidth()}}),s.getChildAtIndexIfKindOrThrow(r,t.SyntaxKind.ShorthandPropertyAssignment)}setInitializer(e){let t=this.getInitializerOrThrow();return kt({insertPos:t.getStart(),newText:I(this._getWriterWithQueuedChildIndentation(),e),parent:this,replacing:{textLength:t.getWidth()}}),this}set(e){if(he(Oo.prototype,this,e),e.initializer!=null)this.setInitializer(e.initializer);else if(e.hasOwnProperty(t.nameof(e,`initializer`)))return this.removeInitializer();return this}getStructure(){let t=this.getInitializerOrThrow(),n=me(Oo.prototype,this,{kind:e.StructureKind.PropertyAssignment,initializer:t.getText()});return delete n.hasQuestionToken,n}},Ao=(e=>zi(ca(ra(e))))(So),jo=class extends Ao{hasObjectAssignmentInitializer(){return this.compilerNode.objectAssignmentInitializer!=null}getObjectAssignmentInitializerOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getObjectAssignmentInitializer(),e??`Expected to find an object assignment initializer.`,this)}getObjectAssignmentInitializer(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.objectAssignmentInitializer)}getEqualsTokenOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getEqualsToken(),e??`Expected to find an equals token.`,this)}getEqualsToken(){let e=this.compilerNode.equalsToken;if(e!=null)return this._getNodeFromCompilerNode(e)}removeObjectAssignmentInitializer(){return this.hasObjectAssignmentInitializer()&&It({children:[this.getEqualsTokenOrThrow(),this.getObjectAssignmentInitializerOrThrow()],removePrecedingSpaces:!0}),this}setInitializer(e){let n=this.getParentSyntaxList()||this.getParentOrThrow(),r=this.getChildIndex();return kt({insertPos:this.getStart(),newText:this.getText()+`: ${e}`,parent:n,replacing:{textLength:this.getWidth()}}),n.getChildAtIndexIfKindOrThrow(r,t.SyntaxKind.PropertyAssignment)}set(e){return he(Ao.prototype,this,e),this}getStructure(){let t=me(Ao.prototype,this,{kind:e.StructureKind.ShorthandPropertyAssignment});return delete t.hasQuestionToken,t}getValueSymbol(){return this._context.typeChecker.getShorthandAssignmentValueSymbol(this)}getValueSymbolOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getValueSymbol(),e??`Expected to find a value symbol.`,this)}},Mo=Ka(So),No=class extends Mo{set(e){return he(Mo.prototype,this,e),this}getStructure(){return me(Mo.prototype,this,{kind:e.StructureKind.SpreadAssignment,expression:this.getExpression().getText()})}},Po=Ma,Fo=class extends Po{},K=Ka(Ma),q=class extends K{},Io=Ka(Ma),Lo=class extends Io{},Ro=za,zo=class extends Ro{getOperatorToken(){return this.compilerNode.operator}getOperand(){return this._getNodeFromCompilerNode(this.compilerNode.operand)}},Bo=za,Vo=class extends Bo{getOperatorToken(){return this.compilerNode.operator}getOperand(){return this._getNodeFromCompilerNode(this.compilerNode.operand)}},Ho=(e=>ra(sa(Ja(e))))(Va),Uo=class extends Ho{},Wo=(e=>ba(Ka(e)))(Ma),Go=class extends Wo{},Ko=Ka(Ma),qo=class extends Ko{},Jo=Ya(uo),Yo=class extends Jo{},Xo=Ha,Zo=class extends Xo{},Qo=Ya(Uo),$o=class extends Qo{},es=Ha,ts=class extends es{},ns=(e=>ba(Xa(e)))(za),rs=class extends ns{},is=Xa(za),as=class extends is{},os=Xa(za),ss=class extends os{},cs=Wa(Fi(Ma)),ls=class extends cs{},us=Cn(H),ds=class extends us{remove(){Gt(this)}};function fs(e){return class extends e{getStatements(){return(this._getCompilerStatementsContainer()?.statements??[]).map(e=>this._getNodeFromCompilerNode(e))}getStatementsWithComments(){return this._getCompilerStatementsWithComments().map(e=>this._getNodeFromCompilerNode(e))}getStatement(e){return this.getStatements().find(e)}getStatementOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getStatement(e),n??`Expected to find a statement matching the provided condition.`,this)}getStatementByKind(e){let t=this._getCompilerStatementsWithComments().find(t=>t.kind===e);return this._getNodeFromCompilerNodeIfExists(t)}getStatementByKindOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getStatementByKind(e),n??`Expected to find a statement with syntax kind ${t.getSyntaxKindName(e)}.`,this)}addStatements(e){return this.insertStatements(this._getCompilerStatementsWithComments().length,e)}insertStatements(e,n){return ps(this),r.call(this).insertChildText(e,e=>{this._context.structurePrinterFactory.forStatement({isAmbient:k(this)}).printTexts(e,n)});function r(){let e=this.getChildSyntaxListOrThrow();if(H.isCaseClause(this)||H.isDefaultClause(this)){let n=e.getFirstChildIfKind(t.SyntaxKind.Block);if(n!=null)return n.getChildSyntaxListOrThrow()}return e}}removeStatement(e){return e=et(e,this._getCompilerStatementsWithComments().length-1),this.removeStatements([e,e])}removeStatements(e){let n=this.getStatementsWithComments();return t.errors.throwIfRangeOutOfRange(e,[0,n.length],`indexRange`),Kt(n.slice(e[0],e[1]+1)),this}addClass(e){return this.addClasses([e])[0]}addClasses(e){return this.insertClasses(this._getCompilerStatementsWithComments().length,e)}insertClass(e,t){return this.insertClasses(e,[t])[0]}insertClasses(e,n){return this._insertChildren({expectedKind:t.SyntaxKind.ClassDeclaration,index:e,structures:n,write:(e,t)=>{this._standardWrite(e,t,()=>{this._context.structurePrinterFactory.forClassDeclaration({isAmbient:k(this)}).printTexts(e,n)})}})}getClasses(){return this.getStatements().filter(H.isClassDeclaration)}getClass(e){return s(this.getClasses(),e)}getClassOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getClass(e),()=>l(`class`,e))}addEnum(e){return this.addEnums([e])[0]}addEnums(e){return this.insertEnums(this._getCompilerStatementsWithComments().length,e)}insertEnum(e,t){return this.insertEnums(e,[t])[0]}insertEnums(e,n){return this._insertChildren({expectedKind:t.SyntaxKind.EnumDeclaration,index:e,structures:n,write:(e,t)=>{this._standardWrite(e,t,()=>{this._context.structurePrinterFactory.forEnumDeclaration().printTexts(e,n)})}})}getEnums(){return this.getStatements().filter(H.isEnumDeclaration)}getEnum(e){return s(this.getEnums(),e)}getEnumOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getEnum(e),()=>l(`enum`,e))}addFunction(e){return this.addFunctions([e])[0]}addFunctions(e){return this.insertFunctions(this._getCompilerStatementsWithComments().length,e)}insertFunction(e,t){return this.insertFunctions(e,[t])[0]}insertFunctions(e,n){return this._insertChildren({expectedKind:t.SyntaxKind.FunctionDeclaration,index:e,structures:n,write:(e,t)=>{this._standardWrite(e,t,()=>{this._context.structurePrinterFactory.forFunctionDeclaration({isAmbient:k(this)}).printTexts(e,n)},{previousNewLine:e=>n[0].hasDeclareKeyword===!0&&H.isFunctionDeclaration(e)&&e.getBody()==null,nextNewLine:e=>n[n.length-1].hasDeclareKeyword===!0&&H.isFunctionDeclaration(e)&&e.getBody()==null})}})}getFunctions(){return this.getStatements().filter(H.isFunctionDeclaration).filter(e=>e.isAmbient()||e.isImplementation())}getFunction(e){return s(this.getFunctions(),e)}getFunctionOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getFunction(e),()=>l(`function`,e))}addInterface(e){return this.addInterfaces([e])[0]}addInterfaces(e){return this.insertInterfaces(this._getCompilerStatementsWithComments().length,e)}insertInterface(e,t){return this.insertInterfaces(e,[t])[0]}insertInterfaces(e,n){return this._insertChildren({expectedKind:t.SyntaxKind.InterfaceDeclaration,index:e,structures:n,write:(e,t)=>{this._standardWrite(e,t,()=>{this._context.structurePrinterFactory.forInterfaceDeclaration().printTexts(e,n)})}})}getInterfaces(){return this.getStatements().filter(H.isInterfaceDeclaration)}getInterface(e){return s(this.getInterfaces(),e)}getInterfaceOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getInterface(e),()=>l(`interface`,e))}addModule(e){return this.addModules([e])[0]}addModules(e){return this.insertModules(this._getCompilerStatementsWithComments().length,e)}insertModule(e,t){return this.insertModules(e,[t])[0]}insertModules(e,n){return this._insertChildren({expectedKind:t.SyntaxKind.ModuleDeclaration,index:e,structures:n,write:(e,t)=>{this._standardWrite(e,t,()=>{this._context.structurePrinterFactory.forModuleDeclaration({isAmbient:k(this)}).printTexts(e,n)})}})}getModules(){return this.getStatements().filter(H.isModuleDeclaration)}getModule(e){return s(this.getModules(),e)}getModuleOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getModule(e),()=>l(`module`,e))}addTypeAlias(e){return this.addTypeAliases([e])[0]}addTypeAliases(e){return this.insertTypeAliases(this._getCompilerStatementsWithComments().length,e)}insertTypeAlias(e,t){return this.insertTypeAliases(e,[t])[0]}insertTypeAliases(e,n){return this._insertChildren({expectedKind:t.SyntaxKind.TypeAliasDeclaration,index:e,structures:n,write:(e,t)=>{this._standardWrite(e,t,()=>{this._context.structurePrinterFactory.forTypeAliasDeclaration().printTexts(e,n)},{previousNewLine:e=>H.isTypeAliasDeclaration(e),nextNewLine:e=>H.isTypeAliasDeclaration(e)})}})}getTypeAliases(){return this.getStatements().filter(H.isTypeAliasDeclaration)}getTypeAlias(e){return s(this.getTypeAliases(),e)}getTypeAliasOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getTypeAlias(e),()=>l(`type alias`,e))}getVariableStatements(){return this.getStatements().filter(H.isVariableStatement)}getVariableStatement(e){return this.getVariableStatements().find(t());function t(){return typeof e==`string`?t=>t.getDeclarations().some(t=>c(t,e)):e}}getVariableStatementOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getVariableStatement(e),n??`Expected to find a variable statement that matched the provided condition.`,this)}addVariableStatement(e){return this.addVariableStatements([e])[0]}addVariableStatements(e){return this.insertVariableStatements(this._getCompilerStatementsWithComments().length,e)}insertVariableStatement(e,t){return this.insertVariableStatements(e,[t])[0]}insertVariableStatements(e,n){return this._insertChildren({expectedKind:t.SyntaxKind.VariableStatement,index:e,structures:n,write:(e,t)=>{this._standardWrite(e,t,()=>{this._context.structurePrinterFactory.forVariableStatement().printTexts(e,n)},{previousNewLine:e=>H.isVariableStatement(e),nextNewLine:e=>H.isVariableStatement(e)})}})}getVariableDeclarations(){let e=[];for(let t of this.getVariableStatements())e.push(...t.getDeclarations());return e}getVariableDeclaration(e){return s(this.getVariableDeclarations(),e)}getVariableDeclarationOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getVariableDeclaration(e),()=>l(`variable declaration`,e))}getStructure(){let t={};return H.isBodyable(this)&&!this.hasBody()?t.statements=void 0:t.statements=this.getStatements().map(e=>H._hasStructure(e)?e.getStructure():e.getText({trimLeadingIndentation:!0})),me(e.prototype,this,t)}set(n){if(H.isBodyable(this)&&n.statements==null&&n.hasOwnProperty(t.nameof(n,`statements`)))this.removeBody();else if(n.statements!=null){let e=this._getCompilerStatementsWithComments().length;e>0&&this.removeStatements([0,e-1])}return he(e.prototype,this,n),n.statements!=null&&this.addStatements(n.statements),this}_getCompilerStatementsWithComments(){let e=this._getCompilerStatementsContainer();return e==null?[]:T.getContainerArray(e,this._sourceFile.compilerNode)}_getCompilerStatementsContainer(){if(H.isSourceFile(this)||H.isCaseClause(this)||H.isDefaultClause(this))return this.compilerNode;if(H.isModuleDeclaration(this))return this._getInnerBody()?.compilerNode;if(H.isBodyable(this)||H.isBodied(this))return this.getBody()?.compilerNode;if(H.isBlock(this)||H.isModuleBlock(this))return this.compilerNode;throw new t.errors.NotImplementedError(`Could not find the statements for node kind: ${this.getKindName()}, text: ${this.getText()}`)}_insertChildren(e){return ps(this),Nt({expectedKind:e.expectedKind,getIndexedChildren:()=>this.getStatementsWithComments(),index:e.index,parent:this,structures:e.structures,write:(t,n)=>e.write(t,n)})}_standardWrite(e,t,n,r={}){t.previousMember!=null&&(r.previousNewLine==null||!r.previousNewLine(t.previousMember))&&!H.isCommentNode(t.previousMember)?e.blankLine():t.isStartOfFile||e.newLineIfLastNot(),n(),t.nextMember!=null&&(r.nextNewLine==null||!r.nextNewLine(t.nextMember))?e.blankLine():e.newLineIfLastNot()}}}function ps(e){H.isBodyable(e)&&!e.hasBody()&&e.addBody()}var ms=(e=>_a(fs(e)))(ds),hs=class extends ms{},gs=class extends ds{getLabel(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.label)}getLabelOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getLabel(),e??`Expected to find a label.`,this)}},_s=_a(H),vs=class extends _s{getClauses(){return(this.compilerNode.clauses||[]).map(e=>this._getNodeFromCompilerNode(e))}removeClause(e){return e=et(e,this.getClauses().length-1),this.removeClauses([e,e])}removeClauses(e){let n=this.getClauses();return t.errors.throwIfRangeOutOfRange(e,[0,n.length],`indexRange`),Xt(n.slice(e[0],e[1]+1)),this}},ys=(e=>Hi(Ka(_a(fs(e)))))(H),bs=class extends ys{remove(){Jt(this)}},xs=H,Ss=class extends xs{getBlock(){return this._getNodeFromCompilerNode(this.compilerNode.block)}getVariableDeclaration(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.variableDeclaration)}getVariableDeclarationOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getVariableDeclaration(),e??`Expected to find a variable declaration.`,this)}},Cs=class extends ds{},ws=class extends ds{getLabel(){return this.compilerNode.label==null?void 0:this._getNodeFromCompilerNode(this.compilerNode.label)}getLabelOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getLabel(),e??`Expected to find a label.`,this)}},Ts=ds,Es=class extends Ts{},Ds=(e=>_a(fs(e)))(H),Os=class extends Ds{remove(){Jt(this)}},ks=class extends ds{getStatement(){return this._getNodeFromCompilerNode(this.compilerNode.statement)}},As=Ka(ks),js=class extends As{},Ms=ds,Ns=class extends Ms{},Ps=Ka(Hi(ds)),Fs=class extends Ps{},Is=Ka(ks),Ls=class extends Is{getInitializer(){return this._getNodeFromCompilerNode(this.compilerNode.initializer)}},Rs=Ka(sn(ks)),zs=class extends Rs{getInitializer(){return this._getNodeFromCompilerNode(this.compilerNode.initializer)}},Bs=ks,Vs=class extends Bs{getInitializer(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.initializer)}getInitializerOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getInitializer(),e??`Expected to find an initializer.`,this)}getCondition(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.condition)}getConditionOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getCondition(),e??`Expected to find a condition.`,this)}getIncrementor(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.incrementor)}getIncrementorOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getIncrementor(),e??`Expected to find an incrementor.`,this)}},Hs=Ka(ds),Us=class extends Hs{getThenStatement(){return this._getNodeFromCompilerNode(this.compilerNode.thenStatement)}getElseStatement(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.elseStatement)}remove(){let e=[];H.isIfStatement(this.getParentOrThrow())&&e.push(this.getPreviousSiblingIfKindOrThrow(t.SyntaxKind.ElseKeyword)),e.push(this),Kt(e)}},Ws=Hi(ds),Gs=class extends Ws{getLabel(){return this._getNodeFromCompilerNode(this.compilerNode.label)}getStatement(){return this._getNodeFromCompilerNode(this.compilerNode.statement)}},Ks=ds,qs=class extends Ks{},Js=Wa(ds),Ys=class extends Js{},Xs=Ka(ds),Zs=class extends Xs{getCaseBlock(){return this._getNodeFromCompilerNode(this.compilerNode.caseBlock)}getClauses(){return this.getCaseBlock().getClauses()}removeClause(e){return this.getCaseBlock().removeClause(e)}removeClauses(e){return this.getCaseBlock().removeClauses(e)}},Qs=Ka(ds),$s=class extends Qs{},ec=ds,tc=class extends ec{getTryBlock(){return this._getNodeFromCompilerNode(this.compilerNode.tryBlock)}getCatchClause(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.catchClause)}getCatchClauseOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getCatchClause(),e??`Expected to find a catch clause.`,this)}getFinallyBlock(){if(!(this.compilerNode.finallyBlock==null||this.compilerNode.finallyBlock.getFullWidth()===0))return this._getNodeFromCompilerNode(this.compilerNode.finallyBlock)}getFinallyBlockOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getFinallyBlock(),e??`Expected to find a finally block.`,this)}},nc=Ka(Hi(ds)),rc=class extends nc{isExportEquals(){return this.compilerNode.isExportEquals||!1}setIsExportEquals(e){return this.isExportEquals()===e||(e?this.getFirstChildByKindOrThrow(t.SyntaxKind.DefaultKeyword).replaceWithText(`=`):this.getFirstChildByKindOrThrow(t.SyntaxKind.EqualsToken).replaceWithText(`default`)),this}set(e){return he(nc.prototype,this,e),e.expression!=null&&this.setExpression(e.expression),e.isExportEquals!=null&&this.setIsExportEquals(e.isExportEquals),this}getStructure(){return me(ds.prototype,this,{kind:e.StructureKind.ExportAssignment,expression:this.getExpression().getText(),isExportEquals:this.isExportEquals()})}},ic=ds,ac=class extends ic{isTypeOnly(){return this.compilerNode.isTypeOnly}setIsTypeOnly(e){return this.isTypeOnly()===e||(e?kt({parent:this,insertPos:(this.getNodeProperty(`exportClause`)??this.getFirstChildByKindOrThrow(t.SyntaxKind.AsteriskToken)).getStart(),newText:`type `}):It({children:[this.getFirstChildByKindOrThrow(t.ts.SyntaxKind.TypeKeyword)],removeFollowingSpaces:!0})),this}getNamespaceExport(){let e=this.getNodeProperty(`exportClause`);return e!=null&&H.isNamespaceExport(e)?e:void 0}getNamespaceExportOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getNamespaceExport(),e??`Expected to find a namespace export.`,this)}setNamespaceExport(e){let n=this.getNodeProperty(`exportClause`),r=t.StringUtils.isNullOrWhitespace(e)?`*`:`* as ${e}`;return n==null?kt({insertPos:this.getFirstChildByKindOrThrow(t.SyntaxKind.AsteriskToken).getStart(),parent:this,newText:r,replacing:{textLength:1}}):H.isNamespaceExport(n)?n.getNameNode().replaceWithText(e):kt({insertPos:n.getStart(),parent:this,newText:r,replacing:{textLength:n.getWidth()}}),this}setModuleSpecifier(e){let n=typeof e==`string`?e:this._sourceFile.getRelativePathAsModuleSpecifierTo(e);if(t.StringUtils.isNullOrEmpty(n))return this.removeModuleSpecifier(),this;let r=this.getModuleSpecifier();if(r==null){let e=this.getLastChildIfKind(t.SyntaxKind.SemicolonToken),r=this._context.manipulationSettings.getQuoteKind();kt({insertPos:e==null?this.getEnd():e.getPos(),parent:this,newText:` from ${r}${n}${r}`})}else r.setLiteralValue(n);return this}getModuleSpecifier(){let e=this._getNodeFromCompilerNodeIfExists(this.compilerNode.moduleSpecifier);if(e!=null){if(!H.isStringLiteral(e))throw new t.errors.InvalidOperationError(`Expected the module specifier to be a string literal.`);return e}}getModuleSpecifierValue(){return this.getModuleSpecifier()?.getLiteralValue()}getModuleSpecifierSourceFileOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getModuleSpecifierSourceFile(),e??`A module specifier source file was expected.`,this)}getModuleSpecifierSourceFile(){let e=this.getLastChildByKind(t.SyntaxKind.StringLiteral);if(e==null)return;let n=e.getSymbol();if(n==null)return;let r=n.getDeclarations()[0];return r!=null&&H.isSourceFile(r)?r:void 0}isModuleSpecifierRelative(){let e=this.getModuleSpecifierValue();return e==null?!1:ne.isModuleSpecifierRelative(e)}removeModuleSpecifier(){let e=this.getModuleSpecifier();if(e==null)return this;if(!this.hasNamedExports())throw new t.errors.InvalidOperationError(`Cannot remove the module specifier from an export declaration that has no named exports.`);return It({children:[this.getFirstChildByKindOrThrow(t.SyntaxKind.FromKeyword),e],removePrecedingNewLines:!0,removePrecedingSpaces:!0}),this}hasModuleSpecifier(){return this.getLastChildByKind(t.SyntaxKind.StringLiteral)!=null}isNamespaceExport(){return!this.hasNamedExports()}hasNamedExports(){return this.compilerNode.exportClause?.kind===t.SyntaxKind.NamedExports}addNamedExport(e){return this.addNamedExports([e])[0]}addNamedExports(e){return this.insertNamedExports(this.getNamedExports().length,e)}insertNamedExport(e,t){return this.insertNamedExports(e,[t])[0]}insertNamedExports(e,n){if(!(n instanceof Function)&&t.ArrayUtils.isNullOrEmpty(n))return[];let r=this.getNamedExports(),i=this._getWriterWithIndentation(),a=this._context.structurePrinterFactory.forNamedImportExportSpecifier();e=et(e,r.length);let o=this.getNodeProperty(`exportClause`);return o==null?(a.printTextsWithBraces(i,n),kt({insertPos:this.getFirstChildByKindOrThrow(t.SyntaxKind.AsteriskToken).getStart(),parent:this,newText:i.toString(),replacing:{textLength:1}})):o.getKind()===t.SyntaxKind.NamespaceExport?(a.printTextsWithBraces(i,n),kt({insertPos:o.getStart(),parent:this,newText:i.toString(),replacing:{textLength:o.getWidth()}})):(a.printTexts(i,n),jt({parent:this.getFirstChildByKindOrThrow(t.SyntaxKind.NamedExports).getFirstChildByKindOrThrow(t.SyntaxKind.SyntaxList),currentNodes:r,insertIndex:e,newText:i.toString(),surroundWithSpaces:this._context.getFormatCodeSettings().insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces,useTrailingCommas:!1})),Ye(r,this.getNamedExports(),e,!1)}getNamedExports(){let e=this.compilerNode.exportClause;return e==null||t.ts.isNamespaceExport(e)?[]:e.elements.map(e=>this._getNodeFromCompilerNode(e))}toNamespaceExport(){if(!this.hasModuleSpecifier())throw new t.errors.InvalidOperationError(`Cannot change to a namespace export when no module specifier exists.`);let e=this.getNodeProperty(`exportClause`);return e==null||kt({parent:this,newText:`*`,insertPos:e.getStart(),replacing:{textLength:e.getWidth()}}),this}setAttributes(e){let t=this.getAttributes();if(t)e?t.setElements(e):t.remove();else if(e){let t=this._context.structurePrinterFactory.forImportAttribute(),n=this._context.createWriter();n.space(),t.printAttributes(n,e),kt({parent:this,newText:n.toString(),insertPos:this.getSourceFile().getFullText()[this.getEnd()-1]===`;`?this.getEnd()-1:this.getEnd()})}return this}getAttributes(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.attributes)}set(e){return he(ic.prototype,this,e),e.namedExports==null?e.hasOwnProperty(t.nameof(e,`namedExports`))&&e.moduleSpecifier==null&&this.toNamespaceExport():(oc(this),this.addNamedExports(e.namedExports)),e.moduleSpecifier==null?e.hasOwnProperty(t.nameof(e,`moduleSpecifier`))&&this.removeModuleSpecifier():this.setModuleSpecifier(e.moduleSpecifier),e.namedExports==null&&e.hasOwnProperty(t.nameof(e,`namedExports`))&&this.toNamespaceExport(),e.namespaceExport!=null&&this.setNamespaceExport(e.namespaceExport),e.isTypeOnly!=null&&this.setIsTypeOnly(e.isTypeOnly),e.hasOwnProperty(t.nameof(e,`attributes`))&&this.setAttributes(e.attributes),this}getStructure(){let t=this.getModuleSpecifier(),n=this.getAttributes();return me(ic.prototype,this,{kind:e.StructureKind.ExportDeclaration,isTypeOnly:this.isTypeOnly(),moduleSpecifier:t?.getLiteralText(),namedExports:this.getNamedExports().map(e=>e.getStructure()),namespaceExport:this.getNamespaceExport()?.getName(),attributes:n?n.getElements().map(e=>e.getStructure()):void 0})}};function oc(e){let n=e.getNodeProperty(`exportClause`),r;if(n!=null){if(e.getNamedExports().length===0)return;r=n}else r=e.getFirstChildByKindOrThrow(t.SyntaxKind.AsteriskToken);kt({parent:e,newText:`{ }`,insertPos:r.getStart(),replacing:{textLength:r.getWidth()}})}var sc=H,cc=class extends sc{setName(e){let t=this.getNameNode();return this.getName()===e||(ce(e)?t.replaceWithText(e):t.replaceWithText(`"${e.replaceAll(`"`,`\\"`)}"`)),this}getName(){let e=this.getNameNode();return e.getKind()===t.ts.SyntaxKind.StringLiteral?e.getLiteralText():e.getText()}getNameNode(){return this._getNodeFromCompilerNode(this.compilerNode.propertyName||this.compilerNode.name)}renameAlias(e){if(t.StringUtils.isNullOrWhitespace(e))return this.removeAliasWithRename(),this;let n=this.getAliasNode();return n??=(this.setAlias(this.getName()),this.getAliasNode()),n.getKind()===t.SyntaxKind.Identifier&&n.rename(e),this}setAlias(e){if(t.StringUtils.isNullOrWhitespace(e))return this.removeAlias(),this;let n=this.getAliasNode();return n==null?kt({insertPos:this.getNameNode().getEnd(),parent:this,newText:` as ${e}`}):ce(e)?n.replaceWithText(e):n.replaceWithText(`"${e.replaceAll(`"`,`\\"`)}"`),this}removeAlias(){let e=this.getAliasNode();return e==null||It({children:[this.getFirstChildByKindOrThrow(t.SyntaxKind.AsKeyword),e],removePrecedingSpaces:!0,removePrecedingNewLines:!0}),this}removeAliasWithRename(){let e=this.getAliasNode();return e==null?this:(e.getKind()===t.SyntaxKind.Identifier&&e.rename(this.getName()),this.removeAlias(),this)}getAliasNode(){if(this.compilerNode.propertyName!=null)return this._getNodeFromCompilerNode(this.compilerNode.name)}isTypeOnly(){return this.compilerNode.isTypeOnly}setIsTypeOnly(e){return this.isTypeOnly()===e||(e?kt({insertPos:this.getStart(),parent:this,newText:`type `}):It({children:[this.getFirstChildByKindOrThrow(t.ts.SyntaxKind.TypeKeyword)],removeFollowingSpaces:!0})),this}getExportDeclaration(){return this.getFirstAncestorByKindOrThrow(t.SyntaxKind.ExportDeclaration)}getLocalTargetSymbolOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getLocalTargetSymbol(),e??`The export specifier's local target symbol was expected.`,this)}getLocalTargetSymbol(){return this._context.typeChecker.getExportSpecifierLocalTargetSymbol(this)}getLocalTargetDeclarations(){return this.getLocalTargetSymbol()?.getDeclarations()??[]}remove(){let e=this.getExportDeclaration();e.getNamedExports().length>1||e.getNamespaceExport()==null?Ut(this):e.toNamespaceExport()}set(e){return he(sc.prototype,this,e),e.isTypeOnly!=null&&this.setIsTypeOnly(e.isTypeOnly),e.name!=null&&this.setName(e.name),e.alias==null?e.hasOwnProperty(t.nameof(e,`alias`))&&this.removeAlias():this.setAlias(e.alias),this}getStructure(){let t=this.getAliasNode();return me(H.prototype,this,{kind:e.StructureKind.ExportSpecifier,alias:t?t.getText():void 0,name:this.getNameNode().getText(),isTypeOnly:this.isTypeOnly()})}},lc=Wa(H),uc=class extends lc{getReferencedSourceFileOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getReferencedSourceFile(),e??`Expected to find the referenced source file.`,this)}isRelative(){let e=this.getExpression();return e==null||!H.isStringLiteral(e)?!1:ne.isModuleSpecifierRelative(e.getLiteralText())}getReferencedSourceFile(){let e=this.getExpression();if(e==null)return;let t=e.getSymbol();if(t!=null)return ne.getReferencedSourceFileFromSymbol(t)}},dc=Qi(H),fc=class extends dc{getValue(){return this._getNodeFromCompilerNode(this.compilerNode.value)}set(e){return he(dc.prototype,this,e),e.value&&this.getValue().replaceWithText(e.value),this}getStructure(){return me(dc.prototype,this,{kind:e.StructureKind.ImportAttribute,value:this.getValue().getText()})}},pc=H,mc=class extends pc{setElements(e){return this.replaceWithText(t=>{this._context.structurePrinterFactory.forImportAttribute().printAttributes(t,e)}),this}getElements(){return this.compilerNode.elements.map(e=>this._getNodeFromCompilerNode(e))}remove(){It({children:[this],removePrecedingNewLines:!0,removePrecedingSpaces:!0})}},hc=H,gc=class extends hc{isTypeOnly(){return this.compilerNode.isTypeOnly}setIsTypeOnly(e){return this.isTypeOnly()===e||(e?kt({parent:this,insertPos:this.getStart(),newText:`type `}):It({children:[this.getFirstChildByKindOrThrow(t.ts.SyntaxKind.TypeKeyword)],removeFollowingSpaces:!0})),this}getDefaultImportOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getDefaultImport(),e??`Expected to find a default import.`,this)}getDefaultImport(){return this.getNodeProperty(`name`)}getNamedBindingsOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getNamedBindings(),e??`Expected to find an import declaration's named bindings.`,this)}getNamedBindings(){return this.getNodeProperty(`namedBindings`)}getNamespaceImportOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getNamespaceImport(),e??`Expected to find a namespace import.`,this)}getNamespaceImport(){let e=this.getNamedBindings();if(!(e==null||!H.isNamespaceImport(e)))return e.getNameNode()}getNamedImports(){let e=this.getNamedBindings();return e==null||!H.isNamedImports(e)?[]:e.getElements()}},_c=ds,vc=class extends _c{isTypeOnly(){return this.getImportClause()?.isTypeOnly()??!1}setIsTypeOnly(e){let n=this.getImportClause();if(n==null){if(e)throw new t.errors.InvalidOperationError(`Cannot set an import as type only when there is no import clause.`);return this}return n.setIsTypeOnly(e),this}setModuleSpecifier(e){let t=typeof e==`string`?e:this._sourceFile.getRelativePathAsModuleSpecifierTo(e);return this.getModuleSpecifier().setLiteralValue(t),this}getModuleSpecifier(){let e=this._getNodeFromCompilerNode(this.compilerNode.moduleSpecifier);if(!H.isStringLiteral(e))throw new t.errors.InvalidOperationError(`Expected the module specifier to be a string literal.`);return e}getModuleSpecifierValue(){return this.getModuleSpecifier().getLiteralValue()}getModuleSpecifierSourceFileOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getModuleSpecifierSourceFile(),e??`A module specifier source file was expected.`,this)}getModuleSpecifierSourceFile(){let e=this.getModuleSpecifier().getSymbol();if(e!=null)return ne.getReferencedSourceFileFromSymbol(e)}isModuleSpecifierRelative(){return ne.isModuleSpecifierRelative(this.getModuleSpecifierValue())}setDefaultImport(e){if(t.StringUtils.isNullOrWhitespace(e))return this.removeDefaultImport();let n=this.getDefaultImport();if(n!=null)return n.replaceWithText(e),this;let r=this.getFirstChildByKindOrThrow(t.SyntaxKind.ImportKeyword),i=this.getImportClause();return i==null?(kt({insertPos:r.getEnd(),parent:this,newText:` ${e} from`}),this):(kt({insertPos:r.getEnd(),parent:i,newText:` ${e},`}),this)}renameDefaultImport(e){if(t.StringUtils.isNullOrWhitespace(e))return this.removeDefaultImport();let n=this.getDefaultImport();return n==null?(this.setDefaultImport(e),this):(n.rename(e),this)}getDefaultImportOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getDefaultImport(),e??`Expected to find a default import.`,this)}getDefaultImport(){return this.getImportClause()?.getDefaultImport()??void 0}setNamespaceImport(e){if(t.StringUtils.isNullOrWhitespace(e))return this.removeNamespaceImport();let n=this.getNamespaceImport();if(n!=null)return n.rename(e),this;if(this.getNamedImports().length>0)throw new t.errors.InvalidOperationError(`Cannot add a namespace import to an import declaration that has named imports.`);let r=this.getDefaultImport();return r==null?(kt({insertPos:this.getFirstChildByKindOrThrow(t.SyntaxKind.ImportKeyword).getEnd(),parent:this,newText:` * as ${e} from`}),this):(kt({insertPos:r.getEnd(),parent:this.getImportClause(),newText:`, * as ${e}`}),this)}removeNamespaceImport(){let e=this.getNamespaceImport();if(e==null)return this;return It({children:n.call(this),removePrecedingSpaces:!0,removePrecedingNewLines:!0}),this;function n(){let n=this.getDefaultImport();return n==null?[this.getImportClauseOrThrow(),this.getLastChildByKindOrThrow(t.SyntaxKind.FromKeyword)]:[n.getNextSiblingIfKindOrThrow(t.SyntaxKind.CommaToken),e]}}removeDefaultImport(){let e=this.getImportClause();if(e==null)return this;let n=e.getDefaultImport();return n==null||(e.getNamedBindings()==null?e.isTypeOnly()?kt({parent:e,newText:`{}`,insertPos:n.getStart(),replacing:{textLength:n.getWidth()}}):It({children:[e,e.getNextSiblingIfKindOrThrow(t.SyntaxKind.FromKeyword)],removePrecedingSpaces:!0,removePrecedingNewLines:!0}):It({children:[n,n.getNextSiblingIfKindOrThrow(t.SyntaxKind.CommaToken)],removePrecedingSpaces:!0,removePrecedingNewLines:!0})),this}getNamespaceImportOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getNamespaceImport(),e??`Expected to find a namespace import.`,this)}getNamespaceImport(){return this.getImportClause()?.getNamespaceImport()??void 0}addNamedImport(e){return this.addNamedImports([e])[0]}addNamedImports(e){return this.insertNamedImports(this.getNamedImports().length,e)}insertNamedImport(e,t){return this.insertNamedImports(e,[t])[0]}insertNamedImports(e,n){if(!(n instanceof Function)&&t.ArrayUtils.isNullOrEmpty(n))return[];let r=this.getNamedImports(),i=this._getWriterWithQueuedIndentation(),a=this._context.structurePrinterFactory.forNamedImportExportSpecifier(),o=this.getImportClause();if(e=et(e,r.length),r.length===0)if(a.printTextsWithBraces(i,n),o==null)kt({insertPos:this.getFirstChildByKindOrThrow(t.SyntaxKind.ImportKeyword).getEnd(),parent:this,newText:` ${i.toString()} from`});else if(this.getNamespaceImport()!=null)throw bc();else if(o.getNamedBindings()!=null){let e=o.getNamedBindingsOrThrow();kt({insertPos:e.getStart(),replacing:{textLength:e.getWidth()},parent:o,newText:i.toString()})}else kt({insertPos:this.getDefaultImport().getEnd(),parent:o,newText:`, ${i.toString()}`});else{if(o==null)throw new t.errors.NotImplementedError(`Expected to have an import clause.`);a.printTexts(i,n),jt({parent:o.getFirstChildByKindOrThrow(t.SyntaxKind.NamedImports).getFirstChildByKindOrThrow(t.SyntaxKind.SyntaxList),currentNodes:r,insertIndex:e,newText:i.toString(),surroundWithSpaces:this._context.getFormatCodeSettings().insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces,useTrailingCommas:!1})}return Ye(r,this.getNamedImports(),e,!1)}getNamedImports(){return this.getImportClause()?.getNamedImports()??[]}removeNamedImports(){let e=this.getImportClause();if(e==null)return this;let n=e.getNamedBindings();if(n==null||n.getKind()!==t.SyntaxKind.NamedImports)return this;let r=this.getDefaultImport();return r==null?(It({children:[e,e.getNextSiblingIfKindOrThrow(t.SyntaxKind.FromKeyword)],removePrecedingSpaces:!0}),this):(It({children:[r.getNextSiblingIfKindOrThrow(t.SyntaxKind.CommaToken),n]}),this)}getImportClauseOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getImportClause(),e??`Expected to find an import clause.`,this)}getImportClause(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.importClause)}setAttributes(e){let t=this.getAttributes();if(t)e?t.setElements(e):t.remove();else if(e){let t=this._context.structurePrinterFactory.forImportAttribute(),n=this._context.createWriter();n.space(),t.printAttributes(n,e),kt({parent:this,newText:n.toString(),insertPos:this.getSourceFile().getFullText()[this.getEnd()-1]===`;`?this.getEnd()-1:this.getEnd()})}return this}getAttributes(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.attributes)}set(e){return he(_c.prototype,this,e),e.defaultImport==null?e.hasOwnProperty(t.nameof(e,`defaultImport`))&&this.removeDefaultImport():this.setDefaultImport(e.defaultImport),e.hasOwnProperty(t.nameof(e,`namedImports`))&&this.removeNamedImports(),e.namespaceImport==null?e.hasOwnProperty(t.nameof(e,`namespaceImport`))&&this.removeNamespaceImport():this.setNamespaceImport(e.namespaceImport),e.namedImports!=null&&(yc(this),this.addNamedImports(e.namedImports)),e.moduleSpecifier!=null&&this.setModuleSpecifier(e.moduleSpecifier),e.isTypeOnly!=null&&this.setIsTypeOnly(e.isTypeOnly),e.hasOwnProperty(t.nameof(e,`attributes`))&&this.setAttributes(e.attributes),this}getStructure(){let t=this.getNamespaceImport(),n=this.getDefaultImport(),r=this.getAttributes();return me(_c.prototype,this,{kind:e.StructureKind.ImportDeclaration,isTypeOnly:this.isTypeOnly(),defaultImport:n?n.getText():void 0,moduleSpecifier:this.getModuleSpecifier().getLiteralText(),namedImports:this.getNamedImports().map(e=>e.getStructure()),namespaceImport:t?t.getText():void 0,attributes:r?r.getElements().map(e=>e.getStructure()):void 0})}};function yc(e){let n=e.getNodeProperty(`importClause`),r=e._getWriterWithQueuedChildIndentation();e._context.structurePrinterFactory.forNamedImportExportSpecifier().printTextsWithBraces(r,[]);let i=r.toString();if(e.getNamespaceImport()!=null)throw bc();if(n==null){kt({insertPos:e.getFirstChildByKindOrThrow(t.SyntaxKind.ImportKeyword).getEnd(),parent:e,newText:` ${i} from`});return}let a=n.getNamedBindings();if(a!=null){kt({parent:n,newText:i,insertPos:a.getStart(),replacing:{textLength:a.getWidth()}});return}let o=n.getDefaultImport();if(o!=null){kt({insertPos:o.getEnd(),parent:n,newText:`, ${i}`});return}}function bc(){return new t.errors.InvalidOperationError(`Cannot add a named import to an import declaration that has a namespace import.`)}var xc=(e=>Mn(Wi(Hi(ra(e)))))(ds),Sc=class extends xc{isTypeOnly(){return this.compilerNode.isTypeOnly??!1}setIsTypeOnly(e){return this.isTypeOnly()===e||(e?kt({parent:this,insertPos:this.getNameNode().getStart(),newText:`type `}):It({children:[this.getFirstChildByKindOrThrow(t.ts.SyntaxKind.TypeKeyword)],removeFollowingSpaces:!0})),this}getModuleReference(){return this._getNodeFromCompilerNode(this.compilerNode.moduleReference)}isExternalModuleReferenceRelative(){let e=this.getModuleReference();return H.isExternalModuleReference(e)?e.isRelative():!1}setExternalModuleReference(e){let t=typeof e==`string`?e:this._sourceFile.getRelativePathAsModuleSpecifierTo(e),n=this.getModuleReference();return H.isExternalModuleReference(n)&&n.getExpression()!=null?n.getExpressionOrThrow().replaceWithText(e=>e.quote(t)):n.replaceWithText(e=>e.write(`require(`).quote(t).write(`)`)),this}getExternalModuleReferenceSourceFileOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getExternalModuleReferenceSourceFile(),e??`Expected to find an external module reference's referenced source file.`,this)}getExternalModuleReferenceSourceFile(){let e=this.getModuleReference();if(H.isExternalModuleReference(e))return e.getReferencedSourceFile()}},Cc=H,wc=class extends Cc{setName(e){let t=this.getNameNode();return this.getName()===e||(ce(e)?t.replaceWithText(e):t.replaceWithText(`"${e.replaceAll(`"`,`\\"`)}"`)),this}getName(){let e=this.getNameNode();return e.getKind()===t.ts.SyntaxKind.StringLiteral?e.getLiteralText():e.getText()}getNameNode(){return this._getNodeFromCompilerNode(this.compilerNode.propertyName??this.compilerNode.name)}renameAlias(e){if(t.StringUtils.isNullOrWhitespace(e))return this.removeAliasWithRename(),this;let n=this.getAliasNode();return n??=(this.setAlias(this.getName()),this.getAliasNode()),n.rename(e),this}setAlias(e){if(t.StringUtils.isNullOrWhitespace(e))return this.removeAlias(),this;let n=this.getAliasNode();return n==null?kt({insertPos:this.getNameNode().getEnd(),parent:this,newText:` as ${e}`}):n.replaceWithText(e),this}removeAlias(){let e=this.getAliasNode();return e==null||It({children:[this.getFirstChildByKindOrThrow(t.SyntaxKind.AsKeyword),e],removePrecedingSpaces:!0,removePrecedingNewLines:!0}),this}removeAliasWithRename(){let e=this.getAliasNode();return e==null?this:(e.rename(this.getName()),this.removeAlias(),this)}getAliasNode(){if(this.compilerNode.propertyName!=null)return this._getNodeFromCompilerNode(this.compilerNode.name)}isTypeOnly(){return this.compilerNode.isTypeOnly}setIsTypeOnly(e){return this.isTypeOnly()===e||(e?kt({insertPos:this.getStart(),parent:this,newText:`type `}):It({children:[this.getFirstChildByKindOrThrow(t.ts.SyntaxKind.TypeKeyword)],removeFollowingSpaces:!0})),this}getImportDeclaration(){return this.getFirstAncestorByKindOrThrow(t.SyntaxKind.ImportDeclaration)}remove(){let e=this.getImportDeclaration();e.getNamedImports().length>1||e.getNamespaceImport()==null&&e.getDefaultImport()==null?Ut(this):e.removeNamedImports()}set(e){return he(Cc.prototype,this,e),e.isTypeOnly!=null&&this.setIsTypeOnly(e.isTypeOnly),e.name!=null&&this.setName(e.name),e.alias==null?e.hasOwnProperty(t.nameof(e,`alias`))&&this.removeAlias():this.setAlias(e.alias),this}getStructure(){let t=this.getAliasNode();return me(Cc.prototype,this,{kind:e.StructureKind.ImportSpecifier,name:this.getName(),alias:t?t.getText():void 0,isTypeOnly:this.isTypeOnly()})}},Tc=fs(ds),Ec=class extends Tc{};function Dc(e){return class extends e{getParentModuleOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getParentModule(),e??`Expected to find the parent module declaration.`,this)}getParentModule(){let e=this.getParentOrThrow();if(H.isModuleBlock(e)){for(;e.getParentOrThrow().getKind()===t.SyntaxKind.ModuleDeclaration;)e=e.getParentOrThrow();return e}}}}e.ModuleDeclarationKind=void 0,(function(e){e.Namespace=`namespace`,e.Module=`module`,e.Global=`global`})(e.ModuleDeclarationKind||={});var Oc=(e=>Ki(Ea(_a(Sn(Dc(fs(Hi(ge(Mn(Wi($i(e))))))))))))(ds),kc=class extends Oc{getName(){let e=this.getNameNodes();return e instanceof Array?e.map(e=>e.getText()).join(`.`):e.getText()}setName(e){let n=`Please open an issue if you really need this and I'll up the priority.`;if(e.indexOf(`.`)>=0)throw new t.errors.NotImplementedError(`Not implemented to set a namespace name to a name containing a period. ${n}`);let r=this.getNameNodes();if(r instanceof Array){if(r.length>1)throw new t.errors.NotImplementedError(`Not implemented to set a namespace name that uses dot notation. ${n}`);e!==`global`&&Ac(this),t.StringUtils.isQuoted(e)&&jc(this),r[0].replaceWithText(e)}else r.replaceWithText(e);return this}rename(e,n){if(e.indexOf(`.`)>=0)throw new t.errors.NotSupportedError(`Cannot rename a namespace name to a name containing a period.`);let r=this.getNameNodes();if(r instanceof Array){if(r.length>1)throw new t.errors.NotSupportedError(`Cannot rename a namespace name that uses dot notation. Rename the individual nodes via .${t.nameof(this,`getNameNodes`)}()`);e!==`global`&&Ac(this),r[0].rename(e,n)}else yn(r,t.StringUtils.stripQuotes(e),n);return this}getNameNodes(){let e=this.getNameNode();if(H.isStringLiteral(e))return e;{let e=[],n=this;do e.push(this._getNodeFromCompilerNode(n.compilerNode.name)),n=n.getFirstChildByKind(t.SyntaxKind.ModuleDeclaration);while(n!=null);return e}}hasNamespaceKeyword(){return this.getDeclarationKind()===e.ModuleDeclarationKind.Namespace}hasModuleKeyword(){return this.getDeclarationKind()===e.ModuleDeclarationKind.Module}setDeclarationKind(t){if(this.getDeclarationKind()===t)return this;if(t===e.ModuleDeclarationKind.Global){let e=this.getDeclarationKindKeyword();this.getNameNode().replaceWithText(`global`),e!=null&&It({children:[e],removeFollowingNewLines:!0,removeFollowingSpaces:!0})}else{let e=this.getDeclarationKindKeyword();e==null?kt({parent:this,insertPos:this.getNameNode().getStart(),newText:t+` `}):e.replaceWithText(t)}return this}getDeclarationKind(){let n=this.getFlags();return(n&t.ts.NodeFlags.GlobalAugmentation)===0?(n&t.ts.NodeFlags.Namespace)===0?e.ModuleDeclarationKind.Module:e.ModuleDeclarationKind.Namespace:e.ModuleDeclarationKind.Global}getDeclarationKindKeyword(){return this.getFirstChild(e=>e.getKind()===t.SyntaxKind.NamespaceKeyword||e.getKind()===t.SyntaxKind.ModuleKeyword)}set(e){return e.name!=null&&e.name!==`global`&&Ac(this),he(Oc.prototype,this,e),e.declarationKind!=null&&this.setDeclarationKind(e.declarationKind),this}getStructure(){return me(Oc.prototype,this,{kind:e.StructureKind.Module,declarationKind:this.getDeclarationKind()})}_getInnerBody(){let e=this.getBody();for(;e!=null&&H.isBodyable(e)&&e.compilerNode.statements==null;)e=e.getBody();return e}};function Ac(t){t.getDeclarationKind()===e.ModuleDeclarationKind.Global&&t.setDeclarationKind(e.ModuleDeclarationKind.Namespace)}function jc(t){t.hasNamespaceKeyword()&&t.setDeclarationKind(e.ModuleDeclarationKind.Module),t.hasDeclareKeyword()||t.setHasDeclareKeyword(!0)}var Mc=H,Nc=class extends Mc{getElements(){return this.compilerNode.elements.map(e=>this._getNodeFromCompilerNode(e))}},Pc=H,Fc=class extends Pc{getElements(){return this.compilerNode.elements.map(e=>this._getNodeFromCompilerNode(e))}},Ic=Xi(H),Lc=class extends Ic{setName(e){let t=this.getNameNode();return this.getName()===e||(ce(e)?t.replaceWithText(e):t.replaceWithText(`"${e.replaceAll(`"`,`\\"`)}"`)),this}getName(){let e=this.getNameNode();return e.getKind()===t.ts.SyntaxKind.StringLiteral?e.getLiteralText():e.getText()}getNameNode(){return this._getNodeFromCompilerNode(this.compilerNode.name)}},Rc=Xi(H),zc=class extends Rc{setName(e){let t=this.getNameNode();return t.getText()===e||t.replaceWithText(e),this}getName(){return this.getNameNode().getText()}getNameNode(){return this._getNodeFromCompilerNode(this.compilerNode.name)}},Bc=class extends dn{constructor(e,t){super(e,t)}getFileName(){return this.compilerObject.fileName}};e.FileSystemRefreshResult=void 0,(function(e){e[e.NoChange=0]=`NoChange`,e[e.Updated=1]=`Updated`,e[e.Deleted=2]=`Deleted`})(e.FileSystemRefreshResult||={});function Vc(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var Hc=Ki(_a(fs(H))),Uc=class extends Hc{#e=!1;#t=new t.EventContainer;#n=new t.EventContainer;_referenceContainer=new de(this);#r;#i;#a;_hasBom;constructor(e,t){super(e,t,void 0),this.__sourceFile=this;let n=()=>{this.isFromExternalLibrary(),this.#n.unsubscribe(n)};this.#n.subscribe(n)}_replaceCompilerNodeFromFactory(e){super._replaceCompilerNodeFromFactory(e),this._context.resetProgram(),this.#e=!1,this.#t.fire(this)}_clearInternals(){super._clearInternals(),e(this.#r),e(this.#a),e(this.#i),this.#r=void 0,this.#a=void 0,this.#i=void 0;function e(e){e?.forEach(e=>e._forget())}}getFilePath(){return this.compilerNode.fileName}getBaseName(){return t.FileUtils.getBaseName(this.getFilePath())}getBaseNameWithoutExtension(){let e=this.getBaseName(),t=this.getExtension();return e.substring(0,e.length-t.length)}getExtension(){return t.FileUtils.getExtension(this.getFilePath())}getDirectory(){return this._context.compilerFactory.getDirectoryFromCache(this.getDirectoryPath())}getDirectoryPath(){return this._context.fileSystemWrapper.getStandardizedAbsolutePath(t.FileUtils.getDirPath(this.compilerNode.fileName))}getFullText(){return this.compilerNode.text}getLineAndColumnAtPos(e){let n=this.getFullText();return{line:t.StringUtils.getLineNumberAtPos(n,e),column:t.StringUtils.getLengthFromLineStartAtPos(n,e)+1}}getLengthFromLineStartAtPos(e){return t.StringUtils.getLengthFromLineStartAtPos(this.getFullText(),e)}copyToDirectory(e,n){let r=typeof e==`string`?e:e.getPath();return this.copy(t.FileUtils.pathJoin(r,this.getBaseName()),n)}copy(e,t={}){this._throwIfIsInMemoryLibFile();let n=this._copyInternal(e,t);if(n===!1)return this;let r=n;return r.getDirectoryPath()!==this.getDirectoryPath()&&r._updateReferencesForCopyInternal(this._getReferencesForCopyInternal()),r}_copyInternal(e,n={}){let{overwrite:r=!1}=n,{compilerFactory:i,fileSystemWrapper:a}=this._context,o=a.getStandardizedAbsolutePath(e,this.getDirectoryPath());if(o===this.getFilePath())return!1;return s(this);function s(e){try{return i.createSourceFileFromText(o,e.getFullText(),{overwrite:r,markInProject:n()})}catch(e){throw e instanceof t.errors.InvalidOperationError?new t.errors.InvalidOperationError(`Did you mean to provide the overwrite option? `+e.message):e}function n(){if(e._isInProject())return!0;let t=i.getSourceFileFromCacheFromFilePath(o);return t!=null&&t._isInProject()}}}_getReferencesForCopyInternal(){return Array.from(this._referenceContainer.getLiteralsReferencingOtherSourceFilesEntries())}_updateReferencesForCopyInternal(e){for(let t of e)t[0]=this.getChildSyntaxListOrThrow().getDescendantAtStartWithWidth(t[0].getStart(),t[0].getWidth());Wc(e)}async copyImmediately(e,t){let n=this.copy(e,t);return await n.save(),n}copyImmediatelySync(e,t){let n=this.copy(e,t);return n.saveSync(),n}moveToDirectory(e,n){let r=typeof e==`string`?e:e.getPath();return this.move(t.FileUtils.pathJoin(r,this.getBaseName()),n)}move(e,t={}){this._throwIfIsInMemoryLibFile();let n=this.getDirectoryPath(),r=this._getReferencesForMoveInternal(),i=this.getFilePath();return this._moveInternal(e,t)?(this._context.fileSystemWrapper.queueFileDelete(i),this._updateReferencesForMoveInternal(r,n),this._context.lazyReferenceCoordinator.clearDirtySourceFiles(),this._context.lazyReferenceCoordinator.addDirtySourceFile(this),this):this}_moveInternal(e,t={}){let{overwrite:n=!1}=t,r=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getDirectoryPath());if(r===this.getFilePath())return!1;let i=!1;if(n){let e=this._context.compilerFactory.getSourceFileFromCacheFromFilePath(r);e!=null&&(i=e._isInProject(),e.forget())}else this._context.compilerFactory.throwIfFileExists(r,`Did you mean to provide the overwrite option?`);return nn({newFilePath:r,sourceFile:this}),i&&this._markAsInProject(),this._isInProject()&&this.getDirectory()._markAsInProject(),!0}_getReferencesForMoveInternal(){return{literalReferences:Array.from(this._referenceContainer.getLiteralsReferencingOtherSourceFilesEntries()),referencingLiterals:Array.from(this._referenceContainer.getReferencingLiteralsInOtherSourceFiles())}}_updateReferencesForMoveInternal(e,t){let{literalReferences:n,referencingLiterals:r}=e;t!==this.getDirectoryPath()&&Wc(n),Wc(r.map(e=>[e,this]))}async moveImmediately(e,t){let n=this.getFilePath(),r=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getDirectoryPath());return this.move(e,t),n===r?await this.save():(await this._context.fileSystemWrapper.moveFileImmediately(n,r,this.getFullText()),this.#e=!0),this}moveImmediatelySync(e,t){let n=this.getFilePath(),r=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getDirectoryPath());return this.move(e,t),n===r?this.saveSync():(this._context.fileSystemWrapper.moveFileImmediatelySync(n,r,this.getFullText()),this.#e=!0),this}delete(){this._throwIfIsInMemoryLibFile();let e=this.getFilePath();this.forget(),this._context.fileSystemWrapper.queueFileDelete(e)}async deleteImmediately(){this._throwIfIsInMemoryLibFile();let e=this.getFilePath();this.forget(),await this._context.fileSystemWrapper.deleteFileImmediately(e)}deleteImmediatelySync(){this._throwIfIsInMemoryLibFile();let e=this.getFilePath();this.forget(),this._context.fileSystemWrapper.deleteFileImmediatelySync(e)}async save(){this._isLibFileInMemory()||(await this._context.fileSystemWrapper.writeFile(this.getFilePath(),this.#o()),this.#e=!0)}saveSync(){this._isLibFileInMemory()||(this._context.fileSystemWrapper.writeFileSync(this.getFilePath(),this.#o()),this.#e=!0)}#o(){let e=this.getFullText();return this._hasBom?``+e:e}getPathReferenceDirectives(){return this.#r??=(this.compilerNode.referencedFiles||[]).map(e=>new Bc(e,this)),this.#r}getTypeReferenceDirectives(){return this.#a??=(this.compilerNode.typeReferenceDirectives||[]).map(e=>new Bc(e,this)),this.#a}getLibReferenceDirectives(){return this.#i??=(this.compilerNode.libReferenceDirectives||[]).map(e=>new Bc(e,this)),this.#i}getReferencingSourceFiles(){return Array.from(this._referenceContainer.getDependentSourceFiles())}getReferencingNodesInOtherSourceFiles(){let e=this.getReferencingLiteralsInOtherSourceFiles();return Array.from(t());function*t(){for(let t of e)yield Gc(t)}}getReferencingLiteralsInOtherSourceFiles(){return Array.from(this._referenceContainer.getReferencingLiteralsInOtherSourceFiles())}getReferencedSourceFiles(){let e=this._referenceContainer.getLiteralsReferencingOtherSourceFilesEntries();return Array.from(new Set(t()).values());function*t(){for(let[,t]of e)yield t}}getNodesReferencingOtherSourceFiles(){let e=this._referenceContainer.getLiteralsReferencingOtherSourceFilesEntries();return Array.from(t());function*t(){for(let[t]of e)yield Gc(t)}}getLiteralsReferencingOtherSourceFiles(){let e=this._referenceContainer.getLiteralsReferencingOtherSourceFilesEntries();return Array.from(t());function*t(){for(let[t]of e)yield t}}getImportStringLiterals(){return this._ensureBound(),(this.compilerNode.imports||[]).filter(e=>e.pos!==-1).map(e=>this._getNodeFromCompilerNode(e))}getLanguageVersion(){return this.compilerNode.languageVersion}getLanguageVariant(){return this.compilerNode.languageVariant}getScriptKind(){return this.compilerNode.scriptKind}isDeclarationFile(){return this.compilerNode.isDeclarationFile}isFromExternalLibrary(){return this._context.program._isCompilerProgramCreated()?this._context.program.compilerObject.isSourceFileFromExternalLibrary(this.compilerNode):!1}isInNodeModules(){return this.getFilePath().indexOf(`/node_modules/`)>=0}isSaved(){return this.#e&&!this._isLibFileInMemory()}_setIsSaved(e){this.#e=e}getPreEmitDiagnostics(){return this._context.getPreEmitDiagnostics(this)}unindent(e,t=1){return this.indent(e,t*-1)}indent(e,n=1){if(n===0)return this;let r=this.getFullText(),i=typeof e==`number`?[e,e]:e;t.errors.throwIfRangeOutOfRange(i,[0,r.length],`positionRange`);let a=Me(r,i[0],e=>e===o.NEWLINE),s=je(r,i[1],e=>e===o.CARRIAGE_RETURN||e===o.NEWLINE),c=t.StringUtils.indent(r.substring(a,s),n,{indentText:this._context.manipulationSettings.getIndentationText(),indentSizeInSpaces:this._context.manipulationSettings._getIndentSizeInSpaces(),isInStringAtPos:e=>this.isInStringAtPos(e+a)});return Qt({sourceFile:this,newText:r.substring(0,a)+c+r.substring(s)}),this}emit(e){return this._context.program.emit({targetSourceFile:this,...e})}emitSync(e){return this._context.program.emitSync({targetSourceFile:this,...e})}getEmitOutput(e={}){return this._context.languageService.getEmitOutput(this,e.emitOnlyDtsFiles||!1)}formatText(e={}){Qt({sourceFile:this,newText:this._context.languageService.getFormattedDocumentText(this.getFilePath(),e)})}async refreshFromFileSystem(){let e=await this._context.fileSystemWrapper.readFileOrNotExists(this.getFilePath(),this._context.getEncoding());return this.#s(e)}refreshFromFileSystemSync(){let e=this._context.fileSystemWrapper.readFileOrNotExistsSync(this.getFilePath(),this._context.getEncoding());return this.#s(e)}getRelativePathTo(e){return this.getDirectory().getRelativePathTo(e)}getRelativePathAsModuleSpecifierTo(e){return this.getDirectory().getRelativePathAsModuleSpecifierTo(e)}onModified(e,t=!0){return t?this.#t.subscribe(e):this.#t.unsubscribe(e),this}_doActionPreNextModification(e){let t=()=>{e(),this.#n.unsubscribe(t)};return this.#n.subscribe(t),this}_firePreModified(){this.#n.fire(this)}organizeImports(e={},t={}){return this._context.languageService.organizeImports(this,e,t).forEach(e=>e.applyChanges()),this}fixUnusedIdentifiers(e={},t={}){return this._context.languageService.getCombinedCodeFix(this,`unusedIdentifier_delete`,e,t).applyChanges(),this._context.languageService.getCombinedCodeFix(this,`unusedIdentifier_deleteImports`,e,t).applyChanges(),this}fixMissingImports(e={},n={}){let r=this._context.languageService.getCombinedCodeFix(this,`fixMissingImport`,e,n),i=this;for(let e of r.getChanges()){let t=e.getTextChanges();a(t),o(t)}return this;function a(e){e.sort((e,t)=>e.getSpan().getStart()-t.getSpan().getStart());for(let t=0;t<e.length-1;t++){let{compilerObject:n}=e[t];n.newText=n.newText.replace(/(\r?)\n\r?\n$/,`$1
|
|
31380
31386
|
`)}}function o(e){let n=t.ArrayUtils.groupBy(e,e=>e.getSpan().getStart()),r=0;for(let e of n){let t=e[0].getSpan().getStart()+r,n=e.map(e=>e.getNewText()).join(``);At({sourceFile:i,insertPos:t,newText:n}),r+=n.length}}}applyTextChanges(e){return e.length===0?this:(this.forgetDescendants(),Zt({sourceFile:this._sourceFile,start:0,replacingLength:this.getFullWidth(),newText:R(this,e)}),this)}set(e){return he(Hc.prototype,this,e),this}getStructure(){return me(Hc.prototype,this,{kind:e.StructureKind.SourceFile})}#s(t){if(t===!1)return this.forget(),e.FileSystemRefreshResult.Deleted;let n=t;return n===this.getFullText()?e.FileSystemRefreshResult.NoChange:(this.replaceText([0,this.getEnd()],n),this._setIsSaved(!0),e.FileSystemRefreshResult.Updated)}_isLibFileInMemory(){return this.compilerNode.fileName.startsWith(t.libFolderInMemoryPath)}_throwIfIsInMemoryLibFile(){if(this._isLibFileInMemory())throw new t.errors.InvalidOperationError(`This operation is not permitted on an in memory lib folder file.`)}_isInProject(){return this._context.inProjectCoordinator.isSourceFileInProject(this)}_markAsInProject(){this._context.inProjectCoordinator.markSourceFileAsInProject(this)}};Vc([t.Memoize],Uc.prototype,`isFromExternalLibrary`,null);function Wc(e){for(let[t,n]of e)ne.isModuleSpecifierRelative(t.getLiteralText())&&t.setLiteralValue(t._sourceFile.getRelativePathAsModuleSpecifierTo(n))}function Gc(e){let t=e.getParentOrThrow(),n=t.getParent();return n!=null&&H.isImportEqualsDeclaration(n)?n:t}var Kc=(e=>Dc(Hi(ge(Mn(Wi(e))))))(ds),qc=class extends Kc{getDeclarationList(){return this._getNodeFromCompilerNode(this.compilerNode.declarationList)}getDeclarations(){return this.getDeclarationList().getDeclarations()}getDeclarationKind(){return this.getDeclarationList().getDeclarationKind()}getDeclarationKindKeywords(){return this.getDeclarationList().getDeclarationKindKeywords()}setDeclarationKind(e){return this.getDeclarationList().setDeclarationKind(e)}addDeclaration(e){return this.getDeclarationList().addDeclaration(e)}addDeclarations(e){return this.getDeclarationList().addDeclarations(e)}insertDeclaration(e,t){return this.getDeclarationList().insertDeclaration(e,t)}insertDeclarations(e,t){return this.getDeclarationList().insertDeclarations(e,t)}set(e){if(he(Kc.prototype,this,e),e.declarationKind!=null&&this.setDeclarationKind(e.declarationKind),e.declarations!=null){let t=this.getDeclarations();this.addDeclarations(e.declarations),t.forEach(e=>e.remove())}return this}getStructure(){return me(Kc.prototype,this,{kind:e.StructureKind.VariableStatement,declarationKind:this.getDeclarationKind(),declarations:this.getDeclarations().map(e=>e.getStructure())})}},Jc=Ka(ks),Yc=class extends Jc{},Xc=Ka(ds),Zc=class extends Xc{getStatement(){return this._getNodeFromCompilerNode(this.compilerNode.statement)}};function Qc(e){return Hi(wa(ha(fs(Wi(e)))))}var $c=(e=>_a(xn(on(Qc(e)))))(Ma),el=class extends $c{getEqualsGreaterThan(){return this._getNodeFromCompilerNode(this.compilerNode.equalsGreaterThanToken)}};function tl(e){return class extends e{getOverloads(){return nl(this).filter(e=>e.isOverload())}getImplementation(){return this.isImplementation()?this:nl(this).find(e=>e.isImplementation())}getImplementationOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getImplementation(),e??`Expected to find a corresponding implementation for the overload.`,this)}isOverload(){return!this.isImplementation()}isImplementation(){return this.getBody()!=null}}}function nl(e){let t=e.getParentOrThrow(),n=rl(e),r=il(e),i=e.getKind();return t.forEachChildAsArray().filter(e=>rl(e)===n&&e.getKind()===i&&il(e)===r)}function rl(e){let t=e;if(t.getName instanceof Function)return t.getName()}function il(e){let t=e;return t.isStatic instanceof Function?t.isStatic():!1}function al(e){if(e.structures.length===0)return[];let t=e.node.getParentSyntaxListOrThrow(),n=e.node.getImplementation()||e.node,r=e.node.getOverloads(),i=r.length,a=r.length>0?r[0].getChildIndex():n.getChildIndex(),o=et(e.index,i),s=a+o,c=e.getThisStructure(n),l=e.structures.map(e=>Object.assign(Object.assign({},c),e)),u=n._getWriterWithQueuedIndentation();for(let t of l)u.getLength()>0&&u.newLine(),e.printStructure(u,t);return u.newLine(),u.write(``),kt({parent:t,insertPos:(r[o]||n).getNonWhitespaceStart(),newText:u.toString()}),Xe(t.getChildren(),s,l.length,e.expectedSyntaxKind)}var ol=(e=>Ea(_a(tl(Sn(on(Fi(ge(Mn(Qc(Dc(ea(e))))))))))))(ds),sl=(e=>Ea(_a(on(Fi(ha(ge(Dc(Hi(wa(Mn(Wi(e))))))))))))(ds),cl=class extends ol{addOverload(e){return this.addOverloads([e])[0]}addOverloads(e){return this.insertOverloads(this.getOverloads().length,e)}insertOverload(e,t){return this.insertOverloads(e,[t])[0]}insertOverloads(e,n){let r=this.getName(),i=this._context.structurePrinterFactory.forFunctionDeclaration({isAmbient:this.isAmbient()});return al({node:this,index:e,structures:n,printStructure:(e,t)=>{i.printOverload(e,r,t)},getThisStructure:Qe,expectedSyntaxKind:t.SyntaxKind.FunctionDeclaration})}remove(){Wt(this)}set(e){return he(ol.prototype,this,e),e.overloads!=null&&(this.getOverloads().forEach(e=>e.remove()),this.addOverloads(e.overloads)),this}getStructure(){let t=this.isOverload(),n=this.getImplementation();return me(t&&n?sl.prototype:ol.prototype,this,r(this));function r(r){if(n&&t)return i();return a();function i(){return{kind:e.StructureKind.FunctionOverload}}function a(){return n?{kind:e.StructureKind.Function,overloads:r.getOverloads().map(e=>e.getStructure())}:{kind:e.StructureKind.Function}}}}},ll=(e=>Hi(_a(xn(on(Fi(fs(wa(ha(Wi(ea(e)))))))))))(Ha),ul=class extends ll{},dl=(e=>aa(ca(wn(da(la(Wi(On(ba(Bi(Zi(e)))))))))))(H),fl=class extends dl{isRestParameter(){return this.compilerNode.dotDotDotToken!=null}isParameterProperty(){return this.getScope()!=null||this.isReadonly()||this.hasOverrideKeyword()}setIsRestParameter(e){return this.isRestParameter()===e||(e?(pl(this),kt({insertPos:this.getNameNode().getStart(),parent:this,newText:`...`})):It({children:[this.getDotDotDotTokenOrThrow()]})),this}isOptional(){return this.compilerNode.questionToken!=null||this.isRestParameter()||this.hasInitializer()}remove(){Ut(this)}set(e){return he(dl.prototype,this,e),e.isRestParameter!=null&&this.setIsRestParameter(e.isRestParameter),this}getStructure(){return me(dl.prototype,this,{kind:e.StructureKind.Parameter,isRestParameter:this.isRestParameter()})}setHasQuestionToken(e){return e&&pl(this),super.setHasQuestionToken(e),this}setInitializer(e){return pl(this),super.setInitializer(e),this}setType(e){return pl(this),super.setType.call(this,e),this}};function pl(e){let n=e.getParentOrThrow();r()&&i();function r(){return H.isArrowFunction(n)&&n.compilerNode.parameters.length===1&&e.getParentSyntaxListOrThrow().getPreviousSiblingIfKind(t.SyntaxKind.OpenParenToken)==null}function i(){let t=e.getText();kt({parent:n,insertPos:e.getStart(),newText:`(${t})`,replacing:{textLength:t.length},customMappings:t=>[{currentNode:e,newNode:t.parameters[0]}]})}}var ml=class extends H{remove(){let e=this.getParentOrThrow();H.isClassDeclaration(e)||H.isClassExpression(e)?zt(this):H.isObjectLiteralExpression(e)?Ut(this):H.isInterfaceDeclaration(e)?Vt(this):t.errors.throwNotImplementedForSyntaxKindError(e.getKind())}},hl=(e=>Cn(_a(aa(tl(Sn(wn(ja(ma(ca(ga(on(Fi(Qc(ia(e)))))))))))))))(ml),gl=(e=>Hi(Cn(_a(aa(ma(wa(ja(ca(ga(on(Wi(Fi(ha(e))))))))))))))(ml),_l=class extends hl{set(e){return he(hl.prototype,this,e),e.overloads!=null&&(this.getOverloads().forEach(e=>e.remove()),this.addOverloads(e.overloads)),this}addOverload(e){return this.addOverloads([e])[0]}addOverloads(e){return this.insertOverloads(this.getOverloads().length,e)}insertOverload(e,t){return this.insertOverloads(e,[t])[0]}insertOverloads(e,n){let r=this.getName(),i=this._context.structurePrinterFactory.forMethodDeclaration({isAmbient:k(this)});return al({node:this,index:e,structures:n,printStructure:(e,t)=>{i.printOverload(e,r,t)},getThisStructure:$e,expectedSyntaxKind:t.SyntaxKind.MethodDeclaration})}getStructure(){let t=this.getImplementation()!=null,n=this.isOverload();return me(n&&t?gl.prototype:hl.prototype,this,r(this));function r(r){if(t&&n)return i();return a();function i(){return{kind:e.StructureKind.MethodOverload}}function a(){return t?{kind:e.StructureKind.Method,overloads:r.getOverloads().map(e=>e.getStructure())}:{kind:e.StructureKind.Method}}}}};function vl(e){return yl(ea(_a(Ri(Li(ja(Hi(wa(wn(Wi(e))))))))))}function yl(e){return class extends e{setExtends(e){if(e=this._getTextWithQueuedChildIndentation(e),t.StringUtils.isNullOrWhitespace(e))return this.removeExtends();let n=this.getHeritageClauseByKind(t.SyntaxKind.ExtendsKeyword);if(n!=null){let r=n.getFirstChildByKindOrThrow(t.SyntaxKind.SyntaxList),i=r.getStart();kt({parent:n,newText:e,insertPos:i,replacing:{textLength:r.getEnd()-i}})}else{let n=this.getHeritageClauseByKind(t.SyntaxKind.ImplementsKeyword),r;r=n==null?this.getFirstChildByKindOrThrow(t.SyntaxKind.OpenBraceToken).getStart():n.getStart();let i=/\s/.test(this.getSourceFile().getFullText()[r-1]),a=`extends ${e} `;i||(a=` `+a),kt({parent:n==null?this:n.getParentSyntaxListOrThrow(),insertPos:r,newText:a})}return this}removeExtends(){return this.getHeritageClauseByKind(t.SyntaxKind.ExtendsKeyword)?.removeExpression(0),this}getExtendsOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getExtends(),e??`Expected to find the extends expression for the class ${this.getName()}.`,this)}getExtends(){let e=this.getHeritageClauseByKind(t.SyntaxKind.ExtendsKeyword);if(e==null)return;let n=e.getTypeNodes();return n.length===0?void 0:n[0]}addMembers(e){return this.insertMembers(Ae(this.getMembersWithComments()),e)}addMember(e){return this.insertMember(Ae(this.getMembersWithComments()),e)}insertMember(e,t){return this.insertMembers(e,[t])[0]}insertMembers(e,t){let n=k(this);return Pt({getIndexedChildren:()=>this.getMembersWithComments(),index:e,parent:this,write:(e,i)=>{let a=!n&&i.previousMember!=null&&H.isBodyable(i.previousMember)&&i.previousMember.hasBody(),o=!n&&t instanceof Array&&r(t[0]);a||i.previousMember!=null&&o?e.blankLineIfLastNot():e.newLineIfLastNot();let s=this._getWriter();this._context.structurePrinterFactory.forClassMember({isAmbient:n}).printTexts(s,t),e.write(s.toString());let c=!n&&t instanceof Array&&r(t[t.length-1]),l=!n&&i.nextMember!=null&&H.isBodyable(i.nextMember)&&i.nextMember.hasBody();i.nextMember!=null&&c||l?e.blankLineIfLastNot():e.newLineIfLastNot()}});function r(e){if(n||e==null||typeof e.kind!=`number`)return!1;let t=e;return Jn.isMethod(t)||Jn.isGetAccessor(t)||Jn.isSetAccessor(t)||Jn.isConstructor(t)}}addConstructor(e={}){return this.insertConstructor(Ae(this.getMembersWithComments()),e)}addConstructors(e){return this.insertConstructors(Ae(this.getMembersWithComments()),e)}insertConstructor(e,t={}){return this.insertConstructors(e,[t])[0]}insertConstructors(e,n){let r=k(this);return wl(this,{index:e,structures:n,expectedKind:t.SyntaxKind.Constructor,write:(e,t)=>{!r&&t.previousMember!=null&&!H.isCommentNode(t.previousMember)?e.blankLineIfLastNot():e.newLineIfLastNot(),this._context.structurePrinterFactory.forConstructorDeclaration({isAmbient:r}).printTexts(e,n),!r&&t.nextMember!=null?e.blankLineIfLastNot():e.newLineIfLastNot()}})}getConstructors(){return this.getMembers().filter(e=>H.isConstructorDeclaration(e))}addStaticBlock(e={}){return this.insertStaticBlock(Ae(this.getMembersWithComments()),e)}addStaticBlocks(e){return this.insertStaticBlocks(Ae(this.getMembersWithComments()),e)}insertStaticBlock(e,t={}){return this.insertStaticBlocks(e,[t])[0]}insertStaticBlocks(e,n){let r=k(this);return wl(this,{index:e,structures:n,expectedKind:t.SyntaxKind.ClassStaticBlockDeclaration,write:(e,t)=>{!r&&t.previousMember!=null&&!H.isCommentNode(t.previousMember)?e.blankLineIfLastNot():e.newLineIfLastNot(),this._context.structurePrinterFactory.forClassStaticBlockDeclaration().printTexts(e,n),!r&&t.nextMember!=null?e.blankLineIfLastNot():e.newLineIfLastNot()}})}getStaticBlocks(){return this.getMembers().filter(e=>H.isClassStaticBlockDeclaration(e))}addGetAccessor(e){return this.addGetAccessors([e])[0]}addGetAccessors(e){return this.insertGetAccessors(Ae(this.getMembersWithComments()),e)}insertGetAccessor(e,t){return this.insertGetAccessors(e,[t])[0]}insertGetAccessors(e,n){return wl(this,{index:e,structures:n,expectedKind:t.SyntaxKind.GetAccessor,write:(e,t)=>{t.previousMember!=null&&!H.isCommentNode(t.previousMember)?e.blankLineIfLastNot():e.newLineIfLastNot(),this._context.structurePrinterFactory.forGetAccessorDeclaration({isAmbient:k(this)}).printTexts(e,n),t.nextMember==null?e.newLineIfLastNot():e.blankLineIfLastNot()}})}addSetAccessor(e){return this.addSetAccessors([e])[0]}addSetAccessors(e){return this.insertSetAccessors(Ae(this.getMembersWithComments()),e)}insertSetAccessor(e,t){return this.insertSetAccessors(e,[t])[0]}insertSetAccessors(e,n){return wl(this,{index:e,structures:n,expectedKind:t.SyntaxKind.SetAccessor,write:(e,t)=>{t.previousMember!=null&&!H.isCommentNode(t.previousMember)?e.blankLineIfLastNot():e.newLineIfLastNot(),this._context.structurePrinterFactory.forSetAccessorDeclaration({isAmbient:k(this)}).printTexts(e,n),t.nextMember==null?e.newLineIfLastNot():e.blankLineIfLastNot()}})}addProperty(e){return this.addProperties([e])[0]}addProperties(e){return this.insertProperties(Ae(this.getMembersWithComments()),e)}insertProperty(e,t){return this.insertProperties(e,[t])[0]}insertProperties(e,n){return wl(this,{index:e,structures:n,expectedKind:t.SyntaxKind.PropertyDeclaration,write:(e,t)=>{t.previousMember!=null&&H.hasBody(t.previousMember)?e.blankLineIfLastNot():e.newLineIfLastNot(),this._context.structurePrinterFactory.forPropertyDeclaration().printTexts(e,n),t.nextMember!=null&&H.hasBody(t.nextMember)?e.blankLineIfLastNot():e.newLineIfLastNot()}})}addMethod(e){return this.addMethods([e])[0]}addMethods(e){return this.insertMethods(Ae(this.getMembersWithComments()),e)}insertMethod(e,t){return this.insertMethods(e,[t])[0]}insertMethods(e,n){let r=k(this);return n=n.map(e=>({...e})),wl(this,{index:e,write:(e,t)=>{!r&&t.previousMember!=null&&!H.isCommentNode(t.previousMember)?e.blankLineIfLastNot():e.newLineIfLastNot(),this._context.structurePrinterFactory.forMethodDeclaration({isAmbient:r}).printTexts(e,n),!r&&t.nextMember!=null?e.blankLineIfLastNot():e.newLineIfLastNot()},structures:n,expectedKind:t.SyntaxKind.MethodDeclaration})}getInstanceProperty(e){return s(this.getInstanceProperties(),e)}getInstancePropertyOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getInstanceProperty(e),()=>l(`class instance property`,e))}getInstanceProperties(){return this.getInstanceMembers().filter(e=>Sl(e))}getStaticProperty(e){return s(this.getStaticProperties(),e)}getStaticPropertyOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getStaticProperty(e),()=>l(`class static property`,e))}getStaticProperties(){return this.getStaticMembers().filter(e=>Sl(e))}getProperty(e){return s(this.getProperties(),e)}getPropertyOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getProperty(e),()=>l(`class property declaration`,e))}getProperties(){return this.getMembers().filter(e=>H.isPropertyDeclaration(e))}getGetAccessor(e){return s(this.getGetAccessors(),e)}getGetAccessorOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getGetAccessor(e),()=>l(`class getAccessor declaration`,e))}getGetAccessors(){return this.getMembers().filter(e=>H.isGetAccessorDeclaration(e))}getSetAccessor(e){return s(this.getSetAccessors(),e)}getSetAccessorOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getSetAccessor(e),()=>l(`class setAccessor declaration`,e))}getSetAccessors(){return this.getMembers().filter(e=>H.isSetAccessorDeclaration(e))}getMethod(e){return s(this.getMethods(),e)}getMethodOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getMethod(e),()=>l(`class method declaration`,e))}getMethods(){return this.getMembers().filter(e=>H.isMethodDeclaration(e))}getInstanceMethod(e){return s(this.getInstanceMethods(),e)}getInstanceMethodOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getInstanceMethod(e),()=>l(`class instance method`,e))}getInstanceMethods(){return this.getInstanceMembers().filter(e=>e instanceof _l)}getStaticMethod(e){return s(this.getStaticMethods(),e)}getStaticMethodOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getStaticMethod(e),()=>l(`class static method`,e))}getStaticMethods(){return this.getStaticMembers().filter(e=>e instanceof _l)}getInstanceMember(e){return s(this.getInstanceMembers(),e)}getInstanceMemberOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getInstanceMember(e),()=>l(`class instance member`,e))}getInstanceMembers(){return this.getMembersWithParameterProperties().filter(e=>H.isConstructorDeclaration(e)?!1:H.isParameterDeclaration(e)||!e.isStatic())}getStaticMember(e){return s(this.getStaticMembers(),e)}getStaticMemberOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getStaticMember(e),()=>l(`class static member`,e))}getStaticMembers(){return this.getMembers().filter(e=>H.isConstructorDeclaration(e)?!1:!H.isParameterDeclaration(e)&&e.isStatic())}getMembersWithParameterProperties(){let e=this.getMembers(),t=e.filter(e=>H.isConstructorDeclaration(e)&&e.isImplementation());for(let n of t){let t=e.indexOf(n)+1;for(let r of n.getParameters())r.isParameterProperty()&&(e.splice(t,0,r),t++)}return e}getMembers(){return bl(this,this.compilerNode.members).filter(e=>Cl(e))}getMembersWithComments(){let e=this.compilerNode,t=T.getContainerArray(e,this.getSourceFile().compilerNode);return bl(this,t).filter(e=>Cl(e)||H.isCommentClassElement(e))}getMember(e){return s(this.getMembers(),e)}getMemberOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getMember(e),()=>l(`class member`,e))}getBaseTypes(){return this.getType().getBaseTypes()}getBaseClassOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getBaseClass(),e??`Expected to find the base class of ${this.getName()}.`,this)}getBaseClass(){let e=this.getBaseTypes().map(e=>e.isIntersection()?e.getIntersectionTypes():[e]).flat().map(e=>e.getSymbol()).filter(e=>e!=null).map(e=>e.getDeclarations()).reduce((e,t)=>e.concat(t),[]).filter(e=>e.getKind()===t.SyntaxKind.ClassDeclaration);if(e.length===1)return e[0]}getDerivedClasses(){let e=xl(this);for(let t=0;t<e.length;t++){let n=xl(e[t]);for(let t of n)t!==this&&e.indexOf(t)===-1&&e.push(t)}return e}}}function bl(e,t){let n=k(e),r=t.map(t=>e._getNodeFromCompilerNode(t));return n?r:r.filter(e=>!(H.isConstructorDeclaration(e)||H.isMethodDeclaration(e))||H.isMethodDeclaration(e)&&e.isAbstract()?!0:e.isImplementation())}function xl(e){let n=[],r=e.getNameNode();if(r==null)return n;for(let e of r.findReferencesAsNodes()){e=e.getParentWhileKind(t.SyntaxKind.PropertyAccessExpression)??e;let r=e.getParentIfKind(t.SyntaxKind.ExpressionWithTypeArguments);if(r==null)continue;let i=r.getParentIfKind(t.SyntaxKind.HeritageClause);if(i==null||i.getToken()!==t.SyntaxKind.ExtendsKeyword)continue;let a=i.getParentIfKind(t.SyntaxKind.ClassDeclaration);a!=null&&n.push(a)}return n}function Sl(e){return H.isPropertyDeclaration(e)||H.isSetAccessorDeclaration(e)||H.isGetAccessorDeclaration(e)||H.isParameterDeclaration(e)}function Cl(e){return H.isMethodDeclaration(e)||H.isPropertyDeclaration(e)||H.isGetAccessorDeclaration(e)||H.isSetAccessorDeclaration(e)||H.isConstructorDeclaration(e)||H.isClassStaticBlockDeclaration(e)}function wl(e,t){return Nt({getIndexedChildren:()=>e.getMembersWithComments(),parent:e,...t})}var Tl=(e=>Dc(ge(Mn(vl(e)))))(ds),El=class extends Tl{set(e){return he(Tl.prototype,this,e),e.extends==null?e.hasOwnProperty(t.nameof(e,`extends`))&&this.removeExtends():this.setExtends(e.extends),e.ctors!=null&&(this.getConstructors().forEach(e=>e.remove()),this.addConstructors(e.ctors)),e.staticBlocks!=null&&(this.getStaticBlocks().forEach(e=>e.remove()),this.addStaticBlocks(e.staticBlocks)),e.properties!=null&&(this.getProperties().forEach(e=>e.remove()),this.addProperties(e.properties)),e.getAccessors!=null&&(this.getGetAccessors().forEach(e=>e.remove()),this.addGetAccessors(e.getAccessors)),e.setAccessors!=null&&(this.getSetAccessors().forEach(e=>e.remove()),this.addSetAccessors(e.setAccessors)),e.methods!=null&&(this.getMethods().forEach(e=>e.remove()),this.addMethods(e.methods)),this}getStructure(){let t=this.getExtends(),n=this.isAmbient();return me(Tl.prototype,this,{kind:e.StructureKind.Class,ctors:this.getConstructors().filter(e=>n||!e.isOverload()).map(e=>e.getStructure()),staticBlocks:this.getStaticBlocks().map(e=>e.getStructure()),methods:this.getMethods().filter(e=>n||!e.isOverload()).map(e=>e.getStructure()),properties:this.getProperties().map(e=>e.getStructure()),extends:t?t.getText():void 0,getAccessors:this.getGetAccessors().map(e=>e.getStructure()),setAccessors:this.getSetAccessors().map(e=>e.getStructure())})}extractInterface(t){let{constructors:n,properties:r,methods:i,accessors:a}=Dl(this,!1),o=n.map(e=>e.getParameters().filter(e=>e.isParameterProperty())).flat().filter(t=>t.getName()!=null&&t.getScope()===e.Scope.Public);return{kind:e.StructureKind.Interface,name:Ol(t,this),docs:this.getJsDocs().map(e=>e.getStructure()),typeParameters:this.getTypeParameters().map(e=>e.getStructure()),properties:[...o.map(t=>{let n=t.getParentOrThrow().getJsDocs().map(e=>e.getTags()).flat().filter(H.isJSDocParameterTag).filter(e=>e.getTagName()===`param`&&e.getName()===t.getName()&&e.getComment()!=null).map(e=>e.getCommentText().trim())[0];return{kind:e.StructureKind.PropertySignature,docs:n==null?[]:[{kind:e.StructureKind.JSDoc,description:n}],name:t.getName(),type:t.getType().getText(t),hasQuestionToken:t.hasQuestionToken(),isReadonly:t.isReadonly()}}),...r.map(kl),...a.map(Al)],methods:i.map(jl)}}extractStaticInterface(t){let{constructors:n,properties:r,methods:i,accessors:a}=Dl(this,!0),o=Ol(void 0,this);return{kind:e.StructureKind.Interface,name:t,properties:[...r.map(kl),...a.map(Al)],methods:i.map(jl),constructSignatures:n.map(t=>({kind:e.StructureKind.ConstructSignature,docs:t.getJsDocs().map(e=>e.getStructure()),parameters:t.getParameters().map(e=>({...Ml(e),scope:void 0,isReadonly:!1})),returnType:o}))}}};function Dl(n,r){return{constructors:n.getConstructors().map(e=>e.getOverloads().length>0?e.getOverloads():[e]).flat(),properties:n.getProperties().filter(t=>t.isStatic()===r&&t.getScope()===e.Scope.Public),methods:n.getMethods().filter(t=>t.isStatic()===r&&t.getScope()===e.Scope.Public).map(e=>e.getOverloads().length>0?e.getOverloads():[e]).flat(),accessors:i()};function i(){let i=new t.KeyValueCache;for(let t of[...n.getGetAccessors(),...n.getSetAccessors()])t.isStatic()===r&&t.getScope()===e.Scope.Public&&i.getOrCreate(t.getName(),()=>[]).push(t);return i.getValuesAsArray()}}function Ol(e,n){return e=t.StringUtils.isNullOrWhitespace(e)?void 0:e,e||n.getName()||n.getSourceFile().getBaseNameWithoutExtension().replace(/[^a-zA-Z0-9_$]/g,``)}function kl(t){return{kind:e.StructureKind.PropertySignature,docs:t.getJsDocs().map(e=>e.getStructure()),name:t.getName(),type:t.getType().getText(t),hasQuestionToken:t.hasQuestionToken(),isReadonly:t.isReadonly()}}function Al(t){return{kind:e.StructureKind.PropertySignature,docs:t[0].getJsDocs().map(e=>e.getStructure()),name:t[0].getName(),type:t[0].getType().getText(t[0]),hasQuestionToken:!1,isReadonly:t.every(H.isGetAccessorDeclaration)}}function jl(t){return{kind:e.StructureKind.MethodSignature,docs:t.getJsDocs().map(e=>e.getStructure()),name:t.getName(),hasQuestionToken:t.hasQuestionToken(),returnType:t.getReturnType().getText(t),parameters:t.getParameters().map(Ml),typeParameters:t.getTypeParameters().map(e=>e.getStructure())}}function Ml(e){return{...e.getStructure(),decorators:[]}}var Nl=vl(Ha),Pl=class extends Nl{},Fl=(e=>Cn(_a(fs(Hi(xn(e))))))(ml),Il=class extends Fl{getName(){return`static`}isStatic(){return!0}set(e){return he(Fl.prototype,this,e),this}getStructure(){return me(Fl.prototype,this,{kind:e.StructureKind.ClassStaticBlock})}},Ll=class extends ml{},Rl=(e=>Ji(Cn(_a(tl(ma(Qc(Sn(e))))))))(ml),zl=(e=>wa(Hi(Cn(_a(ma(Wi(ha(e))))))))(ml),Bl=class extends Rl{set(e){return he(Rl.prototype,this,e),e.overloads!=null&&(this.getOverloads().forEach(e=>e.remove()),this.addOverloads(e.overloads)),this}addOverload(e){return this.addOverloads([e])[0]}addOverloads(e){return this.insertOverloads(this.getOverloads().length,e)}insertOverload(e,t){return this.insertOverloads(e,[t])[0]}insertOverloads(e,n){let r=this._context.structurePrinterFactory.forConstructorDeclaration({isAmbient:k(this)});return al({node:this,index:e,structures:n,printStructure:(e,t)=>{r.printOverload(e,t)},getThisStructure:Ze,expectedSyntaxKind:t.SyntaxKind.Constructor})}getStructure(){let t=this.getImplementation()!=null,n=this.isOverload();return me(n&&t?zl.prototype:Rl.prototype,this,r(this));function r(r){if(t&&n)return i();return a();function i(){return{kind:e.StructureKind.ConstructorOverload}}function a(){return t?{kind:e.StructureKind.Constructor,overloads:r.getOverloads().map(e=>e.getStructure())}:{kind:e.StructureKind.Constructor}}}}},Vl=(e=>Cn(_a(wn(ja(ma(ga(Qc(Sn(ia(e))))))))))(ml),Hl=class extends Vl{set(e){return he(Vl.prototype,this,e),this}getSetAccessor(){let e=this.getName(),t=this.isStatic();return this.getParentOrThrow().forEachChild(n=>{if(H.isSetAccessorDeclaration(n)&&n.getName()===e&&n.isStatic()===t)return n})}getSetAccessorOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getSetAccessor(),e??(()=>`Expected to find a corresponding set accessor for ${this.getName()}.`),this)}getStructure(){return me(Vl.prototype,this,{kind:e.StructureKind.GetAccessor})}},Ul=(e=>Cn(aa(ge(wn(ja(ma(ga(Hi(la(kn(ca(Bi(ba(ia(Wi(e))))))))))))))))(ml),Wl=class extends Ul{hasAccessorKeyword(){return this.hasModifier(t.SyntaxKind.AccessorKeyword)}setHasAccessorKeyword(e){return this.toggleModifier(`accessor`,e)}set(e){return he(Ul.prototype,this,e),e.hasAccessorKeyword!=null&&this.setHasAccessorKeyword(e.hasAccessorKeyword),this}remove(){let e=this.getParentOrThrow();switch(e.getKind()){case t.SyntaxKind.ClassDeclaration:super.remove();break;default:throw new t.errors.NotImplementedError(`Not implemented parent syntax kind: ${e.getKindName()}`)}}getStructure(){return me(Ul.prototype,this,{kind:e.StructureKind.Property,hasAccessorKeyword:this.hasAccessorKeyword()})}},Gl=(e=>Cn(_a(wn(ja(ma(ga(Qc(Sn(ia(e))))))))))(ml),Kl=class extends Gl{set(e){return he(Gl.prototype,this,e),this}getGetAccessor(){let e=this.getName(),t=this.isStatic();return this.getParentOrThrow().forEachChild(n=>{if(H.isGetAccessorDeclaration(n)&&n.getName()===e&&n.isStatic()===t)return n})}getGetAccessorOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getGetAccessor(),e??(()=>`Expected to find a corresponding get accessor for ${this.getName()}.`),this)}getStructure(){return me(Gl.prototype,this,{kind:e.StructureKind.SetAccessor})}},ql=Ja(H),Jl=class extends ql{getName(){return this.getNameNode().getText()}getNameNode(){let e=this.getCallExpression();if(e)return n(e.getExpression());return n(this._getInnerExpression());function n(e){let n=r(e);if(!H.isIdentifier(n))throw new t.errors.NotImplementedError(`Expected the decorator expression '${n.getText()}' to be an identifier. Please deal directly with 'getExpression()' on the decorator to handle more complex scenarios.`);return n}function r(e){return H.isPropertyAccessExpression(e)?e.getNameNode():e}}getFullName(){let e=this.getSourceFile();return this.isDecoratorFactory()?this.getCallExpression().getExpression().getText():this.compilerNode.expression.getText(e.compilerNode)}isDecoratorFactory(){return H.isCallExpression(this._getInnerExpression())}setIsDecoratorFactory(e){if(this.isDecoratorFactory()===e)return this;if(e){let e=this._getInnerExpression(),t=e.getText();kt({parent:this,insertPos:e.getStart(),newText:`${t}()`,replacing:{textLength:t.length},customMappings:t=>[{currentNode:e,newNode:t.expression.expression}]})}else{let e=this.getCallExpressionOrThrow(),t=e.getExpression(),n=t.getText();kt({parent:this,insertPos:e.getStart(),newText:`${n}`,replacing:{textLength:e.getWidth()},customMappings:e=>[{currentNode:t,newNode:e.expression}]})}return this}getCallExpressionOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getCallExpression(),e??`Expected to find a call expression.`,this)}getCallExpression(){let e=this._getInnerExpression();return H.isCallExpression(e)?e:void 0}getArguments(){return this.getCallExpression()?.getArguments()??[]}getTypeArguments(){return this.getCallExpression()?.getTypeArguments()??[]}addTypeArgument(e){return this.getCallExpressionOrThrow().addTypeArgument(e)}addTypeArguments(e){return this.getCallExpressionOrThrow().addTypeArguments(e)}insertTypeArgument(e,t){return this.getCallExpressionOrThrow().insertTypeArgument(e,t)}insertTypeArguments(e,t){return this.getCallExpressionOrThrow().insertTypeArguments(e,t)}removeTypeArgument(e){let n=this.getCallExpression();if(n==null)throw new t.errors.InvalidOperationError(`Cannot remove a type argument from a decorator that has no type arguments.`);return n.removeTypeArgument(e),this}addArgument(e){return this.addArguments([e])[0]}addArguments(e){return this.insertArguments(this.getArguments().length,e)}insertArgument(e,t){return this.insertArguments(e,[t])[0]}insertArguments(e,t){return this.setIsDecoratorFactory(!0),this.getCallExpressionOrThrow().insertArguments(e,t)}removeArgument(e){let n=this.getCallExpression();if(n==null)throw new t.errors.InvalidOperationError(`Cannot remove an argument from a decorator that has no arguments.`);return n.removeArgument(e),this}remove(){let e=this.getStartLinePos(),n=this.getPreviousSiblingIfKind(t.SyntaxKind.Decorator);n!=null&&n.getStartLinePos()===e?It({children:[this],removePrecedingSpaces:!0}):Lt({children:[this],getSiblingFormatting:(t,n)=>n.getStartLinePos()===e?_e.Space:_e.Newline})}_getInnerExpression(){let e=this.getExpression();for(;H.isParenthesizedExpression(e);)e=e.getExpression();return e}set(e){return he(ql.prototype,this,e),e.name!=null&&this.getNameNode().replaceWithText(e.name),e.arguments!=null&&(this.setIsDecoratorFactory(!0),this.getArguments().map(e=>this.removeArgument(e)),this.addArguments(e.arguments)),e.typeArguments!=null&&e.typeArguments.length>0&&(this.setIsDecoratorFactory(!0),this.getTypeArguments().map(e=>this.removeTypeArgument(e)),this.addTypeArguments(e.typeArguments)),this}getStructure(){let t=this.isDecoratorFactory();return me(ql.prototype,this,{kind:e.StructureKind.Decorator,name:this.getName(),arguments:t?this.getArguments().map(e=>e.getText()):void 0,typeArguments:t?this.getTypeArguments().map(e=>e.getText()):void 0})}};function Yl(e){return class extends e{getTypeExpression(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.typeExpression)}getTypeExpressionOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getTypeExpression(),e??`Expected to find a JS doc type expression.`,this)}getName(){return this.getNameNode().getText()}getNameNode(){return this._getNodeFromCompilerNode(this.compilerNode.name)}isBracketed(){return this.compilerNode.isBracketed}}}function Xl(e){return class extends e{getTypeExpression(){let e=this._getNodeFromCompilerNodeIfExists(this.compilerNode.typeExpression);if(!(e!=null&&e.getWidth()===0))return e}getTypeExpressionOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getTypeExpression(),e??`Expected to find the JS doc tag's type expression.`,this)}}}function Zl(e){return class extends e{getTypeParameters(){return this.compilerNode.typeParameters.map(e=>this._getNodeFromCompilerNode(e)).filter(e=>e.getWidth()>0)}}}function Ql(e){return e.replace(/^\/\*\*[^\S\n]*\n?/,``).replace(/(\r?\n)?[^\S\n]*\*\/$/,``).split(/\n/).map(e=>{let t=n(e);if(t===-1)return e;let r=e[t+1]===` `?t+2:t+1;return e.substring(r)}).join(`
|
|
31381
31387
|
`);function n(e){for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===o.ASTERISK)return n;if(!t.StringUtils.isWhitespaceCharCode(r))break}return-1}}var $l=H,eu=class extends $l{isMultiLine(){return this.getText().includes(`
|
|
31382
|
-
`)}getTags(){return this.compilerNode.tags?.map(e=>this._getNodeFromCompilerNode(e))??[]}getInnerText(){return Ql(this.getText())}getComment(){if(this.compilerNode.comment!=null)return typeof this.compilerNode.comment==`string`?this.compilerNode.comment:this.compilerNode.comment.map(e=>this._getNodeFromCompilerNodeIfExists(e))}getCommentText(){return typeof this.compilerNode.comment==`string`?this.compilerNode.comment:t.ts.getTextOfJSDocComment(this.compilerNode.comment)}getDescription(){let e=this.getSourceFile().getFullText(),n=this.getTags()[0]?.getStart()??this.getEnd()-2,r=i(this);return Ql(e.substring(r,Math.max(r,a())));function i(t){let n=t.getStart()+3;return e.charCodeAt(n)===o.SPACE?n+1:n}function a(){return Me(e,Me(e,n,e=>e===o.NEWLINE||!t.StringUtils.isWhitespaceCharCode(e)&&e!==o.ASTERISK),e=>e!==o.NEWLINE&&e!==o.CARRIAGE_RETURN)}}setDescription(e){let t=this.getTags(),n=this.getStart()+3,r=t.length>0?Me(this._sourceFile.getFullText(),t[0].getStart(),e=>e===o.ASTERISK)-1:this.getEnd()-2;return tn({parent:this,newText:i.call(this),replacePos:n,replacingLength:r-n}),this;function i(){let t=this.getIndentationText(),n=this._context.manipulationSettings.getNewLineKindAsString(),r=I(this._getWriter(),e).split(/\r?\n/),i=r[0].length===0,a=r.length===1&&(this.compilerNode.tags?.length??0)===0,o=a?r[0]:r.map(e=>e.length===0?`${t} *`:`${t} * ${e}`).slice(+!!i).join(n);return a?` `+o+` `:n+o+n+t+` `}}addTag(e){return this.addTags([e])[0]}addTags(e){return this.insertTags(this.compilerNode.tags?.length??0,e)}insertTag(e,t){return this.insertTags(e,[t])[0]}insertTags(e,n){if(t.ArrayUtils.isNullOrEmpty(n))return[];let r=this._getWriterWithQueuedIndentation(),i=this.getTags();if(e=et(e,i.length),i.length===0&&!this.isMultiLine()){let e=this._context.structurePrinterFactory.forJSDoc();this.replaceWithText(t=>{e.printText(t,{description:this.getDescription(),tags:n})})}else{let t=this._context.structurePrinterFactory.forJSDocTag({printStarsOnNewLine:!0});r.newLine().write(` * `),t.printTexts(r,n),r.newLine().write(` *`),r.conditionalWrite(e<i.length,` `);let o=a.call(this),c=s.call(this);kt({parent:this,insertPos:o,replacing:{textLength:c-o},newText:r.toString()})}return Ye(i,this.getTags(),e,!1);function a(){let n=e<i.length?i[e].getStart():this.getEnd()-2,r=this.getStart()+3;return Math.max(r,Me(this.getSourceFile().getFullText(),n,e=>!t.StringUtils.isWhitespaceCharCode(e)&&e!==o.ASTERISK))}function s(){return e<i.length?i[e].getStart():this.getEnd()-1}}remove(){It({children:[this],removeFollowingSpaces:!0,removeFollowingNewLines:!0})}set(e){return he($l.prototype,this,e),e.tags==null?(e.description!=null&&this.setDescription(e.description),this):this.replaceWithText(t=>{this._context.structurePrinterFactory.forJSDoc().printText(t,{description:e.description??this.getDescription(),tags:e.tags})})}getStructure(){return me($l.prototype,this,{kind:e.StructureKind.JSDoc,description:this.getDescription(),tags:this.getTags().map(e=>e.getStructure())})}},tu=class extends H{},nu=ya(tu),ru=class extends nu{},iu=class extends tu{getElementTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.elementType)}},au=class extends tu{getCheckType(){return this._getNodeFromCompilerNode(this.compilerNode.checkType)}getExtendsType(){return this._getNodeFromCompilerNode(this.compilerNode.extendsType)}getTrueType(){return this._getNodeFromCompilerNode(this.compilerNode.trueType)}getFalseType(){return this._getNodeFromCompilerNode(this.compilerNode.falseType)}},ou=ha(tu),su=class extends ou{},cu=ja(Wi(su)),lu=class extends cu{},uu=Ja(ru),du=class extends uu{},fu=wa(su),pu=class extends fu{},mu=class extends ru{setArgument(e){let t=this.getArgument();if(H.isLiteralTypeNode(t)){let n=t.getLiteral();if(H.isStringLiteral(n))return n.setLiteralValue(e),this}return t.replaceWithText(t=>t.quote(e),this._getWriterWithQueuedChildIndentation()),this}getArgument(){return this._getNodeFromCompilerNode(this.compilerNode.argument)}setQualifier(e){let n=this.getQualifier();return n==null?kt({insertPos:this.getFirstChildByKindOrThrow(t.SyntaxKind.CloseParenToken).getEnd(),parent:this,newText:this._getWriterWithQueuedIndentation().write(`.`).write(e).toString()}):n.replaceWithText(e,this._getWriterWithQueuedChildIndentation()),this}getQualifierOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getQualifier(),e??(()=>`Expected to find a qualifier for the import type: ${this.getText()}`),this)}getQualifier(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.qualifier)}getAttributes(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.attributes)}getAttributesOrThrow(e){return t.errors.throwIfNullOrUndefined(this._getNodeFromCompilerNodeIfExists(this.compilerNode.attributes),e??`Could not find import type assertion container.`,this)}},hu=class extends tu{getObjectTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.objectType)}getIndexTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.indexType)}},gu=class extends tu{getTypeParameter(){return this._getNodeFromCompilerNode(this.compilerNode.typeParameter)}},_u=class extends tu{getTypeNodes(){return this.compilerNode.types.map(e=>this._getNodeFromCompilerNode(e))}},vu=class extends tu{getLiteral(){let e=this.compilerNode.literal;return this._getNodeFromCompilerNode(e)}},yu=class extends tu{getNameTypeNode(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.nameType)}getNameTypeNodeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getNameTypeNode(),e??`Type did not exist.`,this)}getReadonlyToken(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.readonlyToken)}getReadonlyTokenOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getReadonlyToken(),e??`Readonly token did not exist.`,this)}getQuestionToken(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.questionToken)}getQuestionTokenOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getQuestionToken(),e??`Question token did not exist.`,this)}getTypeParameter(){return this._getNodeFromCompilerNode(this.compilerNode.typeParameter)}getTypeNode(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.type)}getTypeNodeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getTypeNode(),e??`Type did not exist, but was expected to exist.`,this)}},bu=(e=>ba(ca(On(Hi(ra(e))))))(tu),xu=class extends bu{getTypeNode(){return super.getTypeNode()}removeType(){throw new t.errors.InvalidOperationError(`Cannot remove the type of a named tuple member.`)}},Su=class extends tu{getTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.type)}setType(e){return this.getTypeNode().replaceWithText(e),this}},Cu=class extends tu{getTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.type)}},wu=class extends tu{getHead(){return this._getNodeFromCompilerNode(this.compilerNode.head)}getTemplateSpans(){return this.compilerNode.templateSpans.map(e=>this._getNodeFromCompilerNode(e))}setLiteralValue(e){let t=this.getChildIndex(),n=this.getParentSyntaxList()??this.getParentOrThrow();return Zt({sourceFile:this._sourceFile,start:this.getStart()+1,replacingLength:this.getWidth()-2,newText:e}),n.getChildAtIndex(t)}},Tu=class extends tu{},Eu=class extends tu{getElements(){return this.compilerNode.elements.map(e=>this._getNodeFromCompilerNode(e))}},Du=(e=>wa(ba(Hi(ge(Mn(Wi(ra(e))))))))(ds),Ou=class extends Du{set(e){return he(Du.prototype,this,e),this}getStructure(){return me(Du.prototype,this,{kind:e.StructureKind.TypeAlias,type:this.getTypeNodeOrThrow().getText()})}},ku=Sa(tu),Au=class extends ku{},ju=class extends tu{getOperator(){return this.compilerNode.operator}getTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.type)}};e.TypeParameterVariance=void 0,(function(e){e[e.None=0]=`None`,e[e.In=1]=`In`,e[e.Out=2]=`Out`,e[e.InOut=3]=`InOut`})(e.TypeParameterVariance||={});var Mu=(e=>Wi(ra(e)))(H),Nu=class extends Mu{isConst(){return this.hasModifier(t.SyntaxKind.ConstKeyword)}setIsConst(e){return this.toggleModifier(`const`,e)}getConstraint(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.constraint)}getConstraintOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getConstraint(),e??`Expected to find the type parameter's constraint.`,this)}setConstraint(e){if(e=this.getParentOrThrow()._getTextWithQueuedChildIndentation(e),t.StringUtils.isNullOrWhitespace(e))return this.removeConstraint(),this;let n=this.getConstraint();if(n!=null)return n.replaceWithText(e),this;let r=this.getNameNode();return kt({parent:this,insertPos:r.getEnd(),newText:` extends ${e}`}),this}removeConstraint(){return Pu(this.getConstraint(),t.SyntaxKind.ExtendsKeyword),this}getDefault(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.default)}getDefaultOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getDefault(),e??`Expected to find the type parameter's default.`,this)}setDefault(e){if(e=this.getParentOrThrow()._getTextWithQueuedChildIndentation(e),t.StringUtils.isNullOrWhitespace(e))return this.removeDefault(),this;let n=this.getDefault();if(n!=null)return n.replaceWithText(e),this;let r=this.getConstraint()||this.getNameNode();return kt({parent:this,insertPos:r.getEnd(),newText:` = ${e}`}),this}removeDefault(){return Pu(this.getDefault(),t.SyntaxKind.EqualsToken),this}setVariance(t){return this.toggleModifier(`in`,(t&e.TypeParameterVariance.In)!==0),this.toggleModifier(`out`,(t&e.TypeParameterVariance.Out)!==0),this}getVariance(){let n=e.TypeParameterVariance.None;return this.hasModifier(t.SyntaxKind.InKeyword)&&(n|=e.TypeParameterVariance.In),this.hasModifier(t.SyntaxKind.OutKeyword)&&(n|=e.TypeParameterVariance.Out),n}remove(){let e=this.getParentSyntaxListOrThrow();e.getChildrenOfKind(t.SyntaxKind.TypeParameter).length===1?n():Ut(this);function n(){It({children:[e.getPreviousSiblingIfKindOrThrow(t.SyntaxKind.LessThanToken),e,e.getNextSiblingIfKindOrThrow(t.SyntaxKind.GreaterThanToken)]})}}set(e){return he(Mu.prototype,this,e),e.isConst!=null&&this.setIsConst(e.isConst),e.constraint==null?e.hasOwnProperty(t.nameof(e,`constraint`))&&this.removeConstraint():this.setConstraint(e.constraint),e.default==null?e.hasOwnProperty(t.nameof(e,`default`))&&this.removeDefault():this.setDefault(e.default),e.variance!=null&&this.setVariance(e.variance),this}getStructure(){let t=this.getConstraint(),n=this.getDefault();return me(Mu.prototype,this,{kind:e.StructureKind.TypeParameter,isConst:this.isConst(),constraint:t?.getText({trimLeadingIndentation:!0}),default:n?n.getText({trimLeadingIndentation:!0}):void 0,variance:this.getVariance()})}};function Pu(e,t){e!=null&&It({children:[e.getPreviousSiblingIfKindOrThrow(t),e],removePrecedingSpaces:!0})}var Fu=class extends tu{getParameterNameNode(){return this._getNodeFromCompilerNode(this.compilerNode.parameterName)}hasAssertsModifier(){return this.compilerNode.assertsModifier!=null}getAssertsModifier(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.assertsModifier)}getAssertsModifierOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getAssertsModifier(),e??`Expected to find an asserts modifier.`,this)}getTypeNode(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.type)}getTypeNodeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getTypeNode(),e??`Expected to find a type node.`,this)}},Iu=class extends ru{getExprName(){return this._getNodeFromCompilerNode(this.compilerNode.exprName)}},Lu=class extends ru{getTypeName(){return this._getNodeFromCompilerNode(this.compilerNode.typeName)}},Ru=class extends tu{getTypeNodes(){return this.compilerNode.types.map(e=>this._getNodeFromCompilerNode(e))}},zu=class extends tu{},Bu=class extends zu{},Vu=H,Hu=class extends Vu{getTagName(){return this.getTagNameNode().getText()}getTagNameNode(){return this._getNodeFromCompilerNode(this.compilerNode.tagName)}setTagName(e){return this.set({tagName:e})}getComment(){if(this.compilerNode.comment!=null)return typeof this.compilerNode.comment==`string`?this.compilerNode.comment:this.compilerNode.comment.map(e=>this._getNodeFromCompilerNodeIfExists(e))}getCommentText(){return typeof this.compilerNode.comment==`string`?this.compilerNode.comment:t.ts.getTextOfJSDocComment(this.compilerNode.comment)}remove(){let e=this.getParentOrThrow().getStart()+3,t=Ku(this),n=t==null,r=i.call(this);It({children:[this],customRemovalPos:r,customRemovalEnd:Gu(this,t),replaceTrivia:a.call(this)});function i(){return Math.max(e,qu(this,this.getStart()))}function a(){return r===e&&n?``:`${this._context.manipulationSettings.getNewLineKindAsString()}${this.getParentOrThrow().getIndentationText()} `+(n?``:`* `)}}set(e){return he(Vu.prototype,this,e),e.text!=null||e.tagName!=null?this.replaceWithText(t=>{this._context.structurePrinterFactory.forJSDocTag({printStarsOnNewLine:!0}).printText(t,{tagName:e.tagName??this.getTagName(),text:e.text==null?Uu(this):e.text})}):this}replaceWithText(e){let t=I(this._getWriterWithQueuedIndentation(),e),n=this.getParentOrThrow(),r=this.getChildIndex(),i=this.getStart();return kt({parent:n,insertPos:i,newText:t,replacing:{textLength:Wu(this)-i}}),n.getChildren()[r]}getStructure(){let t=Uu(this);return me(Vu.prototype,this,{kind:e.StructureKind.JSDocTag,tagName:this.getTagName(),text:t.length===0?void 0:t})}};function Uu(e){let t=e.getSourceFile().getFullText(),n=e.getTagNameNode().getEnd(),r=Wu(e),i=Math.min(t.charCodeAt(n)===o.SPACE?n+1:n,r);return Ql(t.substring(i,r))}function Wu(e){return qu(e,Gu(e))}function Gu(e,t){return t??=Ku(e),t==null?e.getParentOrThrow().getEnd()-2:t.getStart()}function Ku(e){let n=e.getParentIfKindOrThrow(t.SyntaxKind.JSDoc).getTags();return n[n.indexOf(e)+1]}function qu(e,n){return Me(e.getSourceFile().getFullText(),n,e=>e!==o.ASTERISK&&!t.StringUtils.isWhitespaceCharCode(e))}var Ju=class extends Hu{},Yu=class extends Hu{},Xu=class extends Hu{},Zu=class extends Hu{},Qu=class extends Hu{},$u=class extends Hu{},ed=ha(zu),td=class extends ed{},nd=class extends Hu{},rd=class extends H{},id=class extends H{},ad=class extends H{},od=class extends H{},sd=class extends zu{getTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.type)}},cd=class extends H{getName(){return this._getNodeFromCompilerNode(this.compilerNode.name)}},ld=class extends zu{getTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.type)}isPostfix(){return this.compilerNode.postfix}},ud=class extends zu{getTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.type)}isPostfix(){return this.compilerNode.postfix}},dd=class extends zu{getTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.type)}},fd=Xl(Hu),pd=class extends fd{},md=class extends Hu{},hd=Yl(Hu),gd=class extends hd{},_d=class extends Hu{},J=Yl(Hu),vd=class extends J{},yd=class extends Hu{},bd=class extends Hu{},xd=class extends Hu{},Sd=Xl(Hu),Cd=class extends Sd{},wd=Xl(Hu),Td=class extends wd{},Ed=Xl(Hu),Dd=class extends Ed{},Od=class extends zu{getTypeNode(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.type)}},kd=class{#e;constructor(e){this.#e=e}get compilerObject(){return this.#e}getName(){return this.compilerObject.name}getText(){return this.compilerObject.text??[]}},Ad=Zl(Hu),jd=class extends Ad{getConstraint(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.constraint)}getConstraintOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getConstraint(),e??`Expected to find the JS doc template tag's constraint.`,this)}},Md=class extends H{},Nd=Xl(Hu),Pd=class extends Nd{},Fd=Xl(Hu),Id=class extends Fd{},Ld=class extends Hu{},Rd=class extends tu{getTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.type)}},zd=class extends zu{isArrayType(){return this.compilerNode.isArrayType}getPropertyTags(){return this.compilerNode.jsDocPropertyTags?this.compilerNode.jsDocPropertyTags.map(e=>this._getNodeFromCompilerNode(e)):void 0}},Bd=class extends Hu{getTypeExpression(){let e=this.compilerNode.typeExpression;if(!(e!=null&&e.pos===e.end))return this._getNodeFromCompilerNodeIfExists(this.compilerNode.typeExpression)}},Vd=class extends Hu{},Hd=class extends zu{},Ud=class extends zu{getTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.type)}},Wd=class extends H{remove(){Rt({children:[this],getSiblingFormatting:()=>_e.Newline})}},Gd=(e=>_a(Dc(Hi(ge(Mn(Wi(ra(e))))))))(ds),Kd=class extends Gd{set(e){return he(Gd.prototype,this,e),e.isConst!=null&&this.setIsConstEnum(e.isConst),e.members!=null&&(this.getMembers().forEach(e=>e.remove()),this.addMembers(e.members)),this}addMember(e){return this.addMembers([e])[0]}addMembers(e){return this.insertMembers(this.getMembers().length,e)}insertMember(e,t){return this.insertMembers(e,[t])[0]}insertMembers(e,t){if(t.length===0)return[];let n=this.getMembersWithComments();e=et(e,n.length);let r=this._getWriterWithChildIndentation();return this._context.structurePrinterFactory.forEnumMember().printTexts(r,t),jt({parent:this.getChildSyntaxListOrThrow(),currentNodes:n,insertIndex:e,newText:r.toString(),useNewLines:!0,useTrailingCommas:this._context.manipulationSettings.getUseTrailingCommas()}),Ye(n,this.getMembersWithComments(),e,!i());function i(){return t instanceof Array?t.every(e=>typeof e==`object`):!1}}getMember(e){return s(this.getMembers(),e)}getMemberOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getMember(e),()=>l(`enum member`,e))}getMembers(){return this.compilerNode.members.map(e=>this._getNodeFromCompilerNode(e))}getMembersWithComments(){let e=this.compilerNode;return T.getContainerArray(e,this.getSourceFile().compilerNode).map(e=>this._getNodeFromCompilerNode(e))}setIsConstEnum(e){return this.toggleModifier(`const`,e)}isConstEnum(){return this.getConstKeyword()!=null}getConstKeyword(){return this.getFirstModifierByKind(t.SyntaxKind.ConstKeyword)}getStructure(){return me(Gd.prototype,this,{kind:e.StructureKind.Enum,isConst:this.isConstEnum(),members:this.getMembers().map(e=>e.getStructure())})}},qd=(e=>Hi(Bi(ia(e))))(H),Jd=class extends qd{getValue(){return this._context.typeChecker.getConstantValue(this)}setValue(e){let n;if(typeof e==`string`){let r=this._context.manipulationSettings.getQuoteKind();n=r+t.StringUtils.escapeForWithinString(e,r)+r}else n=e.toString();return this.setInitializer(n),this}remove(){let e=[this],n=this.getNextSiblingIfKind(t.SyntaxKind.CommaToken);n!=null&&e.push(n),Rt({children:e,getSiblingFormatting:()=>_e.Newline})}set(e){return he(qd.prototype,this,e),e.value==null?e.hasOwnProperty(t.nameof(e,`value`))&&e.initializer==null&&this.removeInitializer():this.setValue(e.value),this}getStructure(){return me(qd.prototype,this,{kind:e.StructureKind.EnumMember,value:void 0})}},Yd=class extends H{getTypeNodes(){return this.compilerNode.types?.map(e=>this._getNodeFromCompilerNode(e))??[]}getToken(){return this.compilerNode.token}removeExpression(e){let t=this.getTypeNodes(),n=typeof e==`number`?r(e):e;if(t.length===1){let e=this.getParentSyntaxListOrThrow().getChildren();e.length===1?It({children:[e[0].getParentSyntaxListOrThrow()],removePrecedingSpaces:!0}):It({children:[this],removePrecedingSpaces:!0})}else Ut(n);return this;function r(e){return t[et(e,t.length-1)]}}},Xd=class extends H{remove(){Vt(this)}},Zd=(e=>wa(Cn(Hi(ha(e)))))(Xd),Qd=class extends Zd{set(e){return he(Zd.prototype,this,e),this}getStructure(){return me(Zd.prototype,this,{kind:e.StructureKind.CallSignature})}},$d=class extends Xd{},ef=(e=>wa(Cn(Hi(ha(e)))))(Xd),tf=class extends ef{set(e){return he(ef.prototype,this,e),this}getStructure(){return me(ef.prototype,this,{kind:e.StructureKind.ConstructSignature})}},nf=(e=>ua(Cn(Hi(la(Wi(e))))))(Xd),rf=class extends nf{getKeyName(){return this.getKeyNameNode().getText()}setKeyName(e){t.errors.throwIfWhitespaceOrNotString(e,`name`),this.getKeyName()!==e&&this.getKeyNameNode().replaceWithText(e,this._getWriterWithQueuedChildIndentation())}getKeyNameNode(){let e=this.compilerNode.parameters[0];return this._getNodeFromCompilerNode(e.name)}getKeyType(){return this.getKeyNameNode().getType()}setKeyType(e){t.errors.throwIfWhitespaceOrNotString(e,`type`);let n=this.getKeyTypeNode();return n.getText()===e||n.replaceWithText(e,this._getWriterWithQueuedChildIndentation()),this}getKeyTypeNode(){let e=this.compilerNode.parameters[0];return this._getNodeFromCompilerNode(e.type)}set(e){return he(nf.prototype,this,e),e.keyName!=null&&this.setKeyName(e.keyName),e.keyType!=null&&this.setKeyType(e.keyType),this}getStructure(){let t=this.getKeyTypeNode();return me(nf.prototype,this,{kind:e.StructureKind.IndexSignature,keyName:this.getKeyName(),keyType:t.getText()})}},af=(e=>Sa(_a(Pi(Li(wa(Hi(ge(Dc(Mn(Wi(ra(e))))))))))))(ds),of=class extends af{getBaseTypes(){return this.getType().getBaseTypes()}getBaseDeclarations(){return this.getType().getBaseTypes().map(e=>e.getSymbol()?.getDeclarations()??[]).flat()}getImplementations(){return this.getNameNode().getImplementations()}set(e){return he(af.prototype,this,e),this}getStructure(){return me(af.prototype,this,{kind:e.StructureKind.Interface})}},sf=(e=>Cn(Hi(ca(wa(ha(ia(e)))))))(Xd),cf=class extends sf{set(e){return he(sf.prototype,this,e),this}getStructure(){return me(sf.prototype,this,{kind:e.StructureKind.MethodSignature})}},lf=(e=>Cn(Hi(la(ca(Bi(ba(ia(Wi(e)))))))))(Xd),uf=class extends lf{set(e){return he(lf.prototype,this,e),this}getStructure(){return me(lf.prototype,this,{kind:e.StructureKind.PropertySignature})}};function df(e){return class extends e{getAttributes(){return this.compilerNode.attributes.properties.map(e=>this._getNodeFromCompilerNode(e))}getAttributeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getAttribute(e),()=>l(`attribute`,e))}getAttribute(e){return s(this.getAttributes(),e)}addAttribute(e){return this.addAttributes([e])[0]}addAttributes(e){return this.insertAttributes(this.compilerNode.attributes.properties.length,e)}insertAttribute(e,t){return this.insertAttributes(e,[t])[0]}insertAttributes(e,n){if(n.length===0)return[];let r=this.compilerNode.attributes.properties.length;e=et(e,r);let i=e===0?this.getTagNameNode().getEnd():this.getAttributes()[e-1].getEnd(),a=this._getWriterWithQueuedChildIndentation();return new Wn(this._context.structurePrinterFactory.forJsxAttributeDecider()).printText(a,n),kt({insertPos:i,newText:` `+a.toString(),parent:this.getNodeProperty(`attributes`).getFirstChildByKindOrThrow(t.SyntaxKind.SyntaxList)}),Ye(r,this.getAttributes(),e,!1)}set(t){return he(e.prototype,this,t),t.attributes!=null&&(this.getAttributes().forEach(e=>e.remove()),this.addAttributes(t.attributes)),this}getStructure(){return me(e.prototype,this,{attributes:this.getAttributes().map(e=>e.getStructure())})}}}function ff(e){return class extends e{getTagNameNode(){return this._getNodeFromCompilerNode(this.compilerNode.tagName)}set(t){return he(e.prototype,this,t),t.name!=null&&this.getTagNameNode().replaceWithText(t.name),this}getStructure(){return me(e.prototype,this,{name:this.getTagNameNode().getText()})}}}function pf(e){return class extends e{getText(){return this.compilerNode.text}getDefinitionNodes(){return this.getDefinitions().map(e=>e.getDeclarationNode()).filter(e=>e!=null)}getDefinitions(){return this._context.languageService.getDefinitions(this)}}}var mf=Ka(H),hf=class extends mf{},gf=pf(Ji(Xi(Ha))),_f=class extends gf{getImplementations(){return this._context.languageService.getImplementations(this)}},vf=pf(Ji(Xi(H))),yf=class extends vf{},bf=class extends H{getLeft(){return this._getNodeFromCompilerNode(this.compilerNode.left)}getRight(){return this._getNodeFromCompilerNode(this.compilerNode.right)}},xf=H,Sf=class extends xf{getNameNode(){return this._getNodeFromCompilerNode(this.compilerNode.name)}setName(e){return this.getNameNode().replaceWithText(t=>{typeof e==`object`?this._context.structurePrinterFactory.forJsxNamespacedName().printText(t,e):t.write(e)}),this}getInitializerOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getInitializer(),e??`Expected to find an initializer for the JSX attribute '${this.getNameNode().getText()}'`,this)}getInitializer(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.initializer)}setInitializer(e){let n=I(this._getWriterWithQueuedIndentation(),e);if(t.StringUtils.isNullOrWhitespace(n))return this.removeInitializer(),this;let r=this.getInitializer();return r==null?(kt({insertPos:this.getNameNode().getEnd(),parent:this,newText:`=${n}`}),this):(r.replaceWithText(n),this)}removeInitializer(){let e=this.getInitializer();return e==null||It({children:[e.getPreviousSiblingIfKindOrThrow(t.SyntaxKind.EqualsToken),e],removePrecedingSpaces:!0,removePrecedingNewLines:!0}),this}remove(){It({children:[this],removePrecedingNewLines:!0,removePrecedingSpaces:!0})}set(e){return he(xf.prototype,this,e),e.name!=null&&this.setName(e.name),e.initializer==null?e.hasOwnProperty(t.nameof(e,`initializer`))&&this.removeInitializer():this.setInitializer(e.initializer),this}getStructure(){let t=this.getInitializer(),n=this.getNameNode();return me(xf.prototype,this,{name:n instanceof _f?n.getText():n.getStructure(),kind:e.StructureKind.JsxAttribute,initializer:t?.getText()})}},Cf=(e=>ff(e))(H),wf=class extends Cf{},Tf=class extends Ma{},Ef=Ha,Df=class extends Ef{getJsxChildren(){return this.compilerNode.children.map(e=>this._getNodeFromCompilerNode(e))}getOpeningElement(){return this._getNodeFromCompilerNode(this.compilerNode.openingElement)}getClosingElement(){return this._getNodeFromCompilerNode(this.compilerNode.closingElement)}setBodyText(e){let t=ln(this._getWriterWithIndentation(),e);return Of(this,t),this}setBodyTextInline(e){let t=this._getWriterWithQueuedChildIndentation();return re(t,e),t.isLastNewLine()&&(t.setIndentationLevel(Math.max(0,this.getIndentationLevel()-1)),t.write(``)),Of(this,t.toString()),this}set(e){if(he(Ef.prototype,this,e),e.attributes!=null){let t=this.getOpeningElement();t.getAttributes().forEach(e=>e.remove()),t.addAttributes(e.attributes)}if(e.children!=null)throw new t.errors.NotImplementedError(`Setting JSX children is currently not implemented. Please open an issue if you need this.`);return e.bodyText==null?e.hasOwnProperty(t.nameof(e,`bodyText`))&&this.setBodyTextInline(``):this.setBodyText(e.bodyText),e.name!=null&&(this.getOpeningElement().getTagNameNode().replaceWithText(e.name),this.getClosingElement().getTagNameNode().replaceWithText(e.name)),this}getStructure(){let t=this.getOpeningElement(),n=me(Ef.prototype,this,{kind:e.StructureKind.JsxElement,name:t.getTagNameNode().getText(),attributes:t.getAttributes().map(e=>e.getStructure()),children:void 0,bodyText:un(this)});return delete n.children,n}};function Of(e,t){let n=e.getOpeningElement(),r=e.getClosingElement();kt({insertPos:n.getEnd(),newText:t,parent:e.getChildSyntaxListOrThrow(),replacing:{textLength:r.getStart()-n.getEnd()}})}var kf=Wa(On(Ma)),Af=class extends kf{},jf=class extends Ha{getJsxChildren(){return this.compilerNode.children.map(e=>this._getNodeFromCompilerNode(e))}getOpeningFragment(){return this._getNodeFromCompilerNode(this.compilerNode.openingFragment)}getClosingFragment(){return this._getNodeFromCompilerNode(this.compilerNode.closingFragment)}},Mf=H,Nf=class extends Mf{getNamespaceNode(){return this._getNodeFromCompilerNode(this.compilerNode.namespace)}getNameNode(){return this._getNodeFromCompilerNode(this.compilerNode.name)}set(e){return this.getNamespaceNode().replaceWithText(e.namespace),this.getNameNode().replaceWithText(e.name),this}getStructure(){return{namespace:this.getNamespaceNode().getText(),name:this.getNameNode().getText()}}},Pf=(e=>df(ff(e)))(Ma),Ff=class extends Pf{},If=class extends Ma{},Lf=(e=>df(ff(e)))(Ha),Rf=class extends Lf{set(e){return he(Lf.prototype,this,e),this}getStructure(){return me(Lf.prototype,this,{kind:e.StructureKind.JsxSelfClosingElement})}},zf=Ka(H),Bf=class extends zf{remove(){It({children:[this],removePrecedingNewLines:!0,removePrecedingSpaces:!0})}set(e){return he(zf.prototype,this,e),e.expression!=null&&this.setExpression(e.expression),this}getStructure(){return me(zf.prototype,this,{kind:e.StructureKind.JsxSpreadAttribute,expression:this.getExpression().getText()})}},Vf=Ui(H),Hf=class extends Vf{containsOnlyTriviaWhiteSpaces(){let e=this.compilerNode;return typeof e.containsOnlyWhiteSpaces==`boolean`?e.containsOnlyWhiteSpaces:this.compilerNode.containsOnlyTriviaWhiteSpaces}},Uf=ho,Wf=class extends Uf{getLiteralValue(){let e=this.compilerNode.text;if(typeof BigInt>`u`)throw new t.errors.InvalidOperationError(`Runtime environment does not support BigInts. Perhaps work with the text instead?`);let n=e.substring(0,e.length-1);return BigInt(n)}setLiteralValue(e){if(typeof e!=`bigint`)throw new t.errors.ArgumentTypeError(`value`,`bigint`,typeof e);return Zt({sourceFile:this._sourceFile,start:this.getStart(),replacingLength:this.getWidth(),newText:e.toString()+`n`}),this}},Gf=Ha,Kf=class extends Gf{getLiteralValue(){return Xf(this)}setLiteralValue(e){return Yf(this,e)}},qf=Ha,Jf=class extends qf{getLiteralValue(){return Xf(this)}setLiteralValue(e){return Yf(this,e)}};function Yf(e,t){if(Xf(e)===t)return e;let n=e.getParentSyntaxList()||e.getParentOrThrow(),r=e.getChildIndex();return e.replaceWithText(t?`true`:`false`),n.getChildAtIndex(r)}function Xf(e){return e.getKind()===t.SyntaxKind.TrueKeyword}var Zf=Ha,Qf=class extends Zf{},$f=ho,ep=class extends $f{getLiteralValue(){let e=this.compilerNode.text;return e.indexOf(`.`)>=0?parseFloat(e):parseInt(e,10)}setLiteralValue(e){return Zt({sourceFile:this._sourceFile,start:this.getStart(),replacingLength:this.getWidth(),newText:e.toString(10)}),this}};e.QuoteKind=void 0,(function(e){e.Single=`'`,e.Double=`"`})(e.QuoteKind||={});var tp=ho,np=class extends tp{getLiteralValue(){let e=/^\/(.*)\/([^\/]*)$/,t=this.compilerNode.text,n=e.exec(t);return new RegExp(n[1],n[2])}setLiteralValue(e,t){let n;return typeof e==`string`?n=e:(n=e.source,t=e.flags),Zt({sourceFile:this._sourceFile,start:this.getStart(),replacingLength:this.getWidth(),newText:`/${n}/${t||``}`}),this}},rp=ho,ip=class extends rp{getLiteralValue(){return this.compilerNode.text}setLiteralValue(e){return Zt({sourceFile:this._sourceFile,start:this.getStart()+1,replacingLength:this.getWidth()-2,newText:t.StringUtils.escapeForWithinString(e,this.getQuoteKind())}),this}getQuoteKind(){return this.getText()[0]===`'`?e.QuoteKind.Single:e.QuoteKind.Double}},ap=ho,op=class extends ap{getLiteralValue(){return this.compilerNode.text}setLiteralValue(e){let t=this.getChildIndex(),n=this.getParentSyntaxList()||this.getParentOrThrow();return Zt({sourceFile:this._sourceFile,start:this.getStart()+1,replacingLength:this.getWidth()-2,newText:e}),n.getChildAtIndex(t)}},sp=class extends Va{getTag(){return this._getNodeFromCompilerNode(this.compilerNode.tag)}getTemplate(){return this._getNodeFromCompilerNode(this.compilerNode.template)}removeTag(){let e=this.getParentSyntaxList()??this.getParentOrThrow(),t=this.getChildIndex(),n=this.getTemplate();return kt({customMappings:(e,r)=>[{currentNode:n,newNode:e.getChildren(r)[t]}],parent:e,insertPos:this.getStart(),newText:this.getTemplate().getText(),replacing:{textLength:this.getWidth(),nodes:[this]}}),e.getChildAtIndex(t)}},cp=Ha,lp=class extends cp{getHead(){return this._getNodeFromCompilerNode(this.compilerNode.head)}getTemplateSpans(){return this.compilerNode.templateSpans.map(e=>this._getNodeFromCompilerNode(e))}setLiteralValue(e){let t=this.getChildIndex(),n=this.getParentSyntaxList()??this.getParentOrThrow();return Zt({sourceFile:this._sourceFile,start:this.getStart()+1,replacingLength:this.getWidth()-2,newText:e}),n.getChildAtIndex(t)}},up=Ui(H),dp=class extends up{},fp=Ui(H),pp=class extends fp{},mp=Ka(H),hp=class extends mp{getLiteral(){return this._getNodeFromCompilerNode(this.compilerNode.literal)}},gp=Ui(H),_p=class extends gp{},vp=(e=>An(kn(ba(Bi(Zi(e))))))(H),yp=class extends vp{remove(){let e=this.getParentOrThrow();switch(e.getKind()){case t.SyntaxKind.VariableDeclarationList:n(this);break;case t.SyntaxKind.CatchClause:r(this);break;default:throw new t.errors.NotImplementedError(`Not implemented for syntax kind: ${e.getKindName()}`)}function n(n){let r=e.getParentIfKindOrThrow(t.SyntaxKind.VariableStatement);r.getDeclarations().length===1?r.remove():Ut(n)}function r(e){It({children:[e.getPreviousSiblingIfKindOrThrow(t.SyntaxKind.OpenParenToken),e,e.getNextSiblingIfKindOrThrow(t.SyntaxKind.CloseParenToken)],removePrecedingSpaces:!0})}}getVariableStatementOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getVariableStatement(),e??`Expected the grandparent to be a variable statement.`,this)}getVariableStatement(){let e=this.getParentOrThrow().getParentOrThrow();return H.isVariableStatement(e)?e:void 0}set(e){return he(vp.prototype,this,e),this}getStructure(){return me(vp.prototype,this,{kind:e.StructureKind.VariableDeclaration})}},bp=Wi(H),xp=class extends bp{getDeclarations(){return this.compilerNode.declarations.map(e=>this._getNodeFromCompilerNode(e))}getDeclarationKind(){let n=this.compilerNode.flags;return n&t.ts.NodeFlags.Let?e.VariableDeclarationKind.Let:(n&t.ts.NodeFlags.AwaitUsing)===t.ts.NodeFlags.AwaitUsing?e.VariableDeclarationKind.AwaitUsing:(n&t.ts.NodeFlags.Using)===t.ts.NodeFlags.Using?e.VariableDeclarationKind.Using:n&t.ts.NodeFlags.Const?e.VariableDeclarationKind.Const:e.VariableDeclarationKind.Var}getDeclarationKindKeywords(){let n=this.getDeclarationKind();switch(n){case e.VariableDeclarationKind.Const:return[this.getFirstChildByKindOrThrow(t.SyntaxKind.ConstKeyword)];case e.VariableDeclarationKind.Let:return[this.getFirstChildByKindOrThrow(t.SyntaxKind.LetKeyword)];case e.VariableDeclarationKind.Var:return[this.getFirstChildByKindOrThrow(t.SyntaxKind.VarKeyword)];case e.VariableDeclarationKind.Using:return[this.getFirstChildByKindOrThrow(t.SyntaxKind.UsingKeyword)];case e.VariableDeclarationKind.AwaitUsing:let r=this.getFirstChildByKindOrThrow(t.SyntaxKind.AwaitKeyword);return[r,r.getNextSiblingIfKindOrThrow(t.SyntaxKind.UsingKeyword)];default:return t.errors.throwNotImplementedForNeverValueError(n)}}setDeclarationKind(e){if(this.getDeclarationKind()===e)return this;let t=this.getDeclarationKindKeywords(),n=t[0].getStart(),r=t[t.length-1].getEnd();return kt({insertPos:n,newText:e,parent:this,replacing:{textLength:r-n}}),this}addDeclaration(e){return this.addDeclarations([e])[0]}addDeclarations(e){return this.insertDeclarations(this.getDeclarations().length,e)}insertDeclaration(e,t){return this.insertDeclarations(e,[t])[0]}insertDeclarations(e,n){let r=this._getWriterWithQueuedChildIndentation(),i=new Bn(this._context.structurePrinterFactory.forVariableDeclaration()),a=this.compilerNode.declarations.length;return e=et(e,a),i.printText(r,n),jt({parent:this.getFirstChildByKindOrThrow(t.SyntaxKind.SyntaxList),currentNodes:this.getDeclarations(),insertIndex:e,newText:r.toString(),useTrailingCommas:!1}),Ye(a,this.getDeclarations(),e,!1)}},Sp=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get compilerSignature(){return this.#t}getTypeParameters(){return(this.compilerSignature.typeParameters||[]).map(e=>this.#e.compilerFactory.getTypeParameter(e))}getParameters(){return this.compilerSignature.parameters.map(e=>this.#e.compilerFactory.getSymbol(e))}getReturnType(){return this.#e.compilerFactory.getType(this.compilerSignature.getReturnType())}getDocumentationComments(){return this.compilerSignature.getDocumentationComment(this.#e.typeChecker.compilerObject).map(e=>this.#e.compilerFactory.getSymbolDisplayPart(e))}getJsDocTags(){return this.compilerSignature.getJsDocTags().map(e=>this.#e.compilerFactory.getJSDocTagInfo(e))}getDeclaration(){let{compilerFactory:e}=this.#e,t=this.compilerSignature.getDeclaration();return e.getNodeFromCompilerNode(t,e.getSourceFileForNode(t))}},Cp=class{#e;#t;get compilerSymbol(){return this.#t}constructor(e,t){this.#e=e,this.#t=t,this.getValueDeclaration(),this.getDeclarations()}getName(){return this.compilerSymbol.getName()}getEscapedName(){return this.compilerSymbol.getEscapedName()}getAliasedSymbolOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getAliasedSymbol(),e??`Expected to find an aliased symbol.`)}getImmediatelyAliasedSymbol(){return this.#e.typeChecker.getImmediatelyAliasedSymbol(this)}getImmediatelyAliasedSymbolOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getImmediatelyAliasedSymbol(),e??`Expected to find an immediately aliased symbol.`)}getAliasedSymbol(){return this.#e.typeChecker.getAliasedSymbol(this)}getExportSymbol(){return this.#e.typeChecker.getExportSymbolOfSymbol(this)}isAlias(){return(this.getFlags()&t.SymbolFlags.Alias)===t.SymbolFlags.Alias}isOptional(){return(this.getFlags()&t.SymbolFlags.Optional)===t.SymbolFlags.Optional}getFlags(){return this.compilerSymbol.getFlags()}hasFlags(e){return(this.compilerSymbol.flags&e)===e}getValueDeclarationOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getValueDeclaration(),e??(()=>`Expected to find the value declaration of symbol '${this.getName()}'.`))}getValueDeclaration(){let e=this.compilerSymbol.valueDeclaration;if(e!=null)return this.#e.compilerFactory.getNodeFromCompilerNode(e,this.#e.compilerFactory.getSourceFileForNode(e))}getDeclarations(){return(this.compilerSymbol.declarations??[]).map(e=>this.#e.compilerFactory.getNodeFromCompilerNode(e,this.#e.compilerFactory.getSourceFileForNode(e)))}getExportOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getExport(e),n??(()=>`Expected to find export with name: ${e}`))}getExport(e){if(this.compilerSymbol.exports==null)return;let n=this.compilerSymbol.exports.get(t.ts.escapeLeadingUnderscores(e));return n==null?void 0:this.#e.compilerFactory.getSymbol(n)}getExports(){return this.compilerSymbol.exports==null?[]:Array.from(this.compilerSymbol.exports.values()).map(e=>this.#e.compilerFactory.getSymbol(e))}getGlobalExportOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getGlobalExport(e),n??(()=>`Expected to find global export with name: ${e}`))}getGlobalExport(e){if(this.compilerSymbol.globalExports==null)return;let n=this.compilerSymbol.globalExports.get(t.ts.escapeLeadingUnderscores(e));return n==null?void 0:this.#e.compilerFactory.getSymbol(n)}getGlobalExports(){return this.compilerSymbol.globalExports==null?[]:Array.from(this.compilerSymbol.globalExports.values()).map(e=>this.#e.compilerFactory.getSymbol(e))}getMemberOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getMember(e),n??`Expected to find member with name: ${e}`)}getMember(e){if(this.compilerSymbol.members==null)return;let n=this.compilerSymbol.members.get(t.ts.escapeLeadingUnderscores(e));return n==null?void 0:this.#e.compilerFactory.getSymbol(n)}getMembers(){return this.compilerSymbol.members==null?[]:Array.from(this.compilerSymbol.members.values()).map(e=>this.#e.compilerFactory.getSymbol(e))}getDeclaredType(){return this.#e.typeChecker.getDeclaredTypeOfSymbol(this)}getTypeAtLocation(e){return this.#e.typeChecker.getTypeOfSymbolAtLocation(this,e)}getFullyQualifiedName(){return this.#e.typeChecker.getFullyQualifiedName(this)}getJsDocTags(){return this.compilerSymbol.getJsDocTags(this.#e.typeChecker.compilerObject).map(e=>new kd(e))}},wp=class{#e;constructor(e){this.#e=e}get compilerObject(){return this.#e}getStart(){return this.compilerObject.start}getEnd(){return this.compilerObject.start+this.compilerObject.length}getLength(){return this.compilerObject.length}},Tp=class{#e;constructor(e){this.#e=e}get compilerObject(){return this.#e}getSpan(){return new wp(this.compilerObject.span)}getNewText(){return this.compilerObject.newText}};Vc([t.Memoize],Tp.prototype,`getSpan`,null);var Ep=class{#e;#t;#n;#r;#i;constructor(e,t){this.#e=e,this.#t=t;let n=e.compilerFactory.addOrGetSourceFileFromFilePath(e.fileSystemWrapper.getStandardizedAbsolutePath(t.fileName),{markInProject:!1,scriptKind:void 0});this.#r=n!=null,t.isNewFile||(this.#n=n)}getFilePath(){return this.#t.fileName}getSourceFile(){return this.#n}getTextChanges(){return this.#t.textChanges.map(e=>new Tp(e))}applyChanges(e={}){if(this.#i)return;if(this.isNewFile()&&this.#r&&!e.overwrite)throw new t.errors.InvalidOperationError(`Cannot apply file text change for creating a new file when the file exists at path ${this.getFilePath()}. Did you mean to provide the overwrite option?`);let n;if(n=this.isNewFile()?this.#e.project.createSourceFile(this.getFilePath(),``,{overwrite:e.overwrite}):this.getSourceFile(),n==null)throw new t.errors.InvalidOperationError(`Cannot apply file text change to modify existing file that doesn't exist at path: ${this.getFilePath()}`);return n.applyTextChanges(this.getTextChanges()),n._markAsInProject(),this.#i=!0,this}isNewFile(){return!!this.#t.isNewFile}};Vc([t.Memoize],Ep.prototype,`getTextChanges`,null);var Dp=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get compilerObject(){return this.#t}getDescription(){return this.compilerObject.description}getChanges(){return this.compilerObject.changes.map(e=>new Ep(this.#e,e))}},Op=class extends Dp{getFixName(){return this.compilerObject.fixName}getFixId(){return this.compilerObject.fixId}getFixAllDescription(){return this.compilerObject.fixAllDescription}},kp=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get compilerObject(){return this.#t}getChanges(){return this.compilerObject.changes.map(e=>new Ep(this.#e,e))}applyChanges(e){for(let t of this.getChanges())t.applyChanges(e);return this}};Vc([t.Memoize],kp.prototype,`getChanges`,null);var Ap=class{_context;_compilerObject;_sourceFile;constructor(e,t){this._context=e,this._compilerObject=t,this._sourceFile=this._context.compilerFactory.addOrGetSourceFileFromFilePath(e.fileSystemWrapper.getStandardizedAbsolutePath(this.compilerObject.fileName),{markInProject:!1,scriptKind:void 0}),this._sourceFile._doActionPreNextModification(()=>this.getNode())}get compilerObject(){return this._compilerObject}getSourceFile(){return this._sourceFile}getTextSpan(){return new wp(this.compilerObject.textSpan)}getNode(){let e=this.getTextSpan(),t=this.getSourceFile(),n=e.getStart(),r=e.getEnd();return i();function i(){let e;return t._context.compilerFactory.forgetNodesCreatedInBlock(i=>{let a,o=t;for(;o!=null;){if(a??(e=o),o.getStart()===n&&o.getWidth()===r)e=a=o;else if(a!=null)break;o=o.getChildAtPos(n)}e!=null&&i(e)}),e}}getOriginalTextSpan(){let{originalTextSpan:e}=this.compilerObject;return e==null?void 0:new wp(e)}getOriginalFileName(){return this.compilerObject.originalFileName}};Vc([t.Memoize],Ap.prototype,`getTextSpan`,null),Vc([t.Memoize],Ap.prototype,`getNode`,null),Vc([t.Memoize],Ap.prototype,`getOriginalTextSpan`,null);var jp=class extends Ap{constructor(e,t){super(e,t),this.getSourceFile()._doActionPreNextModification(()=>this.getDeclarationNode())}getKind(){return this.compilerObject.kind}getName(){return this.compilerObject.name}getContainerKind(){return this.compilerObject.containerKind}getContainerName(){return this.compilerObject.containerName}getDeclarationNode(){if(this.getKind()===`module`&&this.getTextSpan().getLength()===this.getSourceFile().getFullWidth())return this.getSourceFile();let e=this.getTextSpan().getStart();return n(this.getSourceFile())?.getParentOrThrow();function n(r){if(r.getKind()===t.SyntaxKind.Identifier&&r.getStart()===e)return r;for(let t of r._getChildrenIterator())if(t.getPos()<=e&&t.getEnd()>e)return n(t)}}};Vc([t.Memoize],jp.prototype,`getDeclarationNode`,null);var Mp=class e{_compilerObject;constructor(e){this._compilerObject=e}get compilerObject(){return this._compilerObject}getMessageText(){return this.compilerObject.messageText}getNext(){let t=this.compilerObject.next;if(t!=null)return t instanceof Array?t.map(t=>new e(t)):[new e(t)]}getCode(){return this.compilerObject.code}getCategory(){return this.compilerObject.category}},Np=class{_context;_compilerObject;constructor(e,t){this._context=e,this._compilerObject=t,this.getSourceFile()}get compilerObject(){return this._compilerObject}getSourceFile(){if(this._context==null)return;let e=this.compilerObject.file;return e==null?void 0:this._context.compilerFactory.getSourceFile(e,{markInProject:!1})}getMessageText(){let e=this._compilerObject.messageText;return typeof e==`string`?e:this._context==null?new Mp(e):this._context.compilerFactory.getDiagnosticMessageChain(e)}getLineNumber(){let e=this.getSourceFile(),n=this.getStart();if(!(e==null||n==null))return t.StringUtils.getLineNumberAtPos(e.getFullText(),n)}getStart(){return this.compilerObject.start}getLength(){return this.compilerObject.length}getCategory(){return this.compilerObject.category}getCode(){return this.compilerObject.code}getSource(){return this.compilerObject.source}};Vc([t.Memoize],Np.prototype,`getSourceFile`,null);var Pp=class extends Np{constructor(e,t){super(e,t)}getLineNumber(){return super.getLineNumber()}getStart(){return super.getStart()}getLength(){return super.getLength()}getSourceFile(){return super.getSourceFile()}},Fp=class{#e;#t;constructor(e,t){this.#e=t,this.#t=e}get compilerObject(){return this.#e}getFilePath(){return this.#t.fileSystemWrapper.getStandardizedAbsolutePath(this.compilerObject.name)}getWriteByteOrderMark(){return this.compilerObject.writeByteOrderMark||!1}getText(){return this.compilerObject.text}},Ip=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get compilerObject(){return this.#t}getDiagnostics(){return this.compilerObject.diagnostics.map(e=>this.#e.compilerFactory.getDiagnostic(e))}getEmitSkipped(){return this.compilerObject.emitSkipped}getOutputFiles(){return this.compilerObject.outputFiles.map(e=>new Fp(this.#e,e))}};Vc([t.Memoize],Ip.prototype,`getDiagnostics`,null),Vc([t.Memoize],Ip.prototype,`getOutputFiles`,null);var Lp=class{_context;_compilerObject;constructor(e,t){this._context=e,this._compilerObject=t,this.getDiagnostics()}get compilerObject(){return this._compilerObject}getEmitSkipped(){return this.compilerObject.emitSkipped}getDiagnostics(){return this.compilerObject.diagnostics.map(e=>this._context.compilerFactory.getDiagnostic(e))}};Vc([t.Memoize],Lp.prototype,`getDiagnostics`,null);var Rp=class extends Ap{constructor(e,t){super(e,t)}getKind(){return this.compilerObject.kind}getDisplayParts(){return this.compilerObject.displayParts.map(e=>this._context.compilerFactory.getSymbolDisplayPart(e))}};Vc([t.Memoize],Rp.prototype,`getDisplayParts`,null);var zp=class extends Lp{#e;constructor(e,t,n){super(e,t),this.#e=n}getFiles(){return this.#e}saveFiles(){let e=this._context.fileSystemWrapper,t=this.#e.map(t=>e.writeFile(t.filePath,t.writeByteOrderMark?``+t.text:t.text));return Promise.all(t)}saveFilesSync(){let e=this._context.fileSystemWrapper;for(let t of this.#e)e.writeFileSync(t.filePath,t.writeByteOrderMark?``+t.text:t.text)}},Bp=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get compilerObject(){return this.#t}getEdits(){return this.compilerObject.edits.map(e=>new Ep(this.#e,e))}getRenameFilePath(){return this.compilerObject.renameFilename}getRenameLocation(){return this.compilerObject.renameLocation}applyChanges(e){for(let t of this.getEdits())t.applyChanges(e);return this}};Vc([t.Memoize],Bp.prototype,`getEdits`,null);var Vp=class{_context;#e;#t;constructor(e,t){this._context=e,this.#e=t,this.#t=this.compilerObject.references.map(t=>e.compilerFactory.getReferencedSymbolEntry(t))}get compilerObject(){return this.#e}getDefinition(){return this._context.compilerFactory.getReferencedSymbolDefinitionInfo(this.compilerObject.definition)}getReferences(){return this.#t}};Vc([t.Memoize],Vp.prototype,`getDefinition`,null);var Hp=class extends jp{constructor(e,t){super(e,t)}getDisplayParts(){return this.compilerObject.displayParts.map(e=>this._context.compilerFactory.getSymbolDisplayPart(e))}};Vc([t.Memoize],Hp.prototype,`getDisplayParts`,null);var Up=class extends Ap{constructor(e,t){super(e,t)}isWriteAccess(){return this.compilerObject.isWriteAccess}isInString(){return this.compilerObject.isInString}},Wp=class extends Up{constructor(e,t){super(e,t)}isDefinition(){return this.compilerObject.isDefinition}},Gp=class extends Ap{getPrefixText(){return this._compilerObject.prefixText}getSuffixText(){return this._compilerObject.suffixText}},Kp=class{#e;constructor(e){this.#e=e}get compilerObject(){return this.#e}getText(){return this.compilerObject.text}getKind(){return this.compilerObject.kind}},qp=class{#e;#t;constructor(e){this.#e=e}get compilerObject(){return this.#t()}_reset(e){this.#t=e}getAmbientModules(){return this.compilerObject.getAmbientModules().map(e=>this.#e.compilerFactory.getSymbol(e))}getApparentType(e){return this.#e.compilerFactory.getType(this.compilerObject.getApparentType(e.compilerType))}getConstantValue(e){return this.compilerObject.getConstantValue(e.compilerNode)}getFullyQualifiedName(e){return this.compilerObject.getFullyQualifiedName(e.compilerSymbol)}getTypeAtLocation(e){return this.#e.compilerFactory.getType(this.compilerObject.getTypeAtLocation(e.compilerNode))}getContextualType(e){let t=this.compilerObject.getContextualType(e.compilerNode);return t==null?void 0:this.#e.compilerFactory.getType(t)}getTypeOfSymbolAtLocation(e,t){return this.#e.compilerFactory.getType(this.compilerObject.getTypeOfSymbolAtLocation(e.compilerSymbol,t.compilerNode))}getDeclaredTypeOfSymbol(e){return this.#e.compilerFactory.getType(this.compilerObject.getDeclaredTypeOfSymbol(e.compilerSymbol))}getSymbolAtLocation(e){let t=this.compilerObject.getSymbolAtLocation(e.compilerNode);return t==null?void 0:this.#e.compilerFactory.getSymbol(t)}getAliasedSymbol(e){if(!e.hasFlags(t.SymbolFlags.Alias))return;let n=this.compilerObject.getAliasedSymbol(e.compilerSymbol);return n==null?void 0:this.#e.compilerFactory.getSymbol(n)}getImmediatelyAliasedSymbol(e){let t=this.compilerObject.getImmediateAliasedSymbol(e.compilerSymbol);return t==null?void 0:this.#e.compilerFactory.getSymbol(t)}getExportSymbolOfSymbol(e){return this.#e.compilerFactory.getSymbol(this.compilerObject.getExportSymbolOfSymbol(e.compilerSymbol))}getPropertiesOfType(e){return this.compilerObject.getPropertiesOfType(e.compilerType).map(e=>this.#e.compilerFactory.getSymbol(e))}getTypeText(e,t,n){return n??=this.#n(t),this.compilerObject.typeToString(e.compilerType,t?.compilerNode,n)}getReturnTypeOfSignature(e){return this.#e.compilerFactory.getType(this.compilerObject.getReturnTypeOfSignature(e.compilerSignature))}getSignatureFromNode(e){let t=this.compilerObject.getSignatureFromDeclaration(e.compilerNode);return t==null?void 0:this.#e.compilerFactory.getSignature(t)}getExportsOfModule(e){return(this.compilerObject.getExportsOfModule(e.compilerSymbol)||[]).map(e=>this.#e.compilerFactory.getSymbol(e))}getExportSpecifierLocalTargetSymbol(e){let t=this.compilerObject.getExportSpecifierLocalTargetSymbol(e.compilerNode);return t==null?void 0:this.#e.compilerFactory.getSymbol(t)}getResolvedSignature(e){let t=this.compilerObject.getResolvedSignature(e.compilerNode);if(!(!t||!t.declaration))return this.#e.compilerFactory.getSignature(t)}getResolvedSignatureOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getResolvedSignature(e),n??`Signature could not be resolved.`,e)}getBaseTypeOfLiteralType(e){return this.#e.compilerFactory.getType(this.compilerObject.getBaseTypeOfLiteralType(e.compilerType))}getSymbolsInScope(e,t){return this.compilerObject.getSymbolsInScope(e.compilerNode,t).map(e=>this.#e.compilerFactory.getSymbol(e))}getTypeArguments(e){return this.compilerObject.getTypeArguments(e.compilerType).map(e=>this.#e.compilerFactory.getType(e))}isTypeAssignableTo(e,t){return this.compilerObject.isTypeAssignableTo(e.compilerType,t.compilerType)}#n(e){let n=t.TypeFormatFlags.UseTypeOfFunction|t.TypeFormatFlags.NoTruncation|t.TypeFormatFlags.UseFullyQualifiedType|t.TypeFormatFlags.WriteTypeArgumentsOfSignature;return e!=null&&e.getKind()===t.SyntaxKind.TypeAliasDeclaration&&(n|=t.TypeFormatFlags.InTypeAlias),n}getShorthandAssignmentValueSymbol(e){let t=this.compilerObject.getShorthandAssignmentValueSymbol(e.compilerNode);return t?this.#e.compilerFactory.getSymbol(t):void 0}resolveName(e,t,n,r){let i=this.compilerObject.resolveName(e,t?.compilerNode,n,r);return i?this.#e.compilerFactory.getSymbol(i):void 0}},Jp=class{#e;#t;#n;#r;#i;#a;constructor(e){this.#e=e.context,this.#a=e.configFileParsingDiagnostics,this.#t=new qp(this.#e),this._reset(e.rootNames,e.host)}get compilerObject(){return this.#i()}_isCompilerProgramCreated(){return this.#n!=null}_reset(e,n){let r=this.#e.compilerOptions.get();this.#i=()=>(this.#n??(this.#n=t.ts.createProgram(e,r,n,this.#r,this.#a),this.#r=void 0),this.#n),this.#n!=null&&(this.#r=this.#n,this.#n=void 0),this.#t._reset(()=>this.compilerObject.getTypeChecker())}getTypeChecker(){return this.#t}async emit(e={}){if(e.writeFile){let n=`Cannot specify a ${t.nameof(e,`writeFile`)} option when emitting asynchrously. Use ${t.nameof(this,`emitSync`)}() instead.`;throw new t.errors.InvalidOperationError(n)}let{fileSystemWrapper:n}=this.#e,r=[],i=this.#o({writeFile:(e,t,i)=>{r.push(n.writeFile(n.getStandardizedAbsolutePath(e),i?``+t:t))},...e});return await Promise.all(r),new Lp(this.#e,i)}emitSync(e={}){return new Lp(this.#e,this.#o(e))}emitToMemory(e={}){let t=[],{fileSystemWrapper:n}=this.#e,r=this.#o({writeFile:(e,r,i)=>{t.push({filePath:n.getStandardizedAbsolutePath(e),text:r,writeByteOrderMark:i||!1})},...e});return new zp(this.#e,r,t)}#o(e={}){let t=e.targetSourceFile==null?void 0:e.targetSourceFile.compilerNode,{emitOnlyDtsFiles:n,customTransformers:r,writeFile:i}=e;return this.compilerObject.emit(t,i,void 0,n,r)}getSyntacticDiagnostics(e){return this.compilerObject.getSyntacticDiagnostics(e?.compilerNode).map(e=>this.#e.compilerFactory.getDiagnosticWithLocation(e))}getSemanticDiagnostics(e){return this.compilerObject.getSemanticDiagnostics(e?.compilerNode).map(e=>this.#e.compilerFactory.getDiagnostic(e))}getDeclarationDiagnostics(e){return this.compilerObject.getDeclarationDiagnostics(e?.compilerNode).map(e=>this.#e.compilerFactory.getDiagnosticWithLocation(e))}getGlobalDiagnostics(){return this.compilerObject.getGlobalDiagnostics().map(e=>this.#e.compilerFactory.getDiagnostic(e))}getConfigFileParsingDiagnostics(){return this.compilerObject.getConfigFileParsingDiagnostics().map(e=>this.#e.compilerFactory.getDiagnostic(e))}getEmitModuleResolutionKind(){return t.getEmitModuleResolutionKind(this.compilerObject.getCompilerOptions())}isSourceFileFromExternalLibrary(e){return e.isFromExternalLibrary()}},Yp=class{#e;#t;#n;#r;#i=0;get compilerObject(){return this.#e}constructor(e){this.#r=e.context;let{languageServiceHost:n,compilerHost:r}=t.createHosts({transactionalFileSystem:this.#r.fileSystemWrapper,sourceFileContainer:this.#r.getSourceFileContainer(),compilerOptions:this.#r.compilerOptions,getNewLine:()=>this.#r.manipulationSettings.getNewLineKindAsString(),getProjectVersion:()=>`${this.#i}`,resolutionHost:e.resolutionHost??{},libFolderPath:e.libFolderPath,skipLoadingLibFiles:e.skipLoadingLibFiles});this.#t=r,this.#e=t.ts.createLanguageService(n,this.#r.compilerFactory.documentRegistry),this.#n=new Jp({context:this.#r,rootNames:Array.from(this.#r.compilerFactory.getSourceFilePaths()),host:this.#t,configFileParsingDiagnostics:e.configFileParsingDiagnostics}),this.#r.compilerFactory.onSourceFileAdded(e=>{e._isInProject()&&this._reset()}),this.#r.compilerFactory.onSourceFileRemoved(()=>this._reset())}_reset(){this.#i+=1,this.#n._reset(Array.from(this.#r.compilerFactory.getSourceFilePaths()),this.#t)}getProgram(){return this.#n}getDefinitions(e){return this.getDefinitionsAtPosition(e._sourceFile,e.getStart())}getDefinitionsAtPosition(e,t){return(this.compilerObject.getDefinitionAtPosition(e.getFilePath(),t)||[]).map(e=>this.#r.compilerFactory.getDefinitionInfo(e))}getImplementations(e){return this.getImplementationsAtPosition(e._sourceFile,e.getStart())}getImplementationsAtPosition(e,t){return(this.compilerObject.getImplementationAtPosition(e.getFilePath(),t)||[]).map(e=>new Rp(this.#r,e))}findReferences(e){return this.findReferencesAtPosition(e._sourceFile,e.getStart())}findReferencesAsNodes(e){let n=this.findReferences(e);return Array.from(r());function*r(){for(let e of n){let n=e.getDefinition().getKind()===t.ts.ScriptElementKind.alias,r=e.getReferences();for(let e=0;e<r.length;e++){let t=r[e];(n||!t.isDefinition()||e>0)&&(yield t.getNode())}}}}findReferencesAtPosition(e,t){return(this.compilerObject.findReferences(e.getFilePath(),t)||[]).map(e=>this.#r.compilerFactory.getReferencedSymbol(e))}findRenameLocations(e,t={}){let n=t.usePrefixAndSuffixText==null?this.#r.manipulationSettings.getUsePrefixAndSuffixTextForRename():t.usePrefixAndSuffixText;return(this.compilerObject.findRenameLocations(e._sourceFile.getFilePath(),e.getStart(),t.renameInStrings||!1,t.renameInComments||!1,n)||[]).map(e=>new Gp(this.#r,e))}getSuggestionDiagnostics(e){let t=this.#a(e);return this.compilerObject.getSuggestionDiagnostics(t).map(e=>this.#r.compilerFactory.getDiagnosticWithLocation(e))}getFormattingEditsForRange(e,t,n){return(this.compilerObject.getFormattingEditsForRange(e,t[0],t[1],this.#o(n))||[]).map(e=>new Tp(e))}getFormattingEditsForDocument(e,t){let n=this.#r.fileSystemWrapper.getStandardizedAbsolutePath(e);return(this.compilerObject.getFormattingEditsForDocument(n,this.#o(t))||[]).map(e=>new Tp(e))}getFormattedDocumentText(e,n){let r=this.#r.fileSystemWrapper.getStandardizedAbsolutePath(e),i=this.#r.compilerFactory.getSourceFileFromCacheFromFilePath(r);if(i==null)throw new t.errors.FileNotFoundError(r);n=this.#o(n);let a=R(i,this.getFormattingEditsForDocument(r,n)),o=n.newLineCharacter;return n.ensureNewLineAtEndOfFile&&!a.endsWith(o)&&(a+=o),a.replace(/\r?\n/g,o)}getEmitOutput(e,t){let n=this.#a(e),r=this.compilerObject;return new Ip(this.#r,i());function i(){let e=r.getProgram();return e==null||e.getSourceFile(n)==null?{emitSkipped:!0,outputFiles:[],diagnostics:[]}:r.getEmitOutput(n,t)}}getIdentationAtPosition(e,t,n){let r=this.#a(e);return n==null?n=this.#r.manipulationSettings.getEditorSettings():P(n,this.#r.manipulationSettings),this.compilerObject.getIndentationAtPosition(r,t,n)}organizeImports(e,t={},n={}){let r={type:`file`,fileName:this.#a(e)};return this.compilerObject.organizeImports(r,this.#o(t),this.#s(n)).map(e=>new Ep(this.#r,e))}getEditsForRefactor(e,t,n,r,i,a={}){let o=this.#a(e),s=typeof n==`number`?n:{pos:n.getPos(),end:n.getEnd()},c=this.compilerObject.getEditsForRefactor(o,this.#o(t),s,r,i,this.#s(a));return c==null?void 0:new Bp(this.#r,c)}getCombinedCodeFix(e,t,n={},r={}){let i=this.compilerObject.getCombinedCodeFix({type:`file`,fileName:this.#a(e)},t,this.#o(n),this.#s(r||{}));return new kp(this.#r,i)}getCodeFixesAtPosition(e,t,n,r,i={},a={}){let o=this.#a(e);return this.compilerObject.getCodeFixesAtPosition(o,t,n,r,this.#o(i),this.#s(a||{})).map(e=>new Op(this.#r,e))}#a(e){let n=typeof e==`string`?this.#r.fileSystemWrapper.getStandardizedAbsolutePath(e):e.getFilePath();if(!this.#r.compilerFactory.containsSourceFileAtPath(n))throw new t.errors.FileNotFoundError(n);return n}#o(e){return e._filled?e:(e=Object.assign(this.#r.getFormatCodeSettings(),e),F(e,this.#r.manipulationSettings),e._filled=!0,e)}#s(e){return Object.assign(this.#r.getUserPreferences(),e)}},Xp=class{_context;#e;get compilerType(){return this.#e}constructor(e,t){this._context=e,this.#e=t}getText(e,t){return this._context.typeChecker.getTypeText(this,e,t)}getAliasSymbol(){return this.compilerType.aliasSymbol==null?void 0:this._context.compilerFactory.getSymbol(this.compilerType.aliasSymbol)}getAliasSymbolOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getAliasSymbol(),`Expected to find an alias symbol.`)}getAliasTypeArguments(){return(this.compilerType.aliasTypeArguments||[]).map(e=>this._context.compilerFactory.getType(e))}getApparentType(){return this._context.typeChecker.getApparentType(this)}getArrayElementTypeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getArrayElementType(),e??`Expected to find an array element type.`)}getArrayElementType(){if(this.isArray())return this.getTypeArguments()[0]}getBaseTypes(){return(this.compilerType.getBaseTypes()||[]).map(e=>this._context.compilerFactory.getType(e))}getBaseTypeOfLiteralType(){return this._context.typeChecker.getBaseTypeOfLiteralType(this)}getCallSignatures(){return this.compilerType.getCallSignatures().map(e=>this._context.compilerFactory.getSignature(e))}getConstructSignatures(){return this.compilerType.getConstructSignatures().map(e=>this._context.compilerFactory.getSignature(e))}getConstraintOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getConstraint(),e??`Expected to find a constraint.`)}getConstraint(){let e=this.compilerType.getConstraint();return e==null?void 0:this._context.compilerFactory.getType(e)}getDefaultOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getDefault(),e??`Expected to find a default type.`)}getDefault(){let e=this.compilerType.getDefault();return e==null?void 0:this._context.compilerFactory.getType(e)}getProperties(){return this.compilerType.getProperties().map(e=>this._context.compilerFactory.getSymbol(e))}getPropertyOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getProperty(e),()=>l(`symbol property`,e))}getProperty(e){return ee(this.getProperties(),e)}getApparentProperties(){return this.compilerType.getApparentProperties().map(e=>this._context.compilerFactory.getSymbol(e))}getApparentProperty(e){return ee(this.getApparentProperties(),e)}isNullable(){return this.getUnionTypes().some(e=>e.isNull()||e.isUndefined())}getNonNullableType(){return this._context.compilerFactory.getType(this.compilerType.getNonNullableType())}getNumberIndexType(){let e=this.compilerType.getNumberIndexType();return e==null?void 0:this._context.compilerFactory.getType(e)}getStringIndexType(){let e=this.compilerType.getStringIndexType();return e==null?void 0:this._context.compilerFactory.getType(e)}getTargetType(){let e=this.compilerType.target||void 0;return e==null?void 0:this._context.compilerFactory.getType(e)}getTargetTypeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getTargetType(),e??`Expected to find the target type.`)}getTypeArguments(){return this._context.typeChecker.getTypeArguments(this)}getTupleElements(){return this.isTuple()?this.getTypeArguments():[]}getUnionTypes(){return this.isUnion()?this.compilerType.types.map(e=>this._context.compilerFactory.getType(e)):[]}getIntersectionTypes(){return this.isIntersection()?this.compilerType.types.map(e=>this._context.compilerFactory.getType(e)):[]}getLiteralValue(){return this.compilerType?.value}getLiteralValueOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getLiteralValue(),e??`Type was not a literal type.`)}getLiteralFreshType(){let e=this.compilerType?.freshType;return e==null?void 0:this._context.compilerFactory.getType(e)}getLiteralFreshTypeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getLiteralFreshType(),e??`Type was not a literal type.`)}getLiteralRegularType(){let e=this.compilerType?.regularType;return e==null?void 0:this._context.compilerFactory.getType(e)}getLiteralRegularTypeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getLiteralRegularType(),e??`Type was not a literal type.`)}getSymbol(){let e=this.compilerType.getSymbol();return e==null?void 0:this._context.compilerFactory.getSymbol(e)}getSymbolOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getSymbol(),e??`Expected to find a symbol.`)}isAssignableTo(e){return this._context.typeChecker.isTypeAssignableTo(this,e)}isAnonymous(){return this.#n(t.ObjectFlags.Anonymous)}isAny(){return this.#t(t.TypeFlags.Any)}isNever(){return this.#t(t.TypeFlags.Never)}isArray(){let e=this.getSymbol();return e==null?!1:(e.getName()===`Array`||e.getName()===`ReadonlyArray`)&&this.getTypeArguments().length===1}isReadonlyArray(){let e=this.getSymbol();return e==null?!1:e.getName()===`ReadonlyArray`&&this.getTypeArguments().length===1}isTemplateLiteral(){return this.#t(t.TypeFlags.TemplateLiteral)}isBoolean(){return this.#t(t.TypeFlags.Boolean)}isString(){return this.#t(t.TypeFlags.String)}isNumber(){return this.#t(t.TypeFlags.Number)}isBigInt(){return this.#t(t.TypeFlags.BigInt)}isLiteral(){let e=this.isBooleanLiteral();return this.compilerType.isLiteral()||e}isBooleanLiteral(){return this.#t(t.TypeFlags.BooleanLiteral)}isBigIntLiteral(){return this.#t(t.TypeFlags.BigIntLiteral)}isEnumLiteral(){return this.#t(t.TypeFlags.EnumLiteral)&&!this.isUnion()}isNumberLiteral(){return this.#t(t.TypeFlags.NumberLiteral)}isStringLiteral(){return this.compilerType.isStringLiteral()}isClass(){return this.compilerType.isClass()}isClassOrInterface(){return this.compilerType.isClassOrInterface()}isEnum(){if(this.#t(t.TypeFlags.Enum))return!0;if(this.isEnumLiteral()&&!this.isUnion())return!1;let e=this.getSymbol();if(e==null)return!1;let n=e.getValueDeclaration();return n!=null&&H.isEnumDeclaration(n)}isInterface(){return this.#n(t.ObjectFlags.Interface)}isObject(){return this.#t(t.TypeFlags.Object)}isTypeParameter(){return this.compilerType.isTypeParameter()}isTuple(){let e=this.getTargetType();return e==null?!1:e.#n(t.ObjectFlags.Tuple)}isUnion(){return this.compilerType.isUnion()}isIntersection(){return this.compilerType.isIntersection()}isUnionOrIntersection(){return this.compilerType.isUnionOrIntersection()}isUnknown(){return this.#t(t.TypeFlags.Unknown)}isNull(){return this.#t(t.TypeFlags.Null)}isUndefined(){return this.#t(t.TypeFlags.Undefined)}isVoid(){return this.#t(t.TypeFlags.Void)}getFlags(){return this.compilerType.flags}getObjectFlags(){return this.isObject()&&this.compilerType.objectFlags||0}#t(e){return(this.compilerType.flags&e)===e}#n(e){return(this.getObjectFlags()&e)===e}},Zp=class extends Xp{getConstraintOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getConstraint(),e??`Expected type parameter to have a constraint.`)}getConstraint(){let e=this.#e();if(e==null)return;let t=e.getConstraint();if(t!=null)return this._context.typeChecker.getTypeAtLocation(t)}getDefaultOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getDefault(),e??`Expected type parameter to have a default type.`)}getDefault(){let e=this.#e();if(e==null)return;let t=e.getDefault();if(t!=null)return this._context.typeChecker.getTypeAtLocation(t)}#e(){let e=this.getSymbol();if(e==null)return;let t=e.getDeclarations()[0];if(t!=null&&H.isTypeParameterDeclaration(t))return t}},Qp=class{#e;#t;constructor(e,t){this.#t=e,this.#e=t}getSkippedFilePaths(){return this.#t}getOutputFilePaths(){return this.#e}},$p=class e{#e;#t;#n;constructor(e,t){this.#e=e,this._setPathInternal(t)}_setPathInternal(e){this.#t=e,this.#n=e.split(`/`).filter(e=>e.length>0)}get _context(){return this.#s(),this.#e}isAncestorOf(t){return e.#u(this,t)}isDescendantOf(t){return e.#u(t,this)}_getDepth(){return this.#n.length}getPath(){return this.#s(),this.#t}getBaseName(){return this.#n[this.#n.length-1]}getParentOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getParent(),e??(()=>`Parent directory of ${this.getPath()} does not exist or was never added.`))}getParent(){if(!t.FileUtils.isRootDirPath(this.getPath()))return this.addDirectoryAtPathIfExists(t.FileUtils.getDirPath(this.getPath()))}getDirectoryOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getDirectory(e),()=>typeof e==`string`?`Could not find a directory at path '${this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath())}'.`:`Could not find child directory that matched condition.`)}getDirectory(e){if(typeof e==`string`){let t=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath());return this._context.compilerFactory.getDirectoryFromCache(t)}return this.getDirectories().find(e)}getSourceFileOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getSourceFile(e),()=>typeof e==`string`?`Could not find child source file at path '${this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath())}'.`:`Could not find child source file that matched condition.`)}getSourceFile(e){if(typeof e==`string`){let t=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath());return this._context.compilerFactory.getSourceFileFromCacheFromFilePath(t)}for(let t of this._getSourceFilesIterator())if(e(t))return t}getDirectories(){return Array.from(this._getDirectoriesIterator())}_getDirectoriesIterator(){return this._context.compilerFactory.getChildDirectoriesOfDirectory(this.getPath())}getSourceFiles(e){let{compilerFactory:n,fileSystemWrapper:r}=this._context,i=this;if(typeof e==`string`||e instanceof Array){let t=typeof e==`string`?[e]:e;return Array.from(a(t))}else return Array.from(this._getSourceFilesIterator());function*a(e){let a=Array.from(s()),o=t.matchGlobs(a,e,i.getPath());for(let e of o)yield n.getSourceFileFromCacheFromFilePath(r.getStandardizedAbsolutePath(e));function*s(){for(let e of i._getDescendantSourceFilesIterator())yield e.getFilePath()}}}_getSourceFilesIterator(){return this._context.compilerFactory.getChildSourceFilesOfDirectory(this.getPath())}getDescendantSourceFiles(){return Array.from(this._getDescendantSourceFilesIterator())}*_getDescendantSourceFilesIterator(){for(let e of this._getSourceFilesIterator())yield e;for(let e of this._getDirectoriesIterator())yield*e._getDescendantSourceFilesIterator()}getDescendantDirectories(){return Array.from(this._getDescendantDirectoriesIterator())}*_getDescendantDirectoriesIterator(){for(let e of this.getDirectories())yield e,yield*e._getDescendantDirectoriesIterator()}addSourceFilesAtPaths(e){return e=typeof e==`string`?[e]:e,e=e.map(e=>t.FileUtils.pathIsAbsolute(e)?e:t.FileUtils.pathJoin(this.getPath(),e)),this._context.directoryCoordinator.addSourceFilesAtPaths(e,{markInProject:this._isInProject()})}addDirectoryAtPathIfExists(e,t={}){let n=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath());return this._context.directoryCoordinator.addDirectoryAtPathIfExists(n,{...t,markInProject:this._isInProject()})}addDirectoryAtPath(e,t={}){let n=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath());return this._context.directoryCoordinator.addDirectoryAtPath(n,{...t,markInProject:this._isInProject()})}createDirectory(e){let t=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath());return this._context.directoryCoordinator.createDirectoryOrAddIfExists(t,{markInProject:this._isInProject()})}createSourceFile(e,t,n){let r=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath());return this._context.compilerFactory.createSourceFile(r,t||``,{...n||{},markInProject:this._isInProject()})}addSourceFileAtPathIfExists(e){let t=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath());return this._context.directoryCoordinator.addSourceFileAtPathIfExists(t,{markInProject:this._isInProject()})}addSourceFileAtPath(e){let t=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath());return this._context.directoryCoordinator.addSourceFileAtPath(t,{markInProject:this._isInProject()})}async emit(e={}){let{fileSystemWrapper:t}=this._context,n=[],r=[],i=[];for(let a of this.#r(e))tm(a)?i.push(a):(n.push(t.writeFile(a.filePath,a.fileText)),r.push(a.filePath));return await Promise.all(n),new Qp(i,r)}emitSync(e={}){let{fileSystemWrapper:t}=this._context,n=[],r=[];for(let i of this.#r(e))tm(i)?r.push(i):(t.writeFileSync(i.filePath,i.fileText),n.push(i.filePath));return new Qp(r,n)}#r(e={}){let{emitOnlyDtsFiles:n=!1}=e,r=e.outDir==null?void 0:/\.js$/i,i=e.outDir==null?void 0:/\.js\.map$/i,a=e.declarationDir==null&&e.outDir==null?void 0:/\.d\.ts$/i,o=e=>e==null?void 0:this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath()),s=(e,n)=>e==null?void 0:t.FileUtils.pathJoin(e,n.getBaseName()),c=this._context.compilerOptions.get().declarationDir!=null||e.declarationDir!=null;return l(this,o(e.outDir),o(e.declarationDir));function*l(e,o,u){for(let s of e.getSourceFiles()){let e=s.getEmitOutput({emitOnlyDtsFiles:n});if(e.getEmitSkipped()){yield s.getFilePath();continue}for(let n of e.getOutputFiles()){let e=n.getFilePath(),s=n.getWriteByteOrderMark()?t.FileUtils.getTextWithByteOrderMark(n.getText()):n.getText();o!=null&&(r.test(e)||i.test(e)||!c&&a.test(e))?e=t.FileUtils.pathJoin(o,t.FileUtils.getBaseName(e)):u!=null&&a.test(e)&&(e=t.FileUtils.pathJoin(u,t.FileUtils.getBaseName(e))),yield{filePath:e,fileText:s}}}for(let t of e.getDirectories())yield*l(t,s(o,t),s(u,t))}}copyToDirectory(e,n){let r=typeof e==`string`?e:e.getPath();return this.copy(t.FileUtils.pathJoin(r,this.getBaseName()),n)}copy(e,t){let n=this.getPath(),r=this._context.fileSystemWrapper,i=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath());return n===i?this:(t=em(t),t.includeUntrackedFiles&&r.queueCopyDirectory(n,i),this.#i(i,t))}async copyImmediately(e,t){let n=this._context.fileSystemWrapper,r=this.getPath(),i=n.getStandardizedAbsolutePath(e,r);if(r===i)return await this.save(),this;t=em(t);let a=this.#i(i,t);return t.includeUntrackedFiles&&await n.copyDirectoryImmediately(r,i),await a.save(),a}copyImmediatelySync(e,t){let n=this._context.fileSystemWrapper,r=this.getPath(),i=n.getStandardizedAbsolutePath(e,r);if(r===i)return this.saveSync(),this;t=em(t);let a=this.#i(i,t);return t.includeUntrackedFiles&&n.copyDirectoryImmediatelySync(r,i),a.saveSync(),a}#i(e,t){if(this.getPath()===e)return this;let{fileSystemWrapper:n,compilerFactory:r}=this._context,i=[this,...this.getDescendantDirectories()].map(t=>({newDirPath:t===this?e:n.getStandardizedAbsolutePath(this.getRelativePathTo(t),e)})),a=this.getDescendantSourceFiles().map(t=>({sourceFile:t,newFilePath:n.getStandardizedAbsolutePath(this.getRelativePathTo(t),e),references:this.#c(t)}));for(let{newDirPath:e}of i)this._context.compilerFactory.createDirectoryOrAddIfExists(e,{markInProject:this._isInProject()});for(let{sourceFile:e,newFilePath:n}of a)e._copyInternal(n,t);for(let{references:e,newFilePath:t}of a)this.getSourceFileOrThrow(t)._updateReferencesForCopyInternal(e);return r.getDirectoryFromCache(e)}moveToDirectory(e,n){let r=typeof e==`string`?e:e.getPath();return this.move(t.FileUtils.pathJoin(r,this.getBaseName()),n)}move(e,t){let n=this._context.fileSystemWrapper,r=this.getPath(),i=n.getStandardizedAbsolutePath(e,r);return r===i?this:this.#a(i,t,()=>n.queueMoveDirectory(r,i))}async moveImmediately(e,t){let n=this._context.fileSystemWrapper,r=this.getPath(),i=n.getStandardizedAbsolutePath(e,r);return r===i?(await this.save(),this):(this.#a(i,t),await n.moveDirectoryImmediately(r,i),await this.save(),this)}moveImmediatelySync(e,t){let n=this._context.fileSystemWrapper,r=this.getPath(),i=n.getStandardizedAbsolutePath(e,r);return r===i?(this.saveSync(),this):(this.#a(i,t),n.moveDirectoryImmediatelySync(r,i),this.saveSync(),this)}#a(e,t,n){let r=this.getPath();if(r===e)return this;let i=this._context.compilerFactory.getDirectoryFromCacheOnlyIfInCache(e),a=i!=null&&i._isInProject();n&&n();let o=this._context.fileSystemWrapper,s=this._context.compilerFactory,c=[this,...this.getDescendantDirectories()].map(t=>({directory:t,oldPath:t.getPath(),newDirPath:t===this?e:o.getStandardizedAbsolutePath(this.getRelativePathTo(t),e)})),l=this.getDescendantSourceFiles().map(t=>({sourceFile:t,newFilePath:o.getStandardizedAbsolutePath(this.getRelativePathTo(t),e),references:this.#l(t)}));for(let{directory:e,oldPath:t,newDirPath:n}of c)s.removeDirectoryFromCache(t),s.getDirectoryFromCache(n)?._forgetOnlyThis(),e._setPathInternal(n),s.addDirectoryToCache(e);for(let{sourceFile:e,newFilePath:n}of l)e._moveInternal(n,t);for(let{sourceFile:e,references:t}of l)e._updateReferencesForMoveInternal(t,r);return a&&this._markAsInProject(),this}clear(){let e=this.getPath();this.#o(),this._context.fileSystemWrapper.queueDirectoryDelete(e),this._context.fileSystemWrapper.queueMkdir(e)}async clearImmediately(){let e=this.getPath();this.#o(),await this._context.fileSystemWrapper.clearDirectoryImmediately(e)}clearImmediatelySync(){let e=this.getPath();this.#o(),this._context.fileSystemWrapper.clearDirectoryImmediatelySync(e)}delete(){let e=this.getPath();this.#o(),this._context.fileSystemWrapper.queueDirectoryDelete(e),this.forget()}#o(){for(let e of this.getSourceFiles())e.delete();for(let e of this.getDirectories())e.delete()}async deleteImmediately(){let{fileSystemWrapper:e}=this._context,t=this.getPath();this.forget(),await e.deleteDirectoryImmediately(t)}deleteImmediatelySync(){let{fileSystemWrapper:e}=this._context,t=this.getPath();this.forget(),e.deleteDirectoryImmediatelySync(t)}forget(){if(!this.wasForgotten()){for(let e of this.getSourceFiles())e.forget();for(let e of this.getDirectories())e.forget();this._forgetOnlyThis()}}_forgetOnlyThis(){this.wasForgotten()||(this._context.compilerFactory.removeDirectoryFromCache(this.getPath()),this.#e=void 0)}async save(){await this._context.fileSystemWrapper.saveForDirectory(this.getPath());let e=this.getDescendantSourceFiles().filter(e=>!e.isSaved());await Promise.all(e.map(e=>e.save()))}saveSync(){this._context.fileSystemWrapper.saveForDirectorySync(this.getPath()),this.getDescendantSourceFiles().filter(e=>!e.isSaved()).forEach(e=>e.saveSync())}getRelativePathTo(n){let r=this;return t.FileUtils.getRelativePathTo(this.getPath(),i());function i(){return n instanceof Uc?n.getFilePath():n instanceof e?n.getPath():r._context.fileSystemWrapper.getStandardizedAbsolutePath(n,r.getPath())}}getRelativePathAsModuleSpecifierTo(n){let r=this._context.program.getEmitModuleResolutionKind(),i=this,a=t.FileUtils.getRelativePathTo(this.getPath(),o()).replace(/((\.d\.ts$)|(\.[^/.]+$))/i,``);return a.startsWith(`../`)?a:`./`+a;function o(){return n instanceof Uc?a(n):n instanceof e?o(n):s(i._context.fileSystemWrapper.getStandardizedAbsolutePath(n,i.getPath()));function a(e){return s(e.getFilePath())}function o(e){switch(r){case t.ModuleResolutionKind.Node10:return e===i?t.FileUtils.pathJoin(e.getPath(),`index.ts`):e.getPath();case t.ModuleResolutionKind.Classic:case t.ModuleResolutionKind.Node16:case t.ModuleResolutionKind.NodeNext:case t.ModuleResolutionKind.Bundler:return t.FileUtils.pathJoin(e.getPath(),`index.ts`);default:return t.errors.throwNotImplementedForNeverValueError(r)}}function s(e){let n=t.FileUtils.getDirPath(e);switch(r){case t.ModuleResolutionKind.Node10:return n===i.getPath()?e:e.replace(/\/index?(\.d\.ts|\.ts|\.js)$/i,``);case t.ModuleResolutionKind.Classic:case t.ModuleResolutionKind.Node16:case t.ModuleResolutionKind.NodeNext:case t.ModuleResolutionKind.Bundler:return e;default:return t.errors.throwNotImplementedForNeverValueError(r)}}}}getProject(){return this._context.project}wasForgotten(){return this.#e==null}_isInProject(){return this._context.inProjectCoordinator.isDirectoryInProject(this)}_markAsInProject(){this._context.inProjectCoordinator.markDirectoryAsInProject(this)}_hasLoadedParent(){return this._context.compilerFactory.containsDirectoryAtPath(t.FileUtils.getDirPath(this.getPath()))}#s(){if(this.wasForgotten())throw new t.errors.InvalidOperationError(`Cannot use a directory that was deleted, removed, or overwritten.`)}#c(e){return e._getReferencesForCopyInternal().filter(e=>!this.isAncestorOf(e[1]))}#l(e){let{literalReferences:t,referencingLiterals:n}=e._getReferencesForMoveInternal();return{literalReferences:t.filter(e=>!this.isAncestorOf(e[1])),referencingLiterals:n.filter(e=>!this.isAncestorOf(e._sourceFile))}}static#u(e,t){if(t instanceof Uc&&(t=t.getDirectory(),e===t))return!0;if(e.#n.length>=t.#n.length)return!1;for(let n=e.#n.length-1;n>=0;n--)if(e.#n[n]!==t.#n[n])return!1;return!0}};function em(e){return e=t.ObjectUtils.clone(e||{}),N(e,`includeUntrackedFiles`,!0),e}function tm(e){return typeof e==`string`}var nm=class{#e;#t;constructor(e,t){this.#t=e,this.#e=t}addDirectoryAtPathIfExists(e,n){let r=this.#t.getDirectoryFromPath(e,n);if(r!=null){if(n.recursive)for(let r of t.FileUtils.getDescendantDirectories(this.#e,e))this.#t.createDirectoryOrAddIfExists(r,n);return r}}addDirectoryAtPath(e,n){let r=this.addDirectoryAtPathIfExists(e,n);if(r==null)throw new t.errors.DirectoryNotFoundError(e);return r}createDirectoryOrAddIfExists(e,t){return this.#t.createDirectoryOrAddIfExists(e,t)}addSourceFileAtPathIfExists(e,t){return this.#t.addOrGetSourceFileFromFilePath(e,{markInProject:t.markInProject,scriptKind:void 0})}addSourceFileAtPath(e,n){let r=this.addSourceFileAtPathIfExists(e,n);if(r==null)throw new t.errors.FileNotFoundError(this.#e.getStandardizedAbsolutePath(e));return r}addSourceFilesAtPaths(e,n){typeof e==`string`&&(e=[e]);let r=[],i=new Set;for(let a of this.#e.globSync(e)){let e=this.addSourceFileAtPathIfExists(a,n);e!=null&&r.push(e),i.add(t.FileUtils.getDirPath(a))}for(let e of t.FileUtils.getParentMostPaths(Array.from(i)))this.addDirectoryAtPathIfExists(e,{recursive:!0,markInProject:n.markInProject});return r}},rm=class{#e;#t=new t.KeyValueCache;#n=new t.KeyValueCache;#r=new t.KeyValueCache;#i=new t.KeyValueCache;constructor(e){this.#e=e}has(e){return this.#t.has(e)}get(e){if(!this.#t.has(e)){for(let n of this.#i.getValues())if(t.FileUtils.pathStartsWith(n.getPath(),e))return this.createOrAddIfExists(e);return}return this.#t.get(e)}getOrphans(){return this.#i.getValues()}getAll(){return this.#t.getValuesAsArray()}*getAllByDepth(){let e=new t.KeyValueCache,n=0;for(let e of this.getOrphans())r(e);for(n=Math.min(...Array.from(e.getKeys()));e.getSize()>0;){for(let t of e.get(n)||[])yield t,t.getDirectories().forEach(r);e.removeByKey(n),n++}function r(t){let r=t._getDepth();if(n>r)throw Error(`For some reason a subdirectory had a lower depth than the parent directory: ${t.getPath()}`);e.getOrCreate(r,()=>[]).push(t)}}remove(e){this.#s(e),this.#t.removeByKey(e),this.#i.removeByKey(e)}*getChildDirectoriesOfDirectory(e){let t=this.#r.get(e)?.entries();if(t!=null)for(let e of t)yield e}*getChildSourceFilesOfDirectory(e){let t=this.#n.get(e)?.entries();if(t!=null)for(let e of t)yield e}addSourceFile(e){let n=e.getDirectoryPath();this.createOrAddIfExists(n),this.#n.getOrCreate(n,()=>new t.SortedKeyValueArray(e=>e.getBaseName(),t.LocaleStringComparer.instance)).set(e)}removeSourceFile(e){let n=t.FileUtils.getDirPath(e),r=this.#n.get(n);r!=null&&(r.removeByKey(t.FileUtils.getBaseName(e)),r.hasItems()||this.#n.removeByKey(n))}createOrAddIfExists(e){return this.has(e)?this.get(e):(this.#c(e),this.#a(e))}#a(e){let t=new $p(this.#e,e);return this.addDirectory(t),t}addDirectory(e){let n=e.getPath(),r=t.FileUtils.getDirPath(n),i=r===n;for(let e of this.#i.getValues()){let r=e.getPath(),i=t.FileUtils.getDirPath(r);i!==r&&i===n&&this.#i.removeByKey(r)}i||this.#o(e),this.has(r)||this.#i.set(n,e),this.#t.set(n,e),this.#e.fileSystemWrapper.directoryExistsSync(n)||this.#e.fileSystemWrapper.queueMkdir(n);for(let t of this.#i.getValues())e.isAncestorOf(t)&&this.#c(t.getPath())}#o(e){if(t.FileUtils.isRootDirPath(e.getPath()))return;let n=t.FileUtils.getDirPath(e.getPath());this.#r.getOrCreate(n,()=>new t.SortedKeyValueArray(e=>e.getBaseName(),t.LocaleStringComparer.instance)).set(e)}#s(e){if(t.FileUtils.isRootDirPath(e))return;let n=t.FileUtils.getDirPath(e),r=this.#r.get(n);r!=null&&(r.removeByKey(t.FileUtils.getBaseName(e)),r.hasItems()||this.#r.removeByKey(n))}#c(e){let n=[],r=t.FileUtils.getDirPath(e);for(;e!==r;){if(e=r,r=t.FileUtils.getDirPath(e),this.#t.has(e)){for(let e of n)this.#a(e);break}n.unshift(e)}}},im=class extends t.KeyValueCache{#e=[];getOrCreate(e,t){return super.getOrCreate(e,()=>{let e=t();return this.#e.length>0&&this.#e[this.#e.length-1].add(e),e})}setForgetPoint(){this.#e.push(new Set)}forgetLastPoint(){let e=this.#e.pop();e!=null&&this.#n(e.values())}rememberNode(e){if(e.wasForgotten())throw new t.errors.InvalidOperationError(`Cannot remember a node that was removed or forgotten.`);let n=!1;for(let t of this.#e)if(t.delete(e)){n=!0;break}return n&&this.#t(e),n}#t(e){let t=e.getParentSyntaxList()||e.getParent();t!=null&&this.rememberNode(t)}#n(e){for(let n of e)n.wasForgotten()||n.getKind()===t.SyntaxKind.SourceFile||n._forgetOnlyThis()}},am={[t.SyntaxKind.SourceFile]:Uc,[t.SyntaxKind.ArrayBindingPattern]:Da,[t.SyntaxKind.ArrayLiteralExpression]:Ua,[t.SyntaxKind.ArrayType]:iu,[t.SyntaxKind.ArrowFunction]:el,[t.SyntaxKind.AsExpression]:Qa,[t.SyntaxKind.AwaitExpression]:eo,[t.SyntaxKind.BigIntLiteral]:Wf,[t.SyntaxKind.BindingElement]:ka,[t.SyntaxKind.BinaryExpression]:Pa,[t.SyntaxKind.Block]:hs,[t.SyntaxKind.BreakStatement]:gs,[t.SyntaxKind.CallExpression]:no,[t.SyntaxKind.CallSignature]:Qd,[t.SyntaxKind.CaseBlock]:vs,[t.SyntaxKind.CaseClause]:bs,[t.SyntaxKind.CatchClause]:Ss,[t.SyntaxKind.ClassDeclaration]:El,[t.SyntaxKind.ClassExpression]:Pl,[t.SyntaxKind.ClassStaticBlockDeclaration]:Il,[t.SyntaxKind.ConditionalType]:au,[t.SyntaxKind.Constructor]:Bl,[t.SyntaxKind.ConstructorType]:lu,[t.SyntaxKind.ConstructSignature]:tf,[t.SyntaxKind.ContinueStatement]:ws,[t.SyntaxKind.CommaListExpression]:io,[t.SyntaxKind.ComputedPropertyName]:hf,[t.SyntaxKind.ConditionalExpression]:oo,[t.SyntaxKind.DebuggerStatement]:Es,[t.SyntaxKind.Decorator]:Jl,[t.SyntaxKind.DefaultClause]:Os,[t.SyntaxKind.DeleteExpression]:co,[t.SyntaxKind.DoStatement]:js,[t.SyntaxKind.ElementAccessExpression]:uo,[t.SyntaxKind.EmptyStatement]:Ns,[t.SyntaxKind.EnumDeclaration]:Kd,[t.SyntaxKind.EnumMember]:Jd,[t.SyntaxKind.ExportAssignment]:rc,[t.SyntaxKind.ExportDeclaration]:ac,[t.SyntaxKind.ExportSpecifier]:cc,[t.SyntaxKind.ExpressionWithTypeArguments]:du,[t.SyntaxKind.ExpressionStatement]:Fs,[t.SyntaxKind.ExternalModuleReference]:uc,[t.SyntaxKind.QualifiedName]:bf,[t.SyntaxKind.ForInStatement]:Ls,[t.SyntaxKind.ForOfStatement]:zs,[t.SyntaxKind.ForStatement]:Vs,[t.SyntaxKind.FunctionDeclaration]:cl,[t.SyntaxKind.FunctionExpression]:ul,[t.SyntaxKind.FunctionType]:pu,[t.SyntaxKind.GetAccessor]:Hl,[t.SyntaxKind.HeritageClause]:Yd,[t.SyntaxKind.Identifier]:_f,[t.SyntaxKind.IfStatement]:Us,[t.SyntaxKind.ImportClause]:gc,[t.SyntaxKind.ImportDeclaration]:vc,[t.SyntaxKind.ImportEqualsDeclaration]:Sc,[t.SyntaxKind.ImportSpecifier]:wc,[t.SyntaxKind.ImportType]:mu,[t.SyntaxKind.ImportAttribute]:fc,[t.SyntaxKind.ImportAttributes]:mc,[t.SyntaxKind.IndexedAccessType]:hu,[t.SyntaxKind.IndexSignature]:rf,[t.SyntaxKind.InferType]:gu,[t.SyntaxKind.InterfaceDeclaration]:of,[t.SyntaxKind.IntersectionType]:_u,[t.SyntaxKind.JSDocAllType]:Bu,[t.SyntaxKind.JSDocAugmentsTag]:Ju,[t.SyntaxKind.JSDocAuthorTag]:Yu,[t.SyntaxKind.JSDocCallbackTag]:Xu,[t.SyntaxKind.JSDocClassTag]:Zu,[t.SyntaxKind.JSDocDeprecatedTag]:Qu,[t.SyntaxKind.JSDocEnumTag]:$u,[t.SyntaxKind.JSDocFunctionType]:td,[t.SyntaxKind.JSDocImplementsTag]:nd,[t.SyntaxKind.JSDocLink]:rd,[t.SyntaxKind.JSDocLinkCode]:id,[t.SyntaxKind.JSDocLinkPlain]:ad,[t.SyntaxKind.JSDocMemberName]:od,[t.SyntaxKind.JSDocNamepathType]:sd,[t.SyntaxKind.JSDocNameReference]:cd,[t.SyntaxKind.JSDocNonNullableType]:ld,[t.SyntaxKind.JSDocNullableType]:ud,[t.SyntaxKind.JSDocOptionalType]:dd,[t.SyntaxKind.JSDocOverrideTag]:md,[t.SyntaxKind.JSDocParameterTag]:gd,[t.SyntaxKind.JSDocPrivateTag]:_d,[t.SyntaxKind.JSDocPropertyTag]:vd,[t.SyntaxKind.JSDocProtectedTag]:yd,[t.SyntaxKind.JSDocPublicTag]:bd,[t.SyntaxKind.JSDocReturnTag]:Cd,[t.SyntaxKind.JSDocReadonlyTag]:xd,[t.SyntaxKind.JSDocThrowsTag]:Id,[t.SyntaxKind.JSDocOverloadTag]:pd,[t.SyntaxKind.JSDocSatisfiesTag]:Td,[t.SyntaxKind.JSDocSeeTag]:Dd,[t.SyntaxKind.JSDocSignature]:Od,[t.SyntaxKind.JSDocTag]:Vd,[t.SyntaxKind.JSDocTemplateTag]:jd,[t.SyntaxKind.JSDocText]:Md,[t.SyntaxKind.JSDocThisTag]:Pd,[t.SyntaxKind.JSDocTypeExpression]:Rd,[t.SyntaxKind.JSDocTypeLiteral]:zd,[t.SyntaxKind.JSDocTypeTag]:Bd,[t.SyntaxKind.JSDocTypedefTag]:Ld,[t.SyntaxKind.JSDocUnknownType]:Hd,[t.SyntaxKind.JSDocVariadicType]:Ud,[t.SyntaxKind.JsxAttribute]:Sf,[t.SyntaxKind.JsxClosingElement]:wf,[t.SyntaxKind.JsxClosingFragment]:Tf,[t.SyntaxKind.JsxElement]:Df,[t.SyntaxKind.JsxExpression]:Af,[t.SyntaxKind.JsxFragment]:jf,[t.SyntaxKind.JsxNamespacedName]:Nf,[t.SyntaxKind.JsxOpeningElement]:Ff,[t.SyntaxKind.JsxOpeningFragment]:If,[t.SyntaxKind.JsxSelfClosingElement]:Rf,[t.SyntaxKind.JsxSpreadAttribute]:Bf,[t.SyntaxKind.JsxText]:Hf,[t.SyntaxKind.LabeledStatement]:Gs,[t.SyntaxKind.LiteralType]:vu,[t.SyntaxKind.MappedType]:yu,[t.SyntaxKind.MetaProperty]:_o,[t.SyntaxKind.MethodDeclaration]:_l,[t.SyntaxKind.MethodSignature]:cf,[t.SyntaxKind.ModuleBlock]:Ec,[t.SyntaxKind.ModuleDeclaration]:kc,[t.SyntaxKind.NamedExports]:Nc,[t.SyntaxKind.NamedImports]:Fc,[t.SyntaxKind.NamedTupleMember]:xu,[t.SyntaxKind.NamespaceExport]:Lc,[t.SyntaxKind.NamespaceImport]:zc,[t.SyntaxKind.NewExpression]:yo,[t.SyntaxKind.NonNullExpression]:xo,[t.SyntaxKind.NotEmittedStatement]:qs,[t.SyntaxKind.NoSubstitutionTemplateLiteral]:op,[t.SyntaxKind.NumericLiteral]:ep,[t.SyntaxKind.ObjectBindingPattern]:Aa,[t.SyntaxKind.ObjectLiteralExpression]:Do,[t.SyntaxKind.OmittedExpression]:Fo,[t.SyntaxKind.Parameter]:fl,[t.SyntaxKind.ParenthesizedExpression]:q,[t.SyntaxKind.ParenthesizedType]:Su,[t.SyntaxKind.PartiallyEmittedExpression]:Lo,[t.SyntaxKind.PostfixUnaryExpression]:zo,[t.SyntaxKind.PrefixUnaryExpression]:Vo,[t.SyntaxKind.PrivateIdentifier]:yf,[t.SyntaxKind.PropertyAccessExpression]:Uo,[t.SyntaxKind.PropertyAssignment]:ko,[t.SyntaxKind.PropertyDeclaration]:Wl,[t.SyntaxKind.PropertySignature]:uf,[t.SyntaxKind.RegularExpressionLiteral]:np,[t.SyntaxKind.RestType]:Cu,[t.SyntaxKind.ReturnStatement]:Ys,[t.SyntaxKind.SatisfiesExpression]:Go,[t.SyntaxKind.SetAccessor]:Kl,[t.SyntaxKind.ShorthandPropertyAssignment]:jo,[t.SyntaxKind.SpreadAssignment]:No,[t.SyntaxKind.SpreadElement]:qo,[t.SyntaxKind.StringLiteral]:ip,[t.SyntaxKind.SwitchStatement]:Zs,[t.SyntaxKind.SyntaxList]:vn,[t.SyntaxKind.TaggedTemplateExpression]:sp,[t.SyntaxKind.TemplateExpression]:lp,[t.SyntaxKind.TemplateHead]:dp,[t.SyntaxKind.TemplateLiteralType]:wu,[t.SyntaxKind.TemplateMiddle]:pp,[t.SyntaxKind.TemplateSpan]:hp,[t.SyntaxKind.TemplateTail]:_p,[t.SyntaxKind.ThisType]:Tu,[t.SyntaxKind.ThrowStatement]:$s,[t.SyntaxKind.TryStatement]:tc,[t.SyntaxKind.TupleType]:Eu,[t.SyntaxKind.TypeAliasDeclaration]:Ou,[t.SyntaxKind.TypeAssertionExpression]:rs,[t.SyntaxKind.TypeLiteral]:Au,[t.SyntaxKind.TypeOperator]:ju,[t.SyntaxKind.TypeParameter]:Nu,[t.SyntaxKind.TypePredicate]:Fu,[t.SyntaxKind.TypeQuery]:Iu,[t.SyntaxKind.TypeReference]:Lu,[t.SyntaxKind.UnionType]:Ru,[t.SyntaxKind.VariableDeclaration]:yp,[t.SyntaxKind.VariableDeclarationList]:xp,[t.SyntaxKind.VariableStatement]:qc,[t.SyntaxKind.JSDoc]:eu,[t.SyntaxKind.TypeOfExpression]:as,[t.SyntaxKind.WhileStatement]:Yc,[t.SyntaxKind.WithStatement]:Zc,[t.SyntaxKind.YieldExpression]:ls,[t.SyntaxKind.SemicolonToken]:H,[t.SyntaxKind.AnyKeyword]:Ma,[t.SyntaxKind.BooleanKeyword]:Ma,[t.SyntaxKind.FalseKeyword]:Jf,[t.SyntaxKind.ImportKeyword]:po,[t.SyntaxKind.InferKeyword]:H,[t.SyntaxKind.NeverKeyword]:H,[t.SyntaxKind.NullKeyword]:Qf,[t.SyntaxKind.NumberKeyword]:Ma,[t.SyntaxKind.ObjectKeyword]:Ma,[t.SyntaxKind.StringKeyword]:Ma,[t.SyntaxKind.SymbolKeyword]:Ma,[t.SyntaxKind.SuperKeyword]:Zo,[t.SyntaxKind.ThisKeyword]:ts,[t.SyntaxKind.TrueKeyword]:Kf,[t.SyntaxKind.UndefinedKeyword]:Ma,[t.SyntaxKind.VoidExpression]:ss},om=class{#e;#t=new Map;#n=new t.WeakCache;#r=new t.WeakCache;#i=new t.WeakCache;#a=new t.WeakCache;#o=new t.WeakCache;#s=new t.WeakCache;#c=new t.WeakCache;#l=new t.WeakCache;#u=new t.WeakCache;#d=new t.WeakCache;#f=new t.WeakCache;#p=new t.WeakCache;#m=new t.WeakCache;#h=new im;#g;#_=new t.EventContainer;#v=new t.EventContainer;documentRegistry;constructor(e){this.documentRegistry=new t.DocumentRegistry(e.fileSystemWrapper),this.#g=new rm(e),e.compilerOptions.onModified(()=>{let e=Array.from(this.#t.values());for(let t of e)rn(t)}),this.#e=e}*getSourceFilesByDirectoryDepth(){for(let e of this.getDirectoriesByDepth())yield*e.getSourceFiles()}getSourceFilePaths(){return this.#t.keys()}getChildDirectoriesOfDirectory(e){return this.#g.getChildDirectoriesOfDirectory(e)}getChildSourceFilesOfDirectory(e){return this.#g.getChildSourceFilesOfDirectory(e)}onSourceFileAdded(e,t=!0){t?this.#_.subscribe(e):this.#_.unsubscribe(e)}onSourceFileRemoved(e){this.#v.subscribe(e)}createSourceFile(e,n,r){if(n=n instanceof Function?I(this.#e.createWriter(),n):n||``,typeof n==`string`)return this.createSourceFileFromText(e,n,r);let i=this.#e.createWriter();return this.#e.structurePrinterFactory.forSourceFile({isAmbient:t.FileUtils.getExtension(e)===`.d.ts`}).printText(i,n),this.createSourceFileFromText(e,i.toString(),r)}createSourceFileFromText(e,t,n){return e=this.#e.fileSystemWrapper.getStandardizedAbsolutePath(e),n.overwrite===!0?this.#y(e,t,n):(this.throwIfFileExists(e,`Did you mean to provide the overwrite option?`),this.#b(e,t,n))}throwIfFileExists(e,n){if(!(!this.containsSourceFileAtPath(e)&&!this.#e.fileSystemWrapper.fileExistsSync(e)))throw n=n==null?``:n+` `,new t.errors.InvalidOperationError(`${n}A source file already exists at the provided file path: ${e}`)}#y(e,t,n){e=this.#e.fileSystemWrapper.getStandardizedAbsolutePath(e);let r=this.addOrGetSourceFileFromFilePath(e,n);return r==null?this.#b(e,t,n):(r.getChildren().forEach(e=>e.forget()),this.replaceCompilerNode(r,this.createCompilerSourceFileFromText(e,t,n.scriptKind)),r)}getSourceFileFromCacheFromFilePath(e){return e=this.#e.fileSystemWrapper.getStandardizedAbsolutePath(e),this.#t.get(e)}addOrGetSourceFileFromFilePath(e,t){e=this.#e.fileSystemWrapper.getStandardizedAbsolutePath(e);let n=this.#t.get(e);if(n==null){let r=this.#e.fileSystemWrapper.readFileIfExistsSync(e,this.#e.getEncoding());r!=null&&(this.#e.logger.log(`Loaded file: ${e}`),n=this.#b(e,r,t),n._setIsSaved(!0))}return n!=null&&t.markInProject&&n._markAsInProject(),n}containsSourceFileAtPath(e){return e=this.#e.fileSystemWrapper.getStandardizedAbsolutePath(e),this.#t.has(e)}containsDirectoryAtPath(e){return e=this.#e.fileSystemWrapper.getStandardizedAbsolutePath(e),this.#g.has(e)}getSourceFileForNode(e){let n=e;for(;n.kind!==t.SyntaxKind.SourceFile;){if(n.parent==null)return;n=n.parent}return this.getSourceFile(n,{markInProject:!1})}hasCompilerNode(e){return this.#h.has(e)}getExistingNodeFromCompilerNode(e){return this.#h.get(e)}getNodeFromCompilerNode(e,n){if(e.kind===t.SyntaxKind.SourceFile)return this.getSourceFile(e,{markInProject:!1});return this.#h.getOrCreate(e,()=>{let e=r.call(this);return a.call(this,e),e});function r(){return i(e)?y.isCommentStatement(e)?new Cs(this.#e,e,n):y.isCommentClassElement(e)?new Ll(this.#e,e,n):y.isCommentTypeElement(e)?new $d(this.#e,e,n):y.isCommentObjectLiteralElement(e)?new Co(this.#e,e,n):y.isCommentEnumMember(e)?new Wd(this.#e,e,n):t.errors.throwNotImplementedForNeverValueError(e):new(am[e.kind]||H)(this.#e,e,n)}function i(e){return e._commentKind!=null}function a(r){if(e.parent!=null){let t=this.getNodeFromCompilerNode(e.parent,n);t._wrappedChildCount++}let i=r._getParentSyntaxListIfWrapped();if(i!=null&&i._wrappedChildCount++,e.kind===t.SyntaxKind.SyntaxList){let e=0;for(let t of r._getChildrenInCacheIterator())e++;r._wrappedChildCount=e}}}#b(e,n,r){let i=t.StringUtils.hasBom(n);i&&(n=t.StringUtils.stripBom(n));let a=this.getSourceFile(this.createCompilerSourceFileFromText(e,n,r.scriptKind),r);return i&&(a._hasBom=!0),a}createCompilerSourceFileFromText(e,n,r){return this.documentRegistry.createOrUpdateSourceFile(e,this.#e.compilerOptions.get(),t.ts.ScriptSnapshot.fromString(n),r)}getSourceFile(e,t){let n=!1,r=this.#t.get(e.fileName)??this.#h.getOrCreate(e,()=>{let r=new Uc(this.#e,e);return t.markInProject||this.#e.inProjectCoordinator.setSourceFileNotInProject(r),this.#x(r),n=!0,r});return t.markInProject&&r._markAsInProject(),n&&this.#_.fire(r),r}#x(e){this.#t.set(e.getFilePath(),e),this.#e.fileSystemWrapper.removeFileDelete(e.getFilePath()),this.#g.addSourceFile(e)}getDirectoryFromPath(e,t){e=this.#e.fileSystemWrapper.getStandardizedAbsolutePath(e);let n=this.#g.get(e);return n==null&&this.#e.fileSystemWrapper.directoryExistsSync(e)&&(n=this.#g.createOrAddIfExists(e)),n!=null&&t.markInProject&&n._markAsInProject(),n}createDirectoryOrAddIfExists(e,t){let n=this.#g.createOrAddIfExists(e);return n!=null&&t.markInProject&&n._markAsInProject(),n}getDirectoryFromCache(e){return this.#g.get(e)}getDirectoryFromCacheOnlyIfInCache(e){return this.#g.has(e)?this.#g.get(e):void 0}getDirectoriesByDepth(){return this.#g.getAllByDepth()}getOrphanDirectories(){return this.#g.getOrphans()}getSymbolDisplayPart(e){return this.#l.getOrCreate(e,()=>new Kp(e))}getType(e){return(e.flags&t.TypeFlags.TypeParameter)===t.TypeFlags.TypeParameter?this.getTypeParameter(e):this.#p.getOrCreate(e,()=>new Xp(this.#e,e))}getTypeParameter(e){return this.#m.getOrCreate(e,()=>new Zp(this.#e,e))}getSignature(e){return this.#s.getOrCreate(e,()=>new Sp(this.#e,e))}getSymbol(e){return this.#c.getOrCreate(e,()=>new Cp(this.#e,e))}getDefinitionInfo(e){return this.#r.getOrCreate(e,()=>new jp(this.#e,e))}getDocumentSpan(e){return this.#i.getOrCreate(e,()=>new Ap(this.#e,e))}getReferencedSymbolEntry(e){return this.#u.getOrCreate(e,()=>new Wp(this.#e,e))}getReferencedSymbol(e){return this.#d.getOrCreate(e,()=>new Vp(this.#e,e))}getReferencedSymbolDefinitionInfo(e){return this.#f.getOrCreate(e,()=>new Hp(this.#e,e))}getDiagnostic(e){return this.#n.getOrCreate(e,()=>e.start==null?new Np(this.#e,e):new Pp(this.#e,e))}getDiagnosticWithLocation(e){return this.#n.getOrCreate(e,()=>new Pp(this.#e,e))}getDiagnosticMessageChain(e){return this.#a.getOrCreate(e,()=>new Mp(e))}getJSDocTagInfo(e){return this.#o.getOrCreate(e,()=>new kd(e))}replaceCompilerNode(e,n){let r=e instanceof H?e.compilerNode:e,i=e instanceof H?e:this.#h.get(e);if(r.kind===t.SyntaxKind.SourceFile&&r.fileName!==n.fileName){let e=i;this.#S(r),e._replaceCompilerNodeFromFactory(n),this.#h.set(n,e),this.#x(e),this.#_.fire(e)}else this.#h.replaceKey(r,n),i?._replaceCompilerNodeFromFactory(n)}removeNodeFromCache(e){this.#S(e.compilerNode)}#S(e){if(this.#h.removeByKey(e),e.kind===t.SyntaxKind.SourceFile){let t=e,n=this.#e.fileSystemWrapper.getStandardizedAbsolutePath(t.fileName);this.#g.removeSourceFile(n);let r=this.#t.get(n);this.#t.delete(n),this.documentRegistry.removeSourceFile(n),r!=null&&this.#v.fire(r)}}addDirectoryToCache(e){this.#g.addDirectory(e)}removeDirectoryFromCache(e){this.#g.remove(e)}forgetNodesCreatedInBlock(e){this.#h.setForgetPoint();let t=!1,n;try{if(n=e((...e)=>{for(let t of e)this.#h.rememberNode(t)}),H.isNode(n)&&this.#h.rememberNode(n),r(n))return t=!0,n.then(e=>(H.isNode(e)&&this.#h.rememberNode(e),this.#h.forgetLastPoint(),e))}finally{t||this.#h.forgetLastPoint()}return n;function r(e){return e!=null&&typeof e.then==`function`}}},sm=class{#e;#t=new Set;constructor(e){e.onSourceFileRemoved(e=>{this.#t.delete(e)}),this.#e=e}setSourceFileNotInProject(e){this.#t.add(e),e._inProject=!1}markSourceFileAsInProject(e){this.isSourceFileInProject(e)||(this.#n(e),this.#t.delete(e))}markSourceFilesAsInProjectForResolution(){let e=this.#e,n=[],r=[];for(let e of[...this.#t.values()])i(e)?(this.#n(e),this.#t.delete(e),n.push(e)):r.push(e);return{changedSourceFiles:n,unchangedSourceFiles:r};function i(n){let r=n.getFilePath(),i=r.toLowerCase().lastIndexOf(`/node_modules/`);if(i===-1)return!0;let a=r.substring(0,i+14-1),o=e.getDirectoryFromCacheOnlyIfInCache(a);if(o!=null&&o._isInProject())return!0;let s=n.getDirectory();for(;s!=null&&s.getPath()!==a;){if(s._isInProject())return!0;s=e.getDirectoryFromCacheOnlyIfInCache(t.FileUtils.getDirPath(s.getPath()))}return!1}}#n(e){e._inProject=!0,this.markDirectoryAsInProject(e.getDirectory())}isSourceFileInProject(e){return e._inProject===!0}setDirectoryAndFilesAsNotInProjectForTesting(e){for(let t of e.getDirectories())this.setDirectoryAndFilesAsNotInProjectForTesting(t);for(let t of e.getSourceFiles())delete t._inProject,this.#t.add(t);delete e._inProject}markDirectoryAsInProject(e){if(this.isDirectoryInProject(e))return;let n=this,r=this.#e;e._inProject=!0,i(e);function i(e){let t=Array.from(a(e)),r=t[t.length-1];if(!(r==null||!n.isDirectoryInProject(r)))for(let e of t)e._inProject=!0}function*a(e){if(t.FileUtils.isRootDirPath(e.getPath()))return;let i=t.FileUtils.getDirPath(e.getPath()),o=r.getDirectoryFromCacheOnlyIfInCache(i);o!=null&&(yield o,n.isDirectoryInProject(o)||(yield*a(o)))}}isDirectoryInProject(e){return e._inProject===!0}},cm=class{_getFormatCodeSettings;constructor(e){this._getFormatCodeSettings=e}getFormatCodeSettings(){return this._getFormatCodeSettings()}forInitializerExpressionableNode(){return new Fn}forModifierableNode(){return new In}forReturnTypedNode(e){return new Ln(e)}forTypedNode(e,t){return new Rn(e,t)}forClassDeclaration(e){return new qn(this,e)}forClassMember(e){return new Vr(this,e)}forClassStaticBlockDeclaration(){return new Hr(this)}forConstructorDeclaration(e){return new Ur(this,e)}forGetAccessorDeclaration(e){return new Wr(this,e)}forMethodDeclaration(e){return new Gr(this,e)}forPropertyDeclaration(){return new Kr(this)}forSetAccessorDeclaration(e){return new qr(this,e)}forDecorator(){return new Yr(this)}forJSDoc(){return new Xr(this)}forJSDocTag(e){return new Zr(this,e)}forEnumDeclaration(){return new Qr(this)}forEnumMember(){return new $r(this)}forObjectLiteralExpressionProperty(){return new ei(this)}forPropertyAssignment(){return new ti(this)}forShorthandPropertyAssignment(){return new ni(this)}forSpreadAssignment(){return new ri(this)}forFunctionDeclaration(e){return new ii(this,e)}forParameterDeclaration(){return new ai(this)}forCallSignatureDeclaration(){return new oi(this)}forConstructSignatureDeclaration(){return new si(this)}forIndexSignatureDeclaration(){return new ci(this)}forInterfaceDeclaration(){return new li(this)}forMethodSignature(){return new ui(this)}forPropertySignature(){return new di(this)}forTypeElementMemberedNode(){return new fi(this)}forTypeElementMember(){return new pi(this)}forJsxAttributeDecider(){return new mi(this)}forJsxAttribute(){return new hi(this)}forJsxChildDecider(){return new gi(this)}forJsxElement(){return new _i(this)}forJsxNamespacedName(){return new vi(this)}forJsxSelfClosingElement(){return new yi(this)}forJsxSpreadAttribute(){return new bi(this)}forExportAssignment(){return new xi(this)}forExportDeclaration(){return new Si(this)}forImportAttribute(){return new Ci(this)}forImportDeclaration(){return new wi(this)}forModuleDeclaration(e){return new Ti(this,e)}forNamedImportExportSpecifier(){return new Ei(this)}forSourceFile(e){return new Di(this,e)}forStatementedNode(e){return new Oi(this,e)}forStatement(e){return new ki(this,e)}forVariableStatement(){return new Ai(this)}forTypeAliasDeclaration(){return new ji(this)}forTypeParameterDeclaration(){return new Mi(this)}forVariableDeclaration(){return new Ni(this)}};Vc([t.Memoize],cm.prototype,`forInitializerExpressionableNode`,null),Vc([t.Memoize],cm.prototype,`forModifierableNode`,null),Vc([t.Memoize],cm.prototype,`forReturnTypedNode`,null),Vc([t.Memoize],cm.prototype,`forTypedNode`,null),Vc([t.Memoize],cm.prototype,`forClassDeclaration`,null),Vc([t.Memoize],cm.prototype,`forClassMember`,null),Vc([t.Memoize],cm.prototype,`forClassStaticBlockDeclaration`,null),Vc([t.Memoize],cm.prototype,`forConstructorDeclaration`,null),Vc([t.Memoize],cm.prototype,`forGetAccessorDeclaration`,null),Vc([t.Memoize],cm.prototype,`forMethodDeclaration`,null),Vc([t.Memoize],cm.prototype,`forPropertyDeclaration`,null),Vc([t.Memoize],cm.prototype,`forSetAccessorDeclaration`,null),Vc([t.Memoize],cm.prototype,`forDecorator`,null),Vc([t.Memoize],cm.prototype,`forJSDoc`,null),Vc([t.Memoize],cm.prototype,`forJSDocTag`,null),Vc([t.Memoize],cm.prototype,`forEnumDeclaration`,null),Vc([t.Memoize],cm.prototype,`forEnumMember`,null),Vc([t.Memoize],cm.prototype,`forObjectLiteralExpressionProperty`,null),Vc([t.Memoize],cm.prototype,`forPropertyAssignment`,null),Vc([t.Memoize],cm.prototype,`forShorthandPropertyAssignment`,null),Vc([t.Memoize],cm.prototype,`forSpreadAssignment`,null),Vc([t.Memoize],cm.prototype,`forFunctionDeclaration`,null),Vc([t.Memoize],cm.prototype,`forParameterDeclaration`,null),Vc([t.Memoize],cm.prototype,`forCallSignatureDeclaration`,null),Vc([t.Memoize],cm.prototype,`forConstructSignatureDeclaration`,null),Vc([t.Memoize],cm.prototype,`forIndexSignatureDeclaration`,null),Vc([t.Memoize],cm.prototype,`forInterfaceDeclaration`,null),Vc([t.Memoize],cm.prototype,`forMethodSignature`,null),Vc([t.Memoize],cm.prototype,`forPropertySignature`,null),Vc([t.Memoize],cm.prototype,`forTypeElementMemberedNode`,null),Vc([t.Memoize],cm.prototype,`forTypeElementMember`,null),Vc([t.Memoize],cm.prototype,`forJsxAttributeDecider`,null),Vc([t.Memoize],cm.prototype,`forJsxAttribute`,null),Vc([t.Memoize],cm.prototype,`forJsxChildDecider`,null),Vc([t.Memoize],cm.prototype,`forJsxElement`,null),Vc([t.Memoize],cm.prototype,`forJsxNamespacedName`,null),Vc([t.Memoize],cm.prototype,`forJsxSelfClosingElement`,null),Vc([t.Memoize],cm.prototype,`forJsxSpreadAttribute`,null),Vc([t.Memoize],cm.prototype,`forExportAssignment`,null),Vc([t.Memoize],cm.prototype,`forExportDeclaration`,null),Vc([t.Memoize],cm.prototype,`forImportAttribute`,null),Vc([t.Memoize],cm.prototype,`forImportDeclaration`,null),Vc([t.Memoize],cm.prototype,`forModuleDeclaration`,null),Vc([t.Memoize],cm.prototype,`forNamedImportExportSpecifier`,null),Vc([t.Memoize],cm.prototype,`forSourceFile`,null),Vc([t.Memoize],cm.prototype,`forStatementedNode`,null),Vc([t.Memoize],cm.prototype,`forStatement`,null),Vc([t.Memoize],cm.prototype,`forVariableStatement`,null),Vc([t.Memoize],cm.prototype,`forTypeAliasDeclaration`,null),Vc([t.Memoize],cm.prototype,`forTypeParameterDeclaration`,null),Vc([t.Memoize],cm.prototype,`forVariableDeclaration`,null);var lm=class{#e;#t;#n;#r;get project(){if(this.#r==null)throw new t.errors.InvalidOperationError(`This operation is not permitted in this context.`);return this.#r}logger=new ae;lazyReferenceCoordinator;directoryCoordinator;fileSystemWrapper;manipulationSettings=new M;structurePrinterFactory;compilerFactory;inProjectCoordinator;constructor(e){this.#r=e.project,this.fileSystemWrapper=e.fileSystemWrapper,this.#t=e.compilerOptionsContainer,this.compilerFactory=new om(this),this.inProjectCoordinator=new sm(this.compilerFactory),this.structurePrinterFactory=new cm(()=>this.manipulationSettings.getFormatCodeSettings()),this.lazyReferenceCoordinator=new ue(this.compilerFactory),this.directoryCoordinator=new nm(this.compilerFactory,e.fileSystemWrapper),this.#e=e.createLanguageService?new Yp({context:this,configFileParsingDiagnostics:e.configFileParsingDiagnostics,resolutionHost:e.resolutionHost&&e.resolutionHost(this.getModuleResolutionHost(),()=>this.compilerOptions.get()),skipLoadingLibFiles:e.skipLoadingLibFiles,libFolderPath:e.libFolderPath}):void 0,e.typeChecker!=null&&(t.errors.throwIfTrue(e.createLanguageService,`Cannot specify a type checker and create a language service.`),this.#n=new qp(this),this.#n._reset(()=>e.typeChecker))}get compilerOptions(){return this.#t}get languageService(){if(this.#e==null)throw this.#i(`language service`);return this.#e}get program(){if(this.#e==null)throw this.#i(`program`);return this.languageService.getProgram()}get typeChecker(){if(this.#n!=null)return this.#n;if(this.#e==null)throw this.#i(`type checker`);return this.program.getTypeChecker()}hasLanguageService(){return this.#e!=null}getEncoding(){return this.compilerOptions.getEncoding()}getFormatCodeSettings(){return this.manipulationSettings.getFormatCodeSettings()}getUserPreferences(){return this.manipulationSettings.getUserPreferences()}resetProgram(){this.languageService._reset()}createWriter(){let t=this.manipulationSettings.getIndentationText();return new i.default({newLine:this.manipulationSettings.getNewLineKindAsString(),indentNumberOfSpaces:t===e.IndentationText.Tab?void 0:t.length,useTabs:t===e.IndentationText.Tab,useSingleQuote:this.manipulationSettings.getQuoteKind()===e.QuoteKind.Single})}getPreEmitDiagnostics(e){return t.ts.getPreEmitDiagnostics(this.program.compilerObject,e?.compilerNode).map(e=>this.compilerFactory.getDiagnostic(e))}getSourceFileContainer(){return{addOrGetSourceFileFromFilePath:(e,t)=>Promise.resolve(this.compilerFactory.addOrGetSourceFileFromFilePath(e,t)?.compilerNode),addOrGetSourceFileFromFilePathSync:(e,t)=>this.compilerFactory.addOrGetSourceFileFromFilePath(e,t)?.compilerNode,containsDirectoryAtPath:e=>this.compilerFactory.containsDirectoryAtPath(e),containsSourceFileAtPath:e=>this.compilerFactory.containsSourceFileAtPath(e),getSourceFileFromCacheFromFilePath:e=>this.compilerFactory.getSourceFileFromCacheFromFilePath(e)?.compilerNode,getSourceFilePaths:()=>this.compilerFactory.getSourceFilePaths(),getSourceFileVersion:e=>this.compilerFactory.documentRegistry.getSourceFileVersion(e),getChildDirectoriesOfDirectory:e=>{let t=[];for(let n of this.compilerFactory.getChildDirectoriesOfDirectory(e))t.push(n.getPath());return t}}}getModuleResolutionHost(){return t.createModuleResolutionHost({transactionalFileSystem:this.fileSystemWrapper,getEncoding:()=>this.getEncoding(),sourceFileContainer:this.getSourceFileContainer()})}#i(e){return new t.errors.InvalidOperationError(`A ${e} is required for this operation. This might occur when manipulating or getting type information from a node that was not added to a Project object and created via createWrappedNode. Please submit a bug report if you don't believe a ${e} should be required for this operation.`)}};Vc([t.Memoize],lm.prototype,`getSourceFileContainer`,null),Vc([t.Memoize],lm.prototype,`getModuleResolutionHost`,null);var um=class{_context;constructor(e={}){s();let n=c(),r=new t.TransactionalFileSystem({fileSystem:n,skipLoadingLibFiles:e.skipLoadingLibFiles,libFolderPath:e.libFolderPath}),i=e.tsConfigFilePath==null?void 0:new t.TsConfigResolver(r,r.getStandardizedAbsolutePath(e.tsConfigFilePath),d()),a=l(),o=new t.CompilerOptionsContainer(e.defaultCompilerOptions);o.set(a),this._context=new lm({project:this,compilerOptionsContainer:o,fileSystemWrapper:r,createLanguageService:!0,resolutionHost:e.resolutionHost,configFileParsingDiagnostics:i?.getErrors()??[],skipLoadingLibFiles:e.skipLoadingLibFiles,libFolderPath:e.libFolderPath}),e.manipulationSettings!=null&&this._context.manipulationSettings.set(e.manipulationSettings),i!=null&&e.skipAddingFilesFromTsConfig!==!0&&(this.#e(i,a),e.skipFileDependencyResolution||this.resolveSourceFileDependencies());function s(){if(e.fileSystem!=null&&e.useInMemoryFileSystem)throw new t.errors.InvalidOperationError(`Cannot provide a file system when specifying to use an in-memory file system.`)}function c(){return e.useInMemoryFileSystem?new t.InMemoryFileSystemHost:e.fileSystem??new t.RealFileSystemHost}function l(){return{...u(),...e.compilerOptions??{}}}function u(){return i?.getCompilerOptions()??{}}function d(){let t=`utf-8`;return e.compilerOptions==null?t:e.compilerOptions.charset??t}}get manipulationSettings(){return this._context.manipulationSettings}get compilerOptions(){return this._context.compilerOptions}resolveSourceFileDependencies(){let e=new Set,t=t=>e.add(t),{compilerFactory:n,inProjectCoordinator:r}=this._context;n.onSourceFileAdded(t);try{this.getProgram().compilerObject}finally{n.onSourceFileAdded(t,!1)}let i=r.markSourceFilesAsInProjectForResolution();for(let t of i.changedSourceFiles)e.add(t);for(let t of i.unchangedSourceFiles)e.delete(t);return Array.from(e.values())}addDirectoryAtPathIfExists(e,t={}){return this._context.directoryCoordinator.addDirectoryAtPathIfExists(this._context.fileSystemWrapper.getStandardizedAbsolutePath(e),{...t,markInProject:!0})}addDirectoryAtPath(e,t={}){return this._context.directoryCoordinator.addDirectoryAtPath(this._context.fileSystemWrapper.getStandardizedAbsolutePath(e),{...t,markInProject:!0})}createDirectory(e){return this._context.directoryCoordinator.createDirectoryOrAddIfExists(this._context.fileSystemWrapper.getStandardizedAbsolutePath(e),{markInProject:!0})}getDirectoryOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getDirectory(e),n??(()=>`Could not find a directory at the specified path: ${this._context.fileSystemWrapper.getStandardizedAbsolutePath(e)}`))}getDirectory(e){let{compilerFactory:t}=this._context;return t.getDirectoryFromCache(this._context.fileSystemWrapper.getStandardizedAbsolutePath(e))}getDirectories(){return Array.from(this.#n())}getRootDirectories(){let{inProjectCoordinator:e}=this._context,t=[];for(let e of this._context.compilerFactory.getOrphanDirectories())for(let r of n(e))t.push(r);return t;function*n(t){if(e.isDirectoryInProject(t)){yield t;return}for(let e of t._getDirectoriesIterator())yield*n(e)}}addSourceFilesAtPaths(e){return this._context.directoryCoordinator.addSourceFilesAtPaths(e,{markInProject:!0})}addSourceFileAtPathIfExists(e){return this._context.directoryCoordinator.addSourceFileAtPathIfExists(this._context.fileSystemWrapper.getStandardizedAbsolutePath(e),{markInProject:!0})}addSourceFileAtPath(e){return this._context.directoryCoordinator.addSourceFileAtPath(this._context.fileSystemWrapper.getStandardizedAbsolutePath(e),{markInProject:!0})}addSourceFilesFromTsConfig(e){let n=new t.TsConfigResolver(this._context.fileSystemWrapper,this._context.fileSystemWrapper.getStandardizedAbsolutePath(e),this._context.getEncoding());return this.#e(n,n.getCompilerOptions())}#e(e,t){let n=e.getPaths(t),r=n.filePaths.map(e=>this.addSourceFileAtPath(e));for(let e of n.directoryPaths)this.addDirectoryAtPathIfExists(e);return r}createSourceFile(e,t,n){return this._context.compilerFactory.createSourceFile(this._context.fileSystemWrapper.getStandardizedAbsolutePath(e),t??``,{...n??{},markInProject:!0})}removeSourceFile(e){let t=e.wasForgotten();return e.forget(),!t}getSourceFileOrThrow(e){let n=this.getSourceFile(e);if(n!=null)return n;if(typeof e==`string`){let n=t.FileUtils.standardizeSlashes(e);if(t.FileUtils.pathIsAbsolute(n)||n.indexOf(`/`)>=0){let e=this._context.fileSystemWrapper.getStandardizedAbsolutePath(n);throw new t.errors.InvalidOperationError(`Could not find source file in project at the provided path: ${e}`)}else throw new t.errors.InvalidOperationError(`Could not find source file in project with the provided file name: ${e}`)}else throw new t.errors.InvalidOperationError(`Could not find source file in project based on the provided condition.`)}getSourceFile(e){let n=r(this._context.fileSystemWrapper);if(i(n))return this._context.compilerFactory.getSourceFileFromCacheFromFilePath(n);return t.IterableUtils.find(this.#t(),n);function r(n){if(e instanceof Function)return e;let r=t.FileUtils.standardizeSlashes(e);return t.FileUtils.pathIsAbsolute(r)||r.indexOf(`/`)>=0?n.getStandardizedAbsolutePath(r):e=>t.FileUtils.pathEndsWith(e.getFilePath(),r)}function i(e){return typeof e==`string`}}getSourceFiles(e){let{compilerFactory:n,fileSystemWrapper:r}=this._context,i=this.#t();if(typeof e==`string`||e instanceof Array)return Array.from(a());return Array.from(i);function*a(){let a=Array.from(s()),o=t.matchGlobs(a,e,r.getCurrentDirectory());for(let e of o)yield n.getSourceFileFromCacheFromFilePath(r.getStandardizedAbsolutePath(e));function*s(){for(let e of i)yield e.getFilePath()}}}*#t(){let{compilerFactory:e,inProjectCoordinator:t}=this._context;for(let n of e.getSourceFilesByDirectoryDepth())t.isSourceFileInProject(n)&&(yield n)}*#n(){let{compilerFactory:e,inProjectCoordinator:t}=this._context;for(let n of e.getDirectoriesByDepth())t.isDirectoryInProject(n)&&(yield n)}getAmbientModule(e){return e=dm(e),this.getAmbientModules().find(t=>t.getName()===e)}getAmbientModuleOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getAmbientModule(e),n??(()=>`Could not find ambient module with name: ${dm(e)}`))}getAmbientModules(){return this.getTypeChecker().getAmbientModules()}async save(){await this._context.fileSystemWrapper.flush(),await Promise.all(this.#r().map(e=>e.save()))}saveSync(){this._context.fileSystemWrapper.flushSync();for(let e of this.#r())e.saveSync()}enableLogging(e=!0){this._context.logger.setEnabled(e)}#r(){return Array.from(e(this._context.compilerFactory.getSourceFilesByDirectoryDepth()));function*e(e){for(let t of e)t.isSaved()||(yield t)}}getPreEmitDiagnostics(){return this._context.getPreEmitDiagnostics()}getLanguageService(){return this._context.languageService}getProgram(){return this._context.program}getTypeChecker(){return this._context.typeChecker}getFileSystem(){return this._context.fileSystemWrapper.getFileSystem()}emit(e={}){return this._context.program.emit(e)}emitSync(e={}){return this._context.program.emitSync(e)}emitToMemory(e={}){return this._context.program.emitToMemory(e)}getCompilerOptions(){return this._context.compilerOptions.get()}getConfigFileParsingDiagnostics(){return this.getProgram().getConfigFileParsingDiagnostics()}createWriter(){return this._context.createWriter()}forgetNodesCreatedInBlock(e){return this._context.compilerFactory.forgetNodesCreatedInBlock(e)}formatDiagnosticsWithColorAndContext(e,n={}){return t.ts.formatDiagnosticsWithColorAndContext(e.map(e=>e.compilerObject),{getCurrentDirectory:()=>this._context.fileSystemWrapper.getCurrentDirectory(),getCanonicalFileName:e=>e,getNewLine:()=>n.newLineChar??t.runtime.getEndOfLine()})}getModuleResolutionHost(){return this._context.getModuleResolutionHost()}};function dm(e){return t(e[0])&&t(e[e.length-1])&&(e=e.substring(1,e.length-1)),`"${e}"`;function t(e){return e===`"`||e===`'`}}function fm(e,n={}){let{compilerOptions:r={},sourceFile:i,typeChecker:a}=n,o=new t.CompilerOptionsContainer;o.set(r);let s=new lm({project:void 0,fileSystemWrapper:new t.TransactionalFileSystem({fileSystem:new t.RealFileSystemHost,skipLoadingLibFiles:!0,libFolderPath:void 0}),compilerOptionsContainer:o,createLanguageService:!1,typeChecker:a,configFileParsingDiagnostics:[],skipLoadingLibFiles:!0,libFolderPath:void 0}),c=s.compilerFactory.getSourceFile(l(),{markInProject:!0});return s.compilerFactory.getNodeFromCompilerNode(e,c);function l(){return i??u(e)}function u(e){if(e.kind===t.SyntaxKind.SourceFile)return e;if(e.parent==null)throw new t.errors.InvalidOperationError(`Please ensure the node was created from a source file with 'setParentNodes' set to 'true'.`);let n=e;for(;n.parent!=null;)n=n.parent;if(n.kind!==t.SyntaxKind.SourceFile)throw new t.errors.NotImplementedError(`For some reason the top parent was not a source file.`);return n}}var pm=new cm(()=>{throw new t.errors.NotImplementedError(`Not implemented scenario for getting code format settings when using a writer function. Please open an issue.`)}),mm=class{constructor(){}static object(e){return t=>{let n=Object.keys(e);t.write(`{`),n.length>0&&t.indent(()=>{r()}),t.write(`}`);function r(){for(let r=0;r<n.length;r++){r>0&&t.write(`,`).newLine();let i=n[r],a=e[i];t.write(i),a!=null&&(t.write(`: `),vm(t,a))}t.newLine()}}}static objectType(e){return t=>{t.write(`{`),gm(e)&&t.indent(()=>{pm.forTypeElementMemberedNode().printText(t,e)}),t.write(`}`)}}static unionType(e,t,...n){return hm(`|`,[e,t,...n])}static intersectionType(e,t,...n){return hm(`&`,[e,t,...n])}static assertion(e,t){return n=>{vm(n,e),n.spaceIfLastNot().write(`as `),vm(n,t)}}static returnStatement(e){return t=>{t.write(`return `),t.hangingIndentUnlessBlock(()=>{vm(t,e),t.write(`;`)})}}};function hm(e,t){return n=>{_m(n,` ${e} `,t)}}function gm(e){for(let t of Object.keys(e))if(e[t]!=null&&!(e[t]instanceof Array&&e[t].length===0))return!0;return!1}function _m(e,t,n){for(let r=0;r<n.length;r++)e.conditionalWrite(r>0,t),vm(e,n[r])}function vm(e,t){t instanceof Function?t(e):e.write(t.toString())}var{InvalidOperationError:ym,FileNotFoundError:bm,ArgumentError:xm,ArgumentNullOrWhitespaceError:Sm,ArgumentOutOfRangeError:Cm,ArgumentTypeError:wm,BaseError:Tm,DirectoryNotFoundError:Em,NotImplementedError:Dm,NotSupportedError:Om,PathNotFoundError:km}=t.errors;Object.defineProperty(e,"CompilerOptionsContainer",{enumerable:!0,get:function(){return t.CompilerOptionsContainer}}),Object.defineProperty(e,"DiagnosticCategory",{enumerable:!0,get:function(){return t.DiagnosticCategory}}),Object.defineProperty(e,"EmitHint",{enumerable:!0,get:function(){return t.EmitHint}}),Object.defineProperty(e,"InMemoryFileSystemHost",{enumerable:!0,get:function(){return t.InMemoryFileSystemHost}}),Object.defineProperty(e,"LanguageVariant",{enumerable:!0,get:function(){return t.LanguageVariant}}),Object.defineProperty(e,"ModuleKind",{enumerable:!0,get:function(){return t.ModuleKind}}),Object.defineProperty(e,"ModuleResolutionKind",{enumerable:!0,get:function(){return t.ModuleResolutionKind}}),Object.defineProperty(e,"NewLineKind",{enumerable:!0,get:function(){return t.NewLineKind}}),Object.defineProperty(e,"NodeFlags",{enumerable:!0,get:function(){return t.NodeFlags}}),Object.defineProperty(e,"ObjectFlags",{enumerable:!0,get:function(){return t.ObjectFlags}}),Object.defineProperty(e,"ResolutionHosts",{enumerable:!0,get:function(){return t.ResolutionHosts}}),Object.defineProperty(e,"ScriptKind",{enumerable:!0,get:function(){return t.ScriptKind}}),Object.defineProperty(e,"ScriptTarget",{enumerable:!0,get:function(){return t.ScriptTarget}}),Object.defineProperty(e,"SettingsContainer",{enumerable:!0,get:function(){return t.SettingsContainer}}),Object.defineProperty(e,"SymbolFlags",{enumerable:!0,get:function(){return t.SymbolFlags}}),Object.defineProperty(e,"SyntaxKind",{enumerable:!0,get:function(){return t.SyntaxKind}}),Object.defineProperty(e,"TypeFlags",{enumerable:!0,get:function(){return t.TypeFlags}}),Object.defineProperty(e,"TypeFormatFlags",{enumerable:!0,get:function(){return t.TypeFormatFlags}}),Object.defineProperty(e,"ts",{enumerable:!0,get:function(){return t.ts}}),Object.defineProperty(e,"CodeBlockWriter",{enumerable:!0,get:function(){return i.default}}),e.AbstractableNode=ja,e.AmbientableNode=ge,e.ArgumentError=xm,e.ArgumentNullOrWhitespaceError=Sm,e.ArgumentOutOfRangeError=Cm,e.ArgumentTypeError=wm,e.ArgumentedNode=an,e.ArrayBindingPattern=Da,e.ArrayDestructuringAssignment=Ra,e.ArrayDestructuringAssignmentBase=La,e.ArrayLiteralExpression=Ua,e.ArrayTypeNode=iu,e.ArrowFunction=el,e.ArrowFunctionBase=$c,e.AsExpression=Qa,e.AsExpressionBase=Za,e.AssignmentExpression=Ia,e.AssignmentExpressionBase=Fa,e.AsyncableNode=on,e.AwaitExpression=eo,e.AwaitExpressionBase=$a,e.AwaitableNode=sn,e.BaseError=Tm,e.BaseExpressionedNode=Ga,e.BigIntLiteral=Wf,e.BigIntLiteralBase=Uf,e.BinaryExpression=Pa,e.BinaryExpressionBase=Na,e.BindingElement=ka,e.BindingElementBase=Oa,e.BindingNamedNode=Zi,e.Block=hs,e.BlockBase=ms,e.BodiedNode=xn,e.BodyableNode=Sn,e.BreakStatement=gs,e.CallExpression=no,e.CallExpressionBase=to,e.CallSignatureDeclaration=Qd,e.CallSignatureDeclarationBase=Zd,e.CaseBlock=vs,e.CaseBlockBase=_s,e.CaseClause=bs,e.CaseClauseBase=ys,e.CatchClause=Ss,e.CatchClauseBase=xs,e.ChildOrderableNode=Cn,e.ClassDeclaration=El,e.ClassDeclarationBase=Tl,e.ClassElement=ml,e.ClassExpression=Pl,e.ClassExpressionBase=Nl,e.ClassLikeDeclarationBase=vl,e.ClassLikeDeclarationBaseSpecific=yl,e.ClassStaticBlockDeclaration=Il,e.ClassStaticBlockDeclarationBase=Fl,e.CodeAction=Dp,e.CodeFixAction=Op,e.CombinedCodeActions=kp,e.CommaListExpression=io,e.CommaListExpressionBase=ro,e.CommentClassElement=Ll,e.CommentEnumMember=Wd,e.CommentObjectLiteralElement=Co,e.CommentRange=fn,e.CommentStatement=Cs,e.CommentTypeElement=$d,e.CommonIdentifierBase=pf,e.CompilerCommentClassElement=f,e.CompilerCommentEnumMember=h,e.CompilerCommentNode=u,e.CompilerCommentObjectLiteralElement=m,e.CompilerCommentStatement=d,e.CompilerCommentTypeElement=p,e.ComputedPropertyName=hf,e.ComputedPropertyNameBase=mf,e.ConditionalExpression=oo,e.ConditionalExpressionBase=ao,e.ConditionalTypeNode=au,e.ConstructSignatureDeclaration=tf,e.ConstructSignatureDeclarationBase=ef,e.ConstructorDeclaration=Bl,e.ConstructorDeclarationBase=Rl,e.ConstructorDeclarationOverloadBase=zl,e.ConstructorTypeNode=lu,e.ConstructorTypeNodeBase=cu,e.ContinueStatement=ws,e.DebuggerStatement=Es,e.DebuggerStatementBase=Ts,e.DecoratableNode=wn,e.Decorator=Jl,e.DecoratorBase=ql,e.DefaultClause=Os,e.DefaultClauseBase=Ds,e.DefinitionInfo=jp,e.DeleteExpression=co,e.DeleteExpressionBase=so,e.Diagnostic=Np,e.DiagnosticMessageChain=Mp,e.DiagnosticWithLocation=Pp,e.Directory=$p,e.DirectoryEmitResult=Qp,e.DirectoryNotFoundError=Em,e.DoStatement=js,e.DoStatementBase=As,e.DocumentSpan=Ap,e.DotDotDotTokenableNode=On,e.ElementAccessExpression=uo,e.ElementAccessExpressionBase=lo,e.EmitOutput=Ip,e.EmitResult=Lp,e.EmptyStatement=Ns,e.EmptyStatementBase=Ms,e.EnumDeclaration=Kd,e.EnumDeclarationBase=Gd,e.EnumMember=Jd,e.EnumMemberBase=qd,e.ExclamationTokenableNode=kn,e.ExportAssignment=rc,e.ExportAssignmentBase=nc,e.ExportDeclaration=ac,e.ExportDeclarationBase=ic,e.ExportGetableNode=An,e.ExportSpecifier=cc,e.ExportSpecifierBase=sc,e.ExportableNode=Mn,e.Expression=Ma,e.ExpressionStatement=Fs,e.ExpressionStatementBase=Ps,e.ExpressionWithTypeArguments=du,e.ExpressionWithTypeArgumentsBase=uu,e.ExpressionableNode=Wa,e.ExpressionedNode=Ka,e.ExtendsClauseableNode=Pi,e.ExternalModuleReference=uc,e.ExternalModuleReferenceBase=lc,e.FalseLiteral=Jf,e.FalseLiteralBase=qf,e.FileNotFoundError=bm,e.FileReference=Bc,e.FileTextChanges=Ep,e.ForInStatement=Ls,e.ForInStatementBase=Is,e.ForOfStatement=zs,e.ForOfStatementBase=Rs,e.ForStatement=Vs,e.ForStatementBase=Bs,e.FunctionDeclaration=cl,e.FunctionDeclarationBase=ol,e.FunctionDeclarationOverloadBase=sl,e.FunctionExpression=ul,e.FunctionExpressionBase=ll,e.FunctionLikeDeclaration=Qc,e.FunctionOrConstructorTypeNodeBase=su,e.FunctionOrConstructorTypeNodeBaseBase=ou,e.FunctionTypeNode=pu,e.FunctionTypeNodeBase=fu,e.GeneratorableNode=Fi,e.GetAccessorDeclaration=Hl,e.GetAccessorDeclarationBase=Vl,e.HeritageClause=Yd,e.HeritageClauseableNode=Li,e.Identifier=_f,e.IdentifierBase=gf,e.IfStatement=Us,e.IfStatementBase=Hs,e.ImplementationLocation=Rp,e.ImplementsClauseableNode=Ri,e.ImportAttribute=fc,e.ImportAttributeBase=dc,e.ImportAttributeNamedNode=Qi,e.ImportAttributes=mc,e.ImportAttributesBase=pc,e.ImportClause=gc,e.ImportClauseBase=hc,e.ImportDeclaration=vc,e.ImportDeclarationBase=_c,e.ImportEqualsDeclaration=Sc,e.ImportEqualsDeclarationBase=xc,e.ImportExpression=po,e.ImportExpressionBase=fo,e.ImportExpressionedNode=qa,e.ImportSpecifier=wc,e.ImportSpecifierBase=Cc,e.ImportTypeNode=mu,e.IndexSignatureDeclaration=rf,e.IndexSignatureDeclarationBase=nf,e.IndexedAccessTypeNode=hu,e.InferTypeNode=gu,e.InitializerExpressionGetableNode=zi,e.InitializerExpressionableNode=Bi,e.InterfaceDeclaration=of,e.InterfaceDeclarationBase=af,e.IntersectionTypeNode=_u,e.InvalidOperationError=ym,e.IterationStatement=ks,e.JSDoc=eu,e.JSDocAllType=Bu,e.JSDocAugmentsTag=Ju,e.JSDocAuthorTag=Yu,e.JSDocBase=$l,e.JSDocCallbackTag=Xu,e.JSDocClassTag=Zu,e.JSDocDeprecatedTag=Qu,e.JSDocEnumTag=$u,e.JSDocFunctionType=td,e.JSDocFunctionTypeBase=ed,e.JSDocImplementsTag=nd,e.JSDocLink=rd,e.JSDocLinkCode=id,e.JSDocLinkPlain=ad,e.JSDocMemberName=od,e.JSDocNameReference=cd,e.JSDocNamepathType=sd,e.JSDocNonNullableType=ld,e.JSDocNullableType=ud,e.JSDocOptionalType=dd,e.JSDocOverloadTag=pd,e.JSDocOverloadTagBase=fd,e.JSDocOverrideTag=md,e.JSDocParameterTag=gd,e.JSDocParameterTagBase=hd,e.JSDocPrivateTag=_d,e.JSDocPropertyLikeTag=Yl,e.JSDocPropertyTag=vd,e.JSDocPropertyTagBase=J,e.JSDocProtectedTag=yd,e.JSDocPublicTag=bd,e.JSDocReadonlyTag=xd,e.JSDocReturnTag=Cd,e.JSDocReturnTagBase=Sd,e.JSDocSatisfiesTag=Td,e.JSDocSatisfiesTagBase=wd,e.JSDocSeeTag=Dd,e.JSDocSeeTagBase=Ed,e.JSDocSignature=Od,e.JSDocTag=Hu,e.JSDocTagBase=Vu,e.JSDocTagInfo=kd,e.JSDocTemplateTag=jd,e.JSDocTemplateTagBase=Ad,e.JSDocText=Md,e.JSDocThisTag=Pd,e.JSDocThisTagBase=Nd,e.JSDocThrowsTag=Id,e.JSDocThrowsTagBase=Fd,e.JSDocType=zu,e.JSDocTypeExpression=Rd,e.JSDocTypeExpressionableTag=Xl,e.JSDocTypeLiteral=zd,e.JSDocTypeParameteredTag=Zl,e.JSDocTypeTag=Bd,e.JSDocTypedefTag=Ld,e.JSDocUnknownTag=Vd,e.JSDocUnknownType=Hd,e.JSDocVariadicType=Ud,e.JSDocableNode=Hi,e.JsxAttribute=Sf,e.JsxAttributeBase=xf,e.JsxAttributedNode=df,e.JsxClosingElement=wf,e.JsxClosingElementBase=Cf,e.JsxClosingFragment=Tf,e.JsxElement=Df,e.JsxElementBase=Ef,e.JsxExpression=Af,e.JsxExpressionBase=kf,e.JsxFragment=jf,e.JsxNamespacedName=Nf,e.JsxNamespacedNameBase=Mf,e.JsxOpeningElement=Ff,e.JsxOpeningElementBase=Pf,e.JsxOpeningFragment=If,e.JsxSelfClosingElement=Rf,e.JsxSelfClosingElementBase=Lf,e.JsxSpreadAttribute=Bf,e.JsxSpreadAttributeBase=zf,e.JsxTagNamedNode=ff,e.JsxText=Hf,e.JsxTextBase=Vf,e.LabeledStatement=Gs,e.LabeledStatementBase=Ws,e.LanguageService=Yp,e.LeftHandSideExpression=G,e.LeftHandSideExpressionedNode=Ja,e.LiteralExpression=ho,e.LiteralExpressionBase=mo,e.LiteralLikeNode=Ui,e.LiteralTypeNode=vu,e.ManipulationError=Et,e.ManipulationSettingsContainer=M,e.MappedTypeNode=yu,e.MemberExpression=Va,e.MemoryEmitResult=zp,e.MetaProperty=_o,e.MetaPropertyBase=go,e.MethodDeclaration=_l,e.MethodDeclarationBase=hl,e.MethodDeclarationOverloadBase=gl,e.MethodSignature=cf,e.MethodSignatureBase=sf,e.ModifierableNode=Wi,e.ModuleBlock=Ec,e.ModuleBlockBase=Tc,e.ModuleChildableNode=Dc,e.ModuleDeclaration=kc,e.ModuleDeclarationBase=Oc,e.ModuleNamedNode=$i,e.ModuledNode=Ki,e.NameableNode=ea,e.NamedExports=Nc,e.NamedExportsBase=Mc,e.NamedImports=Fc,e.NamedImportsBase=Pc,e.NamedNode=ra,e.NamedNodeBase=qi,e.NamedTupleMember=xu,e.NamedTupleMemberBase=bu,e.NamespaceExport=Lc,e.NamespaceExportBase=Ic,e.NamespaceImport=zc,e.NamespaceImportBase=Rc,e.NewExpression=yo,e.NewExpressionBase=vo,e.NoSubstitutionTemplateLiteral=op,e.NoSubstitutionTemplateLiteralBase=ap,e.Node=H,e.NodeWithTypeArguments=ru,e.NodeWithTypeArgumentsBase=nu,e.NonNullExpression=xo,e.NonNullExpressionBase=bo,e.NotEmittedStatement=qs,e.NotEmittedStatementBase=Ks,e.NotImplementedError=Dm,e.NotSupportedError=Om,e.NullLiteral=Qf,e.NullLiteralBase=Zf,e.NumericLiteral=ep,e.NumericLiteralBase=$f,e.ObjectBindingPattern=Aa,e.ObjectDestructuringAssignment=To,e.ObjectDestructuringAssignmentBase=wo,e.ObjectLiteralElement=So,e.ObjectLiteralExpression=Do,e.ObjectLiteralExpressionBase=Eo,e.OmittedExpression=Fo,e.OmittedExpressionBase=Po,e.OutputFile=Fp,e.OverloadableNode=tl,e.OverrideableNode=aa,e.ParameterDeclaration=fl,e.ParameterDeclarationBase=dl,e.ParameteredNode=oa,e.ParenthesizedExpression=q,e.ParenthesizedExpressionBase=K,e.ParenthesizedTypeNode=Su,e.PartiallyEmittedExpression=Lo,e.PartiallyEmittedExpressionBase=Io,e.PathNotFoundError=km,e.PostfixUnaryExpression=zo,e.PostfixUnaryExpressionBase=Ro,e.PrefixUnaryExpression=Vo,e.PrefixUnaryExpressionBase=Bo,e.PrimaryExpression=Ha,e.PrivateIdentifier=yf,e.PrivateIdentifierBase=vf,e.Program=Jp,e.Project=um,e.PropertyAccessExpression=Uo,e.PropertyAccessExpressionBase=Ho,e.PropertyAssignment=ko,e.PropertyAssignmentBase=Oo,e.PropertyDeclaration=Wl,e.PropertyDeclarationBase=Ul,e.PropertyNamedNode=ia,e.PropertySignature=uf,e.PropertySignatureBase=lf,e.QualifiedName=bf,e.QuestionDotTokenableNode=sa,e.QuestionTokenableNode=ca,e.ReadonlyableNode=la,e.RefactorEditInfo=Bp,e.ReferenceEntry=Up,e.ReferenceFindableNode=Ji,e.ReferencedSymbol=Vp,e.ReferencedSymbolDefinitionInfo=Hp,e.ReferencedSymbolEntry=Wp,e.RegularExpressionLiteral=np,e.RegularExpressionLiteralBase=tp,e.RenameLocation=Gp,e.RenameableNode=Xi,e.RestTypeNode=Cu,e.ReturnStatement=Ys,e.ReturnStatementBase=Js,e.ReturnTypedNode=ua,e.SatisfiesExpression=Go,e.SatisfiesExpressionBase=Wo,e.ScopeableNode=da,e.ScopedNode=ma,e.SetAccessorDeclaration=Kl,e.SetAccessorDeclarationBase=Gl,e.ShorthandPropertyAssignment=jo,e.ShorthandPropertyAssignmentBase=Ao,e.Signature=Sp,e.SignaturedDeclaration=ha,e.SourceFile=Uc,e.SourceFileBase=Hc,e.SpreadAssignment=No,e.SpreadAssignmentBase=Mo,e.SpreadElement=qo,e.SpreadElementBase=Ko,e.Statement=ds,e.StatementBase=us,e.StatementedNode=fs,e.StaticableNode=ga,e.StringLiteral=ip,e.StringLiteralBase=rp,e.Structure=Jn,e.SuperElementAccessExpression=Yo,e.SuperElementAccessExpressionBase=Jo,e.SuperExpression=Zo,e.SuperExpressionBase=Xo,e.SuperExpressionedNode=Ya,e.SuperPropertyAccessExpression=$o,e.SuperPropertyAccessExpressionBase=Qo,e.SwitchStatement=Zs,e.SwitchStatementBase=Xs,e.Symbol=Cp,e.SymbolDisplayPart=Kp,e.SyntaxList=vn,e.TaggedTemplateExpression=sp,e.TemplateExpression=lp,e.TemplateExpressionBase=cp,e.TemplateHead=dp,e.TemplateHeadBase=up,e.TemplateLiteralTypeNode=wu,e.TemplateMiddle=pp,e.TemplateMiddleBase=fp,e.TemplateSpan=hp,e.TemplateSpanBase=mp,e.TemplateTail=_p,e.TemplateTailBase=gp,e.TextChange=Tp,e.TextInsertableNode=_a,e.TextRange=dn,e.TextSpan=wp,e.ThisExpression=ts,e.ThisExpressionBase=es,e.ThisTypeNode=Tu,e.ThrowStatement=$s,e.ThrowStatementBase=Qs,e.TrueLiteral=Kf,e.TrueLiteralBase=Gf,e.TryStatement=tc,e.TryStatementBase=ec,e.TupleTypeNode=Eu,e.Type=Xp,e.TypeAliasDeclaration=Ou,e.TypeAliasDeclarationBase=Du,e.TypeArgumentedNode=ya,e.TypeAssertion=rs,e.TypeAssertionBase=ns,e.TypeChecker=qp,e.TypeElement=Xd,e.TypeElementMemberedNode=Sa,e.TypeLiteralNode=Au,e.TypeLiteralNodeBase=ku,e.TypeNode=tu,e.TypeOfExpression=as,e.TypeOfExpressionBase=is,e.TypeOperatorTypeNode=ju,e.TypeParameter=Zp,e.TypeParameterDeclaration=Nu,e.TypeParameterDeclarationBase=Mu,e.TypeParameteredNode=wa,e.TypePredicateNode=Fu,e.TypeQueryNode=Iu,e.TypeReferenceNode=Lu,e.TypedNode=ba,e.UnaryExpression=za,e.UnaryExpressionedNode=Xa,e.UnionTypeNode=Ru,e.UnwrappableNode=Ea,e.UpdateExpression=Ba,e.VariableDeclaration=yp,e.VariableDeclarationBase=vp,e.VariableDeclarationList=xp,e.VariableDeclarationListBase=bp,e.VariableStatement=qc,e.VariableStatementBase=Kc,e.VoidExpression=ss,e.VoidExpressionBase=os,e.WhileStatement=Yc,e.WhileStatementBase=Jc,e.WithStatement=Zc,e.WithStatementBase=Xc,e.Writers=mm,e.YieldExpression=ls,e.YieldExpressionBase=cs,e.createWrappedNode=fm,e.forEachStructureChild=Yn,e.getCompilerOptionsFromTsConfig=fe,e.getScopeForNode=fa,e.insertOverloads=al,e.printNode=j,e.setScopeForNode=pa}))(),V=new Set([`t`,`msg`]),Zt=`Trans`,Qt=e=>{if(e!==void 0&&(Xt.Node.isStringLiteral(e)||Xt.Node.isNoSubstitutionTemplateLiteral(e)))return e.getLiteralText()},$t=e=>{if(e===void 0)return;let t=Qt(e);if(t!==void 0)return{message:t};if(!Xt.Node.isObjectLiteralExpression(e))return;let n=e.getProperty(`message`);if(n===void 0||!Xt.Node.isPropertyAssignment(n))return;let r=Qt(n.getInitializer());if(r===void 0)return;let i=e.getProperty(`context`),a=i!==void 0&&Xt.Node.isPropertyAssignment(i)?Qt(i.getInitializer()):void 0;return a===void 0?{message:r}:{message:r,context:a}},en=(e,t)=>{let n=e.getAttribute(t);if(n===void 0||!Xt.Node.isJsxAttribute(n))return;let r=n.getInitializer();if(r!==void 0){if(Xt.Node.isStringLiteral(r))return r.getLiteralText();if(Xt.Node.isJsxExpression(r))return Qt(r.getExpression())}},tn=e=>{let t=e.getJsxChildren();if(t.some(e=>Xt.Node.isJsxExpression(e)||Xt.Node.isJsxElement(e)||Xt.Node.isJsxSelfClosingElement(e)))return;let n=v(t.filter(e=>Xt.Node.isJsxText(e)).map(e=>e.getText()).join(``));return n.length>0?n:void 0},nn=e=>{let t=new Map;for(let n of e)t.set(_(n.message,n.context),n);return[...t.values()]},rn=async e=>{if(e.length===0)return[];let t=new Xt.Project({useInMemoryFileSystem:!0,skipFileDependencyResolution:!0}),n=[];for(let r=0;r<e.length;r++){let a;try{a=await(0,i.readFile)(e[r],`utf8`)}catch{continue}t.createSourceFile(`front-component-${r}.tsx`,a,{overwrite:!0}).forEachDescendant(e=>{if(Xt.Node.isCallExpression(e)){let t=e.getExpression();if(Xt.Node.isIdentifier(t)&&V.has(t.getText())){let t=$t(e.getArguments()[0]);t!==void 0&&n.push(t)}return}if(Xt.Node.isJsxSelfClosingElement(e)){if(e.getTagNameNode().getText()!==Zt)return;let t=en(e,`message`);if(t!==void 0&&t.length>0){let r=en(e,`context`);n.push(r===void 0?{message:t}:{message:t,context:r})}return}if(Xt.Node.isJsxElement(e)){let t=e.getOpeningElement();if(t.getTagNameNode().getText()!==Zt)return;let r=en(t,`message`)??tn(e);if(r!==void 0&&r.length>0){let e=en(t,`context`);n.push(e===void 0?{message:r}:{message:r,context:e})}}})}return nn(n)},an={objects:[`labelSingular`,`labelPlural`,`description`],fields:[`label`,`description`],views:[`name`],pageLayoutTabs:[`title`],commandMenuItems:[`label`,`shortLabel`],navigationMenuItems:[`name`]},on=e=>{let t=new Set,n=e=>{typeof e==`string`&&e.length>0&&t.add(e)};for(let[t,r]of Object.entries(an)){let i=e[t];if(Array.isArray(i)){for(let e of i)if(!(typeof e!=`object`||!e))for(let t of r)n(e[t])}}for(let t of e.pageLayouts??[])for(let e of t.tabs??[]){n(e.title);for(let t of e.widgets??[])n(t.title)}return[...t].sort()},sn=async({manifest:e,frontComponentSourcePaths:t})=>{let n=on(e).map(e=>({message:e})),r=await rn(t),i=new Map;for(let e of[...n,...r])i.set(_(e.message,e.context),e);return i},cn=async({appPath:e,manifest:a,frontComponentSourcePaths:o=[],scaffoldLocale:s})=>{let c=await sn({manifest:a,frontComponentSourcePaths:o}),l=[...c.keys()].sort(),u=r.default.join(e,t.nt);await t.lt(u);let d={};for(let e of l){let t=c.get(e);n.t(t)&&(d[e]=t.message)}if(await t.pt(r.default.join(u,`en.json`),d),s!==void 0&&s!==`en`){let e=r.default.join(u,`${s}.json`);await t.ut(e)||await t.pt(e,{})}let f=(await(0,i.readdir)(u)).filter(e=>e.endsWith(`.json`)&&e!==`en.json`);for(let e of f){let n=r.default.join(u,e),i=await t.dt(n)??{},a={};for(let e of l){let t=i[e];a[e]=typeof t==`string`?t:``}await t.pt(n,a)}return{sourceCount:l.length,updatedLocaleFiles:f}},ln=e=>Object.prototype.hasOwnProperty.call(t.xt,e),un=class{async execute(e){let n=e.appPath??t.Ot,i;e.locale!==void 0&&((e.locale===`en`||!ln(e.locale))&&(console.error(u.default.red(`"${e.locale}" is not a supported target locale. Choose one of: ${Object.keys(t.xt).filter(e=>e!==`en`).join(`, `)}`)),process.exit(1)),i=e.locale),console.log(u.default.blue(`Extracting translatable strings...`));let a=await t.$(n);a.success||(console.error(u.default.red(a.errors.join(`
|
|
31388
|
+
`)}getTags(){return this.compilerNode.tags?.map(e=>this._getNodeFromCompilerNode(e))??[]}getInnerText(){return Ql(this.getText())}getComment(){if(this.compilerNode.comment!=null)return typeof this.compilerNode.comment==`string`?this.compilerNode.comment:this.compilerNode.comment.map(e=>this._getNodeFromCompilerNodeIfExists(e))}getCommentText(){return typeof this.compilerNode.comment==`string`?this.compilerNode.comment:t.ts.getTextOfJSDocComment(this.compilerNode.comment)}getDescription(){let e=this.getSourceFile().getFullText(),n=this.getTags()[0]?.getStart()??this.getEnd()-2,r=i(this);return Ql(e.substring(r,Math.max(r,a())));function i(t){let n=t.getStart()+3;return e.charCodeAt(n)===o.SPACE?n+1:n}function a(){return Me(e,Me(e,n,e=>e===o.NEWLINE||!t.StringUtils.isWhitespaceCharCode(e)&&e!==o.ASTERISK),e=>e!==o.NEWLINE&&e!==o.CARRIAGE_RETURN)}}setDescription(e){let t=this.getTags(),n=this.getStart()+3,r=t.length>0?Me(this._sourceFile.getFullText(),t[0].getStart(),e=>e===o.ASTERISK)-1:this.getEnd()-2;return tn({parent:this,newText:i.call(this),replacePos:n,replacingLength:r-n}),this;function i(){let t=this.getIndentationText(),n=this._context.manipulationSettings.getNewLineKindAsString(),r=I(this._getWriter(),e).split(/\r?\n/),i=r[0].length===0,a=r.length===1&&(this.compilerNode.tags?.length??0)===0,o=a?r[0]:r.map(e=>e.length===0?`${t} *`:`${t} * ${e}`).slice(+!!i).join(n);return a?` `+o+` `:n+o+n+t+` `}}addTag(e){return this.addTags([e])[0]}addTags(e){return this.insertTags(this.compilerNode.tags?.length??0,e)}insertTag(e,t){return this.insertTags(e,[t])[0]}insertTags(e,n){if(t.ArrayUtils.isNullOrEmpty(n))return[];let r=this._getWriterWithQueuedIndentation(),i=this.getTags();if(e=et(e,i.length),i.length===0&&!this.isMultiLine()){let e=this._context.structurePrinterFactory.forJSDoc();this.replaceWithText(t=>{e.printText(t,{description:this.getDescription(),tags:n})})}else{let t=this._context.structurePrinterFactory.forJSDocTag({printStarsOnNewLine:!0});r.newLine().write(` * `),t.printTexts(r,n),r.newLine().write(` *`),r.conditionalWrite(e<i.length,` `);let o=a.call(this),c=s.call(this);kt({parent:this,insertPos:o,replacing:{textLength:c-o},newText:r.toString()})}return Ye(i,this.getTags(),e,!1);function a(){let n=e<i.length?i[e].getStart():this.getEnd()-2,r=this.getStart()+3;return Math.max(r,Me(this.getSourceFile().getFullText(),n,e=>!t.StringUtils.isWhitespaceCharCode(e)&&e!==o.ASTERISK))}function s(){return e<i.length?i[e].getStart():this.getEnd()-1}}remove(){It({children:[this],removeFollowingSpaces:!0,removeFollowingNewLines:!0})}set(e){return he($l.prototype,this,e),e.tags==null?(e.description!=null&&this.setDescription(e.description),this):this.replaceWithText(t=>{this._context.structurePrinterFactory.forJSDoc().printText(t,{description:e.description??this.getDescription(),tags:e.tags})})}getStructure(){return me($l.prototype,this,{kind:e.StructureKind.JSDoc,description:this.getDescription(),tags:this.getTags().map(e=>e.getStructure())})}},tu=class extends H{},nu=ya(tu),ru=class extends nu{},iu=class extends tu{getElementTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.elementType)}},au=class extends tu{getCheckType(){return this._getNodeFromCompilerNode(this.compilerNode.checkType)}getExtendsType(){return this._getNodeFromCompilerNode(this.compilerNode.extendsType)}getTrueType(){return this._getNodeFromCompilerNode(this.compilerNode.trueType)}getFalseType(){return this._getNodeFromCompilerNode(this.compilerNode.falseType)}},ou=ha(tu),su=class extends ou{},cu=ja(Wi(su)),lu=class extends cu{},uu=Ja(ru),du=class extends uu{},fu=wa(su),pu=class extends fu{},mu=class extends ru{setArgument(e){let t=this.getArgument();if(H.isLiteralTypeNode(t)){let n=t.getLiteral();if(H.isStringLiteral(n))return n.setLiteralValue(e),this}return t.replaceWithText(t=>t.quote(e),this._getWriterWithQueuedChildIndentation()),this}getArgument(){return this._getNodeFromCompilerNode(this.compilerNode.argument)}setQualifier(e){let n=this.getQualifier();return n==null?kt({insertPos:this.getFirstChildByKindOrThrow(t.SyntaxKind.CloseParenToken).getEnd(),parent:this,newText:this._getWriterWithQueuedIndentation().write(`.`).write(e).toString()}):n.replaceWithText(e,this._getWriterWithQueuedChildIndentation()),this}getQualifierOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getQualifier(),e??(()=>`Expected to find a qualifier for the import type: ${this.getText()}`),this)}getQualifier(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.qualifier)}getAttributes(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.attributes)}getAttributesOrThrow(e){return t.errors.throwIfNullOrUndefined(this._getNodeFromCompilerNodeIfExists(this.compilerNode.attributes),e??`Could not find import type assertion container.`,this)}},hu=class extends tu{getObjectTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.objectType)}getIndexTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.indexType)}},gu=class extends tu{getTypeParameter(){return this._getNodeFromCompilerNode(this.compilerNode.typeParameter)}},_u=class extends tu{getTypeNodes(){return this.compilerNode.types.map(e=>this._getNodeFromCompilerNode(e))}},vu=class extends tu{getLiteral(){let e=this.compilerNode.literal;return this._getNodeFromCompilerNode(e)}},yu=class extends tu{getNameTypeNode(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.nameType)}getNameTypeNodeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getNameTypeNode(),e??`Type did not exist.`,this)}getReadonlyToken(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.readonlyToken)}getReadonlyTokenOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getReadonlyToken(),e??`Readonly token did not exist.`,this)}getQuestionToken(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.questionToken)}getQuestionTokenOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getQuestionToken(),e??`Question token did not exist.`,this)}getTypeParameter(){return this._getNodeFromCompilerNode(this.compilerNode.typeParameter)}getTypeNode(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.type)}getTypeNodeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getTypeNode(),e??`Type did not exist, but was expected to exist.`,this)}},bu=(e=>ba(ca(On(Hi(ra(e))))))(tu),xu=class extends bu{getTypeNode(){return super.getTypeNode()}removeType(){throw new t.errors.InvalidOperationError(`Cannot remove the type of a named tuple member.`)}},Su=class extends tu{getTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.type)}setType(e){return this.getTypeNode().replaceWithText(e),this}},Cu=class extends tu{getTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.type)}},wu=class extends tu{getHead(){return this._getNodeFromCompilerNode(this.compilerNode.head)}getTemplateSpans(){return this.compilerNode.templateSpans.map(e=>this._getNodeFromCompilerNode(e))}setLiteralValue(e){let t=this.getChildIndex(),n=this.getParentSyntaxList()??this.getParentOrThrow();return Zt({sourceFile:this._sourceFile,start:this.getStart()+1,replacingLength:this.getWidth()-2,newText:e}),n.getChildAtIndex(t)}},Tu=class extends tu{},Eu=class extends tu{getElements(){return this.compilerNode.elements.map(e=>this._getNodeFromCompilerNode(e))}},Du=(e=>wa(ba(Hi(ge(Mn(Wi(ra(e))))))))(ds),Ou=class extends Du{set(e){return he(Du.prototype,this,e),this}getStructure(){return me(Du.prototype,this,{kind:e.StructureKind.TypeAlias,type:this.getTypeNodeOrThrow().getText()})}},ku=Sa(tu),Au=class extends ku{},ju=class extends tu{getOperator(){return this.compilerNode.operator}getTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.type)}};e.TypeParameterVariance=void 0,(function(e){e[e.None=0]=`None`,e[e.In=1]=`In`,e[e.Out=2]=`Out`,e[e.InOut=3]=`InOut`})(e.TypeParameterVariance||={});var Mu=(e=>Wi(ra(e)))(H),Nu=class extends Mu{isConst(){return this.hasModifier(t.SyntaxKind.ConstKeyword)}setIsConst(e){return this.toggleModifier(`const`,e)}getConstraint(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.constraint)}getConstraintOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getConstraint(),e??`Expected to find the type parameter's constraint.`,this)}setConstraint(e){if(e=this.getParentOrThrow()._getTextWithQueuedChildIndentation(e),t.StringUtils.isNullOrWhitespace(e))return this.removeConstraint(),this;let n=this.getConstraint();if(n!=null)return n.replaceWithText(e),this;let r=this.getNameNode();return kt({parent:this,insertPos:r.getEnd(),newText:` extends ${e}`}),this}removeConstraint(){return Pu(this.getConstraint(),t.SyntaxKind.ExtendsKeyword),this}getDefault(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.default)}getDefaultOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getDefault(),e??`Expected to find the type parameter's default.`,this)}setDefault(e){if(e=this.getParentOrThrow()._getTextWithQueuedChildIndentation(e),t.StringUtils.isNullOrWhitespace(e))return this.removeDefault(),this;let n=this.getDefault();if(n!=null)return n.replaceWithText(e),this;let r=this.getConstraint()||this.getNameNode();return kt({parent:this,insertPos:r.getEnd(),newText:` = ${e}`}),this}removeDefault(){return Pu(this.getDefault(),t.SyntaxKind.EqualsToken),this}setVariance(t){return this.toggleModifier(`in`,(t&e.TypeParameterVariance.In)!==0),this.toggleModifier(`out`,(t&e.TypeParameterVariance.Out)!==0),this}getVariance(){let n=e.TypeParameterVariance.None;return this.hasModifier(t.SyntaxKind.InKeyword)&&(n|=e.TypeParameterVariance.In),this.hasModifier(t.SyntaxKind.OutKeyword)&&(n|=e.TypeParameterVariance.Out),n}remove(){let e=this.getParentSyntaxListOrThrow();e.getChildrenOfKind(t.SyntaxKind.TypeParameter).length===1?n():Ut(this);function n(){It({children:[e.getPreviousSiblingIfKindOrThrow(t.SyntaxKind.LessThanToken),e,e.getNextSiblingIfKindOrThrow(t.SyntaxKind.GreaterThanToken)]})}}set(e){return he(Mu.prototype,this,e),e.isConst!=null&&this.setIsConst(e.isConst),e.constraint==null?e.hasOwnProperty(t.nameof(e,`constraint`))&&this.removeConstraint():this.setConstraint(e.constraint),e.default==null?e.hasOwnProperty(t.nameof(e,`default`))&&this.removeDefault():this.setDefault(e.default),e.variance!=null&&this.setVariance(e.variance),this}getStructure(){let t=this.getConstraint(),n=this.getDefault();return me(Mu.prototype,this,{kind:e.StructureKind.TypeParameter,isConst:this.isConst(),constraint:t?.getText({trimLeadingIndentation:!0}),default:n?n.getText({trimLeadingIndentation:!0}):void 0,variance:this.getVariance()})}};function Pu(e,t){e!=null&&It({children:[e.getPreviousSiblingIfKindOrThrow(t),e],removePrecedingSpaces:!0})}var Fu=class extends tu{getParameterNameNode(){return this._getNodeFromCompilerNode(this.compilerNode.parameterName)}hasAssertsModifier(){return this.compilerNode.assertsModifier!=null}getAssertsModifier(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.assertsModifier)}getAssertsModifierOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getAssertsModifier(),e??`Expected to find an asserts modifier.`,this)}getTypeNode(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.type)}getTypeNodeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getTypeNode(),e??`Expected to find a type node.`,this)}},Iu=class extends ru{getExprName(){return this._getNodeFromCompilerNode(this.compilerNode.exprName)}},Lu=class extends ru{getTypeName(){return this._getNodeFromCompilerNode(this.compilerNode.typeName)}},Ru=class extends tu{getTypeNodes(){return this.compilerNode.types.map(e=>this._getNodeFromCompilerNode(e))}},zu=class extends tu{},Bu=class extends zu{},Vu=H,Hu=class extends Vu{getTagName(){return this.getTagNameNode().getText()}getTagNameNode(){return this._getNodeFromCompilerNode(this.compilerNode.tagName)}setTagName(e){return this.set({tagName:e})}getComment(){if(this.compilerNode.comment!=null)return typeof this.compilerNode.comment==`string`?this.compilerNode.comment:this.compilerNode.comment.map(e=>this._getNodeFromCompilerNodeIfExists(e))}getCommentText(){return typeof this.compilerNode.comment==`string`?this.compilerNode.comment:t.ts.getTextOfJSDocComment(this.compilerNode.comment)}remove(){let e=this.getParentOrThrow().getStart()+3,t=Ku(this),n=t==null,r=i.call(this);It({children:[this],customRemovalPos:r,customRemovalEnd:Gu(this,t),replaceTrivia:a.call(this)});function i(){return Math.max(e,qu(this,this.getStart()))}function a(){return r===e&&n?``:`${this._context.manipulationSettings.getNewLineKindAsString()}${this.getParentOrThrow().getIndentationText()} `+(n?``:`* `)}}set(e){return he(Vu.prototype,this,e),e.text!=null||e.tagName!=null?this.replaceWithText(t=>{this._context.structurePrinterFactory.forJSDocTag({printStarsOnNewLine:!0}).printText(t,{tagName:e.tagName??this.getTagName(),text:e.text==null?Uu(this):e.text})}):this}replaceWithText(e){let t=I(this._getWriterWithQueuedIndentation(),e),n=this.getParentOrThrow(),r=this.getChildIndex(),i=this.getStart();return kt({parent:n,insertPos:i,newText:t,replacing:{textLength:Wu(this)-i}}),n.getChildren()[r]}getStructure(){let t=Uu(this);return me(Vu.prototype,this,{kind:e.StructureKind.JSDocTag,tagName:this.getTagName(),text:t.length===0?void 0:t})}};function Uu(e){let t=e.getSourceFile().getFullText(),n=e.getTagNameNode().getEnd(),r=Wu(e),i=Math.min(t.charCodeAt(n)===o.SPACE?n+1:n,r);return Ql(t.substring(i,r))}function Wu(e){return qu(e,Gu(e))}function Gu(e,t){return t??=Ku(e),t==null?e.getParentOrThrow().getEnd()-2:t.getStart()}function Ku(e){let n=e.getParentIfKindOrThrow(t.SyntaxKind.JSDoc).getTags();return n[n.indexOf(e)+1]}function qu(e,n){return Me(e.getSourceFile().getFullText(),n,e=>e!==o.ASTERISK&&!t.StringUtils.isWhitespaceCharCode(e))}var Ju=class extends Hu{},Yu=class extends Hu{},Xu=class extends Hu{},Zu=class extends Hu{},Qu=class extends Hu{},$u=class extends Hu{},ed=ha(zu),td=class extends ed{},nd=class extends Hu{},rd=class extends H{},id=class extends H{},ad=class extends H{},od=class extends H{},sd=class extends zu{getTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.type)}},cd=class extends H{getName(){return this._getNodeFromCompilerNode(this.compilerNode.name)}},ld=class extends zu{getTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.type)}isPostfix(){return this.compilerNode.postfix}},ud=class extends zu{getTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.type)}isPostfix(){return this.compilerNode.postfix}},dd=class extends zu{getTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.type)}},fd=Xl(Hu),pd=class extends fd{},md=class extends Hu{},hd=Yl(Hu),gd=class extends hd{},_d=class extends Hu{},J=Yl(Hu),vd=class extends J{},yd=class extends Hu{},bd=class extends Hu{},xd=class extends Hu{},Sd=Xl(Hu),Cd=class extends Sd{},wd=Xl(Hu),Td=class extends wd{},Ed=Xl(Hu),Dd=class extends Ed{},Od=class extends zu{getTypeNode(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.type)}},kd=class{#e;constructor(e){this.#e=e}get compilerObject(){return this.#e}getName(){return this.compilerObject.name}getText(){return this.compilerObject.text??[]}},Ad=Zl(Hu),jd=class extends Ad{getConstraint(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.constraint)}getConstraintOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getConstraint(),e??`Expected to find the JS doc template tag's constraint.`,this)}},Md=class extends H{},Nd=Xl(Hu),Pd=class extends Nd{},Fd=Xl(Hu),Id=class extends Fd{},Ld=class extends Hu{},Rd=class extends tu{getTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.type)}},zd=class extends zu{isArrayType(){return this.compilerNode.isArrayType}getPropertyTags(){return this.compilerNode.jsDocPropertyTags?this.compilerNode.jsDocPropertyTags.map(e=>this._getNodeFromCompilerNode(e)):void 0}},Bd=class extends Hu{getTypeExpression(){let e=this.compilerNode.typeExpression;if(!(e!=null&&e.pos===e.end))return this._getNodeFromCompilerNodeIfExists(this.compilerNode.typeExpression)}},Vd=class extends Hu{},Hd=class extends zu{},Ud=class extends zu{getTypeNode(){return this._getNodeFromCompilerNode(this.compilerNode.type)}},Wd=class extends H{remove(){Rt({children:[this],getSiblingFormatting:()=>_e.Newline})}},Gd=(e=>_a(Dc(Hi(ge(Mn(Wi(ra(e))))))))(ds),Kd=class extends Gd{set(e){return he(Gd.prototype,this,e),e.isConst!=null&&this.setIsConstEnum(e.isConst),e.members!=null&&(this.getMembers().forEach(e=>e.remove()),this.addMembers(e.members)),this}addMember(e){return this.addMembers([e])[0]}addMembers(e){return this.insertMembers(this.getMembers().length,e)}insertMember(e,t){return this.insertMembers(e,[t])[0]}insertMembers(e,t){if(t.length===0)return[];let n=this.getMembersWithComments();e=et(e,n.length);let r=this._getWriterWithChildIndentation();return this._context.structurePrinterFactory.forEnumMember().printTexts(r,t),jt({parent:this.getChildSyntaxListOrThrow(),currentNodes:n,insertIndex:e,newText:r.toString(),useNewLines:!0,useTrailingCommas:this._context.manipulationSettings.getUseTrailingCommas()}),Ye(n,this.getMembersWithComments(),e,!i());function i(){return t instanceof Array?t.every(e=>typeof e==`object`):!1}}getMember(e){return s(this.getMembers(),e)}getMemberOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getMember(e),()=>l(`enum member`,e))}getMembers(){return this.compilerNode.members.map(e=>this._getNodeFromCompilerNode(e))}getMembersWithComments(){let e=this.compilerNode;return T.getContainerArray(e,this.getSourceFile().compilerNode).map(e=>this._getNodeFromCompilerNode(e))}setIsConstEnum(e){return this.toggleModifier(`const`,e)}isConstEnum(){return this.getConstKeyword()!=null}getConstKeyword(){return this.getFirstModifierByKind(t.SyntaxKind.ConstKeyword)}getStructure(){return me(Gd.prototype,this,{kind:e.StructureKind.Enum,isConst:this.isConstEnum(),members:this.getMembers().map(e=>e.getStructure())})}},qd=(e=>Hi(Bi(ia(e))))(H),Jd=class extends qd{getValue(){return this._context.typeChecker.getConstantValue(this)}setValue(e){let n;if(typeof e==`string`){let r=this._context.manipulationSettings.getQuoteKind();n=r+t.StringUtils.escapeForWithinString(e,r)+r}else n=e.toString();return this.setInitializer(n),this}remove(){let e=[this],n=this.getNextSiblingIfKind(t.SyntaxKind.CommaToken);n!=null&&e.push(n),Rt({children:e,getSiblingFormatting:()=>_e.Newline})}set(e){return he(qd.prototype,this,e),e.value==null?e.hasOwnProperty(t.nameof(e,`value`))&&e.initializer==null&&this.removeInitializer():this.setValue(e.value),this}getStructure(){return me(qd.prototype,this,{kind:e.StructureKind.EnumMember,value:void 0})}},Yd=class extends H{getTypeNodes(){return this.compilerNode.types?.map(e=>this._getNodeFromCompilerNode(e))??[]}getToken(){return this.compilerNode.token}removeExpression(e){let t=this.getTypeNodes(),n=typeof e==`number`?r(e):e;if(t.length===1){let e=this.getParentSyntaxListOrThrow().getChildren();e.length===1?It({children:[e[0].getParentSyntaxListOrThrow()],removePrecedingSpaces:!0}):It({children:[this],removePrecedingSpaces:!0})}else Ut(n);return this;function r(e){return t[et(e,t.length-1)]}}},Xd=class extends H{remove(){Vt(this)}},Zd=(e=>wa(Cn(Hi(ha(e)))))(Xd),Qd=class extends Zd{set(e){return he(Zd.prototype,this,e),this}getStructure(){return me(Zd.prototype,this,{kind:e.StructureKind.CallSignature})}},$d=class extends Xd{},ef=(e=>wa(Cn(Hi(ha(e)))))(Xd),tf=class extends ef{set(e){return he(ef.prototype,this,e),this}getStructure(){return me(ef.prototype,this,{kind:e.StructureKind.ConstructSignature})}},nf=(e=>ua(Cn(Hi(la(Wi(e))))))(Xd),rf=class extends nf{getKeyName(){return this.getKeyNameNode().getText()}setKeyName(e){t.errors.throwIfWhitespaceOrNotString(e,`name`),this.getKeyName()!==e&&this.getKeyNameNode().replaceWithText(e,this._getWriterWithQueuedChildIndentation())}getKeyNameNode(){let e=this.compilerNode.parameters[0];return this._getNodeFromCompilerNode(e.name)}getKeyType(){return this.getKeyNameNode().getType()}setKeyType(e){t.errors.throwIfWhitespaceOrNotString(e,`type`);let n=this.getKeyTypeNode();return n.getText()===e||n.replaceWithText(e,this._getWriterWithQueuedChildIndentation()),this}getKeyTypeNode(){let e=this.compilerNode.parameters[0];return this._getNodeFromCompilerNode(e.type)}set(e){return he(nf.prototype,this,e),e.keyName!=null&&this.setKeyName(e.keyName),e.keyType!=null&&this.setKeyType(e.keyType),this}getStructure(){let t=this.getKeyTypeNode();return me(nf.prototype,this,{kind:e.StructureKind.IndexSignature,keyName:this.getKeyName(),keyType:t.getText()})}},af=(e=>Sa(_a(Pi(Li(wa(Hi(ge(Dc(Mn(Wi(ra(e))))))))))))(ds),of=class extends af{getBaseTypes(){return this.getType().getBaseTypes()}getBaseDeclarations(){return this.getType().getBaseTypes().map(e=>e.getSymbol()?.getDeclarations()??[]).flat()}getImplementations(){return this.getNameNode().getImplementations()}set(e){return he(af.prototype,this,e),this}getStructure(){return me(af.prototype,this,{kind:e.StructureKind.Interface})}},sf=(e=>Cn(Hi(ca(wa(ha(ia(e)))))))(Xd),cf=class extends sf{set(e){return he(sf.prototype,this,e),this}getStructure(){return me(sf.prototype,this,{kind:e.StructureKind.MethodSignature})}},lf=(e=>Cn(Hi(la(ca(Bi(ba(ia(Wi(e)))))))))(Xd),uf=class extends lf{set(e){return he(lf.prototype,this,e),this}getStructure(){return me(lf.prototype,this,{kind:e.StructureKind.PropertySignature})}};function df(e){return class extends e{getAttributes(){return this.compilerNode.attributes.properties.map(e=>this._getNodeFromCompilerNode(e))}getAttributeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getAttribute(e),()=>l(`attribute`,e))}getAttribute(e){return s(this.getAttributes(),e)}addAttribute(e){return this.addAttributes([e])[0]}addAttributes(e){return this.insertAttributes(this.compilerNode.attributes.properties.length,e)}insertAttribute(e,t){return this.insertAttributes(e,[t])[0]}insertAttributes(e,n){if(n.length===0)return[];let r=this.compilerNode.attributes.properties.length;e=et(e,r);let i=e===0?this.getTagNameNode().getEnd():this.getAttributes()[e-1].getEnd(),a=this._getWriterWithQueuedChildIndentation();return new Wn(this._context.structurePrinterFactory.forJsxAttributeDecider()).printText(a,n),kt({insertPos:i,newText:` `+a.toString(),parent:this.getNodeProperty(`attributes`).getFirstChildByKindOrThrow(t.SyntaxKind.SyntaxList)}),Ye(r,this.getAttributes(),e,!1)}set(t){return he(e.prototype,this,t),t.attributes!=null&&(this.getAttributes().forEach(e=>e.remove()),this.addAttributes(t.attributes)),this}getStructure(){return me(e.prototype,this,{attributes:this.getAttributes().map(e=>e.getStructure())})}}}function ff(e){return class extends e{getTagNameNode(){return this._getNodeFromCompilerNode(this.compilerNode.tagName)}set(t){return he(e.prototype,this,t),t.name!=null&&this.getTagNameNode().replaceWithText(t.name),this}getStructure(){return me(e.prototype,this,{name:this.getTagNameNode().getText()})}}}function pf(e){return class extends e{getText(){return this.compilerNode.text}getDefinitionNodes(){return this.getDefinitions().map(e=>e.getDeclarationNode()).filter(e=>e!=null)}getDefinitions(){return this._context.languageService.getDefinitions(this)}}}var mf=Ka(H),hf=class extends mf{},gf=pf(Ji(Xi(Ha))),_f=class extends gf{getImplementations(){return this._context.languageService.getImplementations(this)}},vf=pf(Ji(Xi(H))),yf=class extends vf{},bf=class extends H{getLeft(){return this._getNodeFromCompilerNode(this.compilerNode.left)}getRight(){return this._getNodeFromCompilerNode(this.compilerNode.right)}},xf=H,Sf=class extends xf{getNameNode(){return this._getNodeFromCompilerNode(this.compilerNode.name)}setName(e){return this.getNameNode().replaceWithText(t=>{typeof e==`object`?this._context.structurePrinterFactory.forJsxNamespacedName().printText(t,e):t.write(e)}),this}getInitializerOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getInitializer(),e??`Expected to find an initializer for the JSX attribute '${this.getNameNode().getText()}'`,this)}getInitializer(){return this._getNodeFromCompilerNodeIfExists(this.compilerNode.initializer)}setInitializer(e){let n=I(this._getWriterWithQueuedIndentation(),e);if(t.StringUtils.isNullOrWhitespace(n))return this.removeInitializer(),this;let r=this.getInitializer();return r==null?(kt({insertPos:this.getNameNode().getEnd(),parent:this,newText:`=${n}`}),this):(r.replaceWithText(n),this)}removeInitializer(){let e=this.getInitializer();return e==null||It({children:[e.getPreviousSiblingIfKindOrThrow(t.SyntaxKind.EqualsToken),e],removePrecedingSpaces:!0,removePrecedingNewLines:!0}),this}remove(){It({children:[this],removePrecedingNewLines:!0,removePrecedingSpaces:!0})}set(e){return he(xf.prototype,this,e),e.name!=null&&this.setName(e.name),e.initializer==null?e.hasOwnProperty(t.nameof(e,`initializer`))&&this.removeInitializer():this.setInitializer(e.initializer),this}getStructure(){let t=this.getInitializer(),n=this.getNameNode();return me(xf.prototype,this,{name:n instanceof _f?n.getText():n.getStructure(),kind:e.StructureKind.JsxAttribute,initializer:t?.getText()})}},Cf=(e=>ff(e))(H),wf=class extends Cf{},Tf=class extends Ma{},Ef=Ha,Df=class extends Ef{getJsxChildren(){return this.compilerNode.children.map(e=>this._getNodeFromCompilerNode(e))}getOpeningElement(){return this._getNodeFromCompilerNode(this.compilerNode.openingElement)}getClosingElement(){return this._getNodeFromCompilerNode(this.compilerNode.closingElement)}setBodyText(e){let t=ln(this._getWriterWithIndentation(),e);return Of(this,t),this}setBodyTextInline(e){let t=this._getWriterWithQueuedChildIndentation();return re(t,e),t.isLastNewLine()&&(t.setIndentationLevel(Math.max(0,this.getIndentationLevel()-1)),t.write(``)),Of(this,t.toString()),this}set(e){if(he(Ef.prototype,this,e),e.attributes!=null){let t=this.getOpeningElement();t.getAttributes().forEach(e=>e.remove()),t.addAttributes(e.attributes)}if(e.children!=null)throw new t.errors.NotImplementedError(`Setting JSX children is currently not implemented. Please open an issue if you need this.`);return e.bodyText==null?e.hasOwnProperty(t.nameof(e,`bodyText`))&&this.setBodyTextInline(``):this.setBodyText(e.bodyText),e.name!=null&&(this.getOpeningElement().getTagNameNode().replaceWithText(e.name),this.getClosingElement().getTagNameNode().replaceWithText(e.name)),this}getStructure(){let t=this.getOpeningElement(),n=me(Ef.prototype,this,{kind:e.StructureKind.JsxElement,name:t.getTagNameNode().getText(),attributes:t.getAttributes().map(e=>e.getStructure()),children:void 0,bodyText:un(this)});return delete n.children,n}};function Of(e,t){let n=e.getOpeningElement(),r=e.getClosingElement();kt({insertPos:n.getEnd(),newText:t,parent:e.getChildSyntaxListOrThrow(),replacing:{textLength:r.getStart()-n.getEnd()}})}var kf=Wa(On(Ma)),Af=class extends kf{},jf=class extends Ha{getJsxChildren(){return this.compilerNode.children.map(e=>this._getNodeFromCompilerNode(e))}getOpeningFragment(){return this._getNodeFromCompilerNode(this.compilerNode.openingFragment)}getClosingFragment(){return this._getNodeFromCompilerNode(this.compilerNode.closingFragment)}},Mf=H,Nf=class extends Mf{getNamespaceNode(){return this._getNodeFromCompilerNode(this.compilerNode.namespace)}getNameNode(){return this._getNodeFromCompilerNode(this.compilerNode.name)}set(e){return this.getNamespaceNode().replaceWithText(e.namespace),this.getNameNode().replaceWithText(e.name),this}getStructure(){return{namespace:this.getNamespaceNode().getText(),name:this.getNameNode().getText()}}},Pf=(e=>df(ff(e)))(Ma),Ff=class extends Pf{},If=class extends Ma{},Lf=(e=>df(ff(e)))(Ha),Rf=class extends Lf{set(e){return he(Lf.prototype,this,e),this}getStructure(){return me(Lf.prototype,this,{kind:e.StructureKind.JsxSelfClosingElement})}},zf=Ka(H),Bf=class extends zf{remove(){It({children:[this],removePrecedingNewLines:!0,removePrecedingSpaces:!0})}set(e){return he(zf.prototype,this,e),e.expression!=null&&this.setExpression(e.expression),this}getStructure(){return me(zf.prototype,this,{kind:e.StructureKind.JsxSpreadAttribute,expression:this.getExpression().getText()})}},Vf=Ui(H),Hf=class extends Vf{containsOnlyTriviaWhiteSpaces(){let e=this.compilerNode;return typeof e.containsOnlyWhiteSpaces==`boolean`?e.containsOnlyWhiteSpaces:this.compilerNode.containsOnlyTriviaWhiteSpaces}},Uf=ho,Wf=class extends Uf{getLiteralValue(){let e=this.compilerNode.text;if(typeof BigInt>`u`)throw new t.errors.InvalidOperationError(`Runtime environment does not support BigInts. Perhaps work with the text instead?`);let n=e.substring(0,e.length-1);return BigInt(n)}setLiteralValue(e){if(typeof e!=`bigint`)throw new t.errors.ArgumentTypeError(`value`,`bigint`,typeof e);return Zt({sourceFile:this._sourceFile,start:this.getStart(),replacingLength:this.getWidth(),newText:e.toString()+`n`}),this}},Gf=Ha,Kf=class extends Gf{getLiteralValue(){return Xf(this)}setLiteralValue(e){return Yf(this,e)}},qf=Ha,Jf=class extends qf{getLiteralValue(){return Xf(this)}setLiteralValue(e){return Yf(this,e)}};function Yf(e,t){if(Xf(e)===t)return e;let n=e.getParentSyntaxList()||e.getParentOrThrow(),r=e.getChildIndex();return e.replaceWithText(t?`true`:`false`),n.getChildAtIndex(r)}function Xf(e){return e.getKind()===t.SyntaxKind.TrueKeyword}var Zf=Ha,Qf=class extends Zf{},$f=ho,ep=class extends $f{getLiteralValue(){let e=this.compilerNode.text;return e.indexOf(`.`)>=0?parseFloat(e):parseInt(e,10)}setLiteralValue(e){return Zt({sourceFile:this._sourceFile,start:this.getStart(),replacingLength:this.getWidth(),newText:e.toString(10)}),this}};e.QuoteKind=void 0,(function(e){e.Single=`'`,e.Double=`"`})(e.QuoteKind||={});var tp=ho,np=class extends tp{getLiteralValue(){let e=/^\/(.*)\/([^\/]*)$/,t=this.compilerNode.text,n=e.exec(t);return new RegExp(n[1],n[2])}setLiteralValue(e,t){let n;return typeof e==`string`?n=e:(n=e.source,t=e.flags),Zt({sourceFile:this._sourceFile,start:this.getStart(),replacingLength:this.getWidth(),newText:`/${n}/${t||``}`}),this}},rp=ho,ip=class extends rp{getLiteralValue(){return this.compilerNode.text}setLiteralValue(e){return Zt({sourceFile:this._sourceFile,start:this.getStart()+1,replacingLength:this.getWidth()-2,newText:t.StringUtils.escapeForWithinString(e,this.getQuoteKind())}),this}getQuoteKind(){return this.getText()[0]===`'`?e.QuoteKind.Single:e.QuoteKind.Double}},ap=ho,op=class extends ap{getLiteralValue(){return this.compilerNode.text}setLiteralValue(e){let t=this.getChildIndex(),n=this.getParentSyntaxList()||this.getParentOrThrow();return Zt({sourceFile:this._sourceFile,start:this.getStart()+1,replacingLength:this.getWidth()-2,newText:e}),n.getChildAtIndex(t)}},sp=class extends Va{getTag(){return this._getNodeFromCompilerNode(this.compilerNode.tag)}getTemplate(){return this._getNodeFromCompilerNode(this.compilerNode.template)}removeTag(){let e=this.getParentSyntaxList()??this.getParentOrThrow(),t=this.getChildIndex(),n=this.getTemplate();return kt({customMappings:(e,r)=>[{currentNode:n,newNode:e.getChildren(r)[t]}],parent:e,insertPos:this.getStart(),newText:this.getTemplate().getText(),replacing:{textLength:this.getWidth(),nodes:[this]}}),e.getChildAtIndex(t)}},cp=Ha,lp=class extends cp{getHead(){return this._getNodeFromCompilerNode(this.compilerNode.head)}getTemplateSpans(){return this.compilerNode.templateSpans.map(e=>this._getNodeFromCompilerNode(e))}setLiteralValue(e){let t=this.getChildIndex(),n=this.getParentSyntaxList()??this.getParentOrThrow();return Zt({sourceFile:this._sourceFile,start:this.getStart()+1,replacingLength:this.getWidth()-2,newText:e}),n.getChildAtIndex(t)}},up=Ui(H),dp=class extends up{},fp=Ui(H),pp=class extends fp{},mp=Ka(H),hp=class extends mp{getLiteral(){return this._getNodeFromCompilerNode(this.compilerNode.literal)}},gp=Ui(H),_p=class extends gp{},vp=(e=>An(kn(ba(Bi(Zi(e))))))(H),yp=class extends vp{remove(){let e=this.getParentOrThrow();switch(e.getKind()){case t.SyntaxKind.VariableDeclarationList:n(this);break;case t.SyntaxKind.CatchClause:r(this);break;default:throw new t.errors.NotImplementedError(`Not implemented for syntax kind: ${e.getKindName()}`)}function n(n){let r=e.getParentIfKindOrThrow(t.SyntaxKind.VariableStatement);r.getDeclarations().length===1?r.remove():Ut(n)}function r(e){It({children:[e.getPreviousSiblingIfKindOrThrow(t.SyntaxKind.OpenParenToken),e,e.getNextSiblingIfKindOrThrow(t.SyntaxKind.CloseParenToken)],removePrecedingSpaces:!0})}}getVariableStatementOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getVariableStatement(),e??`Expected the grandparent to be a variable statement.`,this)}getVariableStatement(){let e=this.getParentOrThrow().getParentOrThrow();return H.isVariableStatement(e)?e:void 0}set(e){return he(vp.prototype,this,e),this}getStructure(){return me(vp.prototype,this,{kind:e.StructureKind.VariableDeclaration})}},bp=Wi(H),xp=class extends bp{getDeclarations(){return this.compilerNode.declarations.map(e=>this._getNodeFromCompilerNode(e))}getDeclarationKind(){let n=this.compilerNode.flags;return n&t.ts.NodeFlags.Let?e.VariableDeclarationKind.Let:(n&t.ts.NodeFlags.AwaitUsing)===t.ts.NodeFlags.AwaitUsing?e.VariableDeclarationKind.AwaitUsing:(n&t.ts.NodeFlags.Using)===t.ts.NodeFlags.Using?e.VariableDeclarationKind.Using:n&t.ts.NodeFlags.Const?e.VariableDeclarationKind.Const:e.VariableDeclarationKind.Var}getDeclarationKindKeywords(){let n=this.getDeclarationKind();switch(n){case e.VariableDeclarationKind.Const:return[this.getFirstChildByKindOrThrow(t.SyntaxKind.ConstKeyword)];case e.VariableDeclarationKind.Let:return[this.getFirstChildByKindOrThrow(t.SyntaxKind.LetKeyword)];case e.VariableDeclarationKind.Var:return[this.getFirstChildByKindOrThrow(t.SyntaxKind.VarKeyword)];case e.VariableDeclarationKind.Using:return[this.getFirstChildByKindOrThrow(t.SyntaxKind.UsingKeyword)];case e.VariableDeclarationKind.AwaitUsing:let r=this.getFirstChildByKindOrThrow(t.SyntaxKind.AwaitKeyword);return[r,r.getNextSiblingIfKindOrThrow(t.SyntaxKind.UsingKeyword)];default:return t.errors.throwNotImplementedForNeverValueError(n)}}setDeclarationKind(e){if(this.getDeclarationKind()===e)return this;let t=this.getDeclarationKindKeywords(),n=t[0].getStart(),r=t[t.length-1].getEnd();return kt({insertPos:n,newText:e,parent:this,replacing:{textLength:r-n}}),this}addDeclaration(e){return this.addDeclarations([e])[0]}addDeclarations(e){return this.insertDeclarations(this.getDeclarations().length,e)}insertDeclaration(e,t){return this.insertDeclarations(e,[t])[0]}insertDeclarations(e,n){let r=this._getWriterWithQueuedChildIndentation(),i=new Bn(this._context.structurePrinterFactory.forVariableDeclaration()),a=this.compilerNode.declarations.length;return e=et(e,a),i.printText(r,n),jt({parent:this.getFirstChildByKindOrThrow(t.SyntaxKind.SyntaxList),currentNodes:this.getDeclarations(),insertIndex:e,newText:r.toString(),useTrailingCommas:!1}),Ye(a,this.getDeclarations(),e,!1)}},Sp=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get compilerSignature(){return this.#t}getTypeParameters(){return(this.compilerSignature.typeParameters||[]).map(e=>this.#e.compilerFactory.getTypeParameter(e))}getParameters(){return this.compilerSignature.parameters.map(e=>this.#e.compilerFactory.getSymbol(e))}getReturnType(){return this.#e.compilerFactory.getType(this.compilerSignature.getReturnType())}getDocumentationComments(){return this.compilerSignature.getDocumentationComment(this.#e.typeChecker.compilerObject).map(e=>this.#e.compilerFactory.getSymbolDisplayPart(e))}getJsDocTags(){return this.compilerSignature.getJsDocTags().map(e=>this.#e.compilerFactory.getJSDocTagInfo(e))}getDeclaration(){let{compilerFactory:e}=this.#e,t=this.compilerSignature.getDeclaration();return e.getNodeFromCompilerNode(t,e.getSourceFileForNode(t))}},Cp=class{#e;#t;get compilerSymbol(){return this.#t}constructor(e,t){this.#e=e,this.#t=t,this.getValueDeclaration(),this.getDeclarations()}getName(){return this.compilerSymbol.getName()}getEscapedName(){return this.compilerSymbol.getEscapedName()}getAliasedSymbolOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getAliasedSymbol(),e??`Expected to find an aliased symbol.`)}getImmediatelyAliasedSymbol(){return this.#e.typeChecker.getImmediatelyAliasedSymbol(this)}getImmediatelyAliasedSymbolOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getImmediatelyAliasedSymbol(),e??`Expected to find an immediately aliased symbol.`)}getAliasedSymbol(){return this.#e.typeChecker.getAliasedSymbol(this)}getExportSymbol(){return this.#e.typeChecker.getExportSymbolOfSymbol(this)}isAlias(){return(this.getFlags()&t.SymbolFlags.Alias)===t.SymbolFlags.Alias}isOptional(){return(this.getFlags()&t.SymbolFlags.Optional)===t.SymbolFlags.Optional}getFlags(){return this.compilerSymbol.getFlags()}hasFlags(e){return(this.compilerSymbol.flags&e)===e}getValueDeclarationOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getValueDeclaration(),e??(()=>`Expected to find the value declaration of symbol '${this.getName()}'.`))}getValueDeclaration(){let e=this.compilerSymbol.valueDeclaration;if(e!=null)return this.#e.compilerFactory.getNodeFromCompilerNode(e,this.#e.compilerFactory.getSourceFileForNode(e))}getDeclarations(){return(this.compilerSymbol.declarations??[]).map(e=>this.#e.compilerFactory.getNodeFromCompilerNode(e,this.#e.compilerFactory.getSourceFileForNode(e)))}getExportOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getExport(e),n??(()=>`Expected to find export with name: ${e}`))}getExport(e){if(this.compilerSymbol.exports==null)return;let n=this.compilerSymbol.exports.get(t.ts.escapeLeadingUnderscores(e));return n==null?void 0:this.#e.compilerFactory.getSymbol(n)}getExports(){return this.compilerSymbol.exports==null?[]:Array.from(this.compilerSymbol.exports.values()).map(e=>this.#e.compilerFactory.getSymbol(e))}getGlobalExportOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getGlobalExport(e),n??(()=>`Expected to find global export with name: ${e}`))}getGlobalExport(e){if(this.compilerSymbol.globalExports==null)return;let n=this.compilerSymbol.globalExports.get(t.ts.escapeLeadingUnderscores(e));return n==null?void 0:this.#e.compilerFactory.getSymbol(n)}getGlobalExports(){return this.compilerSymbol.globalExports==null?[]:Array.from(this.compilerSymbol.globalExports.values()).map(e=>this.#e.compilerFactory.getSymbol(e))}getMemberOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getMember(e),n??`Expected to find member with name: ${e}`)}getMember(e){if(this.compilerSymbol.members==null)return;let n=this.compilerSymbol.members.get(t.ts.escapeLeadingUnderscores(e));return n==null?void 0:this.#e.compilerFactory.getSymbol(n)}getMembers(){return this.compilerSymbol.members==null?[]:Array.from(this.compilerSymbol.members.values()).map(e=>this.#e.compilerFactory.getSymbol(e))}getDeclaredType(){return this.#e.typeChecker.getDeclaredTypeOfSymbol(this)}getTypeAtLocation(e){return this.#e.typeChecker.getTypeOfSymbolAtLocation(this,e)}getFullyQualifiedName(){return this.#e.typeChecker.getFullyQualifiedName(this)}getJsDocTags(){return this.compilerSymbol.getJsDocTags(this.#e.typeChecker.compilerObject).map(e=>new kd(e))}},wp=class{#e;constructor(e){this.#e=e}get compilerObject(){return this.#e}getStart(){return this.compilerObject.start}getEnd(){return this.compilerObject.start+this.compilerObject.length}getLength(){return this.compilerObject.length}},Tp=class{#e;constructor(e){this.#e=e}get compilerObject(){return this.#e}getSpan(){return new wp(this.compilerObject.span)}getNewText(){return this.compilerObject.newText}};Vc([t.Memoize],Tp.prototype,`getSpan`,null);var Ep=class{#e;#t;#n;#r;#i;constructor(e,t){this.#e=e,this.#t=t;let n=e.compilerFactory.addOrGetSourceFileFromFilePath(e.fileSystemWrapper.getStandardizedAbsolutePath(t.fileName),{markInProject:!1,scriptKind:void 0});this.#r=n!=null,t.isNewFile||(this.#n=n)}getFilePath(){return this.#t.fileName}getSourceFile(){return this.#n}getTextChanges(){return this.#t.textChanges.map(e=>new Tp(e))}applyChanges(e={}){if(this.#i)return;if(this.isNewFile()&&this.#r&&!e.overwrite)throw new t.errors.InvalidOperationError(`Cannot apply file text change for creating a new file when the file exists at path ${this.getFilePath()}. Did you mean to provide the overwrite option?`);let n;if(n=this.isNewFile()?this.#e.project.createSourceFile(this.getFilePath(),``,{overwrite:e.overwrite}):this.getSourceFile(),n==null)throw new t.errors.InvalidOperationError(`Cannot apply file text change to modify existing file that doesn't exist at path: ${this.getFilePath()}`);return n.applyTextChanges(this.getTextChanges()),n._markAsInProject(),this.#i=!0,this}isNewFile(){return!!this.#t.isNewFile}};Vc([t.Memoize],Ep.prototype,`getTextChanges`,null);var Dp=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get compilerObject(){return this.#t}getDescription(){return this.compilerObject.description}getChanges(){return this.compilerObject.changes.map(e=>new Ep(this.#e,e))}},Op=class extends Dp{getFixName(){return this.compilerObject.fixName}getFixId(){return this.compilerObject.fixId}getFixAllDescription(){return this.compilerObject.fixAllDescription}},kp=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get compilerObject(){return this.#t}getChanges(){return this.compilerObject.changes.map(e=>new Ep(this.#e,e))}applyChanges(e){for(let t of this.getChanges())t.applyChanges(e);return this}};Vc([t.Memoize],kp.prototype,`getChanges`,null);var Ap=class{_context;_compilerObject;_sourceFile;constructor(e,t){this._context=e,this._compilerObject=t,this._sourceFile=this._context.compilerFactory.addOrGetSourceFileFromFilePath(e.fileSystemWrapper.getStandardizedAbsolutePath(this.compilerObject.fileName),{markInProject:!1,scriptKind:void 0}),this._sourceFile._doActionPreNextModification(()=>this.getNode())}get compilerObject(){return this._compilerObject}getSourceFile(){return this._sourceFile}getTextSpan(){return new wp(this.compilerObject.textSpan)}getNode(){let e=this.getTextSpan(),t=this.getSourceFile(),n=e.getStart(),r=e.getEnd();return i();function i(){let e;return t._context.compilerFactory.forgetNodesCreatedInBlock(i=>{let a,o=t;for(;o!=null;){if(a??(e=o),o.getStart()===n&&o.getWidth()===r)e=a=o;else if(a!=null)break;o=o.getChildAtPos(n)}e!=null&&i(e)}),e}}getOriginalTextSpan(){let{originalTextSpan:e}=this.compilerObject;return e==null?void 0:new wp(e)}getOriginalFileName(){return this.compilerObject.originalFileName}};Vc([t.Memoize],Ap.prototype,`getTextSpan`,null),Vc([t.Memoize],Ap.prototype,`getNode`,null),Vc([t.Memoize],Ap.prototype,`getOriginalTextSpan`,null);var jp=class extends Ap{constructor(e,t){super(e,t),this.getSourceFile()._doActionPreNextModification(()=>this.getDeclarationNode())}getKind(){return this.compilerObject.kind}getName(){return this.compilerObject.name}getContainerKind(){return this.compilerObject.containerKind}getContainerName(){return this.compilerObject.containerName}getDeclarationNode(){if(this.getKind()===`module`&&this.getTextSpan().getLength()===this.getSourceFile().getFullWidth())return this.getSourceFile();let e=this.getTextSpan().getStart();return n(this.getSourceFile())?.getParentOrThrow();function n(r){if(r.getKind()===t.SyntaxKind.Identifier&&r.getStart()===e)return r;for(let t of r._getChildrenIterator())if(t.getPos()<=e&&t.getEnd()>e)return n(t)}}};Vc([t.Memoize],jp.prototype,`getDeclarationNode`,null);var Mp=class e{_compilerObject;constructor(e){this._compilerObject=e}get compilerObject(){return this._compilerObject}getMessageText(){return this.compilerObject.messageText}getNext(){let t=this.compilerObject.next;if(t!=null)return t instanceof Array?t.map(t=>new e(t)):[new e(t)]}getCode(){return this.compilerObject.code}getCategory(){return this.compilerObject.category}},Np=class{_context;_compilerObject;constructor(e,t){this._context=e,this._compilerObject=t,this.getSourceFile()}get compilerObject(){return this._compilerObject}getSourceFile(){if(this._context==null)return;let e=this.compilerObject.file;return e==null?void 0:this._context.compilerFactory.getSourceFile(e,{markInProject:!1})}getMessageText(){let e=this._compilerObject.messageText;return typeof e==`string`?e:this._context==null?new Mp(e):this._context.compilerFactory.getDiagnosticMessageChain(e)}getLineNumber(){let e=this.getSourceFile(),n=this.getStart();if(!(e==null||n==null))return t.StringUtils.getLineNumberAtPos(e.getFullText(),n)}getStart(){return this.compilerObject.start}getLength(){return this.compilerObject.length}getCategory(){return this.compilerObject.category}getCode(){return this.compilerObject.code}getSource(){return this.compilerObject.source}};Vc([t.Memoize],Np.prototype,`getSourceFile`,null);var Pp=class extends Np{constructor(e,t){super(e,t)}getLineNumber(){return super.getLineNumber()}getStart(){return super.getStart()}getLength(){return super.getLength()}getSourceFile(){return super.getSourceFile()}},Fp=class{#e;#t;constructor(e,t){this.#e=t,this.#t=e}get compilerObject(){return this.#e}getFilePath(){return this.#t.fileSystemWrapper.getStandardizedAbsolutePath(this.compilerObject.name)}getWriteByteOrderMark(){return this.compilerObject.writeByteOrderMark||!1}getText(){return this.compilerObject.text}},Ip=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get compilerObject(){return this.#t}getDiagnostics(){return this.compilerObject.diagnostics.map(e=>this.#e.compilerFactory.getDiagnostic(e))}getEmitSkipped(){return this.compilerObject.emitSkipped}getOutputFiles(){return this.compilerObject.outputFiles.map(e=>new Fp(this.#e,e))}};Vc([t.Memoize],Ip.prototype,`getDiagnostics`,null),Vc([t.Memoize],Ip.prototype,`getOutputFiles`,null);var Lp=class{_context;_compilerObject;constructor(e,t){this._context=e,this._compilerObject=t,this.getDiagnostics()}get compilerObject(){return this._compilerObject}getEmitSkipped(){return this.compilerObject.emitSkipped}getDiagnostics(){return this.compilerObject.diagnostics.map(e=>this._context.compilerFactory.getDiagnostic(e))}};Vc([t.Memoize],Lp.prototype,`getDiagnostics`,null);var Rp=class extends Ap{constructor(e,t){super(e,t)}getKind(){return this.compilerObject.kind}getDisplayParts(){return this.compilerObject.displayParts.map(e=>this._context.compilerFactory.getSymbolDisplayPart(e))}};Vc([t.Memoize],Rp.prototype,`getDisplayParts`,null);var zp=class extends Lp{#e;constructor(e,t,n){super(e,t),this.#e=n}getFiles(){return this.#e}saveFiles(){let e=this._context.fileSystemWrapper,t=this.#e.map(t=>e.writeFile(t.filePath,t.writeByteOrderMark?``+t.text:t.text));return Promise.all(t)}saveFilesSync(){let e=this._context.fileSystemWrapper;for(let t of this.#e)e.writeFileSync(t.filePath,t.writeByteOrderMark?``+t.text:t.text)}},Bp=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get compilerObject(){return this.#t}getEdits(){return this.compilerObject.edits.map(e=>new Ep(this.#e,e))}getRenameFilePath(){return this.compilerObject.renameFilename}getRenameLocation(){return this.compilerObject.renameLocation}applyChanges(e){for(let t of this.getEdits())t.applyChanges(e);return this}};Vc([t.Memoize],Bp.prototype,`getEdits`,null);var Vp=class{_context;#e;#t;constructor(e,t){this._context=e,this.#e=t,this.#t=this.compilerObject.references.map(t=>e.compilerFactory.getReferencedSymbolEntry(t))}get compilerObject(){return this.#e}getDefinition(){return this._context.compilerFactory.getReferencedSymbolDefinitionInfo(this.compilerObject.definition)}getReferences(){return this.#t}};Vc([t.Memoize],Vp.prototype,`getDefinition`,null);var Hp=class extends jp{constructor(e,t){super(e,t)}getDisplayParts(){return this.compilerObject.displayParts.map(e=>this._context.compilerFactory.getSymbolDisplayPart(e))}};Vc([t.Memoize],Hp.prototype,`getDisplayParts`,null);var Up=class extends Ap{constructor(e,t){super(e,t)}isWriteAccess(){return this.compilerObject.isWriteAccess}isInString(){return this.compilerObject.isInString}},Wp=class extends Up{constructor(e,t){super(e,t)}isDefinition(){return this.compilerObject.isDefinition}},Gp=class extends Ap{getPrefixText(){return this._compilerObject.prefixText}getSuffixText(){return this._compilerObject.suffixText}},Kp=class{#e;constructor(e){this.#e=e}get compilerObject(){return this.#e}getText(){return this.compilerObject.text}getKind(){return this.compilerObject.kind}},qp=class{#e;#t;constructor(e){this.#e=e}get compilerObject(){return this.#t()}_reset(e){this.#t=e}getAmbientModules(){return this.compilerObject.getAmbientModules().map(e=>this.#e.compilerFactory.getSymbol(e))}getApparentType(e){return this.#e.compilerFactory.getType(this.compilerObject.getApparentType(e.compilerType))}getConstantValue(e){return this.compilerObject.getConstantValue(e.compilerNode)}getFullyQualifiedName(e){return this.compilerObject.getFullyQualifiedName(e.compilerSymbol)}getTypeAtLocation(e){return this.#e.compilerFactory.getType(this.compilerObject.getTypeAtLocation(e.compilerNode))}getContextualType(e){let t=this.compilerObject.getContextualType(e.compilerNode);return t==null?void 0:this.#e.compilerFactory.getType(t)}getTypeOfSymbolAtLocation(e,t){return this.#e.compilerFactory.getType(this.compilerObject.getTypeOfSymbolAtLocation(e.compilerSymbol,t.compilerNode))}getDeclaredTypeOfSymbol(e){return this.#e.compilerFactory.getType(this.compilerObject.getDeclaredTypeOfSymbol(e.compilerSymbol))}getSymbolAtLocation(e){let t=this.compilerObject.getSymbolAtLocation(e.compilerNode);return t==null?void 0:this.#e.compilerFactory.getSymbol(t)}getAliasedSymbol(e){if(!e.hasFlags(t.SymbolFlags.Alias))return;let n=this.compilerObject.getAliasedSymbol(e.compilerSymbol);return n==null?void 0:this.#e.compilerFactory.getSymbol(n)}getImmediatelyAliasedSymbol(e){let t=this.compilerObject.getImmediateAliasedSymbol(e.compilerSymbol);return t==null?void 0:this.#e.compilerFactory.getSymbol(t)}getExportSymbolOfSymbol(e){return this.#e.compilerFactory.getSymbol(this.compilerObject.getExportSymbolOfSymbol(e.compilerSymbol))}getPropertiesOfType(e){return this.compilerObject.getPropertiesOfType(e.compilerType).map(e=>this.#e.compilerFactory.getSymbol(e))}getTypeText(e,t,n){return n??=this.#n(t),this.compilerObject.typeToString(e.compilerType,t?.compilerNode,n)}getReturnTypeOfSignature(e){return this.#e.compilerFactory.getType(this.compilerObject.getReturnTypeOfSignature(e.compilerSignature))}getSignatureFromNode(e){let t=this.compilerObject.getSignatureFromDeclaration(e.compilerNode);return t==null?void 0:this.#e.compilerFactory.getSignature(t)}getExportsOfModule(e){return(this.compilerObject.getExportsOfModule(e.compilerSymbol)||[]).map(e=>this.#e.compilerFactory.getSymbol(e))}getExportSpecifierLocalTargetSymbol(e){let t=this.compilerObject.getExportSpecifierLocalTargetSymbol(e.compilerNode);return t==null?void 0:this.#e.compilerFactory.getSymbol(t)}getResolvedSignature(e){let t=this.compilerObject.getResolvedSignature(e.compilerNode);if(!(!t||!t.declaration))return this.#e.compilerFactory.getSignature(t)}getResolvedSignatureOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getResolvedSignature(e),n??`Signature could not be resolved.`,e)}getBaseTypeOfLiteralType(e){return this.#e.compilerFactory.getType(this.compilerObject.getBaseTypeOfLiteralType(e.compilerType))}getSymbolsInScope(e,t){return this.compilerObject.getSymbolsInScope(e.compilerNode,t).map(e=>this.#e.compilerFactory.getSymbol(e))}getTypeArguments(e){return this.compilerObject.getTypeArguments(e.compilerType).map(e=>this.#e.compilerFactory.getType(e))}isTypeAssignableTo(e,t){return this.compilerObject.isTypeAssignableTo(e.compilerType,t.compilerType)}#n(e){let n=t.TypeFormatFlags.UseTypeOfFunction|t.TypeFormatFlags.NoTruncation|t.TypeFormatFlags.UseFullyQualifiedType|t.TypeFormatFlags.WriteTypeArgumentsOfSignature;return e!=null&&e.getKind()===t.SyntaxKind.TypeAliasDeclaration&&(n|=t.TypeFormatFlags.InTypeAlias),n}getShorthandAssignmentValueSymbol(e){let t=this.compilerObject.getShorthandAssignmentValueSymbol(e.compilerNode);return t?this.#e.compilerFactory.getSymbol(t):void 0}resolveName(e,t,n,r){let i=this.compilerObject.resolveName(e,t?.compilerNode,n,r);return i?this.#e.compilerFactory.getSymbol(i):void 0}},Jp=class{#e;#t;#n;#r;#i;#a;constructor(e){this.#e=e.context,this.#a=e.configFileParsingDiagnostics,this.#t=new qp(this.#e),this._reset(e.rootNames,e.host)}get compilerObject(){return this.#i()}_isCompilerProgramCreated(){return this.#n!=null}_reset(e,n){let r=this.#e.compilerOptions.get();this.#i=()=>(this.#n??(this.#n=t.ts.createProgram(e,r,n,this.#r,this.#a),this.#r=void 0),this.#n),this.#n!=null&&(this.#r=this.#n,this.#n=void 0),this.#t._reset(()=>this.compilerObject.getTypeChecker())}getTypeChecker(){return this.#t}async emit(e={}){if(e.writeFile){let n=`Cannot specify a ${t.nameof(e,`writeFile`)} option when emitting asynchrously. Use ${t.nameof(this,`emitSync`)}() instead.`;throw new t.errors.InvalidOperationError(n)}let{fileSystemWrapper:n}=this.#e,r=[],i=this.#o({writeFile:(e,t,i)=>{r.push(n.writeFile(n.getStandardizedAbsolutePath(e),i?``+t:t))},...e});return await Promise.all(r),new Lp(this.#e,i)}emitSync(e={}){return new Lp(this.#e,this.#o(e))}emitToMemory(e={}){let t=[],{fileSystemWrapper:n}=this.#e,r=this.#o({writeFile:(e,r,i)=>{t.push({filePath:n.getStandardizedAbsolutePath(e),text:r,writeByteOrderMark:i||!1})},...e});return new zp(this.#e,r,t)}#o(e={}){let t=e.targetSourceFile==null?void 0:e.targetSourceFile.compilerNode,{emitOnlyDtsFiles:n,customTransformers:r,writeFile:i}=e;return this.compilerObject.emit(t,i,void 0,n,r)}getSyntacticDiagnostics(e){return this.compilerObject.getSyntacticDiagnostics(e?.compilerNode).map(e=>this.#e.compilerFactory.getDiagnosticWithLocation(e))}getSemanticDiagnostics(e){return this.compilerObject.getSemanticDiagnostics(e?.compilerNode).map(e=>this.#e.compilerFactory.getDiagnostic(e))}getDeclarationDiagnostics(e){return this.compilerObject.getDeclarationDiagnostics(e?.compilerNode).map(e=>this.#e.compilerFactory.getDiagnosticWithLocation(e))}getGlobalDiagnostics(){return this.compilerObject.getGlobalDiagnostics().map(e=>this.#e.compilerFactory.getDiagnostic(e))}getConfigFileParsingDiagnostics(){return this.compilerObject.getConfigFileParsingDiagnostics().map(e=>this.#e.compilerFactory.getDiagnostic(e))}getEmitModuleResolutionKind(){return t.getEmitModuleResolutionKind(this.compilerObject.getCompilerOptions())}isSourceFileFromExternalLibrary(e){return e.isFromExternalLibrary()}},Yp=class{#e;#t;#n;#r;#i=0;get compilerObject(){return this.#e}constructor(e){this.#r=e.context;let{languageServiceHost:n,compilerHost:r}=t.createHosts({transactionalFileSystem:this.#r.fileSystemWrapper,sourceFileContainer:this.#r.getSourceFileContainer(),compilerOptions:this.#r.compilerOptions,getNewLine:()=>this.#r.manipulationSettings.getNewLineKindAsString(),getProjectVersion:()=>`${this.#i}`,resolutionHost:e.resolutionHost??{},libFolderPath:e.libFolderPath,skipLoadingLibFiles:e.skipLoadingLibFiles});this.#t=r,this.#e=t.ts.createLanguageService(n,this.#r.compilerFactory.documentRegistry),this.#n=new Jp({context:this.#r,rootNames:Array.from(this.#r.compilerFactory.getSourceFilePaths()),host:this.#t,configFileParsingDiagnostics:e.configFileParsingDiagnostics}),this.#r.compilerFactory.onSourceFileAdded(e=>{e._isInProject()&&this._reset()}),this.#r.compilerFactory.onSourceFileRemoved(()=>this._reset())}_reset(){this.#i+=1,this.#n._reset(Array.from(this.#r.compilerFactory.getSourceFilePaths()),this.#t)}getProgram(){return this.#n}getDefinitions(e){return this.getDefinitionsAtPosition(e._sourceFile,e.getStart())}getDefinitionsAtPosition(e,t){return(this.compilerObject.getDefinitionAtPosition(e.getFilePath(),t)||[]).map(e=>this.#r.compilerFactory.getDefinitionInfo(e))}getImplementations(e){return this.getImplementationsAtPosition(e._sourceFile,e.getStart())}getImplementationsAtPosition(e,t){return(this.compilerObject.getImplementationAtPosition(e.getFilePath(),t)||[]).map(e=>new Rp(this.#r,e))}findReferences(e){return this.findReferencesAtPosition(e._sourceFile,e.getStart())}findReferencesAsNodes(e){let n=this.findReferences(e);return Array.from(r());function*r(){for(let e of n){let n=e.getDefinition().getKind()===t.ts.ScriptElementKind.alias,r=e.getReferences();for(let e=0;e<r.length;e++){let t=r[e];(n||!t.isDefinition()||e>0)&&(yield t.getNode())}}}}findReferencesAtPosition(e,t){return(this.compilerObject.findReferences(e.getFilePath(),t)||[]).map(e=>this.#r.compilerFactory.getReferencedSymbol(e))}findRenameLocations(e,t={}){let n=t.usePrefixAndSuffixText==null?this.#r.manipulationSettings.getUsePrefixAndSuffixTextForRename():t.usePrefixAndSuffixText;return(this.compilerObject.findRenameLocations(e._sourceFile.getFilePath(),e.getStart(),t.renameInStrings||!1,t.renameInComments||!1,n)||[]).map(e=>new Gp(this.#r,e))}getSuggestionDiagnostics(e){let t=this.#a(e);return this.compilerObject.getSuggestionDiagnostics(t).map(e=>this.#r.compilerFactory.getDiagnosticWithLocation(e))}getFormattingEditsForRange(e,t,n){return(this.compilerObject.getFormattingEditsForRange(e,t[0],t[1],this.#o(n))||[]).map(e=>new Tp(e))}getFormattingEditsForDocument(e,t){let n=this.#r.fileSystemWrapper.getStandardizedAbsolutePath(e);return(this.compilerObject.getFormattingEditsForDocument(n,this.#o(t))||[]).map(e=>new Tp(e))}getFormattedDocumentText(e,n){let r=this.#r.fileSystemWrapper.getStandardizedAbsolutePath(e),i=this.#r.compilerFactory.getSourceFileFromCacheFromFilePath(r);if(i==null)throw new t.errors.FileNotFoundError(r);n=this.#o(n);let a=R(i,this.getFormattingEditsForDocument(r,n)),o=n.newLineCharacter;return n.ensureNewLineAtEndOfFile&&!a.endsWith(o)&&(a+=o),a.replace(/\r?\n/g,o)}getEmitOutput(e,t){let n=this.#a(e),r=this.compilerObject;return new Ip(this.#r,i());function i(){let e=r.getProgram();return e==null||e.getSourceFile(n)==null?{emitSkipped:!0,outputFiles:[],diagnostics:[]}:r.getEmitOutput(n,t)}}getIdentationAtPosition(e,t,n){let r=this.#a(e);return n==null?n=this.#r.manipulationSettings.getEditorSettings():P(n,this.#r.manipulationSettings),this.compilerObject.getIndentationAtPosition(r,t,n)}organizeImports(e,t={},n={}){let r={type:`file`,fileName:this.#a(e)};return this.compilerObject.organizeImports(r,this.#o(t),this.#s(n)).map(e=>new Ep(this.#r,e))}getEditsForRefactor(e,t,n,r,i,a={}){let o=this.#a(e),s=typeof n==`number`?n:{pos:n.getPos(),end:n.getEnd()},c=this.compilerObject.getEditsForRefactor(o,this.#o(t),s,r,i,this.#s(a));return c==null?void 0:new Bp(this.#r,c)}getCombinedCodeFix(e,t,n={},r={}){let i=this.compilerObject.getCombinedCodeFix({type:`file`,fileName:this.#a(e)},t,this.#o(n),this.#s(r||{}));return new kp(this.#r,i)}getCodeFixesAtPosition(e,t,n,r,i={},a={}){let o=this.#a(e);return this.compilerObject.getCodeFixesAtPosition(o,t,n,r,this.#o(i),this.#s(a||{})).map(e=>new Op(this.#r,e))}#a(e){let n=typeof e==`string`?this.#r.fileSystemWrapper.getStandardizedAbsolutePath(e):e.getFilePath();if(!this.#r.compilerFactory.containsSourceFileAtPath(n))throw new t.errors.FileNotFoundError(n);return n}#o(e){return e._filled?e:(e=Object.assign(this.#r.getFormatCodeSettings(),e),F(e,this.#r.manipulationSettings),e._filled=!0,e)}#s(e){return Object.assign(this.#r.getUserPreferences(),e)}},Xp=class{_context;#e;get compilerType(){return this.#e}constructor(e,t){this._context=e,this.#e=t}getText(e,t){return this._context.typeChecker.getTypeText(this,e,t)}getAliasSymbol(){return this.compilerType.aliasSymbol==null?void 0:this._context.compilerFactory.getSymbol(this.compilerType.aliasSymbol)}getAliasSymbolOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getAliasSymbol(),`Expected to find an alias symbol.`)}getAliasTypeArguments(){return(this.compilerType.aliasTypeArguments||[]).map(e=>this._context.compilerFactory.getType(e))}getApparentType(){return this._context.typeChecker.getApparentType(this)}getArrayElementTypeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getArrayElementType(),e??`Expected to find an array element type.`)}getArrayElementType(){if(this.isArray())return this.getTypeArguments()[0]}getBaseTypes(){return(this.compilerType.getBaseTypes()||[]).map(e=>this._context.compilerFactory.getType(e))}getBaseTypeOfLiteralType(){return this._context.typeChecker.getBaseTypeOfLiteralType(this)}getCallSignatures(){return this.compilerType.getCallSignatures().map(e=>this._context.compilerFactory.getSignature(e))}getConstructSignatures(){return this.compilerType.getConstructSignatures().map(e=>this._context.compilerFactory.getSignature(e))}getConstraintOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getConstraint(),e??`Expected to find a constraint.`)}getConstraint(){let e=this.compilerType.getConstraint();return e==null?void 0:this._context.compilerFactory.getType(e)}getDefaultOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getDefault(),e??`Expected to find a default type.`)}getDefault(){let e=this.compilerType.getDefault();return e==null?void 0:this._context.compilerFactory.getType(e)}getProperties(){return this.compilerType.getProperties().map(e=>this._context.compilerFactory.getSymbol(e))}getPropertyOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getProperty(e),()=>l(`symbol property`,e))}getProperty(e){return ee(this.getProperties(),e)}getApparentProperties(){return this.compilerType.getApparentProperties().map(e=>this._context.compilerFactory.getSymbol(e))}getApparentProperty(e){return ee(this.getApparentProperties(),e)}isNullable(){return this.getUnionTypes().some(e=>e.isNull()||e.isUndefined())}getNonNullableType(){return this._context.compilerFactory.getType(this.compilerType.getNonNullableType())}getNumberIndexType(){let e=this.compilerType.getNumberIndexType();return e==null?void 0:this._context.compilerFactory.getType(e)}getStringIndexType(){let e=this.compilerType.getStringIndexType();return e==null?void 0:this._context.compilerFactory.getType(e)}getTargetType(){let e=this.compilerType.target||void 0;return e==null?void 0:this._context.compilerFactory.getType(e)}getTargetTypeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getTargetType(),e??`Expected to find the target type.`)}getTypeArguments(){return this._context.typeChecker.getTypeArguments(this)}getTupleElements(){return this.isTuple()?this.getTypeArguments():[]}getUnionTypes(){return this.isUnion()?this.compilerType.types.map(e=>this._context.compilerFactory.getType(e)):[]}getIntersectionTypes(){return this.isIntersection()?this.compilerType.types.map(e=>this._context.compilerFactory.getType(e)):[]}getLiteralValue(){return this.compilerType?.value}getLiteralValueOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getLiteralValue(),e??`Type was not a literal type.`)}getLiteralFreshType(){let e=this.compilerType?.freshType;return e==null?void 0:this._context.compilerFactory.getType(e)}getLiteralFreshTypeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getLiteralFreshType(),e??`Type was not a literal type.`)}getLiteralRegularType(){let e=this.compilerType?.regularType;return e==null?void 0:this._context.compilerFactory.getType(e)}getLiteralRegularTypeOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getLiteralRegularType(),e??`Type was not a literal type.`)}getSymbol(){let e=this.compilerType.getSymbol();return e==null?void 0:this._context.compilerFactory.getSymbol(e)}getSymbolOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getSymbol(),e??`Expected to find a symbol.`)}isAssignableTo(e){return this._context.typeChecker.isTypeAssignableTo(this,e)}isAnonymous(){return this.#n(t.ObjectFlags.Anonymous)}isAny(){return this.#t(t.TypeFlags.Any)}isNever(){return this.#t(t.TypeFlags.Never)}isArray(){let e=this.getSymbol();return e==null?!1:(e.getName()===`Array`||e.getName()===`ReadonlyArray`)&&this.getTypeArguments().length===1}isReadonlyArray(){let e=this.getSymbol();return e==null?!1:e.getName()===`ReadonlyArray`&&this.getTypeArguments().length===1}isTemplateLiteral(){return this.#t(t.TypeFlags.TemplateLiteral)}isBoolean(){return this.#t(t.TypeFlags.Boolean)}isString(){return this.#t(t.TypeFlags.String)}isNumber(){return this.#t(t.TypeFlags.Number)}isBigInt(){return this.#t(t.TypeFlags.BigInt)}isLiteral(){let e=this.isBooleanLiteral();return this.compilerType.isLiteral()||e}isBooleanLiteral(){return this.#t(t.TypeFlags.BooleanLiteral)}isBigIntLiteral(){return this.#t(t.TypeFlags.BigIntLiteral)}isEnumLiteral(){return this.#t(t.TypeFlags.EnumLiteral)&&!this.isUnion()}isNumberLiteral(){return this.#t(t.TypeFlags.NumberLiteral)}isStringLiteral(){return this.compilerType.isStringLiteral()}isClass(){return this.compilerType.isClass()}isClassOrInterface(){return this.compilerType.isClassOrInterface()}isEnum(){if(this.#t(t.TypeFlags.Enum))return!0;if(this.isEnumLiteral()&&!this.isUnion())return!1;let e=this.getSymbol();if(e==null)return!1;let n=e.getValueDeclaration();return n!=null&&H.isEnumDeclaration(n)}isInterface(){return this.#n(t.ObjectFlags.Interface)}isObject(){return this.#t(t.TypeFlags.Object)}isTypeParameter(){return this.compilerType.isTypeParameter()}isTuple(){let e=this.getTargetType();return e==null?!1:e.#n(t.ObjectFlags.Tuple)}isUnion(){return this.compilerType.isUnion()}isIntersection(){return this.compilerType.isIntersection()}isUnionOrIntersection(){return this.compilerType.isUnionOrIntersection()}isUnknown(){return this.#t(t.TypeFlags.Unknown)}isNull(){return this.#t(t.TypeFlags.Null)}isUndefined(){return this.#t(t.TypeFlags.Undefined)}isVoid(){return this.#t(t.TypeFlags.Void)}getFlags(){return this.compilerType.flags}getObjectFlags(){return this.isObject()&&this.compilerType.objectFlags||0}#t(e){return(this.compilerType.flags&e)===e}#n(e){return(this.getObjectFlags()&e)===e}},Zp=class extends Xp{getConstraintOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getConstraint(),e??`Expected type parameter to have a constraint.`)}getConstraint(){let e=this.#e();if(e==null)return;let t=e.getConstraint();if(t!=null)return this._context.typeChecker.getTypeAtLocation(t)}getDefaultOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getDefault(),e??`Expected type parameter to have a default type.`)}getDefault(){let e=this.#e();if(e==null)return;let t=e.getDefault();if(t!=null)return this._context.typeChecker.getTypeAtLocation(t)}#e(){let e=this.getSymbol();if(e==null)return;let t=e.getDeclarations()[0];if(t!=null&&H.isTypeParameterDeclaration(t))return t}},Qp=class{#e;#t;constructor(e,t){this.#t=e,this.#e=t}getSkippedFilePaths(){return this.#t}getOutputFilePaths(){return this.#e}},$p=class e{#e;#t;#n;constructor(e,t){this.#e=e,this._setPathInternal(t)}_setPathInternal(e){this.#t=e,this.#n=e.split(`/`).filter(e=>e.length>0)}get _context(){return this.#s(),this.#e}isAncestorOf(t){return e.#u(this,t)}isDescendantOf(t){return e.#u(t,this)}_getDepth(){return this.#n.length}getPath(){return this.#s(),this.#t}getBaseName(){return this.#n[this.#n.length-1]}getParentOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getParent(),e??(()=>`Parent directory of ${this.getPath()} does not exist or was never added.`))}getParent(){if(!t.FileUtils.isRootDirPath(this.getPath()))return this.addDirectoryAtPathIfExists(t.FileUtils.getDirPath(this.getPath()))}getDirectoryOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getDirectory(e),()=>typeof e==`string`?`Could not find a directory at path '${this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath())}'.`:`Could not find child directory that matched condition.`)}getDirectory(e){if(typeof e==`string`){let t=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath());return this._context.compilerFactory.getDirectoryFromCache(t)}return this.getDirectories().find(e)}getSourceFileOrThrow(e){return t.errors.throwIfNullOrUndefined(this.getSourceFile(e),()=>typeof e==`string`?`Could not find child source file at path '${this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath())}'.`:`Could not find child source file that matched condition.`)}getSourceFile(e){if(typeof e==`string`){let t=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath());return this._context.compilerFactory.getSourceFileFromCacheFromFilePath(t)}for(let t of this._getSourceFilesIterator())if(e(t))return t}getDirectories(){return Array.from(this._getDirectoriesIterator())}_getDirectoriesIterator(){return this._context.compilerFactory.getChildDirectoriesOfDirectory(this.getPath())}getSourceFiles(e){let{compilerFactory:n,fileSystemWrapper:r}=this._context,i=this;if(typeof e==`string`||e instanceof Array){let t=typeof e==`string`?[e]:e;return Array.from(a(t))}else return Array.from(this._getSourceFilesIterator());function*a(e){let a=Array.from(s()),o=t.matchGlobs(a,e,i.getPath());for(let e of o)yield n.getSourceFileFromCacheFromFilePath(r.getStandardizedAbsolutePath(e));function*s(){for(let e of i._getDescendantSourceFilesIterator())yield e.getFilePath()}}}_getSourceFilesIterator(){return this._context.compilerFactory.getChildSourceFilesOfDirectory(this.getPath())}getDescendantSourceFiles(){return Array.from(this._getDescendantSourceFilesIterator())}*_getDescendantSourceFilesIterator(){for(let e of this._getSourceFilesIterator())yield e;for(let e of this._getDirectoriesIterator())yield*e._getDescendantSourceFilesIterator()}getDescendantDirectories(){return Array.from(this._getDescendantDirectoriesIterator())}*_getDescendantDirectoriesIterator(){for(let e of this.getDirectories())yield e,yield*e._getDescendantDirectoriesIterator()}addSourceFilesAtPaths(e){return e=typeof e==`string`?[e]:e,e=e.map(e=>t.FileUtils.pathIsAbsolute(e)?e:t.FileUtils.pathJoin(this.getPath(),e)),this._context.directoryCoordinator.addSourceFilesAtPaths(e,{markInProject:this._isInProject()})}addDirectoryAtPathIfExists(e,t={}){let n=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath());return this._context.directoryCoordinator.addDirectoryAtPathIfExists(n,{...t,markInProject:this._isInProject()})}addDirectoryAtPath(e,t={}){let n=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath());return this._context.directoryCoordinator.addDirectoryAtPath(n,{...t,markInProject:this._isInProject()})}createDirectory(e){let t=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath());return this._context.directoryCoordinator.createDirectoryOrAddIfExists(t,{markInProject:this._isInProject()})}createSourceFile(e,t,n){let r=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath());return this._context.compilerFactory.createSourceFile(r,t||``,{...n||{},markInProject:this._isInProject()})}addSourceFileAtPathIfExists(e){let t=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath());return this._context.directoryCoordinator.addSourceFileAtPathIfExists(t,{markInProject:this._isInProject()})}addSourceFileAtPath(e){let t=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath());return this._context.directoryCoordinator.addSourceFileAtPath(t,{markInProject:this._isInProject()})}async emit(e={}){let{fileSystemWrapper:t}=this._context,n=[],r=[],i=[];for(let a of this.#r(e))tm(a)?i.push(a):(n.push(t.writeFile(a.filePath,a.fileText)),r.push(a.filePath));return await Promise.all(n),new Qp(i,r)}emitSync(e={}){let{fileSystemWrapper:t}=this._context,n=[],r=[];for(let i of this.#r(e))tm(i)?r.push(i):(t.writeFileSync(i.filePath,i.fileText),n.push(i.filePath));return new Qp(r,n)}#r(e={}){let{emitOnlyDtsFiles:n=!1}=e,r=e.outDir==null?void 0:/\.js$/i,i=e.outDir==null?void 0:/\.js\.map$/i,a=e.declarationDir==null&&e.outDir==null?void 0:/\.d\.ts$/i,o=e=>e==null?void 0:this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath()),s=(e,n)=>e==null?void 0:t.FileUtils.pathJoin(e,n.getBaseName()),c=this._context.compilerOptions.get().declarationDir!=null||e.declarationDir!=null;return l(this,o(e.outDir),o(e.declarationDir));function*l(e,o,u){for(let s of e.getSourceFiles()){let e=s.getEmitOutput({emitOnlyDtsFiles:n});if(e.getEmitSkipped()){yield s.getFilePath();continue}for(let n of e.getOutputFiles()){let e=n.getFilePath(),s=n.getWriteByteOrderMark()?t.FileUtils.getTextWithByteOrderMark(n.getText()):n.getText();o!=null&&(r.test(e)||i.test(e)||!c&&a.test(e))?e=t.FileUtils.pathJoin(o,t.FileUtils.getBaseName(e)):u!=null&&a.test(e)&&(e=t.FileUtils.pathJoin(u,t.FileUtils.getBaseName(e))),yield{filePath:e,fileText:s}}}for(let t of e.getDirectories())yield*l(t,s(o,t),s(u,t))}}copyToDirectory(e,n){let r=typeof e==`string`?e:e.getPath();return this.copy(t.FileUtils.pathJoin(r,this.getBaseName()),n)}copy(e,t){let n=this.getPath(),r=this._context.fileSystemWrapper,i=this._context.fileSystemWrapper.getStandardizedAbsolutePath(e,this.getPath());return n===i?this:(t=em(t),t.includeUntrackedFiles&&r.queueCopyDirectory(n,i),this.#i(i,t))}async copyImmediately(e,t){let n=this._context.fileSystemWrapper,r=this.getPath(),i=n.getStandardizedAbsolutePath(e,r);if(r===i)return await this.save(),this;t=em(t);let a=this.#i(i,t);return t.includeUntrackedFiles&&await n.copyDirectoryImmediately(r,i),await a.save(),a}copyImmediatelySync(e,t){let n=this._context.fileSystemWrapper,r=this.getPath(),i=n.getStandardizedAbsolutePath(e,r);if(r===i)return this.saveSync(),this;t=em(t);let a=this.#i(i,t);return t.includeUntrackedFiles&&n.copyDirectoryImmediatelySync(r,i),a.saveSync(),a}#i(e,t){if(this.getPath()===e)return this;let{fileSystemWrapper:n,compilerFactory:r}=this._context,i=[this,...this.getDescendantDirectories()].map(t=>({newDirPath:t===this?e:n.getStandardizedAbsolutePath(this.getRelativePathTo(t),e)})),a=this.getDescendantSourceFiles().map(t=>({sourceFile:t,newFilePath:n.getStandardizedAbsolutePath(this.getRelativePathTo(t),e),references:this.#c(t)}));for(let{newDirPath:e}of i)this._context.compilerFactory.createDirectoryOrAddIfExists(e,{markInProject:this._isInProject()});for(let{sourceFile:e,newFilePath:n}of a)e._copyInternal(n,t);for(let{references:e,newFilePath:t}of a)this.getSourceFileOrThrow(t)._updateReferencesForCopyInternal(e);return r.getDirectoryFromCache(e)}moveToDirectory(e,n){let r=typeof e==`string`?e:e.getPath();return this.move(t.FileUtils.pathJoin(r,this.getBaseName()),n)}move(e,t){let n=this._context.fileSystemWrapper,r=this.getPath(),i=n.getStandardizedAbsolutePath(e,r);return r===i?this:this.#a(i,t,()=>n.queueMoveDirectory(r,i))}async moveImmediately(e,t){let n=this._context.fileSystemWrapper,r=this.getPath(),i=n.getStandardizedAbsolutePath(e,r);return r===i?(await this.save(),this):(this.#a(i,t),await n.moveDirectoryImmediately(r,i),await this.save(),this)}moveImmediatelySync(e,t){let n=this._context.fileSystemWrapper,r=this.getPath(),i=n.getStandardizedAbsolutePath(e,r);return r===i?(this.saveSync(),this):(this.#a(i,t),n.moveDirectoryImmediatelySync(r,i),this.saveSync(),this)}#a(e,t,n){let r=this.getPath();if(r===e)return this;let i=this._context.compilerFactory.getDirectoryFromCacheOnlyIfInCache(e),a=i!=null&&i._isInProject();n&&n();let o=this._context.fileSystemWrapper,s=this._context.compilerFactory,c=[this,...this.getDescendantDirectories()].map(t=>({directory:t,oldPath:t.getPath(),newDirPath:t===this?e:o.getStandardizedAbsolutePath(this.getRelativePathTo(t),e)})),l=this.getDescendantSourceFiles().map(t=>({sourceFile:t,newFilePath:o.getStandardizedAbsolutePath(this.getRelativePathTo(t),e),references:this.#l(t)}));for(let{directory:e,oldPath:t,newDirPath:n}of c)s.removeDirectoryFromCache(t),s.getDirectoryFromCache(n)?._forgetOnlyThis(),e._setPathInternal(n),s.addDirectoryToCache(e);for(let{sourceFile:e,newFilePath:n}of l)e._moveInternal(n,t);for(let{sourceFile:e,references:t}of l)e._updateReferencesForMoveInternal(t,r);return a&&this._markAsInProject(),this}clear(){let e=this.getPath();this.#o(),this._context.fileSystemWrapper.queueDirectoryDelete(e),this._context.fileSystemWrapper.queueMkdir(e)}async clearImmediately(){let e=this.getPath();this.#o(),await this._context.fileSystemWrapper.clearDirectoryImmediately(e)}clearImmediatelySync(){let e=this.getPath();this.#o(),this._context.fileSystemWrapper.clearDirectoryImmediatelySync(e)}delete(){let e=this.getPath();this.#o(),this._context.fileSystemWrapper.queueDirectoryDelete(e),this.forget()}#o(){for(let e of this.getSourceFiles())e.delete();for(let e of this.getDirectories())e.delete()}async deleteImmediately(){let{fileSystemWrapper:e}=this._context,t=this.getPath();this.forget(),await e.deleteDirectoryImmediately(t)}deleteImmediatelySync(){let{fileSystemWrapper:e}=this._context,t=this.getPath();this.forget(),e.deleteDirectoryImmediatelySync(t)}forget(){if(!this.wasForgotten()){for(let e of this.getSourceFiles())e.forget();for(let e of this.getDirectories())e.forget();this._forgetOnlyThis()}}_forgetOnlyThis(){this.wasForgotten()||(this._context.compilerFactory.removeDirectoryFromCache(this.getPath()),this.#e=void 0)}async save(){await this._context.fileSystemWrapper.saveForDirectory(this.getPath());let e=this.getDescendantSourceFiles().filter(e=>!e.isSaved());await Promise.all(e.map(e=>e.save()))}saveSync(){this._context.fileSystemWrapper.saveForDirectorySync(this.getPath()),this.getDescendantSourceFiles().filter(e=>!e.isSaved()).forEach(e=>e.saveSync())}getRelativePathTo(n){let r=this;return t.FileUtils.getRelativePathTo(this.getPath(),i());function i(){return n instanceof Uc?n.getFilePath():n instanceof e?n.getPath():r._context.fileSystemWrapper.getStandardizedAbsolutePath(n,r.getPath())}}getRelativePathAsModuleSpecifierTo(n){let r=this._context.program.getEmitModuleResolutionKind(),i=this,a=t.FileUtils.getRelativePathTo(this.getPath(),o()).replace(/((\.d\.ts$)|(\.[^/.]+$))/i,``);return a.startsWith(`../`)?a:`./`+a;function o(){return n instanceof Uc?a(n):n instanceof e?o(n):s(i._context.fileSystemWrapper.getStandardizedAbsolutePath(n,i.getPath()));function a(e){return s(e.getFilePath())}function o(e){switch(r){case t.ModuleResolutionKind.Node10:return e===i?t.FileUtils.pathJoin(e.getPath(),`index.ts`):e.getPath();case t.ModuleResolutionKind.Classic:case t.ModuleResolutionKind.Node16:case t.ModuleResolutionKind.NodeNext:case t.ModuleResolutionKind.Bundler:return t.FileUtils.pathJoin(e.getPath(),`index.ts`);default:return t.errors.throwNotImplementedForNeverValueError(r)}}function s(e){let n=t.FileUtils.getDirPath(e);switch(r){case t.ModuleResolutionKind.Node10:return n===i.getPath()?e:e.replace(/\/index?(\.d\.ts|\.ts|\.js)$/i,``);case t.ModuleResolutionKind.Classic:case t.ModuleResolutionKind.Node16:case t.ModuleResolutionKind.NodeNext:case t.ModuleResolutionKind.Bundler:return e;default:return t.errors.throwNotImplementedForNeverValueError(r)}}}}getProject(){return this._context.project}wasForgotten(){return this.#e==null}_isInProject(){return this._context.inProjectCoordinator.isDirectoryInProject(this)}_markAsInProject(){this._context.inProjectCoordinator.markDirectoryAsInProject(this)}_hasLoadedParent(){return this._context.compilerFactory.containsDirectoryAtPath(t.FileUtils.getDirPath(this.getPath()))}#s(){if(this.wasForgotten())throw new t.errors.InvalidOperationError(`Cannot use a directory that was deleted, removed, or overwritten.`)}#c(e){return e._getReferencesForCopyInternal().filter(e=>!this.isAncestorOf(e[1]))}#l(e){let{literalReferences:t,referencingLiterals:n}=e._getReferencesForMoveInternal();return{literalReferences:t.filter(e=>!this.isAncestorOf(e[1])),referencingLiterals:n.filter(e=>!this.isAncestorOf(e._sourceFile))}}static#u(e,t){if(t instanceof Uc&&(t=t.getDirectory(),e===t))return!0;if(e.#n.length>=t.#n.length)return!1;for(let n=e.#n.length-1;n>=0;n--)if(e.#n[n]!==t.#n[n])return!1;return!0}};function em(e){return e=t.ObjectUtils.clone(e||{}),N(e,`includeUntrackedFiles`,!0),e}function tm(e){return typeof e==`string`}var nm=class{#e;#t;constructor(e,t){this.#t=e,this.#e=t}addDirectoryAtPathIfExists(e,n){let r=this.#t.getDirectoryFromPath(e,n);if(r!=null){if(n.recursive)for(let r of t.FileUtils.getDescendantDirectories(this.#e,e))this.#t.createDirectoryOrAddIfExists(r,n);return r}}addDirectoryAtPath(e,n){let r=this.addDirectoryAtPathIfExists(e,n);if(r==null)throw new t.errors.DirectoryNotFoundError(e);return r}createDirectoryOrAddIfExists(e,t){return this.#t.createDirectoryOrAddIfExists(e,t)}addSourceFileAtPathIfExists(e,t){return this.#t.addOrGetSourceFileFromFilePath(e,{markInProject:t.markInProject,scriptKind:void 0})}addSourceFileAtPath(e,n){let r=this.addSourceFileAtPathIfExists(e,n);if(r==null)throw new t.errors.FileNotFoundError(this.#e.getStandardizedAbsolutePath(e));return r}addSourceFilesAtPaths(e,n){typeof e==`string`&&(e=[e]);let r=[],i=new Set;for(let a of this.#e.globSync(e)){let e=this.addSourceFileAtPathIfExists(a,n);e!=null&&r.push(e),i.add(t.FileUtils.getDirPath(a))}for(let e of t.FileUtils.getParentMostPaths(Array.from(i)))this.addDirectoryAtPathIfExists(e,{recursive:!0,markInProject:n.markInProject});return r}},rm=class{#e;#t=new t.KeyValueCache;#n=new t.KeyValueCache;#r=new t.KeyValueCache;#i=new t.KeyValueCache;constructor(e){this.#e=e}has(e){return this.#t.has(e)}get(e){if(!this.#t.has(e)){for(let n of this.#i.getValues())if(t.FileUtils.pathStartsWith(n.getPath(),e))return this.createOrAddIfExists(e);return}return this.#t.get(e)}getOrphans(){return this.#i.getValues()}getAll(){return this.#t.getValuesAsArray()}*getAllByDepth(){let e=new t.KeyValueCache,n=0;for(let e of this.getOrphans())r(e);for(n=Math.min(...Array.from(e.getKeys()));e.getSize()>0;){for(let t of e.get(n)||[])yield t,t.getDirectories().forEach(r);e.removeByKey(n),n++}function r(t){let r=t._getDepth();if(n>r)throw Error(`For some reason a subdirectory had a lower depth than the parent directory: ${t.getPath()}`);e.getOrCreate(r,()=>[]).push(t)}}remove(e){this.#s(e),this.#t.removeByKey(e),this.#i.removeByKey(e)}*getChildDirectoriesOfDirectory(e){let t=this.#r.get(e)?.entries();if(t!=null)for(let e of t)yield e}*getChildSourceFilesOfDirectory(e){let t=this.#n.get(e)?.entries();if(t!=null)for(let e of t)yield e}addSourceFile(e){let n=e.getDirectoryPath();this.createOrAddIfExists(n),this.#n.getOrCreate(n,()=>new t.SortedKeyValueArray(e=>e.getBaseName(),t.LocaleStringComparer.instance)).set(e)}removeSourceFile(e){let n=t.FileUtils.getDirPath(e),r=this.#n.get(n);r!=null&&(r.removeByKey(t.FileUtils.getBaseName(e)),r.hasItems()||this.#n.removeByKey(n))}createOrAddIfExists(e){return this.has(e)?this.get(e):(this.#c(e),this.#a(e))}#a(e){let t=new $p(this.#e,e);return this.addDirectory(t),t}addDirectory(e){let n=e.getPath(),r=t.FileUtils.getDirPath(n),i=r===n;for(let e of this.#i.getValues()){let r=e.getPath(),i=t.FileUtils.getDirPath(r);i!==r&&i===n&&this.#i.removeByKey(r)}i||this.#o(e),this.has(r)||this.#i.set(n,e),this.#t.set(n,e),this.#e.fileSystemWrapper.directoryExistsSync(n)||this.#e.fileSystemWrapper.queueMkdir(n);for(let t of this.#i.getValues())e.isAncestorOf(t)&&this.#c(t.getPath())}#o(e){if(t.FileUtils.isRootDirPath(e.getPath()))return;let n=t.FileUtils.getDirPath(e.getPath());this.#r.getOrCreate(n,()=>new t.SortedKeyValueArray(e=>e.getBaseName(),t.LocaleStringComparer.instance)).set(e)}#s(e){if(t.FileUtils.isRootDirPath(e))return;let n=t.FileUtils.getDirPath(e),r=this.#r.get(n);r!=null&&(r.removeByKey(t.FileUtils.getBaseName(e)),r.hasItems()||this.#r.removeByKey(n))}#c(e){let n=[],r=t.FileUtils.getDirPath(e);for(;e!==r;){if(e=r,r=t.FileUtils.getDirPath(e),this.#t.has(e)){for(let e of n)this.#a(e);break}n.unshift(e)}}},im=class extends t.KeyValueCache{#e=[];getOrCreate(e,t){return super.getOrCreate(e,()=>{let e=t();return this.#e.length>0&&this.#e[this.#e.length-1].add(e),e})}setForgetPoint(){this.#e.push(new Set)}forgetLastPoint(){let e=this.#e.pop();e!=null&&this.#n(e.values())}rememberNode(e){if(e.wasForgotten())throw new t.errors.InvalidOperationError(`Cannot remember a node that was removed or forgotten.`);let n=!1;for(let t of this.#e)if(t.delete(e)){n=!0;break}return n&&this.#t(e),n}#t(e){let t=e.getParentSyntaxList()||e.getParent();t!=null&&this.rememberNode(t)}#n(e){for(let n of e)n.wasForgotten()||n.getKind()===t.SyntaxKind.SourceFile||n._forgetOnlyThis()}},am={[t.SyntaxKind.SourceFile]:Uc,[t.SyntaxKind.ArrayBindingPattern]:Da,[t.SyntaxKind.ArrayLiteralExpression]:Ua,[t.SyntaxKind.ArrayType]:iu,[t.SyntaxKind.ArrowFunction]:el,[t.SyntaxKind.AsExpression]:Qa,[t.SyntaxKind.AwaitExpression]:eo,[t.SyntaxKind.BigIntLiteral]:Wf,[t.SyntaxKind.BindingElement]:ka,[t.SyntaxKind.BinaryExpression]:Pa,[t.SyntaxKind.Block]:hs,[t.SyntaxKind.BreakStatement]:gs,[t.SyntaxKind.CallExpression]:no,[t.SyntaxKind.CallSignature]:Qd,[t.SyntaxKind.CaseBlock]:vs,[t.SyntaxKind.CaseClause]:bs,[t.SyntaxKind.CatchClause]:Ss,[t.SyntaxKind.ClassDeclaration]:El,[t.SyntaxKind.ClassExpression]:Pl,[t.SyntaxKind.ClassStaticBlockDeclaration]:Il,[t.SyntaxKind.ConditionalType]:au,[t.SyntaxKind.Constructor]:Bl,[t.SyntaxKind.ConstructorType]:lu,[t.SyntaxKind.ConstructSignature]:tf,[t.SyntaxKind.ContinueStatement]:ws,[t.SyntaxKind.CommaListExpression]:io,[t.SyntaxKind.ComputedPropertyName]:hf,[t.SyntaxKind.ConditionalExpression]:oo,[t.SyntaxKind.DebuggerStatement]:Es,[t.SyntaxKind.Decorator]:Jl,[t.SyntaxKind.DefaultClause]:Os,[t.SyntaxKind.DeleteExpression]:co,[t.SyntaxKind.DoStatement]:js,[t.SyntaxKind.ElementAccessExpression]:uo,[t.SyntaxKind.EmptyStatement]:Ns,[t.SyntaxKind.EnumDeclaration]:Kd,[t.SyntaxKind.EnumMember]:Jd,[t.SyntaxKind.ExportAssignment]:rc,[t.SyntaxKind.ExportDeclaration]:ac,[t.SyntaxKind.ExportSpecifier]:cc,[t.SyntaxKind.ExpressionWithTypeArguments]:du,[t.SyntaxKind.ExpressionStatement]:Fs,[t.SyntaxKind.ExternalModuleReference]:uc,[t.SyntaxKind.QualifiedName]:bf,[t.SyntaxKind.ForInStatement]:Ls,[t.SyntaxKind.ForOfStatement]:zs,[t.SyntaxKind.ForStatement]:Vs,[t.SyntaxKind.FunctionDeclaration]:cl,[t.SyntaxKind.FunctionExpression]:ul,[t.SyntaxKind.FunctionType]:pu,[t.SyntaxKind.GetAccessor]:Hl,[t.SyntaxKind.HeritageClause]:Yd,[t.SyntaxKind.Identifier]:_f,[t.SyntaxKind.IfStatement]:Us,[t.SyntaxKind.ImportClause]:gc,[t.SyntaxKind.ImportDeclaration]:vc,[t.SyntaxKind.ImportEqualsDeclaration]:Sc,[t.SyntaxKind.ImportSpecifier]:wc,[t.SyntaxKind.ImportType]:mu,[t.SyntaxKind.ImportAttribute]:fc,[t.SyntaxKind.ImportAttributes]:mc,[t.SyntaxKind.IndexedAccessType]:hu,[t.SyntaxKind.IndexSignature]:rf,[t.SyntaxKind.InferType]:gu,[t.SyntaxKind.InterfaceDeclaration]:of,[t.SyntaxKind.IntersectionType]:_u,[t.SyntaxKind.JSDocAllType]:Bu,[t.SyntaxKind.JSDocAugmentsTag]:Ju,[t.SyntaxKind.JSDocAuthorTag]:Yu,[t.SyntaxKind.JSDocCallbackTag]:Xu,[t.SyntaxKind.JSDocClassTag]:Zu,[t.SyntaxKind.JSDocDeprecatedTag]:Qu,[t.SyntaxKind.JSDocEnumTag]:$u,[t.SyntaxKind.JSDocFunctionType]:td,[t.SyntaxKind.JSDocImplementsTag]:nd,[t.SyntaxKind.JSDocLink]:rd,[t.SyntaxKind.JSDocLinkCode]:id,[t.SyntaxKind.JSDocLinkPlain]:ad,[t.SyntaxKind.JSDocMemberName]:od,[t.SyntaxKind.JSDocNamepathType]:sd,[t.SyntaxKind.JSDocNameReference]:cd,[t.SyntaxKind.JSDocNonNullableType]:ld,[t.SyntaxKind.JSDocNullableType]:ud,[t.SyntaxKind.JSDocOptionalType]:dd,[t.SyntaxKind.JSDocOverrideTag]:md,[t.SyntaxKind.JSDocParameterTag]:gd,[t.SyntaxKind.JSDocPrivateTag]:_d,[t.SyntaxKind.JSDocPropertyTag]:vd,[t.SyntaxKind.JSDocProtectedTag]:yd,[t.SyntaxKind.JSDocPublicTag]:bd,[t.SyntaxKind.JSDocReturnTag]:Cd,[t.SyntaxKind.JSDocReadonlyTag]:xd,[t.SyntaxKind.JSDocThrowsTag]:Id,[t.SyntaxKind.JSDocOverloadTag]:pd,[t.SyntaxKind.JSDocSatisfiesTag]:Td,[t.SyntaxKind.JSDocSeeTag]:Dd,[t.SyntaxKind.JSDocSignature]:Od,[t.SyntaxKind.JSDocTag]:Vd,[t.SyntaxKind.JSDocTemplateTag]:jd,[t.SyntaxKind.JSDocText]:Md,[t.SyntaxKind.JSDocThisTag]:Pd,[t.SyntaxKind.JSDocTypeExpression]:Rd,[t.SyntaxKind.JSDocTypeLiteral]:zd,[t.SyntaxKind.JSDocTypeTag]:Bd,[t.SyntaxKind.JSDocTypedefTag]:Ld,[t.SyntaxKind.JSDocUnknownType]:Hd,[t.SyntaxKind.JSDocVariadicType]:Ud,[t.SyntaxKind.JsxAttribute]:Sf,[t.SyntaxKind.JsxClosingElement]:wf,[t.SyntaxKind.JsxClosingFragment]:Tf,[t.SyntaxKind.JsxElement]:Df,[t.SyntaxKind.JsxExpression]:Af,[t.SyntaxKind.JsxFragment]:jf,[t.SyntaxKind.JsxNamespacedName]:Nf,[t.SyntaxKind.JsxOpeningElement]:Ff,[t.SyntaxKind.JsxOpeningFragment]:If,[t.SyntaxKind.JsxSelfClosingElement]:Rf,[t.SyntaxKind.JsxSpreadAttribute]:Bf,[t.SyntaxKind.JsxText]:Hf,[t.SyntaxKind.LabeledStatement]:Gs,[t.SyntaxKind.LiteralType]:vu,[t.SyntaxKind.MappedType]:yu,[t.SyntaxKind.MetaProperty]:_o,[t.SyntaxKind.MethodDeclaration]:_l,[t.SyntaxKind.MethodSignature]:cf,[t.SyntaxKind.ModuleBlock]:Ec,[t.SyntaxKind.ModuleDeclaration]:kc,[t.SyntaxKind.NamedExports]:Nc,[t.SyntaxKind.NamedImports]:Fc,[t.SyntaxKind.NamedTupleMember]:xu,[t.SyntaxKind.NamespaceExport]:Lc,[t.SyntaxKind.NamespaceImport]:zc,[t.SyntaxKind.NewExpression]:yo,[t.SyntaxKind.NonNullExpression]:xo,[t.SyntaxKind.NotEmittedStatement]:qs,[t.SyntaxKind.NoSubstitutionTemplateLiteral]:op,[t.SyntaxKind.NumericLiteral]:ep,[t.SyntaxKind.ObjectBindingPattern]:Aa,[t.SyntaxKind.ObjectLiteralExpression]:Do,[t.SyntaxKind.OmittedExpression]:Fo,[t.SyntaxKind.Parameter]:fl,[t.SyntaxKind.ParenthesizedExpression]:q,[t.SyntaxKind.ParenthesizedType]:Su,[t.SyntaxKind.PartiallyEmittedExpression]:Lo,[t.SyntaxKind.PostfixUnaryExpression]:zo,[t.SyntaxKind.PrefixUnaryExpression]:Vo,[t.SyntaxKind.PrivateIdentifier]:yf,[t.SyntaxKind.PropertyAccessExpression]:Uo,[t.SyntaxKind.PropertyAssignment]:ko,[t.SyntaxKind.PropertyDeclaration]:Wl,[t.SyntaxKind.PropertySignature]:uf,[t.SyntaxKind.RegularExpressionLiteral]:np,[t.SyntaxKind.RestType]:Cu,[t.SyntaxKind.ReturnStatement]:Ys,[t.SyntaxKind.SatisfiesExpression]:Go,[t.SyntaxKind.SetAccessor]:Kl,[t.SyntaxKind.ShorthandPropertyAssignment]:jo,[t.SyntaxKind.SpreadAssignment]:No,[t.SyntaxKind.SpreadElement]:qo,[t.SyntaxKind.StringLiteral]:ip,[t.SyntaxKind.SwitchStatement]:Zs,[t.SyntaxKind.SyntaxList]:vn,[t.SyntaxKind.TaggedTemplateExpression]:sp,[t.SyntaxKind.TemplateExpression]:lp,[t.SyntaxKind.TemplateHead]:dp,[t.SyntaxKind.TemplateLiteralType]:wu,[t.SyntaxKind.TemplateMiddle]:pp,[t.SyntaxKind.TemplateSpan]:hp,[t.SyntaxKind.TemplateTail]:_p,[t.SyntaxKind.ThisType]:Tu,[t.SyntaxKind.ThrowStatement]:$s,[t.SyntaxKind.TryStatement]:tc,[t.SyntaxKind.TupleType]:Eu,[t.SyntaxKind.TypeAliasDeclaration]:Ou,[t.SyntaxKind.TypeAssertionExpression]:rs,[t.SyntaxKind.TypeLiteral]:Au,[t.SyntaxKind.TypeOperator]:ju,[t.SyntaxKind.TypeParameter]:Nu,[t.SyntaxKind.TypePredicate]:Fu,[t.SyntaxKind.TypeQuery]:Iu,[t.SyntaxKind.TypeReference]:Lu,[t.SyntaxKind.UnionType]:Ru,[t.SyntaxKind.VariableDeclaration]:yp,[t.SyntaxKind.VariableDeclarationList]:xp,[t.SyntaxKind.VariableStatement]:qc,[t.SyntaxKind.JSDoc]:eu,[t.SyntaxKind.TypeOfExpression]:as,[t.SyntaxKind.WhileStatement]:Yc,[t.SyntaxKind.WithStatement]:Zc,[t.SyntaxKind.YieldExpression]:ls,[t.SyntaxKind.SemicolonToken]:H,[t.SyntaxKind.AnyKeyword]:Ma,[t.SyntaxKind.BooleanKeyword]:Ma,[t.SyntaxKind.FalseKeyword]:Jf,[t.SyntaxKind.ImportKeyword]:po,[t.SyntaxKind.InferKeyword]:H,[t.SyntaxKind.NeverKeyword]:H,[t.SyntaxKind.NullKeyword]:Qf,[t.SyntaxKind.NumberKeyword]:Ma,[t.SyntaxKind.ObjectKeyword]:Ma,[t.SyntaxKind.StringKeyword]:Ma,[t.SyntaxKind.SymbolKeyword]:Ma,[t.SyntaxKind.SuperKeyword]:Zo,[t.SyntaxKind.ThisKeyword]:ts,[t.SyntaxKind.TrueKeyword]:Kf,[t.SyntaxKind.UndefinedKeyword]:Ma,[t.SyntaxKind.VoidExpression]:ss},om=class{#e;#t=new Map;#n=new t.WeakCache;#r=new t.WeakCache;#i=new t.WeakCache;#a=new t.WeakCache;#o=new t.WeakCache;#s=new t.WeakCache;#c=new t.WeakCache;#l=new t.WeakCache;#u=new t.WeakCache;#d=new t.WeakCache;#f=new t.WeakCache;#p=new t.WeakCache;#m=new t.WeakCache;#h=new im;#g;#_=new t.EventContainer;#v=new t.EventContainer;documentRegistry;constructor(e){this.documentRegistry=new t.DocumentRegistry(e.fileSystemWrapper),this.#g=new rm(e),e.compilerOptions.onModified(()=>{let e=Array.from(this.#t.values());for(let t of e)rn(t)}),this.#e=e}*getSourceFilesByDirectoryDepth(){for(let e of this.getDirectoriesByDepth())yield*e.getSourceFiles()}getSourceFilePaths(){return this.#t.keys()}getChildDirectoriesOfDirectory(e){return this.#g.getChildDirectoriesOfDirectory(e)}getChildSourceFilesOfDirectory(e){return this.#g.getChildSourceFilesOfDirectory(e)}onSourceFileAdded(e,t=!0){t?this.#_.subscribe(e):this.#_.unsubscribe(e)}onSourceFileRemoved(e){this.#v.subscribe(e)}createSourceFile(e,n,r){if(n=n instanceof Function?I(this.#e.createWriter(),n):n||``,typeof n==`string`)return this.createSourceFileFromText(e,n,r);let i=this.#e.createWriter();return this.#e.structurePrinterFactory.forSourceFile({isAmbient:t.FileUtils.getExtension(e)===`.d.ts`}).printText(i,n),this.createSourceFileFromText(e,i.toString(),r)}createSourceFileFromText(e,t,n){return e=this.#e.fileSystemWrapper.getStandardizedAbsolutePath(e),n.overwrite===!0?this.#y(e,t,n):(this.throwIfFileExists(e,`Did you mean to provide the overwrite option?`),this.#b(e,t,n))}throwIfFileExists(e,n){if(!(!this.containsSourceFileAtPath(e)&&!this.#e.fileSystemWrapper.fileExistsSync(e)))throw n=n==null?``:n+` `,new t.errors.InvalidOperationError(`${n}A source file already exists at the provided file path: ${e}`)}#y(e,t,n){e=this.#e.fileSystemWrapper.getStandardizedAbsolutePath(e);let r=this.addOrGetSourceFileFromFilePath(e,n);return r==null?this.#b(e,t,n):(r.getChildren().forEach(e=>e.forget()),this.replaceCompilerNode(r,this.createCompilerSourceFileFromText(e,t,n.scriptKind)),r)}getSourceFileFromCacheFromFilePath(e){return e=this.#e.fileSystemWrapper.getStandardizedAbsolutePath(e),this.#t.get(e)}addOrGetSourceFileFromFilePath(e,t){e=this.#e.fileSystemWrapper.getStandardizedAbsolutePath(e);let n=this.#t.get(e);if(n==null){let r=this.#e.fileSystemWrapper.readFileIfExistsSync(e,this.#e.getEncoding());r!=null&&(this.#e.logger.log(`Loaded file: ${e}`),n=this.#b(e,r,t),n._setIsSaved(!0))}return n!=null&&t.markInProject&&n._markAsInProject(),n}containsSourceFileAtPath(e){return e=this.#e.fileSystemWrapper.getStandardizedAbsolutePath(e),this.#t.has(e)}containsDirectoryAtPath(e){return e=this.#e.fileSystemWrapper.getStandardizedAbsolutePath(e),this.#g.has(e)}getSourceFileForNode(e){let n=e;for(;n.kind!==t.SyntaxKind.SourceFile;){if(n.parent==null)return;n=n.parent}return this.getSourceFile(n,{markInProject:!1})}hasCompilerNode(e){return this.#h.has(e)}getExistingNodeFromCompilerNode(e){return this.#h.get(e)}getNodeFromCompilerNode(e,n){if(e.kind===t.SyntaxKind.SourceFile)return this.getSourceFile(e,{markInProject:!1});return this.#h.getOrCreate(e,()=>{let e=r.call(this);return a.call(this,e),e});function r(){return i(e)?y.isCommentStatement(e)?new Cs(this.#e,e,n):y.isCommentClassElement(e)?new Ll(this.#e,e,n):y.isCommentTypeElement(e)?new $d(this.#e,e,n):y.isCommentObjectLiteralElement(e)?new Co(this.#e,e,n):y.isCommentEnumMember(e)?new Wd(this.#e,e,n):t.errors.throwNotImplementedForNeverValueError(e):new(am[e.kind]||H)(this.#e,e,n)}function i(e){return e._commentKind!=null}function a(r){if(e.parent!=null){let t=this.getNodeFromCompilerNode(e.parent,n);t._wrappedChildCount++}let i=r._getParentSyntaxListIfWrapped();if(i!=null&&i._wrappedChildCount++,e.kind===t.SyntaxKind.SyntaxList){let e=0;for(let t of r._getChildrenInCacheIterator())e++;r._wrappedChildCount=e}}}#b(e,n,r){let i=t.StringUtils.hasBom(n);i&&(n=t.StringUtils.stripBom(n));let a=this.getSourceFile(this.createCompilerSourceFileFromText(e,n,r.scriptKind),r);return i&&(a._hasBom=!0),a}createCompilerSourceFileFromText(e,n,r){return this.documentRegistry.createOrUpdateSourceFile(e,this.#e.compilerOptions.get(),t.ts.ScriptSnapshot.fromString(n),r)}getSourceFile(e,t){let n=!1,r=this.#t.get(e.fileName)??this.#h.getOrCreate(e,()=>{let r=new Uc(this.#e,e);return t.markInProject||this.#e.inProjectCoordinator.setSourceFileNotInProject(r),this.#x(r),n=!0,r});return t.markInProject&&r._markAsInProject(),n&&this.#_.fire(r),r}#x(e){this.#t.set(e.getFilePath(),e),this.#e.fileSystemWrapper.removeFileDelete(e.getFilePath()),this.#g.addSourceFile(e)}getDirectoryFromPath(e,t){e=this.#e.fileSystemWrapper.getStandardizedAbsolutePath(e);let n=this.#g.get(e);return n==null&&this.#e.fileSystemWrapper.directoryExistsSync(e)&&(n=this.#g.createOrAddIfExists(e)),n!=null&&t.markInProject&&n._markAsInProject(),n}createDirectoryOrAddIfExists(e,t){let n=this.#g.createOrAddIfExists(e);return n!=null&&t.markInProject&&n._markAsInProject(),n}getDirectoryFromCache(e){return this.#g.get(e)}getDirectoryFromCacheOnlyIfInCache(e){return this.#g.has(e)?this.#g.get(e):void 0}getDirectoriesByDepth(){return this.#g.getAllByDepth()}getOrphanDirectories(){return this.#g.getOrphans()}getSymbolDisplayPart(e){return this.#l.getOrCreate(e,()=>new Kp(e))}getType(e){return(e.flags&t.TypeFlags.TypeParameter)===t.TypeFlags.TypeParameter?this.getTypeParameter(e):this.#p.getOrCreate(e,()=>new Xp(this.#e,e))}getTypeParameter(e){return this.#m.getOrCreate(e,()=>new Zp(this.#e,e))}getSignature(e){return this.#s.getOrCreate(e,()=>new Sp(this.#e,e))}getSymbol(e){return this.#c.getOrCreate(e,()=>new Cp(this.#e,e))}getDefinitionInfo(e){return this.#r.getOrCreate(e,()=>new jp(this.#e,e))}getDocumentSpan(e){return this.#i.getOrCreate(e,()=>new Ap(this.#e,e))}getReferencedSymbolEntry(e){return this.#u.getOrCreate(e,()=>new Wp(this.#e,e))}getReferencedSymbol(e){return this.#d.getOrCreate(e,()=>new Vp(this.#e,e))}getReferencedSymbolDefinitionInfo(e){return this.#f.getOrCreate(e,()=>new Hp(this.#e,e))}getDiagnostic(e){return this.#n.getOrCreate(e,()=>e.start==null?new Np(this.#e,e):new Pp(this.#e,e))}getDiagnosticWithLocation(e){return this.#n.getOrCreate(e,()=>new Pp(this.#e,e))}getDiagnosticMessageChain(e){return this.#a.getOrCreate(e,()=>new Mp(e))}getJSDocTagInfo(e){return this.#o.getOrCreate(e,()=>new kd(e))}replaceCompilerNode(e,n){let r=e instanceof H?e.compilerNode:e,i=e instanceof H?e:this.#h.get(e);if(r.kind===t.SyntaxKind.SourceFile&&r.fileName!==n.fileName){let e=i;this.#S(r),e._replaceCompilerNodeFromFactory(n),this.#h.set(n,e),this.#x(e),this.#_.fire(e)}else this.#h.replaceKey(r,n),i?._replaceCompilerNodeFromFactory(n)}removeNodeFromCache(e){this.#S(e.compilerNode)}#S(e){if(this.#h.removeByKey(e),e.kind===t.SyntaxKind.SourceFile){let t=e,n=this.#e.fileSystemWrapper.getStandardizedAbsolutePath(t.fileName);this.#g.removeSourceFile(n);let r=this.#t.get(n);this.#t.delete(n),this.documentRegistry.removeSourceFile(n),r!=null&&this.#v.fire(r)}}addDirectoryToCache(e){this.#g.addDirectory(e)}removeDirectoryFromCache(e){this.#g.remove(e)}forgetNodesCreatedInBlock(e){this.#h.setForgetPoint();let t=!1,n;try{if(n=e((...e)=>{for(let t of e)this.#h.rememberNode(t)}),H.isNode(n)&&this.#h.rememberNode(n),r(n))return t=!0,n.then(e=>(H.isNode(e)&&this.#h.rememberNode(e),this.#h.forgetLastPoint(),e))}finally{t||this.#h.forgetLastPoint()}return n;function r(e){return e!=null&&typeof e.then==`function`}}},sm=class{#e;#t=new Set;constructor(e){e.onSourceFileRemoved(e=>{this.#t.delete(e)}),this.#e=e}setSourceFileNotInProject(e){this.#t.add(e),e._inProject=!1}markSourceFileAsInProject(e){this.isSourceFileInProject(e)||(this.#n(e),this.#t.delete(e))}markSourceFilesAsInProjectForResolution(){let e=this.#e,n=[],r=[];for(let e of[...this.#t.values()])i(e)?(this.#n(e),this.#t.delete(e),n.push(e)):r.push(e);return{changedSourceFiles:n,unchangedSourceFiles:r};function i(n){let r=n.getFilePath(),i=r.toLowerCase().lastIndexOf(`/node_modules/`);if(i===-1)return!0;let a=r.substring(0,i+14-1),o=e.getDirectoryFromCacheOnlyIfInCache(a);if(o!=null&&o._isInProject())return!0;let s=n.getDirectory();for(;s!=null&&s.getPath()!==a;){if(s._isInProject())return!0;s=e.getDirectoryFromCacheOnlyIfInCache(t.FileUtils.getDirPath(s.getPath()))}return!1}}#n(e){e._inProject=!0,this.markDirectoryAsInProject(e.getDirectory())}isSourceFileInProject(e){return e._inProject===!0}setDirectoryAndFilesAsNotInProjectForTesting(e){for(let t of e.getDirectories())this.setDirectoryAndFilesAsNotInProjectForTesting(t);for(let t of e.getSourceFiles())delete t._inProject,this.#t.add(t);delete e._inProject}markDirectoryAsInProject(e){if(this.isDirectoryInProject(e))return;let n=this,r=this.#e;e._inProject=!0,i(e);function i(e){let t=Array.from(a(e)),r=t[t.length-1];if(!(r==null||!n.isDirectoryInProject(r)))for(let e of t)e._inProject=!0}function*a(e){if(t.FileUtils.isRootDirPath(e.getPath()))return;let i=t.FileUtils.getDirPath(e.getPath()),o=r.getDirectoryFromCacheOnlyIfInCache(i);o!=null&&(yield o,n.isDirectoryInProject(o)||(yield*a(o)))}}isDirectoryInProject(e){return e._inProject===!0}},cm=class{_getFormatCodeSettings;constructor(e){this._getFormatCodeSettings=e}getFormatCodeSettings(){return this._getFormatCodeSettings()}forInitializerExpressionableNode(){return new Fn}forModifierableNode(){return new In}forReturnTypedNode(e){return new Ln(e)}forTypedNode(e,t){return new Rn(e,t)}forClassDeclaration(e){return new qn(this,e)}forClassMember(e){return new Vr(this,e)}forClassStaticBlockDeclaration(){return new Hr(this)}forConstructorDeclaration(e){return new Ur(this,e)}forGetAccessorDeclaration(e){return new Wr(this,e)}forMethodDeclaration(e){return new Gr(this,e)}forPropertyDeclaration(){return new Kr(this)}forSetAccessorDeclaration(e){return new qr(this,e)}forDecorator(){return new Yr(this)}forJSDoc(){return new Xr(this)}forJSDocTag(e){return new Zr(this,e)}forEnumDeclaration(){return new Qr(this)}forEnumMember(){return new $r(this)}forObjectLiteralExpressionProperty(){return new ei(this)}forPropertyAssignment(){return new ti(this)}forShorthandPropertyAssignment(){return new ni(this)}forSpreadAssignment(){return new ri(this)}forFunctionDeclaration(e){return new ii(this,e)}forParameterDeclaration(){return new ai(this)}forCallSignatureDeclaration(){return new oi(this)}forConstructSignatureDeclaration(){return new si(this)}forIndexSignatureDeclaration(){return new ci(this)}forInterfaceDeclaration(){return new li(this)}forMethodSignature(){return new ui(this)}forPropertySignature(){return new di(this)}forTypeElementMemberedNode(){return new fi(this)}forTypeElementMember(){return new pi(this)}forJsxAttributeDecider(){return new mi(this)}forJsxAttribute(){return new hi(this)}forJsxChildDecider(){return new gi(this)}forJsxElement(){return new _i(this)}forJsxNamespacedName(){return new vi(this)}forJsxSelfClosingElement(){return new yi(this)}forJsxSpreadAttribute(){return new bi(this)}forExportAssignment(){return new xi(this)}forExportDeclaration(){return new Si(this)}forImportAttribute(){return new Ci(this)}forImportDeclaration(){return new wi(this)}forModuleDeclaration(e){return new Ti(this,e)}forNamedImportExportSpecifier(){return new Ei(this)}forSourceFile(e){return new Di(this,e)}forStatementedNode(e){return new Oi(this,e)}forStatement(e){return new ki(this,e)}forVariableStatement(){return new Ai(this)}forTypeAliasDeclaration(){return new ji(this)}forTypeParameterDeclaration(){return new Mi(this)}forVariableDeclaration(){return new Ni(this)}};Vc([t.Memoize],cm.prototype,`forInitializerExpressionableNode`,null),Vc([t.Memoize],cm.prototype,`forModifierableNode`,null),Vc([t.Memoize],cm.prototype,`forReturnTypedNode`,null),Vc([t.Memoize],cm.prototype,`forTypedNode`,null),Vc([t.Memoize],cm.prototype,`forClassDeclaration`,null),Vc([t.Memoize],cm.prototype,`forClassMember`,null),Vc([t.Memoize],cm.prototype,`forClassStaticBlockDeclaration`,null),Vc([t.Memoize],cm.prototype,`forConstructorDeclaration`,null),Vc([t.Memoize],cm.prototype,`forGetAccessorDeclaration`,null),Vc([t.Memoize],cm.prototype,`forMethodDeclaration`,null),Vc([t.Memoize],cm.prototype,`forPropertyDeclaration`,null),Vc([t.Memoize],cm.prototype,`forSetAccessorDeclaration`,null),Vc([t.Memoize],cm.prototype,`forDecorator`,null),Vc([t.Memoize],cm.prototype,`forJSDoc`,null),Vc([t.Memoize],cm.prototype,`forJSDocTag`,null),Vc([t.Memoize],cm.prototype,`forEnumDeclaration`,null),Vc([t.Memoize],cm.prototype,`forEnumMember`,null),Vc([t.Memoize],cm.prototype,`forObjectLiteralExpressionProperty`,null),Vc([t.Memoize],cm.prototype,`forPropertyAssignment`,null),Vc([t.Memoize],cm.prototype,`forShorthandPropertyAssignment`,null),Vc([t.Memoize],cm.prototype,`forSpreadAssignment`,null),Vc([t.Memoize],cm.prototype,`forFunctionDeclaration`,null),Vc([t.Memoize],cm.prototype,`forParameterDeclaration`,null),Vc([t.Memoize],cm.prototype,`forCallSignatureDeclaration`,null),Vc([t.Memoize],cm.prototype,`forConstructSignatureDeclaration`,null),Vc([t.Memoize],cm.prototype,`forIndexSignatureDeclaration`,null),Vc([t.Memoize],cm.prototype,`forInterfaceDeclaration`,null),Vc([t.Memoize],cm.prototype,`forMethodSignature`,null),Vc([t.Memoize],cm.prototype,`forPropertySignature`,null),Vc([t.Memoize],cm.prototype,`forTypeElementMemberedNode`,null),Vc([t.Memoize],cm.prototype,`forTypeElementMember`,null),Vc([t.Memoize],cm.prototype,`forJsxAttributeDecider`,null),Vc([t.Memoize],cm.prototype,`forJsxAttribute`,null),Vc([t.Memoize],cm.prototype,`forJsxChildDecider`,null),Vc([t.Memoize],cm.prototype,`forJsxElement`,null),Vc([t.Memoize],cm.prototype,`forJsxNamespacedName`,null),Vc([t.Memoize],cm.prototype,`forJsxSelfClosingElement`,null),Vc([t.Memoize],cm.prototype,`forJsxSpreadAttribute`,null),Vc([t.Memoize],cm.prototype,`forExportAssignment`,null),Vc([t.Memoize],cm.prototype,`forExportDeclaration`,null),Vc([t.Memoize],cm.prototype,`forImportAttribute`,null),Vc([t.Memoize],cm.prototype,`forImportDeclaration`,null),Vc([t.Memoize],cm.prototype,`forModuleDeclaration`,null),Vc([t.Memoize],cm.prototype,`forNamedImportExportSpecifier`,null),Vc([t.Memoize],cm.prototype,`forSourceFile`,null),Vc([t.Memoize],cm.prototype,`forStatementedNode`,null),Vc([t.Memoize],cm.prototype,`forStatement`,null),Vc([t.Memoize],cm.prototype,`forVariableStatement`,null),Vc([t.Memoize],cm.prototype,`forTypeAliasDeclaration`,null),Vc([t.Memoize],cm.prototype,`forTypeParameterDeclaration`,null),Vc([t.Memoize],cm.prototype,`forVariableDeclaration`,null);var lm=class{#e;#t;#n;#r;get project(){if(this.#r==null)throw new t.errors.InvalidOperationError(`This operation is not permitted in this context.`);return this.#r}logger=new ae;lazyReferenceCoordinator;directoryCoordinator;fileSystemWrapper;manipulationSettings=new M;structurePrinterFactory;compilerFactory;inProjectCoordinator;constructor(e){this.#r=e.project,this.fileSystemWrapper=e.fileSystemWrapper,this.#t=e.compilerOptionsContainer,this.compilerFactory=new om(this),this.inProjectCoordinator=new sm(this.compilerFactory),this.structurePrinterFactory=new cm(()=>this.manipulationSettings.getFormatCodeSettings()),this.lazyReferenceCoordinator=new ue(this.compilerFactory),this.directoryCoordinator=new nm(this.compilerFactory,e.fileSystemWrapper),this.#e=e.createLanguageService?new Yp({context:this,configFileParsingDiagnostics:e.configFileParsingDiagnostics,resolutionHost:e.resolutionHost&&e.resolutionHost(this.getModuleResolutionHost(),()=>this.compilerOptions.get()),skipLoadingLibFiles:e.skipLoadingLibFiles,libFolderPath:e.libFolderPath}):void 0,e.typeChecker!=null&&(t.errors.throwIfTrue(e.createLanguageService,`Cannot specify a type checker and create a language service.`),this.#n=new qp(this),this.#n._reset(()=>e.typeChecker))}get compilerOptions(){return this.#t}get languageService(){if(this.#e==null)throw this.#i(`language service`);return this.#e}get program(){if(this.#e==null)throw this.#i(`program`);return this.languageService.getProgram()}get typeChecker(){if(this.#n!=null)return this.#n;if(this.#e==null)throw this.#i(`type checker`);return this.program.getTypeChecker()}hasLanguageService(){return this.#e!=null}getEncoding(){return this.compilerOptions.getEncoding()}getFormatCodeSettings(){return this.manipulationSettings.getFormatCodeSettings()}getUserPreferences(){return this.manipulationSettings.getUserPreferences()}resetProgram(){this.languageService._reset()}createWriter(){let t=this.manipulationSettings.getIndentationText();return new i.default({newLine:this.manipulationSettings.getNewLineKindAsString(),indentNumberOfSpaces:t===e.IndentationText.Tab?void 0:t.length,useTabs:t===e.IndentationText.Tab,useSingleQuote:this.manipulationSettings.getQuoteKind()===e.QuoteKind.Single})}getPreEmitDiagnostics(e){return t.ts.getPreEmitDiagnostics(this.program.compilerObject,e?.compilerNode).map(e=>this.compilerFactory.getDiagnostic(e))}getSourceFileContainer(){return{addOrGetSourceFileFromFilePath:(e,t)=>Promise.resolve(this.compilerFactory.addOrGetSourceFileFromFilePath(e,t)?.compilerNode),addOrGetSourceFileFromFilePathSync:(e,t)=>this.compilerFactory.addOrGetSourceFileFromFilePath(e,t)?.compilerNode,containsDirectoryAtPath:e=>this.compilerFactory.containsDirectoryAtPath(e),containsSourceFileAtPath:e=>this.compilerFactory.containsSourceFileAtPath(e),getSourceFileFromCacheFromFilePath:e=>this.compilerFactory.getSourceFileFromCacheFromFilePath(e)?.compilerNode,getSourceFilePaths:()=>this.compilerFactory.getSourceFilePaths(),getSourceFileVersion:e=>this.compilerFactory.documentRegistry.getSourceFileVersion(e),getChildDirectoriesOfDirectory:e=>{let t=[];for(let n of this.compilerFactory.getChildDirectoriesOfDirectory(e))t.push(n.getPath());return t}}}getModuleResolutionHost(){return t.createModuleResolutionHost({transactionalFileSystem:this.fileSystemWrapper,getEncoding:()=>this.getEncoding(),sourceFileContainer:this.getSourceFileContainer()})}#i(e){return new t.errors.InvalidOperationError(`A ${e} is required for this operation. This might occur when manipulating or getting type information from a node that was not added to a Project object and created via createWrappedNode. Please submit a bug report if you don't believe a ${e} should be required for this operation.`)}};Vc([t.Memoize],lm.prototype,`getSourceFileContainer`,null),Vc([t.Memoize],lm.prototype,`getModuleResolutionHost`,null);var um=class{_context;constructor(e={}){s();let n=c(),r=new t.TransactionalFileSystem({fileSystem:n,skipLoadingLibFiles:e.skipLoadingLibFiles,libFolderPath:e.libFolderPath}),i=e.tsConfigFilePath==null?void 0:new t.TsConfigResolver(r,r.getStandardizedAbsolutePath(e.tsConfigFilePath),d()),a=l(),o=new t.CompilerOptionsContainer(e.defaultCompilerOptions);o.set(a),this._context=new lm({project:this,compilerOptionsContainer:o,fileSystemWrapper:r,createLanguageService:!0,resolutionHost:e.resolutionHost,configFileParsingDiagnostics:i?.getErrors()??[],skipLoadingLibFiles:e.skipLoadingLibFiles,libFolderPath:e.libFolderPath}),e.manipulationSettings!=null&&this._context.manipulationSettings.set(e.manipulationSettings),i!=null&&e.skipAddingFilesFromTsConfig!==!0&&(this.#e(i,a),e.skipFileDependencyResolution||this.resolveSourceFileDependencies());function s(){if(e.fileSystem!=null&&e.useInMemoryFileSystem)throw new t.errors.InvalidOperationError(`Cannot provide a file system when specifying to use an in-memory file system.`)}function c(){return e.useInMemoryFileSystem?new t.InMemoryFileSystemHost:e.fileSystem??new t.RealFileSystemHost}function l(){return{...u(),...e.compilerOptions??{}}}function u(){return i?.getCompilerOptions()??{}}function d(){let t=`utf-8`;return e.compilerOptions==null?t:e.compilerOptions.charset??t}}get manipulationSettings(){return this._context.manipulationSettings}get compilerOptions(){return this._context.compilerOptions}resolveSourceFileDependencies(){let e=new Set,t=t=>e.add(t),{compilerFactory:n,inProjectCoordinator:r}=this._context;n.onSourceFileAdded(t);try{this.getProgram().compilerObject}finally{n.onSourceFileAdded(t,!1)}let i=r.markSourceFilesAsInProjectForResolution();for(let t of i.changedSourceFiles)e.add(t);for(let t of i.unchangedSourceFiles)e.delete(t);return Array.from(e.values())}addDirectoryAtPathIfExists(e,t={}){return this._context.directoryCoordinator.addDirectoryAtPathIfExists(this._context.fileSystemWrapper.getStandardizedAbsolutePath(e),{...t,markInProject:!0})}addDirectoryAtPath(e,t={}){return this._context.directoryCoordinator.addDirectoryAtPath(this._context.fileSystemWrapper.getStandardizedAbsolutePath(e),{...t,markInProject:!0})}createDirectory(e){return this._context.directoryCoordinator.createDirectoryOrAddIfExists(this._context.fileSystemWrapper.getStandardizedAbsolutePath(e),{markInProject:!0})}getDirectoryOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getDirectory(e),n??(()=>`Could not find a directory at the specified path: ${this._context.fileSystemWrapper.getStandardizedAbsolutePath(e)}`))}getDirectory(e){let{compilerFactory:t}=this._context;return t.getDirectoryFromCache(this._context.fileSystemWrapper.getStandardizedAbsolutePath(e))}getDirectories(){return Array.from(this.#n())}getRootDirectories(){let{inProjectCoordinator:e}=this._context,t=[];for(let e of this._context.compilerFactory.getOrphanDirectories())for(let r of n(e))t.push(r);return t;function*n(t){if(e.isDirectoryInProject(t)){yield t;return}for(let e of t._getDirectoriesIterator())yield*n(e)}}addSourceFilesAtPaths(e){return this._context.directoryCoordinator.addSourceFilesAtPaths(e,{markInProject:!0})}addSourceFileAtPathIfExists(e){return this._context.directoryCoordinator.addSourceFileAtPathIfExists(this._context.fileSystemWrapper.getStandardizedAbsolutePath(e),{markInProject:!0})}addSourceFileAtPath(e){return this._context.directoryCoordinator.addSourceFileAtPath(this._context.fileSystemWrapper.getStandardizedAbsolutePath(e),{markInProject:!0})}addSourceFilesFromTsConfig(e){let n=new t.TsConfigResolver(this._context.fileSystemWrapper,this._context.fileSystemWrapper.getStandardizedAbsolutePath(e),this._context.getEncoding());return this.#e(n,n.getCompilerOptions())}#e(e,t){let n=e.getPaths(t),r=n.filePaths.map(e=>this.addSourceFileAtPath(e));for(let e of n.directoryPaths)this.addDirectoryAtPathIfExists(e);return r}createSourceFile(e,t,n){return this._context.compilerFactory.createSourceFile(this._context.fileSystemWrapper.getStandardizedAbsolutePath(e),t??``,{...n??{},markInProject:!0})}removeSourceFile(e){let t=e.wasForgotten();return e.forget(),!t}getSourceFileOrThrow(e){let n=this.getSourceFile(e);if(n!=null)return n;if(typeof e==`string`){let n=t.FileUtils.standardizeSlashes(e);if(t.FileUtils.pathIsAbsolute(n)||n.indexOf(`/`)>=0){let e=this._context.fileSystemWrapper.getStandardizedAbsolutePath(n);throw new t.errors.InvalidOperationError(`Could not find source file in project at the provided path: ${e}`)}else throw new t.errors.InvalidOperationError(`Could not find source file in project with the provided file name: ${e}`)}else throw new t.errors.InvalidOperationError(`Could not find source file in project based on the provided condition.`)}getSourceFile(e){let n=r(this._context.fileSystemWrapper);if(i(n))return this._context.compilerFactory.getSourceFileFromCacheFromFilePath(n);return t.IterableUtils.find(this.#t(),n);function r(n){if(e instanceof Function)return e;let r=t.FileUtils.standardizeSlashes(e);return t.FileUtils.pathIsAbsolute(r)||r.indexOf(`/`)>=0?n.getStandardizedAbsolutePath(r):e=>t.FileUtils.pathEndsWith(e.getFilePath(),r)}function i(e){return typeof e==`string`}}getSourceFiles(e){let{compilerFactory:n,fileSystemWrapper:r}=this._context,i=this.#t();if(typeof e==`string`||e instanceof Array)return Array.from(a());return Array.from(i);function*a(){let a=Array.from(s()),o=t.matchGlobs(a,e,r.getCurrentDirectory());for(let e of o)yield n.getSourceFileFromCacheFromFilePath(r.getStandardizedAbsolutePath(e));function*s(){for(let e of i)yield e.getFilePath()}}}*#t(){let{compilerFactory:e,inProjectCoordinator:t}=this._context;for(let n of e.getSourceFilesByDirectoryDepth())t.isSourceFileInProject(n)&&(yield n)}*#n(){let{compilerFactory:e,inProjectCoordinator:t}=this._context;for(let n of e.getDirectoriesByDepth())t.isDirectoryInProject(n)&&(yield n)}getAmbientModule(e){return e=dm(e),this.getAmbientModules().find(t=>t.getName()===e)}getAmbientModuleOrThrow(e,n){return t.errors.throwIfNullOrUndefined(this.getAmbientModule(e),n??(()=>`Could not find ambient module with name: ${dm(e)}`))}getAmbientModules(){return this.getTypeChecker().getAmbientModules()}async save(){await this._context.fileSystemWrapper.flush(),await Promise.all(this.#r().map(e=>e.save()))}saveSync(){this._context.fileSystemWrapper.flushSync();for(let e of this.#r())e.saveSync()}enableLogging(e=!0){this._context.logger.setEnabled(e)}#r(){return Array.from(e(this._context.compilerFactory.getSourceFilesByDirectoryDepth()));function*e(e){for(let t of e)t.isSaved()||(yield t)}}getPreEmitDiagnostics(){return this._context.getPreEmitDiagnostics()}getLanguageService(){return this._context.languageService}getProgram(){return this._context.program}getTypeChecker(){return this._context.typeChecker}getFileSystem(){return this._context.fileSystemWrapper.getFileSystem()}emit(e={}){return this._context.program.emit(e)}emitSync(e={}){return this._context.program.emitSync(e)}emitToMemory(e={}){return this._context.program.emitToMemory(e)}getCompilerOptions(){return this._context.compilerOptions.get()}getConfigFileParsingDiagnostics(){return this.getProgram().getConfigFileParsingDiagnostics()}createWriter(){return this._context.createWriter()}forgetNodesCreatedInBlock(e){return this._context.compilerFactory.forgetNodesCreatedInBlock(e)}formatDiagnosticsWithColorAndContext(e,n={}){return t.ts.formatDiagnosticsWithColorAndContext(e.map(e=>e.compilerObject),{getCurrentDirectory:()=>this._context.fileSystemWrapper.getCurrentDirectory(),getCanonicalFileName:e=>e,getNewLine:()=>n.newLineChar??t.runtime.getEndOfLine()})}getModuleResolutionHost(){return this._context.getModuleResolutionHost()}};function dm(e){return t(e[0])&&t(e[e.length-1])&&(e=e.substring(1,e.length-1)),`"${e}"`;function t(e){return e===`"`||e===`'`}}function fm(e,n={}){let{compilerOptions:r={},sourceFile:i,typeChecker:a}=n,o=new t.CompilerOptionsContainer;o.set(r);let s=new lm({project:void 0,fileSystemWrapper:new t.TransactionalFileSystem({fileSystem:new t.RealFileSystemHost,skipLoadingLibFiles:!0,libFolderPath:void 0}),compilerOptionsContainer:o,createLanguageService:!1,typeChecker:a,configFileParsingDiagnostics:[],skipLoadingLibFiles:!0,libFolderPath:void 0}),c=s.compilerFactory.getSourceFile(l(),{markInProject:!0});return s.compilerFactory.getNodeFromCompilerNode(e,c);function l(){return i??u(e)}function u(e){if(e.kind===t.SyntaxKind.SourceFile)return e;if(e.parent==null)throw new t.errors.InvalidOperationError(`Please ensure the node was created from a source file with 'setParentNodes' set to 'true'.`);let n=e;for(;n.parent!=null;)n=n.parent;if(n.kind!==t.SyntaxKind.SourceFile)throw new t.errors.NotImplementedError(`For some reason the top parent was not a source file.`);return n}}var pm=new cm(()=>{throw new t.errors.NotImplementedError(`Not implemented scenario for getting code format settings when using a writer function. Please open an issue.`)}),mm=class{constructor(){}static object(e){return t=>{let n=Object.keys(e);t.write(`{`),n.length>0&&t.indent(()=>{r()}),t.write(`}`);function r(){for(let r=0;r<n.length;r++){r>0&&t.write(`,`).newLine();let i=n[r],a=e[i];t.write(i),a!=null&&(t.write(`: `),vm(t,a))}t.newLine()}}}static objectType(e){return t=>{t.write(`{`),gm(e)&&t.indent(()=>{pm.forTypeElementMemberedNode().printText(t,e)}),t.write(`}`)}}static unionType(e,t,...n){return hm(`|`,[e,t,...n])}static intersectionType(e,t,...n){return hm(`&`,[e,t,...n])}static assertion(e,t){return n=>{vm(n,e),n.spaceIfLastNot().write(`as `),vm(n,t)}}static returnStatement(e){return t=>{t.write(`return `),t.hangingIndentUnlessBlock(()=>{vm(t,e),t.write(`;`)})}}};function hm(e,t){return n=>{_m(n,` ${e} `,t)}}function gm(e){for(let t of Object.keys(e))if(e[t]!=null&&!(e[t]instanceof Array&&e[t].length===0))return!0;return!1}function _m(e,t,n){for(let r=0;r<n.length;r++)e.conditionalWrite(r>0,t),vm(e,n[r])}function vm(e,t){t instanceof Function?t(e):e.write(t.toString())}var{InvalidOperationError:ym,FileNotFoundError:bm,ArgumentError:xm,ArgumentNullOrWhitespaceError:Sm,ArgumentOutOfRangeError:Cm,ArgumentTypeError:wm,BaseError:Tm,DirectoryNotFoundError:Em,NotImplementedError:Dm,NotSupportedError:Om,PathNotFoundError:km}=t.errors;Object.defineProperty(e,"CompilerOptionsContainer",{enumerable:!0,get:function(){return t.CompilerOptionsContainer}}),Object.defineProperty(e,"DiagnosticCategory",{enumerable:!0,get:function(){return t.DiagnosticCategory}}),Object.defineProperty(e,"EmitHint",{enumerable:!0,get:function(){return t.EmitHint}}),Object.defineProperty(e,"InMemoryFileSystemHost",{enumerable:!0,get:function(){return t.InMemoryFileSystemHost}}),Object.defineProperty(e,"LanguageVariant",{enumerable:!0,get:function(){return t.LanguageVariant}}),Object.defineProperty(e,"ModuleKind",{enumerable:!0,get:function(){return t.ModuleKind}}),Object.defineProperty(e,"ModuleResolutionKind",{enumerable:!0,get:function(){return t.ModuleResolutionKind}}),Object.defineProperty(e,"NewLineKind",{enumerable:!0,get:function(){return t.NewLineKind}}),Object.defineProperty(e,"NodeFlags",{enumerable:!0,get:function(){return t.NodeFlags}}),Object.defineProperty(e,"ObjectFlags",{enumerable:!0,get:function(){return t.ObjectFlags}}),Object.defineProperty(e,"ResolutionHosts",{enumerable:!0,get:function(){return t.ResolutionHosts}}),Object.defineProperty(e,"ScriptKind",{enumerable:!0,get:function(){return t.ScriptKind}}),Object.defineProperty(e,"ScriptTarget",{enumerable:!0,get:function(){return t.ScriptTarget}}),Object.defineProperty(e,"SettingsContainer",{enumerable:!0,get:function(){return t.SettingsContainer}}),Object.defineProperty(e,"SymbolFlags",{enumerable:!0,get:function(){return t.SymbolFlags}}),Object.defineProperty(e,"SyntaxKind",{enumerable:!0,get:function(){return t.SyntaxKind}}),Object.defineProperty(e,"TypeFlags",{enumerable:!0,get:function(){return t.TypeFlags}}),Object.defineProperty(e,"TypeFormatFlags",{enumerable:!0,get:function(){return t.TypeFormatFlags}}),Object.defineProperty(e,"ts",{enumerable:!0,get:function(){return t.ts}}),Object.defineProperty(e,"CodeBlockWriter",{enumerable:!0,get:function(){return i.default}}),e.AbstractableNode=ja,e.AmbientableNode=ge,e.ArgumentError=xm,e.ArgumentNullOrWhitespaceError=Sm,e.ArgumentOutOfRangeError=Cm,e.ArgumentTypeError=wm,e.ArgumentedNode=an,e.ArrayBindingPattern=Da,e.ArrayDestructuringAssignment=Ra,e.ArrayDestructuringAssignmentBase=La,e.ArrayLiteralExpression=Ua,e.ArrayTypeNode=iu,e.ArrowFunction=el,e.ArrowFunctionBase=$c,e.AsExpression=Qa,e.AsExpressionBase=Za,e.AssignmentExpression=Ia,e.AssignmentExpressionBase=Fa,e.AsyncableNode=on,e.AwaitExpression=eo,e.AwaitExpressionBase=$a,e.AwaitableNode=sn,e.BaseError=Tm,e.BaseExpressionedNode=Ga,e.BigIntLiteral=Wf,e.BigIntLiteralBase=Uf,e.BinaryExpression=Pa,e.BinaryExpressionBase=Na,e.BindingElement=ka,e.BindingElementBase=Oa,e.BindingNamedNode=Zi,e.Block=hs,e.BlockBase=ms,e.BodiedNode=xn,e.BodyableNode=Sn,e.BreakStatement=gs,e.CallExpression=no,e.CallExpressionBase=to,e.CallSignatureDeclaration=Qd,e.CallSignatureDeclarationBase=Zd,e.CaseBlock=vs,e.CaseBlockBase=_s,e.CaseClause=bs,e.CaseClauseBase=ys,e.CatchClause=Ss,e.CatchClauseBase=xs,e.ChildOrderableNode=Cn,e.ClassDeclaration=El,e.ClassDeclarationBase=Tl,e.ClassElement=ml,e.ClassExpression=Pl,e.ClassExpressionBase=Nl,e.ClassLikeDeclarationBase=vl,e.ClassLikeDeclarationBaseSpecific=yl,e.ClassStaticBlockDeclaration=Il,e.ClassStaticBlockDeclarationBase=Fl,e.CodeAction=Dp,e.CodeFixAction=Op,e.CombinedCodeActions=kp,e.CommaListExpression=io,e.CommaListExpressionBase=ro,e.CommentClassElement=Ll,e.CommentEnumMember=Wd,e.CommentObjectLiteralElement=Co,e.CommentRange=fn,e.CommentStatement=Cs,e.CommentTypeElement=$d,e.CommonIdentifierBase=pf,e.CompilerCommentClassElement=f,e.CompilerCommentEnumMember=h,e.CompilerCommentNode=u,e.CompilerCommentObjectLiteralElement=m,e.CompilerCommentStatement=d,e.CompilerCommentTypeElement=p,e.ComputedPropertyName=hf,e.ComputedPropertyNameBase=mf,e.ConditionalExpression=oo,e.ConditionalExpressionBase=ao,e.ConditionalTypeNode=au,e.ConstructSignatureDeclaration=tf,e.ConstructSignatureDeclarationBase=ef,e.ConstructorDeclaration=Bl,e.ConstructorDeclarationBase=Rl,e.ConstructorDeclarationOverloadBase=zl,e.ConstructorTypeNode=lu,e.ConstructorTypeNodeBase=cu,e.ContinueStatement=ws,e.DebuggerStatement=Es,e.DebuggerStatementBase=Ts,e.DecoratableNode=wn,e.Decorator=Jl,e.DecoratorBase=ql,e.DefaultClause=Os,e.DefaultClauseBase=Ds,e.DefinitionInfo=jp,e.DeleteExpression=co,e.DeleteExpressionBase=so,e.Diagnostic=Np,e.DiagnosticMessageChain=Mp,e.DiagnosticWithLocation=Pp,e.Directory=$p,e.DirectoryEmitResult=Qp,e.DirectoryNotFoundError=Em,e.DoStatement=js,e.DoStatementBase=As,e.DocumentSpan=Ap,e.DotDotDotTokenableNode=On,e.ElementAccessExpression=uo,e.ElementAccessExpressionBase=lo,e.EmitOutput=Ip,e.EmitResult=Lp,e.EmptyStatement=Ns,e.EmptyStatementBase=Ms,e.EnumDeclaration=Kd,e.EnumDeclarationBase=Gd,e.EnumMember=Jd,e.EnumMemberBase=qd,e.ExclamationTokenableNode=kn,e.ExportAssignment=rc,e.ExportAssignmentBase=nc,e.ExportDeclaration=ac,e.ExportDeclarationBase=ic,e.ExportGetableNode=An,e.ExportSpecifier=cc,e.ExportSpecifierBase=sc,e.ExportableNode=Mn,e.Expression=Ma,e.ExpressionStatement=Fs,e.ExpressionStatementBase=Ps,e.ExpressionWithTypeArguments=du,e.ExpressionWithTypeArgumentsBase=uu,e.ExpressionableNode=Wa,e.ExpressionedNode=Ka,e.ExtendsClauseableNode=Pi,e.ExternalModuleReference=uc,e.ExternalModuleReferenceBase=lc,e.FalseLiteral=Jf,e.FalseLiteralBase=qf,e.FileNotFoundError=bm,e.FileReference=Bc,e.FileTextChanges=Ep,e.ForInStatement=Ls,e.ForInStatementBase=Is,e.ForOfStatement=zs,e.ForOfStatementBase=Rs,e.ForStatement=Vs,e.ForStatementBase=Bs,e.FunctionDeclaration=cl,e.FunctionDeclarationBase=ol,e.FunctionDeclarationOverloadBase=sl,e.FunctionExpression=ul,e.FunctionExpressionBase=ll,e.FunctionLikeDeclaration=Qc,e.FunctionOrConstructorTypeNodeBase=su,e.FunctionOrConstructorTypeNodeBaseBase=ou,e.FunctionTypeNode=pu,e.FunctionTypeNodeBase=fu,e.GeneratorableNode=Fi,e.GetAccessorDeclaration=Hl,e.GetAccessorDeclarationBase=Vl,e.HeritageClause=Yd,e.HeritageClauseableNode=Li,e.Identifier=_f,e.IdentifierBase=gf,e.IfStatement=Us,e.IfStatementBase=Hs,e.ImplementationLocation=Rp,e.ImplementsClauseableNode=Ri,e.ImportAttribute=fc,e.ImportAttributeBase=dc,e.ImportAttributeNamedNode=Qi,e.ImportAttributes=mc,e.ImportAttributesBase=pc,e.ImportClause=gc,e.ImportClauseBase=hc,e.ImportDeclaration=vc,e.ImportDeclarationBase=_c,e.ImportEqualsDeclaration=Sc,e.ImportEqualsDeclarationBase=xc,e.ImportExpression=po,e.ImportExpressionBase=fo,e.ImportExpressionedNode=qa,e.ImportSpecifier=wc,e.ImportSpecifierBase=Cc,e.ImportTypeNode=mu,e.IndexSignatureDeclaration=rf,e.IndexSignatureDeclarationBase=nf,e.IndexedAccessTypeNode=hu,e.InferTypeNode=gu,e.InitializerExpressionGetableNode=zi,e.InitializerExpressionableNode=Bi,e.InterfaceDeclaration=of,e.InterfaceDeclarationBase=af,e.IntersectionTypeNode=_u,e.InvalidOperationError=ym,e.IterationStatement=ks,e.JSDoc=eu,e.JSDocAllType=Bu,e.JSDocAugmentsTag=Ju,e.JSDocAuthorTag=Yu,e.JSDocBase=$l,e.JSDocCallbackTag=Xu,e.JSDocClassTag=Zu,e.JSDocDeprecatedTag=Qu,e.JSDocEnumTag=$u,e.JSDocFunctionType=td,e.JSDocFunctionTypeBase=ed,e.JSDocImplementsTag=nd,e.JSDocLink=rd,e.JSDocLinkCode=id,e.JSDocLinkPlain=ad,e.JSDocMemberName=od,e.JSDocNameReference=cd,e.JSDocNamepathType=sd,e.JSDocNonNullableType=ld,e.JSDocNullableType=ud,e.JSDocOptionalType=dd,e.JSDocOverloadTag=pd,e.JSDocOverloadTagBase=fd,e.JSDocOverrideTag=md,e.JSDocParameterTag=gd,e.JSDocParameterTagBase=hd,e.JSDocPrivateTag=_d,e.JSDocPropertyLikeTag=Yl,e.JSDocPropertyTag=vd,e.JSDocPropertyTagBase=J,e.JSDocProtectedTag=yd,e.JSDocPublicTag=bd,e.JSDocReadonlyTag=xd,e.JSDocReturnTag=Cd,e.JSDocReturnTagBase=Sd,e.JSDocSatisfiesTag=Td,e.JSDocSatisfiesTagBase=wd,e.JSDocSeeTag=Dd,e.JSDocSeeTagBase=Ed,e.JSDocSignature=Od,e.JSDocTag=Hu,e.JSDocTagBase=Vu,e.JSDocTagInfo=kd,e.JSDocTemplateTag=jd,e.JSDocTemplateTagBase=Ad,e.JSDocText=Md,e.JSDocThisTag=Pd,e.JSDocThisTagBase=Nd,e.JSDocThrowsTag=Id,e.JSDocThrowsTagBase=Fd,e.JSDocType=zu,e.JSDocTypeExpression=Rd,e.JSDocTypeExpressionableTag=Xl,e.JSDocTypeLiteral=zd,e.JSDocTypeParameteredTag=Zl,e.JSDocTypeTag=Bd,e.JSDocTypedefTag=Ld,e.JSDocUnknownTag=Vd,e.JSDocUnknownType=Hd,e.JSDocVariadicType=Ud,e.JSDocableNode=Hi,e.JsxAttribute=Sf,e.JsxAttributeBase=xf,e.JsxAttributedNode=df,e.JsxClosingElement=wf,e.JsxClosingElementBase=Cf,e.JsxClosingFragment=Tf,e.JsxElement=Df,e.JsxElementBase=Ef,e.JsxExpression=Af,e.JsxExpressionBase=kf,e.JsxFragment=jf,e.JsxNamespacedName=Nf,e.JsxNamespacedNameBase=Mf,e.JsxOpeningElement=Ff,e.JsxOpeningElementBase=Pf,e.JsxOpeningFragment=If,e.JsxSelfClosingElement=Rf,e.JsxSelfClosingElementBase=Lf,e.JsxSpreadAttribute=Bf,e.JsxSpreadAttributeBase=zf,e.JsxTagNamedNode=ff,e.JsxText=Hf,e.JsxTextBase=Vf,e.LabeledStatement=Gs,e.LabeledStatementBase=Ws,e.LanguageService=Yp,e.LeftHandSideExpression=G,e.LeftHandSideExpressionedNode=Ja,e.LiteralExpression=ho,e.LiteralExpressionBase=mo,e.LiteralLikeNode=Ui,e.LiteralTypeNode=vu,e.ManipulationError=Et,e.ManipulationSettingsContainer=M,e.MappedTypeNode=yu,e.MemberExpression=Va,e.MemoryEmitResult=zp,e.MetaProperty=_o,e.MetaPropertyBase=go,e.MethodDeclaration=_l,e.MethodDeclarationBase=hl,e.MethodDeclarationOverloadBase=gl,e.MethodSignature=cf,e.MethodSignatureBase=sf,e.ModifierableNode=Wi,e.ModuleBlock=Ec,e.ModuleBlockBase=Tc,e.ModuleChildableNode=Dc,e.ModuleDeclaration=kc,e.ModuleDeclarationBase=Oc,e.ModuleNamedNode=$i,e.ModuledNode=Ki,e.NameableNode=ea,e.NamedExports=Nc,e.NamedExportsBase=Mc,e.NamedImports=Fc,e.NamedImportsBase=Pc,e.NamedNode=ra,e.NamedNodeBase=qi,e.NamedTupleMember=xu,e.NamedTupleMemberBase=bu,e.NamespaceExport=Lc,e.NamespaceExportBase=Ic,e.NamespaceImport=zc,e.NamespaceImportBase=Rc,e.NewExpression=yo,e.NewExpressionBase=vo,e.NoSubstitutionTemplateLiteral=op,e.NoSubstitutionTemplateLiteralBase=ap,e.Node=H,e.NodeWithTypeArguments=ru,e.NodeWithTypeArgumentsBase=nu,e.NonNullExpression=xo,e.NonNullExpressionBase=bo,e.NotEmittedStatement=qs,e.NotEmittedStatementBase=Ks,e.NotImplementedError=Dm,e.NotSupportedError=Om,e.NullLiteral=Qf,e.NullLiteralBase=Zf,e.NumericLiteral=ep,e.NumericLiteralBase=$f,e.ObjectBindingPattern=Aa,e.ObjectDestructuringAssignment=To,e.ObjectDestructuringAssignmentBase=wo,e.ObjectLiteralElement=So,e.ObjectLiteralExpression=Do,e.ObjectLiteralExpressionBase=Eo,e.OmittedExpression=Fo,e.OmittedExpressionBase=Po,e.OutputFile=Fp,e.OverloadableNode=tl,e.OverrideableNode=aa,e.ParameterDeclaration=fl,e.ParameterDeclarationBase=dl,e.ParameteredNode=oa,e.ParenthesizedExpression=q,e.ParenthesizedExpressionBase=K,e.ParenthesizedTypeNode=Su,e.PartiallyEmittedExpression=Lo,e.PartiallyEmittedExpressionBase=Io,e.PathNotFoundError=km,e.PostfixUnaryExpression=zo,e.PostfixUnaryExpressionBase=Ro,e.PrefixUnaryExpression=Vo,e.PrefixUnaryExpressionBase=Bo,e.PrimaryExpression=Ha,e.PrivateIdentifier=yf,e.PrivateIdentifierBase=vf,e.Program=Jp,e.Project=um,e.PropertyAccessExpression=Uo,e.PropertyAccessExpressionBase=Ho,e.PropertyAssignment=ko,e.PropertyAssignmentBase=Oo,e.PropertyDeclaration=Wl,e.PropertyDeclarationBase=Ul,e.PropertyNamedNode=ia,e.PropertySignature=uf,e.PropertySignatureBase=lf,e.QualifiedName=bf,e.QuestionDotTokenableNode=sa,e.QuestionTokenableNode=ca,e.ReadonlyableNode=la,e.RefactorEditInfo=Bp,e.ReferenceEntry=Up,e.ReferenceFindableNode=Ji,e.ReferencedSymbol=Vp,e.ReferencedSymbolDefinitionInfo=Hp,e.ReferencedSymbolEntry=Wp,e.RegularExpressionLiteral=np,e.RegularExpressionLiteralBase=tp,e.RenameLocation=Gp,e.RenameableNode=Xi,e.RestTypeNode=Cu,e.ReturnStatement=Ys,e.ReturnStatementBase=Js,e.ReturnTypedNode=ua,e.SatisfiesExpression=Go,e.SatisfiesExpressionBase=Wo,e.ScopeableNode=da,e.ScopedNode=ma,e.SetAccessorDeclaration=Kl,e.SetAccessorDeclarationBase=Gl,e.ShorthandPropertyAssignment=jo,e.ShorthandPropertyAssignmentBase=Ao,e.Signature=Sp,e.SignaturedDeclaration=ha,e.SourceFile=Uc,e.SourceFileBase=Hc,e.SpreadAssignment=No,e.SpreadAssignmentBase=Mo,e.SpreadElement=qo,e.SpreadElementBase=Ko,e.Statement=ds,e.StatementBase=us,e.StatementedNode=fs,e.StaticableNode=ga,e.StringLiteral=ip,e.StringLiteralBase=rp,e.Structure=Jn,e.SuperElementAccessExpression=Yo,e.SuperElementAccessExpressionBase=Jo,e.SuperExpression=Zo,e.SuperExpressionBase=Xo,e.SuperExpressionedNode=Ya,e.SuperPropertyAccessExpression=$o,e.SuperPropertyAccessExpressionBase=Qo,e.SwitchStatement=Zs,e.SwitchStatementBase=Xs,e.Symbol=Cp,e.SymbolDisplayPart=Kp,e.SyntaxList=vn,e.TaggedTemplateExpression=sp,e.TemplateExpression=lp,e.TemplateExpressionBase=cp,e.TemplateHead=dp,e.TemplateHeadBase=up,e.TemplateLiteralTypeNode=wu,e.TemplateMiddle=pp,e.TemplateMiddleBase=fp,e.TemplateSpan=hp,e.TemplateSpanBase=mp,e.TemplateTail=_p,e.TemplateTailBase=gp,e.TextChange=Tp,e.TextInsertableNode=_a,e.TextRange=dn,e.TextSpan=wp,e.ThisExpression=ts,e.ThisExpressionBase=es,e.ThisTypeNode=Tu,e.ThrowStatement=$s,e.ThrowStatementBase=Qs,e.TrueLiteral=Kf,e.TrueLiteralBase=Gf,e.TryStatement=tc,e.TryStatementBase=ec,e.TupleTypeNode=Eu,e.Type=Xp,e.TypeAliasDeclaration=Ou,e.TypeAliasDeclarationBase=Du,e.TypeArgumentedNode=ya,e.TypeAssertion=rs,e.TypeAssertionBase=ns,e.TypeChecker=qp,e.TypeElement=Xd,e.TypeElementMemberedNode=Sa,e.TypeLiteralNode=Au,e.TypeLiteralNodeBase=ku,e.TypeNode=tu,e.TypeOfExpression=as,e.TypeOfExpressionBase=is,e.TypeOperatorTypeNode=ju,e.TypeParameter=Zp,e.TypeParameterDeclaration=Nu,e.TypeParameterDeclarationBase=Mu,e.TypeParameteredNode=wa,e.TypePredicateNode=Fu,e.TypeQueryNode=Iu,e.TypeReferenceNode=Lu,e.TypedNode=ba,e.UnaryExpression=za,e.UnaryExpressionedNode=Xa,e.UnionTypeNode=Ru,e.UnwrappableNode=Ea,e.UpdateExpression=Ba,e.VariableDeclaration=yp,e.VariableDeclarationBase=vp,e.VariableDeclarationList=xp,e.VariableDeclarationListBase=bp,e.VariableStatement=qc,e.VariableStatementBase=Kc,e.VoidExpression=ss,e.VoidExpressionBase=os,e.WhileStatement=Yc,e.WhileStatementBase=Jc,e.WithStatement=Zc,e.WithStatementBase=Xc,e.Writers=mm,e.YieldExpression=ls,e.YieldExpressionBase=cs,e.createWrappedNode=fm,e.forEachStructureChild=Yn,e.getCompilerOptionsFromTsConfig=fe,e.getScopeForNode=fa,e.insertOverloads=al,e.printNode=j,e.setScopeForNode=pa}))(),V=new Set([`t`,`msg`]),Zt=`Trans`,Qt=e=>{if(e!==void 0&&(Xt.Node.isStringLiteral(e)||Xt.Node.isNoSubstitutionTemplateLiteral(e)))return e.getLiteralText()},$t=e=>{if(e===void 0)return;let t=Qt(e);if(t!==void 0)return{message:t};if(!Xt.Node.isObjectLiteralExpression(e))return;let n=e.getProperty(`message`);if(n===void 0||!Xt.Node.isPropertyAssignment(n))return;let r=Qt(n.getInitializer());if(r===void 0)return;let i=e.getProperty(`context`),a=i!==void 0&&Xt.Node.isPropertyAssignment(i)?Qt(i.getInitializer()):void 0;return a===void 0?{message:r}:{message:r,context:a}},en=(e,t)=>{let n=e.getAttribute(t);if(n===void 0||!Xt.Node.isJsxAttribute(n))return;let r=n.getInitializer();if(r!==void 0){if(Xt.Node.isStringLiteral(r))return r.getLiteralText();if(Xt.Node.isJsxExpression(r))return Qt(r.getExpression())}},tn=e=>{let t=e.getJsxChildren();if(t.some(e=>Xt.Node.isJsxExpression(e)||Xt.Node.isJsxElement(e)||Xt.Node.isJsxSelfClosingElement(e)))return;let n=v(t.filter(e=>Xt.Node.isJsxText(e)).map(e=>e.getText()).join(``));return n.length>0?n:void 0},nn=e=>{let t=new Map;for(let n of e)t.set(_(n.message,n.context),n);return[...t.values()]},rn=async e=>{if(e.length===0)return[];let t=new Xt.Project({useInMemoryFileSystem:!0,skipFileDependencyResolution:!0}),n=[];for(let r=0;r<e.length;r++){let a;try{a=await(0,i.readFile)(e[r],`utf8`)}catch{continue}t.createSourceFile(`front-component-${r}.tsx`,a,{overwrite:!0}).forEachDescendant(e=>{if(Xt.Node.isCallExpression(e)){let t=e.getExpression();if(Xt.Node.isIdentifier(t)&&V.has(t.getText())){let t=$t(e.getArguments()[0]);t!==void 0&&n.push(t)}return}if(Xt.Node.isJsxSelfClosingElement(e)){if(e.getTagNameNode().getText()!==Zt)return;let t=en(e,`message`);if(t!==void 0&&t.length>0){let r=en(e,`context`);n.push(r===void 0?{message:t}:{message:t,context:r})}return}if(Xt.Node.isJsxElement(e)){let t=e.getOpeningElement();if(t.getTagNameNode().getText()!==Zt)return;let r=en(t,`message`)??tn(e);if(r!==void 0&&r.length>0){let e=en(t,`context`);n.push(e===void 0?{message:r}:{message:r,context:e})}}})}return nn(n)},an={objects:[`labelSingular`,`labelPlural`,`description`],fields:[`label`,`description`],views:[`name`],pageLayoutTabs:[`title`],commandMenuItems:[`label`,`shortLabel`],navigationMenuItems:[`name`]},on=e=>{let t=new Set,n=e=>{typeof e==`string`&&e.length>0&&t.add(e)};for(let[t,r]of Object.entries(an)){let i=e[t];if(Array.isArray(i)){for(let e of i)if(!(typeof e!=`object`||!e))for(let t of r)n(e[t])}}for(let t of e.pageLayouts??[])for(let e of t.tabs??[]){n(e.title);for(let t of e.widgets??[])n(t.title)}return[...t].sort()},sn=async({manifest:e,frontComponentSourcePaths:t})=>{let n=on(e).map(e=>({message:e})),r=await rn(t),i=new Map;for(let e of[...n,...r])i.set(_(e.message,e.context),e);return i},cn=async({appPath:e,manifest:a,frontComponentSourcePaths:o=[],scaffoldLocale:s})=>{let c=await sn({manifest:a,frontComponentSourcePaths:o}),l=[...c.keys()].sort(),u=r.default.join(e,t.nt);await t.lt(u);let d={};for(let e of l){let t=c.get(e);n.t(t)&&(d[e]=t.message)}if(await t.pt(r.default.join(u,`en.json`),d),s!==void 0&&s!==`en`){let e=r.default.join(u,`${s}.json`);await t.ut(e)||await t.pt(e,{})}let f=(await(0,i.readdir)(u)).filter(e=>e.endsWith(`.json`)&&e!==`en.json`);for(let e of f){let n=r.default.join(u,e),i=await t.dt(n)??{},a={};for(let e of l){let t=i[e];a[e]=typeof t==`string`?t:``}await t.pt(n,a)}return{sourceCount:l.length,updatedLocaleFiles:f}},ln=e=>Object.prototype.hasOwnProperty.call(t.xt,e),un=class{async execute(e){let n=e.appPath??t.kt,i;e.locale!==void 0&&((e.locale===`en`||!ln(e.locale))&&(console.error(u.default.red(`"${e.locale}" is not a supported target locale. Choose one of: ${Object.keys(t.xt).filter(e=>e!==`en`).join(`, `)}`)),process.exit(1)),i=e.locale),console.log(u.default.blue(`Extracting translatable strings...`));let a=await t.$(n);a.success||(console.error(u.default.red(a.errors.join(`
|
|
31383
31389
|
`))),process.exit(1)),a.warnings.length>0&&console.warn(u.default.yellow(a.warnings.join(`
|
|
31384
|
-
`)));let o=a.filePaths.frontComponents.map(e=>r.default.join(n,e)),{sourceCount:s,updatedLocaleFiles:c}=await cn({appPath:n,manifest:a.manifest,frontComponentSourcePaths:o,scaffoldLocale:i});console.log(u.default.green(`✓ Extracted ${s} string${s===1?``:`s`} to locales/`)),c.length>0&&console.log(u.default.gray(`Updated: ${c.join(`, `)}`))}},dn=e=>{let n=new ve,r=new Mt,i=new Pt,a=new Se,o=new _e,s=new It,c=new un;e.command(`dev [appPath]`).description(`Build and sync local changes`).option(`-o, --once`,"Build and sync once, then exit (deprecated: use `twenty apply`)").option(`--dry-run`,"Preview the metadata changes without applying them (deprecated: use `twenty plan`)").option(`-f, --force`,`Apply destructive changes (deletes) without confirmation`).option(`--debounceMs <ms>`,`Debounce in ms (default: 1 000)`).option(`-v, --verbose`,`Show detailed logs`).option(`-d, --debug`,`Show detailed logs (alias for --verbose)`).action(async(e,t)=>{t.dryRun&&!t.once&&console.warn(u.default.yellow("--dry-run only applies with --once. Ignoring it; run `yarn twenty plan` to preview changes."));let n=t.verbose||t.debug;if(t.once){console.warn(u.default.yellow(t.dryRun?"⚠ `twenty dev --once --dry-run` is deprecated. Use `twenty plan` instead.":"⚠ `twenty dev --once` is deprecated. Use `twenty apply` instead.")),await i.execute({appPath:g(e),verbose:n,apply:!t.dryRun,force:t.force});return}await r.execute({appPath:g(e),verbose:n,debounceMs:t.debounceMs?parseInt(t.debounceMs,10):void 0,force:t.force})}),e.command(`plan [appPath]`).description(`Preview metadata changes without applying them`).option(`-v, --verbose`,`Show detailed logs`).action(async(e,t)=>{await i.execute({appPath:g(e),verbose:t.verbose,apply:!1})}),e.command(`apply [appPath]`).description(`Apply local metadata changes after showing the plan`).option(`-f, --force`,`Apply destructive changes (deletes) without confirmation`).option(`-v, --verbose`,`Show detailed logs`).action(async(e,t)=>{await i.execute({appPath:g(e),verbose:t.verbose,apply:!0,force:t.force})}),e.command(`dev:build [appPath]`).description(`Build and generate API client`).option(`--tarball`,`Also pack into a .tgz tarball`).action(async(e,t)=>{await n.execute({appPath:g(e),tarball:t.tarball})}),e.command(`dev:typecheck [appPath]`).description(`Run TypeScript type checking`).action(async e=>{await a.execute({appPath:g(e)})}),e.command(`dev:add [entityType]`).description(`Scaffold a new entity (${Object.values(t.ht).join(`|`)})`).option(`--path <path>`,`Path in which the entity should be created.`).action(async(e,t)=>{await o.execute(e,t?.path)}),e.command(`dev:catalog-sync`).description(`Trigger marketplace catalog sync`).option(`-r, --remote <name>`,`Sync on a specific remote`).action(async e=>{let{CatalogSyncCommand:t}=await Promise.resolve().then(()=>require("./catalog-sync-
|
|
31385
|
-
Start one with: yarn twenty docker:start`)),process.exit(1)),console.log(u.default.gray(`Found local server at ${n}`)),a=n):a=t.
|
|
31390
|
+
`)));let o=a.filePaths.frontComponents.map(e=>r.default.join(n,e)),{sourceCount:s,updatedLocaleFiles:c}=await cn({appPath:n,manifest:a.manifest,frontComponentSourcePaths:o,scaffoldLocale:i});console.log(u.default.green(`✓ Extracted ${s} string${s===1?``:`s`} to locales/`)),c.length>0&&console.log(u.default.gray(`Updated: ${c.join(`, `)}`))}},dn=e=>{let n=new ve,r=new Mt,i=new Pt,a=new Se,o=new _e,s=new It,c=new un;e.command(`dev [appPath]`).description(`Build and sync local changes`).option(`-o, --once`,"Build and sync once, then exit (deprecated: use `twenty apply`)").option(`--dry-run`,"Preview the metadata changes without applying them (deprecated: use `twenty plan`)").option(`-f, --force`,`Apply destructive changes (deletes) without confirmation`).option(`--debounceMs <ms>`,`Debounce in ms (default: 1 000)`).option(`-v, --verbose`,`Show detailed logs`).option(`-d, --debug`,`Show detailed logs (alias for --verbose)`).action(async(e,t)=>{t.dryRun&&!t.once&&console.warn(u.default.yellow("--dry-run only applies with --once. Ignoring it; run `yarn twenty plan` to preview changes."));let n=t.verbose||t.debug;if(t.once){console.warn(u.default.yellow(t.dryRun?"⚠ `twenty dev --once --dry-run` is deprecated. Use `twenty plan` instead.":"⚠ `twenty dev --once` is deprecated. Use `twenty apply` instead.")),await i.execute({appPath:g(e),verbose:n,apply:!t.dryRun,force:t.force});return}await r.execute({appPath:g(e),verbose:n,debounceMs:t.debounceMs?parseInt(t.debounceMs,10):void 0,force:t.force})}),e.command(`plan [appPath]`).description(`Preview metadata changes without applying them`).option(`-v, --verbose`,`Show detailed logs`).action(async(e,t)=>{await i.execute({appPath:g(e),verbose:t.verbose,apply:!1})}),e.command(`apply [appPath]`).description(`Apply local metadata changes after showing the plan`).option(`-f, --force`,`Apply destructive changes (deletes) without confirmation`).option(`-v, --verbose`,`Show detailed logs`).action(async(e,t)=>{await i.execute({appPath:g(e),verbose:t.verbose,apply:!0,force:t.force})}),e.command(`dev:build [appPath]`).description(`Build and generate API client`).option(`--tarball`,`Also pack into a .tgz tarball`).action(async(e,t)=>{await n.execute({appPath:g(e),tarball:t.tarball})}),e.command(`dev:typecheck [appPath]`).description(`Run TypeScript type checking`).action(async e=>{await a.execute({appPath:g(e)})}),e.command(`dev:add [entityType]`).description(`Scaffold a new entity (${Object.values(t.ht).join(`|`)})`).option(`--path <path>`,`Path in which the entity should be created.`).action(async(e,t)=>{await o.execute(e,t?.path)}),e.command(`dev:catalog-sync`).description(`Trigger marketplace catalog sync`).option(`-r, --remote <name>`,`Sync on a specific remote`).action(async e=>{let{CatalogSyncCommand:t}=await Promise.resolve().then(()=>require("./catalog-sync-Bh6piElD.js"));await new t().execute({remote:e.remote})}),e.command(`dev:generate-client [appPath]`).description(`Generate the typed API client from the active remote (no app definition required)`).action(async e=>{await s.execute({appPath:g(e)})}),e.command(`dev:translations-extract [appPath]`).description(`Extract translatable strings into locales/ catalogs`).option(`--locale <locale>`,`Scaffold an empty catalog for a target locale (e.g. fr-FR)`).action(async(e,t)=>{await c.execute({appPath:g(e),locale:t.locale})}),Ft(e)},fn=async(e,n)=>{let r=n.test?t.C:t.S,i=n.port?parseInt(n.port,10):r;(isNaN(i)||i<1||i>65535)&&(console.error(u.default.red(`Invalid port number.`)),process.exit(1));let a=await t.n({port:i,test:n.test,version:e,onProgress:e=>console.log(u.default.gray(e))});a.success||(console.error(u.default.red(a.error.message)),process.exit(1))},H=e=>{let n=e.test?t.w:t.x;if(!t.E(n)){console.log(u.default.yellow(`No Twenty server container found.`));return}(0,l.execSync)(`docker stop ${n}`,{stdio:`ignore`}),console.log(u.default.green(`Twenty server stopped.`))},pn=e=>{let n=e.test?t.w:t.x;if(!t.E(n)){console.log(u.default.yellow(`No Twenty server container found.`));return}try{(0,l.spawnSync)(`docker`,[`logs`,`-f`,`--tail`,e.lines,n],{stdio:`inherit`})}catch{}},mn=async e=>{let n=e.test?t.w:t.x,r=e.test?t.C:t.S;if(!t.E(n)){console.log(` Status: ${u.default.gray(`not created`)}`),console.log(u.default.gray(` Run 'yarn twenty docker:start${e.test?` --test`:``}' to create one.`));return}let i=t.M(n),a=i?t.k(n):r,o=i?await t.p(a):!1,s=o?u.default.green(`running (healthy)`):i?u.default.yellow(`running (starting...)`):u.default.gray(`stopped`),c=t.O(`APP_VERSION`,n);console.log(` Status: ${s}`),console.log(` URL: http://localhost:${a}`),c&&console.log(` Version: ${u.default.gray(c)}`),o&&console.log(u.default.gray(` Login: tim@apple.dev / tim@apple.dev`))},hn=e=>{let n=e.test?t.w:t.x,r=e.test?`twenty-app-dev-test-data`:`twenty-app-dev-data`,i=e.test?`twenty-app-dev-test-storage`:`twenty-app-dev-storage`;t.E(n)&&(0,l.execSync)(`docker rm -f ${n}`,{stdio:`ignore`});try{(0,l.execSync)(`docker volume rm ${r} ${i}`,{stdio:`ignore`})}catch{}console.log(u.default.green(`Twenty server data reset.`)),console.log(u.default.gray(`Run 'yarn twenty docker:start${e.test?` --test`:``}' to start a fresh instance.`))},gn=async(e,n)=>{let r=await t.i({version:e??`latest`,test:n.test,onProgress:e=>console.log(u.default.gray(e))});r.success||(console.error(u.default.red(r.error.message)),process.exit(1));let{data:i}=r;if(!i.imageUpdated){console.log(u.default.green(` Already up to date (${i.image}).`));return}console.log(u.default.green(` Upgraded to: ${i.image}`)),i.containerRecreated&&console.log(u.default.gray(` Run 'yarn twenty docker:start${n.test?` --test`:``}' to wait for the server to be ready.`))},_n=e=>{e.command(`docker:start [version]`).description("Start the local Twenty container (version defaults to the app `engines.twenty` range, then `latest`)").option(`-p, --port <port>`,`HTTP port`).option(`--test`,`Start a separate test instance (port 2021)`).action(fn),e.command(`docker:stop`).description(`Stop the local Twenty container`).option(`--test`,`Stop the test instance`).action(H),e.command(`docker:logs`).description(`Stream container logs`).option(`-n, --lines <lines>`,`Number of lines to show`,`50`).option(`--test`,`Show logs for the test instance`).action(pn),e.command(`docker:status`).description(`Show container status`).option(`--test`,`Show status of the test instance`).action(mn),e.command(`docker:reset`).description(`Delete all data and start fresh`).option(`--test`,`Reset the test instance`).action(hn),e.command(`docker:upgrade [version]`).description(`Upgrade the Docker image`).option(`--test`,`Upgrade the test instance`).action(gn);let t=e.command(`server`,{hidden:!0}).description(`Manage a Twenty server (local instance and server-side actions)`),n=(e,t)=>console.warn(u.default.yellow(`⚠ \`twenty server ${e}\` is deprecated. Use \`twenty ${t}\` instead.`));t.command(`start [version]`).option(`-p, --port <port>`,`HTTP port`).option(`--test`,`Start a separate test instance (port 2021)`).action(async(e,t)=>{n(`start`,`docker:start`),await fn(e,t)}),t.command(`stop`).option(`--test`,`Stop the test instance`).action(e=>{n(`stop`,`docker:stop`),H(e)}),t.command(`logs`).option(`-n, --lines <lines>`,`Number of lines to show`,`50`).option(`--test`,`Show logs for the test instance`).action(e=>{n(`logs`,`docker:logs`),pn(e)}),t.command(`status`).option(`--test`,`Show status of the test instance`).action(async e=>{n(`status`,`docker:status`),await mn(e)}),t.command(`reset`).option(`--test`,`Reset the test instance`).action(e=>{n(`reset`,`docker:reset`),hn(e)}),t.command(`upgrade [version]`).option(`--test`,`Upgrade the test instance`).action(async(e,t)=>{n(`upgrade`,`docker:upgrade`),await gn(e,t)}),t.command(`catalog-sync`).option(`-r, --remote <name>`,`Sync on a specific remote`).action(async e=>{n(`catalog-sync`,`dev:catalog-sync`);let{CatalogSyncCommand:t}=await Promise.resolve().then(()=>require("./catalog-sync-Bh6piElD.js"));await new t().execute({remote:e.remote})})},vn=/^(\d{1,3}\.){3}\d{1,3}$/,yn=e=>{try{let{hostname:t}=new URL(e);if(vn.test(t))return t.replace(/\./g,`-`);let n=t.split(`.`);return n.length>2?n.slice(0,-2).join(`-`):n.length===2?n[0]:n.join(`-`)}catch{return`remote`}},bn=async(e,n)=>n?((await t.t({apiKey:n,apiUrl:e})).success||(console.error(u.default.red(`✗ Authentication failed.`)),process.exit(1)),`API key`):xn(e),xn=async e=>{console.log(u.default.gray(`Opening browser for authentication...`));let n=await t.H({apiUrl:e});return n.success?`OAuth`:(console.log(u.default.yellow(n.error.message)),(await t.t({apiKey:(await d.default.prompt([{type:`password`,name:`apiKey`,message:`API Key:`,mask:`*`,validate:e=>e.length>0||`API key is required`}])).apiKey,apiUrl:e})).success||(console.error(u.default.red(`✗ Authentication failed.`)),process.exit(1)),`API key`)},Sn=async e=>{e.apiUrl&&console.warn(u.default.yellow(`⚠ --api-url is deprecated. Use --url instead.`));let n=e.test?t.W(!0):void 0,r=new t.U(n?{configPath:n}:void 0),i=await r.getRemotes();if(e.as!==void 0&&i.includes(e.as)){let n=await r.getConfigForRemote(e.as);t.U.setActiveRemote(e.as);let i=await bn(n.apiUrl,e.apiKey);console.log(u.default.green(`✓ Re-authenticated "${e.as}" via ${i}.`)),await r.setDefaultRemote(e.as),console.log(u.default.green(`✓ Default remote set to "${e.as}".`));return}let a=e.url??e.apiUrl;if(a)a=t.yt(a);else{let n=await t.m();e.local?(n||(console.error(u.default.red(`No local Twenty server found.
|
|
31391
|
+
Start one with: yarn twenty docker:start`)),process.exit(1)),console.log(u.default.gray(`Found local server at ${n}`)),a=n):a=t.yt((await d.default.prompt([{type:`input`,name:`serverUrl`,message:`Twenty server URL:`,validate:e=>{try{return new URL(e),!0}catch{return`Please enter a valid URL`}}}])).serverUrl)}let o=e.as??yn(a);t.U.setActiveRemote(o);let s=await bn(a,e.apiKey);console.log(u.default.green(`✓ Remote "${o}" added (${a}) via ${s}.`)),await r.setDefaultRemote(o),console.log(u.default.green(`✓ Default remote set to "${o}".`))},Cn=async()=>{let e=new t.U,n=await e.getRemotes(),r=await e.getDefaultRemote();if(n.length===0){console.log(`No remotes configured.`),console.log(`Use 'twenty remote:add' to add one.`);return}console.log(``);for(let t of n){let n=await e.getConfigForRemote(t),i=n.twentyCLIAccessToken?`oauth`:n.apiKey?`api-key`:`none`,a=t===r,o=a?`* `:` `,s=a?u.default.bold(t):t;console.log(`${o}${s} ${u.default.gray(n.apiUrl)} [${i}]`)}console.log(`
|
|
31386
31392
|
`,u.default.gray(`Use 'twenty remote:use <name>' to change default`))},wn=async e=>{let n=new t.U,r=e??(await d.default.prompt([{type:`select`,name:`remote`,message:`Select default remote:`,choices:await n.getRemotes()}])).remote;(await n.getRemotes()).includes(r)||(console.error(u.default.red(`Remote "${r}" not found.`)),process.exit(1)),await n.setDefaultRemote(r),console.log(u.default.green(`✓ Default remote set to "${r}".`))},Tn=async()=>{let e=new t.U,n=new t.z,r=t.U.getActiveRemote(),i=await e.getConfig(),a=i.twentyCLIAccessToken?`oauth`:i.apiKey?`api-key`:`none`;if(console.log(` Remote: ${u.default.bold(r)}`),console.log(` Server: ${i.apiUrl}`),a===`none`){console.log(` Auth: ${u.default.yellow(`not configured`)}`);return}let{authValid:o}=await n.validateAuth(),s=o?u.default.green(`${a} (valid)`):u.default.red(`${a} (invalid)`);console.log(` Auth: ${s}`)},En=async e=>{let n=new t.U;(await n.getRemotes()).includes(e)||(console.error(u.default.red(`Remote "${e}" not found.`)),process.exit(1)),t.U.setActiveRemote(e),await n.clearConfig(),console.log(u.default.green(`✓ Remote "${e}" removed.`))},Dn=e=>{e.command(`remote:add`).description(`Add or re-authenticate a remote`).option(`--as <name>`,`Name for this remote`).option(`--api-key <apiKey>`,`API key for non-interactive auth`).option(`--url <url>`,`Server URL`).option(`--api-url <apiUrl>`,`[deprecated: use --url]`).option(`--local`,`Connect to a local Twenty server (auto-detect)`).option(`--test`,`Write to config.test.json (for integration tests)`).action(Sn),e.command(`remote:list`).description(`List all configured remotes`).action(Cn),e.command(`remote:use [name]`).description(`Set the default remote`).action(wn),e.command(`remote:status`).description(`Show active remote auth status`).action(Tn),e.command(`remote:remove <name>`).description(`Remove a remote`).action(En);let t=e.command(`remote`,{hidden:!0}).description(`Manage remote Twenty servers`),n=(e,t)=>console.warn(u.default.yellow(`⚠ \`twenty remote ${e}\` is deprecated. Use \`twenty ${t}\` instead.`));t.command(`add`).option(`--as <name>`,`Name for this remote`).option(`--api-key <apiKey>`,`API key for non-interactive auth`).option(`--url <url>`,`Server URL`).option(`--api-url <apiUrl>`,`[deprecated: use --url]`).option(`--local`,`Connect to a local Twenty server (auto-detect)`).option(`--test`,`Write to config.test.json (for integration tests)`).action(async e=>{n(`add`,`remote:add`),await Sn(e)}),t.command(`list`).action(async()=>{n(`list`,`remote:list`),await Cn()}),t.command(`switch [name]`).action(async e=>{n(`switch`,`remote:use`),await wn(e)}),t.command(`status`).action(async()=>{n(`status`,`remote:status`),await Tn()}),t.command(`remove <name>`).action(async e=>{n(`remove`,`remote:remove`),await En(e)})},U=e=>{dn(e),T(e),_n(e),Dn(e),we(e)};h.inspect.defaultOptions.depth=10;var On=new m.Command;On.name(`twenty`).description(`CLI for Twenty application development`).version(t.I.version),On.option(`-r, --remote <name>`,`Use a specific remote (overrides the default set by remote:use)`),On.hook(`preAction`,async e=>{let n=(e.optsWithGlobals?e.optsWithGlobals():e.opts()).remote;n?console.log(u.default.gray(`Using remote: ${n}`)):n=await new t.U().getDefaultRemote(),t.U.setActiveRemote(n)}),U(On),On.exitOverride();try{On.parse()}catch(e){e instanceof m.CommanderError&&process.exit(e.exitCode),e instanceof Error&&(console.error(u.default.red(`Error:`),e.message),process.exit(1))}
|