twenty-sdk 2.50.0 → 2.51.1

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.
Files changed (39) hide show
  1. package/dist/build/descriptor.json +1 -1
  2. package/dist/{build-snapshot-DlB2VyNd.mjs → build-snapshot--GXJr4vI.mjs} +2 -2
  3. package/dist/{build-snapshot-C-NQg7fn.js → build-snapshot-D38u-ntr.js} +1 -1
  4. package/dist/build.cjs +1 -1
  5. package/dist/build.mjs +2 -2
  6. package/dist/{catalog-sync-DxcdSEBJ.js → catalog-sync-DJgluWIc.js} +1 -1
  7. package/dist/{catalog-sync-C6jv_xoa.mjs → catalog-sync-Z1uWs5Ge.mjs} +1 -1
  8. package/dist/cli/utilities/build/common/front-component-build/css-injection-plugin.d.ts +1 -2
  9. package/dist/cli/utilities/build/common/front-component-build/utils/unwrap-define-front-component-to-direct-export.d.ts +1 -1
  10. package/dist/cli.cjs +11 -11
  11. package/dist/cli.mjs +113 -113
  12. package/dist/{compile-application-BFhqkVqO.js → compile-application-BPxjs2Co.js} +5 -5
  13. package/dist/{compile-application-B2LfsDBX.mjs → compile-application-CU3rJlps.mjs} +1380 -1376
  14. package/dist/define/index.cjs +15 -12
  15. package/dist/define/index.cjs.map +1 -1
  16. package/dist/define/index.d.ts +22 -5
  17. package/dist/define/index.mjs +5555 -5128
  18. package/dist/define/index.mjs.map +1 -1
  19. package/dist/front-component/index.cjs +1 -1
  20. package/dist/front-component/index.cjs.map +1 -1
  21. package/dist/front-component/index.d.ts +6 -1
  22. package/dist/front-component/index.mjs +26 -15
  23. package/dist/front-component/index.mjs.map +1 -1
  24. package/dist/front-component-renderer/build.cjs +1 -1
  25. package/dist/front-component-renderer/build.mjs +1 -1
  26. package/dist/get-front-component-build-plugins-B0LNjbg4.js +883 -0
  27. package/dist/{get-front-component-build-plugins-QXeU8MwC.mjs → get-front-component-build-plugins-CnwC-jU8.mjs} +7178 -6721
  28. package/dist/logic-function/index.cjs.map +1 -1
  29. package/dist/logic-function/index.mjs.map +1 -1
  30. package/dist/{login-_eABINVq.mjs → login-CNV69o8l.mjs} +466 -466
  31. package/dist/{login-DkjpI4jn.js → login-CbjId2Zl.js} +9 -9
  32. package/dist/operations.cjs +1 -1
  33. package/dist/operations.mjs +2 -2
  34. package/dist/{package-DftRfrG7.mjs → package-CEEl5qZD.mjs} +6 -1
  35. package/dist/package-RzehG8GA.js +1 -0
  36. package/dist/{typecheck-application-DIe_vwjU.mjs → typecheck-application-aR7mCSHB.mjs} +1 -1
  37. package/package.json +8 -3
  38. package/dist/get-front-component-build-plugins-BcUjFnki.js +0 -880
  39. package/dist/package-vtLsH5RS.js +0 -1
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("./isDefined-Dtu5EYqP-CGZoVWsO.js"),t=require("./compile-application-BFhqkVqO.js"),n=require("./get-front-component-build-plugins-BcUjFnki.js"),r=require("./login-DkjpI4jn.js"),i=require("./package-vtLsH5RS.js");let a=require("path");a=e.i(a);let o=require("@sniptt/guards"),s=require("uuid"),c=require("react");c=e.i(c);let l=require("crypto");l=e.i(l);let u=require("node:fs/promises"),d=require("node:path");d=e.i(d);let f=require("node:child_process"),p=require("chalk");p=e.i(p);let m=require("inquirer");m=e.i(m);let h=require("chokidar");h=e.i(h);let g=require("react/jsx-runtime"),_=require("commander"),v=require("util");var y=e=>e&&!e?.startsWith(`/`)?(0,a.join)(t.U,e):e,b=async e=>{let n=(0,a.join)(e,`package.json`);if(await t.R(n))try{let e=await(0,u.readFile)(n,`utf-8`),t=JSON.parse(e);return t.dependencies?.[`twenty-sdk`]??t.devDependencies?.[`twenty-sdk`]??void 0}catch{return}},x=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},S=async e=>{let t=i.t.version,n=await b(e);if(!t||!n)return;let r=x(t),a=x(n);r===null||a===null||r!==a&&(console.warn(p.default.yellow(`⚠ Version mismatch: your app requires twenty-sdk@${a}.x but the CLI running is v${t}. Major version mismatches may cause unexpected behavior.\n Update with: npm install -g twenty-sdk@${a}`)),console.warn(``))},ee=class{async execute(e){e.private?await this.executePrivate(e):await this.executeNpm(e)}async executeNpm(e){let n=e.appPath??t.U;await S(n),console.log(p.default.blue(`Publishing to npm...`)),console.log(p.default.gray(`App path: ${n}\n`));let i=await r.G({appPath:n,npmTag:e.tag,onProgress:e=>console.log(p.default.gray(e))});i.success||(console.error(p.default.red(i.error.message)),process.exit(1)),console.log(p.default.green(`✓ Published to npm successfully`))}async executePrivate(e){let n=e.appPath??t.U;await S(n);let i=e.remote??r.Z.getActiveRemote();console.log(p.default.blue(`Deploying application on ${i}...`)),console.log(p.default.gray(`App path: ${n}\n`));let o=e=>console.log(p.default.gray(e)),s=await r.$({appPath:n,tarball:!0,onProgress:o});s.success||(console.error(p.default.red(s.error.message)),process.exit(1));let c=await r.K({tarballPath:s.data.tarballPath,remote:e.remote,onProgress:o});c.success||(console.error(p.default.red(c.error.message)),process.exit(1));let l=await t.z(a.default.join(n,`package.json`)).catch(()=>void 0),u=l?.name??c.data.name,d=l?.version??`unknown`;console.log(p.default.green(`\n✓ Published ${u} 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.U;await S(n),await r.O();let i=e.remote??r.Z.getActiveRemote();console.log(p.default.blue(`Installing application on ${i}...`)),console.log(p.default.gray(`App path: ${n}\n`));let a=await r.H({appPath:n,remote:e.remote});a.success||(console.error(p.default.red(a.error.message)),process.exit(1)),console.log(p.default.green(`✓ Application installed`))}},te=class{async execute({appPath:e=t.U,askForConfirmation:n}){let i=r.Z.getActiveRemote();console.log(p.default.blue(`🚀 Uninstall Twenty Application on ${i}`)),console.log(p.default.gray(`📁 App Path: ${e}\n`)),n&&!await this.confirmationPrompt()&&(console.error(p.default.red(`⛔️ Aborting uninstall`)),process.exit(1));let a=await r.D({appPath:e});return a.success?(console.log(p.default.green(`✅ Application uninstalled successfully`)),{success:!0,data:void 0}):(console.error(p.default.red(`❌ Uninstall failed:`),a.error.message),{success:!1,error:a.error.message})}async confirmationPrompt(){let{confirmation:e}=await m.default.prompt([{type:`confirm`,name:`confirmation`,message:`Are you sure you want to uninstall this application?`,default:!1}]);return e}},ne=e=>{let t=new ee,n=new C,r=new te;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:y(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:y(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:y(e),askForConfirmation:!t?.yes});process.exit(+!n.success)}catch{process.exit(1)}})},re=[`src/application.config.ts`,`src/application-config.ts`,`src/applicationConfig.ts`],ie=async e=>{for(let n of re){let r=(0,a.join)(e,n);if(await t.R(r))return r}return null},ae=async e=>{let n=await ie(e);if(n===null)throw Error(`Could not find the application config file (expected one of: ${re.join(`, `)}). Create it with defineApplication({ universalIdentifier: ... }) before generating entities.`);let{config:r}=await t.u({appPath:e,filePath:n});if(!r?.universalIdentifier)throw Error(`defineApplication in ${n} must declare a universalIdentifier before generating entities.`);return r.universalIdentifier},oe=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,ee=64,C=128,te=256,ne=512,re=30,ie=`...`,ae=800,oe=16,se=1,ce=2,le=3,ue=1/0,de=9007199254740991,fe=17976931348623157e292,pe=NaN,me=4294967295,he=me-1,ge=me>>>1,_e=[[`ary`,C],[`bind`,_],[`bindKey`,v],[`curry`,b],[`curryRight`,x],[`flip`,ne],[`partial`,S],[`partialRight`,ee],[`rearg`,te]],ve=`[object Arguments]`,ye=`[object Array]`,be=`[object AsyncFunction]`,xe=`[object Boolean]`,Se=`[object Date]`,Ce=`[object DOMException]`,we=`[object Error]`,Te=`[object Function]`,Ee=`[object GeneratorFunction]`,De=`[object Map]`,Oe=`[object Number]`,ke=`[object Null]`,Ae=`[object Object]`,je=`[object Promise]`,Me=`[object Proxy]`,Ne=`[object RegExp]`,Pe=`[object Set]`,Fe=`[object String]`,Ie=`[object Symbol]`,Le=`[object Undefined]`,Re=`[object WeakMap]`,ze=`[object WeakSet]`,w=`[object ArrayBuffer]`,Be=`[object DataView]`,Ve=`[object Float32Array]`,He=`[object Float64Array]`,Ue=`[object Int8Array]`,We=`[object Int16Array]`,Ge=`[object Int32Array]`,Ke=`[object Uint8Array]`,qe=`[object Uint8ClampedArray]`,Je=`[object Uint16Array]`,Ye=`[object Uint32Array]`,Xe=/\b__p \+= '';/g,Ze=/\b(__p \+=) '' \+/g,Qe=/(__e\(.*?\)|\b__t\)) \+\n'';/g,$e=/&(?:amp|lt|gt|quot|#39);/g,et=/[&<>"']/g,tt=RegExp($e.source),nt=RegExp(et.source),rt=/<%-([\s\S]+?)%>/g,it=/<%([\s\S]+?)%>/g,at=/<%=([\s\S]+?)%>/g,ot=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,st=/^\w*$/,ct=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,lt=/[\\^$.*+?()[\]{}|]/g,ut=RegExp(lt.source),dt=/^\s+/,T=/\s/,ft=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,pt=/\{\n\/\* \[wrapped with (.+)\] \*/,mt=/,? & /,ht=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,gt=/[()=,{}\[\]\/\s]/,_t=/\\(\\)?/g,vt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,yt=/\w*$/,bt=/^[-+]0x[0-9a-f]+$/i,xt=/^0b[01]+$/i,St=/^\[object .+?Constructor\]$/,Ct=/^0o[0-7]+$/i,wt=/^(?:0|[1-9]\d*)$/,Tt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Et=/($^)/,Dt=/['\n\r\u2028\u2029\\]/g,Ot=`\\ud800-\\udfff`,kt=`\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff`,At=`\\u2700-\\u27bf`,E=`a-z\\xdf-\\xf6\\xf8-\\xff`,jt=`\\xac\\xb1\\xd7\\xf7`,D=`\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf`,O=`\\u2000-\\u206f`,Mt=` \\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`,Nt=`A-Z\\xc0-\\xd6\\xd8-\\xde`,Pt=`\\ufe0e\\ufe0f`,Ft=jt+D+O+Mt,It=`['’]`,k=`[`+Ot+`]`,Lt=`[`+Ft+`]`,Rt=`[`+kt+`]`,zt=`\\d+`,Bt=`[`+At+`]`,Vt=`[`+E+`]`,Ht=`[^`+Ot+Ft+zt+At+E+Nt+`]`,Ut=`\\ud83c[\\udffb-\\udfff]`,Wt=`(?:`+Rt+`|`+Ut+`)`,Gt=`[^`+Ot+`]`,Kt=`(?:\\ud83c[\\udde6-\\uddff]){2}`,qt=`[\\ud800-\\udbff][\\udc00-\\udfff]`,Jt=`[`+Nt+`]`,Yt=`\\u200d`,Xt=`(?:`+Vt+`|`+Ht+`)`,Zt=`(?:`+Jt+`|`+Ht+`)`,Qt=`(?:`+It+`(?:d|ll|m|re|s|t|ve))?`,$t=`(?:`+It+`(?:D|LL|M|RE|S|T|VE))?`,en=Wt+`?`,tn=`[`+Pt+`]?`,nn=`(?:`+Yt+`(?:`+[Gt,Kt,qt].join(`|`)+`)`+tn+en+`)*`,rn=`\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])`,an=`\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])`,on=tn+en+nn,sn=`(?:`+[Bt,Kt,qt].join(`|`)+`)`+on,cn=`(?:`+[Gt+Rt+`?`,Rt,Kt,qt,k].join(`|`)+`)`,ln=RegExp(It,`g`),un=RegExp(Rt,`g`),dn=RegExp(Ut+`(?=`+Ut+`)|`+cn+on,`g`),fn=RegExp([Jt+`?`+Vt+`+`+Qt+`(?=`+[Lt,Jt,`$`].join(`|`)+`)`,Zt+`+`+$t+`(?=`+[Lt,Jt+Xt,`$`].join(`|`)+`)`,Jt+`?`+Xt+`+`+Qt,Jt+`+`+$t,an,rn,zt,sn].join(`|`),`g`),pn=RegExp(`[`+Yt+Ot+kt+Pt+`]`),A=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,mn=`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(`.`),hn=-1,j={};j[Ve]=j[He]=j[Ue]=j[We]=j[Ge]=j[Ke]=j[qe]=j[Je]=j[Ye]=!0,j[ve]=j[ye]=j[w]=j[xe]=j[Be]=j[Se]=j[we]=j[Te]=j[De]=j[Oe]=j[Ae]=j[Ne]=j[Pe]=j[Fe]=j[Re]=!1;var M={};M[ve]=M[ye]=M[w]=M[Be]=M[xe]=M[Se]=M[Ve]=M[He]=M[Ue]=M[We]=M[Ge]=M[De]=M[Oe]=M[Ae]=M[Ne]=M[Pe]=M[Fe]=M[Ie]=M[Ke]=M[qe]=M[Je]=M[Ye]=!0,M[we]=M[Te]=M[Re]=!1;var N={À:`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`},gn={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},_n={"&amp;":`&`,"&lt;":`<`,"&gt;":`>`,"&quot;":`"`,"&#39;":`'`},vn={"\\":`\\`,"'":`'`,"\n":`n`,"\r":`r`,"\u2028":`u2028`,"\u2029":`u2029`},yn=parseFloat,bn=parseInt,xn=typeof global==`object`&&global&&global.Object===Object&&global,Sn=typeof self==`object`&&self&&self.Object===Object&&self,P=xn||Sn||Function(`return this`)(),Cn=typeof e==`object`&&e&&!e.nodeType&&e,wn=Cn&&typeof t==`object`&&t&&!t.nodeType&&t,Tn=wn&&wn.exports===Cn,En=Tn&&xn.process,F=function(){try{return wn&&wn.require&&wn.require(`util`).types||En&&En.binding&&En.binding(`util`)}catch{}}(),Dn=F&&F.isArrayBuffer,On=F&&F.isDate,kn=F&&F.isMap,An=F&&F.isRegExp,jn=F&&F.isSet,Mn=F&&F.isTypedArray;function Nn(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 Pn(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 Fn(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}function In(e,t){for(var n=e==null?0:e.length;n--&&t(e[n],n,e)!==!1;);return e}function Ln(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 Rn(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 zn(e,t){return!!(e!=null&&e.length)&&Xn(e,t,0)>-1}function Bn(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 I(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 Vn(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function Hn(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 Un(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 Wn(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 Gn=er(`length`);function Kn(e){return e.split(``)}function qn(e){return e.match(ht)||[]}function Jn(e,t,n){var r;return n(e,function(e,n,i){if(t(e,n,i))return r=n,!1}),r}function Yn(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 Xn(e,t,n){return t===t?Er(e,t,n):Yn(e,Qn,n)}function Zn(e,t,n,r){for(var i=n-1,a=e.length;++i<a;)if(r(e[i],t))return i;return-1}function Qn(e){return e!==e}function $n(e,t){var n=e==null?0:e.length;return n?ir(e,t)/n:pe}function er(e){return function(t){return t==null?n:t[e]}}function tr(e){return function(t){return e==null?n:e[t]}}function nr(e,t,n,r,i){return i(e,function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)}),n}function rr(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}function ir(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 ar(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function or(e,t){return I(t,function(t){return[t,e[t]]})}function sr(e){return e&&e.slice(0,Ar(e)+1).replace(dt,``)}function cr(e){return function(t){return e(t)}}function lr(e,t){return I(t,function(t){return e[t]})}function ur(e,t){return e.has(t)}function dr(e,t){for(var n=-1,r=e.length;++n<r&&Xn(t,e[n],0)>-1;);return n}function fr(e,t){for(var n=e.length;n--&&Xn(t,e[n],0)>-1;);return n}function pr(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}var mr=tr(N),hr=tr(gn);function gr(e){return`\\`+vn[e]}function _r(e,t){return e==null?n:e[t]}function vr(e){return pn.test(e)}function yr(e){return A.test(e)}function br(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}function xr(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function Sr(e,t){return function(n){return e(t(n))}}function Cr(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 wr(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}function Tr(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=[e,e]}),n}function Er(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}function Dr(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}function Or(e){return vr(e)?Mr(e):Gn(e)}function kr(e){return vr(e)?Nr(e):Kn(e)}function Ar(e){for(var t=e.length;t--&&T.test(e.charAt(t)););return t}var jr=tr(_n);function Mr(e){for(var t=dn.lastIndex=0;dn.test(e);)++t;return t}function Nr(e){return e.match(dn)||[]}function Pr(e){return e.match(fn)||[]}var Fr=(function e(t){t=t==null?P:Fr.defaults(P.Object(),t,Fr.pick(P,mn));var T=t.Array,ht=t.Date,Ot=t.Error,kt=t.Function,At=t.Math,E=t.Object,jt=t.RegExp,D=t.String,O=t.TypeError,Mt=T.prototype,Nt=kt.prototype,Pt=E.prototype,Ft=t[`__core-js_shared__`],It=Nt.toString,k=Pt.hasOwnProperty,Lt=0,Rt=function(){var e=/[^.]+$/.exec(Ft&&Ft.keys&&Ft.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}(),zt=Pt.toString,Bt=It.call(E),Vt=P._,Ht=jt(`^`+It.call(k).replace(lt,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`),Ut=Tn?t.Buffer:n,Wt=t.Symbol,Gt=t.Uint8Array,Kt=Ut?Ut.allocUnsafe:n,qt=Sr(E.getPrototypeOf,E),Jt=E.create,Yt=Pt.propertyIsEnumerable,Xt=Mt.splice,Zt=Wt?Wt.isConcatSpreadable:n,Qt=Wt?Wt.iterator:n,$t=Wt?Wt.toStringTag:n,en=function(){try{var e=is(E,`defineProperty`);return e({},``,{}),e}catch{}}(),tn=t.clearTimeout!==P.clearTimeout&&t.clearTimeout,nn=ht&&ht.now!==P.Date.now&&ht.now,rn=t.setTimeout!==P.setTimeout&&t.setTimeout,an=At.ceil,on=At.floor,sn=E.getOwnPropertySymbols,cn=Ut?Ut.isBuffer:n,dn=t.isFinite,fn=Mt.join,pn=Sr(E.keys,E),A=At.max,N=At.min,gn=ht.now,_n=t.parseInt,vn=At.random,xn=Mt.reverse,Sn=is(t,`DataView`),Cn=is(t,`Map`),wn=is(t,`Promise`),En=is(t,`Set`),F=is(t,`WeakMap`),Gn=is(E,`create`),Kn=F&&new F,tr={},Er=Vs(Sn),Mr=Vs(Cn),Nr=Vs(wn),Ir=Vs(En),Lr=Vs(F),Rr=Wt?Wt.prototype:n,zr=Rr?Rr.valueOf:n,Br=Rr?Rr.toString:n;function L(e){if(X(e)&&!K(e)&&!(e instanceof R)){if(e instanceof Ur)return e;if(k.call(e,`__wrapped__`))return Us(e)}return new Ur(e)}var Vr=function(){function e(){}return function(t){if(!Y(t))return{};if(Jt)return Jt(t);e.prototype=t;var r=new e;return e.prototype=n,r}}();function Hr(){}function Ur(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=n}L.templateSettings={escape:rt,evaluate:it,interpolate:at,variable:``,imports:{_:L}},L.prototype=Hr.prototype,L.prototype.constructor=L,Ur.prototype=Vr(Hr.prototype),Ur.prototype.constructor=Ur;function R(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=me,this.__views__=[]}function Wr(){var e=new R(this.__wrapped__);return e.__actions__=H(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=H(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=H(this.__views__),e}function Gr(){if(this.__filtered__){var e=new R(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Kr(){var e=this.__wrapped__.value(),t=this.__dir__,n=K(e),r=t<0,i=n?e.length:0,a=cs(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=N(c,this.__takeCount__);if(!n||!r&&i==c&&p==c)return Za(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==ce)g=b;else if(!b){if(y==se)continue outer;break outer}}m[f++]=g}return m}R.prototype=Vr(Hr.prototype),R.prototype.constructor=R;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__=Gn?Gn(null):{},this.size=0}function Yr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}function Xr(e){var t=this.__data__;if(Gn){var r=t[e];return r===l?n:r}return k.call(t,e)?t[e]:n}function Zr(e){var t=this.__data__;return Gn?t[e]!==n:k.call(t,e)}function Qr(e,t){var r=this.__data__;return this.size+=+!this.has(e),r[e]=Gn&&t===n?l: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.__data__=[],this.size=0}function ti(e){var t=this.__data__,n=Ei(t,e);return n<0?!1:(n==t.length-1?t.pop():Xt.call(t,n,1),--this.size,!0)}function ni(e){var t=this.__data__,r=Ei(t,e);return r<0?n:t[r][1]}function ri(e){return Ei(this.__data__,e)>-1}function ii(e,t){var n=this.__data__,r=Ei(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,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.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function oi(){this.size=0,this.__data__={hash:new qr,map:new(Cn||$r),string:new qr}}function si(e){var t=ns(this,e).delete(e);return this.size-=+!!t,t}function ci(e){return ns(this,e).get(e)}function li(e){return ns(this,e).has(e)}function ui(e,t){var n=ns(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}ai.prototype.clear=oi,ai.prototype.delete=si,ai.prototype.get=ci,ai.prototype.has=li,ai.prototype.set=ui;function di(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new ai;++t<n;)this.add(e[t])}function fi(e){return this.__data__.set(e,l),this}function pi(e){return this.__data__.has(e)}di.prototype.add=di.prototype.push=fi,di.prototype.has=pi;function mi(e){var t=this.__data__=new $r(e);this.size=t.size}function hi(){this.__data__=new $r,this.size=0}function gi(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function _i(e){return this.__data__.get(e)}function vi(e){return this.__data__.has(e)}function yi(e,t){var n=this.__data__;if(n instanceof $r){var r=n.__data__;if(!Cn||r.length<i-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ai(r)}return n.set(e,t),this.size=n.size,this}mi.prototype.clear=hi,mi.prototype.delete=gi,mi.prototype.get=_i,mi.prototype.has=vi,mi.prototype.set=yi;function bi(e,t){var n=K(e),r=!n&&gu(e),i=!n&&!r&&yu(e),a=!n&&!r&&!i&&Wu(e),o=n||r||i||a,s=o?ar(e.length,D):[],c=s.length;for(var l in e)(t||k.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||gs(l,c)))&&s.push(l);return s}function xi(e){var t=e.length;return t?e[ja(0,t-1)]:n}function Si(e,t){return Rs(H(e),Mi(t,0,e.length))}function Ci(e){return Rs(H(e))}function wi(e,t,r){(r!==n&&!pu(e[t],r)||r===n&&!(t in e))&&Ai(e,t,r)}function Ti(e,t,r){var i=e[t];(!(k.call(e,t)&&pu(i,r))||r===n&&!(t in e))&&Ai(e,t,r)}function Ei(e,t){for(var n=e.length;n--;)if(pu(e[n][0],t))return n;return-1}function Di(e,t,n,r){return Ri(e,function(e,i,a){t(r,e,n(e),a)}),r}function Oi(e,t){return e&&_o(t,$(t),e)}function ki(e,t){return e&&_o(t,wd(t),e)}function Ai(e,t,n){t==`__proto__`&&en?en(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function ji(e,t){for(var r=-1,i=t.length,a=T(i),o=e==null;++r<i;)a[r]=o?n:vd(e,t[r]);return a}function Mi(e,t,r){return e===e&&(r!==n&&(e=e<=r?e:r),t!==n&&(e=e>=t?e:t)),e}function Ni(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(!Y(e))return e;var d=K(e);if(d){if(s=ds(e),!c)return H(e,s)}else{var h=W(e),g=h==Te||h==Ee;if(yu(e))return oo(e,c);if(h==Ae||h==ve||g&&!a){if(s=l||g?{}:fs(e),!c)return l?yo(e,ki(s,e)):vo(e,Oi(s,e))}else{if(!M[h])return a?e:{};s=ps(e,h,c)}}o||=new mi;var _=o.get(e);if(_)return _;o.set(e,s),Vu(e)?e.forEach(function(n){s.add(Ni(n,t,r,n,e,o))}):Au(e)&&e.forEach(function(n,i){s.set(i,Ni(n,t,r,i,e,o))});var v=d?n:(u?l?Qo:Zo:l?wd:$)(e);return Fn(v||e,function(n,i){v&&(i=n,n=e[i]),Ti(s,i,Ni(n,t,r,i,e,o))}),s}function Pi(e){var t=$(e);return function(n){return Fi(n,e,t)}}function Fi(e,t,r){var i=r.length;if(e==null)return!i;for(e=E(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 Ii(e,t,r){if(typeof e!=`function`)throw new O(o);return Ps(function(){e.apply(n,r)},t)}function Li(e,t,n,r){var a=-1,o=zn,s=!0,c=e.length,l=[],u=t.length;if(!c)return l;n&&(t=I(t,cr(n))),r?(o=Bn,s=!1):t.length>=i&&(o=ur,s=!1,t=new di(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 Ri=So(Ki),zi=So(qi,!0);function Bi(e,t){var n=!0;return Ri(e,function(e,r,i){return n=!!t(e,r,i),n}),n}function Vi(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&&!Uu(s):r(s,c)))var c=s,l=o}return l}function Hi(e,t,r,i){var a=e.length;for(r=Z(r),r<0&&(r=-r>a?0:a+r),i=i===n||i>a?a:Z(i),i<0&&(i+=a),i=r>i?0:Qu(i);r<i;)e[r++]=t;return e}function Ui(e,t){var n=[];return Ri(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function z(e,t,n,r,i){var a=-1,o=e.length;for(n||=hs,i||=[];++a<o;){var s=e[a];t>0&&n(s)?t>1?z(s,t-1,n,r,i):Vn(i,s):r||(i[i.length]=s)}return i}var Wi=Co(),Gi=Co(!0);function Ki(e,t){return e&&Wi(e,t,$)}function qi(e,t){return e&&Gi(e,t,$)}function Ji(e,t){return Rn(t,function(t){return Du(e[t])})}function Yi(e,t){t=no(t,e);for(var r=0,i=t.length;e!=null&&r<i;)e=e[Bs(t[r++])];return r&&r==i?e:n}function Xi(e,t,n){var r=t(e);return K(e)?r:Vn(r,n(e))}function B(e){return e==null?e===n?Le:ke:$t&&$t in E(e)?as(e):Os(e)}function Zi(e,t){return e>t}function Qi(e,t){return e!=null&&k.call(e,t)}function $i(e,t){return e!=null&&t in E(e)}function ea(e,t,n){return e>=N(t,n)&&e<A(t,n)}function ta(e,t,r){for(var i=r?Bn:zn,a=e[0].length,o=e.length,s=o,c=T(o),l=1/0,u=[];s--;){var d=e[s];s&&t&&(d=I(d,cr(t))),l=N(d.length,l),c[s]=!r&&(t||a>=120&&d.length>=120)?new di(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?ur(p,h):i(u,h,r))){for(s=o;--s;){var g=c[s];if(!(g?ur(g,h):i(e[s],h,r)))continue outer}p&&p.push(h),u.push(m)}}return u}function na(e,t,n,r){return Ki(e,function(e,i,a){t(r,n(e),i,a)}),r}function ra(e,t,r){t=no(t,e),e=As(e,t);var i=e==null?e:e[Bs(mc(t))];return i==null?n:Nn(i,e,r)}function ia(e){return X(e)&&B(e)==ve}function aa(e){return X(e)&&B(e)==w}function oa(e){return X(e)&&B(e)==Se}function sa(e,t,n,r,i){return e===t?!0:e==null||t==null||!X(e)&&!X(t)?e!==e&&t!==t:ca(e,t,n,r,sa,i)}function ca(e,t,n,r,i,a){var o=K(e),s=K(t),c=o?ye:W(e),l=s?ye:W(t);c=c==ve?Ae:c,l=l==ve?Ae:l;var u=c==Ae,d=l==Ae,f=c==l;if(f&&yu(e)){if(!yu(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new mi,o||Wu(e)?qo(e,t,n,r,i,a):Jo(e,t,c,n,r,i,a);if(!(n&h)){var p=u&&k.call(e,`__wrapped__`),m=d&&k.call(t,`__wrapped__`);if(p||m){var g=p?e.value():e,_=m?t.value():t;return a||=new mi,i(g,_,n,r,a)}}return f?(a||=new mi,Yo(e,t,n,r,i,a)):!1}function la(e){return X(e)&&W(e)==De}function ua(e,t,r,i){var a=r.length,o=a,s=!i;if(e==null)return!o;for(e=E(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 mi;if(i)var p=i(u,d,l,e,t,f);if(!(p===n?sa(d,u,h|g,i,f):p))return!1}}return!0}function da(e){return!Y(e)||bs(e)?!1:(Du(e)?Ht:St).test(Vs(e))}function fa(e){return X(e)&&B(e)==Ne}function pa(e){return X(e)&&W(e)==Pe}function ma(e){return X(e)&&ku(e.length)&&!!j[B(e)]}function ha(e){return typeof e==`function`?e:e==null?Mf:typeof e==`object`?K(e)?xa(e[0],e[1]):ba(e):Gf(e)}function ga(e){if(!Ss(e))return pn(e);var t=[];for(var n in E(e))k.call(e,n)&&n!=`constructor`&&t.push(n);return t}function _a(e){if(!Y(e))return Ds(e);var t=Ss(e),n=[];for(var r in e)r==`constructor`&&(t||!k.call(e,r))||n.push(r);return n}function va(e,t){return e<t}function ya(e,t){var n=-1,r=q(e)?T(e.length):[];return Ri(e,function(e,i,a){r[++n]=t(e,i,a)}),r}function ba(e){var t=rs(e);return t.length==1&&t[0][2]?ws(t[0][0],t[0][1]):function(n){return n===e||ua(n,e,t)}}function xa(e,t){return _s(e)&&Cs(t)?ws(Bs(e),t):function(r){var i=vd(r,e);return i===n&&i===t?bd(r,e):sa(t,i,h|g)}}function Sa(e,t,r,i,a){e!==t&&Wi(t,function(o,s){if(a||=new mi,Y(o))Ca(e,t,s,r,Sa,i,a);else{var c=i?i(Ms(e,s),o,s+``,e,t,a):n;c===n&&(c=o),wi(e,s,c)}},wd)}function Ca(e,t,r,i,a,o,s){var c=Ms(e,r),l=Ms(t,r),u=s.get(l);if(u){wi(e,r,u);return}var d=o?o(c,l,r+``,e,t,s):n,f=d===n;if(f){var p=K(l),m=!p&&yu(l),h=!p&&!m&&Wu(l);d=l,p||m||h?K(c)?d=c:J(c)?d=H(c):m?(f=!1,d=oo(l,!0)):h?(f=!1,d=fo(l,!0)):d=[]:Ru(l)||gu(l)?(d=c,gu(c)?d=ed(c):(!Y(c)||Du(c))&&(d=fs(l))):f=!1}f&&(s.set(l,d),a(d,l,i,o,s),s.delete(l)),wi(e,r,d)}function wa(e,t){var r=e.length;if(r)return t+=t<0?r:0,gs(t,r)?e[t]:n}function Ta(e,t,n){t=t.length?I(t,function(e){return K(e)?function(t){return Yi(t,e.length===1?e[0]:e)}:e}):[Mf];var r=-1;return t=I(t,cr(U())),rr(ya(e,function(e,n,i){return{criteria:I(t,function(t){return t(e)}),index:++r,value:e}}),function(e,t){return mo(e,t,n)})}function Ea(e,t){return Da(e,t,function(t,n){return bd(e,n)})}function Da(e,t,n){for(var r=-1,i=t.length,a={};++r<i;){var o=t[r],s=Yi(e,o);n(s,o)&&Ia(a,no(o,e),s)}return a}function Oa(e){return function(t){return Yi(t,e)}}function ka(e,t,n,r){var i=r?Zn:Xn,a=-1,o=t.length,s=e;for(e===t&&(t=H(t)),n&&(s=I(e,cr(n)));++a<o;)for(var c=0,l=t[a],u=n?n(l):l;(c=i(s,u,c,r))>-1;)s!==e&&Xt.call(s,c,1),Xt.call(e,c,1);return e}function Aa(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;gs(i)?Xt.call(e,i,1):Ja(e,i)}}return e}function ja(e,t){return e+on(vn()*(t-e+1))}function Ma(e,t,n,r){for(var i=-1,a=A(an((t-e)/(n||1)),0),o=T(a);a--;)o[r?a:++i]=e,e+=n;return o}function Na(e,t){var n=``;if(!e||t<1||t>de)return n;do t%2&&(n+=e),t=on(t/2),t&&(e+=e);while(t);return n}function V(e,t){return Fs(ks(e,t,Mf),e+``)}function Pa(e){return xi(Hd(e))}function Fa(e,t){var n=Hd(e);return Rs(n,Mi(t,0,n.length))}function Ia(e,t,r,i){if(!Y(e))return e;t=no(t,e);for(var a=-1,o=t.length,s=o-1,c=e;c!=null&&++a<o;){var l=Bs(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=Y(d)?d:gs(t[a+1])?[]:{})}Ti(c,l,u),c=c[l]}return e}var La=Kn?function(e,t){return Kn.set(e,t),e}:Mf,Ra=en?function(e,t){return en(e,`toString`,{configurable:!0,enumerable:!1,value:Of(t),writable:!0})}:Mf;function za(e){return Rs(Hd(e))}function Ba(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=T(i);++r<i;)a[r]=e[r+t];return a}function Va(e,t){var n;return Ri(e,function(e,r,i){return n=t(e,r,i),!n}),!!n}function Ha(e,t,n){var r=0,i=e==null?r:e.length;if(typeof t==`number`&&t===t&&i<=ge){for(;r<i;){var a=r+i>>>1,o=e[a];o!==null&&!Uu(o)&&(n?o<=t:o<t)?r=a+1:i=a}return i}return Ua(e,t,Mf,n)}function Ua(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=Uu(t),u=t===n;a<o;){var d=on((a+o)/2),f=r(e[d]),p=f!==n,m=f===null,h=f===f,g=Uu(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 N(o,he)}function Wa(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||!pu(s,c)){var c=s;a[i++]=o===0?0:o}}return a}function Ga(e){return typeof e==`number`?e:Uu(e)?pe:+e}function Ka(e){if(typeof e==`string`)return e;if(K(e))return I(e,Ka)+``;if(Uu(e))return Br?Br.call(e):``;var t=e+``;return t==`0`&&1/e==-ue?`-0`:t}function qa(e,t,n){var r=-1,a=zn,o=e.length,s=!0,c=[],l=c;if(n)s=!1,a=Bn;else if(o>=i){var u=t?null:Vo(e);if(u)return wr(u);s=!1,a=ur,l=new di}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 Ja(e,t){t=no(t,e);var n=-1,r=t.length;if(!r)return!0;for(;++n<r;){var i=Bs(t[n]);if(i===`__proto__`&&!k.call(e,`__proto__`)||(i===`constructor`||i===`prototype`)&&n<r-1)return!1}var a=As(e,t);return a==null||delete a[Bs(mc(t))]}function Ya(e,t,n,r){return Ia(e,t,n(Yi(e,t)),r)}function Xa(e,t,n,r){for(var i=e.length,a=r?i:-1;(r?a--:++a<i)&&t(e[a],a,e););return n?Ba(e,r?0:a,r?a+1:i):Ba(e,r?a+1:0,r?i:a)}function Za(e,t){var n=e;return n instanceof R&&(n=n.value()),Hn(t,function(e,t){return t.func.apply(t.thisArg,Vn([e],t.args))},n)}function Qa(e,t,n){var r=e.length;if(r<2)return r?qa(e[0]):[];for(var i=-1,a=T(r);++i<r;)for(var o=e[i],s=-1;++s<r;)s!=i&&(a[i]=Li(a[i]||o,e[s],t,n));return qa(z(a,1),t,n)}function $a(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 eo(e){return J(e)?e:[]}function to(e){return typeof e==`function`?e:Mf}function no(e,t){return K(e)?e:_s(e,t)?[e]:zs(Q(e))}var ro=V;function io(e,t,r){var i=e.length;return r=r===n?i:r,!t&&r>=i?e:Ba(e,t,r)}var ao=tn||function(e){return P.clearTimeout(e)};function oo(e,t){if(t)return e.slice();var n=e.length,r=Kt?Kt(n):new e.constructor(n);return e.copy(r),r}function so(e){var t=new e.constructor(e.byteLength);return new Gt(t).set(new Gt(e)),t}function co(e,t){var n=t?so(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function lo(e){var t=new e.constructor(e.source,yt.exec(e));return t.lastIndex=e.lastIndex,t}function uo(e){return zr?E(zr.call(e)):{}}function fo(e,t){var n=t?so(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function po(e,t){if(e!==t){var r=e!==n,i=e===null,a=e===e,o=Uu(e),s=t!==n,c=t===null,l=t===t,u=Uu(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 mo(e,t,n){for(var r=-1,i=e.criteria,a=t.criteria,o=i.length,s=n.length;++r<o;){var c=po(i[r],a[r]);if(c)return r>=s?c:c*(n[r]==`desc`?-1:1)}return e.index-t.index}function ho(e,t,n,r){for(var i=-1,a=e.length,o=n.length,s=-1,c=t.length,l=A(a-o,0),u=T(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 go(e,t,n,r){for(var i=-1,a=e.length,o=-1,s=n.length,c=-1,l=t.length,u=A(a-s,0),d=T(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 H(e,t){var n=-1,r=e.length;for(t||=T(r);++n<r;)t[n]=e[n];return t}function _o(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?Ai(r,c,l):Ti(r,c,l)}return r}function vo(e,t){return _o(e,os(e),t)}function yo(e,t){return _o(e,ss(e),t)}function bo(e,t){return function(n,r){var i=K(n)?Pn:Di,a=t?t():{};return i(n,e,U(r,2),a)}}function xo(e){return V(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&&G(r[0],r[1],s)&&(o=a<3?n:o,a=1),t=E(t);++i<a;){var c=r[i];c&&e(t,c,i,o)}return t})}function So(e,t){return function(n,r){if(n==null)return n;if(!q(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=E(n);(t?a--:++a<i)&&r(o[a],a,o)!==!1;);return n}}function Co(e){return function(t,n,r){for(var i=-1,a=E(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 wo(e,t,n){var r=t&_,i=Do(e);function a(){return(this&&this!==P&&this instanceof a?i:e).apply(r?n:this,arguments)}return a}function To(e){return function(t){t=Q(t);var r=vr(t)?kr(t):n,i=r?r[0]:t.charAt(0),a=r?io(r,1).join(``):t.slice(1);return i[e]()+a}}function Eo(e){return function(t){return Hn(Cf(Yd(t).replace(ln,``)),e,``)}}function Do(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=Vr(e.prototype),r=e.apply(n,t);return Y(r)?r:n}}function Oo(e,t,r){var i=Do(e);function a(){for(var o=arguments.length,s=T(o),c=o,l=ts(a);c--;)s[c]=arguments[c];var u=o<3&&s[0]!==l&&s[o-1]!==l?[]:Cr(s,l);return o-=u.length,o<r?zo(e,t,jo,a.placeholder,n,s,u,n,n,r-o):Nn(this&&this!==P&&this instanceof a?i:e,this,s)}return a}function ko(e){return function(t,r,i){var a=E(t);if(!q(t)){var o=U(r,3);t=$(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 Ao(e){return Xo(function(t){var r=t.length,i=r,a=Ur.prototype.thru;for(e&&t.reverse();i--;){var s=t[i];if(typeof s!=`function`)throw new O(o);if(a&&!c&&es(s)==`wrapper`)var c=new Ur([],!0)}for(i=c?i:r;++i<r;){s=t[i];var l=es(s),u=l==`wrapper`?$o(s):n;c=u&&ys(u[0])&&u[1]==(C|b|S|te)&&!u[4].length&&u[9]==1?c[es(u[0])].apply(c,u[3]):s.length==1&&ys(s)?c[l]():c.thru(s)}return function(){var e=arguments,n=e[0];if(c&&e.length==1&&K(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 jo(e,t,r,i,a,o,s,c,l,u){var d=t&C,f=t&_,p=t&v,m=t&(b|x),h=t&ne,g=p?n:Do(e);function y(){for(var n=arguments.length,_=T(n),v=n;v--;)_[v]=arguments[v];if(m)var b=ts(y),x=pr(_,b);if(i&&(_=ho(_,i,a,m)),o&&(_=go(_,o,s,m)),n-=x,m&&n<u){var S=Cr(_,b);return zo(e,t,jo,y.placeholder,r,_,S,c,l,u-n)}var ee=f?r:this,C=p?ee[e]:e;return n=_.length,c?_=js(_,c):h&&n>1&&_.reverse(),d&&l<n&&(_.length=l),this&&this!==P&&this instanceof y&&(C=g||Do(C)),C.apply(ee,_)}return y}function Mo(e,t){return function(n,r){return na(n,e,t(r),{})}}function No(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=Ka(r),i=Ka(i)):(r=Ga(r),i=Ga(i)),a=e(r,i)}return a}}function Po(e){return Xo(function(t){return t=I(t,cr(U())),V(function(n){var r=this;return e(t,function(e){return Nn(e,r,n)})})})}function Fo(e,t){t=t===n?` `:Ka(t);var r=t.length;if(r<2)return r?Na(t,e):t;var i=Na(t,an(e/Or(t)));return vr(t)?io(kr(i),0,e).join(``):i.slice(0,e)}function Io(e,t,n,r){var i=t&_,a=Do(e);function o(){for(var t=-1,s=arguments.length,c=-1,l=r.length,u=T(l+s),d=this&&this!==P&&this instanceof o?a:e;++c<l;)u[c]=r[c];for(;s--;)u[c++]=arguments[++t];return Nn(d,i?n:this,u)}return o}function Lo(e){return function(t,r,i){return i&&typeof i!=`number`&&G(t,r,i)&&(r=i=n),t=Zu(t),r===n?(r=t,t=0):r=Zu(r),i=i===n?t<r?1:-1:Zu(i),Ma(t,r,i,e)}}function Ro(e){return function(t,n){return typeof t==`string`&&typeof n==`string`||(t=$u(t),n=$u(n)),e(t,n)}}function zo(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:ee,t&=~(d?ee:S),t&y||(t&=~(_|v));var g=[e,t,a,m,f,h,p,c,l,u],x=r.apply(n,g);return ys(e)&&Ns(x,g),x.placeholder=i,Is(x,e,t)}function Bo(e){var t=At[e];return function(e,n){if(e=$u(e),n=n==null?0:N(Z(n),292),n&&dn(e)){var r=(Q(e)+`e`).split(`e`);return r=(Q(t(r[0]+`e`+(+r[1]+n)))+`e`).split(`e`),+(r[0]+`e`+(+r[1]-n))}return t(e)}}var Vo=En&&1/wr(new En([,-0]))[1]==ue?function(e){return new En(e)}:Bf;function Ho(e){return function(t){var n=W(t);return n==De?xr(t):n==Pe?Tr(t):or(t,e(t))}}function Uo(e,t,r,i,a,s,c,l){var u=t&v;if(!u&&typeof e!=`function`)throw new O(o);var d=i?i.length:0;if(d||(t&=~(S|ee),i=a=n),c=c===n?c:A(Z(c),0),l=l===n?l:Z(l),d-=a?a.length:0,t&ee){var f=i,p=a;i=a=n}var m=u?n:$o(e),h=[e,t,r,i,a,f,p,s,c,l];if(m&&Es(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:A(h[9]-d,0),!l&&t&(b|x)&&(t&=~(b|x)),!t||t==_)var g=wo(e,t,r);else g=t==b||t==x?Oo(e,t,l):(t==S||t==(_|S))&&!a.length?Io(e,t,r,i):jo.apply(n,h);return Is((m?La:Ns)(g,h),e,t)}function Wo(e,t,r,i){return e===n||pu(e,Pt[r])&&!k.call(i,r)?t:e}function Go(e,t,r,i,a,o){return Y(e)&&Y(t)&&(o.set(t,e),Sa(e,t,n,Go,o),o.delete(t)),e}function Ko(e){return Ru(e)?n:e}function qo(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 di: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(!Wn(t,function(e,t){if(!ur(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 Jo(e,t,n,r,i,a,o){switch(n){case Be:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case w:return!(e.byteLength!=t.byteLength||!a(new Gt(e),new Gt(t)));case xe:case Se:case Oe:return pu(+e,+t);case we:return e.name==t.name&&e.message==t.message;case Ne:case Fe:return e==t+``;case De:var s=xr;case Pe:var c=r&h;if(s||=wr,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=qo(s(e),s(t),r,i,a,o);return o.delete(e),u;case Ie:if(zr)return zr.call(e)==zr.call(t)}return!1}function Yo(e,t,r,i,a,o){var s=r&h,c=Zo(e),l=c.length;if(l!=Zo(t).length&&!s)return!1;for(var u=l;u--;){var d=c[u];if(!(s?d in t:k.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 Xo(e){return Fs(ks(e,n,rc),e+``)}function Zo(e){return Xi(e,$,os)}function Qo(e){return Xi(e,wd,ss)}var $o=Kn?function(e){return Kn.get(e)}:Bf;function es(e){for(var t=e.name+``,n=tr[t],r=k.call(tr,t)?n.length:0;r--;){var i=n[r],a=i.func;if(a==null||a==e)return i.name}return t}function ts(e){return(k.call(L,`placeholder`)?L:e).placeholder}function U(){var e=L.iteratee||Nf;return e=e===Nf?ha:e,arguments.length?e(arguments[0],arguments[1]):e}function ns(e,t){var n=e.__data__;return vs(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function rs(e){for(var t=$(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,Cs(i)]}return t}function is(e,t){var r=_r(e,t);return da(r)?r:n}function as(e){var t=k.call(e,$t),r=e[$t];try{e[$t]=n;var i=!0}catch{}var a=zt.call(e);return i&&(t?e[$t]=r:delete e[$t]),a}var os=sn?function(e){return e==null?[]:(e=E(e),Rn(sn(e),function(t){return Yt.call(e,t)}))}:Yf,ss=sn?function(e){for(var t=[];e;)Vn(t,os(e)),e=qt(e);return t}:Yf,W=B;(Sn&&W(new Sn(new ArrayBuffer(1)))!=Be||Cn&&W(new Cn)!=De||wn&&W(wn.resolve())!=je||En&&W(new En)!=Pe||F&&W(new F)!=Re)&&(W=function(e){var t=B(e),r=t==Ae?e.constructor:n,i=r?Vs(r):``;if(i)switch(i){case Er:return Be;case Mr:return De;case Nr:return je;case Ir:return Pe;case Lr:return Re}return t});function cs(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=N(t,e+o);break;case`takeRight`:e=A(e,t-o);break}}return{start:e,end:t}}function ls(e){var t=e.match(pt);return t?t[1].split(mt):[]}function us(e,t,n){t=no(t,e);for(var r=-1,i=t.length,a=!1;++r<i;){var o=Bs(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&&ku(i)&&gs(o,i)&&(K(e)||gu(e)))}function ds(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]==`string`&&k.call(e,`index`)&&(n.index=e.index,n.input=e.input),n}function fs(e){return typeof e.constructor==`function`&&!Ss(e)?Vr(qt(e)):{}}function ps(e,t,n){var r=e.constructor;switch(t){case w:return so(e);case xe:case Se:return new r(+e);case Be:return co(e,n);case Ve:case He:case Ue:case We:case Ge:case Ke:case qe:case Je:case Ye:return fo(e,n);case De:return new r;case Oe:case Fe:return new r(e);case Ne:return lo(e);case Pe:return new r;case Ie:return uo(e)}}function ms(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(ft,`{
2
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./isDefined-Dtu5EYqP-CGZoVWsO.js"),t=require("./compile-application-BPxjs2Co.js"),n=require("./get-front-component-build-plugins-B0LNjbg4.js"),r=require("./login-CbjId2Zl.js"),i=require("./package-RzehG8GA.js");let a=require("path");a=e.i(a);let o=require("@sniptt/guards"),s=require("uuid"),c=require("react");c=e.i(c);let l=require("crypto");l=e.i(l);let u=require("node:fs/promises"),d=require("node:path");d=e.i(d);let f=require("node:child_process"),p=require("chalk");p=e.i(p);let m=require("inquirer");m=e.i(m);let h=require("chokidar");h=e.i(h);let g=require("react/jsx-runtime"),_=require("commander"),v=require("util");var y=e=>e&&!e?.startsWith(`/`)?(0,a.join)(t.U,e):e,b=async e=>{let n=(0,a.join)(e,`package.json`);if(await t.R(n))try{let e=await(0,u.readFile)(n,`utf-8`),t=JSON.parse(e);return t.dependencies?.[`twenty-sdk`]??t.devDependencies?.[`twenty-sdk`]??void 0}catch{return}},x=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},S=async e=>{let t=i.t.version,n=await b(e);if(!t||!n)return;let r=x(t),a=x(n);r===null||a===null||r!==a&&(console.warn(p.default.yellow(`⚠ Version mismatch: your app requires twenty-sdk@${a}.x but the CLI running is v${t}. Major version mismatches may cause unexpected behavior.\n Update with: npm install -g twenty-sdk@${a}`)),console.warn(``))},ee=class{async execute(e){e.private?await this.executePrivate(e):await this.executeNpm(e)}async executeNpm(e){let n=e.appPath??t.U;await S(n),console.log(p.default.blue(`Publishing to npm...`)),console.log(p.default.gray(`App path: ${n}\n`));let i=await r.G({appPath:n,npmTag:e.tag,onProgress:e=>console.log(p.default.gray(e))});i.success||(console.error(p.default.red(i.error.message)),process.exit(1)),console.log(p.default.green(`✓ Published to npm successfully`))}async executePrivate(e){let n=e.appPath??t.U;await S(n);let i=e.remote??r.Z.getActiveRemote();console.log(p.default.blue(`Deploying application on ${i}...`)),console.log(p.default.gray(`App path: ${n}\n`));let o=e=>console.log(p.default.gray(e)),s=await r.$({appPath:n,tarball:!0,onProgress:o});s.success||(console.error(p.default.red(s.error.message)),process.exit(1));let c=await r.K({tarballPath:s.data.tarballPath,remote:e.remote,onProgress:o});c.success||(console.error(p.default.red(c.error.message)),process.exit(1));let l=await t.z(a.default.join(n,`package.json`)).catch(()=>void 0),u=l?.name??c.data.name,d=l?.version??`unknown`;console.log(p.default.green(`\n✓ Published ${u} 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.U;await S(n),await r.O();let i=e.remote??r.Z.getActiveRemote();console.log(p.default.blue(`Installing application on ${i}...`)),console.log(p.default.gray(`App path: ${n}\n`));let a=await r.H({appPath:n,remote:e.remote});a.success||(console.error(p.default.red(a.error.message)),process.exit(1)),console.log(p.default.green(`✓ Application installed`))}},te=class{async execute({appPath:e=t.U,askForConfirmation:n}){let i=r.Z.getActiveRemote();console.log(p.default.blue(`🚀 Uninstall Twenty Application on ${i}`)),console.log(p.default.gray(`📁 App Path: ${e}\n`)),n&&!await this.confirmationPrompt()&&(console.error(p.default.red(`⛔️ Aborting uninstall`)),process.exit(1));let a=await r.D({appPath:e});return a.success?(console.log(p.default.green(`✅ Application uninstalled successfully`)),{success:!0,data:void 0}):(console.error(p.default.red(`❌ Uninstall failed:`),a.error.message),{success:!1,error:a.error.message})}async confirmationPrompt(){let{confirmation:e}=await m.default.prompt([{type:`confirm`,name:`confirmation`,message:`Are you sure you want to uninstall this application?`,default:!1}]);return e}},ne=e=>{let t=new ee,n=new C,r=new te;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:y(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:y(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:y(e),askForConfirmation:!t?.yes});process.exit(+!n.success)}catch{process.exit(1)}})},re=[`src/application.config.ts`,`src/application-config.ts`,`src/applicationConfig.ts`],ie=async e=>{for(let n of re){let r=(0,a.join)(e,n);if(await t.R(r))return r}return null},ae=async e=>{let n=await ie(e);if(n===null)throw Error(`Could not find the application config file (expected one of: ${re.join(`, `)}). Create it with defineApplication({ universalIdentifier: ... }) before generating entities.`);let{config:r}=await t.u({appPath:e,filePath:n});if(!r?.universalIdentifier)throw Error(`defineApplication in ${n} must declare a universalIdentifier before generating entities.`);return r.universalIdentifier},oe=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,ee=64,C=128,te=256,ne=512,re=30,ie=`...`,ae=800,oe=16,se=1,ce=2,le=3,ue=1/0,de=9007199254740991,fe=17976931348623157e292,pe=NaN,me=4294967295,he=me-1,ge=me>>>1,_e=[[`ary`,C],[`bind`,_],[`bindKey`,v],[`curry`,b],[`curryRight`,x],[`flip`,ne],[`partial`,S],[`partialRight`,ee],[`rearg`,te]],ve=`[object Arguments]`,ye=`[object Array]`,be=`[object AsyncFunction]`,xe=`[object Boolean]`,Se=`[object Date]`,Ce=`[object DOMException]`,we=`[object Error]`,Te=`[object Function]`,Ee=`[object GeneratorFunction]`,De=`[object Map]`,Oe=`[object Number]`,ke=`[object Null]`,Ae=`[object Object]`,je=`[object Promise]`,Me=`[object Proxy]`,Ne=`[object RegExp]`,Pe=`[object Set]`,Fe=`[object String]`,Ie=`[object Symbol]`,Le=`[object Undefined]`,Re=`[object WeakMap]`,ze=`[object WeakSet]`,w=`[object ArrayBuffer]`,Be=`[object DataView]`,Ve=`[object Float32Array]`,He=`[object Float64Array]`,Ue=`[object Int8Array]`,We=`[object Int16Array]`,Ge=`[object Int32Array]`,Ke=`[object Uint8Array]`,qe=`[object Uint8ClampedArray]`,Je=`[object Uint16Array]`,Ye=`[object Uint32Array]`,Xe=/\b__p \+= '';/g,Ze=/\b(__p \+=) '' \+/g,Qe=/(__e\(.*?\)|\b__t\)) \+\n'';/g,$e=/&(?:amp|lt|gt|quot|#39);/g,et=/[&<>"']/g,tt=RegExp($e.source),nt=RegExp(et.source),rt=/<%-([\s\S]+?)%>/g,it=/<%([\s\S]+?)%>/g,at=/<%=([\s\S]+?)%>/g,ot=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,st=/^\w*$/,ct=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,lt=/[\\^$.*+?()[\]{}|]/g,ut=RegExp(lt.source),dt=/^\s+/,T=/\s/,ft=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,pt=/\{\n\/\* \[wrapped with (.+)\] \*/,mt=/,? & /,ht=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,gt=/[()=,{}\[\]\/\s]/,_t=/\\(\\)?/g,vt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,yt=/\w*$/,bt=/^[-+]0x[0-9a-f]+$/i,xt=/^0b[01]+$/i,St=/^\[object .+?Constructor\]$/,Ct=/^0o[0-7]+$/i,wt=/^(?:0|[1-9]\d*)$/,Tt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Et=/($^)/,Dt=/['\n\r\u2028\u2029\\]/g,Ot=`\\ud800-\\udfff`,kt=`\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff`,At=`\\u2700-\\u27bf`,E=`a-z\\xdf-\\xf6\\xf8-\\xff`,jt=`\\xac\\xb1\\xd7\\xf7`,D=`\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf`,O=`\\u2000-\\u206f`,Mt=` \\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`,Nt=`A-Z\\xc0-\\xd6\\xd8-\\xde`,Pt=`\\ufe0e\\ufe0f`,Ft=jt+D+O+Mt,It=`['’]`,k=`[`+Ot+`]`,Lt=`[`+Ft+`]`,Rt=`[`+kt+`]`,zt=`\\d+`,Bt=`[`+At+`]`,Vt=`[`+E+`]`,Ht=`[^`+Ot+Ft+zt+At+E+Nt+`]`,Ut=`\\ud83c[\\udffb-\\udfff]`,Wt=`(?:`+Rt+`|`+Ut+`)`,Gt=`[^`+Ot+`]`,Kt=`(?:\\ud83c[\\udde6-\\uddff]){2}`,qt=`[\\ud800-\\udbff][\\udc00-\\udfff]`,Jt=`[`+Nt+`]`,Yt=`\\u200d`,Xt=`(?:`+Vt+`|`+Ht+`)`,Zt=`(?:`+Jt+`|`+Ht+`)`,Qt=`(?:`+It+`(?:d|ll|m|re|s|t|ve))?`,$t=`(?:`+It+`(?:D|LL|M|RE|S|T|VE))?`,en=Wt+`?`,tn=`[`+Pt+`]?`,nn=`(?:`+Yt+`(?:`+[Gt,Kt,qt].join(`|`)+`)`+tn+en+`)*`,rn=`\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])`,an=`\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])`,on=tn+en+nn,sn=`(?:`+[Bt,Kt,qt].join(`|`)+`)`+on,cn=`(?:`+[Gt+Rt+`?`,Rt,Kt,qt,k].join(`|`)+`)`,ln=RegExp(It,`g`),un=RegExp(Rt,`g`),dn=RegExp(Ut+`(?=`+Ut+`)|`+cn+on,`g`),fn=RegExp([Jt+`?`+Vt+`+`+Qt+`(?=`+[Lt,Jt,`$`].join(`|`)+`)`,Zt+`+`+$t+`(?=`+[Lt,Jt+Xt,`$`].join(`|`)+`)`,Jt+`?`+Xt+`+`+Qt,Jt+`+`+$t,an,rn,zt,sn].join(`|`),`g`),pn=RegExp(`[`+Yt+Ot+kt+Pt+`]`),A=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,mn=`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(`.`),hn=-1,j={};j[Ve]=j[He]=j[Ue]=j[We]=j[Ge]=j[Ke]=j[qe]=j[Je]=j[Ye]=!0,j[ve]=j[ye]=j[w]=j[xe]=j[Be]=j[Se]=j[we]=j[Te]=j[De]=j[Oe]=j[Ae]=j[Ne]=j[Pe]=j[Fe]=j[Re]=!1;var M={};M[ve]=M[ye]=M[w]=M[Be]=M[xe]=M[Se]=M[Ve]=M[He]=M[Ue]=M[We]=M[Ge]=M[De]=M[Oe]=M[Ae]=M[Ne]=M[Pe]=M[Fe]=M[Ie]=M[Ke]=M[qe]=M[Je]=M[Ye]=!0,M[we]=M[Te]=M[Re]=!1;var N={À:`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`},gn={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},_n={"&amp;":`&`,"&lt;":`<`,"&gt;":`>`,"&quot;":`"`,"&#39;":`'`},vn={"\\":`\\`,"'":`'`,"\n":`n`,"\r":`r`,"\u2028":`u2028`,"\u2029":`u2029`},yn=parseFloat,bn=parseInt,xn=typeof global==`object`&&global&&global.Object===Object&&global,Sn=typeof self==`object`&&self&&self.Object===Object&&self,P=xn||Sn||Function(`return this`)(),Cn=typeof e==`object`&&e&&!e.nodeType&&e,wn=Cn&&typeof t==`object`&&t&&!t.nodeType&&t,Tn=wn&&wn.exports===Cn,En=Tn&&xn.process,F=function(){try{return wn&&wn.require&&wn.require(`util`).types||En&&En.binding&&En.binding(`util`)}catch{}}(),Dn=F&&F.isArrayBuffer,On=F&&F.isDate,kn=F&&F.isMap,An=F&&F.isRegExp,jn=F&&F.isSet,Mn=F&&F.isTypedArray;function Nn(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 Pn(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 Fn(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}function In(e,t){for(var n=e==null?0:e.length;n--&&t(e[n],n,e)!==!1;);return e}function Ln(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 Rn(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 zn(e,t){return!!(e!=null&&e.length)&&Xn(e,t,0)>-1}function Bn(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 I(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 Vn(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function Hn(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 Un(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 Wn(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 Gn=er(`length`);function Kn(e){return e.split(``)}function qn(e){return e.match(ht)||[]}function Jn(e,t,n){var r;return n(e,function(e,n,i){if(t(e,n,i))return r=n,!1}),r}function Yn(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 Xn(e,t,n){return t===t?Er(e,t,n):Yn(e,Qn,n)}function Zn(e,t,n,r){for(var i=n-1,a=e.length;++i<a;)if(r(e[i],t))return i;return-1}function Qn(e){return e!==e}function $n(e,t){var n=e==null?0:e.length;return n?ir(e,t)/n:pe}function er(e){return function(t){return t==null?n:t[e]}}function tr(e){return function(t){return e==null?n:e[t]}}function nr(e,t,n,r,i){return i(e,function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)}),n}function rr(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}function ir(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 ar(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function or(e,t){return I(t,function(t){return[t,e[t]]})}function sr(e){return e&&e.slice(0,Ar(e)+1).replace(dt,``)}function cr(e){return function(t){return e(t)}}function lr(e,t){return I(t,function(t){return e[t]})}function ur(e,t){return e.has(t)}function dr(e,t){for(var n=-1,r=e.length;++n<r&&Xn(t,e[n],0)>-1;);return n}function fr(e,t){for(var n=e.length;n--&&Xn(t,e[n],0)>-1;);return n}function pr(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}var mr=tr(N),hr=tr(gn);function gr(e){return`\\`+vn[e]}function _r(e,t){return e==null?n:e[t]}function vr(e){return pn.test(e)}function yr(e){return A.test(e)}function br(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}function xr(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function Sr(e,t){return function(n){return e(t(n))}}function Cr(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 wr(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}function Tr(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=[e,e]}),n}function Er(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}function Dr(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}function Or(e){return vr(e)?Mr(e):Gn(e)}function kr(e){return vr(e)?Nr(e):Kn(e)}function Ar(e){for(var t=e.length;t--&&T.test(e.charAt(t)););return t}var jr=tr(_n);function Mr(e){for(var t=dn.lastIndex=0;dn.test(e);)++t;return t}function Nr(e){return e.match(dn)||[]}function Pr(e){return e.match(fn)||[]}var Fr=(function e(t){t=t==null?P:Fr.defaults(P.Object(),t,Fr.pick(P,mn));var T=t.Array,ht=t.Date,Ot=t.Error,kt=t.Function,At=t.Math,E=t.Object,jt=t.RegExp,D=t.String,O=t.TypeError,Mt=T.prototype,Nt=kt.prototype,Pt=E.prototype,Ft=t[`__core-js_shared__`],It=Nt.toString,k=Pt.hasOwnProperty,Lt=0,Rt=function(){var e=/[^.]+$/.exec(Ft&&Ft.keys&&Ft.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}(),zt=Pt.toString,Bt=It.call(E),Vt=P._,Ht=jt(`^`+It.call(k).replace(lt,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`),Ut=Tn?t.Buffer:n,Wt=t.Symbol,Gt=t.Uint8Array,Kt=Ut?Ut.allocUnsafe:n,qt=Sr(E.getPrototypeOf,E),Jt=E.create,Yt=Pt.propertyIsEnumerable,Xt=Mt.splice,Zt=Wt?Wt.isConcatSpreadable:n,Qt=Wt?Wt.iterator:n,$t=Wt?Wt.toStringTag:n,en=function(){try{var e=is(E,`defineProperty`);return e({},``,{}),e}catch{}}(),tn=t.clearTimeout!==P.clearTimeout&&t.clearTimeout,nn=ht&&ht.now!==P.Date.now&&ht.now,rn=t.setTimeout!==P.setTimeout&&t.setTimeout,an=At.ceil,on=At.floor,sn=E.getOwnPropertySymbols,cn=Ut?Ut.isBuffer:n,dn=t.isFinite,fn=Mt.join,pn=Sr(E.keys,E),A=At.max,N=At.min,gn=ht.now,_n=t.parseInt,vn=At.random,xn=Mt.reverse,Sn=is(t,`DataView`),Cn=is(t,`Map`),wn=is(t,`Promise`),En=is(t,`Set`),F=is(t,`WeakMap`),Gn=is(E,`create`),Kn=F&&new F,tr={},Er=Vs(Sn),Mr=Vs(Cn),Nr=Vs(wn),Ir=Vs(En),Lr=Vs(F),Rr=Wt?Wt.prototype:n,zr=Rr?Rr.valueOf:n,Br=Rr?Rr.toString:n;function L(e){if(X(e)&&!K(e)&&!(e instanceof R)){if(e instanceof Ur)return e;if(k.call(e,`__wrapped__`))return Us(e)}return new Ur(e)}var Vr=function(){function e(){}return function(t){if(!Y(t))return{};if(Jt)return Jt(t);e.prototype=t;var r=new e;return e.prototype=n,r}}();function Hr(){}function Ur(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=n}L.templateSettings={escape:rt,evaluate:it,interpolate:at,variable:``,imports:{_:L}},L.prototype=Hr.prototype,L.prototype.constructor=L,Ur.prototype=Vr(Hr.prototype),Ur.prototype.constructor=Ur;function R(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=me,this.__views__=[]}function Wr(){var e=new R(this.__wrapped__);return e.__actions__=H(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=H(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=H(this.__views__),e}function Gr(){if(this.__filtered__){var e=new R(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Kr(){var e=this.__wrapped__.value(),t=this.__dir__,n=K(e),r=t<0,i=n?e.length:0,a=cs(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=N(c,this.__takeCount__);if(!n||!r&&i==c&&p==c)return Za(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==ce)g=b;else if(!b){if(y==se)continue outer;break outer}}m[f++]=g}return m}R.prototype=Vr(Hr.prototype),R.prototype.constructor=R;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__=Gn?Gn(null):{},this.size=0}function Yr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}function Xr(e){var t=this.__data__;if(Gn){var r=t[e];return r===l?n:r}return k.call(t,e)?t[e]:n}function Zr(e){var t=this.__data__;return Gn?t[e]!==n:k.call(t,e)}function Qr(e,t){var r=this.__data__;return this.size+=+!this.has(e),r[e]=Gn&&t===n?l: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.__data__=[],this.size=0}function ti(e){var t=this.__data__,n=Ei(t,e);return n<0?!1:(n==t.length-1?t.pop():Xt.call(t,n,1),--this.size,!0)}function ni(e){var t=this.__data__,r=Ei(t,e);return r<0?n:t[r][1]}function ri(e){return Ei(this.__data__,e)>-1}function ii(e,t){var n=this.__data__,r=Ei(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,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.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function oi(){this.size=0,this.__data__={hash:new qr,map:new(Cn||$r),string:new qr}}function si(e){var t=ns(this,e).delete(e);return this.size-=+!!t,t}function ci(e){return ns(this,e).get(e)}function li(e){return ns(this,e).has(e)}function ui(e,t){var n=ns(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}ai.prototype.clear=oi,ai.prototype.delete=si,ai.prototype.get=ci,ai.prototype.has=li,ai.prototype.set=ui;function di(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new ai;++t<n;)this.add(e[t])}function fi(e){return this.__data__.set(e,l),this}function pi(e){return this.__data__.has(e)}di.prototype.add=di.prototype.push=fi,di.prototype.has=pi;function mi(e){var t=this.__data__=new $r(e);this.size=t.size}function hi(){this.__data__=new $r,this.size=0}function gi(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function _i(e){return this.__data__.get(e)}function vi(e){return this.__data__.has(e)}function yi(e,t){var n=this.__data__;if(n instanceof $r){var r=n.__data__;if(!Cn||r.length<i-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ai(r)}return n.set(e,t),this.size=n.size,this}mi.prototype.clear=hi,mi.prototype.delete=gi,mi.prototype.get=_i,mi.prototype.has=vi,mi.prototype.set=yi;function bi(e,t){var n=K(e),r=!n&&gu(e),i=!n&&!r&&yu(e),a=!n&&!r&&!i&&Wu(e),o=n||r||i||a,s=o?ar(e.length,D):[],c=s.length;for(var l in e)(t||k.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||gs(l,c)))&&s.push(l);return s}function xi(e){var t=e.length;return t?e[ja(0,t-1)]:n}function Si(e,t){return Rs(H(e),Mi(t,0,e.length))}function Ci(e){return Rs(H(e))}function wi(e,t,r){(r!==n&&!pu(e[t],r)||r===n&&!(t in e))&&Ai(e,t,r)}function Ti(e,t,r){var i=e[t];(!(k.call(e,t)&&pu(i,r))||r===n&&!(t in e))&&Ai(e,t,r)}function Ei(e,t){for(var n=e.length;n--;)if(pu(e[n][0],t))return n;return-1}function Di(e,t,n,r){return Ri(e,function(e,i,a){t(r,e,n(e),a)}),r}function Oi(e,t){return e&&_o(t,$(t),e)}function ki(e,t){return e&&_o(t,wd(t),e)}function Ai(e,t,n){t==`__proto__`&&en?en(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function ji(e,t){for(var r=-1,i=t.length,a=T(i),o=e==null;++r<i;)a[r]=o?n:vd(e,t[r]);return a}function Mi(e,t,r){return e===e&&(r!==n&&(e=e<=r?e:r),t!==n&&(e=e>=t?e:t)),e}function Ni(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(!Y(e))return e;var d=K(e);if(d){if(s=ds(e),!c)return H(e,s)}else{var h=W(e),g=h==Te||h==Ee;if(yu(e))return oo(e,c);if(h==Ae||h==ve||g&&!a){if(s=l||g?{}:fs(e),!c)return l?yo(e,ki(s,e)):vo(e,Oi(s,e))}else{if(!M[h])return a?e:{};s=ps(e,h,c)}}o||=new mi;var _=o.get(e);if(_)return _;o.set(e,s),Vu(e)?e.forEach(function(n){s.add(Ni(n,t,r,n,e,o))}):Au(e)&&e.forEach(function(n,i){s.set(i,Ni(n,t,r,i,e,o))});var v=d?n:(u?l?Qo:Zo:l?wd:$)(e);return Fn(v||e,function(n,i){v&&(i=n,n=e[i]),Ti(s,i,Ni(n,t,r,i,e,o))}),s}function Pi(e){var t=$(e);return function(n){return Fi(n,e,t)}}function Fi(e,t,r){var i=r.length;if(e==null)return!i;for(e=E(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 Ii(e,t,r){if(typeof e!=`function`)throw new O(o);return Ps(function(){e.apply(n,r)},t)}function Li(e,t,n,r){var a=-1,o=zn,s=!0,c=e.length,l=[],u=t.length;if(!c)return l;n&&(t=I(t,cr(n))),r?(o=Bn,s=!1):t.length>=i&&(o=ur,s=!1,t=new di(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 Ri=So(Ki),zi=So(qi,!0);function Bi(e,t){var n=!0;return Ri(e,function(e,r,i){return n=!!t(e,r,i),n}),n}function Vi(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&&!Uu(s):r(s,c)))var c=s,l=o}return l}function Hi(e,t,r,i){var a=e.length;for(r=Z(r),r<0&&(r=-r>a?0:a+r),i=i===n||i>a?a:Z(i),i<0&&(i+=a),i=r>i?0:Qu(i);r<i;)e[r++]=t;return e}function Ui(e,t){var n=[];return Ri(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function z(e,t,n,r,i){var a=-1,o=e.length;for(n||=hs,i||=[];++a<o;){var s=e[a];t>0&&n(s)?t>1?z(s,t-1,n,r,i):Vn(i,s):r||(i[i.length]=s)}return i}var Wi=Co(),Gi=Co(!0);function Ki(e,t){return e&&Wi(e,t,$)}function qi(e,t){return e&&Gi(e,t,$)}function Ji(e,t){return Rn(t,function(t){return Du(e[t])})}function Yi(e,t){t=no(t,e);for(var r=0,i=t.length;e!=null&&r<i;)e=e[Bs(t[r++])];return r&&r==i?e:n}function Xi(e,t,n){var r=t(e);return K(e)?r:Vn(r,n(e))}function B(e){return e==null?e===n?Le:ke:$t&&$t in E(e)?as(e):Os(e)}function Zi(e,t){return e>t}function Qi(e,t){return e!=null&&k.call(e,t)}function $i(e,t){return e!=null&&t in E(e)}function ea(e,t,n){return e>=N(t,n)&&e<A(t,n)}function ta(e,t,r){for(var i=r?Bn:zn,a=e[0].length,o=e.length,s=o,c=T(o),l=1/0,u=[];s--;){var d=e[s];s&&t&&(d=I(d,cr(t))),l=N(d.length,l),c[s]=!r&&(t||a>=120&&d.length>=120)?new di(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?ur(p,h):i(u,h,r))){for(s=o;--s;){var g=c[s];if(!(g?ur(g,h):i(e[s],h,r)))continue outer}p&&p.push(h),u.push(m)}}return u}function na(e,t,n,r){return Ki(e,function(e,i,a){t(r,n(e),i,a)}),r}function ra(e,t,r){t=no(t,e),e=As(e,t);var i=e==null?e:e[Bs(mc(t))];return i==null?n:Nn(i,e,r)}function ia(e){return X(e)&&B(e)==ve}function aa(e){return X(e)&&B(e)==w}function oa(e){return X(e)&&B(e)==Se}function sa(e,t,n,r,i){return e===t?!0:e==null||t==null||!X(e)&&!X(t)?e!==e&&t!==t:ca(e,t,n,r,sa,i)}function ca(e,t,n,r,i,a){var o=K(e),s=K(t),c=o?ye:W(e),l=s?ye:W(t);c=c==ve?Ae:c,l=l==ve?Ae:l;var u=c==Ae,d=l==Ae,f=c==l;if(f&&yu(e)){if(!yu(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new mi,o||Wu(e)?qo(e,t,n,r,i,a):Jo(e,t,c,n,r,i,a);if(!(n&h)){var p=u&&k.call(e,`__wrapped__`),m=d&&k.call(t,`__wrapped__`);if(p||m){var g=p?e.value():e,_=m?t.value():t;return a||=new mi,i(g,_,n,r,a)}}return f?(a||=new mi,Yo(e,t,n,r,i,a)):!1}function la(e){return X(e)&&W(e)==De}function ua(e,t,r,i){var a=r.length,o=a,s=!i;if(e==null)return!o;for(e=E(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 mi;if(i)var p=i(u,d,l,e,t,f);if(!(p===n?sa(d,u,h|g,i,f):p))return!1}}return!0}function da(e){return!Y(e)||bs(e)?!1:(Du(e)?Ht:St).test(Vs(e))}function fa(e){return X(e)&&B(e)==Ne}function pa(e){return X(e)&&W(e)==Pe}function ma(e){return X(e)&&ku(e.length)&&!!j[B(e)]}function ha(e){return typeof e==`function`?e:e==null?Mf:typeof e==`object`?K(e)?xa(e[0],e[1]):ba(e):Gf(e)}function ga(e){if(!Ss(e))return pn(e);var t=[];for(var n in E(e))k.call(e,n)&&n!=`constructor`&&t.push(n);return t}function _a(e){if(!Y(e))return Ds(e);var t=Ss(e),n=[];for(var r in e)r==`constructor`&&(t||!k.call(e,r))||n.push(r);return n}function va(e,t){return e<t}function ya(e,t){var n=-1,r=q(e)?T(e.length):[];return Ri(e,function(e,i,a){r[++n]=t(e,i,a)}),r}function ba(e){var t=rs(e);return t.length==1&&t[0][2]?ws(t[0][0],t[0][1]):function(n){return n===e||ua(n,e,t)}}function xa(e,t){return _s(e)&&Cs(t)?ws(Bs(e),t):function(r){var i=vd(r,e);return i===n&&i===t?bd(r,e):sa(t,i,h|g)}}function Sa(e,t,r,i,a){e!==t&&Wi(t,function(o,s){if(a||=new mi,Y(o))Ca(e,t,s,r,Sa,i,a);else{var c=i?i(Ms(e,s),o,s+``,e,t,a):n;c===n&&(c=o),wi(e,s,c)}},wd)}function Ca(e,t,r,i,a,o,s){var c=Ms(e,r),l=Ms(t,r),u=s.get(l);if(u){wi(e,r,u);return}var d=o?o(c,l,r+``,e,t,s):n,f=d===n;if(f){var p=K(l),m=!p&&yu(l),h=!p&&!m&&Wu(l);d=l,p||m||h?K(c)?d=c:J(c)?d=H(c):m?(f=!1,d=oo(l,!0)):h?(f=!1,d=fo(l,!0)):d=[]:Ru(l)||gu(l)?(d=c,gu(c)?d=ed(c):(!Y(c)||Du(c))&&(d=fs(l))):f=!1}f&&(s.set(l,d),a(d,l,i,o,s),s.delete(l)),wi(e,r,d)}function wa(e,t){var r=e.length;if(r)return t+=t<0?r:0,gs(t,r)?e[t]:n}function Ta(e,t,n){t=t.length?I(t,function(e){return K(e)?function(t){return Yi(t,e.length===1?e[0]:e)}:e}):[Mf];var r=-1;return t=I(t,cr(U())),rr(ya(e,function(e,n,i){return{criteria:I(t,function(t){return t(e)}),index:++r,value:e}}),function(e,t){return mo(e,t,n)})}function Ea(e,t){return Da(e,t,function(t,n){return bd(e,n)})}function Da(e,t,n){for(var r=-1,i=t.length,a={};++r<i;){var o=t[r],s=Yi(e,o);n(s,o)&&Ia(a,no(o,e),s)}return a}function Oa(e){return function(t){return Yi(t,e)}}function ka(e,t,n,r){var i=r?Zn:Xn,a=-1,o=t.length,s=e;for(e===t&&(t=H(t)),n&&(s=I(e,cr(n)));++a<o;)for(var c=0,l=t[a],u=n?n(l):l;(c=i(s,u,c,r))>-1;)s!==e&&Xt.call(s,c,1),Xt.call(e,c,1);return e}function Aa(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;gs(i)?Xt.call(e,i,1):Ja(e,i)}}return e}function ja(e,t){return e+on(vn()*(t-e+1))}function Ma(e,t,n,r){for(var i=-1,a=A(an((t-e)/(n||1)),0),o=T(a);a--;)o[r?a:++i]=e,e+=n;return o}function Na(e,t){var n=``;if(!e||t<1||t>de)return n;do t%2&&(n+=e),t=on(t/2),t&&(e+=e);while(t);return n}function V(e,t){return Fs(ks(e,t,Mf),e+``)}function Pa(e){return xi(Hd(e))}function Fa(e,t){var n=Hd(e);return Rs(n,Mi(t,0,n.length))}function Ia(e,t,r,i){if(!Y(e))return e;t=no(t,e);for(var a=-1,o=t.length,s=o-1,c=e;c!=null&&++a<o;){var l=Bs(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=Y(d)?d:gs(t[a+1])?[]:{})}Ti(c,l,u),c=c[l]}return e}var La=Kn?function(e,t){return Kn.set(e,t),e}:Mf,Ra=en?function(e,t){return en(e,`toString`,{configurable:!0,enumerable:!1,value:Of(t),writable:!0})}:Mf;function za(e){return Rs(Hd(e))}function Ba(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=T(i);++r<i;)a[r]=e[r+t];return a}function Va(e,t){var n;return Ri(e,function(e,r,i){return n=t(e,r,i),!n}),!!n}function Ha(e,t,n){var r=0,i=e==null?r:e.length;if(typeof t==`number`&&t===t&&i<=ge){for(;r<i;){var a=r+i>>>1,o=e[a];o!==null&&!Uu(o)&&(n?o<=t:o<t)?r=a+1:i=a}return i}return Ua(e,t,Mf,n)}function Ua(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=Uu(t),u=t===n;a<o;){var d=on((a+o)/2),f=r(e[d]),p=f!==n,m=f===null,h=f===f,g=Uu(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 N(o,he)}function Wa(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||!pu(s,c)){var c=s;a[i++]=o===0?0:o}}return a}function Ga(e){return typeof e==`number`?e:Uu(e)?pe:+e}function Ka(e){if(typeof e==`string`)return e;if(K(e))return I(e,Ka)+``;if(Uu(e))return Br?Br.call(e):``;var t=e+``;return t==`0`&&1/e==-ue?`-0`:t}function qa(e,t,n){var r=-1,a=zn,o=e.length,s=!0,c=[],l=c;if(n)s=!1,a=Bn;else if(o>=i){var u=t?null:Vo(e);if(u)return wr(u);s=!1,a=ur,l=new di}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 Ja(e,t){t=no(t,e);var n=-1,r=t.length;if(!r)return!0;for(;++n<r;){var i=Bs(t[n]);if(i===`__proto__`&&!k.call(e,`__proto__`)||(i===`constructor`||i===`prototype`)&&n<r-1)return!1}var a=As(e,t);return a==null||delete a[Bs(mc(t))]}function Ya(e,t,n,r){return Ia(e,t,n(Yi(e,t)),r)}function Xa(e,t,n,r){for(var i=e.length,a=r?i:-1;(r?a--:++a<i)&&t(e[a],a,e););return n?Ba(e,r?0:a,r?a+1:i):Ba(e,r?a+1:0,r?i:a)}function Za(e,t){var n=e;return n instanceof R&&(n=n.value()),Hn(t,function(e,t){return t.func.apply(t.thisArg,Vn([e],t.args))},n)}function Qa(e,t,n){var r=e.length;if(r<2)return r?qa(e[0]):[];for(var i=-1,a=T(r);++i<r;)for(var o=e[i],s=-1;++s<r;)s!=i&&(a[i]=Li(a[i]||o,e[s],t,n));return qa(z(a,1),t,n)}function $a(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 eo(e){return J(e)?e:[]}function to(e){return typeof e==`function`?e:Mf}function no(e,t){return K(e)?e:_s(e,t)?[e]:zs(Q(e))}var ro=V;function io(e,t,r){var i=e.length;return r=r===n?i:r,!t&&r>=i?e:Ba(e,t,r)}var ao=tn||function(e){return P.clearTimeout(e)};function oo(e,t){if(t)return e.slice();var n=e.length,r=Kt?Kt(n):new e.constructor(n);return e.copy(r),r}function so(e){var t=new e.constructor(e.byteLength);return new Gt(t).set(new Gt(e)),t}function co(e,t){var n=t?so(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function lo(e){var t=new e.constructor(e.source,yt.exec(e));return t.lastIndex=e.lastIndex,t}function uo(e){return zr?E(zr.call(e)):{}}function fo(e,t){var n=t?so(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function po(e,t){if(e!==t){var r=e!==n,i=e===null,a=e===e,o=Uu(e),s=t!==n,c=t===null,l=t===t,u=Uu(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 mo(e,t,n){for(var r=-1,i=e.criteria,a=t.criteria,o=i.length,s=n.length;++r<o;){var c=po(i[r],a[r]);if(c)return r>=s?c:c*(n[r]==`desc`?-1:1)}return e.index-t.index}function ho(e,t,n,r){for(var i=-1,a=e.length,o=n.length,s=-1,c=t.length,l=A(a-o,0),u=T(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 go(e,t,n,r){for(var i=-1,a=e.length,o=-1,s=n.length,c=-1,l=t.length,u=A(a-s,0),d=T(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 H(e,t){var n=-1,r=e.length;for(t||=T(r);++n<r;)t[n]=e[n];return t}function _o(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?Ai(r,c,l):Ti(r,c,l)}return r}function vo(e,t){return _o(e,os(e),t)}function yo(e,t){return _o(e,ss(e),t)}function bo(e,t){return function(n,r){var i=K(n)?Pn:Di,a=t?t():{};return i(n,e,U(r,2),a)}}function xo(e){return V(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&&G(r[0],r[1],s)&&(o=a<3?n:o,a=1),t=E(t);++i<a;){var c=r[i];c&&e(t,c,i,o)}return t})}function So(e,t){return function(n,r){if(n==null)return n;if(!q(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=E(n);(t?a--:++a<i)&&r(o[a],a,o)!==!1;);return n}}function Co(e){return function(t,n,r){for(var i=-1,a=E(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 wo(e,t,n){var r=t&_,i=Do(e);function a(){return(this&&this!==P&&this instanceof a?i:e).apply(r?n:this,arguments)}return a}function To(e){return function(t){t=Q(t);var r=vr(t)?kr(t):n,i=r?r[0]:t.charAt(0),a=r?io(r,1).join(``):t.slice(1);return i[e]()+a}}function Eo(e){return function(t){return Hn(Cf(Yd(t).replace(ln,``)),e,``)}}function Do(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=Vr(e.prototype),r=e.apply(n,t);return Y(r)?r:n}}function Oo(e,t,r){var i=Do(e);function a(){for(var o=arguments.length,s=T(o),c=o,l=ts(a);c--;)s[c]=arguments[c];var u=o<3&&s[0]!==l&&s[o-1]!==l?[]:Cr(s,l);return o-=u.length,o<r?zo(e,t,jo,a.placeholder,n,s,u,n,n,r-o):Nn(this&&this!==P&&this instanceof a?i:e,this,s)}return a}function ko(e){return function(t,r,i){var a=E(t);if(!q(t)){var o=U(r,3);t=$(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 Ao(e){return Xo(function(t){var r=t.length,i=r,a=Ur.prototype.thru;for(e&&t.reverse();i--;){var s=t[i];if(typeof s!=`function`)throw new O(o);if(a&&!c&&es(s)==`wrapper`)var c=new Ur([],!0)}for(i=c?i:r;++i<r;){s=t[i];var l=es(s),u=l==`wrapper`?$o(s):n;c=u&&ys(u[0])&&u[1]==(C|b|S|te)&&!u[4].length&&u[9]==1?c[es(u[0])].apply(c,u[3]):s.length==1&&ys(s)?c[l]():c.thru(s)}return function(){var e=arguments,n=e[0];if(c&&e.length==1&&K(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 jo(e,t,r,i,a,o,s,c,l,u){var d=t&C,f=t&_,p=t&v,m=t&(b|x),h=t&ne,g=p?n:Do(e);function y(){for(var n=arguments.length,_=T(n),v=n;v--;)_[v]=arguments[v];if(m)var b=ts(y),x=pr(_,b);if(i&&(_=ho(_,i,a,m)),o&&(_=go(_,o,s,m)),n-=x,m&&n<u){var S=Cr(_,b);return zo(e,t,jo,y.placeholder,r,_,S,c,l,u-n)}var ee=f?r:this,C=p?ee[e]:e;return n=_.length,c?_=js(_,c):h&&n>1&&_.reverse(),d&&l<n&&(_.length=l),this&&this!==P&&this instanceof y&&(C=g||Do(C)),C.apply(ee,_)}return y}function Mo(e,t){return function(n,r){return na(n,e,t(r),{})}}function No(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=Ka(r),i=Ka(i)):(r=Ga(r),i=Ga(i)),a=e(r,i)}return a}}function Po(e){return Xo(function(t){return t=I(t,cr(U())),V(function(n){var r=this;return e(t,function(e){return Nn(e,r,n)})})})}function Fo(e,t){t=t===n?` `:Ka(t);var r=t.length;if(r<2)return r?Na(t,e):t;var i=Na(t,an(e/Or(t)));return vr(t)?io(kr(i),0,e).join(``):i.slice(0,e)}function Io(e,t,n,r){var i=t&_,a=Do(e);function o(){for(var t=-1,s=arguments.length,c=-1,l=r.length,u=T(l+s),d=this&&this!==P&&this instanceof o?a:e;++c<l;)u[c]=r[c];for(;s--;)u[c++]=arguments[++t];return Nn(d,i?n:this,u)}return o}function Lo(e){return function(t,r,i){return i&&typeof i!=`number`&&G(t,r,i)&&(r=i=n),t=Zu(t),r===n?(r=t,t=0):r=Zu(r),i=i===n?t<r?1:-1:Zu(i),Ma(t,r,i,e)}}function Ro(e){return function(t,n){return typeof t==`string`&&typeof n==`string`||(t=$u(t),n=$u(n)),e(t,n)}}function zo(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:ee,t&=~(d?ee:S),t&y||(t&=~(_|v));var g=[e,t,a,m,f,h,p,c,l,u],x=r.apply(n,g);return ys(e)&&Ns(x,g),x.placeholder=i,Is(x,e,t)}function Bo(e){var t=At[e];return function(e,n){if(e=$u(e),n=n==null?0:N(Z(n),292),n&&dn(e)){var r=(Q(e)+`e`).split(`e`);return r=(Q(t(r[0]+`e`+(+r[1]+n)))+`e`).split(`e`),+(r[0]+`e`+(+r[1]-n))}return t(e)}}var Vo=En&&1/wr(new En([,-0]))[1]==ue?function(e){return new En(e)}:Bf;function Ho(e){return function(t){var n=W(t);return n==De?xr(t):n==Pe?Tr(t):or(t,e(t))}}function Uo(e,t,r,i,a,s,c,l){var u=t&v;if(!u&&typeof e!=`function`)throw new O(o);var d=i?i.length:0;if(d||(t&=~(S|ee),i=a=n),c=c===n?c:A(Z(c),0),l=l===n?l:Z(l),d-=a?a.length:0,t&ee){var f=i,p=a;i=a=n}var m=u?n:$o(e),h=[e,t,r,i,a,f,p,s,c,l];if(m&&Es(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:A(h[9]-d,0),!l&&t&(b|x)&&(t&=~(b|x)),!t||t==_)var g=wo(e,t,r);else g=t==b||t==x?Oo(e,t,l):(t==S||t==(_|S))&&!a.length?Io(e,t,r,i):jo.apply(n,h);return Is((m?La:Ns)(g,h),e,t)}function Wo(e,t,r,i){return e===n||pu(e,Pt[r])&&!k.call(i,r)?t:e}function Go(e,t,r,i,a,o){return Y(e)&&Y(t)&&(o.set(t,e),Sa(e,t,n,Go,o),o.delete(t)),e}function Ko(e){return Ru(e)?n:e}function qo(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 di: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(!Wn(t,function(e,t){if(!ur(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 Jo(e,t,n,r,i,a,o){switch(n){case Be:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case w:return!(e.byteLength!=t.byteLength||!a(new Gt(e),new Gt(t)));case xe:case Se:case Oe:return pu(+e,+t);case we:return e.name==t.name&&e.message==t.message;case Ne:case Fe:return e==t+``;case De:var s=xr;case Pe:var c=r&h;if(s||=wr,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=qo(s(e),s(t),r,i,a,o);return o.delete(e),u;case Ie:if(zr)return zr.call(e)==zr.call(t)}return!1}function Yo(e,t,r,i,a,o){var s=r&h,c=Zo(e),l=c.length;if(l!=Zo(t).length&&!s)return!1;for(var u=l;u--;){var d=c[u];if(!(s?d in t:k.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 Xo(e){return Fs(ks(e,n,rc),e+``)}function Zo(e){return Xi(e,$,os)}function Qo(e){return Xi(e,wd,ss)}var $o=Kn?function(e){return Kn.get(e)}:Bf;function es(e){for(var t=e.name+``,n=tr[t],r=k.call(tr,t)?n.length:0;r--;){var i=n[r],a=i.func;if(a==null||a==e)return i.name}return t}function ts(e){return(k.call(L,`placeholder`)?L:e).placeholder}function U(){var e=L.iteratee||Nf;return e=e===Nf?ha:e,arguments.length?e(arguments[0],arguments[1]):e}function ns(e,t){var n=e.__data__;return vs(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function rs(e){for(var t=$(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,Cs(i)]}return t}function is(e,t){var r=_r(e,t);return da(r)?r:n}function as(e){var t=k.call(e,$t),r=e[$t];try{e[$t]=n;var i=!0}catch{}var a=zt.call(e);return i&&(t?e[$t]=r:delete e[$t]),a}var os=sn?function(e){return e==null?[]:(e=E(e),Rn(sn(e),function(t){return Yt.call(e,t)}))}:Yf,ss=sn?function(e){for(var t=[];e;)Vn(t,os(e)),e=qt(e);return t}:Yf,W=B;(Sn&&W(new Sn(new ArrayBuffer(1)))!=Be||Cn&&W(new Cn)!=De||wn&&W(wn.resolve())!=je||En&&W(new En)!=Pe||F&&W(new F)!=Re)&&(W=function(e){var t=B(e),r=t==Ae?e.constructor:n,i=r?Vs(r):``;if(i)switch(i){case Er:return Be;case Mr:return De;case Nr:return je;case Ir:return Pe;case Lr:return Re}return t});function cs(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=N(t,e+o);break;case`takeRight`:e=A(e,t-o);break}}return{start:e,end:t}}function ls(e){var t=e.match(pt);return t?t[1].split(mt):[]}function us(e,t,n){t=no(t,e);for(var r=-1,i=t.length,a=!1;++r<i;){var o=Bs(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&&ku(i)&&gs(o,i)&&(K(e)||gu(e)))}function ds(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]==`string`&&k.call(e,`index`)&&(n.index=e.index,n.input=e.input),n}function fs(e){return typeof e.constructor==`function`&&!Ss(e)?Vr(qt(e)):{}}function ps(e,t,n){var r=e.constructor;switch(t){case w:return so(e);case xe:case Se:return new r(+e);case Be:return co(e,n);case Ve:case He:case Ue:case We:case Ge:case Ke:case qe:case Je:case Ye:return fo(e,n);case De:return new r;case Oe:case Fe:return new r(e);case Ne:return lo(e);case Pe:return new r;case Ie:return uo(e)}}function ms(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(ft,`{
3
3
  /* [wrapped with `+t+`] */
4
4
  `)}function hs(e){return K(e)||gu(e)||!!(Zt&&e&&e[Zt])}function gs(e,t){var n=typeof e;return t??=de,!!t&&(n==`number`||n!=`symbol`&&wt.test(e))&&e>-1&&e%1==0&&e<t}function G(e,t,n){if(!Y(n))return!1;var r=typeof t;return(r==`number`?q(n)&&gs(t,n.length):r==`string`&&t in n)?pu(n[t],e):!1}function _s(e,t){if(K(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||Uu(e)?!0:st.test(e)||!ot.test(e)||t!=null&&e in E(t)}function vs(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function ys(e){var t=es(e),n=L[t];if(typeof n!=`function`||!(t in R.prototype))return!1;if(e===n)return!0;var r=$o(n);return!!r&&e===r[0]}function bs(e){return!!Rt&&Rt in e}var xs=Ft?Du:Xf;function Ss(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||Pt)}function Cs(e){return e===e&&!Y(e)}function ws(e,t){return function(r){return r==null?!1:r[e]===t&&(t!==n||e in E(r))}}function Ts(e){var t=Yl(e,function(e){return n.size===u&&n.clear(),e}),n=t.cache;return t}function Es(e,t){var n=e[1],r=t[1],i=n|r,a=i<(_|v|C),o=r==C&&n==b||r==C&&n==te&&e[7].length<=t[8]||r==(C|te)&&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?ho(c,s,t[4]):s,e[4]=c?Cr(e[3],d):t[4]}return s=t[5],s&&(c=e[5],e[5]=c?go(c,s,t[6]):s,e[6]=c?Cr(e[5],d):t[6]),s=t[7],s&&(e[7]=s),r&C&&(e[8]=e[8]==null?t[8]:N(e[8],t[8])),e[9]??=t[9],e[0]=t[0],e[1]=i,e}function Ds(e){var t=[];if(e!=null)for(var n in E(e))t.push(n);return t}function Os(e){return zt.call(e)}function ks(e,t,r){return t=A(t===n?e.length-1:t,0),function(){for(var n=arguments,i=-1,a=A(n.length-t,0),o=T(a);++i<a;)o[i]=n[t+i];i=-1;for(var s=T(t+1);++i<t;)s[i]=n[i];return s[t]=r(o),Nn(e,this,s)}}function As(e,t){return t.length<2?e:Yi(e,Ba(t,0,-1))}function js(e,t){for(var r=e.length,i=N(t.length,r),a=H(e);i--;){var o=t[i];e[i]=gs(o,r)?a[o]:n}return e}function Ms(e,t){if(!(t===`constructor`&&typeof e[t]==`function`)&&t!=`__proto__`)return e[t]}var Ns=Ls(La),Ps=rn||function(e,t){return P.setTimeout(e,t)},Fs=Ls(Ra);function Is(e,t,n){var r=t+``;return Fs(e,ms(r,Hs(ls(r),n)))}function Ls(e){var t=0,r=0;return function(){var i=gn(),a=oe-(i-r);if(r=i,a>0){if(++t>=ae)return arguments[0]}else t=0;return e.apply(n,arguments)}}function Rs(e,t){var r=-1,i=e.length,a=i-1;for(t=t===n?i:t;++r<t;){var o=ja(r,a),s=e[o];e[o]=e[r],e[r]=s}return e.length=t,e}var zs=Ts(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(ct,function(e,n,r,i){t.push(r?i.replace(_t,`$1`):n||e)}),t});function Bs(e){if(typeof e==`string`||Uu(e))return e;var t=e+``;return t==`0`&&1/e==-ue?`-0`:t}function Vs(e){if(e!=null){try{return It.call(e)}catch{}try{return e+``}catch{}}return``}function Hs(e,t){return Fn(_e,function(n){var r=`_.`+n[0];t&n[1]&&!zn(e,r)&&e.push(r)}),e.sort()}function Us(e){if(e instanceof R)return e.clone();var t=new Ur(e.__wrapped__,e.__chain__);return t.__actions__=H(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}function Ws(e,t,r){t=(r?G(e,t,r):t===n)?1:A(Z(t),0);var i=e==null?0:e.length;if(!i||t<1)return[];for(var a=0,o=0,s=T(an(i/t));a<i;)s[o++]=Ba(e,a,a+=t);return s}function Gs(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 Ks(){var e=arguments.length;if(!e)return[];for(var t=T(e-1),n=arguments[0],r=e;r--;)t[r-1]=arguments[r];return Vn(K(n)?H(n):[n],z(t,1))}var qs=V(function(e,t){return J(e)?Li(e,z(t,1,J,!0)):[]}),Js=V(function(e,t){var r=mc(t);return J(r)&&(r=n),J(e)?Li(e,z(t,1,J,!0),U(r,2)):[]}),Ys=V(function(e,t){var r=mc(t);return J(r)&&(r=n),J(e)?Li(e,z(t,1,J,!0),n,r):[]});function Xs(e,t,r){var i=e==null?0:e.length;return i?(t=r||t===n?1:Z(t),Ba(e,t<0?0:t,i)):[]}function Zs(e,t,r){var i=e==null?0:e.length;return i?(t=r||t===n?1:Z(t),t=i-t,Ba(e,0,t<0?0:t)):[]}function Qs(e,t){return e&&e.length?Xa(e,U(t,3),!0,!0):[]}function $s(e,t){return e&&e.length?Xa(e,U(t,3),!0):[]}function ec(e,t,n,r){var i=e==null?0:e.length;return i?(n&&typeof n!=`number`&&G(e,t,n)&&(n=0,r=i),Hi(e,t,n,r)):[]}function tc(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:Z(n);return i<0&&(i=A(r+i,0)),Yn(e,U(t,3),i)}function nc(e,t,r){var i=e==null?0:e.length;if(!i)return-1;var a=i-1;return r!==n&&(a=Z(r),a=r<0?A(i+a,0):N(a,i-1)),Yn(e,U(t,3),a,!0)}function rc(e){return e!=null&&e.length?z(e,1):[]}function ic(e){return e!=null&&e.length?z(e,ue):[]}function ac(e,t){return e!=null&&e.length?(t=t===n?1:Z(t),z(e,t)):[]}function oc(e){for(var t=-1,n=e==null?0:e.length,r={};++t<n;){var i=e[t];Ai(r,i[0],i[1])}return r}function sc(e){return e&&e.length?e[0]:n}function cc(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:Z(n);return i<0&&(i=A(r+i,0)),Xn(e,t,i)}function lc(e){return e!=null&&e.length?Ba(e,0,-1):[]}var uc=V(function(e){var t=I(e,eo);return t.length&&t[0]===e[0]?ta(t):[]}),dc=V(function(e){var t=mc(e),r=I(e,eo);return t===mc(r)?t=n:r.pop(),r.length&&r[0]===e[0]?ta(r,U(t,2)):[]}),fc=V(function(e){var t=mc(e),r=I(e,eo);return t=typeof t==`function`?t:n,t&&r.pop(),r.length&&r[0]===e[0]?ta(r,n,t):[]});function pc(e,t){return e==null?``:fn.call(e,t)}function mc(e){var t=e==null?0:e.length;return t?e[t-1]:n}function hc(e,t,r){var i=e==null?0:e.length;if(!i)return-1;var a=i;return r!==n&&(a=Z(r),a=a<0?A(i+a,0):N(a,i-1)),t===t?Dr(e,t,a):Yn(e,Qn,a,!0)}function gc(e,t){return e&&e.length?wa(e,Z(t)):n}var _c=V(vc);function vc(e,t){return e&&e.length&&t&&t.length?ka(e,t):e}function yc(e,t,n){return e&&e.length&&t&&t.length?ka(e,t,U(n,2)):e}function bc(e,t,r){return e&&e.length&&t&&t.length?ka(e,t,n,r):e}var xc=Xo(function(e,t){var n=e==null?0:e.length,r=ji(e,t);return Aa(e,I(t,function(e){return gs(e,n)?+e:e}).sort(po)),r});function Sc(e,t){var n=[];if(!(e&&e.length))return n;var r=-1,i=[],a=e.length;for(t=U(t,3);++r<a;){var o=e[r];t(o,r,e)&&(n.push(o),i.push(r))}return Aa(e,i),n}function Cc(e){return e==null?e:xn.call(e)}function wc(e,t,r){var i=e==null?0:e.length;return i?(r&&typeof r!=`number`&&G(e,t,r)?(t=0,r=i):(t=t==null?0:Z(t),r=r===n?i:Z(r)),Ba(e,t,r)):[]}function Tc(e,t){return Ha(e,t)}function Ec(e,t,n){return Ua(e,t,U(n,2))}function Dc(e,t){var n=e==null?0:e.length;if(n){var r=Ha(e,t);if(r<n&&pu(e[r],t))return r}return-1}function Oc(e,t){return Ha(e,t,!0)}function kc(e,t,n){return Ua(e,t,U(n,2),!0)}function Ac(e,t){if(e!=null&&e.length){var n=Ha(e,t,!0)-1;if(pu(e[n],t))return n}return-1}function jc(e){return e&&e.length?Wa(e):[]}function Mc(e,t){return e&&e.length?Wa(e,U(t,2)):[]}function Nc(e){var t=e==null?0:e.length;return t?Ba(e,1,t):[]}function Pc(e,t,r){return e&&e.length?(t=r||t===n?1:Z(t),Ba(e,0,t<0?0:t)):[]}function Fc(e,t,r){var i=e==null?0:e.length;return i?(t=r||t===n?1:Z(t),t=i-t,Ba(e,t<0?0:t,i)):[]}function Ic(e,t){return e&&e.length?Xa(e,U(t,3),!1,!0):[]}function Lc(e,t){return e&&e.length?Xa(e,U(t,3)):[]}var Rc=V(function(e){return qa(z(e,1,J,!0))}),zc=V(function(e){var t=mc(e);return J(t)&&(t=n),qa(z(e,1,J,!0),U(t,2))}),Bc=V(function(e){var t=mc(e);return t=typeof t==`function`?t:n,qa(z(e,1,J,!0),n,t)});function Vc(e){return e&&e.length?qa(e):[]}function Hc(e,t){return e&&e.length?qa(e,U(t,2)):[]}function Uc(e,t){return t=typeof t==`function`?t:n,e&&e.length?qa(e,n,t):[]}function Wc(e){if(!(e&&e.length))return[];var t=0;return e=Rn(e,function(e){if(J(e))return t=A(e.length,t),!0}),ar(t,function(t){return I(e,er(t))})}function Gc(e,t){if(!(e&&e.length))return[];var r=Wc(e);return t==null?r:I(r,function(e){return Nn(t,n,e)})}var Kc=V(function(e,t){return J(e)?Li(e,t):[]}),qc=V(function(e){return Qa(Rn(e,J))}),Jc=V(function(e){var t=mc(e);return J(t)&&(t=n),Qa(Rn(e,J),U(t,2))}),Yc=V(function(e){var t=mc(e);return t=typeof t==`function`?t:n,Qa(Rn(e,J),n,t)}),Xc=V(Wc);function Zc(e,t){return $a(e||[],t||[],Ti)}function Qc(e,t){return $a(e||[],t||[],Ia)}var $c=V(function(e){var t=e.length,r=t>1?e[t-1]:n;return r=typeof r==`function`?(e.pop(),r):n,Gc(e,r)});function el(e){var t=L(e);return t.__chain__=!0,t}function tl(e,t){return t(e),e}function nl(e,t){return t(e)}var rl=Xo(function(e){var t=e.length,r=t?e[0]:0,i=this.__wrapped__,a=function(t){return ji(t,e)};return t>1||this.__actions__.length||!(i instanceof R)||!gs(r)?this.thru(a):(i=i.slice(r,+r+ +!!t),i.__actions__.push({func:nl,args:[a],thisArg:n}),new Ur(i,this.__chain__).thru(function(e){return t&&!e.length&&e.push(n),e}))});function il(){return el(this)}function al(){return new Ur(this.value(),this.__chain__)}function ol(){this.__values__===n&&(this.__values__=Xu(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?n:this.__values__[this.__index__++]}}function sl(){return this}function cl(e){for(var t,r=this;r instanceof Hr;){var i=Us(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 ll(){var e=this.__wrapped__;if(e instanceof R){var t=e;return this.__actions__.length&&(t=new R(this)),t=t.reverse(),t.__actions__.push({func:nl,args:[Cc],thisArg:n}),new Ur(t,this.__chain__)}return this.thru(Cc)}function ul(){return Za(this.__wrapped__,this.__actions__)}var dl=bo(function(e,t,n){k.call(e,n)?++e[n]:Ai(e,n,1)});function fl(e,t,r){var i=K(e)?Ln:Bi;return r&&G(e,t,r)&&(t=n),i(e,U(t,3))}function pl(e,t){return(K(e)?Rn:Ui)(e,U(t,3))}var ml=ko(tc),hl=ko(nc);function gl(e,t){return z(Tl(e,t),1)}function _l(e,t){return z(Tl(e,t),ue)}function vl(e,t,r){return r=r===n?1:Z(r),z(Tl(e,t),r)}function yl(e,t){return(K(e)?Fn:Ri)(e,U(t,3))}function bl(e,t){return(K(e)?In:zi)(e,U(t,3))}var xl=bo(function(e,t,n){k.call(e,n)?e[n].push(t):Ai(e,n,[t])});function Sl(e,t,n,r){e=q(e)?e:Hd(e),n=n&&!r?Z(n):0;var i=e.length;return n<0&&(n=A(i+n,0)),Hu(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&Xn(e,t,n)>-1}var Cl=V(function(e,t,n){var r=-1,i=typeof t==`function`,a=q(e)?T(e.length):[];return Ri(e,function(e){a[++r]=i?Nn(t,e,n):ra(e,t,n)}),a}),wl=bo(function(e,t,n){Ai(e,n,t)});function Tl(e,t){return(K(e)?I:ya)(e,U(t,3))}function El(e,t,r,i){return e==null?[]:(K(t)||(t=t==null?[]:[t]),r=i?n:r,K(r)||(r=r==null?[]:[r]),Ta(e,t,r))}var Dl=bo(function(e,t,n){e[+!n].push(t)},function(){return[[],[]]});function Ol(e,t,n){var r=K(e)?Hn:nr,i=arguments.length<3;return r(e,U(t,4),n,i,Ri)}function kl(e,t,n){var r=K(e)?Un:nr,i=arguments.length<3;return r(e,U(t,4),n,i,zi)}function Al(e,t){return(K(e)?Rn:Ui)(e,Xl(U(t,3)))}function jl(e){return(K(e)?xi:Pa)(e)}function Ml(e,t,r){return t=(r?G(e,t,r):t===n)?1:Z(t),(K(e)?Si:Fa)(e,t)}function Nl(e){return(K(e)?Ci:za)(e)}function Pl(e){if(e==null)return 0;if(q(e))return Hu(e)?Or(e):e.length;var t=W(e);return t==De||t==Pe?e.size:ga(e).length}function Fl(e,t,r){var i=K(e)?Wn:Va;return r&&G(e,t,r)&&(t=n),i(e,U(t,3))}var Il=V(function(e,t){if(e==null)return[];var n=t.length;return n>1&&G(e,t[0],t[1])?t=[]:n>2&&G(t[0],t[1],t[2])&&(t=[t[0]]),Ta(e,z(t,1),[])}),Ll=nn||function(){return P.Date.now()};function Rl(e,t){if(typeof t!=`function`)throw new O(o);return e=Z(e),function(){if(--e<1)return t.apply(this,arguments)}}function zl(e,t,r){return t=r?n:t,t=e&&t==null?e.length:t,Uo(e,C,n,n,n,n,t)}function Bl(e,t){var r;if(typeof t!=`function`)throw new O(o);return e=Z(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=n),r}}var Vl=V(function(e,t,n){var r=_;if(n.length){var i=Cr(n,ts(Vl));r|=S}return Uo(e,r,t,n,i)}),Hl=V(function(e,t,n){var r=_|v;if(n.length){var i=Cr(n,ts(Hl));r|=S}return Uo(t,r,e,n,i)});function Ul(e,t,r){t=r?n:t;var i=Uo(e,b,n,n,n,n,n,t);return i.placeholder=Ul.placeholder,i}function Wl(e,t,r){t=r?n:t;var i=Uo(e,x,n,n,n,n,n,t);return i.placeholder=Wl.placeholder,i}function Gl(e,t,r){var i,a,s,c,l,u,d=0,f=!1,p=!1,m=!0;if(typeof e!=`function`)throw new O(o);t=$u(t)||0,Y(r)&&(f=!!r.leading,p=`maxWait`in r,s=p?A($u(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=Ps(y,t),f?h(e):c}function _(e){var n=e-u,r=e-d,i=t-n;return p?N(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=Ll();if(v(e))return b(e);l=Ps(y,_(e))}function b(e){return l=n,m&&i?h(e):(i=a=n,c)}function x(){l!==n&&ao(l),d=0,i=u=a=l=n}function S(){return l===n?c:b(Ll())}function ee(){var e=Ll(),r=v(e);if(i=arguments,a=this,u=e,r){if(l===n)return g(u);if(p)return ao(l),l=Ps(y,t),h(u)}return l===n&&(l=Ps(y,t)),c}return ee.cancel=x,ee.flush=S,ee}var Kl=V(function(e,t){return Ii(e,1,t)}),ql=V(function(e,t,n){return Ii(e,$u(t)||0,n)});function Jl(e){return Uo(e,ne)}function Yl(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw new O(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(Yl.Cache||ai),n}Yl.Cache=ai;function Xl(e){if(typeof e!=`function`)throw new O(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 Zl(e){return Bl(2,e)}var Ql=ro(function(e,t){t=t.length==1&&K(t[0])?I(t[0],cr(U())):I(z(t,1),cr(U()));var n=t.length;return V(function(r){for(var i=-1,a=N(r.length,n);++i<a;)r[i]=t[i].call(this,r[i]);return Nn(e,this,r)})}),$l=V(function(e,t){return Uo(e,S,n,t,Cr(t,ts($l)))}),eu=V(function(e,t){return Uo(e,ee,n,t,Cr(t,ts(eu)))}),tu=Xo(function(e,t){return Uo(e,te,n,n,n,t)});function nu(e,t){if(typeof e!=`function`)throw new O(o);return t=t===n?t:Z(t),V(e,t)}function ru(e,t){if(typeof e!=`function`)throw new O(o);return t=t==null?0:A(Z(t),0),V(function(n){var r=n[t],i=io(n,0,t);return r&&Vn(i,r),Nn(e,this,i)})}function iu(e,t,n){var r=!0,i=!0;if(typeof e!=`function`)throw new O(o);return Y(n)&&(r=`leading`in n?!!n.leading:r,i=`trailing`in n?!!n.trailing:i),Gl(e,t,{leading:r,maxWait:t,trailing:i})}function au(e){return zl(e,1)}function ou(e,t){return $l(to(t),e)}function su(){if(!arguments.length)return[];var e=arguments[0];return K(e)?e:[e]}function cu(e){return Ni(e,m)}function lu(e,t){return t=typeof t==`function`?t:n,Ni(e,m,t)}function uu(e){return Ni(e,f|m)}function du(e,t){return t=typeof t==`function`?t:n,Ni(e,f|m,t)}function fu(e,t){return t==null||Fi(e,t,$(t))}function pu(e,t){return e===t||e!==e&&t!==t}var mu=Ro(Zi),hu=Ro(function(e,t){return e>=t}),gu=ia(function(){return arguments}())?ia:function(e){return X(e)&&k.call(e,`callee`)&&!Yt.call(e,`callee`)},K=T.isArray,_u=Dn?cr(Dn):aa;function q(e){return e!=null&&ku(e.length)&&!Du(e)}function J(e){return X(e)&&q(e)}function vu(e){return e===!0||e===!1||X(e)&&B(e)==xe}var yu=cn||Xf,bu=On?cr(On):oa;function xu(e){return X(e)&&e.nodeType===1&&!Ru(e)}function Su(e){if(e==null)return!0;if(q(e)&&(K(e)||typeof e==`string`||typeof e.splice==`function`||yu(e)||Wu(e)||gu(e)))return!e.length;var t=W(e);if(t==De||t==Pe)return!e.size;if(Ss(e))return!ga(e).length;for(var n in e)if(k.call(e,n))return!1;return!0}function Cu(e,t){return sa(e,t)}function wu(e,t,r){r=typeof r==`function`?r:n;var i=r?r(e,t):n;return i===n?sa(e,t,n,r):!!i}function Tu(e){if(!X(e))return!1;var t=B(e);return t==we||t==Ce||typeof e.message==`string`&&typeof e.name==`string`&&!Ru(e)}function Eu(e){return typeof e==`number`&&dn(e)}function Du(e){if(!Y(e))return!1;var t=B(e);return t==Te||t==Ee||t==be||t==Me}function Ou(e){return typeof e==`number`&&e==Z(e)}function ku(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=de}function Y(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}function X(e){return typeof e==`object`&&!!e}var Au=kn?cr(kn):la;function ju(e,t){return e===t||ua(e,t,rs(t))}function Mu(e,t,r){return r=typeof r==`function`?r:n,ua(e,t,rs(t),r)}function Nu(e){return Lu(e)&&e!=+e}function Pu(e){if(xs(e))throw new Ot(a);return da(e)}function Fu(e){return e===null}function Iu(e){return e==null}function Lu(e){return typeof e==`number`||X(e)&&B(e)==Oe}function Ru(e){if(!X(e)||B(e)!=Ae)return!1;var t=qt(e);if(t===null)return!0;var n=k.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&It.call(n)==Bt}var zu=An?cr(An):fa;function Bu(e){return Ou(e)&&e>=-de&&e<=de}var Vu=jn?cr(jn):pa;function Hu(e){return typeof e==`string`||!K(e)&&X(e)&&B(e)==Fe}function Uu(e){return typeof e==`symbol`||X(e)&&B(e)==Ie}var Wu=Mn?cr(Mn):ma;function Gu(e){return e===n}function Ku(e){return X(e)&&W(e)==Re}function qu(e){return X(e)&&B(e)==ze}var Ju=Ro(va),Yu=Ro(function(e,t){return e<=t});function Xu(e){if(!e)return[];if(q(e))return Hu(e)?kr(e):H(e);if(Qt&&e[Qt])return br(e[Qt]());var t=W(e);return(t==De?xr:t==Pe?wr:Hd)(e)}function Zu(e){return e?(e=$u(e),e===ue||e===-ue?(e<0?-1:1)*fe:e===e?e:0):e===0?e:0}function Z(e){var t=Zu(e),n=t%1;return t===t?n?t-n:t:0}function Qu(e){return e?Mi(Z(e),0,me):0}function $u(e){if(typeof e==`number`)return e;if(Uu(e))return pe;if(Y(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=Y(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=sr(e);var n=xt.test(e);return n||Ct.test(e)?bn(e.slice(2),n?2:8):bt.test(e)?pe:+e}function ed(e){return _o(e,wd(e))}function td(e){return e?Mi(Z(e),-de,de):e===0?e:0}function Q(e){return e==null?``:Ka(e)}var nd=xo(function(e,t){if(Ss(t)||q(t)){_o(t,$(t),e);return}for(var n in t)k.call(t,n)&&Ti(e,n,t[n])}),rd=xo(function(e,t){_o(t,wd(t),e)}),id=xo(function(e,t,n,r){_o(t,wd(t),e,r)}),ad=xo(function(e,t,n,r){_o(t,$(t),e,r)}),od=Xo(ji);function sd(e,t){var n=Vr(e);return t==null?n:Oi(n,t)}var cd=V(function(e,t){e=E(e);var r=-1,i=t.length,a=i>2?t[2]:n;for(a&&G(t[0],t[1],a)&&(i=1);++r<i;)for(var o=t[r],s=wd(o),c=-1,l=s.length;++c<l;){var u=s[c],d=e[u];(d===n||pu(d,Pt[u])&&!k.call(e,u))&&(e[u]=o[u])}return e}),ld=V(function(e){return e.push(n,Go),Nn(Od,n,e)});function ud(e,t){return Jn(e,U(t,3),Ki)}function dd(e,t){return Jn(e,U(t,3),qi)}function fd(e,t){return e==null?e:Wi(e,U(t,3),wd)}function pd(e,t){return e==null?e:Gi(e,U(t,3),wd)}function md(e,t){return e&&Ki(e,U(t,3))}function hd(e,t){return e&&qi(e,U(t,3))}function gd(e){return e==null?[]:Ji(e,$(e))}function _d(e){return e==null?[]:Ji(e,wd(e))}function vd(e,t,r){var i=e==null?n:Yi(e,t);return i===n?r:i}function yd(e,t){return e!=null&&us(e,t,Qi)}function bd(e,t){return e!=null&&us(e,t,$i)}var xd=Mo(function(e,t,n){t!=null&&typeof t.toString!=`function`&&(t=zt.call(t)),e[t]=n},Of(Mf)),Sd=Mo(function(e,t,n){t!=null&&typeof t.toString!=`function`&&(t=zt.call(t)),k.call(e,t)?e[t].push(n):e[t]=[n]},U),Cd=V(ra);function $(e){return q(e)?bi(e):ga(e)}function wd(e){return q(e)?bi(e,!0):_a(e)}function Td(e,t){var n={};return t=U(t,3),Ki(e,function(e,r,i){Ai(n,t(e,r,i),e)}),n}function Ed(e,t){var n={};return t=U(t,3),Ki(e,function(e,r,i){Ai(n,r,t(e,r,i))}),n}var Dd=xo(function(e,t,n){Sa(e,t,n)}),Od=xo(function(e,t,n,r){Sa(e,t,n,r)}),kd=Xo(function(e,t){var n={};if(e==null)return n;var r=!1;t=I(t,function(t){return t=no(t,e),r||=t.length>1,t}),_o(e,Qo(e),n),r&&(n=Ni(n,f|p|m,Ko));for(var i=t.length;i--;)Ja(n,t[i]);return n});function Ad(e,t){return Md(e,Xl(U(t)))}var jd=Xo(function(e,t){return e==null?{}:Ea(e,t)});function Md(e,t){if(e==null)return{};var n=I(Qo(e),function(e){return[e]});return t=U(t),Da(e,n,function(e,n){return t(e,n[0])})}function Nd(e,t,r){t=no(t,e);var i=-1,a=t.length;for(a||(a=1,e=n);++i<a;){var o=e==null?n:e[Bs(t[i])];o===n&&(i=a,o=r),e=Du(o)?o.call(e):o}return e}function Pd(e,t,n){return e==null?e:Ia(e,t,n)}function Fd(e,t,r,i){return i=typeof i==`function`?i:n,e==null?e:Ia(e,t,r,i)}var Id=Ho($),Ld=Ho(wd);function Rd(e,t,n){var r=K(e),i=r||yu(e)||Wu(e);if(t=U(t,4),n==null){var a=e&&e.constructor;n=i?r?new a:[]:Y(e)&&Du(a)?Vr(qt(e)):{}}return(i?Fn:Ki)(e,function(e,r,i){return t(n,e,r,i)}),n}function zd(e,t){return e==null?!0:Ja(e,t)}function Bd(e,t,n){return e==null?e:Ya(e,t,to(n))}function Vd(e,t,r,i){return i=typeof i==`function`?i:n,e==null?e:Ya(e,t,to(r),i)}function Hd(e){return e==null?[]:lr(e,$(e))}function Ud(e){return e==null?[]:lr(e,wd(e))}function Wd(e,t,r){return r===n&&(r=t,t=n),r!==n&&(r=$u(r),r=r===r?r:0),t!==n&&(t=$u(t),t=t===t?t:0),Mi($u(e),t,r)}function Gd(e,t,r){return t=Zu(t),r===n?(r=t,t=0):r=Zu(r),e=$u(e),ea(e,t,r)}function Kd(e,t,r){if(r&&typeof r!=`boolean`&&G(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=Zu(e),t===n?(t=e,e=0):t=Zu(t)),e>t){var i=e;e=t,t=i}if(r||e%1||t%1){var a=vn();return N(e+a*(t-e+yn(`1e-`+((a+``).length-1))),t)}return ja(e,t)}var qd=Eo(function(e,t,n){return t=t.toLowerCase(),e+(n?Jd(t):t)});function Jd(e){return Sf(Q(e).toLowerCase())}function Yd(e){return e=Q(e),e&&e.replace(Tt,mr).replace(un,``)}function Xd(e,t,r){e=Q(e),t=Ka(t);var i=e.length;r=r===n?i:Mi(Z(r),0,i);var a=r;return r-=t.length,r>=0&&e.slice(r,a)==t}function Zd(e){return e=Q(e),e&&nt.test(e)?e.replace(et,hr):e}function Qd(e){return e=Q(e),e&&ut.test(e)?e.replace(lt,`\\$&`):e}var $d=Eo(function(e,t,n){return e+(n?`-`:``)+t.toLowerCase()}),ef=Eo(function(e,t,n){return e+(n?` `:``)+t.toLowerCase()}),tf=To(`toLowerCase`);function nf(e,t,n){e=Q(e),t=Z(t);var r=t?Or(e):0;if(!t||r>=t)return e;var i=(t-r)/2;return Fo(on(i),n)+e+Fo(an(i),n)}function rf(e,t,n){e=Q(e),t=Z(t);var r=t?Or(e):0;return t&&r<t?e+Fo(t-r,n):e}function af(e,t,n){e=Q(e),t=Z(t);var r=t?Or(e):0;return t&&r<t?Fo(t-r,n)+e:e}function of(e,t,n){return n||t==null?t=0:t&&=+t,_n(Q(e).replace(dt,``),t||0)}function sf(e,t,r){return t=(r?G(e,t,r):t===n)?1:Z(t),Na(Q(e),t)}function cf(){var e=arguments,t=Q(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var lf=Eo(function(e,t,n){return e+(n?`_`:``)+t.toLowerCase()});function uf(e,t,r){return r&&typeof r!=`number`&&G(e,t,r)&&(t=r=n),r=r===n?me:r>>>0,r?(e=Q(e),e&&(typeof t==`string`||t!=null&&!zu(t))&&(t=Ka(t),!t&&vr(e))?io(kr(e),0,r):e.split(t,r)):[]}var df=Eo(function(e,t,n){return e+(n?` `:``)+Sf(t)});function ff(e,t,n){return e=Q(e),n=n==null?0:Mi(Z(n),0,e.length),t=Ka(t),e.slice(n,n+t.length)==t}function pf(e,t,r){var i=L.templateSettings;r&&G(e,t,r)&&(t=n),e=Q(e),t=ad({},t,i,Wo);var a=ad({},t.imports,i.imports,Wo),o=$(a),l=lr(a,o);Fn(o,function(e){if(gt.test(e))throw new Ot(c)});var u,d,f=0,p=t.interpolate||Et,m=`__p += '`,h=jt((t.escape||Et).source+`|`+p.source+`|`+(p===at?vt:Et).source+`|`+(t.evaluate||Et).source+`|$`,`g`),g=`//# sourceURL=`+(k.call(t,`sourceURL`)?(t.sourceURL+``).replace(/\s/g,` `):`lodash.templateSources[`+ ++hn+`]`)+`
5
5
  `;e.replace(h,function(t,n,r,i,a,o){return r||=i,m+=e.slice(f,o).replace(Dt,gr),n&&(u=!0,m+=`' +
@@ -20,7 +20,7 @@ function print() { __p += __j.call(arguments, '') }
20
20
  `)+m+`return __p
21
21
  }`;var v=wf(function(){return kt(o,g+`return `+m).apply(n,l)});if(v.source=m,Tu(v))throw v;return v}function mf(e){return Q(e).toLowerCase()}function hf(e){return Q(e).toUpperCase()}function gf(e,t,r){if(e=Q(e),e&&(r||t===n))return sr(e);if(!e||!(t=Ka(t)))return e;var i=kr(e),a=kr(t);return io(i,dr(i,a),fr(i,a)+1).join(``)}function _f(e,t,r){if(e=Q(e),e&&(r||t===n))return e.slice(0,Ar(e)+1);if(!e||!(t=Ka(t)))return e;var i=kr(e);return io(i,0,fr(i,kr(t))+1).join(``)}function vf(e,t,r){if(e=Q(e),e&&(r||t===n))return e.replace(dt,``);if(!e||!(t=Ka(t)))return e;var i=kr(e);return io(i,dr(i,kr(t))).join(``)}function yf(e,t){var r=re,i=ie;if(Y(t)){var a=`separator`in t?t.separator:a;r=`length`in t?Z(t.length):r,i=`omission`in t?Ka(t.omission):i}e=Q(e);var o=e.length;if(vr(e)){var s=kr(e);o=s.length}if(r>=o)return e;var c=r-Or(i);if(c<1)return i;var l=s?io(s,0,c).join(``):e.slice(0,c);if(a===n)return l+i;if(s&&(c+=l.length-c),zu(a)){if(e.slice(c).search(a)){var u,d=l;for(a.global||(a=jt(a.source,Q(yt.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(Ka(a),c)!=c){var p=l.lastIndexOf(a);p>-1&&(l=l.slice(0,p))}return l+i}function bf(e){return e=Q(e),e&&tt.test(e)?e.replace($e,jr):e}var xf=Eo(function(e,t,n){return e+(n?` `:``)+t.toUpperCase()}),Sf=To(`toUpperCase`);function Cf(e,t,r){return e=Q(e),t=r?n:t,t===n?yr(e)?Pr(e):qn(e):e.match(t)||[]}var wf=V(function(e,t){try{return Nn(e,n,t)}catch(e){return Tu(e)?e:new Ot(e)}}),Tf=Xo(function(e,t){return Fn(t,function(t){t=Bs(t),Ai(e,t,Vl(e[t],e))}),e});function Ef(e){var t=e==null?0:e.length,n=U();return e=t?I(e,function(e){if(typeof e[1]!=`function`)throw new O(o);return[n(e[0]),e[1]]}):[],V(function(n){for(var r=-1;++r<t;){var i=e[r];if(Nn(i[0],this,n))return Nn(i[1],this,n)}})}function Df(e){return Pi(Ni(e,f))}function Of(e){return function(){return e}}function kf(e,t){return e==null||e!==e?t:e}var Af=Ao(),jf=Ao(!0);function Mf(e){return e}function Nf(e){return ha(typeof e==`function`?e:Ni(e,f))}function Pf(e){return ba(Ni(e,f))}function Ff(e,t){return xa(e,Ni(t,f))}var If=V(function(e,t){return function(n){return ra(n,e,t)}}),Lf=V(function(e,t){return function(n){return ra(e,n,t)}});function Rf(e,t,n){var r=$(t),i=Ji(t,r);n==null&&!(Y(t)&&(i.length||!r.length))&&(n=t,t=e,e=this,i=Ji(t,$(t)));var a=!(Y(n)&&`chain`in n)||!!n.chain,o=Du(e);return Fn(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__=H(this.__actions__)).push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,Vn([this.value()],arguments))})}),e}function zf(){return P._===this&&(P._=Vt),this}function Bf(){}function Vf(e){return e=Z(e),V(function(t){return wa(t,e)})}var Hf=Po(I),Uf=Po(Ln),Wf=Po(Wn);function Gf(e){return _s(e)?er(Bs(e)):Oa(e)}function Kf(e){return function(t){return e==null?n:Yi(e,t)}}var qf=Lo(),Jf=Lo(!0);function Yf(){return[]}function Xf(){return!1}function Zf(){return{}}function Qf(){return``}function $f(){return!0}function ep(e,t){if(e=Z(e),e<1||e>de)return[];var n=me,r=N(e,me);t=U(t),e-=me;for(var i=ar(r,t);++n<e;)t(n);return i}function tp(e){return K(e)?I(e,Bs):Uu(e)?[e]:H(zs(Q(e)))}function np(e){var t=++Lt;return Q(e)+t}var rp=No(function(e,t){return e+t},0),ip=Bo(`ceil`),ap=No(function(e,t){return e/t},1),op=Bo(`floor`);function sp(e){return e&&e.length?Vi(e,Mf,Zi):n}function cp(e,t){return e&&e.length?Vi(e,U(t,2),Zi):n}function lp(e){return $n(e,Mf)}function up(e,t){return $n(e,U(t,2))}function dp(e){return e&&e.length?Vi(e,Mf,va):n}function fp(e,t){return e&&e.length?Vi(e,U(t,2),va):n}var pp=No(function(e,t){return e*t},1),mp=Bo(`round`),hp=No(function(e,t){return e-t},0);function gp(e){return e&&e.length?ir(e,Mf):0}function _p(e,t){return e&&e.length?ir(e,U(t,2)):0}return L.after=Rl,L.ary=zl,L.assign=nd,L.assignIn=rd,L.assignInWith=id,L.assignWith=ad,L.at=od,L.before=Bl,L.bind=Vl,L.bindAll=Tf,L.bindKey=Hl,L.castArray=su,L.chain=el,L.chunk=Ws,L.compact=Gs,L.concat=Ks,L.cond=Ef,L.conforms=Df,L.constant=Of,L.countBy=dl,L.create=sd,L.curry=Ul,L.curryRight=Wl,L.debounce=Gl,L.defaults=cd,L.defaultsDeep=ld,L.defer=Kl,L.delay=ql,L.difference=qs,L.differenceBy=Js,L.differenceWith=Ys,L.drop=Xs,L.dropRight=Zs,L.dropRightWhile=Qs,L.dropWhile=$s,L.fill=ec,L.filter=pl,L.flatMap=gl,L.flatMapDeep=_l,L.flatMapDepth=vl,L.flatten=rc,L.flattenDeep=ic,L.flattenDepth=ac,L.flip=Jl,L.flow=Af,L.flowRight=jf,L.fromPairs=oc,L.functions=gd,L.functionsIn=_d,L.groupBy=xl,L.initial=lc,L.intersection=uc,L.intersectionBy=dc,L.intersectionWith=fc,L.invert=xd,L.invertBy=Sd,L.invokeMap=Cl,L.iteratee=Nf,L.keyBy=wl,L.keys=$,L.keysIn=wd,L.map=Tl,L.mapKeys=Td,L.mapValues=Ed,L.matches=Pf,L.matchesProperty=Ff,L.memoize=Yl,L.merge=Dd,L.mergeWith=Od,L.method=If,L.methodOf=Lf,L.mixin=Rf,L.negate=Xl,L.nthArg=Vf,L.omit=kd,L.omitBy=Ad,L.once=Zl,L.orderBy=El,L.over=Hf,L.overArgs=Ql,L.overEvery=Uf,L.overSome=Wf,L.partial=$l,L.partialRight=eu,L.partition=Dl,L.pick=jd,L.pickBy=Md,L.property=Gf,L.propertyOf=Kf,L.pull=_c,L.pullAll=vc,L.pullAllBy=yc,L.pullAllWith=bc,L.pullAt=xc,L.range=qf,L.rangeRight=Jf,L.rearg=tu,L.reject=Al,L.remove=Sc,L.rest=nu,L.reverse=Cc,L.sampleSize=Ml,L.set=Pd,L.setWith=Fd,L.shuffle=Nl,L.slice=wc,L.sortBy=Il,L.sortedUniq=jc,L.sortedUniqBy=Mc,L.split=uf,L.spread=ru,L.tail=Nc,L.take=Pc,L.takeRight=Fc,L.takeRightWhile=Ic,L.takeWhile=Lc,L.tap=tl,L.throttle=iu,L.thru=nl,L.toArray=Xu,L.toPairs=Id,L.toPairsIn=Ld,L.toPath=tp,L.toPlainObject=ed,L.transform=Rd,L.unary=au,L.union=Rc,L.unionBy=zc,L.unionWith=Bc,L.uniq=Vc,L.uniqBy=Hc,L.uniqWith=Uc,L.unset=zd,L.unzip=Wc,L.unzipWith=Gc,L.update=Bd,L.updateWith=Vd,L.values=Hd,L.valuesIn=Ud,L.without=Kc,L.words=Cf,L.wrap=ou,L.xor=qc,L.xorBy=Jc,L.xorWith=Yc,L.zip=Xc,L.zipObject=Zc,L.zipObjectDeep=Qc,L.zipWith=$c,L.entries=Id,L.entriesIn=Ld,L.extend=rd,L.extendWith=id,Rf(L,L),L.add=rp,L.attempt=wf,L.camelCase=qd,L.capitalize=Jd,L.ceil=ip,L.clamp=Wd,L.clone=cu,L.cloneDeep=uu,L.cloneDeepWith=du,L.cloneWith=lu,L.conformsTo=fu,L.deburr=Yd,L.defaultTo=kf,L.divide=ap,L.endsWith=Xd,L.eq=pu,L.escape=Zd,L.escapeRegExp=Qd,L.every=fl,L.find=ml,L.findIndex=tc,L.findKey=ud,L.findLast=hl,L.findLastIndex=nc,L.findLastKey=dd,L.floor=op,L.forEach=yl,L.forEachRight=bl,L.forIn=fd,L.forInRight=pd,L.forOwn=md,L.forOwnRight=hd,L.get=vd,L.gt=mu,L.gte=hu,L.has=yd,L.hasIn=bd,L.head=sc,L.identity=Mf,L.includes=Sl,L.indexOf=cc,L.inRange=Gd,L.invoke=Cd,L.isArguments=gu,L.isArray=K,L.isArrayBuffer=_u,L.isArrayLike=q,L.isArrayLikeObject=J,L.isBoolean=vu,L.isBuffer=yu,L.isDate=bu,L.isElement=xu,L.isEmpty=Su,L.isEqual=Cu,L.isEqualWith=wu,L.isError=Tu,L.isFinite=Eu,L.isFunction=Du,L.isInteger=Ou,L.isLength=ku,L.isMap=Au,L.isMatch=ju,L.isMatchWith=Mu,L.isNaN=Nu,L.isNative=Pu,L.isNil=Iu,L.isNull=Fu,L.isNumber=Lu,L.isObject=Y,L.isObjectLike=X,L.isPlainObject=Ru,L.isRegExp=zu,L.isSafeInteger=Bu,L.isSet=Vu,L.isString=Hu,L.isSymbol=Uu,L.isTypedArray=Wu,L.isUndefined=Gu,L.isWeakMap=Ku,L.isWeakSet=qu,L.join=pc,L.kebabCase=$d,L.last=mc,L.lastIndexOf=hc,L.lowerCase=ef,L.lowerFirst=tf,L.lt=Ju,L.lte=Yu,L.max=sp,L.maxBy=cp,L.mean=lp,L.meanBy=up,L.min=dp,L.minBy=fp,L.stubArray=Yf,L.stubFalse=Xf,L.stubObject=Zf,L.stubString=Qf,L.stubTrue=$f,L.multiply=pp,L.nth=gc,L.noConflict=zf,L.noop=Bf,L.now=Ll,L.pad=nf,L.padEnd=rf,L.padStart=af,L.parseInt=of,L.random=Kd,L.reduce=Ol,L.reduceRight=kl,L.repeat=sf,L.replace=cf,L.result=Nd,L.round=mp,L.runInContext=e,L.sample=jl,L.size=Pl,L.snakeCase=lf,L.some=Fl,L.sortedIndex=Tc,L.sortedIndexBy=Ec,L.sortedIndexOf=Dc,L.sortedLastIndex=Oc,L.sortedLastIndexBy=kc,L.sortedLastIndexOf=Ac,L.startCase=df,L.startsWith=ff,L.subtract=hp,L.sum=gp,L.sumBy=_p,L.template=pf,L.times=ep,L.toFinite=Zu,L.toInteger=Z,L.toLength=Qu,L.toLower=mf,L.toNumber=$u,L.toSafeInteger=td,L.toString=Q,L.toUpper=hf,L.trim=gf,L.trimEnd=_f,L.trimStart=vf,L.truncate=yf,L.unescape=bf,L.uniqueId=np,L.upperCase=xf,L.upperFirst=Sf,L.each=yl,L.eachRight=bl,L.first=sc,Rf(L,function(){var e={};return Ki(L,function(t,n){k.call(L.prototype,n)||(e[n]=t)}),e}(),{chain:!1}),L.VERSION=r,Fn([`bind`,`bindKey`,`curry`,`curryRight`,`partial`,`partialRight`],function(e){L[e].placeholder=L}),Fn([`drop`,`take`],function(e,t){R.prototype[e]=function(r){r=r===n?1:A(Z(r),0);var i=this.__filtered__&&!t?new R(this):this.clone();return i.__filtered__?i.__takeCount__=N(r,i.__takeCount__):i.__views__.push({size:N(r,me),type:e+(i.__dir__<0?`Right`:``)}),i},R.prototype[e+`Right`]=function(t){return this.reverse()[e](t).reverse()}}),Fn([`filter`,`map`,`takeWhile`],function(e,t){var n=t+1,r=n==se||n==le;R.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:U(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}}),Fn([`head`,`last`],function(e,t){var n=`take`+(t?`Right`:``);R.prototype[e]=function(){return this[n](1).value()[0]}}),Fn([`initial`,`tail`],function(e,t){var n=`drop`+(t?``:`Right`);R.prototype[e]=function(){return this.__filtered__?new R(this):this[n](1)}}),R.prototype.compact=function(){return this.filter(Mf)},R.prototype.find=function(e){return this.filter(e).head()},R.prototype.findLast=function(e){return this.reverse().find(e)},R.prototype.invokeMap=V(function(e,t){return typeof e==`function`?new R(this):this.map(function(n){return ra(n,e,t)})}),R.prototype.reject=function(e){return this.filter(Xl(U(e)))},R.prototype.slice=function(e,t){e=Z(e);var r=this;return r.__filtered__&&(e>0||t<0)?new R(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==n&&(t=Z(t),r=t<0?r.dropRight(-t):r.take(t-e)),r)},R.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},R.prototype.toArray=function(){return this.take(me)},Ki(R.prototype,function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),a=L[i?`take`+(t==`last`?`Right`:``):t],o=i||/^find/.test(t);a&&(L.prototype[t]=function(){var t=this.__wrapped__,s=i?[1]:arguments,c=t instanceof R,l=s[0],u=c||K(t),d=function(e){var t=a.apply(L,Vn([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 R(this);var g=e.apply(t,s);return g.__actions__.push({func:nl,args:[d],thisArg:n}),new Ur(g,f)}return m&&h?e.apply(this,s):(g=this.thru(d),m?i?g.value()[0]:g.value():g)})}),Fn([`pop`,`push`,`shift`,`sort`,`splice`,`unshift`],function(e){var t=Mt[e],n=/^(?:push|sort|unshift)$/.test(e)?`tap`:`thru`,r=/^(?:pop|shift)$/.test(e);L.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(K(i)?i:[],e)}return this[n](function(n){return t.apply(K(n)?n:[],e)})}}),Ki(R.prototype,function(e,t){var n=L[t];if(n){var r=n.name+``;k.call(tr,r)||(tr[r]=[]),tr[r].push({name:t,func:n})}}),tr[jo(n,v).name]=[{name:`wrapper`,func:n}],R.prototype.clone=Wr,R.prototype.reverse=Gr,R.prototype.value=Kr,L.prototype.at=rl,L.prototype.chain=il,L.prototype.commit=al,L.prototype.next=ol,L.prototype.plant=cl,L.prototype.reverse=ll,L.prototype.toJSON=L.prototype.valueOf=L.prototype.value=ul,L.prototype.first=L.prototype.head,Qt&&(L.prototype[Qt]=sl),L})();typeof define==`function`&&typeof define.amd==`object`&&define.amd?(P._=Fr,define(function(){return Fr})):wn?((wn.exports=Fr)._=Fr,Cn._=Fr):P._=Fr}).call(e)}))(),se=e=>{let t=(0,oe.startCase)(e).toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)},ce=/serverVariables\s*:\s*\{/,le=/defineApplication\s*\(\s*\{/,ue=async({projectRoot:e,variables:t})=>{let n=await ie(e);if(n===null)return{status:`skipped-no-config`};let r=await(0,u.readFile)(n,`utf8`),i=t.filter(e=>!RegExp(`\\b${e.name}\\s*:`).test(r));if(i.length===0)return{status:`skipped-existing`};let a=de(i);if(ce.test(r))return await(0,u.writeFile)(n,r.replace(ce,e=>`${e}\n${a}`),`utf8`),{status:`appended`,file:n};if(!le.test(r))return{status:`skipped-no-app-call`};let o=r.replace(/\n(\s*)\}\s*\)\s*;?\s*$/,(e,t)=>`\n${t}${fe(i,t)}\n${t}});\n`);return o===r?{status:`skipped-no-app-call`}:(await(0,u.writeFile)(n,o,`utf8`),{status:`created`,file:n})},de=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
  `),fe=(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}},`,pe=({data:e})=>{let t=(0,s.v4)(),r=e.description?`\n description: '${e.description}',`:``;if(e.type===n.It.RELATION||e.type===n.It.MORPH_RELATION){let i=e.onDelete&&e.onDelete!==`None`,a=`import { defineField, FieldType, RelationType${i?`, OnDeleteAction`:``} } from 'twenty-sdk/define';`,o=i?`, onDelete: OnDeleteAction.${e.onDelete}`:``,c=e.relationType===n.yt.MANY_TO_ONE?`, joinColumnName: '${e.name}Id'`:``,l=e.type===n.It.MORPH_RELATION?`\n morphId: '${(0,s.v4)()}',`:``;return`${a}
23
+ `)}\n${t}},`,pe=({data:e})=>{let t=(0,s.v4)(),r=e.description?`\n description: '${e.description}',`:``;if(e.type===n.Rt.RELATION||e.type===n.Rt.MORPH_RELATION){let i=e.onDelete&&e.onDelete!==`None`,a=`import { defineField, FieldType, RelationType${i?`, OnDeleteAction`:``} } from 'twenty-sdk/define';`,o=i?`, onDelete: OnDeleteAction.${e.onDelete}`:``,c=e.relationType===n.Mt.MANY_TO_ONE?`, joinColumnName: '${e.name}Id'`:``,l=e.type===n.Rt.MORPH_RELATION?`\n morphId: '${(0,s.v4)()}',`:``;return`${a}
24
24
 
25
25
  export default defineField({
26
26
  universalIdentifier: '${t}',
@@ -145,7 +145,7 @@ export default defineCommandMenuItem({
145
145
  label: '${e}',
146
146
  availabilityType: 'GLOBAL',
147
147
  });
148
- `,ye=({name:e,type:t})=>{let r=t===n.kt.DASHBOARD?n.Dt.GRID:n.Dt.VERTICAL_LIST;return`import {
148
+ `,ye=({name:e,type:t})=>{let r=t===n.Dt.DASHBOARD?n.Bt.GRID:n.Bt.VERTICAL_LIST;return`import {
149
149
  definePageLayout,
150
150
  PageLayoutTabLayoutMode,
151
151
  PageLayoutType,
@@ -318,7 +318,7 @@ export default defineView({
318
318
  universalIdentifier: '${t}',
319
319
  name: '${l}',
320
320
  objectUniversalIdentifier: '${i}',
321
- ${c===void 0?``:` type: '${c}',\n`} icon: '${n.at[c??n._t.TABLE]}',
321
+ ${c===void 0?``:` type: '${c}',\n`} icon: '${n.ot[c??n.Lt.TABLE]}',
322
322
  position: 0,
323
323
  ${u}
324
324
  // filters: [
@@ -367,10 +367,10 @@ export default defineTimelineActivityType({
367
367
  name: '${e}',
368
368
  label: '${e}',
369
369
  });
370
- `,Me=`src/application.config.ts`,Ne=`src`,Pe=class{async execute(e,r){try{let i=await ae(t.U),o=e??await this.getEntity(),s=this.getFolderName(o),c=r?(0,a.join)(t.U,r):(0,a.join)(t.U,Ne,s);await t.F(c);let{name:l,file:d}=await this.getEntityData(o,i),f=(0,a.join)(c,this.getFileName(l,o));if(await t.R(f)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,u.writeFile)(f,d),console.log(p.default.green(`✓ Created ${s}:`),p.default.cyan((0,a.relative)(t.U,f))),o===n.c.Object&&await this.promptAndCreateObjectCompanions({objectName:l,applicationUniversalIdentifier:i,customPath:r}),o===n.c.ConnectionProvider&&await this.registerConnectionProviderServerVariables(l)}catch(e){console.error(p.default.red(`Add new entity failed:`),e instanceof Error?e.message:e),process.exit(1)}}async getEntityData(e,t){switch(e){case n.c.Object:{let e=await this.getObjectData(),t=e.nameSingular,n=(0,s.v4)(),r=(0,s.v4)();return this.lastObjectUniversalIdentifier=n,this.lastNameFieldUniversalIdentifier=r,this.lastObjectLabelSingular=e.labelSingular,{name:t,file:_e({data:e,name:t,universalIdentifier:n,nameFieldUniversalIdentifier:r})}}case n.c.Field:{let e=await this.getFieldData(),t=e.name;return{name:t,file:pe({data:e,name:t})}}case n.c.LogicFunction:{let t=await this.getEntityName(e);return{name:t,file:he({name:t})}}case n.c.FrontComponent:{let t=await this.getEntityName(e);return{name:t,file:me({name:t})}}case n.c.Role:{let t=await this.getEntityName(e);return{name:t,file:Ce({name:t})}}case n.c.Skill:{let t=await this.getEntityName(e);return{name:t,file:Ee({name:t})}}case n.c.Agent:{let t=await this.getEntityName(e);return{name:t,file:we({name:t})}}case n.c.ConnectionProvider:{let t=await this.getEntityName(e);return{name:t,file:Te({name:t})}}case n.c.View:{let e=await this.getViewData(),n=e.name;return{name:n,file:Oe({name:n,objectUniversalIdentifier:e.objectUniversalIdentifier,applicationUniversalIdentifier:t})}}case n.c.ViewField:return{name:await this.getEntityName(e),file:ke({})};case n.c.NavigationMenuItem:{let t=await this.getEntityName(e);return{name:t,file:ge({name:t})}}case n.c.PageLayout:{let t=await this.getEntityName(e),{type:r}=await m.default.prompt([{type:`select`,name:`type`,message:`Select the page layout type:`,choices:Object.values(n.kt)}]);return{name:t,file:ye({name:t,type:r})}}case n.c.PageLayoutTab:{let t=await this.getEntityName(e);return{name:t,file:be({name:t})}}case n.c.PageLayoutWidget:{let t=await this.getEntityName(e);return{name:t,file:xe({name:t})}}case n.c.CommandMenuItem:{let t=await this.getEntityName(e);return{name:t,file:ve({name:t})}}case n.c.TimelineActivityType:{let t=await this.getEntityName(e);return{name:t,file:je({name:t})}}case n.c.SettingsMenuItem:{let t=await this.getEntityName(e);return{name:t,file:Ae({name:t})}}default:n.Q(e)}}async promptAndCreateObjectCompanions({objectName:e,applicationUniversalIdentifier:i,customPath:o}){let{createCompanions:c}=await m.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(!c||!this.lastObjectUniversalIdentifier)return;let l=(0,s.v4)(),d=(0,s.v4)(),f=Oe({name:`all-${r.E(e)}`,universalIdentifier:l,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,applicationUniversalIdentifier:i,fields:this.lastNameFieldUniversalIdentifier?[{fieldMetadataUniversalIdentifier:this.lastNameFieldUniversalIdentifier,position:0,isVisible:!0,size:200}]:[]}),h=o?(0,a.join)(t.U,o):(0,a.join)(t.U,Ne,this.getFolderName(n.c.View));await t.F(h);let g=(0,a.join)(h,`all-${r.E(e)}.ts`);if(await t.R(g)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,u.writeFile)(g,f),console.log(p.default.green(`✓ Created view:`),p.default.cyan((0,a.relative)(t.U,g)));let _=this.buildRecordPageFieldsViewFields(this.lastNameFieldUniversalIdentifier),v=Oe({name:`${r.E(e)}-record-page-fields`,universalIdentifier:d,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,applicationUniversalIdentifier:i,type:n._t.FIELDS_WIDGET,fields:_}),y=(0,a.join)(h,`${r.E(e)}-record-page-fields.ts`);if(await t.R(y)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,u.writeFile)(y,v),console.log(p.default.green(`✓ Created record-page-fields view:`),p.default.cyan((0,a.relative)(t.U,y)));let b=ge({name:e,type:`OBJECT`,targetObjectUniversalIdentifier:this.lastObjectUniversalIdentifier}),x=o?(0,a.join)(t.U,o):(0,a.join)(t.U,Ne,this.getFolderName(n.c.NavigationMenuItem));await t.F(x);let S=(0,a.join)(x,`${r.E(e)}.ts`);if(await t.R(S)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,u.writeFile)(S,b),console.log(p.default.green(`✓ Created navigation menu item:`),p.default.cyan((0,a.relative)(t.U,S)));let ee=Se({objectLabelSingular:this.lastObjectLabelSingular??e,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,fieldsWidgetViewUniversalIdentifier:d}),C=o?(0,a.join)(t.U,o):(0,a.join)(t.U,Ne,this.getFolderName(n.c.PageLayout));await t.F(C);let te=(0,a.join)(C,`${r.E(e)}-record-page-layout.ts`);if(await t.R(te)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,u.writeFile)(te,ee),console.log(p.default.green(`✓ Created record page layout:`),p.default.cyan((0,a.relative)(t.U,te)))}async registerConnectionProviderServerVariables(e){let n=r.E(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}],o=await ue({projectRoot:t.U,variables:i});switch(o.status){case`appended`:case`created`:console.log(p.default.green(`✓ Added ${i.map(e=>e.name).join(` + `)} to defineApplication.serverVariables:`),p.default.cyan((0,a.relative)(t.U,o.file)));break;case`skipped-existing`:console.log(p.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(p.default.yellow(`! Couldn't auto-update ${Me}. Add these manually to defineApplication.serverVariables:\n`+i.map(e=>` ${e.name}: { description: '...', isSecret: ${e.isSecret}, isRequired: true },`).join(`
371
- `)));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 m.default.prompt([{type:`select`,name:`entity`,message:`What entity do you want to create?`,default:``,choices:Object.values(n.c)}]);return e}async handleFileExist(){return await m.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 m.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===n.It.RELATION||e===n.It.MORPH_RELATION;return m.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=>se(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(n.It),default:n.It.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(n.yt),default:n.yt.ONE_TO_MANY,when:t=>e(t.type)},{type:`select`,name:`onDelete`,message:`Select the onDelete behavior:`,choices:Object.values(n.dt),default:n.dt.CASCADE,when:t=>e(t.type)}])}async getObjectData(){return m.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=>se(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=>se(e.namePlural),validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0}])}async getViewData(){return m.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`${r.E(e)}s`}getFileName(e,t){switch(t){case n.c.FrontComponent:return`${r.E(e)}.tsx`;default:return`${r.E(e)}.ts`}}},Fe=class{async execute(e){let n=e.appPath??t.U;await S(n),console.log(p.default.blue(`Building application...`)),console.log(p.default.gray(`App path: ${n}\n`));let i=await r.$({appPath:n,tarball:e.tarball,onProgress:e=>console.log(p.default.gray(e))});i.success||(console.error(p.default.red(i.error.message)),process.exit(1)),console.log(p.default.green(`✓ Build succeeded (${i.data.fileCount} file${i.data.fileCount===1?``:`s`})`)),console.log(p.default.gray(`Output: ${i.data.outputDir}`)),i.data.tarballPath&&console.log(p.default.gray(`Tarball: ${i.data.tarballPath}`))}},Ie=class{async execute({appPath:n=t.U,postInstall:i=!1,preInstall:a=!1,uninstall:o=!1,functionUniversalIdentifier:s,functionName:c,payload:l=`{}`}){let u;try{u=JSON.parse(l)}catch{console.error(p.default.red(`Invalid JSON payload. Please provide valid JSON.`)),process.exit(1)}let d=i?`post install`:a?`pre install`:o?`uninstall`:s??c,f=r.Z.getActiveRemote();console.log(p.default.blue(`🚀 Executing function "${d}" on ${f}...`)),console.log(p.default.gray(` Payload: ${JSON.stringify(u)}\n`));let m=await r.T(i?{appPath:n,postInstall:!0,payload:u}:a?{appPath:n,preInstall:!0,payload:u}:o?{appPath:n,uninstall:!0,payload:u}:s?{appPath:n,functionUniversalIdentifier:s,payload:u}:{appPath:n,functionName:c,payload:u});if(!m.success){switch(m.error.code){case r.et.MANIFEST_NOT_FOUND:console.error(p.default.red(`Failed to build manifest.`));break;case r.nt.FETCH_FUNCTIONS_FAILED:console.error(p.default.red(`Failed to fetch functions:`),m.error.message);break;case r.nt.FUNCTION_NOT_FOUND:{console.error(p.default.red(m.error.message),`
370
+ `,Me=`src/application.config.ts`,Ne=`src`,Pe=class{async execute(e,r){try{let i=await ae(t.U),o=e??await this.getEntity(),s=this.getFolderName(o),c=r?(0,a.join)(t.U,r):(0,a.join)(t.U,Ne,s);await t.F(c);let{name:l,file:d}=await this.getEntityData(o,i),f=(0,a.join)(c,this.getFileName(l,o));if(await t.R(f)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,u.writeFile)(f,d),console.log(p.default.green(`✓ Created ${s}:`),p.default.cyan((0,a.relative)(t.U,f))),o===n.c.Object&&await this.promptAndCreateObjectCompanions({objectName:l,applicationUniversalIdentifier:i,customPath:r}),o===n.c.ConnectionProvider&&await this.registerConnectionProviderServerVariables(l)}catch(e){console.error(p.default.red(`Add new entity failed:`),e instanceof Error?e.message:e),process.exit(1)}}async getEntityData(e,t){switch(e){case n.c.Object:{let e=await this.getObjectData(),t=e.nameSingular,n=(0,s.v4)(),r=(0,s.v4)();return this.lastObjectUniversalIdentifier=n,this.lastNameFieldUniversalIdentifier=r,this.lastObjectLabelSingular=e.labelSingular,{name:t,file:_e({data:e,name:t,universalIdentifier:n,nameFieldUniversalIdentifier:r})}}case n.c.Field:{let e=await this.getFieldData(),t=e.name;return{name:t,file:pe({data:e,name:t})}}case n.c.LogicFunction:{let t=await this.getEntityName(e);return{name:t,file:he({name:t})}}case n.c.FrontComponent:{let t=await this.getEntityName(e);return{name:t,file:me({name:t})}}case n.c.Role:{let t=await this.getEntityName(e);return{name:t,file:Ce({name:t})}}case n.c.Skill:{let t=await this.getEntityName(e);return{name:t,file:Ee({name:t})}}case n.c.Agent:{let t=await this.getEntityName(e);return{name:t,file:we({name:t})}}case n.c.ConnectionProvider:{let t=await this.getEntityName(e);return{name:t,file:Te({name:t})}}case n.c.View:{let e=await this.getViewData(),n=e.name;return{name:n,file:Oe({name:n,objectUniversalIdentifier:e.objectUniversalIdentifier,applicationUniversalIdentifier:t})}}case n.c.ViewField:return{name:await this.getEntityName(e),file:ke({})};case n.c.NavigationMenuItem:{let t=await this.getEntityName(e);return{name:t,file:ge({name:t})}}case n.c.PageLayout:{let t=await this.getEntityName(e),{type:r}=await m.default.prompt([{type:`select`,name:`type`,message:`Select the page layout type:`,choices:Object.values(n.Dt)}]);return{name:t,file:ye({name:t,type:r})}}case n.c.PageLayoutTab:{let t=await this.getEntityName(e);return{name:t,file:be({name:t})}}case n.c.PageLayoutWidget:{let t=await this.getEntityName(e);return{name:t,file:xe({name:t})}}case n.c.CommandMenuItem:{let t=await this.getEntityName(e);return{name:t,file:ve({name:t})}}case n.c.TimelineActivityType:{let t=await this.getEntityName(e);return{name:t,file:je({name:t})}}case n.c.SettingsMenuItem:{let t=await this.getEntityName(e);return{name:t,file:Ae({name:t})}}default:n.W(e)}}async promptAndCreateObjectCompanions({objectName:e,applicationUniversalIdentifier:i,customPath:o}){let{createCompanions:c}=await m.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(!c||!this.lastObjectUniversalIdentifier)return;let l=(0,s.v4)(),d=(0,s.v4)(),f=Oe({name:`all-${r.E(e)}`,universalIdentifier:l,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,applicationUniversalIdentifier:i,fields:this.lastNameFieldUniversalIdentifier?[{fieldMetadataUniversalIdentifier:this.lastNameFieldUniversalIdentifier,position:0,isVisible:!0,size:200}]:[]}),h=o?(0,a.join)(t.U,o):(0,a.join)(t.U,Ne,this.getFolderName(n.c.View));await t.F(h);let g=(0,a.join)(h,`all-${r.E(e)}.ts`);if(await t.R(g)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,u.writeFile)(g,f),console.log(p.default.green(`✓ Created view:`),p.default.cyan((0,a.relative)(t.U,g)));let _=this.buildRecordPageFieldsViewFields(this.lastNameFieldUniversalIdentifier),v=Oe({name:`${r.E(e)}-record-page-fields`,universalIdentifier:d,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,applicationUniversalIdentifier:i,type:n.Lt.FIELDS_WIDGET,fields:_}),y=(0,a.join)(h,`${r.E(e)}-record-page-fields.ts`);if(await t.R(y)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,u.writeFile)(y,v),console.log(p.default.green(`✓ Created record-page-fields view:`),p.default.cyan((0,a.relative)(t.U,y)));let b=ge({name:e,type:`OBJECT`,targetObjectUniversalIdentifier:this.lastObjectUniversalIdentifier}),x=o?(0,a.join)(t.U,o):(0,a.join)(t.U,Ne,this.getFolderName(n.c.NavigationMenuItem));await t.F(x);let S=(0,a.join)(x,`${r.E(e)}.ts`);if(await t.R(S)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,u.writeFile)(S,b),console.log(p.default.green(`✓ Created navigation menu item:`),p.default.cyan((0,a.relative)(t.U,S)));let ee=Se({objectLabelSingular:this.lastObjectLabelSingular??e,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,fieldsWidgetViewUniversalIdentifier:d}),C=o?(0,a.join)(t.U,o):(0,a.join)(t.U,Ne,this.getFolderName(n.c.PageLayout));await t.F(C);let te=(0,a.join)(C,`${r.E(e)}-record-page-layout.ts`);if(await t.R(te)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,u.writeFile)(te,ee),console.log(p.default.green(`✓ Created record page layout:`),p.default.cyan((0,a.relative)(t.U,te)))}async registerConnectionProviderServerVariables(e){let n=r.E(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}],o=await ue({projectRoot:t.U,variables:i});switch(o.status){case`appended`:case`created`:console.log(p.default.green(`✓ Added ${i.map(e=>e.name).join(` + `)} to defineApplication.serverVariables:`),p.default.cyan((0,a.relative)(t.U,o.file)));break;case`skipped-existing`:console.log(p.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(p.default.yellow(`! Couldn't auto-update ${Me}. Add these manually to defineApplication.serverVariables:\n`+i.map(e=>` ${e.name}: { description: '...', isSecret: ${e.isSecret}, isRequired: true },`).join(`
371
+ `)));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 m.default.prompt([{type:`select`,name:`entity`,message:`What entity do you want to create?`,default:``,choices:Object.values(n.c)}]);return e}async handleFileExist(){return await m.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 m.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===n.Rt.RELATION||e===n.Rt.MORPH_RELATION;return m.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=>se(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(n.Rt),default:n.Rt.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(n.Mt),default:n.Mt.ONE_TO_MANY,when:t=>e(t.type)},{type:`select`,name:`onDelete`,message:`Select the onDelete behavior:`,choices:Object.values(n.bt),default:n.bt.CASCADE,when:t=>e(t.type)}])}async getObjectData(){return m.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=>se(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=>se(e.namePlural),validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0}])}async getViewData(){return m.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`${r.E(e)}s`}getFileName(e,t){switch(t){case n.c.FrontComponent:return`${r.E(e)}.tsx`;default:return`${r.E(e)}.ts`}}},Fe=class{async execute(e){let n=e.appPath??t.U;await S(n),console.log(p.default.blue(`Building application...`)),console.log(p.default.gray(`App path: ${n}\n`));let i=await r.$({appPath:n,tarball:e.tarball,onProgress:e=>console.log(p.default.gray(e))});i.success||(console.error(p.default.red(i.error.message)),process.exit(1)),console.log(p.default.green(`✓ Build succeeded (${i.data.fileCount} file${i.data.fileCount===1?``:`s`})`)),console.log(p.default.gray(`Output: ${i.data.outputDir}`)),i.data.tarballPath&&console.log(p.default.gray(`Tarball: ${i.data.tarballPath}`))}},Ie=class{async execute({appPath:n=t.U,postInstall:i=!1,preInstall:a=!1,uninstall:o=!1,functionUniversalIdentifier:s,functionName:c,payload:l=`{}`}){let u;try{u=JSON.parse(l)}catch{console.error(p.default.red(`Invalid JSON payload. Please provide valid JSON.`)),process.exit(1)}let d=i?`post install`:a?`pre install`:o?`uninstall`:s??c,f=r.Z.getActiveRemote();console.log(p.default.blue(`🚀 Executing function "${d}" on ${f}...`)),console.log(p.default.gray(` Payload: ${JSON.stringify(u)}\n`));let m=await r.T(i?{appPath:n,postInstall:!0,payload:u}:a?{appPath:n,preInstall:!0,payload:u}:o?{appPath:n,uninstall:!0,payload:u}:s?{appPath:n,functionUniversalIdentifier:s,payload:u}:{appPath:n,functionName:c,payload:u});if(!m.success){switch(m.error.code){case r.et.MANIFEST_NOT_FOUND:console.error(p.default.red(`Failed to build manifest.`));break;case r.nt.FETCH_FUNCTIONS_FAILED:console.error(p.default.red(`Failed to fetch functions:`),m.error.message);break;case r.nt.FUNCTION_NOT_FOUND:{console.error(p.default.red(m.error.message),`
372
372
  `);let e=m.error.details?.availableFunctions??[];e.length>0?(console.log(p.default.cyan(`Available functions:`)),e.forEach(e=>{console.log(` - ${p.default.white(e.name)} (${e.universalIdentifier})`)})):console.log(p.default.yellow("No functions found for this application. Have you synced your app with `twenty dev`?"));break}case r.nt.EXECUTION_FAILED:console.error(p.default.red(`Execution failed:`),m.error.message);break;default:console.error(p.default.red(m.error.message))}process.exit(1)}let h=m.data;console.log(p.default.cyan(`─`.repeat(60))),console.log(p.default.cyan(`Execution Result`)),console.log(p.default.cyan(`─`.repeat(60)));let g=h.status===`SUCCESS`?p.default.green:p.default.red;console.log(`${p.default.bold(`Status:`)} ${g(h.status)}`),console.log(`${p.default.bold(`Duration:`)} ${h.duration}ms\n`),e.t(h.data)&&(console.log(p.default.bold(`Data:`)),console.log(p.default.white(JSON.stringify(h.data,null,2)))),h.error&&(console.log(p.default.bold.red(`Error:`)),console.log(p.default.red(` Type: ${h.error.errorType}`)),console.log(p.default.red(` Message: ${h.error.errorMessage}\n`)),h.error.stackTrace&&(console.log(p.default.gray(`Stack trace:`)),console.log(p.default.gray(h.error.stackTrace)))),h.logs&&(console.log(p.default.bold(`Logs:`)),console.log(p.default.gray(h.logs))),console.log(p.default.cyan(`─`.repeat(60))),h.status!==`SUCCESS`&&process.exit(1)}},Le=class{constructor(){this.apiService=new r.q}async execute({appPath:e=t.U,functionUniversalIdentifier:n,functionName:i}){try{let t=await r.W(e);t||process.exit(1),this.logWatchInfo({appName:t.application.displayName,functionUniversalIdentifier:n,functionName:i}),await this.apiService.subscribeToLogs({applicationUniversalIdentifier:t.application.universalIdentifier,functionUniversalIdentifier:n,functionName:i})}catch(e){console.error(p.default.red(`Watch logs failed:`),e instanceof Error?e.message:e),process.exit(1)}}logWatchInfo({appName:e,functionUniversalIdentifier:t,functionName:n}){let i=e??`Twenty Application`,a=t||n?`function "${t||n}"`:`functions`,o=r.Z.getActiveRemote();console.log(p.default.blue(`🚀 Watching ${i} ${a} logs on ${o}:\n`))}},Re=e=>`${p.default.cyan(e.file)}:${p.default.yellow(String(e.line))}:${p.default.yellow(String(e.column+1))} - ${p.default.red(`error`)} ${e.text}`,ze=class{async execute(e){let n=e.appPath??t.U;console.log(p.default.blue(`Running type check...`)),console.log(p.default.gray(`App path: ${n}\n`));let r=await t.O(n);r.length===0&&(console.log(p.default.green(`✓ No type errors found`)),process.exit(0));for(let e of r)console.log(Re(e));console.log(`
373
- `,p.default.red(`✗ Found ${r.length} type error${r.length===1?``:`s`}`)),process.exit(1)}},w=(e,t)=>console.warn(p.default.yellow(`⚠ \`twenty ${e}\` is deprecated. Use \`twenty ${t}\` instead.`)),Be=e=>{let t=new Fe,n=new ze,r=new Le,i=new Ie,a=new Pe,o=new ee,s=new C,c=new te;e.command(`build [appPath]`,{hidden:!0}).option(`--tarball`,`Also pack into a .tgz tarball`).action(async(e,n)=>{w(`build`,`dev:build`),await t.execute({appPath:y(e),tarball:n.tarball})}),e.command(`typecheck [appPath]`,{hidden:!0}).action(async e=>{w(`typecheck`,`dev:typecheck`),await n.execute({appPath:y(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)=>{w(`logs`,`dev:function:logs`),await r.execute({...t,appPath:y(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)=>{w(`exec`,`dev:function:exec`),!t?.postInstall&&!t?.preInstall&&!t?.functionUniversalIdentifier&&!t?.functionName&&(console.error(p.default.red(`Error: Either --postInstall, --preInstall, --functionName (-n), or --functionUniversalIdentifier (-u) is required.`)),process.exit(1)),await i.execute({...t,payload:t?.payload??`{}`,appPath:y(e)})}),e.command(`add [entityType]`,{hidden:!0}).option(`--path <path>`,`Path in which the entity should be created.`).action(async(e,t)=>{w(`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)=>{w(`publish`,`app:publish`),await o.execute({appPath:y(e),tag:t.tag})}),e.command(`deploy [appPath]`,{hidden:!0}).option(`-r, --remote <name>`,`Deploy to a specific remote`).action(async(e,t)=>{w(`deploy`,`app:publish --private`),await o.execute({appPath:y(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)=>{w(`install`,`app:install`),await s.execute({appPath:y(e),remote:t.remote})}),e.command(`uninstall [appPath]`,{hidden:!0}).option(`-y, --yes`,`Skip confirmation prompt`).action(async(e,t)=>{w(`uninstall`,`app:uninstall`);try{let n=await c.execute({appPath:y(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=>{w(`catalog-sync`,`dev:catalog-sync`);let{CatalogSyncCommand:t}=await Promise.resolve().then(()=>require("./catalog-sync-DxcdSEBJ.js"));await new t().execute({remote:e.remote})})},Ve=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.o(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}},He=class{constructor({apiService:e,state:t,notify:n}){this.hasRetried=!1,this.apiService=e,this.state=t,this.notify=n}async execute(){let t=this.state.steps.checkServer,n=await this.apiService.validateAuth();if(!n.serverUp){let e=await r.C();return e&&!this.hasRetried?(this.hasRetried=!0,await new r.Z().setConfig({apiUrl:e}),this.execute()):(t.output.errorLogged||(t.output={isReady:!1,errorLogged:!0},t.status=`error`,this.state.applyStepEvents([{message:`Cannot reach Twenty server.
373
+ `,p.default.red(`✗ Found ${r.length} type error${r.length===1?``:`s`}`)),process.exit(1)}},w=(e,t)=>console.warn(p.default.yellow(`⚠ \`twenty ${e}\` is deprecated. Use \`twenty ${t}\` instead.`)),Be=e=>{let t=new Fe,n=new ze,r=new Le,i=new Ie,a=new Pe,o=new ee,s=new C,c=new te;e.command(`build [appPath]`,{hidden:!0}).option(`--tarball`,`Also pack into a .tgz tarball`).action(async(e,n)=>{w(`build`,`dev:build`),await t.execute({appPath:y(e),tarball:n.tarball})}),e.command(`typecheck [appPath]`,{hidden:!0}).action(async e=>{w(`typecheck`,`dev:typecheck`),await n.execute({appPath:y(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)=>{w(`logs`,`dev:function:logs`),await r.execute({...t,appPath:y(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)=>{w(`exec`,`dev:function:exec`),!t?.postInstall&&!t?.preInstall&&!t?.functionUniversalIdentifier&&!t?.functionName&&(console.error(p.default.red(`Error: Either --postInstall, --preInstall, --functionName (-n), or --functionUniversalIdentifier (-u) is required.`)),process.exit(1)),await i.execute({...t,payload:t?.payload??`{}`,appPath:y(e)})}),e.command(`add [entityType]`,{hidden:!0}).option(`--path <path>`,`Path in which the entity should be created.`).action(async(e,t)=>{w(`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)=>{w(`publish`,`app:publish`),await o.execute({appPath:y(e),tag:t.tag})}),e.command(`deploy [appPath]`,{hidden:!0}).option(`-r, --remote <name>`,`Deploy to a specific remote`).action(async(e,t)=>{w(`deploy`,`app:publish --private`),await o.execute({appPath:y(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)=>{w(`install`,`app:install`),await s.execute({appPath:y(e),remote:t.remote})}),e.command(`uninstall [appPath]`,{hidden:!0}).option(`-y, --yes`,`Skip confirmation prompt`).action(async(e,t)=>{w(`uninstall`,`app:uninstall`);try{let n=await c.execute({appPath:y(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=>{w(`catalog-sync`,`dev:catalog-sync`);let{CatalogSyncCommand:t}=await Promise.resolve().then(()=>require("./catalog-sync-DJgluWIc.js"));await new t().execute({remote:e.remote})})},Ve=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.o(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}},He=class{constructor({apiService:e,state:t,notify:n}){this.hasRetried=!1,this.apiService=e,this.state=t,this.notify=n}async execute(){let t=this.state.steps.checkServer,n=await this.apiService.validateAuth();if(!n.serverUp){let e=await r.C();return e&&!this.hasRetried?(this.hasRetried=!0,await new r.Z().setConfig({apiUrl:e}),this.execute()):(t.output.errorLogged||(t.output={isReady:!1,errorLogged:!0},t.status=`error`,this.state.applyStepEvents([{message:`Cannot reach Twenty server.
374
374
 
375
375
  Start a local server:
376
376
  yarn twenty docker:start
@@ -378,8 +378,8 @@ export default defineTimelineActivityType({
378
378
  Check server status:
379
379
  yarn twenty docker:status
380
380
 
381
- Waiting for server...`,status:`error`}]),this.state.updatePipeline({status:`error`})),!1)}if(!n.authValid)return t.output.errorLogged||(t.output={isReady:!1,errorLogged:!0},t.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=t.output.isReady;if(t.output={isReady:!0,errorLogged:!1},t.status=`done`,!e.t(this.state.frontendUrl)){let t=await this.apiService.getWorkspaceFrontendUrl();e.t(t)&&(this.state.frontendUrl=t)}return i||this.notify(),!0}},Ue=class{constructor({clientService:e,state:t,notify:n}){this.clientService=e,this.state=t,this.notify=n}async execute(e){let t=this.state.steps.generateApiClient;t.status=`in_progress`,this.notify();try{await this.clientService.generateCoreClient({appPath:e.appPath,applicationUniversalIdentifier:e.applicationUniversalIdentifier}),t.status=`done`}catch(e){this.state.applyStepEvents([{message:`Failed to generate API client: ${e instanceof Error?e.message:String(e)}`,status:`error`}]),t.status=`error`}this.notify()}},We=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 t=await r.b(this.apiService,this.configService,{name:e.manifest.application.displayName,universalIdentifier:e.manifest.application.universalIdentifier});this.state.applyStepEvents([{message:t.isNewRegistration?`App registration created: ${e.manifest.application.displayName}`:`Existing app registration found`,status:t.isNewRegistration?`success`:`info`},...t.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()}},Ge=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,a.join)(this.appPath,e);return await t.R(n)?n:null}))).filter(e=>e!==null);e.length!==0&&(this.watcher=h.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 r=(0,a.relative)(this.appPath,e),i=(0,a.join)(n.E,r),o=(0,a.join)(this.appPath,i);await t.F((0,a.dirname)(o)),await t.N(e,o);let s=await(0,u.readFile)(o),c=l.default.createHash(`md5`).update(s).digest(`hex`);this.handleFileBuilt({fileFolder:this.fileFolder,builtPath:i,sourcePath:r,checksum:c})}async handleUnlink(e){let r=(0,a.join)(n.E,(0,a.relative)(this.appPath,e));await t.B((0,a.join)(this.appPath,r))}},Ke=[`package.json`,`yarn.lock`],qe=class{constructor(e){this.componentsWatcher=null,this.sharedDependenciesBuildContext=null,this.lastSharedDependenciesChecksum=null,this.installedDependenciesWatcher=null,this.isClosed=!1,this.isApplyingRestart=!1,this.sharedDependenciesBuildGeneration=0,this.inFlightSharedDependenciesBuildPromise=null,this.hasSharedDependenciesBuildRequestedDuringInFlightBuild=!1,this.appPath=e.appPath,this.sourcePaths=e.sourcePaths,this.sharedDependencies=e.sharedDependencies,this.watchMode=e.watch??!0,this.shouldSkipTypecheck=e.shouldSkipTypecheck,this.handleFileBuilt=e.handleFileBuilt,this.handleBuildError=e.handleBuildError}getSharedDependenciesBuildContext(){return this.sharedDependenciesBuildContext}shouldRestart(e,t){return(this.componentsWatcher?.shouldRestart(e)??!0)||this.hasSharedDependenciesManifestChanged(t)}async start(){e.t(this.sharedDependencies)&&(await this.requestSharedDependenciesBuild(),await this.startInstalledDependenciesWatcher()),this.componentsWatcher=new t.w({appPath:this.appPath,sourcePaths:this.sourcePaths,watch:this.watchMode,handleFileBuilt:this.handleFileBuilt,handleBuildError:this.handleBuildError,config:{externalModules:t.C,fileFolder:n.ht.BuiltFrontComponent,jsx:`automatic`,extraPlugins:[t.E(this.appPath,this.shouldSkipTypecheck),...n.t({getSharedDependenciesBuildContext:()=>this.sharedDependenciesBuildContext}),t.k()]}}),await this.componentsWatcher.start()}async restart(t,n){this.isApplyingRestart=!0;try{let r=this.hasSharedDependenciesManifestChanged(n);this.sourcePaths=t,r&&(this.sharedDependenciesBuildGeneration+=1,this.hasSharedDependenciesBuildRequestedDuringInFlightBuild=!1,await this.inFlightSharedDependenciesBuildPromise,await this.installedDependenciesWatcher?.close(),this.installedDependenciesWatcher=null,this.sharedDependencies=n,this.sharedDependenciesBuildContext=null,this.lastSharedDependenciesChecksum=null,e.t(n)&&(await this.requestSharedDependenciesBuild(),await this.startInstalledDependenciesWatcher())),await this.componentsWatcher?.restart(t)}finally{this.isApplyingRestart=!1}}async close(){this.isClosed=!0,await this.installedDependenciesWatcher?.close(),this.installedDependenciesWatcher=null,await this.componentsWatcher?.close(),this.componentsWatcher=null}hasSharedDependenciesManifestChanged(t){return!e.t(t)||!e.t(this.sharedDependencies)?e.t(t)!==e.t(this.sharedDependencies):t.dependencies.join(`,`)!==this.sharedDependencies.dependencies.join(`,`)}async requestSharedDependenciesBuild(){if(e.t(this.inFlightSharedDependenciesBuildPromise)){this.hasSharedDependenciesBuildRequestedDuringInFlightBuild=!0;return}this.inFlightSharedDependenciesBuildPromise=this.runSharedDependenciesBuild();try{await this.inFlightSharedDependenciesBuildPromise}finally{this.inFlightSharedDependenciesBuildPromise=null,this.hasSharedDependenciesBuildRequestedDuringInFlightBuild&&(this.hasSharedDependenciesBuildRequestedDuringInFlightBuild=!1,await this.requestSharedDependenciesBuild())}}async runSharedDependenciesBuild(){let n=this.sharedDependencies,r=this.sharedDependenciesBuildGeneration;if(!e.t(n))return;let i=()=>this.isClosed||r!==this.sharedDependenciesBuildGeneration;try{let e=null,r=await t.S({appPath:this.appPath,sharedDependencies:n,onFileBuilt:async t=>{e=t.checksum,!(i()||t.checksum===this.lastSharedDependenciesChecksum)&&await this.handleFileBuilt(t)}});if(i())return;this.sharedDependenciesBuildContext=r,e!==this.lastSharedDependenciesChecksum&&(this.lastSharedDependenciesChecksum=e,this.isApplyingRestart||await this.componentsWatcher?.restart(this.sourcePaths))}catch(e){if(i())return;await this.handleBuildError([{error:e instanceof Error?e.message:String(e),location:null}])}}async startInstalledDependenciesWatcher(){let n=(await Promise.all(Ke.map(async e=>{let n=(0,a.join)(this.appPath,e);return await t.R(n)?n:null}))).filter(e.t);(0,o.isNonEmptyArray)(n)&&(this.installedDependenciesWatcher=h.default.watch(n,{ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.installedDependenciesWatcher.on(`all`,e=>{(e===`add`||e===`change`)&&this.requestSharedDependenciesBuild()}))}},Je=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=d.default.join(this.appPath,`node_modules`,`.bin`,`tsc`);if(!await t.R(e))return;let n=d.default.join(this.appPath,`tsconfig.json`);this.process=(0,f.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(`
382
- `);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.D(e);n&&this.pendingErrors.push(n)}},Ye=new Set([`node_modules`,`dist`,`.twenty`]),Xe=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=h.default.watch(this.appPath,{ignoreInitial:!this.verbose,ignored:t=>{let n=(0,a.relative)(e,t);if(n===``)return!1;let r=n.split(a.default.sep)[0];return Ye.has(r)||r.startsWith(`.`)},awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on(`all`,(e,t)=>{if(e===`addDir`||e===`unlinkDir`)return;let r=(0,a.relative)(this.appPath,t),i=r.startsWith(n.h),o=[`package.json`,`yarn.lock`].includes(r);!(r.endsWith(`.ts`)||r.endsWith(`.tsx`))&&!i&&!o||this.handleChangeDetected(r,e)})}async close(){await this.watcher?.close()}},Ze=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 Xe({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,r=e.manifest?.application.frontComponentSharedDependencies;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,r);return}this.logicFunctionsWatcher?.shouldRestart(t)&&await this.logicFunctionsWatcher.restart(t),this.frontComponentsWatcher?.shouldRestart(n,r)&&await this.frontComponentsWatcher.restart(n,r)}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,n){await Promise.all([this.startTscWatcher(),this.startLogicFunctionsWatcher(e),this.startFrontComponentsWatcher(t,n),this.startAssetWatcher(),this.startDependencyWatcher()])}async startLogicFunctionsWatcher(e){this.logicFunctionsWatcher=t.T({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,t){this.frontComponentsWatcher=new qe({appPath:this.state.appPath,sourcePaths:e,sharedDependencies:t,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.frontComponentsWatcher.start()}async startAssetWatcher(){this.assetWatcher=new Ge({appPath:this.state.appPath,fileFolder:n.ht.PublicAsset,watchPaths:[n.h],handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.assetWatcher.start()}async startDependencyWatcher(){this.dependencyWatcher=new Ge({appPath:this.state.appPath,fileFolder:n.ht.Dependencies,watchPaths:[`package.json`,`yarn.lock`],handleFileBuilt:e=>{this.handleDependencyFileBuilt(e)}}),this.dependencyWatcher.start()}async handleDependencyFileBuilt(e){e.sourcePath===`yarn.lock`&&(await t.s((0,d.join)(this.state.appPath,e.builtPath))).length>0||this.handleFileBuilt(e)}async startTscWatcher(){this.tscWatcher=new Je({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()}},Qe=50,$e={create:`created`,update:`updated`,delete:`deleted`},et=e=>{if(e.type===`create`)return r.y(e.flatEntity)??`unknown`;let t=r.y(e.flatEntity);return t&&t!==e.universalIdentifier?`${t} (${e.universalIdentifier})`:e.universalIdentifier},tt=t=>{if(t.type!==`update`||!e.t(t.diff))return``;let n=Object.keys(t.diff);return n.length===0?``:` [${n.join(`, `)}] changed`},nt=t=>{let n=t??[];if(n.length===0)return[{message:`No metadata changes`,status:`info`}];let r={create:0,update:0,delete:0};for(let e of n)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(e.t).join(`, `)}`,status:`info`}],a=n.slice(0,Qe);for(let e of a){let t=et(e),n=tt(e);i.push({message:` ${$e[e.type]} ${e.metadataName} ${t}${n}`,status:`info`})}let o=n.length-a.length;return o>0&&i.push({message:` …and ${o} more change(s)`,status:`info`}),i},rt=class{constructor({apiService:e,state:t,notify:n,verbose:r,force:i,inferDeletionFromMissingEntities:a,interactive:o,onExit:s}){this.apiService=e,this.state=t,this.notify=n,this.verbose=r??!1,this.force=i??!1,this.inferDeletionFromMissingEntities=a??!0,this.interactive=o??!1,this.onExit=s}async execute(e){let n=this.state.steps.syncApplication;n.status=`in_progress`,this.state.updatePipeline({status:`syncing`});let i=[],a={...t.a({manifest:e.manifest,builtFileInfos:e.builtFileInfos}),translations:await t.n({appPath:e.appPath})};if(i.push({message:`Manifest checksums set`,status:`info`}),await t.i({appPath:e.appPath,manifest:a}),i.push({message:`Manifest saved to output directory`,status:`info`}),!this.force){i.push({message:`Computing metadata plan`,status:`info`});let e=await this.apiService.syncApplication(a,{dryRun:!0,inferDeletionFromMissingEntities:this.inferDeletionFromMissingEntities});if(!e.success){this.applyFailure(e,i);return}if(r.v({actions:e.data.actions,inferDeletionFromMissingEntities:this.inferDeletionFromMissingEntities})&&i.push({message:r.h,status:`info`}),r._(e.data.actions)&&await this.gateDestructiveChange(r.g(e.data.actions),i))return}i.push({message:`Syncing manifest`,status:`info`});let o=await this.apiService.syncApplication(a,{inferDeletionFromMissingEntities:this.inferDeletionFromMissingEntities});if(o.success){i.push(...nt(o.data.actions)),i.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(i);return}this.applyFailure(o,i)}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,t){let n=this.state.steps.syncApplication,i=this.verbose?null:r.U(e.error);i?(t.push(...i),t.push({message:`Add --verbose to see full error log`,status:`info`})):t.push({message:`Sync failed with error: ${e.message??`Sync failed`}`,status:`error`});let a=r.m(e.message);a&&t.push({message:a,status:`info`});let o=i?i[0].message:`Sync failed`;n.output={syncStatus:`error`,error:o},n.status=`error`,this.state.updatePipeline({status:`error`,error:o}),this.state.updateAllEntitiesStatus(`error`),this.state.applyStepEvents(t)}},it=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 e.t(this.state.steps.uploadFiles.output.fileUploader)}initialize(e){let t=this.state.steps.uploadFiles;t.output={...t.output,fileUploader:new r.p({appPath:e.appPath,applicationUniversalIdentifier:e.universalIdentifier})},t.status=`in_progress`,this.notify(),this.uploadPendingFiles()}uploadFile(e,t,n){this.queueUploads([{builtPath:e,sourcePath:t,fileFolder:n}])}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(){this.queueUploads(Array.from(this.state.steps.uploadFiles.output.builtFileInfos.entries()).map(([e,{fileFolder:t,sourcePath:n}])=>({builtPath:e,sourcePath:n,fileFolder:t})))}queueUploads(t){let n=this.state.steps.uploadFiles,i=n.output.fileUploader;if(!e.t(i)||t.length===0)return;n.status=`in_progress`,this.totalQueued+=t.length,this.verbose&&this.state.addEvent({message:`Uploading ${t.map(({builtPath:e})=>e).join(`, `)}`,status:`info`});for(let{sourcePath:e}of t)this.state.updateEntityStatus(e,`uploading`);this.notify();let a=i.uploadFiles(t.map(({builtPath:e,fileFolder:t})=>({builtPath:e,fileFolder:t}))).then(e=>{this.failedCount+=e.length;for(let t of r.f(e))this.state.addEvent({message:t,status:`error`});for(let{builtPath:n,sourcePath:r}of t)e.some(e=>e.builtPath===n)||(this.uploadedCount++,this.verbose&&this.state.addEvent({message:`Successfully uploaded ${n}`,status:`success`}),this.state.updateEntityStatus(r,`success`))}).catch(e=>{this.failedCount+=t.length,this.state.addEvent({message:`Upload failed: ${e}`,status:`error`})}).finally(()=>{n.output.activeUploads.delete(a),n.output.activeUploads.size===0&&(this.logUploadSummary(),n.status=`done`,this.notify())});n.output.activeUploads.add(a)}},at=class{constructor(e){this.syncTimer=null,this.serverCheckInterval=null,this.syncRequestedWhileRunning=!1,this.isClosed=!1,this.skipTypecheck=!0,this.debounceMs=e.debounceMs??1e3,this.state=e.state,this.verbose=e.verbose??!1,this.apiService=new r.q({disableInterceptors:!0});let t=this.apiService,n=new r.Z;this.clientService=new r.w;let i={state:this.state,notify:()=>this.state.notify()};this.checkServerStep=new He({...i,apiService:t}),this.buildManifestStep=new Ve(i),this.registerAppStep=new We({...i,apiService:t,configService:n}),this.uploadFilesStep=new it({...i,verbose:this.verbose}),this.generateApiClientStep=new Ue({...i,clientService:this.clientService}),this.syncApplicationStep=new rt({...i,apiService:t,verbose:this.verbose,force:e.force??!1,inferDeletionFromMissingEntities:e.inferDeletionFromMissingEntities??!0,interactive:e.interactive??!1,onExit:e.onExit}),this.startWatchersStep=new Ze({...i,scheduleSync:this.scheduleSync.bind(this),onFileBuilt:this.handleFileBuilt.bind(this),shouldSkipTypecheck:()=>this.skipTypecheck,verbose:this.verbose})}async start(){this.isClosed=!1;let e=a.default.join(this.state.appPath,n.E);await t.F(e),await t.P(e),this.state.addEvent({message:`Using remote "${r.Z.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.isClosed=!0,this.syncTimer&&=(clearTimeout(this.syncTimer),null),this.serverCheckInterval&&=(clearInterval(this.serverCheckInterval),null),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.isClosed||(this.syncTimer&&clearTimeout(this.syncTimer),this.syncTimer=setTimeout(()=>{this.syncTimer=null,this.performSync()},this.debounceMs))}async performSync(){if(this.state.pipeline.isSyncing){this.syncRequestedWhileRunning=!0;return}this.state.updatePipeline({isSyncing:!0});try{await this.runSyncPipeline()}catch(e){this.state.addEvent({message:`Sync failed with error: ${r.J(e)}`,status:`error`}),this.state.updatePipeline({status:`error`}),this.state.updateAllEntitiesStatus(`error`)}finally{this.state.updatePipeline({isSyncing:!1}),this.syncRequestedWhileRunning&&!this.isClosed&&(this.syncRequestedWhileRunning=!1,this.scheduleSync())}}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,applicationUniversalIdentifier:e.manifest.application.universalIdentifier}),this.skipTypecheck=!1)}async initializePipeline(e){await this.registerAppStep.execute({manifest:e});let t=await this.apiService.createDevelopmentApplication({universalIdentifier:e.application.universalIdentifier,name:e.application.displayName});if(!t.success||!t.data){let e=t.success?void 0:r.x(t.error);return this.state.applyStepEvents([{message:e??`Failed to install development application`,status:`error`},{message:JSON.stringify(t,null,2),status:`error`}]),this.state.updatePipeline({status:`error`}),!1}return 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}},ot={objects:n.c.Object,fields:n.c.Field,logicFunctions:n.c.LogicFunction,frontComponents:n.c.FrontComponent,roles:n.c.Role,skills:n.c.Skill,connectionProviders:n.c.ConnectionProvider,views:n.c.View,viewFields:n.c.ViewField,navigationMenuItems:n.c.NavigationMenuItem,pageLayouts:n.c.PageLayout,pageLayoutTabs:n.c.PageLayoutTab,pageLayoutWidgets:n.c.PageLayoutWidget,commandMenuItems:n.c.CommandMenuItem,timelineActivityTypes:n.c.TimelineActivityType,settingsMenuItems:n.c.SettingsMenuItem},st=200,ct={pending:[`building`,`uploading`,`success`,`error`],building:[`pending`,`uploading`,`success`,`error`],uploading:[`pending`,`success`,`error`],success:[`pending`,`building`,`uploading`,`error`],error:[`pending`,`building`,`uploading`,`success`]},lt=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(-(st-t.length)),...t]}addEvent(e){this.applyStepEvents([e])}updateEntityStatus(e,t){let n=new Map(this.entities),r=n.get(e);r?.status&&!ct[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=ot[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}},ut={idle:{color:`gray`,icon:`○`},in_progress:{color:`yellow`,icon:`spinner`},uploading:{color:`cyan`,icon:`upload`},done:{color:`green`,icon:`✓`},error:{color:`red`,icon:`✗`}},dt=e=>({idle:`idle`,in_progress:`in_progress`,done:`done`,error:`error`})[e],T=e=>({pending:`idle`,building:`in_progress`,uploading:`uploading`,success:`done`,error:`error`})[e],ft=e=>({idle:`idle`,building:`in_progress`,syncing:`in_progress`,synced:`done`,error:`error`})[e],pt={idle:`Idle`,building:`Building...`,syncing:`Syncing...`,synced:`Synced`,error:`Error`},mt=[`◐`,`◓`,`◑`,`◒`],ht=[`↑`,`⇡`,`↑`,`⇡`],gt={[n.c.Object]:`Objects`,[n.c.Field]:`Fields`,[n.c.LogicFunction]:`Logic functions`,[n.c.FrontComponent]:`Front components`,[n.c.CommandMenuItem]:`Command menu items`,[n.c.Role]:`Roles`,[n.c.Skill]:`Skills`,[n.c.View]:`Views`,[n.c.ViewField]:`View fields`,[n.c.NavigationMenuItem]:`Navigation menu items`,[n.c.PageLayout]:`Page layouts`,[n.c.PageLayoutTab]:`Page layout tabs`,[n.c.PageLayoutWidget]:`Page layout widgets`,[n.c.Agent]:`Agents`,[n.c.ConnectionProvider]:`Connection providers`,[n.c.TimelineActivityType]:`Timeline activity types`,[n.c.SettingsMenuItem]:`Settings menu items`},_t=Object.keys(gt),vt={info:`gray`,success:`green`,error:`red`,warning:`yellow`},yt=e=>e.toLocaleTimeString(`en-US`,{hour12:!1,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),bt=(e,t=40)=>{if(e.length<=t)return e;let n=e.split(`/`);return n.length<=2?e:`.../${n.slice(-2).join(`/`)}`},xt=e=>{let t=new Map;for(let e of _t)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},St=[{status:`success`,label:`synced`},{status:`building`,label:`building`},{status:`uploading`,label:`uploading`},{status:`pending`,label:`pending`},{status:`error`,label:`error`}],Ct=e=>{let t={pending:0,building:0,uploading:0,success:0,error:0};for(let n of e)t[n.status]+=1;return St.filter(({status:e})=>t[e]>0).map(({status:e,label:n})=>({status:e,count:t[e],label:n}))},wt=t=>{let n=t.steps.resolveApplication.output.applicationId;return!e.t(t.frontendUrl)||!e.t(n)?null:`${t.frontendUrl}/settings/applications/${n}`},Tt=e=>e.some(e=>e===`error`)?`error`:e.some(e=>e===`in_progress`)?`in_progress`:e.every(e=>e===`done`)?`done`:`idle`,Et=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:Tt([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}]},Dt=120,Ot=Math.round(200/Dt),kt=()=>{let e=Math.floor(Date.now()/Dt);return{spinnerFrame:mt[e%mt.length],uploadFrame:ht[Math.floor(e/Ot)%ht.length]}},At=e=>{let t=ut[e];return t.icon===`spinner`?kt().spinnerFrame:t.icon===`upload`?kt().uploadFrame:t.icon},E=c.default.createContext(null),jt=E.Provider,D=()=>{let e=c.default.useContext(E);if(!e)throw Error(`useInk must be used within InkProvider`);return e},O=({uiStatus:e})=>{let{Text:t}=D(),n=At(e),r=ut[e];return(0,g.jsxs)(t,{color:r.color,children:[n,` `]})},Mt=({entity:e})=>{let{Box:t,Text:n}=D();return(0,g.jsxs)(t,{children:[(0,g.jsx)(O,{uiStatus:T(e.status)}),(0,g.jsx)(n,{children:e.name}),e.path!==e.name&&(0,g.jsxs)(n,{dimColor:!0,children:[` (`,bt(e.path),`)`]})]})},Nt=({type:e,entities:t})=>{let{Box:n,Text:r}=D();return t.length===0?null:(0,g.jsxs)(n,{flexDirection:`column`,marginTop:1,children:[(0,g.jsx)(r,{bold:!0,dimColor:!0,children:gt[e]}),t.map(e=>(0,g.jsx)(Mt,{entity:e},e.path))]})},Pt=({entities:e})=>{let{Box:t,Text:n}=D();if(e.length===0)return null;let r=Ct(e);return(0,g.jsxs)(t,{marginTop:1,children:[(0,g.jsxs)(n,{bold:!0,dimColor:!0,children:[`Entities`,` `]}),r.map((e,r)=>(0,g.jsxs)(t,{children:[r>0&&(0,g.jsx)(n,{dimColor:!0,children:` · `}),(0,g.jsx)(O,{uiStatus:T(e.status)}),(0,g.jsxs)(n,{children:[e.count,` `,e.label]})]},e.status))]})},Ft=()=>{let{Box:e,Text:t}=D();return(0,g.jsx)(e,{marginTop:1,children:(0,g.jsxs)(t,{dimColor:!0,children:[(0,g.jsx)(t,{color:ut.idle.color,children:ut.idle.icon}),` `,`pending`,` `,(0,g.jsx)(t,{color:ut.in_progress.color,children:mt[0]}),` `,`building`,` `,(0,g.jsx)(t,{color:ut.uploading.color,children:ht[0]}),` `,`uploading`,` `,(0,g.jsx)(t,{color:ut.done.color,children:ut.done.icon}),` `,`success`,` `,(0,g.jsx)(t,{color:ut.error.color,children:ut.error.icon}),` `,`error`]})})},It=7,k=({versionInfo:e})=>{let{Box:t,Text:n}=D();if(e===null)return null;let{cliVersion:r,localServerVersion:i,latestServerVersion:a,isMinorOrMajorBehind:o,daysBehind:s}=e,c=o&&s!==null&&s>It;return(0,g.jsxs)(t,{children:[(0,g.jsx)(n,{dimColor:!0,children:`Versions: `}),(0,g.jsx)(n,{dimColor:!0,children:`CLI `}),(0,g.jsxs)(n,{children:[`v`,r]}),i!==null&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(n,{dimColor:!0,children:` • Server `}),(0,g.jsxs)(n,{color:c?`yellow`:void 0,children:[`v`,i]}),i!==null&&a!==null&&i===a&&(0,g.jsx)(n,{color:`green`,children:` ✓ latest`}),c&&a!==null&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(n,{color:`yellow`,children:[` → v`,a]}),s!==null&&(0,g.jsxs)(n,{dimColor:!0,children:[` (`,s,`d behind)`]})]})]})]})},Lt=({state:e})=>{let{Text:t}=D(),n=ft(e.pipeline.status),r=At(n),i=ut[n],a=pt[e.pipeline.status];return(0,g.jsxs)(t,{color:i.color,children:[r,` `,a]})},Rt=({label:e,status:t})=>{let{Box:n,Text:r}=D(),i=dt(t),a=At(i),o=ut[i];return(0,g.jsxs)(n,{children:[(0,g.jsxs)(r,{dimColor:!0,children:[e,`: `]}),(0,g.jsxs)(r,{color:o.color,children:[a,` `,t.replace(`_`,` `)]})]})},zt=({state:e,verbose:t=!1})=>{let{Box:n,Text:r}=D(),i=xt(e.entities),a=wt(e);return(0,g.jsxs)(n,{flexDirection:`column`,borderStyle:`classic`,borderColor:`gray`,paddingX:1,children:[(0,g.jsx)(r,{bold:!0,color:`cyan`,children:`Application`}),(0,g.jsxs)(n,{marginLeft:2,flexDirection:`column`,children:[(0,g.jsxs)(n,{children:[(0,g.jsx)(r,{dimColor:!0,children:`Name: `}),(0,g.jsx)(r,{bold:!0,children:e.pipeline.appName??`Loading...`})]}),(0,g.jsxs)(n,{children:[(0,g.jsx)(r,{dimColor:!0,children:`Overall Status: `}),(0,g.jsx)(Lt,{state:e})]}),a&&(0,g.jsxs)(n,{children:[(0,g.jsx)(r,{dimColor:!0,children:`Open:`}),(0,g.jsxs)(r,{bold:!0,color:`cyan`,children:[` `,a]})]}),(0,g.jsx)(k,{versionInfo:e.versionInfo})]}),(0,g.jsx)(n,{marginLeft:2,flexDirection:`column`,marginTop:1,children:Et(e).map(e=>(0,g.jsx)(Rt,{label:e.label,status:e.status},e.label))}),(0,g.jsx)(n,{marginLeft:2,flexDirection:`column`,children:t?_t.map(e=>(0,g.jsx)(Nt,{type:e,entities:i.get(e)??[]},e)):(0,g.jsx)(Pt,{entities:Array.from(e.entities.values())})})]})},Bt=({state:e})=>{let{Box:t,Text:n,useInput:r}=D(),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,g.jsxs)(t,{marginTop:1,flexDirection:`column`,borderStyle:`classic`,borderColor:`red`,paddingX:1,children:[(0,g.jsxs)(n,{color:`red`,bold:!0,children:[`⚠ `,i.deleteCount,` destructive change(s) detected`]}),(0,g.jsxs)(n,{children:[`Apply and DESTROY `,i.deleteCount,` metadata entity(ies)? Press`,` `,(0,g.jsx)(n,{color:`green`,bold:!0,children:`y`}),` `,`to apply,`,` `,(0,g.jsx)(n,{color:`red`,bold:!0,children:`n`}),` `,`to cancel and stop watching.`]})]}):null},Vt=({event:e})=>{let{Box:t,Text:n}=D(),r=vt[e.status],i=yt(e.timestamp);return(0,g.jsxs)(t,{marginTop:+!!e.spacingBefore,children:[(0,g.jsxs)(n,{dimColor:!0,children:[i,` `]}),(0,g.jsx)(n,{color:r,children:e.message})]})},Ht=new Set([`building`,`syncing`]),Ut=120,Wt=80,Gt=({uiStateManager:e,verbose:t})=>{let{Box:n,Static:r}=D(),[,i]=(0,c.useReducer)(e=>e+1,0),a=(0,c.useRef)(null),o=(0,c.useRef)(0),s=(0,c.useCallback)(()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,o.current=Date.now(),i()},Wt)},[]);(0,c.useEffect)(()=>e.subscribe(()=>{s()}),[e,s]),(0,c.useEffect)(()=>{let t=setInterval(()=>{let t=e.getSnapshot();Ht.has(t.pipeline.status)&&(Date.now()-o.current<Ut||i())},Ut);return()=>clearInterval(t)},[e]),(0,c.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]);let l=e.getSnapshot();return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(r,{items:l.events,children:e=>(0,g.jsx)(Vt,{event:e},e.id)}),(0,g.jsxs)(n,{marginTop:1,flexDirection:`column`,children:[(0,g.jsx)(zt,{state:l,verbose:t}),t&&(0,g.jsx)(Ft,{})]}),l.pendingConfirmation&&(0,g.jsx)(Bt,{state:l})]})},Kt=async(e,t=!1)=>{let{render:n,Box:r,Text:i,Static:a,useInput:o}=await import(`ink`),{unmount:s}=n((0,g.jsx)(jt,{value:{Box:r,Text:i,Static:a,useInput:o},children:(0,g.jsx)(Gt,{uiStateManager:e,verbose:t})}));return{unmount:s}},qt=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)}))}},Jt=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:t}=await new r.q({disableInterceptors:!0}).validateAuth();e&&!t&&await r.Y(r.Z.getActiveRemote())}async execute(e){let n=e.appPath??t.U;await S(n),e.headless&&await r.O(),await this.ensureAuthenticatedBeforeLaunch();let i=new lt({appPath:n});if(!e.headless){let t=new qt(i);i.onChange=()=>t.notify();let{unmount:n}=await Kt(t,e.verbose);this.unmountUI=n,r.k().then(e=>i.setVersionInfo(e))}this.orchestrator=new at({state:i,verbose:e.verbose,debounceMs:e.debounceMs,force:e.force,inferDeletionFromMissingEntities:e.inferDeletionFromMissingEntities,interactive:!e.headless&&process.stdout.isTTY===!0,onExit:({code:t,message:n})=>{e.headless||this.close().then(()=>{console.log(p.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)}},Yt=async(e,{force:t})=>{if(t)return!0;if(!process.stdout.isTTY)return console.error(p.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 m.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},Xt=async e=>{await r.u({appPath:e})&&(console.log(p.default.yellow("This project was written by `twenty pull`, which is experimental and cannot export every entity yet.")),console.log(p.default.yellow(`Entities it could not write are missing from your source, so applying will destroy them in the workspace.`)),console.log(p.default.yellow(`Re-run with --no-delete to keep them.
381
+ Waiting for server...`,status:`error`}]),this.state.updatePipeline({status:`error`})),!1)}if(!n.authValid)return t.output.errorLogged||(t.output={isReady:!1,errorLogged:!0},t.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=t.output.isReady;if(t.output={isReady:!0,errorLogged:!1},t.status=`done`,!e.t(this.state.frontendUrl)){let t=await this.apiService.getWorkspaceFrontendUrl();e.t(t)&&(this.state.frontendUrl=t)}return i||this.notify(),!0}},Ue=class{constructor({clientService:e,state:t,notify:n}){this.clientService=e,this.state=t,this.notify=n}async execute(e){let t=this.state.steps.generateApiClient;t.status=`in_progress`,this.notify();try{await this.clientService.generateCoreClient({appPath:e.appPath,applicationUniversalIdentifier:e.applicationUniversalIdentifier}),t.status=`done`}catch(e){this.state.applyStepEvents([{message:`Failed to generate API client: ${e instanceof Error?e.message:String(e)}`,status:`error`}]),t.status=`error`}this.notify()}},We=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 t=await r.b(this.apiService,this.configService,{name:e.manifest.application.displayName,universalIdentifier:e.manifest.application.universalIdentifier});this.state.applyStepEvents([{message:t.isNewRegistration?`App registration created: ${e.manifest.application.displayName}`:`Existing app registration found`,status:t.isNewRegistration?`success`:`info`},...t.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()}},Ge=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,a.join)(this.appPath,e);return await t.R(n)?n:null}))).filter(e=>e!==null);e.length!==0&&(this.watcher=h.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 r=(0,a.relative)(this.appPath,e),i=(0,a.join)(n.E,r),o=(0,a.join)(this.appPath,i);await t.F((0,a.dirname)(o)),await t.N(e,o);let s=await(0,u.readFile)(o),c=l.default.createHash(`md5`).update(s).digest(`hex`);this.handleFileBuilt({fileFolder:this.fileFolder,builtPath:i,sourcePath:r,checksum:c})}async handleUnlink(e){let r=(0,a.join)(n.E,(0,a.relative)(this.appPath,e));await t.B((0,a.join)(this.appPath,r))}},Ke=[`package.json`,`yarn.lock`],qe=class{constructor(e){this.componentsWatcher=null,this.sharedDependenciesBuildContext=null,this.lastSharedDependenciesChecksum=null,this.installedDependenciesWatcher=null,this.isClosed=!1,this.isApplyingRestart=!1,this.sharedDependenciesBuildGeneration=0,this.inFlightSharedDependenciesBuildPromise=null,this.hasSharedDependenciesBuildRequestedDuringInFlightBuild=!1,this.appPath=e.appPath,this.sourcePaths=e.sourcePaths,this.sharedDependencies=e.sharedDependencies,this.watchMode=e.watch??!0,this.shouldSkipTypecheck=e.shouldSkipTypecheck,this.handleFileBuilt=e.handleFileBuilt,this.handleBuildError=e.handleBuildError}getSharedDependenciesBuildContext(){return this.sharedDependenciesBuildContext}shouldRestart(e,t){return(this.componentsWatcher?.shouldRestart(e)??!0)||this.hasSharedDependenciesManifestChanged(t)}async start(){e.t(this.sharedDependencies)&&(await this.requestSharedDependenciesBuild(),await this.startInstalledDependenciesWatcher()),this.componentsWatcher=new t.w({appPath:this.appPath,sourcePaths:this.sourcePaths,watch:this.watchMode,handleFileBuilt:this.handleFileBuilt,handleBuildError:this.handleBuildError,config:{externalModules:t.C,fileFolder:n.St.BuiltFrontComponent,jsx:`automatic`,extraPlugins:[t.E(this.appPath,this.shouldSkipTypecheck),...n.t({getSharedDependenciesBuildContext:()=>this.sharedDependenciesBuildContext}),t.k()]}}),await this.componentsWatcher.start()}async restart(t,n){this.isApplyingRestart=!0;try{let r=this.hasSharedDependenciesManifestChanged(n);this.sourcePaths=t,r&&(this.sharedDependenciesBuildGeneration+=1,this.hasSharedDependenciesBuildRequestedDuringInFlightBuild=!1,await this.inFlightSharedDependenciesBuildPromise,await this.installedDependenciesWatcher?.close(),this.installedDependenciesWatcher=null,this.sharedDependencies=n,this.sharedDependenciesBuildContext=null,this.lastSharedDependenciesChecksum=null,e.t(n)&&(await this.requestSharedDependenciesBuild(),await this.startInstalledDependenciesWatcher())),await this.componentsWatcher?.restart(t)}finally{this.isApplyingRestart=!1}}async close(){this.isClosed=!0,await this.installedDependenciesWatcher?.close(),this.installedDependenciesWatcher=null,await this.componentsWatcher?.close(),this.componentsWatcher=null}hasSharedDependenciesManifestChanged(t){return!e.t(t)||!e.t(this.sharedDependencies)?e.t(t)!==e.t(this.sharedDependencies):t.dependencies.join(`,`)!==this.sharedDependencies.dependencies.join(`,`)}async requestSharedDependenciesBuild(){if(e.t(this.inFlightSharedDependenciesBuildPromise)){this.hasSharedDependenciesBuildRequestedDuringInFlightBuild=!0;return}this.inFlightSharedDependenciesBuildPromise=this.runSharedDependenciesBuild();try{await this.inFlightSharedDependenciesBuildPromise}finally{this.inFlightSharedDependenciesBuildPromise=null,this.hasSharedDependenciesBuildRequestedDuringInFlightBuild&&(this.hasSharedDependenciesBuildRequestedDuringInFlightBuild=!1,await this.requestSharedDependenciesBuild())}}async runSharedDependenciesBuild(){let n=this.sharedDependencies,r=this.sharedDependenciesBuildGeneration;if(!e.t(n))return;let i=()=>this.isClosed||r!==this.sharedDependenciesBuildGeneration;try{let e=null,r=await t.S({appPath:this.appPath,sharedDependencies:n,onFileBuilt:async t=>{e=t.checksum,!(i()||t.checksum===this.lastSharedDependenciesChecksum)&&await this.handleFileBuilt(t)}});if(i())return;this.sharedDependenciesBuildContext=r,e!==this.lastSharedDependenciesChecksum&&(this.lastSharedDependenciesChecksum=e,this.isApplyingRestart||await this.componentsWatcher?.restart(this.sourcePaths))}catch(e){if(i())return;await this.handleBuildError([{error:e instanceof Error?e.message:String(e),location:null}])}}async startInstalledDependenciesWatcher(){let n=(await Promise.all(Ke.map(async e=>{let n=(0,a.join)(this.appPath,e);return await t.R(n)?n:null}))).filter(e.t);(0,o.isNonEmptyArray)(n)&&(this.installedDependenciesWatcher=h.default.watch(n,{ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.installedDependenciesWatcher.on(`all`,e=>{(e===`add`||e===`change`)&&this.requestSharedDependenciesBuild()}))}},Je=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=d.default.join(this.appPath,`node_modules`,`.bin`,`tsc`);if(!await t.R(e))return;let n=d.default.join(this.appPath,`tsconfig.json`);this.process=(0,f.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(`
382
+ `);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.D(e);n&&this.pendingErrors.push(n)}},Ye=new Set([`node_modules`,`dist`,`.twenty`]),Xe=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=h.default.watch(this.appPath,{ignoreInitial:!this.verbose,ignored:t=>{let n=(0,a.relative)(e,t);if(n===``)return!1;let r=n.split(a.default.sep)[0];return Ye.has(r)||r.startsWith(`.`)},awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on(`all`,(e,t)=>{if(e===`addDir`||e===`unlinkDir`)return;let r=(0,a.relative)(this.appPath,t),i=r.startsWith(n.h),o=[`package.json`,`yarn.lock`].includes(r);!(r.endsWith(`.ts`)||r.endsWith(`.tsx`))&&!i&&!o||this.handleChangeDetected(r,e)})}async close(){await this.watcher?.close()}},Ze=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 Xe({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,r=e.manifest?.application.frontComponentSharedDependencies;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,r);return}this.logicFunctionsWatcher?.shouldRestart(t)&&await this.logicFunctionsWatcher.restart(t),this.frontComponentsWatcher?.shouldRestart(n,r)&&await this.frontComponentsWatcher.restart(n,r)}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,n){await Promise.all([this.startTscWatcher(),this.startLogicFunctionsWatcher(e),this.startFrontComponentsWatcher(t,n),this.startAssetWatcher(),this.startDependencyWatcher()])}async startLogicFunctionsWatcher(e){this.logicFunctionsWatcher=t.T({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,t){this.frontComponentsWatcher=new qe({appPath:this.state.appPath,sourcePaths:e,sharedDependencies:t,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.frontComponentsWatcher.start()}async startAssetWatcher(){this.assetWatcher=new Ge({appPath:this.state.appPath,fileFolder:n.St.PublicAsset,watchPaths:[n.h],handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.assetWatcher.start()}async startDependencyWatcher(){this.dependencyWatcher=new Ge({appPath:this.state.appPath,fileFolder:n.St.Dependencies,watchPaths:[`package.json`,`yarn.lock`],handleFileBuilt:e=>{this.handleDependencyFileBuilt(e)}}),this.dependencyWatcher.start()}async handleDependencyFileBuilt(e){e.sourcePath===`yarn.lock`&&(await t.s((0,d.join)(this.state.appPath,e.builtPath))).length>0||this.handleFileBuilt(e)}async startTscWatcher(){this.tscWatcher=new Je({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()}},Qe=50,$e={create:`created`,update:`updated`,delete:`deleted`},et=e=>{if(e.type===`create`)return r.y(e.flatEntity)??`unknown`;let t=r.y(e.flatEntity);return t&&t!==e.universalIdentifier?`${t} (${e.universalIdentifier})`:e.universalIdentifier},tt=t=>{if(t.type!==`update`||!e.t(t.diff))return``;let n=Object.keys(t.diff);return n.length===0?``:` [${n.join(`, `)}] changed`},nt=t=>{let n=t??[];if(n.length===0)return[{message:`No metadata changes`,status:`info`}];let r={create:0,update:0,delete:0};for(let e of n)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(e.t).join(`, `)}`,status:`info`}],a=n.slice(0,Qe);for(let e of a){let t=et(e),n=tt(e);i.push({message:` ${$e[e.type]} ${e.metadataName} ${t}${n}`,status:`info`})}let o=n.length-a.length;return o>0&&i.push({message:` …and ${o} more change(s)`,status:`info`}),i},rt=class{constructor({apiService:e,state:t,notify:n,verbose:r,force:i,inferDeletionFromMissingEntities:a,interactive:o,onExit:s}){this.apiService=e,this.state=t,this.notify=n,this.verbose=r??!1,this.force=i??!1,this.inferDeletionFromMissingEntities=a??!0,this.interactive=o??!1,this.onExit=s}async execute(e){let n=this.state.steps.syncApplication;n.status=`in_progress`,this.state.updatePipeline({status:`syncing`});let i=[],a={...t.a({manifest:e.manifest,builtFileInfos:e.builtFileInfos}),translations:await t.n({appPath:e.appPath})};if(i.push({message:`Manifest checksums set`,status:`info`}),await t.i({appPath:e.appPath,manifest:a}),i.push({message:`Manifest saved to output directory`,status:`info`}),!this.force){i.push({message:`Computing metadata plan`,status:`info`});let e=await this.apiService.syncApplication(a,{dryRun:!0,inferDeletionFromMissingEntities:this.inferDeletionFromMissingEntities});if(!e.success){this.applyFailure(e,i);return}if(r.v({actions:e.data.actions,inferDeletionFromMissingEntities:this.inferDeletionFromMissingEntities})&&i.push({message:r.h,status:`info`}),r._(e.data.actions)&&await this.gateDestructiveChange(r.g(e.data.actions),i))return}i.push({message:`Syncing manifest`,status:`info`});let o=await this.apiService.syncApplication(a,{inferDeletionFromMissingEntities:this.inferDeletionFromMissingEntities});if(o.success){i.push(...nt(o.data.actions)),i.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(i);return}this.applyFailure(o,i)}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,t){let n=this.state.steps.syncApplication,i=this.verbose?null:r.U(e.error);i?(t.push(...i),t.push({message:`Add --verbose to see full error log`,status:`info`})):t.push({message:`Sync failed with error: ${e.message??`Sync failed`}`,status:`error`});let a=r.m(e.message);a&&t.push({message:a,status:`info`});let o=i?i[0].message:`Sync failed`;n.output={syncStatus:`error`,error:o},n.status=`error`,this.state.updatePipeline({status:`error`,error:o}),this.state.updateAllEntitiesStatus(`error`),this.state.applyStepEvents(t)}},it=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 e.t(this.state.steps.uploadFiles.output.fileUploader)}initialize(e){let t=this.state.steps.uploadFiles;t.output={...t.output,fileUploader:new r.p({appPath:e.appPath,applicationUniversalIdentifier:e.universalIdentifier})},t.status=`in_progress`,this.notify(),this.uploadPendingFiles()}uploadFile(e,t,n){this.queueUploads([{builtPath:e,sourcePath:t,fileFolder:n}])}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(){this.queueUploads(Array.from(this.state.steps.uploadFiles.output.builtFileInfos.entries()).map(([e,{fileFolder:t,sourcePath:n}])=>({builtPath:e,sourcePath:n,fileFolder:t})))}queueUploads(t){let n=this.state.steps.uploadFiles,i=n.output.fileUploader;if(!e.t(i)||t.length===0)return;n.status=`in_progress`,this.totalQueued+=t.length,this.verbose&&this.state.addEvent({message:`Uploading ${t.map(({builtPath:e})=>e).join(`, `)}`,status:`info`});for(let{sourcePath:e}of t)this.state.updateEntityStatus(e,`uploading`);this.notify();let a=i.uploadFiles(t.map(({builtPath:e,fileFolder:t})=>({builtPath:e,fileFolder:t}))).then(e=>{this.failedCount+=e.length;for(let t of r.f(e))this.state.addEvent({message:t,status:`error`});for(let{builtPath:n,sourcePath:r}of t)e.some(e=>e.builtPath===n)||(this.uploadedCount++,this.verbose&&this.state.addEvent({message:`Successfully uploaded ${n}`,status:`success`}),this.state.updateEntityStatus(r,`success`))}).catch(e=>{this.failedCount+=t.length,this.state.addEvent({message:`Upload failed: ${e}`,status:`error`})}).finally(()=>{n.output.activeUploads.delete(a),n.output.activeUploads.size===0&&(this.logUploadSummary(),n.status=`done`,this.notify())});n.output.activeUploads.add(a)}},at=class{constructor(e){this.syncTimer=null,this.serverCheckInterval=null,this.syncRequestedWhileRunning=!1,this.isClosed=!1,this.skipTypecheck=!0,this.debounceMs=e.debounceMs??1e3,this.state=e.state,this.verbose=e.verbose??!1,this.apiService=new r.q({disableInterceptors:!0});let t=this.apiService,n=new r.Z;this.clientService=new r.w;let i={state:this.state,notify:()=>this.state.notify()};this.checkServerStep=new He({...i,apiService:t}),this.buildManifestStep=new Ve(i),this.registerAppStep=new We({...i,apiService:t,configService:n}),this.uploadFilesStep=new it({...i,verbose:this.verbose}),this.generateApiClientStep=new Ue({...i,clientService:this.clientService}),this.syncApplicationStep=new rt({...i,apiService:t,verbose:this.verbose,force:e.force??!1,inferDeletionFromMissingEntities:e.inferDeletionFromMissingEntities??!0,interactive:e.interactive??!1,onExit:e.onExit}),this.startWatchersStep=new Ze({...i,scheduleSync:this.scheduleSync.bind(this),onFileBuilt:this.handleFileBuilt.bind(this),shouldSkipTypecheck:()=>this.skipTypecheck,verbose:this.verbose})}async start(){this.isClosed=!1;let e=a.default.join(this.state.appPath,n.E);await t.F(e),await t.P(e),this.state.addEvent({message:`Using remote "${r.Z.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.isClosed=!0,this.syncTimer&&=(clearTimeout(this.syncTimer),null),this.serverCheckInterval&&=(clearInterval(this.serverCheckInterval),null),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.isClosed||(this.syncTimer&&clearTimeout(this.syncTimer),this.syncTimer=setTimeout(()=>{this.syncTimer=null,this.performSync()},this.debounceMs))}async performSync(){if(this.state.pipeline.isSyncing){this.syncRequestedWhileRunning=!0;return}this.state.updatePipeline({isSyncing:!0});try{await this.runSyncPipeline()}catch(e){this.state.addEvent({message:`Sync failed with error: ${r.J(e)}`,status:`error`}),this.state.updatePipeline({status:`error`}),this.state.updateAllEntitiesStatus(`error`)}finally{this.state.updatePipeline({isSyncing:!1}),this.syncRequestedWhileRunning&&!this.isClosed&&(this.syncRequestedWhileRunning=!1,this.scheduleSync())}}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,applicationUniversalIdentifier:e.manifest.application.universalIdentifier}),this.skipTypecheck=!1)}async initializePipeline(e){await this.registerAppStep.execute({manifest:e});let t=await this.apiService.createDevelopmentApplication({universalIdentifier:e.application.universalIdentifier,name:e.application.displayName});if(!t.success||!t.data){let e=t.success?void 0:r.x(t.error);return this.state.applyStepEvents([{message:e??`Failed to install development application`,status:`error`},{message:JSON.stringify(t,null,2),status:`error`}]),this.state.updatePipeline({status:`error`}),!1}return 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}},ot={objects:n.c.Object,fields:n.c.Field,logicFunctions:n.c.LogicFunction,frontComponents:n.c.FrontComponent,roles:n.c.Role,skills:n.c.Skill,connectionProviders:n.c.ConnectionProvider,views:n.c.View,viewFields:n.c.ViewField,navigationMenuItems:n.c.NavigationMenuItem,pageLayouts:n.c.PageLayout,pageLayoutTabs:n.c.PageLayoutTab,pageLayoutWidgets:n.c.PageLayoutWidget,commandMenuItems:n.c.CommandMenuItem,timelineActivityTypes:n.c.TimelineActivityType,settingsMenuItems:n.c.SettingsMenuItem},st=200,ct={pending:[`building`,`uploading`,`success`,`error`],building:[`pending`,`uploading`,`success`,`error`],uploading:[`pending`,`success`,`error`],success:[`pending`,`building`,`uploading`,`error`],error:[`pending`,`building`,`uploading`,`success`]},lt=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(-(st-t.length)),...t]}addEvent(e){this.applyStepEvents([e])}updateEntityStatus(e,t){let n=new Map(this.entities),r=n.get(e);r?.status&&!ct[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=ot[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}},ut={idle:{color:`gray`,icon:`○`},in_progress:{color:`yellow`,icon:`spinner`},uploading:{color:`cyan`,icon:`upload`},done:{color:`green`,icon:`✓`},error:{color:`red`,icon:`✗`}},dt=e=>({idle:`idle`,in_progress:`in_progress`,done:`done`,error:`error`})[e],T=e=>({pending:`idle`,building:`in_progress`,uploading:`uploading`,success:`done`,error:`error`})[e],ft=e=>({idle:`idle`,building:`in_progress`,syncing:`in_progress`,synced:`done`,error:`error`})[e],pt={idle:`Idle`,building:`Building...`,syncing:`Syncing...`,synced:`Synced`,error:`Error`},mt=[`◐`,`◓`,`◑`,`◒`],ht=[`↑`,`⇡`,`↑`,`⇡`],gt={[n.c.Object]:`Objects`,[n.c.Field]:`Fields`,[n.c.LogicFunction]:`Logic functions`,[n.c.FrontComponent]:`Front components`,[n.c.CommandMenuItem]:`Command menu items`,[n.c.Role]:`Roles`,[n.c.Skill]:`Skills`,[n.c.View]:`Views`,[n.c.ViewField]:`View fields`,[n.c.NavigationMenuItem]:`Navigation menu items`,[n.c.PageLayout]:`Page layouts`,[n.c.PageLayoutTab]:`Page layout tabs`,[n.c.PageLayoutWidget]:`Page layout widgets`,[n.c.Agent]:`Agents`,[n.c.ConnectionProvider]:`Connection providers`,[n.c.TimelineActivityType]:`Timeline activity types`,[n.c.SettingsMenuItem]:`Settings menu items`},_t=Object.keys(gt),vt={info:`gray`,success:`green`,error:`red`,warning:`yellow`},yt=e=>e.toLocaleTimeString(`en-US`,{hour12:!1,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),bt=(e,t=40)=>{if(e.length<=t)return e;let n=e.split(`/`);return n.length<=2?e:`.../${n.slice(-2).join(`/`)}`},xt=e=>{let t=new Map;for(let e of _t)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},St=[{status:`success`,label:`synced`},{status:`building`,label:`building`},{status:`uploading`,label:`uploading`},{status:`pending`,label:`pending`},{status:`error`,label:`error`}],Ct=e=>{let t={pending:0,building:0,uploading:0,success:0,error:0};for(let n of e)t[n.status]+=1;return St.filter(({status:e})=>t[e]>0).map(({status:e,label:n})=>({status:e,count:t[e],label:n}))},wt=t=>{let n=t.steps.resolveApplication.output.applicationId;return!e.t(t.frontendUrl)||!e.t(n)?null:`${t.frontendUrl}/settings/applications/${n}`},Tt=e=>e.some(e=>e===`error`)?`error`:e.some(e=>e===`in_progress`)?`in_progress`:e.every(e=>e===`done`)?`done`:`idle`,Et=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:Tt([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}]},Dt=120,Ot=Math.round(200/Dt),kt=()=>{let e=Math.floor(Date.now()/Dt);return{spinnerFrame:mt[e%mt.length],uploadFrame:ht[Math.floor(e/Ot)%ht.length]}},At=e=>{let t=ut[e];return t.icon===`spinner`?kt().spinnerFrame:t.icon===`upload`?kt().uploadFrame:t.icon},E=c.default.createContext(null),jt=E.Provider,D=()=>{let e=c.default.useContext(E);if(!e)throw Error(`useInk must be used within InkProvider`);return e},O=({uiStatus:e})=>{let{Text:t}=D(),n=At(e),r=ut[e];return(0,g.jsxs)(t,{color:r.color,children:[n,` `]})},Mt=({entity:e})=>{let{Box:t,Text:n}=D();return(0,g.jsxs)(t,{children:[(0,g.jsx)(O,{uiStatus:T(e.status)}),(0,g.jsx)(n,{children:e.name}),e.path!==e.name&&(0,g.jsxs)(n,{dimColor:!0,children:[` (`,bt(e.path),`)`]})]})},Nt=({type:e,entities:t})=>{let{Box:n,Text:r}=D();return t.length===0?null:(0,g.jsxs)(n,{flexDirection:`column`,marginTop:1,children:[(0,g.jsx)(r,{bold:!0,dimColor:!0,children:gt[e]}),t.map(e=>(0,g.jsx)(Mt,{entity:e},e.path))]})},Pt=({entities:e})=>{let{Box:t,Text:n}=D();if(e.length===0)return null;let r=Ct(e);return(0,g.jsxs)(t,{marginTop:1,children:[(0,g.jsxs)(n,{bold:!0,dimColor:!0,children:[`Entities`,` `]}),r.map((e,r)=>(0,g.jsxs)(t,{children:[r>0&&(0,g.jsx)(n,{dimColor:!0,children:` · `}),(0,g.jsx)(O,{uiStatus:T(e.status)}),(0,g.jsxs)(n,{children:[e.count,` `,e.label]})]},e.status))]})},Ft=()=>{let{Box:e,Text:t}=D();return(0,g.jsx)(e,{marginTop:1,children:(0,g.jsxs)(t,{dimColor:!0,children:[(0,g.jsx)(t,{color:ut.idle.color,children:ut.idle.icon}),` `,`pending`,` `,(0,g.jsx)(t,{color:ut.in_progress.color,children:mt[0]}),` `,`building`,` `,(0,g.jsx)(t,{color:ut.uploading.color,children:ht[0]}),` `,`uploading`,` `,(0,g.jsx)(t,{color:ut.done.color,children:ut.done.icon}),` `,`success`,` `,(0,g.jsx)(t,{color:ut.error.color,children:ut.error.icon}),` `,`error`]})})},It=7,k=({versionInfo:e})=>{let{Box:t,Text:n}=D();if(e===null)return null;let{cliVersion:r,localServerVersion:i,latestServerVersion:a,isMinorOrMajorBehind:o,daysBehind:s}=e,c=o&&s!==null&&s>It;return(0,g.jsxs)(t,{children:[(0,g.jsx)(n,{dimColor:!0,children:`Versions: `}),(0,g.jsx)(n,{dimColor:!0,children:`CLI `}),(0,g.jsxs)(n,{children:[`v`,r]}),i!==null&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(n,{dimColor:!0,children:` • Server `}),(0,g.jsxs)(n,{color:c?`yellow`:void 0,children:[`v`,i]}),i!==null&&a!==null&&i===a&&(0,g.jsx)(n,{color:`green`,children:` ✓ latest`}),c&&a!==null&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(n,{color:`yellow`,children:[` → v`,a]}),s!==null&&(0,g.jsxs)(n,{dimColor:!0,children:[` (`,s,`d behind)`]})]})]})]})},Lt=({state:e})=>{let{Text:t}=D(),n=ft(e.pipeline.status),r=At(n),i=ut[n],a=pt[e.pipeline.status];return(0,g.jsxs)(t,{color:i.color,children:[r,` `,a]})},Rt=({label:e,status:t})=>{let{Box:n,Text:r}=D(),i=dt(t),a=At(i),o=ut[i];return(0,g.jsxs)(n,{children:[(0,g.jsxs)(r,{dimColor:!0,children:[e,`: `]}),(0,g.jsxs)(r,{color:o.color,children:[a,` `,t.replace(`_`,` `)]})]})},zt=({state:e,verbose:t=!1})=>{let{Box:n,Text:r}=D(),i=xt(e.entities),a=wt(e);return(0,g.jsxs)(n,{flexDirection:`column`,borderStyle:`classic`,borderColor:`gray`,paddingX:1,children:[(0,g.jsx)(r,{bold:!0,color:`cyan`,children:`Application`}),(0,g.jsxs)(n,{marginLeft:2,flexDirection:`column`,children:[(0,g.jsxs)(n,{children:[(0,g.jsx)(r,{dimColor:!0,children:`Name: `}),(0,g.jsx)(r,{bold:!0,children:e.pipeline.appName??`Loading...`})]}),(0,g.jsxs)(n,{children:[(0,g.jsx)(r,{dimColor:!0,children:`Overall Status: `}),(0,g.jsx)(Lt,{state:e})]}),a&&(0,g.jsxs)(n,{children:[(0,g.jsx)(r,{dimColor:!0,children:`Open:`}),(0,g.jsxs)(r,{bold:!0,color:`cyan`,children:[` `,a]})]}),(0,g.jsx)(k,{versionInfo:e.versionInfo})]}),(0,g.jsx)(n,{marginLeft:2,flexDirection:`column`,marginTop:1,children:Et(e).map(e=>(0,g.jsx)(Rt,{label:e.label,status:e.status},e.label))}),(0,g.jsx)(n,{marginLeft:2,flexDirection:`column`,children:t?_t.map(e=>(0,g.jsx)(Nt,{type:e,entities:i.get(e)??[]},e)):(0,g.jsx)(Pt,{entities:Array.from(e.entities.values())})})]})},Bt=({state:e})=>{let{Box:t,Text:n,useInput:r}=D(),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,g.jsxs)(t,{marginTop:1,flexDirection:`column`,borderStyle:`classic`,borderColor:`red`,paddingX:1,children:[(0,g.jsxs)(n,{color:`red`,bold:!0,children:[`⚠ `,i.deleteCount,` destructive change(s) detected`]}),(0,g.jsxs)(n,{children:[`Apply and DESTROY `,i.deleteCount,` metadata entity(ies)? Press`,` `,(0,g.jsx)(n,{color:`green`,bold:!0,children:`y`}),` `,`to apply,`,` `,(0,g.jsx)(n,{color:`red`,bold:!0,children:`n`}),` `,`to cancel and stop watching.`]})]}):null},Vt=({event:e})=>{let{Box:t,Text:n}=D(),r=vt[e.status],i=yt(e.timestamp);return(0,g.jsxs)(t,{marginTop:+!!e.spacingBefore,children:[(0,g.jsxs)(n,{dimColor:!0,children:[i,` `]}),(0,g.jsx)(n,{color:r,children:e.message})]})},Ht=new Set([`building`,`syncing`]),Ut=120,Wt=80,Gt=({uiStateManager:e,verbose:t})=>{let{Box:n,Static:r}=D(),[,i]=(0,c.useReducer)(e=>e+1,0),a=(0,c.useRef)(null),o=(0,c.useRef)(0),s=(0,c.useCallback)(()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,o.current=Date.now(),i()},Wt)},[]);(0,c.useEffect)(()=>e.subscribe(()=>{s()}),[e,s]),(0,c.useEffect)(()=>{let t=setInterval(()=>{let t=e.getSnapshot();Ht.has(t.pipeline.status)&&(Date.now()-o.current<Ut||i())},Ut);return()=>clearInterval(t)},[e]),(0,c.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]);let l=e.getSnapshot();return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(r,{items:l.events,children:e=>(0,g.jsx)(Vt,{event:e},e.id)}),(0,g.jsxs)(n,{marginTop:1,flexDirection:`column`,children:[(0,g.jsx)(zt,{state:l,verbose:t}),t&&(0,g.jsx)(Ft,{})]}),l.pendingConfirmation&&(0,g.jsx)(Bt,{state:l})]})},Kt=async(e,t=!1)=>{let{render:n,Box:r,Text:i,Static:a,useInput:o}=await import(`ink`),{unmount:s}=n((0,g.jsx)(jt,{value:{Box:r,Text:i,Static:a,useInput:o},children:(0,g.jsx)(Gt,{uiStateManager:e,verbose:t})}));return{unmount:s}},qt=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)}))}},Jt=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:t}=await new r.q({disableInterceptors:!0}).validateAuth();e&&!t&&await r.Y(r.Z.getActiveRemote())}async execute(e){let n=e.appPath??t.U;await S(n),e.headless&&await r.O(),await this.ensureAuthenticatedBeforeLaunch();let i=new lt({appPath:n});if(!e.headless){let t=new qt(i);i.onChange=()=>t.notify();let{unmount:n}=await Kt(t,e.verbose);this.unmountUI=n,r.k().then(e=>i.setVersionInfo(e))}this.orchestrator=new at({state:i,verbose:e.verbose,debounceMs:e.debounceMs,force:e.force,inferDeletionFromMissingEntities:e.inferDeletionFromMissingEntities,interactive:!e.headless&&process.stdout.isTTY===!0,onExit:({code:t,message:n})=>{e.headless||this.close().then(()=>{console.log(p.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)}},Yt=async(e,{force:t})=>{if(t)return!0;if(!process.stdout.isTTY)return console.error(p.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 m.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},Xt=async e=>{await r.u({appPath:e})&&(console.log(p.default.yellow("This project was written by `twenty pull`, which is experimental and cannot export every entity yet.")),console.log(p.default.yellow(`Entities it could not write are missing from your source, so applying will destroy them in the workspace.`)),console.log(p.default.yellow(`Re-run with --no-delete to keep them.
383
383
  `)))},Zt=class{async execute(e){let n=e.appPath??t.U,i=e.apply??!1;await S(n);let a=r.Z.getActiveRemote();console.log(p.default.blue(`${i?`Applying application manifest`:`Planning application apply`} on ${a}...`)),console.log(p.default.gray(`App path: ${n}\n`)),i&&e.inferDeletionFromMissingEntities!==!1&&await Xt(n);let o=await r.d({appPath:n,verbose:e.verbose,apply:i,force:e.force,inferDeletionFromMissingEntities:e.inferDeletionFromMissingEntities,onProgress:e=>console.log(p.default.gray(e)),onPlan:e=>console.log(`\n${e}\n`),confirmApply:t=>Yt(t,{force:e.force})});if(o.success||(o.error.code===r.et.APPLY_ABORTED&&(console.log(p.default.yellow(o.error.message)),process.exit(1)),console.error(p.default.red(o.error.message)),process.exit(1)),!i){console.log(p.default.green(`\n✓ Plan complete for ${o.data.applicationDisplayName} — no changes were applied`));return}console.log(p.default.green(`\n✓ Synced ${o.data.applicationDisplayName} (${o.data.fileCount} file${o.data.fileCount===1?``:`s`})`)),console.log(p.default.gray(`Output: ${o.data.outputDir}`))}},Qt=e=>{let t=new Le,n=new Ie;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:y(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(p.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:y(e)})})},$t=class{async execute(e){let n=e.appPath??t.U,i=(0,a.join)(n,`node_modules`,`twenty-client-sdk`);await t.R(i)||(console.error(p.default.red(`Cannot find twenty-client-sdk in ${n}.\n\n Install it first:
384
384
  yarn add twenty-client-sdk`)),process.exit(1));let o=await new r.q({disableInterceptors:!0}).validateAuth();o.serverUp||(console.error(p.default.red(`Cannot reach Twenty server.
385
385
 
@@ -390,7 +390,7 @@ export default defineTimelineActivityType({
390
390
  that define what it pulls. Commit your work before running it.
391
391
  `)),console.log(p.default.blue(`Pulling application from ${i}...`)),console.log(p.default.gray(`App path: ${n}\n`));let a=await r.a({appPath:n,universalIdentifier:e.universalIdentifier,onProgress:e=>console.log(p.default.gray(e))});a.success||(console.error(p.default.red(a.error.message)),process.exit(1));let o=an({writes:a.data.writes,deletions:a.data.deletions,unchangedCount:a.data.unchangedCount,skipped:a.data.skipped,coverage:a.data.coverage,localOnlyRelativePaths:a.data.localOnlyRelativePaths,unreadableRelativePaths:a.data.unreadableRelativePaths,compiledTranslationEntryCountByLocale:a.data.compiledTranslationEntryCountByLocale,entityLabelByUniversalIdentifier:a.data.entityLabelByUniversalIdentifier,verbose:e.verbose});console.log(`\n${o}\n`),console.log(p.default.green(`✓ Pulled ${a.data.applicationDisplayName} into ${n}`)),console.log(p.default.gray(`Base recorded in ${r.l}`)),a.data.isSdkResolvable?console.log(p.default.gray(`Next: yarn twenty apply --no-delete`)):(console.log(p.default.yellow(`twenty-sdk is not installed here, so the written files cannot build yet.`)),console.log(p.default.gray(`Next: install your dependencies, then yarn twenty apply --no-delete`)))}},sn=async({manifest:e,frontComponentSourcePaths:t})=>{let n=await r.s(t),i=new Map;for(let t of[...r.o(e),...n])i.set(r.c(t.message,t.context),t);return[...i.values()]},cn=async({appPath:e,manifest:n,frontComponentSourcePaths:i=[],scaffoldLocale:o})=>{let s=await sn({manifest:n,frontComponentSourcePaths:i}),c=a.default.join(e,t.g);if(await t.F(c),await t.V(a.default.join(c,`en.json`),t._(s.map(({message:e,context:t})=>({message:e,context:t,translation:e})))),o!==void 0&&o!==`en`){let e=a.default.join(c,`${o}.json`);await t.R(e)||await t.V(e,{})}let l=(await(0,u.readdir)(c)).filter(e=>e.endsWith(`.json`)&&e!==`en.json`);for(let e of l){let n=a.default.join(c,e),i=await t.z(n)??{},o=new Map(t.v(i).map(e=>[r.c(e.message,e.context),e.translation]));await t.V(n,t._(s.map(({message:e,context:t})=>({message:e,context:t,translation:o.get(r.c(e,t))??``}))))}return{sourceCount:s.length,updatedLocaleFiles:l}},ln=e=>Object.prototype.hasOwnProperty.call(n.rt,e),un=class{async execute(e){let r=e.appPath??t.U,i;e.locale!==void 0&&((e.locale===`en`||!ln(e.locale))&&(console.error(p.default.red(`"${e.locale}" is not a supported target locale. Choose one of: ${Object.keys(n.rt).filter(e=>e!==`en`).join(`, `)}`)),process.exit(1)),i=e.locale),console.log(p.default.blue(`Extracting translatable strings...`));let o=await t.o(r);o.success||(console.error(p.default.red(o.errors.join(`
392
392
  `))),process.exit(1)),o.warnings.length>0&&console.warn(p.default.yellow(o.warnings.join(`
393
- `)));let s=o.filePaths.frontComponents.map(e=>a.default.join(r,e)),{sourceCount:c,updatedLocaleFiles:l}=await cn({appPath:r,manifest:o.manifest,frontComponentSourcePaths:s,scaffoldLocale:i});console.log(p.default.green(`✓ Extracted ${c} string${c===1?``:`s`} to locales/`)),l.length>0&&console.log(p.default.gray(`Updated: ${l.join(`, `)}`))}},dn=e=>{let t=new Fe,r=new Jt,i=new Zt,a=new on,o=new ze,s=new Pe,c=new $t,l=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(`--no-delete`,`Keep entities that are missing from your source instead of deleting them`).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(p.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(p.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:y(e),verbose:n,apply:!t.dryRun,force:t.force,inferDeletionFromMissingEntities:t.delete});return}await r.execute({appPath:y(e),verbose:n,debounceMs:t.debounceMs?parseInt(t.debounceMs,10):void 0,force:t.force,inferDeletionFromMissingEntities:t.delete})}),e.command(`plan [appPath]`).description(`Preview metadata changes without applying them`).option(`--no-delete`,`Keep entities that are missing from your source instead of deleting them`).option(`-v, --verbose`,`Show detailed logs`).action(async(e,t)=>{await i.execute({appPath:y(e),verbose:t.verbose,apply:!1,inferDeletionFromMissingEntities:t.delete})}),e.command(`apply [appPath]`).description(`Apply local metadata changes after showing the plan`).option(`-f, --force`,`Apply destructive changes (deletes) without confirmation`).option(`--no-delete`,`Keep entities that are missing from your source instead of deleting them`).option(`-v, --verbose`,`Show detailed logs`).action(async(e,t)=>{await i.execute({appPath:y(e),verbose:t.verbose,apply:!0,force:t.force,inferDeletionFromMissingEntities:t.delete})}),e.command(`pull [appPath]`).description(`Write the installed application back to local source files (experimental)`).option(`-u, --universal-identifier <id>`,`Universal identifier of the application to pull`).option(`-v, --verbose`,`Show detailed logs`).action(async(e,t)=>{await a.execute({appPath:y(e),universalIdentifier:t.universalIdentifier,verbose:t.verbose})}),e.command(`dev:build [appPath]`).description(`Build and generate API client`).option(`--tarball`,`Also pack into a .tgz tarball`).action(async(e,n)=>{await t.execute({appPath:y(e),tarball:n.tarball})}),e.command(`dev:typecheck [appPath]`).description(`Run TypeScript type checking`).action(async e=>{await o.execute({appPath:y(e)})}),e.command(`dev:add [entityType]`).description(`Scaffold a new entity (${Object.values(n.c).join(`|`)})`).option(`--path <path>`,`Path in which the entity should be created.`).action(async(e,t)=>{await s.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-DxcdSEBJ.js"));await new t().execute({remote:e.remote})}),e.command(`dev:generate-client [appPath]`).description(`Generate the typed API client for the built app from the active remote`).action(async e=>{await c.execute({appPath:y(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 l.execute({appPath:y(e),locale:t.locale})}),Qt(e)},fn=async(e,t)=>{let n=t.test?r.M:r.j,i=t.port?parseInt(t.port,10):n;(isNaN(i)||i<1||i>65535)&&(console.error(p.default.red(`Invalid port number.`)),process.exit(1));let a=await r.n({port:i,test:t.test,version:e,onProgress:e=>console.log(p.default.gray(e))});a.success||(console.error(p.default.red(a.error.message)),process.exit(1))},pn=e=>{let t=e.test?r.N:r.A;if(!r.F(t)){console.log(p.default.yellow(`No Twenty server container found.`));return}(0,f.execSync)(`docker stop ${t}`,{stdio:`ignore`}),console.log(p.default.green(`Twenty server stopped.`))},A=e=>{let t=e.test?r.N:r.A;if(!r.F(t)){console.log(p.default.yellow(`No Twenty server container found.`));return}try{(0,f.spawnSync)(`docker`,[`logs`,`-f`,`--tail`,e.lines,t],{stdio:`inherit`})}catch{}},mn=async e=>{let t=e.test?r.N:r.A,n=e.test?r.M:r.j;if(!r.F(t)){console.log(` Status: ${p.default.gray(`not created`)}`),console.log(p.default.gray(` Run 'yarn twenty docker:start${e.test?` --test`:``}' to create one.`));return}let i=r.V(t),a=i?r.R(t):n,o=i?await r.S(a):!1,s=o?p.default.green(`running (healthy)`):i?p.default.yellow(`running (starting...)`):p.default.gray(`stopped`),c=r.L(`APP_VERSION`,t);console.log(` Status: ${s}`),console.log(` URL: http://localhost:${a}`),c&&console.log(` Version: ${p.default.gray(c)}`),o&&console.log(p.default.gray(` Login: tim@apple.dev / tim@apple.dev`))},hn=e=>{let t=e.test?r.N:r.A,n=e.test?`twenty-app-dev-test-data`:`twenty-app-dev-data`,i=e.test?`twenty-app-dev-test-storage`:`twenty-app-dev-storage`,a=e.test?`twenty-app-dev-test-clickhouse`:`twenty-app-dev-clickhouse`;r.F(t)&&(0,f.execSync)(`docker rm -f ${t}`,{stdio:`ignore`});try{(0,f.execSync)(`docker volume rm ${n} ${i} ${a}`,{stdio:`ignore`})}catch{}console.log(p.default.green(`Twenty server data reset.`)),console.log(p.default.gray(`Run 'yarn twenty docker:start${e.test?` --test`:``}' to start a fresh instance.`))},j=async(e,t)=>{let n=await r.i({version:e??`latest`,test:t.test,onProgress:e=>console.log(p.default.gray(e))});n.success||(console.error(p.default.red(n.error.message)),process.exit(1));let{data:i}=n;if(!i.imageUpdated){console.log(p.default.green(` Already up to date (${i.image}).`));return}console.log(p.default.green(` Upgraded to: ${i.image}`)),i.containerRecreated&&console.log(p.default.gray(` Run 'yarn twenty docker:start${t.test?` --test`:``}' to wait for the server to be ready.`))},M=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(pn),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(A),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(j);let t=e.command(`server`,{hidden:!0}).description(`Manage a Twenty server (local instance and server-side actions)`),n=(e,t)=>console.warn(p.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`),pn(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`),A(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 j(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-DxcdSEBJ.js"));await new t().execute({remote:e.remote})})},N=/^(\d{1,3}\.){3}\d{1,3}$/,gn=e=>{try{let{hostname:t}=new URL(e);if(N.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`}},_n=async(e,t)=>t?((await r.t({apiKey:t,apiUrl:e})).success||(console.error(p.default.red(`✗ Authentication failed.`)),process.exit(1)),`API key`):vn(e),vn=async e=>{console.log(p.default.gray(`Opening browser for authentication...`));let t=await r.X({apiUrl:e});return t.success?`OAuth`:(console.log(p.default.yellow(t.error.message)),(await r.t({apiKey:(await m.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(p.default.red(`✗ Authentication failed.`)),process.exit(1)),`API key`)},yn=async e=>{e.apiUrl&&console.warn(p.default.yellow(`⚠ --api-url is deprecated. Use --url instead.`));let t=e.test?r.Q(!0):void 0,i=new r.Z(t?{configPath:t}:void 0),a=await i.getRemotes();if(e.as!==void 0&&a.includes(e.as)){let t=await i.getConfigForRemote(e.as);r.Z.setActiveRemote(e.as);let n=await _n(t.apiUrl,e.apiKey);console.log(p.default.green(`✓ Re-authenticated "${e.as}" via ${n}.`)),await i.setDefaultRemote(e.as),console.log(p.default.green(`✓ Default remote set to "${e.as}".`));return}let o=e.url??e.apiUrl;if(o)o=n.G(o);else{let t=await r.C();e.local?(t||(console.error(p.default.red(`No local Twenty server found.
394
- Start one with: yarn twenty docker:start`)),process.exit(1)),console.log(p.default.gray(`Found local server at ${t}`)),o=t):o=n.G((await m.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 s=e.as??gn(o);r.Z.setActiveRemote(s);let c=await _n(o,e.apiKey);console.log(p.default.green(`✓ Remote "${s}" added (${o}) via ${c}.`)),await i.setDefaultRemote(s),console.log(p.default.green(`✓ Default remote set to "${s}".`))},bn=async()=>{let e=new r.Z,t=await e.getRemotes(),n=await e.getDefaultRemote();if(t.length===0){console.log(`No remotes configured.`),console.log(`Use 'twenty remote:add' to add one.`);return}console.log(``);for(let r of t){let t=await e.getConfigForRemote(r),i=t.twentyCLIAccessToken?`oauth`:t.apiKey?`api-key`:`none`,a=r===n,o=a?`* `:` `,s=a?p.default.bold(r):r;console.log(`${o}${s} ${p.default.gray(t.apiUrl)} [${i}]`)}console.log(`
393
+ `)));let s=o.filePaths.frontComponents.map(e=>a.default.join(r,e)),{sourceCount:c,updatedLocaleFiles:l}=await cn({appPath:r,manifest:o.manifest,frontComponentSourcePaths:s,scaffoldLocale:i});console.log(p.default.green(`✓ Extracted ${c} string${c===1?``:`s`} to locales/`)),l.length>0&&console.log(p.default.gray(`Updated: ${l.join(`, `)}`))}},dn=e=>{let t=new Fe,r=new Jt,i=new Zt,a=new on,o=new ze,s=new Pe,c=new $t,l=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(`--no-delete`,`Keep entities that are missing from your source instead of deleting them`).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(p.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(p.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:y(e),verbose:n,apply:!t.dryRun,force:t.force,inferDeletionFromMissingEntities:t.delete});return}await r.execute({appPath:y(e),verbose:n,debounceMs:t.debounceMs?parseInt(t.debounceMs,10):void 0,force:t.force,inferDeletionFromMissingEntities:t.delete})}),e.command(`plan [appPath]`).description(`Preview metadata changes without applying them`).option(`--no-delete`,`Keep entities that are missing from your source instead of deleting them`).option(`-v, --verbose`,`Show detailed logs`).action(async(e,t)=>{await i.execute({appPath:y(e),verbose:t.verbose,apply:!1,inferDeletionFromMissingEntities:t.delete})}),e.command(`apply [appPath]`).description(`Apply local metadata changes after showing the plan`).option(`-f, --force`,`Apply destructive changes (deletes) without confirmation`).option(`--no-delete`,`Keep entities that are missing from your source instead of deleting them`).option(`-v, --verbose`,`Show detailed logs`).action(async(e,t)=>{await i.execute({appPath:y(e),verbose:t.verbose,apply:!0,force:t.force,inferDeletionFromMissingEntities:t.delete})}),e.command(`pull [appPath]`).description(`Write the installed application back to local source files (experimental)`).option(`-u, --universal-identifier <id>`,`Universal identifier of the application to pull`).option(`-v, --verbose`,`Show detailed logs`).action(async(e,t)=>{await a.execute({appPath:y(e),universalIdentifier:t.universalIdentifier,verbose:t.verbose})}),e.command(`dev:build [appPath]`).description(`Build and generate API client`).option(`--tarball`,`Also pack into a .tgz tarball`).action(async(e,n)=>{await t.execute({appPath:y(e),tarball:n.tarball})}),e.command(`dev:typecheck [appPath]`).description(`Run TypeScript type checking`).action(async e=>{await o.execute({appPath:y(e)})}),e.command(`dev:add [entityType]`).description(`Scaffold a new entity (${Object.values(n.c).join(`|`)})`).option(`--path <path>`,`Path in which the entity should be created.`).action(async(e,t)=>{await s.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-DJgluWIc.js"));await new t().execute({remote:e.remote})}),e.command(`dev:generate-client [appPath]`).description(`Generate the typed API client for the built app from the active remote`).action(async e=>{await c.execute({appPath:y(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 l.execute({appPath:y(e),locale:t.locale})}),Qt(e)},fn=async(e,t)=>{let n=t.test?r.M:r.j,i=t.port?parseInt(t.port,10):n;(isNaN(i)||i<1||i>65535)&&(console.error(p.default.red(`Invalid port number.`)),process.exit(1));let a=await r.n({port:i,test:t.test,version:e,onProgress:e=>console.log(p.default.gray(e))});a.success||(console.error(p.default.red(a.error.message)),process.exit(1))},pn=e=>{let t=e.test?r.N:r.A;if(!r.F(t)){console.log(p.default.yellow(`No Twenty server container found.`));return}(0,f.execSync)(`docker stop ${t}`,{stdio:`ignore`}),console.log(p.default.green(`Twenty server stopped.`))},A=e=>{let t=e.test?r.N:r.A;if(!r.F(t)){console.log(p.default.yellow(`No Twenty server container found.`));return}try{(0,f.spawnSync)(`docker`,[`logs`,`-f`,`--tail`,e.lines,t],{stdio:`inherit`})}catch{}},mn=async e=>{let t=e.test?r.N:r.A,n=e.test?r.M:r.j;if(!r.F(t)){console.log(` Status: ${p.default.gray(`not created`)}`),console.log(p.default.gray(` Run 'yarn twenty docker:start${e.test?` --test`:``}' to create one.`));return}let i=r.V(t),a=i?r.R(t):n,o=i?await r.S(a):!1,s=o?p.default.green(`running (healthy)`):i?p.default.yellow(`running (starting...)`):p.default.gray(`stopped`),c=r.L(`APP_VERSION`,t);console.log(` Status: ${s}`),console.log(` URL: http://localhost:${a}`),c&&console.log(` Version: ${p.default.gray(c)}`),o&&console.log(p.default.gray(` Login: tim@apple.dev / tim@apple.dev`))},hn=e=>{let t=e.test?r.N:r.A,n=e.test?`twenty-app-dev-test-data`:`twenty-app-dev-data`,i=e.test?`twenty-app-dev-test-storage`:`twenty-app-dev-storage`,a=e.test?`twenty-app-dev-test-clickhouse`:`twenty-app-dev-clickhouse`;r.F(t)&&(0,f.execSync)(`docker rm -f ${t}`,{stdio:`ignore`});try{(0,f.execSync)(`docker volume rm ${n} ${i} ${a}`,{stdio:`ignore`})}catch{}console.log(p.default.green(`Twenty server data reset.`)),console.log(p.default.gray(`Run 'yarn twenty docker:start${e.test?` --test`:``}' to start a fresh instance.`))},j=async(e,t)=>{let n=await r.i({version:e??`latest`,test:t.test,onProgress:e=>console.log(p.default.gray(e))});n.success||(console.error(p.default.red(n.error.message)),process.exit(1));let{data:i}=n;if(!i.imageUpdated){console.log(p.default.green(` Already up to date (${i.image}).`));return}console.log(p.default.green(` Upgraded to: ${i.image}`)),i.containerRecreated&&console.log(p.default.gray(` Run 'yarn twenty docker:start${t.test?` --test`:``}' to wait for the server to be ready.`))},M=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(pn),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(A),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(j);let t=e.command(`server`,{hidden:!0}).description(`Manage a Twenty server (local instance and server-side actions)`),n=(e,t)=>console.warn(p.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`),pn(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`),A(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 j(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-DJgluWIc.js"));await new t().execute({remote:e.remote})})},N=/^(\d{1,3}\.){3}\d{1,3}$/,gn=e=>{try{let{hostname:t}=new URL(e);if(N.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`}},_n=async(e,t)=>t?((await r.t({apiKey:t,apiUrl:e})).success||(console.error(p.default.red(`✗ Authentication failed.`)),process.exit(1)),`API key`):vn(e),vn=async e=>{console.log(p.default.gray(`Opening browser for authentication...`));let t=await r.X({apiUrl:e});return t.success?`OAuth`:(console.log(p.default.yellow(t.error.message)),(await r.t({apiKey:(await m.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(p.default.red(`✗ Authentication failed.`)),process.exit(1)),`API key`)},yn=async e=>{e.apiUrl&&console.warn(p.default.yellow(`⚠ --api-url is deprecated. Use --url instead.`));let t=e.test?r.Q(!0):void 0,i=new r.Z(t?{configPath:t}:void 0),a=await i.getRemotes();if(e.as!==void 0&&a.includes(e.as)){let t=await i.getConfigForRemote(e.as);r.Z.setActiveRemote(e.as);let n=await _n(t.apiUrl,e.apiKey);console.log(p.default.green(`✓ Re-authenticated "${e.as}" via ${n}.`)),await i.setDefaultRemote(e.as),console.log(p.default.green(`✓ Default remote set to "${e.as}".`));return}let o=e.url??e.apiUrl;if(o)o=n.Z(o);else{let t=await r.C();e.local?(t||(console.error(p.default.red(`No local Twenty server found.
394
+ Start one with: yarn twenty docker:start`)),process.exit(1)),console.log(p.default.gray(`Found local server at ${t}`)),o=t):o=n.Z((await m.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 s=e.as??gn(o);r.Z.setActiveRemote(s);let c=await _n(o,e.apiKey);console.log(p.default.green(`✓ Remote "${s}" added (${o}) via ${c}.`)),await i.setDefaultRemote(s),console.log(p.default.green(`✓ Default remote set to "${s}".`))},bn=async()=>{let e=new r.Z,t=await e.getRemotes(),n=await e.getDefaultRemote();if(t.length===0){console.log(`No remotes configured.`),console.log(`Use 'twenty remote:add' to add one.`);return}console.log(``);for(let r of t){let t=await e.getConfigForRemote(r),i=t.twentyCLIAccessToken?`oauth`:t.apiKey?`api-key`:`none`,a=r===n,o=a?`* `:` `,s=a?p.default.bold(r):r;console.log(`${o}${s} ${p.default.gray(t.apiUrl)} [${i}]`)}console.log(`
395
395
  `,p.default.gray(`Use 'twenty remote:use <name>' to change default`))},xn=async e=>{let t=new r.Z,n=e??(await m.default.prompt([{type:`select`,name:`remote`,message:`Select default remote:`,choices:await t.getRemotes()}])).remote;(await t.getRemotes()).includes(n)||(console.error(p.default.red(`Remote "${n}" not found.`)),process.exit(1)),await t.setDefaultRemote(n),console.log(p.default.green(`✓ Default remote set to "${n}".`))},Sn=async()=>{let e=new r.Z,t=new r.q,n=r.Z.getActiveRemote(),i=await e.getConfig(),a=i.twentyCLIAccessToken?`oauth`:i.apiKey?`api-key`:`none`;if(console.log(` Remote: ${p.default.bold(n)}`),console.log(` Server: ${i.apiUrl}`),a===`none`){console.log(` Auth: ${p.default.yellow(`not configured`)}`);return}let{authValid:o}=await t.validateAuth(),s=o?p.default.green(`${a} (valid)`):p.default.red(`${a} (invalid)`);console.log(` Auth: ${s}`)},P=async e=>{let t=new r.Z;(await t.getRemotes()).includes(e)||(console.error(p.default.red(`Remote "${e}" not found.`)),process.exit(1)),r.Z.setActiveRemote(e),await t.clearConfig(),console.log(p.default.green(`✓ Remote "${e}" removed.`))},Cn=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(yn),e.command(`remote:list`).description(`List all configured remotes`).action(bn),e.command(`remote:use [name]`).description(`Set the default remote`).action(xn),e.command(`remote:status`).description(`Show active remote auth status`).action(Sn),e.command(`remote:remove <name>`).description(`Remove a remote`).action(P);let t=e.command(`remote`,{hidden:!0}).description(`Manage remote Twenty servers`),n=(e,t)=>console.warn(p.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 yn(e)}),t.command(`list`).action(async()=>{n(`list`,`remote:list`),await bn()}),t.command(`switch [name]`).action(async e=>{n(`switch`,`remote:use`),await xn(e)}),t.command(`status`).action(async()=>{n(`status`,`remote:status`),await Sn()}),t.command(`remove <name>`).action(async e=>{n(`remove`,`remote:remove`),await P(e)})},wn=e=>{dn(e),ne(e),M(e),Cn(e),Be(e)};v.inspect.defaultOptions.depth=10;var Tn=new _.Command;Tn.name(`twenty`).description(`Deprecated CLI bundled with twenty-sdk`).version(i.t.version),Tn.option(`-r, --remote <name>`,`Use a specific remote (overrides the default set by remote:use)`),Tn.hook(`preAction`,async e=>{let t=(e.optsWithGlobals?e.optsWithGlobals():e.opts()).remote;t?console.log(p.default.gray(`Using remote: ${t}`)):t=await new r.Z().getDefaultRemote(),r.Z.setActiveRemote(t)}),wn(Tn),Tn.exitOverride(),console.warn(p.default.yellow([`Warning: The CLI bundled with twenty-sdk is deprecated. Use the standalone twenty package instead.`,`Install: npm install -g twenty`].join(`
396
396
  `)));try{Tn.parse()}catch(e){e instanceof _.CommanderError&&process.exit(e.exitCode),e instanceof Error&&(console.error(p.default.red(`Error:`),e.message),process.exit(1))}