twenty-sdk 2.9.1 → 2.10.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 (45) hide show
  1. package/dist/billing/index.cjs.map +1 -1
  2. package/dist/billing/index.mjs.map +1 -1
  3. package/dist/{catalog-sync-BCebNxby.js → catalog-sync-BjFX6eQu.js} +1 -1
  4. package/dist/{catalog-sync-Zp1B_jdA.mjs → catalog-sync-hdRK4nlg.mjs} +1 -1
  5. package/dist/cli/commands/dev/dev-once.d.ts +1 -0
  6. package/dist/cli/operations/dev-once.d.ts +1 -0
  7. package/dist/cli/utilities/api/api-response-type.d.ts +5 -5
  8. package/dist/cli/utilities/api/api-service.d.ts +8 -2
  9. package/dist/cli/utilities/api/application-api.d.ts +7 -1
  10. package/dist/cli/utilities/api/file-api.d.ts +2 -1
  11. package/dist/cli/utilities/build/manifest/manifest-extract-config.d.ts +2 -0
  12. package/dist/cli/utilities/dev/orchestrator/steps/format-sync-actions-summary.d.ts +3 -0
  13. package/dist/cli/utilities/dev/ui/components/dev-ui-application-panel.d.ts +2 -1
  14. package/dist/cli/utilities/dev/ui/components/dev-ui-entity-section.d.ts +3 -0
  15. package/dist/cli/utilities/dev/ui/components/dev-ui.d.ts +1 -1
  16. package/dist/cli/utilities/dev/ui/dev-ui-constants.d.ts +6 -0
  17. package/dist/cli/utilities/entity/entity-view-field-template.d.ts +3 -0
  18. package/dist/cli/utilities/error/format-manifest-validation-errors.d.ts +2 -1
  19. package/dist/cli/utilities/error/get-sync-error-recovery-hint.d.ts +1 -0
  20. package/dist/cli.cjs +117 -100
  21. package/dist/cli.mjs +2383 -2286
  22. package/dist/define/index.cjs +7 -7
  23. package/dist/define/index.cjs.map +1 -1
  24. package/dist/define/index.d.ts +181 -47
  25. package/dist/define/index.mjs +367 -247
  26. package/dist/define/index.mjs.map +1 -1
  27. package/dist/front-component/index.cjs.map +1 -1
  28. package/dist/front-component/index.mjs.map +1 -1
  29. package/dist/{get-function-input-schema-DTlcRJz3-Dv2yR3dh.mjs → get-function-input-schema-DTlcRJz3-CYRpYtm8.mjs} +1 -1
  30. package/dist/{get-function-input-schema-DTlcRJz3-dBL33k9U.js → get-function-input-schema-DTlcRJz3-Cpo6yw4B.js} +1 -1
  31. package/dist/logic-function/index.cjs +37 -1
  32. package/dist/logic-function/index.cjs.map +1 -1
  33. package/dist/logic-function/index.d.ts +33 -2
  34. package/dist/logic-function/index.mjs +97 -28
  35. package/dist/logic-function/index.mjs.map +1 -1
  36. package/dist/{login-oauth-CR6NzLmb.js → login-oauth-CU95X9A-.js} +55 -52
  37. package/dist/{login-oauth-rznAUORX.mjs → login-oauth-wSHikxei.mjs} +3608 -3414
  38. package/dist/operations.cjs +1 -1
  39. package/dist/operations.mjs +2 -2
  40. package/dist/ui/index.cjs +28 -28
  41. package/dist/ui/index.d.ts +12 -12
  42. package/dist/ui/index.mjs +7582 -7474
  43. package/dist/utils/index.cjs.map +1 -1
  44. package/dist/utils/index.mjs.map +1 -1
  45. package/package.json +5 -8
package/dist/cli.cjs CHANGED
@@ -1,57 +1,57 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var lm=Object.create;var Fo=Object.defineProperty;var cm=Object.getOwnPropertyDescriptor;var fm=Object.getOwnPropertyNames;var dm=Object.getPrototypeOf,pm=Object.prototype.hasOwnProperty;var hm=(l,s,r,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let f of fm(s))!pm.call(l,f)&&f!==r&&Fo(l,f,{get:()=>s[f],enumerable:!(c=cm(s,f))||c.enumerable});return l};var gm=(l,s,r)=>(r=l!=null?lm(dm(l)):{},hm(s||!l||!l.__esModule?Fo(r,"default",{value:l,enumerable:!0}):r,l));const q=require("path"),m=require("./login-oauth-CR6NzLmb.js"),rt=require("node:fs/promises"),mm=require("chalk"),vm=require("inquirer"),Q=require("uuid"),ym=require("chokidar"),_m=require("crypto"),Tn=require("node:child_process"),wm=require("node:path"),T=require("react/jsx-runtime"),bt=require("react"),Xo=require("commander"),Sm=require("util"),Mt=l=>l&&l.__esModule?l:{default:l},Ji=Mt(q),y=Mt(mm),Ye=Mt(vm),Qo=Mt(ym),xm=Mt(_m),Lo=Mt(wm),eu=Mt(bt),Z=process.env.INIT_CWD||process.cwd(),he=l=>l&&!l?.startsWith("/")?q.join(Z,l):l,Im=async l=>{const s=q.join(l,"package.json");if(await m.pathExists(s))try{const r=await rt.readFile(s,"utf-8"),c=JSON.parse(r);return c.dependencies?.["twenty-sdk"]??c.devDependencies?.["twenty-sdk"]??void 0}catch{return}},No=l=>{const s=l.match(/(\d+)\./);if(s)return parseInt(s[1],10);const r=l.match(/^[~^>=<]*(\d+)$/);return r?parseInt(r[1],10):null},tn=async l=>{const s=m.packageJson.version,r=await Im(l);if(!r)return;const c=No(s),f=No(r);c===null||f===null||c!==f&&(console.warn(y.default.yellow(`⚠ Version mismatch: your app requires twenty-sdk@${f}.x but the CLI running is v${s}. Major version mismatches may cause unexpected behavior.
3
- Update with: npm install -g twenty-sdk@${f}`)),console.warn(""))};class tu{async execute(s){s.private?await this.executePrivate(s):await this.executeNpm(s)}async executeNpm(s){const r=s.appPath??Z;await tn(r),console.log(y.default.blue("Publishing to npm...")),console.log(y.default.gray(`App path: ${r}
2
+ "use strict";var dm=Object.create;var No=Object.defineProperty;var pm=Object.getOwnPropertyDescriptor;var hm=Object.getOwnPropertyNames;var gm=Object.getPrototypeOf,mm=Object.prototype.hasOwnProperty;var vm=(u,s,r,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let f of hm(s))!mm.call(u,f)&&f!==r&&No(u,f,{get:()=>s[f],enumerable:!(c=pm(s,f))||c.enumerable});return u};var ym=(u,s,r)=>(r=u!=null?dm(gm(u)):{},vm(s||!u||!u.__esModule?No(r,"default",{value:u,enumerable:!0}):r,u));const q=require("path"),m=require("./login-oauth-CU95X9A-.js"),nt=require("node:fs/promises"),_m=require("chalk"),wm=require("inquirer"),X=require("uuid"),Sm=require("chokidar"),Im=require("crypto"),Pn=require("node:child_process"),xm=require("node:path"),b=require("react/jsx-runtime"),bt=require("react"),tu=require("commander"),Em=require("util"),Dt=u=>u&&u.__esModule?u:{default:u},Zi=Dt(q),y=Dt(_m),Ye=Dt(wm),nu=Dt(Sm),Am=Dt(Im),Oo=Dt(xm),ru=Dt(bt),Z=process.env.INIT_CWD||process.cwd(),ge=u=>u&&!u?.startsWith("/")?q.join(Z,u):u,bm=async u=>{const s=q.join(u,"package.json");if(await m.pathExists(s))try{const r=await nt.readFile(s,"utf-8"),c=JSON.parse(r);return c.dependencies?.["twenty-sdk"]??c.devDependencies?.["twenty-sdk"]??void 0}catch{return}},Uo=u=>{const s=u.match(/(\d+)\./);if(s)return parseInt(s[1],10);const r=u.match(/^[~^>=<]*(\d+)$/);return r?parseInt(r[1],10):null},tn=async u=>{const s=m.packageJson.version,r=await bm(u);if(!r)return;const c=Uo(s),f=Uo(r);c===null||f===null||c!==f&&(console.warn(y.default.yellow(`⚠ Version mismatch: your app requires twenty-sdk@${f}.x but the CLI running is v${s}. Major version mismatches may cause unexpected behavior.
3
+ Update with: npm install -g twenty-sdk@${f}`)),console.warn(""))};class iu{async execute(s){s.private?await this.executePrivate(s):await this.executeNpm(s)}async executeNpm(s){const r=s.appPath??Z;await tn(r),console.log(y.default.blue("Publishing to npm...")),console.log(y.default.gray(`App path: ${r}
4
4
  `));const c=await m.appPublish({appPath:r,npmTag:s.tag,onProgress:f=>console.log(y.default.gray(f))});c.success||(console.error(y.default.red(c.error.message)),process.exit(1)),console.log(y.default.green("✓ Published to npm successfully"))}async executePrivate(s){const r=s.appPath??Z;await tn(r);const c=s.remote??m.ConfigService.getActiveRemote();console.log(y.default.blue(`Deploying application on ${c}...`)),console.log(y.default.gray(`App path: ${r}
5
- `));const f=G=>console.log(y.default.gray(G)),S=await m.appBuild({appPath:r,tarball:!0,onProgress:f});S.success||(console.error(y.default.red(S.error.message)),process.exit(1));const E=await m.appDeploy({tarballPath:S.data.tarballPath,remote:s.remote,onProgress:f});E.success||(console.error(y.default.red(E.error.message)),process.exit(1));const C=await m.readJson(Ji.default.join(r,"package.json")).catch(()=>{}),P=C?.name??E.data.name,$=C?.version??"unknown";console.log(y.default.green(`
6
- ✓ Published ${P} v${$} to ${c}
7
- `)),console.log(" To install deployed application: `yarn twenty app:install`")}}class nu{async execute(s){const r=s.appPath??Z;await tn(r),await m.checkServerVersionCompatibility();const c=s.remote??m.ConfigService.getActiveRemote();console.log(y.default.blue(`Installing application on ${c}...`)),console.log(y.default.gray(`App path: ${r}
8
- `));const f=await m.appInstall({appPath:r,remote:s.remote});f.success||(console.error(y.default.red(f.error.message)),process.exit(1)),console.log(y.default.green("✓ Application installed"))}}class ru{async execute({appPath:s=Z,askForConfirmation:r}){const c=m.ConfigService.getActiveRemote();console.log(y.default.blue(`🚀 Uninstall Twenty Application on ${c}`)),console.log(y.default.gray(`📁 App Path: ${s}
9
- `)),r&&!await this.confirmationPrompt()&&(console.error(y.default.red("⛔️ Aborting uninstall")),process.exit(1));const f=await m.appUninstall({appPath:s});return f.success?(console.log(y.default.green("✅ Application uninstalled successfully")),{success:!0,data:void 0}):(console.error(y.default.red("❌ Uninstall failed:"),f.error.message),{success:!1,error:f.error.message})}async confirmationPrompt(){const{confirmation:s}=await Ye.default.prompt([{type:"confirm",name:"confirmation",message:"Are you sure you want to uninstall this application?",default:!1}]);return s}}const Em=l=>{const s=new tu,r=new nu,c=new ru;l.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(f,S)=>{await s.execute({appPath:he(f),private:S.private,remote:S.remote,tag:S.tag})}),l.command("app:install [appPath]").description("Install a deployed app on the server").option("-r, --remote <name>","Install on a specific remote").action(async(f,S)=>{await r.execute({appPath:he(f),remote:S.remote})}),l.command("app:uninstall [appPath]").description("Uninstall app from server").option("-y, --yes","Skip confirmation prompt").action(async(f,S)=>{try{const E=await c.execute({appPath:he(f),askForConfirmation:!S?.yes});process.exit(E.success?0:1)}catch{process.exit(1)}})};var Cn={exports:{}};var Am=Cn.exports,Oo;function bm(){return Oo||(Oo=1,(function(l,s){(function(){var r,c="4.17.21",f=200,S="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",E="Expected a function",C="Invalid `variable` option passed into `_.template`",P="__lodash_hash_undefined__",$=500,G="__lodash_placeholder__",Y=1,se=2,Fe=4,Ve=1,Je=2,xe=1,Ze=2,Rn=4,Le=8,Ct=16,Ie=32,Ee=64,st=128,rn=256,Er=512,pu=30,hu="...",gu=800,mu=16,Xi=1,vu=2,yu=3,Tt=1/0,mt=9007199254740991,_u=17976931348623157e292,Pn=NaN,Xe=4294967295,wu=Xe-1,Su=Xe>>>1,xu=[["ary",st],["bind",xe],["bindKey",Ze],["curry",Le],["curryRight",Ct],["flip",Er],["partial",Ie],["partialRight",Ee],["rearg",rn]],Wt="[object Arguments]",Fn="[object Array]",Iu="[object AsyncFunction]",sn="[object Boolean]",an="[object Date]",Eu="[object DOMException]",Ln="[object Error]",Nn="[object Function]",Qi="[object GeneratorFunction]",Ge="[object Map]",on="[object Number]",Au="[object Null]",at="[object Object]",es="[object Promise]",bu="[object Proxy]",un="[object RegExp]",qe="[object Set]",ln="[object String]",On="[object Symbol]",Cu="[object Undefined]",cn="[object WeakMap]",Tu="[object WeakSet]",fn="[object ArrayBuffer]",Bt="[object DataView]",Ar="[object Float32Array]",br="[object Float64Array]",Cr="[object Int8Array]",Tr="[object Int16Array]",Rr="[object Int32Array]",Pr="[object Uint8Array]",Fr="[object Uint8ClampedArray]",Lr="[object Uint16Array]",Nr="[object Uint32Array]",Ru=/\b__p \+= '';/g,Pu=/\b(__p \+=) '' \+/g,Fu=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ts=/&(?:amp|lt|gt|quot|#39);/g,ns=/[&<>"']/g,Lu=RegExp(ts.source),Nu=RegExp(ns.source),Ou=/<%-([\s\S]+?)%>/g,$u=/<%([\s\S]+?)%>/g,rs=/<%=([\s\S]+?)%>/g,Uu=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Du=/^\w*$/,Mu=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Or=/[\\^$.*+?()[\]{}|]/g,Wu=RegExp(Or.source),$r=/^\s+/,Bu=/\s/,ku=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Vu=/\{\n\/\* \[wrapped with (.+)\] \*/,Gu=/,? & /,qu=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Hu=/[()=,{}\[\]\/\s]/,zu=/\\(\\)?/g,Ku=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,is=/\w*$/,ju=/^[-+]0x[0-9a-f]+$/i,Yu=/^0b[01]+$/i,Ju=/^\[object .+?Constructor\]$/,Zu=/^0o[0-7]+$/i,Xu=/^(?:0|[1-9]\d*)$/,Qu=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,$n=/($^)/,el=/['\n\r\u2028\u2029\\]/g,Un="\\ud800-\\udfff",tl="\\u0300-\\u036f",nl="\\ufe20-\\ufe2f",rl="\\u20d0-\\u20ff",ss=tl+nl+rl,as="\\u2700-\\u27bf",os="a-z\\xdf-\\xf6\\xf8-\\xff",il="\\xac\\xb1\\xd7\\xf7",sl="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",al="\\u2000-\\u206f",ol=" \\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",us="A-Z\\xc0-\\xd6\\xd8-\\xde",ls="\\ufe0e\\ufe0f",cs=il+sl+al+ol,Ur="['’]",ul="["+Un+"]",fs="["+cs+"]",Dn="["+ss+"]",ds="\\d+",ll="["+as+"]",ps="["+os+"]",hs="[^"+Un+cs+ds+as+os+us+"]",Dr="\\ud83c[\\udffb-\\udfff]",cl="(?:"+Dn+"|"+Dr+")",gs="[^"+Un+"]",Mr="(?:\\ud83c[\\udde6-\\uddff]){2}",Wr="[\\ud800-\\udbff][\\udc00-\\udfff]",kt="["+us+"]",ms="\\u200d",vs="(?:"+ps+"|"+hs+")",fl="(?:"+kt+"|"+hs+")",ys="(?:"+Ur+"(?:d|ll|m|re|s|t|ve))?",_s="(?:"+Ur+"(?:D|LL|M|RE|S|T|VE))?",ws=cl+"?",Ss="["+ls+"]?",dl="(?:"+ms+"(?:"+[gs,Mr,Wr].join("|")+")"+Ss+ws+")*",pl="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",hl="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",xs=Ss+ws+dl,gl="(?:"+[ll,Mr,Wr].join("|")+")"+xs,ml="(?:"+[gs+Dn+"?",Dn,Mr,Wr,ul].join("|")+")",vl=RegExp(Ur,"g"),yl=RegExp(Dn,"g"),Br=RegExp(Dr+"(?="+Dr+")|"+ml+xs,"g"),_l=RegExp([kt+"?"+ps+"+"+ys+"(?="+[fs,kt,"$"].join("|")+")",fl+"+"+_s+"(?="+[fs,kt+vs,"$"].join("|")+")",kt+"?"+vs+"+"+ys,kt+"+"+_s,hl,pl,ds,gl].join("|"),"g"),wl=RegExp("["+ms+Un+ss+ls+"]"),Sl=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,xl=["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"],Il=-1,X={};X[Ar]=X[br]=X[Cr]=X[Tr]=X[Rr]=X[Pr]=X[Fr]=X[Lr]=X[Nr]=!0,X[Wt]=X[Fn]=X[fn]=X[sn]=X[Bt]=X[an]=X[Ln]=X[Nn]=X[Ge]=X[on]=X[at]=X[un]=X[qe]=X[ln]=X[cn]=!1;var J={};J[Wt]=J[Fn]=J[fn]=J[Bt]=J[sn]=J[an]=J[Ar]=J[br]=J[Cr]=J[Tr]=J[Rr]=J[Ge]=J[on]=J[at]=J[un]=J[qe]=J[ln]=J[On]=J[Pr]=J[Fr]=J[Lr]=J[Nr]=!0,J[Ln]=J[Nn]=J[cn]=!1;var El={À:"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"},Al={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},bl={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Cl={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Tl=parseFloat,Rl=parseInt,Is=typeof m.commonjsGlobal=="object"&&m.commonjsGlobal&&m.commonjsGlobal.Object===Object&&m.commonjsGlobal,Pl=typeof self=="object"&&self&&self.Object===Object&&self,ce=Is||Pl||Function("return this")(),kr=s&&!s.nodeType&&s,Rt=kr&&!0&&l&&!l.nodeType&&l,Es=Rt&&Rt.exports===kr,Vr=Es&&Is.process,Ne=(function(){try{var h=Rt&&Rt.require&&Rt.require("util").types;return h||Vr&&Vr.binding&&Vr.binding("util")}catch{}})(),As=Ne&&Ne.isArrayBuffer,bs=Ne&&Ne.isDate,Cs=Ne&&Ne.isMap,Ts=Ne&&Ne.isRegExp,Rs=Ne&&Ne.isSet,Ps=Ne&&Ne.isTypedArray;function Ae(h,_,v){switch(v.length){case 0:return h.call(_);case 1:return h.call(_,v[0]);case 2:return h.call(_,v[0],v[1]);case 3:return h.call(_,v[0],v[1],v[2])}return h.apply(_,v)}function Fl(h,_,v,b){for(var O=-1,H=h==null?0:h.length;++O<H;){var ae=h[O];_(b,ae,v(ae),h)}return b}function Oe(h,_){for(var v=-1,b=h==null?0:h.length;++v<b&&_(h[v],v,h)!==!1;);return h}function Ll(h,_){for(var v=h==null?0:h.length;v--&&_(h[v],v,h)!==!1;);return h}function Fs(h,_){for(var v=-1,b=h==null?0:h.length;++v<b;)if(!_(h[v],v,h))return!1;return!0}function vt(h,_){for(var v=-1,b=h==null?0:h.length,O=0,H=[];++v<b;){var ae=h[v];_(ae,v,h)&&(H[O++]=ae)}return H}function Mn(h,_){var v=h==null?0:h.length;return!!v&&Vt(h,_,0)>-1}function Gr(h,_,v){for(var b=-1,O=h==null?0:h.length;++b<O;)if(v(_,h[b]))return!0;return!1}function ee(h,_){for(var v=-1,b=h==null?0:h.length,O=Array(b);++v<b;)O[v]=_(h[v],v,h);return O}function yt(h,_){for(var v=-1,b=_.length,O=h.length;++v<b;)h[O+v]=_[v];return h}function qr(h,_,v,b){var O=-1,H=h==null?0:h.length;for(b&&H&&(v=h[++O]);++O<H;)v=_(v,h[O],O,h);return v}function Nl(h,_,v,b){var O=h==null?0:h.length;for(b&&O&&(v=h[--O]);O--;)v=_(v,h[O],O,h);return v}function Hr(h,_){for(var v=-1,b=h==null?0:h.length;++v<b;)if(_(h[v],v,h))return!0;return!1}var Ol=zr("length");function $l(h){return h.split("")}function Ul(h){return h.match(qu)||[]}function Ls(h,_,v){var b;return v(h,function(O,H,ae){if(_(O,H,ae))return b=H,!1}),b}function Wn(h,_,v,b){for(var O=h.length,H=v+(b?1:-1);b?H--:++H<O;)if(_(h[H],H,h))return H;return-1}function Vt(h,_,v){return _===_?jl(h,_,v):Wn(h,Ns,v)}function Dl(h,_,v,b){for(var O=v-1,H=h.length;++O<H;)if(b(h[O],_))return O;return-1}function Ns(h){return h!==h}function Os(h,_){var v=h==null?0:h.length;return v?jr(h,_)/v:Pn}function zr(h){return function(_){return _==null?r:_[h]}}function Kr(h){return function(_){return h==null?r:h[_]}}function $s(h,_,v,b,O){return O(h,function(H,ae,j){v=b?(b=!1,H):_(v,H,ae,j)}),v}function Ml(h,_){var v=h.length;for(h.sort(_);v--;)h[v]=h[v].value;return h}function jr(h,_){for(var v,b=-1,O=h.length;++b<O;){var H=_(h[b]);H!==r&&(v=v===r?H:v+H)}return v}function Yr(h,_){for(var v=-1,b=Array(h);++v<h;)b[v]=_(v);return b}function Wl(h,_){return ee(_,function(v){return[v,h[v]]})}function Us(h){return h&&h.slice(0,Bs(h)+1).replace($r,"")}function be(h){return function(_){return h(_)}}function Jr(h,_){return ee(_,function(v){return h[v]})}function dn(h,_){return h.has(_)}function Ds(h,_){for(var v=-1,b=h.length;++v<b&&Vt(_,h[v],0)>-1;);return v}function Ms(h,_){for(var v=h.length;v--&&Vt(_,h[v],0)>-1;);return v}function Bl(h,_){for(var v=h.length,b=0;v--;)h[v]===_&&++b;return b}var kl=Kr(El),Vl=Kr(Al);function Gl(h){return"\\"+Cl[h]}function ql(h,_){return h==null?r:h[_]}function Gt(h){return wl.test(h)}function Hl(h){return Sl.test(h)}function zl(h){for(var _,v=[];!(_=h.next()).done;)v.push(_.value);return v}function Zr(h){var _=-1,v=Array(h.size);return h.forEach(function(b,O){v[++_]=[O,b]}),v}function Ws(h,_){return function(v){return h(_(v))}}function _t(h,_){for(var v=-1,b=h.length,O=0,H=[];++v<b;){var ae=h[v];(ae===_||ae===G)&&(h[v]=G,H[O++]=v)}return H}function Bn(h){var _=-1,v=Array(h.size);return h.forEach(function(b){v[++_]=b}),v}function Kl(h){var _=-1,v=Array(h.size);return h.forEach(function(b){v[++_]=[b,b]}),v}function jl(h,_,v){for(var b=v-1,O=h.length;++b<O;)if(h[b]===_)return b;return-1}function Yl(h,_,v){for(var b=v+1;b--;)if(h[b]===_)return b;return b}function qt(h){return Gt(h)?Zl(h):Ol(h)}function He(h){return Gt(h)?Xl(h):$l(h)}function Bs(h){for(var _=h.length;_--&&Bu.test(h.charAt(_)););return _}var Jl=Kr(bl);function Zl(h){for(var _=Br.lastIndex=0;Br.test(h);)++_;return _}function Xl(h){return h.match(Br)||[]}function Ql(h){return h.match(_l)||[]}var ec=(function h(_){_=_==null?ce:Ht.defaults(ce.Object(),_,Ht.pick(ce,xl));var v=_.Array,b=_.Date,O=_.Error,H=_.Function,ae=_.Math,j=_.Object,Xr=_.RegExp,tc=_.String,$e=_.TypeError,kn=v.prototype,nc=H.prototype,zt=j.prototype,Vn=_["__core-js_shared__"],Gn=nc.toString,K=zt.hasOwnProperty,rc=0,ks=(function(){var e=/[^.]+$/.exec(Vn&&Vn.keys&&Vn.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})(),qn=zt.toString,ic=Gn.call(j),sc=ce._,ac=Xr("^"+Gn.call(K).replace(Or,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Hn=Es?_.Buffer:r,wt=_.Symbol,zn=_.Uint8Array,Vs=Hn?Hn.allocUnsafe:r,Kn=Ws(j.getPrototypeOf,j),Gs=j.create,qs=zt.propertyIsEnumerable,jn=kn.splice,Hs=wt?wt.isConcatSpreadable:r,pn=wt?wt.iterator:r,Pt=wt?wt.toStringTag:r,Yn=(function(){try{var e=$t(j,"defineProperty");return e({},"",{}),e}catch{}})(),oc=_.clearTimeout!==ce.clearTimeout&&_.clearTimeout,uc=b&&b.now!==ce.Date.now&&b.now,lc=_.setTimeout!==ce.setTimeout&&_.setTimeout,Jn=ae.ceil,Zn=ae.floor,Qr=j.getOwnPropertySymbols,cc=Hn?Hn.isBuffer:r,zs=_.isFinite,fc=kn.join,dc=Ws(j.keys,j),oe=ae.max,de=ae.min,pc=b.now,hc=_.parseInt,Ks=ae.random,gc=kn.reverse,ei=$t(_,"DataView"),hn=$t(_,"Map"),ti=$t(_,"Promise"),Kt=$t(_,"Set"),gn=$t(_,"WeakMap"),mn=$t(j,"create"),Xn=gn&&new gn,jt={},mc=Ut(ei),vc=Ut(hn),yc=Ut(ti),_c=Ut(Kt),wc=Ut(gn),Qn=wt?wt.prototype:r,vn=Qn?Qn.valueOf:r,js=Qn?Qn.toString:r;function o(e){if(ne(e)&&!U(e)&&!(e instanceof k)){if(e instanceof Ue)return e;if(K.call(e,"__wrapped__"))return Ya(e)}return new Ue(e)}var Yt=(function(){function e(){}return function(t){if(!te(t))return{};if(Gs)return Gs(t);e.prototype=t;var n=new e;return e.prototype=r,n}})();function er(){}function Ue(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}o.templateSettings={escape:Ou,evaluate:$u,interpolate:rs,variable:"",imports:{_:o}},o.prototype=er.prototype,o.prototype.constructor=o,Ue.prototype=Yt(er.prototype),Ue.prototype.constructor=Ue;function k(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Xe,this.__views__=[]}function Sc(){var e=new k(this.__wrapped__);return e.__actions__=ye(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=ye(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=ye(this.__views__),e}function xc(){if(this.__filtered__){var e=new k(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Ic(){var e=this.__wrapped__.value(),t=this.__dir__,n=U(e),i=t<0,a=n?e.length:0,u=Uf(0,a,this.__views__),d=u.start,p=u.end,g=p-d,w=i?p:d-1,x=this.__iteratees__,I=x.length,A=0,R=de(g,this.__takeCount__);if(!n||!i&&a==g&&R==g)return ya(e,this.__actions__);var L=[];e:for(;g--&&A<R;){w+=t;for(var M=-1,N=e[w];++M<I;){var B=x[M],V=B.iteratee,Re=B.type,ve=V(N);if(Re==vu)N=ve;else if(!ve){if(Re==Xi)continue e;break e}}L[A++]=N}return L}k.prototype=Yt(er.prototype),k.prototype.constructor=k;function Ft(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Ec(){this.__data__=mn?mn(null):{},this.size=0}function Ac(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function bc(e){var t=this.__data__;if(mn){var n=t[e];return n===P?r:n}return K.call(t,e)?t[e]:r}function Cc(e){var t=this.__data__;return mn?t[e]!==r:K.call(t,e)}function Tc(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=mn&&t===r?P:t,this}Ft.prototype.clear=Ec,Ft.prototype.delete=Ac,Ft.prototype.get=bc,Ft.prototype.has=Cc,Ft.prototype.set=Tc;function ot(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Rc(){this.__data__=[],this.size=0}function Pc(e){var t=this.__data__,n=tr(t,e);if(n<0)return!1;var i=t.length-1;return n==i?t.pop():jn.call(t,n,1),--this.size,!0}function Fc(e){var t=this.__data__,n=tr(t,e);return n<0?r:t[n][1]}function Lc(e){return tr(this.__data__,e)>-1}function Nc(e,t){var n=this.__data__,i=tr(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this}ot.prototype.clear=Rc,ot.prototype.delete=Pc,ot.prototype.get=Fc,ot.prototype.has=Lc,ot.prototype.set=Nc;function ut(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Oc(){this.size=0,this.__data__={hash:new Ft,map:new(hn||ot),string:new Ft}}function $c(e){var t=pr(this,e).delete(e);return this.size-=t?1:0,t}function Uc(e){return pr(this,e).get(e)}function Dc(e){return pr(this,e).has(e)}function Mc(e,t){var n=pr(this,e),i=n.size;return n.set(e,t),this.size+=n.size==i?0:1,this}ut.prototype.clear=Oc,ut.prototype.delete=$c,ut.prototype.get=Uc,ut.prototype.has=Dc,ut.prototype.set=Mc;function Lt(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new ut;++t<n;)this.add(e[t])}function Wc(e){return this.__data__.set(e,P),this}function Bc(e){return this.__data__.has(e)}Lt.prototype.add=Lt.prototype.push=Wc,Lt.prototype.has=Bc;function ze(e){var t=this.__data__=new ot(e);this.size=t.size}function kc(){this.__data__=new ot,this.size=0}function Vc(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function Gc(e){return this.__data__.get(e)}function qc(e){return this.__data__.has(e)}function Hc(e,t){var n=this.__data__;if(n instanceof ot){var i=n.__data__;if(!hn||i.length<f-1)return i.push([e,t]),this.size=++n.size,this;n=this.__data__=new ut(i)}return n.set(e,t),this.size=n.size,this}ze.prototype.clear=kc,ze.prototype.delete=Vc,ze.prototype.get=Gc,ze.prototype.has=qc,ze.prototype.set=Hc;function Ys(e,t){var n=U(e),i=!n&&Dt(e),a=!n&&!i&&At(e),u=!n&&!i&&!a&&Qt(e),d=n||i||a||u,p=d?Yr(e.length,tc):[],g=p.length;for(var w in e)(t||K.call(e,w))&&!(d&&(w=="length"||a&&(w=="offset"||w=="parent")||u&&(w=="buffer"||w=="byteLength"||w=="byteOffset")||dt(w,g)))&&p.push(w);return p}function Js(e){var t=e.length;return t?e[di(0,t-1)]:r}function zc(e,t){return hr(ye(e),Nt(t,0,e.length))}function Kc(e){return hr(ye(e))}function ni(e,t,n){(n!==r&&!Ke(e[t],n)||n===r&&!(t in e))&&lt(e,t,n)}function yn(e,t,n){var i=e[t];(!(K.call(e,t)&&Ke(i,n))||n===r&&!(t in e))&&lt(e,t,n)}function tr(e,t){for(var n=e.length;n--;)if(Ke(e[n][0],t))return n;return-1}function jc(e,t,n,i){return St(e,function(a,u,d){t(i,a,n(a),d)}),i}function Zs(e,t){return e&&et(t,ue(t),e)}function Yc(e,t){return e&&et(t,we(t),e)}function lt(e,t,n){t=="__proto__"&&Yn?Yn(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function ri(e,t){for(var n=-1,i=t.length,a=v(i),u=e==null;++n<i;)a[n]=u?r:Di(e,t[n]);return a}function Nt(e,t,n){return e===e&&(n!==r&&(e=e<=n?e:n),t!==r&&(e=e>=t?e:t)),e}function De(e,t,n,i,a,u){var d,p=t&Y,g=t&se,w=t&Fe;if(n&&(d=a?n(e,i,a,u):n(e)),d!==r)return d;if(!te(e))return e;var x=U(e);if(x){if(d=Mf(e),!p)return ye(e,d)}else{var I=pe(e),A=I==Nn||I==Qi;if(At(e))return Sa(e,p);if(I==at||I==Wt||A&&!a){if(d=g||A?{}:Ba(e),!p)return g?Cf(e,Yc(d,e)):bf(e,Zs(d,e))}else{if(!J[I])return a?e:{};d=Wf(e,I,p)}}u||(u=new ze);var R=u.get(e);if(R)return R;u.set(e,d),mo(e)?e.forEach(function(N){d.add(De(N,t,n,N,e,u))}):ho(e)&&e.forEach(function(N,B){d.set(B,De(N,t,n,B,e,u))});var L=w?g?Ii:xi:g?we:ue,M=x?r:L(e);return Oe(M||e,function(N,B){M&&(B=N,N=e[B]),yn(d,B,De(N,t,n,B,e,u))}),d}function Jc(e){var t=ue(e);return function(n){return Xs(n,e,t)}}function Xs(e,t,n){var i=n.length;if(e==null)return!i;for(e=j(e);i--;){var a=n[i],u=t[a],d=e[a];if(d===r&&!(a in e)||!u(d))return!1}return!0}function Qs(e,t,n){if(typeof e!="function")throw new $e(E);return An(function(){e.apply(r,n)},t)}function _n(e,t,n,i){var a=-1,u=Mn,d=!0,p=e.length,g=[],w=t.length;if(!p)return g;n&&(t=ee(t,be(n))),i?(u=Gr,d=!1):t.length>=f&&(u=dn,d=!1,t=new Lt(t));e:for(;++a<p;){var x=e[a],I=n==null?x:n(x);if(x=i||x!==0?x:0,d&&I===I){for(var A=w;A--;)if(t[A]===I)continue e;g.push(x)}else u(t,I,i)||g.push(x)}return g}var St=ba(Qe),ea=ba(si,!0);function Zc(e,t){var n=!0;return St(e,function(i,a,u){return n=!!t(i,a,u),n}),n}function nr(e,t,n){for(var i=-1,a=e.length;++i<a;){var u=e[i],d=t(u);if(d!=null&&(p===r?d===d&&!Te(d):n(d,p)))var p=d,g=u}return g}function Xc(e,t,n,i){var a=e.length;for(n=D(n),n<0&&(n=-n>a?0:a+n),i=i===r||i>a?a:D(i),i<0&&(i+=a),i=n>i?0:yo(i);n<i;)e[n++]=t;return e}function ta(e,t){var n=[];return St(e,function(i,a,u){t(i,a,u)&&n.push(i)}),n}function fe(e,t,n,i,a){var u=-1,d=e.length;for(n||(n=kf),a||(a=[]);++u<d;){var p=e[u];t>0&&n(p)?t>1?fe(p,t-1,n,i,a):yt(a,p):i||(a[a.length]=p)}return a}var ii=Ca(),na=Ca(!0);function Qe(e,t){return e&&ii(e,t,ue)}function si(e,t){return e&&na(e,t,ue)}function rr(e,t){return vt(t,function(n){return pt(e[n])})}function Ot(e,t){t=It(t,e);for(var n=0,i=t.length;e!=null&&n<i;)e=e[tt(t[n++])];return n&&n==i?e:r}function ra(e,t,n){var i=t(e);return U(e)?i:yt(i,n(e))}function ge(e){return e==null?e===r?Cu:Au:Pt&&Pt in j(e)?$f(e):jf(e)}function ai(e,t){return e>t}function Qc(e,t){return e!=null&&K.call(e,t)}function ef(e,t){return e!=null&&t in j(e)}function tf(e,t,n){return e>=de(t,n)&&e<oe(t,n)}function oi(e,t,n){for(var i=n?Gr:Mn,a=e[0].length,u=e.length,d=u,p=v(u),g=1/0,w=[];d--;){var x=e[d];d&&t&&(x=ee(x,be(t))),g=de(x.length,g),p[d]=!n&&(t||a>=120&&x.length>=120)?new Lt(d&&x):r}x=e[0];var I=-1,A=p[0];e:for(;++I<a&&w.length<g;){var R=x[I],L=t?t(R):R;if(R=n||R!==0?R:0,!(A?dn(A,L):i(w,L,n))){for(d=u;--d;){var M=p[d];if(!(M?dn(M,L):i(e[d],L,n)))continue e}A&&A.push(L),w.push(R)}}return w}function nf(e,t,n,i){return Qe(e,function(a,u,d){t(i,n(a),u,d)}),i}function wn(e,t,n){t=It(t,e),e=qa(e,t);var i=e==null?e:e[tt(We(t))];return i==null?r:Ae(i,e,n)}function ia(e){return ne(e)&&ge(e)==Wt}function rf(e){return ne(e)&&ge(e)==fn}function sf(e){return ne(e)&&ge(e)==an}function Sn(e,t,n,i,a){return e===t?!0:e==null||t==null||!ne(e)&&!ne(t)?e!==e&&t!==t:af(e,t,n,i,Sn,a)}function af(e,t,n,i,a,u){var d=U(e),p=U(t),g=d?Fn:pe(e),w=p?Fn:pe(t);g=g==Wt?at:g,w=w==Wt?at:w;var x=g==at,I=w==at,A=g==w;if(A&&At(e)){if(!At(t))return!1;d=!0,x=!1}if(A&&!x)return u||(u=new ze),d||Qt(e)?Da(e,t,n,i,a,u):Nf(e,t,g,n,i,a,u);if(!(n&Ve)){var R=x&&K.call(e,"__wrapped__"),L=I&&K.call(t,"__wrapped__");if(R||L){var M=R?e.value():e,N=L?t.value():t;return u||(u=new ze),a(M,N,n,i,u)}}return A?(u||(u=new ze),Of(e,t,n,i,a,u)):!1}function of(e){return ne(e)&&pe(e)==Ge}function ui(e,t,n,i){var a=n.length,u=a,d=!i;if(e==null)return!u;for(e=j(e);a--;){var p=n[a];if(d&&p[2]?p[1]!==e[p[0]]:!(p[0]in e))return!1}for(;++a<u;){p=n[a];var g=p[0],w=e[g],x=p[1];if(d&&p[2]){if(w===r&&!(g in e))return!1}else{var I=new ze;if(i)var A=i(w,x,g,e,t,I);if(!(A===r?Sn(x,w,Ve|Je,i,I):A))return!1}}return!0}function sa(e){if(!te(e)||Gf(e))return!1;var t=pt(e)?ac:Ju;return t.test(Ut(e))}function uf(e){return ne(e)&&ge(e)==un}function lf(e){return ne(e)&&pe(e)==qe}function cf(e){return ne(e)&&wr(e.length)&&!!X[ge(e)]}function aa(e){return typeof e=="function"?e:e==null?Se:typeof e=="object"?U(e)?la(e[0],e[1]):ua(e):Ro(e)}function li(e){if(!En(e))return dc(e);var t=[];for(var n in j(e))K.call(e,n)&&n!="constructor"&&t.push(n);return t}function ff(e){if(!te(e))return Kf(e);var t=En(e),n=[];for(var i in e)i=="constructor"&&(t||!K.call(e,i))||n.push(i);return n}function ci(e,t){return e<t}function oa(e,t){var n=-1,i=_e(e)?v(e.length):[];return St(e,function(a,u,d){i[++n]=t(a,u,d)}),i}function ua(e){var t=Ai(e);return t.length==1&&t[0][2]?Va(t[0][0],t[0][1]):function(n){return n===e||ui(n,e,t)}}function la(e,t){return Ci(e)&&ka(t)?Va(tt(e),t):function(n){var i=Di(n,e);return i===r&&i===t?Mi(n,e):Sn(t,i,Ve|Je)}}function ir(e,t,n,i,a){e!==t&&ii(t,function(u,d){if(a||(a=new ze),te(u))df(e,t,d,n,ir,i,a);else{var p=i?i(Ri(e,d),u,d+"",e,t,a):r;p===r&&(p=u),ni(e,d,p)}},we)}function df(e,t,n,i,a,u,d){var p=Ri(e,n),g=Ri(t,n),w=d.get(g);if(w){ni(e,n,w);return}var x=u?u(p,g,n+"",e,t,d):r,I=x===r;if(I){var A=U(g),R=!A&&At(g),L=!A&&!R&&Qt(g);x=g,A||R||L?U(p)?x=p:re(p)?x=ye(p):R?(I=!1,x=Sa(g,!0)):L?(I=!1,x=xa(g,!0)):x=[]:bn(g)||Dt(g)?(x=p,Dt(p)?x=_o(p):(!te(p)||pt(p))&&(x=Ba(g))):I=!1}I&&(d.set(g,x),a(x,g,i,u,d),d.delete(g)),ni(e,n,x)}function ca(e,t){var n=e.length;if(n)return t+=t<0?n:0,dt(t,n)?e[t]:r}function fa(e,t,n){t.length?t=ee(t,function(u){return U(u)?function(d){return Ot(d,u.length===1?u[0]:u)}:u}):t=[Se];var i=-1;t=ee(t,be(F()));var a=oa(e,function(u,d,p){var g=ee(t,function(w){return w(u)});return{criteria:g,index:++i,value:u}});return Ml(a,function(u,d){return Af(u,d,n)})}function pf(e,t){return da(e,t,function(n,i){return Mi(e,i)})}function da(e,t,n){for(var i=-1,a=t.length,u={};++i<a;){var d=t[i],p=Ot(e,d);n(p,d)&&xn(u,It(d,e),p)}return u}function hf(e){return function(t){return Ot(t,e)}}function fi(e,t,n,i){var a=i?Dl:Vt,u=-1,d=t.length,p=e;for(e===t&&(t=ye(t)),n&&(p=ee(e,be(n)));++u<d;)for(var g=0,w=t[u],x=n?n(w):w;(g=a(p,x,g,i))>-1;)p!==e&&jn.call(p,g,1),jn.call(e,g,1);return e}function pa(e,t){for(var n=e?t.length:0,i=n-1;n--;){var a=t[n];if(n==i||a!==u){var u=a;dt(a)?jn.call(e,a,1):gi(e,a)}}return e}function di(e,t){return e+Zn(Ks()*(t-e+1))}function gf(e,t,n,i){for(var a=-1,u=oe(Jn((t-e)/(n||1)),0),d=v(u);u--;)d[i?u:++a]=e,e+=n;return d}function pi(e,t){var n="";if(!e||t<1||t>mt)return n;do t%2&&(n+=e),t=Zn(t/2),t&&(e+=e);while(t);return n}function W(e,t){return Pi(Ga(e,t,Se),e+"")}function mf(e){return Js(en(e))}function vf(e,t){var n=en(e);return hr(n,Nt(t,0,n.length))}function xn(e,t,n,i){if(!te(e))return e;t=It(t,e);for(var a=-1,u=t.length,d=u-1,p=e;p!=null&&++a<u;){var g=tt(t[a]),w=n;if(g==="__proto__"||g==="constructor"||g==="prototype")return e;if(a!=d){var x=p[g];w=i?i(x,g,p):r,w===r&&(w=te(x)?x:dt(t[a+1])?[]:{})}yn(p,g,w),p=p[g]}return e}var ha=Xn?function(e,t){return Xn.set(e,t),e}:Se,yf=Yn?function(e,t){return Yn(e,"toString",{configurable:!0,enumerable:!1,value:Bi(t),writable:!0})}:Se;function _f(e){return hr(en(e))}function Me(e,t,n){var i=-1,a=e.length;t<0&&(t=-t>a?0:a+t),n=n>a?a:n,n<0&&(n+=a),a=t>n?0:n-t>>>0,t>>>=0;for(var u=v(a);++i<a;)u[i]=e[i+t];return u}function wf(e,t){var n;return St(e,function(i,a,u){return n=t(i,a,u),!n}),!!n}function sr(e,t,n){var i=0,a=e==null?i:e.length;if(typeof t=="number"&&t===t&&a<=Su){for(;i<a;){var u=i+a>>>1,d=e[u];d!==null&&!Te(d)&&(n?d<=t:d<t)?i=u+1:a=u}return a}return hi(e,t,Se,n)}function hi(e,t,n,i){var a=0,u=e==null?0:e.length;if(u===0)return 0;t=n(t);for(var d=t!==t,p=t===null,g=Te(t),w=t===r;a<u;){var x=Zn((a+u)/2),I=n(e[x]),A=I!==r,R=I===null,L=I===I,M=Te(I);if(d)var N=i||L;else w?N=L&&(i||A):p?N=L&&A&&(i||!R):g?N=L&&A&&!R&&(i||!M):R||M?N=!1:N=i?I<=t:I<t;N?a=x+1:u=x}return de(u,wu)}function ga(e,t){for(var n=-1,i=e.length,a=0,u=[];++n<i;){var d=e[n],p=t?t(d):d;if(!n||!Ke(p,g)){var g=p;u[a++]=d===0?0:d}}return u}function ma(e){return typeof e=="number"?e:Te(e)?Pn:+e}function Ce(e){if(typeof e=="string")return e;if(U(e))return ee(e,Ce)+"";if(Te(e))return js?js.call(e):"";var t=e+"";return t=="0"&&1/e==-Tt?"-0":t}function xt(e,t,n){var i=-1,a=Mn,u=e.length,d=!0,p=[],g=p;if(n)d=!1,a=Gr;else if(u>=f){var w=t?null:Ff(e);if(w)return Bn(w);d=!1,a=dn,g=new Lt}else g=t?[]:p;e:for(;++i<u;){var x=e[i],I=t?t(x):x;if(x=n||x!==0?x:0,d&&I===I){for(var A=g.length;A--;)if(g[A]===I)continue e;t&&g.push(I),p.push(x)}else a(g,I,n)||(g!==p&&g.push(I),p.push(x))}return p}function gi(e,t){return t=It(t,e),e=qa(e,t),e==null||delete e[tt(We(t))]}function va(e,t,n,i){return xn(e,t,n(Ot(e,t)),i)}function ar(e,t,n,i){for(var a=e.length,u=i?a:-1;(i?u--:++u<a)&&t(e[u],u,e););return n?Me(e,i?0:u,i?u+1:a):Me(e,i?u+1:0,i?a:u)}function ya(e,t){var n=e;return n instanceof k&&(n=n.value()),qr(t,function(i,a){return a.func.apply(a.thisArg,yt([i],a.args))},n)}function mi(e,t,n){var i=e.length;if(i<2)return i?xt(e[0]):[];for(var a=-1,u=v(i);++a<i;)for(var d=e[a],p=-1;++p<i;)p!=a&&(u[a]=_n(u[a]||d,e[p],t,n));return xt(fe(u,1),t,n)}function _a(e,t,n){for(var i=-1,a=e.length,u=t.length,d={};++i<a;){var p=i<u?t[i]:r;n(d,e[i],p)}return d}function vi(e){return re(e)?e:[]}function yi(e){return typeof e=="function"?e:Se}function It(e,t){return U(e)?e:Ci(e,t)?[e]:ja(z(e))}var Sf=W;function Et(e,t,n){var i=e.length;return n=n===r?i:n,!t&&n>=i?e:Me(e,t,n)}var wa=oc||function(e){return ce.clearTimeout(e)};function Sa(e,t){if(t)return e.slice();var n=e.length,i=Vs?Vs(n):new e.constructor(n);return e.copy(i),i}function _i(e){var t=new e.constructor(e.byteLength);return new zn(t).set(new zn(e)),t}function xf(e,t){var n=t?_i(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function If(e){var t=new e.constructor(e.source,is.exec(e));return t.lastIndex=e.lastIndex,t}function Ef(e){return vn?j(vn.call(e)):{}}function xa(e,t){var n=t?_i(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Ia(e,t){if(e!==t){var n=e!==r,i=e===null,a=e===e,u=Te(e),d=t!==r,p=t===null,g=t===t,w=Te(t);if(!p&&!w&&!u&&e>t||u&&d&&g&&!p&&!w||i&&d&&g||!n&&g||!a)return 1;if(!i&&!u&&!w&&e<t||w&&n&&a&&!i&&!u||p&&n&&a||!d&&a||!g)return-1}return 0}function Af(e,t,n){for(var i=-1,a=e.criteria,u=t.criteria,d=a.length,p=n.length;++i<d;){var g=Ia(a[i],u[i]);if(g){if(i>=p)return g;var w=n[i];return g*(w=="desc"?-1:1)}}return e.index-t.index}function Ea(e,t,n,i){for(var a=-1,u=e.length,d=n.length,p=-1,g=t.length,w=oe(u-d,0),x=v(g+w),I=!i;++p<g;)x[p]=t[p];for(;++a<d;)(I||a<u)&&(x[n[a]]=e[a]);for(;w--;)x[p++]=e[a++];return x}function Aa(e,t,n,i){for(var a=-1,u=e.length,d=-1,p=n.length,g=-1,w=t.length,x=oe(u-p,0),I=v(x+w),A=!i;++a<x;)I[a]=e[a];for(var R=a;++g<w;)I[R+g]=t[g];for(;++d<p;)(A||a<u)&&(I[R+n[d]]=e[a++]);return I}function ye(e,t){var n=-1,i=e.length;for(t||(t=v(i));++n<i;)t[n]=e[n];return t}function et(e,t,n,i){var a=!n;n||(n={});for(var u=-1,d=t.length;++u<d;){var p=t[u],g=i?i(n[p],e[p],p,n,e):r;g===r&&(g=e[p]),a?lt(n,p,g):yn(n,p,g)}return n}function bf(e,t){return et(e,bi(e),t)}function Cf(e,t){return et(e,Ma(e),t)}function or(e,t){return function(n,i){var a=U(n)?Fl:jc,u=t?t():{};return a(n,e,F(i,2),u)}}function Jt(e){return W(function(t,n){var i=-1,a=n.length,u=a>1?n[a-1]:r,d=a>2?n[2]:r;for(u=e.length>3&&typeof u=="function"?(a--,u):r,d&&me(n[0],n[1],d)&&(u=a<3?r:u,a=1),t=j(t);++i<a;){var p=n[i];p&&e(t,p,i,u)}return t})}function ba(e,t){return function(n,i){if(n==null)return n;if(!_e(n))return e(n,i);for(var a=n.length,u=t?a:-1,d=j(n);(t?u--:++u<a)&&i(d[u],u,d)!==!1;);return n}}function Ca(e){return function(t,n,i){for(var a=-1,u=j(t),d=i(t),p=d.length;p--;){var g=d[e?p:++a];if(n(u[g],g,u)===!1)break}return t}}function Tf(e,t,n){var i=t&xe,a=In(e);function u(){var d=this&&this!==ce&&this instanceof u?a:e;return d.apply(i?n:this,arguments)}return u}function Ta(e){return function(t){t=z(t);var n=Gt(t)?He(t):r,i=n?n[0]:t.charAt(0),a=n?Et(n,1).join(""):t.slice(1);return i[e]()+a}}function Zt(e){return function(t){return qr(Co(bo(t).replace(vl,"")),e,"")}}function In(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=Yt(e.prototype),i=e.apply(n,t);return te(i)?i:n}}function Rf(e,t,n){var i=In(e);function a(){for(var u=arguments.length,d=v(u),p=u,g=Xt(a);p--;)d[p]=arguments[p];var w=u<3&&d[0]!==g&&d[u-1]!==g?[]:_t(d,g);if(u-=w.length,u<n)return Na(e,t,ur,a.placeholder,r,d,w,r,r,n-u);var x=this&&this!==ce&&this instanceof a?i:e;return Ae(x,this,d)}return a}function Ra(e){return function(t,n,i){var a=j(t);if(!_e(t)){var u=F(n,3);t=ue(t),n=function(p){return u(a[p],p,a)}}var d=e(t,n,i);return d>-1?a[u?t[d]:d]:r}}function Pa(e){return ft(function(t){var n=t.length,i=n,a=Ue.prototype.thru;for(e&&t.reverse();i--;){var u=t[i];if(typeof u!="function")throw new $e(E);if(a&&!d&&dr(u)=="wrapper")var d=new Ue([],!0)}for(i=d?i:n;++i<n;){u=t[i];var p=dr(u),g=p=="wrapper"?Ei(u):r;g&&Ti(g[0])&&g[1]==(st|Le|Ie|rn)&&!g[4].length&&g[9]==1?d=d[dr(g[0])].apply(d,g[3]):d=u.length==1&&Ti(u)?d[p]():d.thru(u)}return function(){var w=arguments,x=w[0];if(d&&w.length==1&&U(x))return d.plant(x).value();for(var I=0,A=n?t[I].apply(this,w):x;++I<n;)A=t[I].call(this,A);return A}})}function ur(e,t,n,i,a,u,d,p,g,w){var x=t&st,I=t&xe,A=t&Ze,R=t&(Le|Ct),L=t&Er,M=A?r:In(e);function N(){for(var B=arguments.length,V=v(B),Re=B;Re--;)V[Re]=arguments[Re];if(R)var ve=Xt(N),Pe=Bl(V,ve);if(i&&(V=Ea(V,i,a,R)),u&&(V=Aa(V,u,d,R)),B-=Pe,R&&B<w){var ie=_t(V,ve);return Na(e,t,ur,N.placeholder,n,V,ie,p,g,w-B)}var je=I?n:this,gt=A?je[e]:e;return B=V.length,p?V=Yf(V,p):L&&B>1&&V.reverse(),x&&g<B&&(V.length=g),this&&this!==ce&&this instanceof N&&(gt=M||In(gt)),gt.apply(je,V)}return N}function Fa(e,t){return function(n,i){return nf(n,e,t(i),{})}}function lr(e,t){return function(n,i){var a;if(n===r&&i===r)return t;if(n!==r&&(a=n),i!==r){if(a===r)return i;typeof n=="string"||typeof i=="string"?(n=Ce(n),i=Ce(i)):(n=ma(n),i=ma(i)),a=e(n,i)}return a}}function wi(e){return ft(function(t){return t=ee(t,be(F())),W(function(n){var i=this;return e(t,function(a){return Ae(a,i,n)})})})}function cr(e,t){t=t===r?" ":Ce(t);var n=t.length;if(n<2)return n?pi(t,e):t;var i=pi(t,Jn(e/qt(t)));return Gt(t)?Et(He(i),0,e).join(""):i.slice(0,e)}function Pf(e,t,n,i){var a=t&xe,u=In(e);function d(){for(var p=-1,g=arguments.length,w=-1,x=i.length,I=v(x+g),A=this&&this!==ce&&this instanceof d?u:e;++w<x;)I[w]=i[w];for(;g--;)I[w++]=arguments[++p];return Ae(A,a?n:this,I)}return d}function La(e){return function(t,n,i){return i&&typeof i!="number"&&me(t,n,i)&&(n=i=r),t=ht(t),n===r?(n=t,t=0):n=ht(n),i=i===r?t<n?1:-1:ht(i),gf(t,n,i,e)}}function fr(e){return function(t,n){return typeof t=="string"&&typeof n=="string"||(t=Be(t),n=Be(n)),e(t,n)}}function Na(e,t,n,i,a,u,d,p,g,w){var x=t&Le,I=x?d:r,A=x?r:d,R=x?u:r,L=x?r:u;t|=x?Ie:Ee,t&=~(x?Ee:Ie),t&Rn||(t&=-4);var M=[e,t,a,R,I,L,A,p,g,w],N=n.apply(r,M);return Ti(e)&&Ha(N,M),N.placeholder=i,za(N,e,t)}function Si(e){var t=ae[e];return function(n,i){if(n=Be(n),i=i==null?0:de(D(i),292),i&&zs(n)){var a=(z(n)+"e").split("e"),u=t(a[0]+"e"+(+a[1]+i));return a=(z(u)+"e").split("e"),+(a[0]+"e"+(+a[1]-i))}return t(n)}}var Ff=Kt&&1/Bn(new Kt([,-0]))[1]==Tt?function(e){return new Kt(e)}:Gi;function Oa(e){return function(t){var n=pe(t);return n==Ge?Zr(t):n==qe?Kl(t):Wl(t,e(t))}}function ct(e,t,n,i,a,u,d,p){var g=t&Ze;if(!g&&typeof e!="function")throw new $e(E);var w=i?i.length:0;if(w||(t&=-97,i=a=r),d=d===r?d:oe(D(d),0),p=p===r?p:D(p),w-=a?a.length:0,t&Ee){var x=i,I=a;i=a=r}var A=g?r:Ei(e),R=[e,t,n,i,a,x,I,u,d,p];if(A&&zf(R,A),e=R[0],t=R[1],n=R[2],i=R[3],a=R[4],p=R[9]=R[9]===r?g?0:e.length:oe(R[9]-w,0),!p&&t&(Le|Ct)&&(t&=-25),!t||t==xe)var L=Tf(e,t,n);else t==Le||t==Ct?L=Rf(e,t,p):(t==Ie||t==(xe|Ie))&&!a.length?L=Pf(e,t,n,i):L=ur.apply(r,R);var M=A?ha:Ha;return za(M(L,R),e,t)}function $a(e,t,n,i){return e===r||Ke(e,zt[n])&&!K.call(i,n)?t:e}function Ua(e,t,n,i,a,u){return te(e)&&te(t)&&(u.set(t,e),ir(e,t,r,Ua,u),u.delete(t)),e}function Lf(e){return bn(e)?r:e}function Da(e,t,n,i,a,u){var d=n&Ve,p=e.length,g=t.length;if(p!=g&&!(d&&g>p))return!1;var w=u.get(e),x=u.get(t);if(w&&x)return w==t&&x==e;var I=-1,A=!0,R=n&Je?new Lt:r;for(u.set(e,t),u.set(t,e);++I<p;){var L=e[I],M=t[I];if(i)var N=d?i(M,L,I,t,e,u):i(L,M,I,e,t,u);if(N!==r){if(N)continue;A=!1;break}if(R){if(!Hr(t,function(B,V){if(!dn(R,V)&&(L===B||a(L,B,n,i,u)))return R.push(V)})){A=!1;break}}else if(!(L===M||a(L,M,n,i,u))){A=!1;break}}return u.delete(e),u.delete(t),A}function Nf(e,t,n,i,a,u,d){switch(n){case Bt:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case fn:return!(e.byteLength!=t.byteLength||!u(new zn(e),new zn(t)));case sn:case an:case on:return Ke(+e,+t);case Ln:return e.name==t.name&&e.message==t.message;case un:case ln:return e==t+"";case Ge:var p=Zr;case qe:var g=i&Ve;if(p||(p=Bn),e.size!=t.size&&!g)return!1;var w=d.get(e);if(w)return w==t;i|=Je,d.set(e,t);var x=Da(p(e),p(t),i,a,u,d);return d.delete(e),x;case On:if(vn)return vn.call(e)==vn.call(t)}return!1}function Of(e,t,n,i,a,u){var d=n&Ve,p=xi(e),g=p.length,w=xi(t),x=w.length;if(g!=x&&!d)return!1;for(var I=g;I--;){var A=p[I];if(!(d?A in t:K.call(t,A)))return!1}var R=u.get(e),L=u.get(t);if(R&&L)return R==t&&L==e;var M=!0;u.set(e,t),u.set(t,e);for(var N=d;++I<g;){A=p[I];var B=e[A],V=t[A];if(i)var Re=d?i(V,B,A,t,e,u):i(B,V,A,e,t,u);if(!(Re===r?B===V||a(B,V,n,i,u):Re)){M=!1;break}N||(N=A=="constructor")}if(M&&!N){var ve=e.constructor,Pe=t.constructor;ve!=Pe&&"constructor"in e&&"constructor"in t&&!(typeof ve=="function"&&ve instanceof ve&&typeof Pe=="function"&&Pe instanceof Pe)&&(M=!1)}return u.delete(e),u.delete(t),M}function ft(e){return Pi(Ga(e,r,Xa),e+"")}function xi(e){return ra(e,ue,bi)}function Ii(e){return ra(e,we,Ma)}var Ei=Xn?function(e){return Xn.get(e)}:Gi;function dr(e){for(var t=e.name+"",n=jt[t],i=K.call(jt,t)?n.length:0;i--;){var a=n[i],u=a.func;if(u==null||u==e)return a.name}return t}function Xt(e){var t=K.call(o,"placeholder")?o:e;return t.placeholder}function F(){var e=o.iteratee||ki;return e=e===ki?aa:e,arguments.length?e(arguments[0],arguments[1]):e}function pr(e,t){var n=e.__data__;return Vf(t)?n[typeof t=="string"?"string":"hash"]:n.map}function Ai(e){for(var t=ue(e),n=t.length;n--;){var i=t[n],a=e[i];t[n]=[i,a,ka(a)]}return t}function $t(e,t){var n=ql(e,t);return sa(n)?n:r}function $f(e){var t=K.call(e,Pt),n=e[Pt];try{e[Pt]=r;var i=!0}catch{}var a=qn.call(e);return i&&(t?e[Pt]=n:delete e[Pt]),a}var bi=Qr?function(e){return e==null?[]:(e=j(e),vt(Qr(e),function(t){return qs.call(e,t)}))}:qi,Ma=Qr?function(e){for(var t=[];e;)yt(t,bi(e)),e=Kn(e);return t}:qi,pe=ge;(ei&&pe(new ei(new ArrayBuffer(1)))!=Bt||hn&&pe(new hn)!=Ge||ti&&pe(ti.resolve())!=es||Kt&&pe(new Kt)!=qe||gn&&pe(new gn)!=cn)&&(pe=function(e){var t=ge(e),n=t==at?e.constructor:r,i=n?Ut(n):"";if(i)switch(i){case mc:return Bt;case vc:return Ge;case yc:return es;case _c:return qe;case wc:return cn}return t});function Uf(e,t,n){for(var i=-1,a=n.length;++i<a;){var u=n[i],d=u.size;switch(u.type){case"drop":e+=d;break;case"dropRight":t-=d;break;case"take":t=de(t,e+d);break;case"takeRight":e=oe(e,t-d);break}}return{start:e,end:t}}function Df(e){var t=e.match(Vu);return t?t[1].split(Gu):[]}function Wa(e,t,n){t=It(t,e);for(var i=-1,a=t.length,u=!1;++i<a;){var d=tt(t[i]);if(!(u=e!=null&&n(e,d)))break;e=e[d]}return u||++i!=a?u:(a=e==null?0:e.length,!!a&&wr(a)&&dt(d,a)&&(U(e)||Dt(e)))}function Mf(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 Ba(e){return typeof e.constructor=="function"&&!En(e)?Yt(Kn(e)):{}}function Wf(e,t,n){var i=e.constructor;switch(t){case fn:return _i(e);case sn:case an:return new i(+e);case Bt:return xf(e,n);case Ar:case br:case Cr:case Tr:case Rr:case Pr:case Fr:case Lr:case Nr:return xa(e,n);case Ge:return new i;case on:case ln:return new i(e);case un:return If(e);case qe:return new i;case On:return Ef(e)}}function Bf(e,t){var n=t.length;if(!n)return e;var i=n-1;return t[i]=(n>1?"& ":"")+t[i],t=t.join(n>2?", ":" "),e.replace(ku,`{
5
+ `));const f=G=>console.log(y.default.gray(G)),w=await m.appBuild({appPath:r,tarball:!0,onProgress:f});w.success||(console.error(y.default.red(w.error.message)),process.exit(1));const x=await m.appDeploy({tarballPath:w.data.tarballPath,remote:s.remote,onProgress:f});x.success||(console.error(y.default.red(x.error.message)),process.exit(1));const T=await m.readJson(Zi.default.join(r,"package.json")).catch(()=>{}),$=T?.name??x.data.name,P=T?.version??"unknown";console.log(y.default.green(`
6
+ ✓ Published ${$} v${P} to ${c}
7
+ `)),console.log(" To install deployed application: `yarn twenty app:install`")}}class su{async execute(s){const r=s.appPath??Z;await tn(r),await m.checkServerVersionCompatibility();const c=s.remote??m.ConfigService.getActiveRemote();console.log(y.default.blue(`Installing application on ${c}...`)),console.log(y.default.gray(`App path: ${r}
8
+ `));const f=await m.appInstall({appPath:r,remote:s.remote});f.success||(console.error(y.default.red(f.error.message)),process.exit(1)),console.log(y.default.green("✓ Application installed"))}}class au{async execute({appPath:s=Z,askForConfirmation:r}){const c=m.ConfigService.getActiveRemote();console.log(y.default.blue(`🚀 Uninstall Twenty Application on ${c}`)),console.log(y.default.gray(`📁 App Path: ${s}
9
+ `)),r&&!await this.confirmationPrompt()&&(console.error(y.default.red("⛔️ Aborting uninstall")),process.exit(1));const f=await m.appUninstall({appPath:s});return f.success?(console.log(y.default.green("✅ Application uninstalled successfully")),{success:!0,data:void 0}):(console.error(y.default.red("❌ Uninstall failed:"),f.error.message),{success:!1,error:f.error.message})}async confirmationPrompt(){const{confirmation:s}=await Ye.default.prompt([{type:"confirm",name:"confirmation",message:"Are you sure you want to uninstall this application?",default:!1}]);return s}}const Cm=u=>{const s=new iu,r=new su,c=new au;u.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(f,w)=>{await s.execute({appPath:ge(f),private:w.private,remote:w.remote,tag:w.tag})}),u.command("app:install [appPath]").description("Install a deployed app on the server").option("-r, --remote <name>","Install on a specific remote").action(async(f,w)=>{await r.execute({appPath:ge(f),remote:w.remote})}),u.command("app:uninstall [appPath]").description("Uninstall app from server").option("-y, --yes","Skip confirmation prompt").action(async(f,w)=>{try{const x=await c.execute({appPath:ge(f),askForConfirmation:!w?.yes});process.exit(x.success?0:1)}catch{process.exit(1)}})};var Rn={exports:{}};var Tm=Rn.exports,Do;function Rm(){return Do||(Do=1,(function(u,s){(function(){var r,c="4.18.1",f=200,w="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",x="Expected a function",T="Invalid `variable` option passed into `_.template`",$="Invalid `imports` option passed into `_.template`",P="__lodash_hash_undefined__",G=500,ne="__lodash_placeholder__",Y=1,ht=2,Be=4,Fe=1,Mt=2,me=1,gt=2,rn=4,ke=8,rt=16,ce=32,sn=64,it=128,an=256,Er=512,yu=30,_u="...",wu=800,Su=16,Qi=1,Iu=2,xu=3,Ct=1/0,mt=9007199254740991,Eu=17976931348623157e292,Fn=NaN,Ze=4294967295,Au=Ze-1,bu=Ze>>>1,Cu=[["ary",it],["bind",me],["bindKey",gt],["curry",ke],["curryRight",rt],["flip",Er],["partial",ce],["partialRight",sn],["rearg",an]],Wt="[object Arguments]",$n="[object Array]",Tu="[object AsyncFunction]",on="[object Boolean]",un="[object Date]",Ru="[object DOMException]",Ln="[object Error]",Nn="[object Function]",es="[object GeneratorFunction]",Ve="[object Map]",ln="[object Number]",Pu="[object Null]",st="[object Object]",ts="[object Promise]",Fu="[object Proxy]",cn="[object RegExp]",Ge="[object Set]",fn="[object String]",On="[object Symbol]",$u="[object Undefined]",dn="[object WeakMap]",Lu="[object WeakSet]",pn="[object ArrayBuffer]",Bt="[object DataView]",Ar="[object Float32Array]",br="[object Float64Array]",Cr="[object Int8Array]",Tr="[object Int16Array]",Rr="[object Int32Array]",Pr="[object Uint8Array]",Fr="[object Uint8ClampedArray]",$r="[object Uint16Array]",Lr="[object Uint32Array]",Nu=/\b__p \+= '';/g,Ou=/\b(__p \+=) '' \+/g,Uu=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ns=/&(?:amp|lt|gt|quot|#39);/g,rs=/[&<>"']/g,Du=RegExp(ns.source),Mu=RegExp(rs.source),Wu=/<%-([\s\S]+?)%>/g,Bu=/<%([\s\S]+?)%>/g,is=/<%=([\s\S]+?)%>/g,ku=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Vu=/^\w*$/,Gu=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Nr=/[\\^$.*+?()[\]{}|]/g,qu=RegExp(Nr.source),Or=/^\s+/,Hu=/\s/,ju=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,zu=/\{\n\/\* \[wrapped with (.+)\] \*/,Ku=/,? & /,Yu=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ss=/[()=,{}\[\]\/\s]/,Ju=/\\(\\)?/g,Zu=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,as=/\w*$/,Xu=/^[-+]0x[0-9a-f]+$/i,Qu=/^0b[01]+$/i,el=/^\[object .+?Constructor\]$/,tl=/^0o[0-7]+$/i,nl=/^(?:0|[1-9]\d*)$/,rl=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Un=/($^)/,il=/['\n\r\u2028\u2029\\]/g,Dn="\\ud800-\\udfff",sl="\\u0300-\\u036f",al="\\ufe20-\\ufe2f",ol="\\u20d0-\\u20ff",os=sl+al+ol,us="\\u2700-\\u27bf",ls="a-z\\xdf-\\xf6\\xf8-\\xff",ul="\\xac\\xb1\\xd7\\xf7",ll="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",cl="\\u2000-\\u206f",fl=" \\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",cs="A-Z\\xc0-\\xd6\\xd8-\\xde",fs="\\ufe0e\\ufe0f",ds=ul+ll+cl+fl,Ur="['’]",dl="["+Dn+"]",ps="["+ds+"]",Mn="["+os+"]",hs="\\d+",pl="["+us+"]",gs="["+ls+"]",ms="[^"+Dn+ds+hs+us+ls+cs+"]",Dr="\\ud83c[\\udffb-\\udfff]",hl="(?:"+Mn+"|"+Dr+")",vs="[^"+Dn+"]",Mr="(?:\\ud83c[\\udde6-\\uddff]){2}",Wr="[\\ud800-\\udbff][\\udc00-\\udfff]",kt="["+cs+"]",ys="\\u200d",_s="(?:"+gs+"|"+ms+")",gl="(?:"+kt+"|"+ms+")",ws="(?:"+Ur+"(?:d|ll|m|re|s|t|ve))?",Ss="(?:"+Ur+"(?:D|LL|M|RE|S|T|VE))?",Is=hl+"?",xs="["+fs+"]?",ml="(?:"+ys+"(?:"+[vs,Mr,Wr].join("|")+")"+xs+Is+")*",vl="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",yl="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Es=xs+Is+ml,_l="(?:"+[pl,Mr,Wr].join("|")+")"+Es,wl="(?:"+[vs+Mn+"?",Mn,Mr,Wr,dl].join("|")+")",Sl=RegExp(Ur,"g"),Il=RegExp(Mn,"g"),Br=RegExp(Dr+"(?="+Dr+")|"+wl+Es,"g"),xl=RegExp([kt+"?"+gs+"+"+ws+"(?="+[ps,kt,"$"].join("|")+")",gl+"+"+Ss+"(?="+[ps,kt+_s,"$"].join("|")+")",kt+"?"+_s+"+"+ws,kt+"+"+Ss,yl,vl,hs,_l].join("|"),"g"),El=RegExp("["+ys+Dn+os+fs+"]"),Al=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,bl=["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"],Cl=-1,Q={};Q[Ar]=Q[br]=Q[Cr]=Q[Tr]=Q[Rr]=Q[Pr]=Q[Fr]=Q[$r]=Q[Lr]=!0,Q[Wt]=Q[$n]=Q[pn]=Q[on]=Q[Bt]=Q[un]=Q[Ln]=Q[Nn]=Q[Ve]=Q[ln]=Q[st]=Q[cn]=Q[Ge]=Q[fn]=Q[dn]=!1;var J={};J[Wt]=J[$n]=J[pn]=J[Bt]=J[on]=J[un]=J[Ar]=J[br]=J[Cr]=J[Tr]=J[Rr]=J[Ve]=J[ln]=J[st]=J[cn]=J[Ge]=J[fn]=J[On]=J[Pr]=J[Fr]=J[$r]=J[Lr]=!0,J[Ln]=J[Nn]=J[dn]=!1;var Tl={À:"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"},Rl={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Pl={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Fl={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},$l=parseFloat,Ll=parseInt,As=typeof m.commonjsGlobal=="object"&&m.commonjsGlobal&&m.commonjsGlobal.Object===Object&&m.commonjsGlobal,Nl=typeof self=="object"&&self&&self.Object===Object&&self,fe=As||Nl||Function("return this")(),kr=s&&!s.nodeType&&s,Tt=kr&&!0&&u&&!u.nodeType&&u,bs=Tt&&Tt.exports===kr,Vr=bs&&As.process,$e=(function(){try{var h=Tt&&Tt.require&&Tt.require("util").types;return h||Vr&&Vr.binding&&Vr.binding("util")}catch{}})(),Cs=$e&&$e.isArrayBuffer,Ts=$e&&$e.isDate,Rs=$e&&$e.isMap,Ps=$e&&$e.isRegExp,Fs=$e&&$e.isSet,$s=$e&&$e.isTypedArray;function Ee(h,_,v){switch(v.length){case 0:return h.call(_);case 1:return h.call(_,v[0]);case 2:return h.call(_,v[0],v[1]);case 3:return h.call(_,v[0],v[1],v[2])}return h.apply(_,v)}function Ol(h,_,v,C){for(var O=-1,H=h==null?0:h.length;++O<H;){var ae=h[O];_(C,ae,v(ae),h)}return C}function Ae(h,_){for(var v=-1,C=h==null?0:h.length;++v<C&&_(h[v],v,h)!==!1;);return h}function Ul(h,_){for(var v=h==null?0:h.length;v--&&_(h[v],v,h)!==!1;);return h}function Ls(h,_){for(var v=-1,C=h==null?0:h.length;++v<C;)if(!_(h[v],v,h))return!1;return!0}function vt(h,_){for(var v=-1,C=h==null?0:h.length,O=0,H=[];++v<C;){var ae=h[v];_(ae,v,h)&&(H[O++]=ae)}return H}function Wn(h,_){var v=h==null?0:h.length;return!!v&&Vt(h,_,0)>-1}function Gr(h,_,v){for(var C=-1,O=h==null?0:h.length;++C<O;)if(v(_,h[C]))return!0;return!1}function ee(h,_){for(var v=-1,C=h==null?0:h.length,O=Array(C);++v<C;)O[v]=_(h[v],v,h);return O}function yt(h,_){for(var v=-1,C=_.length,O=h.length;++v<C;)h[O+v]=_[v];return h}function qr(h,_,v,C){var O=-1,H=h==null?0:h.length;for(C&&H&&(v=h[++O]);++O<H;)v=_(v,h[O],O,h);return v}function Dl(h,_,v,C){var O=h==null?0:h.length;for(C&&O&&(v=h[--O]);O--;)v=_(v,h[O],O,h);return v}function Hr(h,_){for(var v=-1,C=h==null?0:h.length;++v<C;)if(_(h[v],v,h))return!0;return!1}var Ml=jr("length");function Wl(h){return h.split("")}function Bl(h){return h.match(Yu)||[]}function Ns(h,_,v){var C;return v(h,function(O,H,ae){if(_(O,H,ae))return C=H,!1}),C}function Bn(h,_,v,C){for(var O=h.length,H=v+(C?1:-1);C?H--:++H<O;)if(_(h[H],H,h))return H;return-1}function Vt(h,_,v){return _===_?Xl(h,_,v):Bn(h,Os,v)}function kl(h,_,v,C){for(var O=v-1,H=h.length;++O<H;)if(C(h[O],_))return O;return-1}function Os(h){return h!==h}function Us(h,_){var v=h==null?0:h.length;return v?Kr(h,_)/v:Fn}function jr(h){return function(_){return _==null?r:_[h]}}function zr(h){return function(_){return h==null?r:h[_]}}function Ds(h,_,v,C,O){return O(h,function(H,ae,K){v=C?(C=!1,H):_(v,H,ae,K)}),v}function Vl(h,_){var v=h.length;for(h.sort(_);v--;)h[v]=h[v].value;return h}function Kr(h,_){for(var v,C=-1,O=h.length;++C<O;){var H=_(h[C]);H!==r&&(v=v===r?H:v+H)}return v}function Yr(h,_){for(var v=-1,C=Array(h);++v<h;)C[v]=_(v);return C}function Gl(h,_){return ee(_,function(v){return[v,h[v]]})}function Ms(h){return h&&h.slice(0,Vs(h)+1).replace(Or,"")}function be(h){return function(_){return h(_)}}function Jr(h,_){return ee(_,function(v){return h[v]})}function hn(h,_){return h.has(_)}function Ws(h,_){for(var v=-1,C=h.length;++v<C&&Vt(_,h[v],0)>-1;);return v}function Bs(h,_){for(var v=h.length;v--&&Vt(_,h[v],0)>-1;);return v}function ql(h,_){for(var v=h.length,C=0;v--;)h[v]===_&&++C;return C}var Hl=zr(Tl),jl=zr(Rl);function zl(h){return"\\"+Fl[h]}function Kl(h,_){return h==null?r:h[_]}function Gt(h){return El.test(h)}function Yl(h){return Al.test(h)}function Jl(h){for(var _,v=[];!(_=h.next()).done;)v.push(_.value);return v}function Zr(h){var _=-1,v=Array(h.size);return h.forEach(function(C,O){v[++_]=[O,C]}),v}function ks(h,_){return function(v){return h(_(v))}}function _t(h,_){for(var v=-1,C=h.length,O=0,H=[];++v<C;){var ae=h[v];(ae===_||ae===ne)&&(h[v]=ne,H[O++]=v)}return H}function kn(h){var _=-1,v=Array(h.size);return h.forEach(function(C){v[++_]=C}),v}function Zl(h){var _=-1,v=Array(h.size);return h.forEach(function(C){v[++_]=[C,C]}),v}function Xl(h,_,v){for(var C=v-1,O=h.length;++C<O;)if(h[C]===_)return C;return-1}function Ql(h,_,v){for(var C=v+1;C--;)if(h[C]===_)return C;return C}function qt(h){return Gt(h)?tc(h):Ml(h)}function qe(h){return Gt(h)?nc(h):Wl(h)}function Vs(h){for(var _=h.length;_--&&Hu.test(h.charAt(_)););return _}var ec=zr(Pl);function tc(h){for(var _=Br.lastIndex=0;Br.test(h);)++_;return _}function nc(h){return h.match(Br)||[]}function rc(h){return h.match(xl)||[]}var ic=(function h(_){_=_==null?fe:Ht.defaults(fe.Object(),_,Ht.pick(fe,bl));var v=_.Array,C=_.Date,O=_.Error,H=_.Function,ae=_.Math,K=_.Object,Xr=_.RegExp,sc=_.String,Le=_.TypeError,Vn=v.prototype,ac=H.prototype,jt=K.prototype,Gn=_["__core-js_shared__"],qn=ac.toString,j=jt.hasOwnProperty,oc=0,Gs=(function(){var e=/[^.]+$/.exec(Gn&&Gn.keys&&Gn.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})(),Hn=jt.toString,uc=qn.call(K),lc=fe._,cc=Xr("^"+qn.call(j).replace(Nr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),jn=bs?_.Buffer:r,wt=_.Symbol,zn=_.Uint8Array,qs=jn?jn.allocUnsafe:r,Kn=ks(K.getPrototypeOf,K),Hs=K.create,js=jt.propertyIsEnumerable,Yn=Vn.splice,zs=wt?wt.isConcatSpreadable:r,gn=wt?wt.iterator:r,Rt=wt?wt.toStringTag:r,Jn=(function(){try{var e=Nt(K,"defineProperty");return e({},"",{}),e}catch{}})(),fc=_.clearTimeout!==fe.clearTimeout&&_.clearTimeout,dc=C&&C.now!==fe.Date.now&&C.now,pc=_.setTimeout!==fe.setTimeout&&_.setTimeout,Zn=ae.ceil,Xn=ae.floor,Qr=K.getOwnPropertySymbols,hc=jn?jn.isBuffer:r,Ks=_.isFinite,gc=Vn.join,mc=ks(K.keys,K),oe=ae.max,pe=ae.min,vc=C.now,yc=_.parseInt,Ys=ae.random,_c=Vn.reverse,ei=Nt(_,"DataView"),mn=Nt(_,"Map"),ti=Nt(_,"Promise"),zt=Nt(_,"Set"),vn=Nt(_,"WeakMap"),yn=Nt(K,"create"),Qn=vn&&new vn,Kt={},wc=Ot(ei),Sc=Ot(mn),Ic=Ot(ti),xc=Ot(zt),Ec=Ot(vn),er=wt?wt.prototype:r,_n=er?er.valueOf:r,Js=er?er.toString:r;function o(e){if(re(e)&&!U(e)&&!(e instanceof k)){if(e instanceof Ne)return e;if(j.call(e,"__wrapped__"))return Za(e)}return new Ne(e)}var Yt=(function(){function e(){}return function(t){if(!te(t))return{};if(Hs)return Hs(t);e.prototype=t;var n=new e;return e.prototype=r,n}})();function tr(){}function Ne(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}o.templateSettings={escape:Wu,evaluate:Bu,interpolate:is,variable:"",imports:{_:o}},o.prototype=tr.prototype,o.prototype.constructor=o,Ne.prototype=Yt(tr.prototype),Ne.prototype.constructor=Ne;function k(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Ze,this.__views__=[]}function Ac(){var e=new k(this.__wrapped__);return e.__actions__=we(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=we(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=we(this.__views__),e}function bc(){if(this.__filtered__){var e=new k(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Cc(){var e=this.__wrapped__.value(),t=this.__dir__,n=U(e),i=t<0,a=n?e.length:0,l=Bf(0,a,this.__views__),d=l.start,p=l.end,g=p-d,S=i?p:d-1,I=this.__iteratees__,E=I.length,A=0,R=pe(g,this.__takeCount__);if(!n||!i&&a==g&&R==g)return wa(e,this.__actions__);var N=[];e:for(;g--&&A<R;){S+=t;for(var M=-1,F=e[S];++M<E;){var B=I[M],V=B.iteratee,Re=B.type,_e=V(F);if(Re==Iu)F=_e;else if(!_e){if(Re==Qi)continue e;break e}}N[A++]=F}return N}k.prototype=Yt(tr.prototype),k.prototype.constructor=k;function Pt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Tc(){this.__data__=yn?yn(null):{},this.size=0}function Rc(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function Pc(e){var t=this.__data__;if(yn){var n=t[e];return n===P?r:n}return j.call(t,e)?t[e]:r}function Fc(e){var t=this.__data__;return yn?t[e]!==r:j.call(t,e)}function $c(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=yn&&t===r?P:t,this}Pt.prototype.clear=Tc,Pt.prototype.delete=Rc,Pt.prototype.get=Pc,Pt.prototype.has=Fc,Pt.prototype.set=$c;function at(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Lc(){this.__data__=[],this.size=0}function Nc(e){var t=this.__data__,n=nr(t,e);if(n<0)return!1;var i=t.length-1;return n==i?t.pop():Yn.call(t,n,1),--this.size,!0}function Oc(e){var t=this.__data__,n=nr(t,e);return n<0?r:t[n][1]}function Uc(e){return nr(this.__data__,e)>-1}function Dc(e,t){var n=this.__data__,i=nr(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this}at.prototype.clear=Lc,at.prototype.delete=Nc,at.prototype.get=Oc,at.prototype.has=Uc,at.prototype.set=Dc;function ot(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Mc(){this.size=0,this.__data__={hash:new Pt,map:new(mn||at),string:new Pt}}function Wc(e){var t=hr(this,e).delete(e);return this.size-=t?1:0,t}function Bc(e){return hr(this,e).get(e)}function kc(e){return hr(this,e).has(e)}function Vc(e,t){var n=hr(this,e),i=n.size;return n.set(e,t),this.size+=n.size==i?0:1,this}ot.prototype.clear=Mc,ot.prototype.delete=Wc,ot.prototype.get=Bc,ot.prototype.has=kc,ot.prototype.set=Vc;function Ft(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new ot;++t<n;)this.add(e[t])}function Gc(e){return this.__data__.set(e,P),this}function qc(e){return this.__data__.has(e)}Ft.prototype.add=Ft.prototype.push=Gc,Ft.prototype.has=qc;function He(e){var t=this.__data__=new at(e);this.size=t.size}function Hc(){this.__data__=new at,this.size=0}function jc(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function zc(e){return this.__data__.get(e)}function Kc(e){return this.__data__.has(e)}function Yc(e,t){var n=this.__data__;if(n instanceof at){var i=n.__data__;if(!mn||i.length<f-1)return i.push([e,t]),this.size=++n.size,this;n=this.__data__=new ot(i)}return n.set(e,t),this.size=n.size,this}He.prototype.clear=Hc,He.prototype.delete=jc,He.prototype.get=zc,He.prototype.has=Kc,He.prototype.set=Yc;function Zs(e,t){var n=U(e),i=!n&&Ut(e),a=!n&&!i&&At(e),l=!n&&!i&&!a&&Qt(e),d=n||i||a||l,p=d?Yr(e.length,sc):[],g=p.length;for(var S in e)(t||j.call(e,S))&&!(d&&(S=="length"||a&&(S=="offset"||S=="parent")||l&&(S=="buffer"||S=="byteLength"||S=="byteOffset")||ct(S,g)))&&p.push(S);return p}function Xs(e){var t=e.length;return t?e[di(0,t-1)]:r}function Jc(e,t){return gr(we(e),$t(t,0,e.length))}function Zc(e){return gr(we(e))}function ni(e,t,n){(n!==r&&!ze(e[t],n)||n===r&&!(t in e))&&Xe(e,t,n)}function wn(e,t,n){var i=e[t];(!(j.call(e,t)&&ze(i,n))||n===r&&!(t in e))&&Xe(e,t,n)}function nr(e,t){for(var n=e.length;n--;)if(ze(e[n][0],t))return n;return-1}function Xc(e,t,n,i){return St(e,function(a,l,d){t(i,a,n(a),d)}),i}function Qs(e,t){return e&&et(t,ue(t),e)}function Qc(e,t){return e&&et(t,Ie(t),e)}function Xe(e,t,n){t=="__proto__"&&Jn?Jn(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function ri(e,t){for(var n=-1,i=t.length,a=v(i),l=e==null;++n<i;)a[n]=l?r:Mi(e,t[n]);return a}function $t(e,t,n){return e===e&&(n!==r&&(e=e<=n?e:n),t!==r&&(e=e>=t?e:t)),e}function Oe(e,t,n,i,a,l){var d,p=t&Y,g=t&ht,S=t&Be;if(n&&(d=a?n(e,i,a,l):n(e)),d!==r)return d;if(!te(e))return e;var I=U(e);if(I){if(d=Vf(e),!p)return we(e,d)}else{var E=he(e),A=E==Nn||E==es;if(At(e))return xa(e,p);if(E==st||E==Wt||A&&!a){if(d=g||A?{}:Va(e),!p)return g?Ff(e,Qc(d,e)):Pf(e,Qs(d,e))}else{if(!J[E])return a?e:{};d=Gf(e,E,p)}}l||(l=new He);var R=l.get(e);if(R)return R;l.set(e,d),yo(e)?e.forEach(function(F){d.add(Oe(F,t,n,F,e,l))}):mo(e)&&e.forEach(function(F,B){d.set(B,Oe(F,t,n,B,e,l))});var N=S?g?xi:Ii:g?Ie:ue,M=I?r:N(e);return Ae(M||e,function(F,B){M&&(B=F,F=e[B]),wn(d,B,Oe(F,t,n,B,e,l))}),d}function ef(e){var t=ue(e);return function(n){return ea(n,e,t)}}function ea(e,t,n){var i=n.length;if(e==null)return!i;for(e=K(e);i--;){var a=n[i],l=t[a],d=e[a];if(d===r&&!(a in e)||!l(d))return!1}return!0}function ta(e,t,n){if(typeof e!="function")throw new Le(x);return Cn(function(){e.apply(r,n)},t)}function Sn(e,t,n,i){var a=-1,l=Wn,d=!0,p=e.length,g=[],S=t.length;if(!p)return g;n&&(t=ee(t,be(n))),i?(l=Gr,d=!1):t.length>=f&&(l=hn,d=!1,t=new Ft(t));e:for(;++a<p;){var I=e[a],E=n==null?I:n(I);if(I=i||I!==0?I:0,d&&E===E){for(var A=S;A--;)if(t[A]===E)continue e;g.push(I)}else l(t,E,i)||g.push(I)}return g}var St=Ta(Qe),na=Ta(si,!0);function tf(e,t){var n=!0;return St(e,function(i,a,l){return n=!!t(i,a,l),n}),n}function rr(e,t,n){for(var i=-1,a=e.length;++i<a;){var l=e[i],d=t(l);if(d!=null&&(p===r?d===d&&!Te(d):n(d,p)))var p=d,g=l}return g}function nf(e,t,n,i){var a=e.length;for(n=D(n),n<0&&(n=-n>a?0:a+n),i=i===r||i>a?a:D(i),i<0&&(i+=a),i=n>i?0:wo(i);n<i;)e[n++]=t;return e}function ra(e,t){var n=[];return St(e,function(i,a,l){t(i,a,l)&&n.push(i)}),n}function de(e,t,n,i,a){var l=-1,d=e.length;for(n||(n=Hf),a||(a=[]);++l<d;){var p=e[l];t>0&&n(p)?t>1?de(p,t-1,n,i,a):yt(a,p):i||(a[a.length]=p)}return a}var ii=Ra(),ia=Ra(!0);function Qe(e,t){return e&&ii(e,t,ue)}function si(e,t){return e&&ia(e,t,ue)}function ir(e,t){return vt(t,function(n){return ft(e[n])})}function Lt(e,t){t=xt(t,e);for(var n=0,i=t.length;e!=null&&n<i;)e=e[je(t[n++])];return n&&n==i?e:r}function sa(e,t,n){var i=t(e);return U(e)?i:yt(i,n(e))}function ve(e){return e==null?e===r?$u:Pu:Rt&&Rt in K(e)?Wf(e):Xf(e)}function ai(e,t){return e>t}function rf(e,t){return e!=null&&j.call(e,t)}function sf(e,t){return e!=null&&t in K(e)}function af(e,t,n){return e>=pe(t,n)&&e<oe(t,n)}function oi(e,t,n){for(var i=n?Gr:Wn,a=e[0].length,l=e.length,d=l,p=v(l),g=1/0,S=[];d--;){var I=e[d];d&&t&&(I=ee(I,be(t))),g=pe(I.length,g),p[d]=!n&&(t||a>=120&&I.length>=120)?new Ft(d&&I):r}I=e[0];var E=-1,A=p[0];e:for(;++E<a&&S.length<g;){var R=I[E],N=t?t(R):R;if(R=n||R!==0?R:0,!(A?hn(A,N):i(S,N,n))){for(d=l;--d;){var M=p[d];if(!(M?hn(M,N):i(e[d],N,n)))continue e}A&&A.push(N),S.push(R)}}return S}function of(e,t,n,i){return Qe(e,function(a,l,d){t(i,n(a),l,d)}),i}function In(e,t,n){t=xt(t,e),e=ja(e,t);var i=e==null?e:e[je(De(t))];return i==null?r:Ee(i,e,n)}function aa(e){return re(e)&&ve(e)==Wt}function uf(e){return re(e)&&ve(e)==pn}function lf(e){return re(e)&&ve(e)==un}function xn(e,t,n,i,a){return e===t?!0:e==null||t==null||!re(e)&&!re(t)?e!==e&&t!==t:cf(e,t,n,i,xn,a)}function cf(e,t,n,i,a,l){var d=U(e),p=U(t),g=d?$n:he(e),S=p?$n:he(t);g=g==Wt?st:g,S=S==Wt?st:S;var I=g==st,E=S==st,A=g==S;if(A&&At(e)){if(!At(t))return!1;d=!0,I=!1}if(A&&!I)return l||(l=new He),d||Qt(e)?Wa(e,t,n,i,a,l):Df(e,t,g,n,i,a,l);if(!(n&Fe)){var R=I&&j.call(e,"__wrapped__"),N=E&&j.call(t,"__wrapped__");if(R||N){var M=R?e.value():e,F=N?t.value():t;return l||(l=new He),a(M,F,n,i,l)}}return A?(l||(l=new He),Mf(e,t,n,i,a,l)):!1}function ff(e){return re(e)&&he(e)==Ve}function ui(e,t,n,i){var a=n.length,l=a,d=!i;if(e==null)return!l;for(e=K(e);a--;){var p=n[a];if(d&&p[2]?p[1]!==e[p[0]]:!(p[0]in e))return!1}for(;++a<l;){p=n[a];var g=p[0],S=e[g],I=p[1];if(d&&p[2]){if(S===r&&!(g in e))return!1}else{var E=new He;if(i)var A=i(S,I,g,e,t,E);if(!(A===r?xn(I,S,Fe|Mt,i,E):A))return!1}}return!0}function oa(e){if(!te(e)||zf(e))return!1;var t=ft(e)?cc:el;return t.test(Ot(e))}function df(e){return re(e)&&ve(e)==cn}function pf(e){return re(e)&&he(e)==Ge}function hf(e){return re(e)&&Sr(e.length)&&!!Q[ve(e)]}function ua(e){return typeof e=="function"?e:e==null?xe:typeof e=="object"?U(e)?fa(e[0],e[1]):ca(e):$o(e)}function li(e){if(!bn(e))return mc(e);var t=[];for(var n in K(e))j.call(e,n)&&n!="constructor"&&t.push(n);return t}function gf(e){if(!te(e))return Zf(e);var t=bn(e),n=[];for(var i in e)i=="constructor"&&(t||!j.call(e,i))||n.push(i);return n}function ci(e,t){return e<t}function la(e,t){var n=-1,i=Se(e)?v(e.length):[];return St(e,function(a,l,d){i[++n]=t(a,l,d)}),i}function ca(e){var t=Ai(e);return t.length==1&&t[0][2]?qa(t[0][0],t[0][1]):function(n){return n===e||ui(n,e,t)}}function fa(e,t){return Ci(e)&&Ga(t)?qa(je(e),t):function(n){var i=Mi(n,e);return i===r&&i===t?Wi(n,e):xn(t,i,Fe|Mt)}}function sr(e,t,n,i,a){e!==t&&ii(t,function(l,d){if(a||(a=new He),te(l))mf(e,t,d,n,sr,i,a);else{var p=i?i(Ri(e,d),l,d+"",e,t,a):r;p===r&&(p=l),ni(e,d,p)}},Ie)}function mf(e,t,n,i,a,l,d){var p=Ri(e,n),g=Ri(t,n),S=d.get(g);if(S){ni(e,n,S);return}var I=l?l(p,g,n+"",e,t,d):r,E=I===r;if(E){var A=U(g),R=!A&&At(g),N=!A&&!R&&Qt(g);I=g,A||R||N?U(p)?I=p:ie(p)?I=we(p):R?(E=!1,I=xa(g,!0)):N?(E=!1,I=Ea(g,!0)):I=[]:Tn(g)||Ut(g)?(I=p,Ut(p)?I=So(p):(!te(p)||ft(p))&&(I=Va(g))):E=!1}E&&(d.set(g,I),a(I,g,i,l,d),d.delete(g)),ni(e,n,I)}function da(e,t){var n=e.length;if(n)return t+=t<0?n:0,ct(t,n)?e[t]:r}function pa(e,t,n){t.length?t=ee(t,function(l){return U(l)?function(d){return Lt(d,l.length===1?l[0]:l)}:l}):t=[xe];var i=-1;t=ee(t,be(L()));var a=la(e,function(l,d,p){var g=ee(t,function(S){return S(l)});return{criteria:g,index:++i,value:l}});return Vl(a,function(l,d){return Rf(l,d,n)})}function vf(e,t){return ha(e,t,function(n,i){return Wi(e,i)})}function ha(e,t,n){for(var i=-1,a=t.length,l={};++i<a;){var d=t[i],p=Lt(e,d);n(p,d)&&En(l,xt(d,e),p)}return l}function yf(e){return function(t){return Lt(t,e)}}function fi(e,t,n,i){var a=i?kl:Vt,l=-1,d=t.length,p=e;for(e===t&&(t=we(t)),n&&(p=ee(e,be(n)));++l<d;)for(var g=0,S=t[l],I=n?n(S):S;(g=a(p,I,g,i))>-1;)p!==e&&Yn.call(p,g,1),Yn.call(e,g,1);return e}function ga(e,t){for(var n=e?t.length:0,i=n-1;n--;){var a=t[n];if(n==i||a!==l){var l=a;ct(a)?Yn.call(e,a,1):gi(e,a)}}return e}function di(e,t){return e+Xn(Ys()*(t-e+1))}function _f(e,t,n,i){for(var a=-1,l=oe(Zn((t-e)/(n||1)),0),d=v(l);l--;)d[i?l:++a]=e,e+=n;return d}function pi(e,t){var n="";if(!e||t<1||t>mt)return n;do t%2&&(n+=e),t=Xn(t/2),t&&(e+=e);while(t);return n}function W(e,t){return Pi(Ha(e,t,xe),e+"")}function wf(e){return Xs(en(e))}function Sf(e,t){var n=en(e);return gr(n,$t(t,0,n.length))}function En(e,t,n,i){if(!te(e))return e;t=xt(t,e);for(var a=-1,l=t.length,d=l-1,p=e;p!=null&&++a<l;){var g=je(t[a]),S=n;if(g==="__proto__"||g==="constructor"||g==="prototype")return e;if(a!=d){var I=p[g];S=i?i(I,g,p):r,S===r&&(S=te(I)?I:ct(t[a+1])?[]:{})}wn(p,g,S),p=p[g]}return e}var ma=Qn?function(e,t){return Qn.set(e,t),e}:xe,If=Jn?function(e,t){return Jn(e,"toString",{configurable:!0,enumerable:!1,value:ki(t),writable:!0})}:xe;function xf(e){return gr(en(e))}function Ue(e,t,n){var i=-1,a=e.length;t<0&&(t=-t>a?0:a+t),n=n>a?a:n,n<0&&(n+=a),a=t>n?0:n-t>>>0,t>>>=0;for(var l=v(a);++i<a;)l[i]=e[i+t];return l}function Ef(e,t){var n;return St(e,function(i,a,l){return n=t(i,a,l),!n}),!!n}function ar(e,t,n){var i=0,a=e==null?i:e.length;if(typeof t=="number"&&t===t&&a<=bu){for(;i<a;){var l=i+a>>>1,d=e[l];d!==null&&!Te(d)&&(n?d<=t:d<t)?i=l+1:a=l}return a}return hi(e,t,xe,n)}function hi(e,t,n,i){var a=0,l=e==null?0:e.length;if(l===0)return 0;t=n(t);for(var d=t!==t,p=t===null,g=Te(t),S=t===r;a<l;){var I=Xn((a+l)/2),E=n(e[I]),A=E!==r,R=E===null,N=E===E,M=Te(E);if(d)var F=i||N;else S?F=N&&(i||A):p?F=N&&A&&(i||!R):g?F=N&&A&&!R&&(i||!M):R||M?F=!1:F=i?E<=t:E<t;F?a=I+1:l=I}return pe(l,Au)}function va(e,t){for(var n=-1,i=e.length,a=0,l=[];++n<i;){var d=e[n],p=t?t(d):d;if(!n||!ze(p,g)){var g=p;l[a++]=d===0?0:d}}return l}function ya(e){return typeof e=="number"?e:Te(e)?Fn:+e}function Ce(e){if(typeof e=="string")return e;if(U(e))return ee(e,Ce)+"";if(Te(e))return Js?Js.call(e):"";var t=e+"";return t=="0"&&1/e==-Ct?"-0":t}function It(e,t,n){var i=-1,a=Wn,l=e.length,d=!0,p=[],g=p;if(n)d=!1,a=Gr;else if(l>=f){var S=t?null:Of(e);if(S)return kn(S);d=!1,a=hn,g=new Ft}else g=t?[]:p;e:for(;++i<l;){var I=e[i],E=t?t(I):I;if(I=n||I!==0?I:0,d&&E===E){for(var A=g.length;A--;)if(g[A]===E)continue e;t&&g.push(E),p.push(I)}else a(g,E,n)||(g!==p&&g.push(E),p.push(I))}return p}function gi(e,t){t=xt(t,e);var n=-1,i=t.length;if(!i)return!0;for(;++n<i;){var a=je(t[n]);if(a==="__proto__"&&!j.call(e,"__proto__")||(a==="constructor"||a==="prototype")&&n<i-1)return!1}var l=ja(e,t);return l==null||delete l[je(De(t))]}function _a(e,t,n,i){return En(e,t,n(Lt(e,t)),i)}function or(e,t,n,i){for(var a=e.length,l=i?a:-1;(i?l--:++l<a)&&t(e[l],l,e););return n?Ue(e,i?0:l,i?l+1:a):Ue(e,i?l+1:0,i?a:l)}function wa(e,t){var n=e;return n instanceof k&&(n=n.value()),qr(t,function(i,a){return a.func.apply(a.thisArg,yt([i],a.args))},n)}function mi(e,t,n){var i=e.length;if(i<2)return i?It(e[0]):[];for(var a=-1,l=v(i);++a<i;)for(var d=e[a],p=-1;++p<i;)p!=a&&(l[a]=Sn(l[a]||d,e[p],t,n));return It(de(l,1),t,n)}function Sa(e,t,n){for(var i=-1,a=e.length,l=t.length,d={};++i<a;){var p=i<l?t[i]:r;n(d,e[i],p)}return d}function vi(e){return ie(e)?e:[]}function yi(e){return typeof e=="function"?e:xe}function xt(e,t){return U(e)?e:Ci(e,t)?[e]:Ja(z(e))}var Af=W;function Et(e,t,n){var i=e.length;return n=n===r?i:n,!t&&n>=i?e:Ue(e,t,n)}var Ia=fc||function(e){return fe.clearTimeout(e)};function xa(e,t){if(t)return e.slice();var n=e.length,i=qs?qs(n):new e.constructor(n);return e.copy(i),i}function _i(e){var t=new e.constructor(e.byteLength);return new zn(t).set(new zn(e)),t}function bf(e,t){var n=t?_i(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function Cf(e){var t=new e.constructor(e.source,as.exec(e));return t.lastIndex=e.lastIndex,t}function Tf(e){return _n?K(_n.call(e)):{}}function Ea(e,t){var n=t?_i(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Aa(e,t){if(e!==t){var n=e!==r,i=e===null,a=e===e,l=Te(e),d=t!==r,p=t===null,g=t===t,S=Te(t);if(!p&&!S&&!l&&e>t||l&&d&&g&&!p&&!S||i&&d&&g||!n&&g||!a)return 1;if(!i&&!l&&!S&&e<t||S&&n&&a&&!i&&!l||p&&n&&a||!d&&a||!g)return-1}return 0}function Rf(e,t,n){for(var i=-1,a=e.criteria,l=t.criteria,d=a.length,p=n.length;++i<d;){var g=Aa(a[i],l[i]);if(g){if(i>=p)return g;var S=n[i];return g*(S=="desc"?-1:1)}}return e.index-t.index}function ba(e,t,n,i){for(var a=-1,l=e.length,d=n.length,p=-1,g=t.length,S=oe(l-d,0),I=v(g+S),E=!i;++p<g;)I[p]=t[p];for(;++a<d;)(E||a<l)&&(I[n[a]]=e[a]);for(;S--;)I[p++]=e[a++];return I}function Ca(e,t,n,i){for(var a=-1,l=e.length,d=-1,p=n.length,g=-1,S=t.length,I=oe(l-p,0),E=v(I+S),A=!i;++a<I;)E[a]=e[a];for(var R=a;++g<S;)E[R+g]=t[g];for(;++d<p;)(A||a<l)&&(E[R+n[d]]=e[a++]);return E}function we(e,t){var n=-1,i=e.length;for(t||(t=v(i));++n<i;)t[n]=e[n];return t}function et(e,t,n,i){var a=!n;n||(n={});for(var l=-1,d=t.length;++l<d;){var p=t[l],g=i?i(n[p],e[p],p,n,e):r;g===r&&(g=e[p]),a?Xe(n,p,g):wn(n,p,g)}return n}function Pf(e,t){return et(e,bi(e),t)}function Ff(e,t){return et(e,Ba(e),t)}function ur(e,t){return function(n,i){var a=U(n)?Ol:Xc,l=t?t():{};return a(n,e,L(i,2),l)}}function Jt(e){return W(function(t,n){var i=-1,a=n.length,l=a>1?n[a-1]:r,d=a>2?n[2]:r;for(l=e.length>3&&typeof l=="function"?(a--,l):r,d&&ye(n[0],n[1],d)&&(l=a<3?r:l,a=1),t=K(t);++i<a;){var p=n[i];p&&e(t,p,i,l)}return t})}function Ta(e,t){return function(n,i){if(n==null)return n;if(!Se(n))return e(n,i);for(var a=n.length,l=t?a:-1,d=K(n);(t?l--:++l<a)&&i(d[l],l,d)!==!1;);return n}}function Ra(e){return function(t,n,i){for(var a=-1,l=K(t),d=i(t),p=d.length;p--;){var g=d[e?p:++a];if(n(l[g],g,l)===!1)break}return t}}function $f(e,t,n){var i=t&me,a=An(e);function l(){var d=this&&this!==fe&&this instanceof l?a:e;return d.apply(i?n:this,arguments)}return l}function Pa(e){return function(t){t=z(t);var n=Gt(t)?qe(t):r,i=n?n[0]:t.charAt(0),a=n?Et(n,1).join(""):t.slice(1);return i[e]()+a}}function Zt(e){return function(t){return qr(Po(Ro(t).replace(Sl,"")),e,"")}}function An(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=Yt(e.prototype),i=e.apply(n,t);return te(i)?i:n}}function Lf(e,t,n){var i=An(e);function a(){for(var l=arguments.length,d=v(l),p=l,g=Xt(a);p--;)d[p]=arguments[p];var S=l<3&&d[0]!==g&&d[l-1]!==g?[]:_t(d,g);if(l-=S.length,l<n)return Oa(e,t,lr,a.placeholder,r,d,S,r,r,n-l);var I=this&&this!==fe&&this instanceof a?i:e;return Ee(I,this,d)}return a}function Fa(e){return function(t,n,i){var a=K(t);if(!Se(t)){var l=L(n,3);t=ue(t),n=function(p){return l(a[p],p,a)}}var d=e(t,n,i);return d>-1?a[l?t[d]:d]:r}}function $a(e){return lt(function(t){var n=t.length,i=n,a=Ne.prototype.thru;for(e&&t.reverse();i--;){var l=t[i];if(typeof l!="function")throw new Le(x);if(a&&!d&&pr(l)=="wrapper")var d=new Ne([],!0)}for(i=d?i:n;++i<n;){l=t[i];var p=pr(l),g=p=="wrapper"?Ei(l):r;g&&Ti(g[0])&&g[1]==(it|ke|ce|an)&&!g[4].length&&g[9]==1?d=d[pr(g[0])].apply(d,g[3]):d=l.length==1&&Ti(l)?d[p]():d.thru(l)}return function(){var S=arguments,I=S[0];if(d&&S.length==1&&U(I))return d.plant(I).value();for(var E=0,A=n?t[E].apply(this,S):I;++E<n;)A=t[E].call(this,A);return A}})}function lr(e,t,n,i,a,l,d,p,g,S){var I=t&it,E=t&me,A=t&gt,R=t&(ke|rt),N=t&Er,M=A?r:An(e);function F(){for(var B=arguments.length,V=v(B),Re=B;Re--;)V[Re]=arguments[Re];if(R)var _e=Xt(F),Pe=ql(V,_e);if(i&&(V=ba(V,i,a,R)),l&&(V=Ca(V,l,d,R)),B-=Pe,R&&B<S){var se=_t(V,_e);return Oa(e,t,lr,F.placeholder,n,V,se,p,g,S-B)}var Ke=E?n:this,pt=A?Ke[e]:e;return B=V.length,p?V=Qf(V,p):N&&B>1&&V.reverse(),I&&g<B&&(V.length=g),this&&this!==fe&&this instanceof F&&(pt=M||An(pt)),pt.apply(Ke,V)}return F}function La(e,t){return function(n,i){return of(n,e,t(i),{})}}function cr(e,t){return function(n,i){var a;if(n===r&&i===r)return t;if(n!==r&&(a=n),i!==r){if(a===r)return i;typeof n=="string"||typeof i=="string"?(n=Ce(n),i=Ce(i)):(n=ya(n),i=ya(i)),a=e(n,i)}return a}}function wi(e){return lt(function(t){return t=ee(t,be(L())),W(function(n){var i=this;return e(t,function(a){return Ee(a,i,n)})})})}function fr(e,t){t=t===r?" ":Ce(t);var n=t.length;if(n<2)return n?pi(t,e):t;var i=pi(t,Zn(e/qt(t)));return Gt(t)?Et(qe(i),0,e).join(""):i.slice(0,e)}function Nf(e,t,n,i){var a=t&me,l=An(e);function d(){for(var p=-1,g=arguments.length,S=-1,I=i.length,E=v(I+g),A=this&&this!==fe&&this instanceof d?l:e;++S<I;)E[S]=i[S];for(;g--;)E[S++]=arguments[++p];return Ee(A,a?n:this,E)}return d}function Na(e){return function(t,n,i){return i&&typeof i!="number"&&ye(t,n,i)&&(n=i=r),t=dt(t),n===r?(n=t,t=0):n=dt(n),i=i===r?t<n?1:-1:dt(i),_f(t,n,i,e)}}function dr(e){return function(t,n){return typeof t=="string"&&typeof n=="string"||(t=Me(t),n=Me(n)),e(t,n)}}function Oa(e,t,n,i,a,l,d,p,g,S){var I=t&ke,E=I?d:r,A=I?r:d,R=I?l:r,N=I?r:l;t|=I?ce:sn,t&=~(I?sn:ce),t&rn||(t&=-4);var M=[e,t,a,R,E,N,A,p,g,S],F=n.apply(r,M);return Ti(e)&&za(F,M),F.placeholder=i,Ka(F,e,t)}function Si(e){var t=ae[e];return function(n,i){if(n=Me(n),i=i==null?0:pe(D(i),292),i&&Ks(n)){var a=(z(n)+"e").split("e"),l=t(a[0]+"e"+(+a[1]+i));return a=(z(l)+"e").split("e"),+(a[0]+"e"+(+a[1]-i))}return t(n)}}var Of=zt&&1/kn(new zt([,-0]))[1]==Ct?function(e){return new zt(e)}:qi;function Ua(e){return function(t){var n=he(t);return n==Ve?Zr(t):n==Ge?Zl(t):Gl(t,e(t))}}function ut(e,t,n,i,a,l,d,p){var g=t&gt;if(!g&&typeof e!="function")throw new Le(x);var S=i?i.length:0;if(S||(t&=-97,i=a=r),d=d===r?d:oe(D(d),0),p=p===r?p:D(p),S-=a?a.length:0,t&sn){var I=i,E=a;i=a=r}var A=g?r:Ei(e),R=[e,t,n,i,a,I,E,l,d,p];if(A&&Jf(R,A),e=R[0],t=R[1],n=R[2],i=R[3],a=R[4],p=R[9]=R[9]===r?g?0:e.length:oe(R[9]-S,0),!p&&t&(ke|rt)&&(t&=-25),!t||t==me)var N=$f(e,t,n);else t==ke||t==rt?N=Lf(e,t,p):(t==ce||t==(me|ce))&&!a.length?N=Nf(e,t,n,i):N=lr.apply(r,R);var M=A?ma:za;return Ka(M(N,R),e,t)}function Da(e,t,n,i){return e===r||ze(e,jt[n])&&!j.call(i,n)?t:e}function Ma(e,t,n,i,a,l){return te(e)&&te(t)&&(l.set(t,e),sr(e,t,r,Ma,l),l.delete(t)),e}function Uf(e){return Tn(e)?r:e}function Wa(e,t,n,i,a,l){var d=n&Fe,p=e.length,g=t.length;if(p!=g&&!(d&&g>p))return!1;var S=l.get(e),I=l.get(t);if(S&&I)return S==t&&I==e;var E=-1,A=!0,R=n&Mt?new Ft:r;for(l.set(e,t),l.set(t,e);++E<p;){var N=e[E],M=t[E];if(i)var F=d?i(M,N,E,t,e,l):i(N,M,E,e,t,l);if(F!==r){if(F)continue;A=!1;break}if(R){if(!Hr(t,function(B,V){if(!hn(R,V)&&(N===B||a(N,B,n,i,l)))return R.push(V)})){A=!1;break}}else if(!(N===M||a(N,M,n,i,l))){A=!1;break}}return l.delete(e),l.delete(t),A}function Df(e,t,n,i,a,l,d){switch(n){case Bt:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case pn:return!(e.byteLength!=t.byteLength||!l(new zn(e),new zn(t)));case on:case un:case ln:return ze(+e,+t);case Ln:return e.name==t.name&&e.message==t.message;case cn:case fn:return e==t+"";case Ve:var p=Zr;case Ge:var g=i&Fe;if(p||(p=kn),e.size!=t.size&&!g)return!1;var S=d.get(e);if(S)return S==t;i|=Mt,d.set(e,t);var I=Wa(p(e),p(t),i,a,l,d);return d.delete(e),I;case On:if(_n)return _n.call(e)==_n.call(t)}return!1}function Mf(e,t,n,i,a,l){var d=n&Fe,p=Ii(e),g=p.length,S=Ii(t),I=S.length;if(g!=I&&!d)return!1;for(var E=g;E--;){var A=p[E];if(!(d?A in t:j.call(t,A)))return!1}var R=l.get(e),N=l.get(t);if(R&&N)return R==t&&N==e;var M=!0;l.set(e,t),l.set(t,e);for(var F=d;++E<g;){A=p[E];var B=e[A],V=t[A];if(i)var Re=d?i(V,B,A,t,e,l):i(B,V,A,e,t,l);if(!(Re===r?B===V||a(B,V,n,i,l):Re)){M=!1;break}F||(F=A=="constructor")}if(M&&!F){var _e=e.constructor,Pe=t.constructor;_e!=Pe&&"constructor"in e&&"constructor"in t&&!(typeof _e=="function"&&_e instanceof _e&&typeof Pe=="function"&&Pe instanceof Pe)&&(M=!1)}return l.delete(e),l.delete(t),M}function lt(e){return Pi(Ha(e,r,eo),e+"")}function Ii(e){return sa(e,ue,bi)}function xi(e){return sa(e,Ie,Ba)}var Ei=Qn?function(e){return Qn.get(e)}:qi;function pr(e){for(var t=e.name+"",n=Kt[t],i=j.call(Kt,t)?n.length:0;i--;){var a=n[i],l=a.func;if(l==null||l==e)return a.name}return t}function Xt(e){var t=j.call(o,"placeholder")?o:e;return t.placeholder}function L(){var e=o.iteratee||Vi;return e=e===Vi?ua:e,arguments.length?e(arguments[0],arguments[1]):e}function hr(e,t){var n=e.__data__;return jf(t)?n[typeof t=="string"?"string":"hash"]:n.map}function Ai(e){for(var t=ue(e),n=t.length;n--;){var i=t[n],a=e[i];t[n]=[i,a,Ga(a)]}return t}function Nt(e,t){var n=Kl(e,t);return oa(n)?n:r}function Wf(e){var t=j.call(e,Rt),n=e[Rt];try{e[Rt]=r;var i=!0}catch{}var a=Hn.call(e);return i&&(t?e[Rt]=n:delete e[Rt]),a}var bi=Qr?function(e){return e==null?[]:(e=K(e),vt(Qr(e),function(t){return js.call(e,t)}))}:Hi,Ba=Qr?function(e){for(var t=[];e;)yt(t,bi(e)),e=Kn(e);return t}:Hi,he=ve;(ei&&he(new ei(new ArrayBuffer(1)))!=Bt||mn&&he(new mn)!=Ve||ti&&he(ti.resolve())!=ts||zt&&he(new zt)!=Ge||vn&&he(new vn)!=dn)&&(he=function(e){var t=ve(e),n=t==st?e.constructor:r,i=n?Ot(n):"";if(i)switch(i){case wc:return Bt;case Sc:return Ve;case Ic:return ts;case xc:return Ge;case Ec:return dn}return t});function Bf(e,t,n){for(var i=-1,a=n.length;++i<a;){var l=n[i],d=l.size;switch(l.type){case"drop":e+=d;break;case"dropRight":t-=d;break;case"take":t=pe(t,e+d);break;case"takeRight":e=oe(e,t-d);break}}return{start:e,end:t}}function kf(e){var t=e.match(zu);return t?t[1].split(Ku):[]}function ka(e,t,n){t=xt(t,e);for(var i=-1,a=t.length,l=!1;++i<a;){var d=je(t[i]);if(!(l=e!=null&&n(e,d)))break;e=e[d]}return l||++i!=a?l:(a=e==null?0:e.length,!!a&&Sr(a)&&ct(d,a)&&(U(e)||Ut(e)))}function Vf(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]=="string"&&j.call(e,"index")&&(n.index=e.index,n.input=e.input),n}function Va(e){return typeof e.constructor=="function"&&!bn(e)?Yt(Kn(e)):{}}function Gf(e,t,n){var i=e.constructor;switch(t){case pn:return _i(e);case on:case un:return new i(+e);case Bt:return bf(e,n);case Ar:case br:case Cr:case Tr:case Rr:case Pr:case Fr:case $r:case Lr:return Ea(e,n);case Ve:return new i;case ln:case fn:return new i(e);case cn:return Cf(e);case Ge:return new i;case On:return Tf(e)}}function qf(e,t){var n=t.length;if(!n)return e;var i=n-1;return t[i]=(n>1?"& ":"")+t[i],t=t.join(n>2?", ":" "),e.replace(ju,`{
10
10
  /* [wrapped with `+t+`] */
11
- `)}function kf(e){return U(e)||Dt(e)||!!(Hs&&e&&e[Hs])}function dt(e,t){var n=typeof e;return t=t??mt,!!t&&(n=="number"||n!="symbol"&&Xu.test(e))&&e>-1&&e%1==0&&e<t}function me(e,t,n){if(!te(n))return!1;var i=typeof t;return(i=="number"?_e(n)&&dt(t,n.length):i=="string"&&t in n)?Ke(n[t],e):!1}function Ci(e,t){if(U(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Te(e)?!0:Du.test(e)||!Uu.test(e)||t!=null&&e in j(t)}function Vf(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Ti(e){var t=dr(e),n=o[t];if(typeof n!="function"||!(t in k.prototype))return!1;if(e===n)return!0;var i=Ei(n);return!!i&&e===i[0]}function Gf(e){return!!ks&&ks in e}var qf=Vn?pt:Hi;function En(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||zt;return e===n}function ka(e){return e===e&&!te(e)}function Va(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==r||e in j(n))}}function Hf(e){var t=yr(e,function(i){return n.size===$&&n.clear(),i}),n=t.cache;return t}function zf(e,t){var n=e[1],i=t[1],a=n|i,u=a<(xe|Ze|st),d=i==st&&n==Le||i==st&&n==rn&&e[7].length<=t[8]||i==(st|rn)&&t[7].length<=t[8]&&n==Le;if(!(u||d))return e;i&xe&&(e[2]=t[2],a|=n&xe?0:Rn);var p=t[3];if(p){var g=e[3];e[3]=g?Ea(g,p,t[4]):p,e[4]=g?_t(e[3],G):t[4]}return p=t[5],p&&(g=e[5],e[5]=g?Aa(g,p,t[6]):p,e[6]=g?_t(e[5],G):t[6]),p=t[7],p&&(e[7]=p),i&st&&(e[8]=e[8]==null?t[8]:de(e[8],t[8])),e[9]==null&&(e[9]=t[9]),e[0]=t[0],e[1]=a,e}function Kf(e){var t=[];if(e!=null)for(var n in j(e))t.push(n);return t}function jf(e){return qn.call(e)}function Ga(e,t,n){return t=oe(t===r?e.length-1:t,0),function(){for(var i=arguments,a=-1,u=oe(i.length-t,0),d=v(u);++a<u;)d[a]=i[t+a];a=-1;for(var p=v(t+1);++a<t;)p[a]=i[a];return p[t]=n(d),Ae(e,this,p)}}function qa(e,t){return t.length<2?e:Ot(e,Me(t,0,-1))}function Yf(e,t){for(var n=e.length,i=de(t.length,n),a=ye(e);i--;){var u=t[i];e[i]=dt(u,n)?a[u]:r}return e}function Ri(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}var Ha=Ka(ha),An=lc||function(e,t){return ce.setTimeout(e,t)},Pi=Ka(yf);function za(e,t,n){var i=t+"";return Pi(e,Bf(i,Jf(Df(i),n)))}function Ka(e){var t=0,n=0;return function(){var i=pc(),a=mu-(i-n);if(n=i,a>0){if(++t>=gu)return arguments[0]}else t=0;return e.apply(r,arguments)}}function hr(e,t){var n=-1,i=e.length,a=i-1;for(t=t===r?i:t;++n<t;){var u=di(n,a),d=e[u];e[u]=e[n],e[n]=d}return e.length=t,e}var ja=Hf(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Mu,function(n,i,a,u){t.push(a?u.replace(zu,"$1"):i||n)}),t});function tt(e){if(typeof e=="string"||Te(e))return e;var t=e+"";return t=="0"&&1/e==-Tt?"-0":t}function Ut(e){if(e!=null){try{return Gn.call(e)}catch{}try{return e+""}catch{}}return""}function Jf(e,t){return Oe(xu,function(n){var i="_."+n[0];t&n[1]&&!Mn(e,i)&&e.push(i)}),e.sort()}function Ya(e){if(e instanceof k)return e.clone();var t=new Ue(e.__wrapped__,e.__chain__);return t.__actions__=ye(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}function Zf(e,t,n){(n?me(e,t,n):t===r)?t=1:t=oe(D(t),0);var i=e==null?0:e.length;if(!i||t<1)return[];for(var a=0,u=0,d=v(Jn(i/t));a<i;)d[u++]=Me(e,a,a+=t);return d}function Xf(e){for(var t=-1,n=e==null?0:e.length,i=0,a=[];++t<n;){var u=e[t];u&&(a[i++]=u)}return a}function Qf(){var e=arguments.length;if(!e)return[];for(var t=v(e-1),n=arguments[0],i=e;i--;)t[i-1]=arguments[i];return yt(U(n)?ye(n):[n],fe(t,1))}var ed=W(function(e,t){return re(e)?_n(e,fe(t,1,re,!0)):[]}),td=W(function(e,t){var n=We(t);return re(n)&&(n=r),re(e)?_n(e,fe(t,1,re,!0),F(n,2)):[]}),nd=W(function(e,t){var n=We(t);return re(n)&&(n=r),re(e)?_n(e,fe(t,1,re,!0),r,n):[]});function rd(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:D(t),Me(e,t<0?0:t,i)):[]}function id(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:D(t),t=i-t,Me(e,0,t<0?0:t)):[]}function sd(e,t){return e&&e.length?ar(e,F(t,3),!0,!0):[]}function ad(e,t){return e&&e.length?ar(e,F(t,3),!0):[]}function od(e,t,n,i){var a=e==null?0:e.length;return a?(n&&typeof n!="number"&&me(e,t,n)&&(n=0,i=a),Xc(e,t,n,i)):[]}function Ja(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=n==null?0:D(n);return a<0&&(a=oe(i+a,0)),Wn(e,F(t,3),a)}function Za(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=i-1;return n!==r&&(a=D(n),a=n<0?oe(i+a,0):de(a,i-1)),Wn(e,F(t,3),a,!0)}function Xa(e){var t=e==null?0:e.length;return t?fe(e,1):[]}function ud(e){var t=e==null?0:e.length;return t?fe(e,Tt):[]}function ld(e,t){var n=e==null?0:e.length;return n?(t=t===r?1:D(t),fe(e,t)):[]}function cd(e){for(var t=-1,n=e==null?0:e.length,i={};++t<n;){var a=e[t];i[a[0]]=a[1]}return i}function Qa(e){return e&&e.length?e[0]:r}function fd(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=n==null?0:D(n);return a<0&&(a=oe(i+a,0)),Vt(e,t,a)}function dd(e){var t=e==null?0:e.length;return t?Me(e,0,-1):[]}var pd=W(function(e){var t=ee(e,vi);return t.length&&t[0]===e[0]?oi(t):[]}),hd=W(function(e){var t=We(e),n=ee(e,vi);return t===We(n)?t=r:n.pop(),n.length&&n[0]===e[0]?oi(n,F(t,2)):[]}),gd=W(function(e){var t=We(e),n=ee(e,vi);return t=typeof t=="function"?t:r,t&&n.pop(),n.length&&n[0]===e[0]?oi(n,r,t):[]});function md(e,t){return e==null?"":fc.call(e,t)}function We(e){var t=e==null?0:e.length;return t?e[t-1]:r}function vd(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=i;return n!==r&&(a=D(n),a=a<0?oe(i+a,0):de(a,i-1)),t===t?Yl(e,t,a):Wn(e,Ns,a,!0)}function yd(e,t){return e&&e.length?ca(e,D(t)):r}var _d=W(eo);function eo(e,t){return e&&e.length&&t&&t.length?fi(e,t):e}function wd(e,t,n){return e&&e.length&&t&&t.length?fi(e,t,F(n,2)):e}function Sd(e,t,n){return e&&e.length&&t&&t.length?fi(e,t,r,n):e}var xd=ft(function(e,t){var n=e==null?0:e.length,i=ri(e,t);return pa(e,ee(t,function(a){return dt(a,n)?+a:a}).sort(Ia)),i});function Id(e,t){var n=[];if(!(e&&e.length))return n;var i=-1,a=[],u=e.length;for(t=F(t,3);++i<u;){var d=e[i];t(d,i,e)&&(n.push(d),a.push(i))}return pa(e,a),n}function Fi(e){return e==null?e:gc.call(e)}function Ed(e,t,n){var i=e==null?0:e.length;return i?(n&&typeof n!="number"&&me(e,t,n)?(t=0,n=i):(t=t==null?0:D(t),n=n===r?i:D(n)),Me(e,t,n)):[]}function Ad(e,t){return sr(e,t)}function bd(e,t,n){return hi(e,t,F(n,2))}function Cd(e,t){var n=e==null?0:e.length;if(n){var i=sr(e,t);if(i<n&&Ke(e[i],t))return i}return-1}function Td(e,t){return sr(e,t,!0)}function Rd(e,t,n){return hi(e,t,F(n,2),!0)}function Pd(e,t){var n=e==null?0:e.length;if(n){var i=sr(e,t,!0)-1;if(Ke(e[i],t))return i}return-1}function Fd(e){return e&&e.length?ga(e):[]}function Ld(e,t){return e&&e.length?ga(e,F(t,2)):[]}function Nd(e){var t=e==null?0:e.length;return t?Me(e,1,t):[]}function Od(e,t,n){return e&&e.length?(t=n||t===r?1:D(t),Me(e,0,t<0?0:t)):[]}function $d(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:D(t),t=i-t,Me(e,t<0?0:t,i)):[]}function Ud(e,t){return e&&e.length?ar(e,F(t,3),!1,!0):[]}function Dd(e,t){return e&&e.length?ar(e,F(t,3)):[]}var Md=W(function(e){return xt(fe(e,1,re,!0))}),Wd=W(function(e){var t=We(e);return re(t)&&(t=r),xt(fe(e,1,re,!0),F(t,2))}),Bd=W(function(e){var t=We(e);return t=typeof t=="function"?t:r,xt(fe(e,1,re,!0),r,t)});function kd(e){return e&&e.length?xt(e):[]}function Vd(e,t){return e&&e.length?xt(e,F(t,2)):[]}function Gd(e,t){return t=typeof t=="function"?t:r,e&&e.length?xt(e,r,t):[]}function Li(e){if(!(e&&e.length))return[];var t=0;return e=vt(e,function(n){if(re(n))return t=oe(n.length,t),!0}),Yr(t,function(n){return ee(e,zr(n))})}function to(e,t){if(!(e&&e.length))return[];var n=Li(e);return t==null?n:ee(n,function(i){return Ae(t,r,i)})}var qd=W(function(e,t){return re(e)?_n(e,t):[]}),Hd=W(function(e){return mi(vt(e,re))}),zd=W(function(e){var t=We(e);return re(t)&&(t=r),mi(vt(e,re),F(t,2))}),Kd=W(function(e){var t=We(e);return t=typeof t=="function"?t:r,mi(vt(e,re),r,t)}),jd=W(Li);function Yd(e,t){return _a(e||[],t||[],yn)}function Jd(e,t){return _a(e||[],t||[],xn)}var Zd=W(function(e){var t=e.length,n=t>1?e[t-1]:r;return n=typeof n=="function"?(e.pop(),n):r,to(e,n)});function no(e){var t=o(e);return t.__chain__=!0,t}function Xd(e,t){return t(e),e}function gr(e,t){return t(e)}var Qd=ft(function(e){var t=e.length,n=t?e[0]:0,i=this.__wrapped__,a=function(u){return ri(u,e)};return t>1||this.__actions__.length||!(i instanceof k)||!dt(n)?this.thru(a):(i=i.slice(n,+n+(t?1:0)),i.__actions__.push({func:gr,args:[a],thisArg:r}),new Ue(i,this.__chain__).thru(function(u){return t&&!u.length&&u.push(r),u}))});function ep(){return no(this)}function tp(){return new Ue(this.value(),this.__chain__)}function np(){this.__values__===r&&(this.__values__=vo(this.value()));var e=this.__index__>=this.__values__.length,t=e?r:this.__values__[this.__index__++];return{done:e,value:t}}function rp(){return this}function ip(e){for(var t,n=this;n instanceof er;){var i=Ya(n);i.__index__=0,i.__values__=r,t?a.__wrapped__=i:t=i;var a=i;n=n.__wrapped__}return a.__wrapped__=e,t}function sp(){var e=this.__wrapped__;if(e instanceof k){var t=e;return this.__actions__.length&&(t=new k(this)),t=t.reverse(),t.__actions__.push({func:gr,args:[Fi],thisArg:r}),new Ue(t,this.__chain__)}return this.thru(Fi)}function ap(){return ya(this.__wrapped__,this.__actions__)}var op=or(function(e,t,n){K.call(e,n)?++e[n]:lt(e,n,1)});function up(e,t,n){var i=U(e)?Fs:Zc;return n&&me(e,t,n)&&(t=r),i(e,F(t,3))}function lp(e,t){var n=U(e)?vt:ta;return n(e,F(t,3))}var cp=Ra(Ja),fp=Ra(Za);function dp(e,t){return fe(mr(e,t),1)}function pp(e,t){return fe(mr(e,t),Tt)}function hp(e,t,n){return n=n===r?1:D(n),fe(mr(e,t),n)}function ro(e,t){var n=U(e)?Oe:St;return n(e,F(t,3))}function io(e,t){var n=U(e)?Ll:ea;return n(e,F(t,3))}var gp=or(function(e,t,n){K.call(e,n)?e[n].push(t):lt(e,n,[t])});function mp(e,t,n,i){e=_e(e)?e:en(e),n=n&&!i?D(n):0;var a=e.length;return n<0&&(n=oe(a+n,0)),Sr(e)?n<=a&&e.indexOf(t,n)>-1:!!a&&Vt(e,t,n)>-1}var vp=W(function(e,t,n){var i=-1,a=typeof t=="function",u=_e(e)?v(e.length):[];return St(e,function(d){u[++i]=a?Ae(t,d,n):wn(d,t,n)}),u}),yp=or(function(e,t,n){lt(e,n,t)});function mr(e,t){var n=U(e)?ee:oa;return n(e,F(t,3))}function _p(e,t,n,i){return e==null?[]:(U(t)||(t=t==null?[]:[t]),n=i?r:n,U(n)||(n=n==null?[]:[n]),fa(e,t,n))}var wp=or(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]});function Sp(e,t,n){var i=U(e)?qr:$s,a=arguments.length<3;return i(e,F(t,4),n,a,St)}function xp(e,t,n){var i=U(e)?Nl:$s,a=arguments.length<3;return i(e,F(t,4),n,a,ea)}function Ip(e,t){var n=U(e)?vt:ta;return n(e,_r(F(t,3)))}function Ep(e){var t=U(e)?Js:mf;return t(e)}function Ap(e,t,n){(n?me(e,t,n):t===r)?t=1:t=D(t);var i=U(e)?zc:vf;return i(e,t)}function bp(e){var t=U(e)?Kc:_f;return t(e)}function Cp(e){if(e==null)return 0;if(_e(e))return Sr(e)?qt(e):e.length;var t=pe(e);return t==Ge||t==qe?e.size:li(e).length}function Tp(e,t,n){var i=U(e)?Hr:wf;return n&&me(e,t,n)&&(t=r),i(e,F(t,3))}var Rp=W(function(e,t){if(e==null)return[];var n=t.length;return n>1&&me(e,t[0],t[1])?t=[]:n>2&&me(t[0],t[1],t[2])&&(t=[t[0]]),fa(e,fe(t,1),[])}),vr=uc||function(){return ce.Date.now()};function Pp(e,t){if(typeof t!="function")throw new $e(E);return e=D(e),function(){if(--e<1)return t.apply(this,arguments)}}function so(e,t,n){return t=n?r:t,t=e&&t==null?e.length:t,ct(e,st,r,r,r,r,t)}function ao(e,t){var n;if(typeof t!="function")throw new $e(E);return e=D(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=r),n}}var Ni=W(function(e,t,n){var i=xe;if(n.length){var a=_t(n,Xt(Ni));i|=Ie}return ct(e,i,t,n,a)}),oo=W(function(e,t,n){var i=xe|Ze;if(n.length){var a=_t(n,Xt(oo));i|=Ie}return ct(t,i,e,n,a)});function uo(e,t,n){t=n?r:t;var i=ct(e,Le,r,r,r,r,r,t);return i.placeholder=uo.placeholder,i}function lo(e,t,n){t=n?r:t;var i=ct(e,Ct,r,r,r,r,r,t);return i.placeholder=lo.placeholder,i}function co(e,t,n){var i,a,u,d,p,g,w=0,x=!1,I=!1,A=!0;if(typeof e!="function")throw new $e(E);t=Be(t)||0,te(n)&&(x=!!n.leading,I="maxWait"in n,u=I?oe(Be(n.maxWait)||0,t):u,A="trailing"in n?!!n.trailing:A);function R(ie){var je=i,gt=a;return i=a=r,w=ie,d=e.apply(gt,je),d}function L(ie){return w=ie,p=An(B,t),x?R(ie):d}function M(ie){var je=ie-g,gt=ie-w,Po=t-je;return I?de(Po,u-gt):Po}function N(ie){var je=ie-g,gt=ie-w;return g===r||je>=t||je<0||I&&gt>=u}function B(){var ie=vr();if(N(ie))return V(ie);p=An(B,M(ie))}function V(ie){return p=r,A&&i?R(ie):(i=a=r,d)}function Re(){p!==r&&wa(p),w=0,i=g=a=p=r}function ve(){return p===r?d:V(vr())}function Pe(){var ie=vr(),je=N(ie);if(i=arguments,a=this,g=ie,je){if(p===r)return L(g);if(I)return wa(p),p=An(B,t),R(g)}return p===r&&(p=An(B,t)),d}return Pe.cancel=Re,Pe.flush=ve,Pe}var Fp=W(function(e,t){return Qs(e,1,t)}),Lp=W(function(e,t,n){return Qs(e,Be(t)||0,n)});function Np(e){return ct(e,Er)}function yr(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new $e(E);var n=function(){var i=arguments,a=t?t.apply(this,i):i[0],u=n.cache;if(u.has(a))return u.get(a);var d=e.apply(this,i);return n.cache=u.set(a,d)||u,d};return n.cache=new(yr.Cache||ut),n}yr.Cache=ut;function _r(e){if(typeof e!="function")throw new $e(E);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 Op(e){return ao(2,e)}var $p=Sf(function(e,t){t=t.length==1&&U(t[0])?ee(t[0],be(F())):ee(fe(t,1),be(F()));var n=t.length;return W(function(i){for(var a=-1,u=de(i.length,n);++a<u;)i[a]=t[a].call(this,i[a]);return Ae(e,this,i)})}),Oi=W(function(e,t){var n=_t(t,Xt(Oi));return ct(e,Ie,r,t,n)}),fo=W(function(e,t){var n=_t(t,Xt(fo));return ct(e,Ee,r,t,n)}),Up=ft(function(e,t){return ct(e,rn,r,r,r,t)});function Dp(e,t){if(typeof e!="function")throw new $e(E);return t=t===r?t:D(t),W(e,t)}function Mp(e,t){if(typeof e!="function")throw new $e(E);return t=t==null?0:oe(D(t),0),W(function(n){var i=n[t],a=Et(n,0,t);return i&&yt(a,i),Ae(e,this,a)})}function Wp(e,t,n){var i=!0,a=!0;if(typeof e!="function")throw new $e(E);return te(n)&&(i="leading"in n?!!n.leading:i,a="trailing"in n?!!n.trailing:a),co(e,t,{leading:i,maxWait:t,trailing:a})}function Bp(e){return so(e,1)}function kp(e,t){return Oi(yi(t),e)}function Vp(){if(!arguments.length)return[];var e=arguments[0];return U(e)?e:[e]}function Gp(e){return De(e,Fe)}function qp(e,t){return t=typeof t=="function"?t:r,De(e,Fe,t)}function Hp(e){return De(e,Y|Fe)}function zp(e,t){return t=typeof t=="function"?t:r,De(e,Y|Fe,t)}function Kp(e,t){return t==null||Xs(e,t,ue(t))}function Ke(e,t){return e===t||e!==e&&t!==t}var jp=fr(ai),Yp=fr(function(e,t){return e>=t}),Dt=ia((function(){return arguments})())?ia:function(e){return ne(e)&&K.call(e,"callee")&&!qs.call(e,"callee")},U=v.isArray,Jp=As?be(As):rf;function _e(e){return e!=null&&wr(e.length)&&!pt(e)}function re(e){return ne(e)&&_e(e)}function Zp(e){return e===!0||e===!1||ne(e)&&ge(e)==sn}var At=cc||Hi,Xp=bs?be(bs):sf;function Qp(e){return ne(e)&&e.nodeType===1&&!bn(e)}function eh(e){if(e==null)return!0;if(_e(e)&&(U(e)||typeof e=="string"||typeof e.splice=="function"||At(e)||Qt(e)||Dt(e)))return!e.length;var t=pe(e);if(t==Ge||t==qe)return!e.size;if(En(e))return!li(e).length;for(var n in e)if(K.call(e,n))return!1;return!0}function th(e,t){return Sn(e,t)}function nh(e,t,n){n=typeof n=="function"?n:r;var i=n?n(e,t):r;return i===r?Sn(e,t,r,n):!!i}function $i(e){if(!ne(e))return!1;var t=ge(e);return t==Ln||t==Eu||typeof e.message=="string"&&typeof e.name=="string"&&!bn(e)}function rh(e){return typeof e=="number"&&zs(e)}function pt(e){if(!te(e))return!1;var t=ge(e);return t==Nn||t==Qi||t==Iu||t==bu}function po(e){return typeof e=="number"&&e==D(e)}function wr(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=mt}function te(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function ne(e){return e!=null&&typeof e=="object"}var ho=Cs?be(Cs):of;function ih(e,t){return e===t||ui(e,t,Ai(t))}function sh(e,t,n){return n=typeof n=="function"?n:r,ui(e,t,Ai(t),n)}function ah(e){return go(e)&&e!=+e}function oh(e){if(qf(e))throw new O(S);return sa(e)}function uh(e){return e===null}function lh(e){return e==null}function go(e){return typeof e=="number"||ne(e)&&ge(e)==on}function bn(e){if(!ne(e)||ge(e)!=at)return!1;var t=Kn(e);if(t===null)return!0;var n=K.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Gn.call(n)==ic}var Ui=Ts?be(Ts):uf;function ch(e){return po(e)&&e>=-mt&&e<=mt}var mo=Rs?be(Rs):lf;function Sr(e){return typeof e=="string"||!U(e)&&ne(e)&&ge(e)==ln}function Te(e){return typeof e=="symbol"||ne(e)&&ge(e)==On}var Qt=Ps?be(Ps):cf;function fh(e){return e===r}function dh(e){return ne(e)&&pe(e)==cn}function ph(e){return ne(e)&&ge(e)==Tu}var hh=fr(ci),gh=fr(function(e,t){return e<=t});function vo(e){if(!e)return[];if(_e(e))return Sr(e)?He(e):ye(e);if(pn&&e[pn])return zl(e[pn]());var t=pe(e),n=t==Ge?Zr:t==qe?Bn:en;return n(e)}function ht(e){if(!e)return e===0?e:0;if(e=Be(e),e===Tt||e===-Tt){var t=e<0?-1:1;return t*_u}return e===e?e:0}function D(e){var t=ht(e),n=t%1;return t===t?n?t-n:t:0}function yo(e){return e?Nt(D(e),0,Xe):0}function Be(e){if(typeof e=="number")return e;if(Te(e))return Pn;if(te(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=te(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Us(e);var n=Yu.test(e);return n||Zu.test(e)?Rl(e.slice(2),n?2:8):ju.test(e)?Pn:+e}function _o(e){return et(e,we(e))}function mh(e){return e?Nt(D(e),-mt,mt):e===0?e:0}function z(e){return e==null?"":Ce(e)}var vh=Jt(function(e,t){if(En(t)||_e(t)){et(t,ue(t),e);return}for(var n in t)K.call(t,n)&&yn(e,n,t[n])}),wo=Jt(function(e,t){et(t,we(t),e)}),xr=Jt(function(e,t,n,i){et(t,we(t),e,i)}),yh=Jt(function(e,t,n,i){et(t,ue(t),e,i)}),_h=ft(ri);function wh(e,t){var n=Yt(e);return t==null?n:Zs(n,t)}var Sh=W(function(e,t){e=j(e);var n=-1,i=t.length,a=i>2?t[2]:r;for(a&&me(t[0],t[1],a)&&(i=1);++n<i;)for(var u=t[n],d=we(u),p=-1,g=d.length;++p<g;){var w=d[p],x=e[w];(x===r||Ke(x,zt[w])&&!K.call(e,w))&&(e[w]=u[w])}return e}),xh=W(function(e){return e.push(r,Ua),Ae(So,r,e)});function Ih(e,t){return Ls(e,F(t,3),Qe)}function Eh(e,t){return Ls(e,F(t,3),si)}function Ah(e,t){return e==null?e:ii(e,F(t,3),we)}function bh(e,t){return e==null?e:na(e,F(t,3),we)}function Ch(e,t){return e&&Qe(e,F(t,3))}function Th(e,t){return e&&si(e,F(t,3))}function Rh(e){return e==null?[]:rr(e,ue(e))}function Ph(e){return e==null?[]:rr(e,we(e))}function Di(e,t,n){var i=e==null?r:Ot(e,t);return i===r?n:i}function Fh(e,t){return e!=null&&Wa(e,t,Qc)}function Mi(e,t){return e!=null&&Wa(e,t,ef)}var Lh=Fa(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=qn.call(t)),e[t]=n},Bi(Se)),Nh=Fa(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=qn.call(t)),K.call(e,t)?e[t].push(n):e[t]=[n]},F),Oh=W(wn);function ue(e){return _e(e)?Ys(e):li(e)}function we(e){return _e(e)?Ys(e,!0):ff(e)}function $h(e,t){var n={};return t=F(t,3),Qe(e,function(i,a,u){lt(n,t(i,a,u),i)}),n}function Uh(e,t){var n={};return t=F(t,3),Qe(e,function(i,a,u){lt(n,a,t(i,a,u))}),n}var Dh=Jt(function(e,t,n){ir(e,t,n)}),So=Jt(function(e,t,n,i){ir(e,t,n,i)}),Mh=ft(function(e,t){var n={};if(e==null)return n;var i=!1;t=ee(t,function(u){return u=It(u,e),i||(i=u.length>1),u}),et(e,Ii(e),n),i&&(n=De(n,Y|se|Fe,Lf));for(var a=t.length;a--;)gi(n,t[a]);return n});function Wh(e,t){return xo(e,_r(F(t)))}var Bh=ft(function(e,t){return e==null?{}:pf(e,t)});function xo(e,t){if(e==null)return{};var n=ee(Ii(e),function(i){return[i]});return t=F(t),da(e,n,function(i,a){return t(i,a[0])})}function kh(e,t,n){t=It(t,e);var i=-1,a=t.length;for(a||(a=1,e=r);++i<a;){var u=e==null?r:e[tt(t[i])];u===r&&(i=a,u=n),e=pt(u)?u.call(e):u}return e}function Vh(e,t,n){return e==null?e:xn(e,t,n)}function Gh(e,t,n,i){return i=typeof i=="function"?i:r,e==null?e:xn(e,t,n,i)}var Io=Oa(ue),Eo=Oa(we);function qh(e,t,n){var i=U(e),a=i||At(e)||Qt(e);if(t=F(t,4),n==null){var u=e&&e.constructor;a?n=i?new u:[]:te(e)?n=pt(u)?Yt(Kn(e)):{}:n={}}return(a?Oe:Qe)(e,function(d,p,g){return t(n,d,p,g)}),n}function Hh(e,t){return e==null?!0:gi(e,t)}function zh(e,t,n){return e==null?e:va(e,t,yi(n))}function Kh(e,t,n,i){return i=typeof i=="function"?i:r,e==null?e:va(e,t,yi(n),i)}function en(e){return e==null?[]:Jr(e,ue(e))}function jh(e){return e==null?[]:Jr(e,we(e))}function Yh(e,t,n){return n===r&&(n=t,t=r),n!==r&&(n=Be(n),n=n===n?n:0),t!==r&&(t=Be(t),t=t===t?t:0),Nt(Be(e),t,n)}function Jh(e,t,n){return t=ht(t),n===r?(n=t,t=0):n=ht(n),e=Be(e),tf(e,t,n)}function Zh(e,t,n){if(n&&typeof n!="boolean"&&me(e,t,n)&&(t=n=r),n===r&&(typeof t=="boolean"?(n=t,t=r):typeof e=="boolean"&&(n=e,e=r)),e===r&&t===r?(e=0,t=1):(e=ht(e),t===r?(t=e,e=0):t=ht(t)),e>t){var i=e;e=t,t=i}if(n||e%1||t%1){var a=Ks();return de(e+a*(t-e+Tl("1e-"+((a+"").length-1))),t)}return di(e,t)}var Xh=Zt(function(e,t,n){return t=t.toLowerCase(),e+(n?Ao(t):t)});function Ao(e){return Wi(z(e).toLowerCase())}function bo(e){return e=z(e),e&&e.replace(Qu,kl).replace(yl,"")}function Qh(e,t,n){e=z(e),t=Ce(t);var i=e.length;n=n===r?i:Nt(D(n),0,i);var a=n;return n-=t.length,n>=0&&e.slice(n,a)==t}function eg(e){return e=z(e),e&&Nu.test(e)?e.replace(ns,Vl):e}function tg(e){return e=z(e),e&&Wu.test(e)?e.replace(Or,"\\$&"):e}var ng=Zt(function(e,t,n){return e+(n?"-":"")+t.toLowerCase()}),rg=Zt(function(e,t,n){return e+(n?" ":"")+t.toLowerCase()}),ig=Ta("toLowerCase");function sg(e,t,n){e=z(e),t=D(t);var i=t?qt(e):0;if(!t||i>=t)return e;var a=(t-i)/2;return cr(Zn(a),n)+e+cr(Jn(a),n)}function ag(e,t,n){e=z(e),t=D(t);var i=t?qt(e):0;return t&&i<t?e+cr(t-i,n):e}function og(e,t,n){e=z(e),t=D(t);var i=t?qt(e):0;return t&&i<t?cr(t-i,n)+e:e}function ug(e,t,n){return n||t==null?t=0:t&&(t=+t),hc(z(e).replace($r,""),t||0)}function lg(e,t,n){return(n?me(e,t,n):t===r)?t=1:t=D(t),pi(z(e),t)}function cg(){var e=arguments,t=z(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var fg=Zt(function(e,t,n){return e+(n?"_":"")+t.toLowerCase()});function dg(e,t,n){return n&&typeof n!="number"&&me(e,t,n)&&(t=n=r),n=n===r?Xe:n>>>0,n?(e=z(e),e&&(typeof t=="string"||t!=null&&!Ui(t))&&(t=Ce(t),!t&&Gt(e))?Et(He(e),0,n):e.split(t,n)):[]}var pg=Zt(function(e,t,n){return e+(n?" ":"")+Wi(t)});function hg(e,t,n){return e=z(e),n=n==null?0:Nt(D(n),0,e.length),t=Ce(t),e.slice(n,n+t.length)==t}function gg(e,t,n){var i=o.templateSettings;n&&me(e,t,n)&&(t=r),e=z(e),t=xr({},t,i,$a);var a=xr({},t.imports,i.imports,$a),u=ue(a),d=Jr(a,u),p,g,w=0,x=t.interpolate||$n,I="__p += '",A=Xr((t.escape||$n).source+"|"+x.source+"|"+(x===rs?Ku:$n).source+"|"+(t.evaluate||$n).source+"|$","g"),R="//# sourceURL="+(K.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Il+"]")+`
12
- `;e.replace(A,function(N,B,V,Re,ve,Pe){return V||(V=Re),I+=e.slice(w,Pe).replace(el,Gl),B&&(p=!0,I+=`' +
11
+ `)}function Hf(e){return U(e)||Ut(e)||!!(zs&&e&&e[zs])}function ct(e,t){var n=typeof e;return t=t??mt,!!t&&(n=="number"||n!="symbol"&&nl.test(e))&&e>-1&&e%1==0&&e<t}function ye(e,t,n){if(!te(n))return!1;var i=typeof t;return(i=="number"?Se(n)&&ct(t,n.length):i=="string"&&t in n)?ze(n[t],e):!1}function Ci(e,t){if(U(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Te(e)?!0:Vu.test(e)||!ku.test(e)||t!=null&&e in K(t)}function jf(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Ti(e){var t=pr(e),n=o[t];if(typeof n!="function"||!(t in k.prototype))return!1;if(e===n)return!0;var i=Ei(n);return!!i&&e===i[0]}function zf(e){return!!Gs&&Gs in e}var Kf=Gn?ft:ji;function bn(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||jt;return e===n}function Ga(e){return e===e&&!te(e)}function qa(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==r||e in K(n))}}function Yf(e){var t=_r(e,function(i){return n.size===G&&n.clear(),i}),n=t.cache;return t}function Jf(e,t){var n=e[1],i=t[1],a=n|i,l=a<(me|gt|it),d=i==it&&n==ke||i==it&&n==an&&e[7].length<=t[8]||i==(it|an)&&t[7].length<=t[8]&&n==ke;if(!(l||d))return e;i&me&&(e[2]=t[2],a|=n&me?0:rn);var p=t[3];if(p){var g=e[3];e[3]=g?ba(g,p,t[4]):p,e[4]=g?_t(e[3],ne):t[4]}return p=t[5],p&&(g=e[5],e[5]=g?Ca(g,p,t[6]):p,e[6]=g?_t(e[5],ne):t[6]),p=t[7],p&&(e[7]=p),i&it&&(e[8]=e[8]==null?t[8]:pe(e[8],t[8])),e[9]==null&&(e[9]=t[9]),e[0]=t[0],e[1]=a,e}function Zf(e){var t=[];if(e!=null)for(var n in K(e))t.push(n);return t}function Xf(e){return Hn.call(e)}function Ha(e,t,n){return t=oe(t===r?e.length-1:t,0),function(){for(var i=arguments,a=-1,l=oe(i.length-t,0),d=v(l);++a<l;)d[a]=i[t+a];a=-1;for(var p=v(t+1);++a<t;)p[a]=i[a];return p[t]=n(d),Ee(e,this,p)}}function ja(e,t){return t.length<2?e:Lt(e,Ue(t,0,-1))}function Qf(e,t){for(var n=e.length,i=pe(t.length,n),a=we(e);i--;){var l=t[i];e[i]=ct(l,n)?a[l]:r}return e}function Ri(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}var za=Ya(ma),Cn=pc||function(e,t){return fe.setTimeout(e,t)},Pi=Ya(If);function Ka(e,t,n){var i=t+"";return Pi(e,qf(i,ed(kf(i),n)))}function Ya(e){var t=0,n=0;return function(){var i=vc(),a=Su-(i-n);if(n=i,a>0){if(++t>=wu)return arguments[0]}else t=0;return e.apply(r,arguments)}}function gr(e,t){var n=-1,i=e.length,a=i-1;for(t=t===r?i:t;++n<t;){var l=di(n,a),d=e[l];e[l]=e[n],e[n]=d}return e.length=t,e}var Ja=Yf(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Gu,function(n,i,a,l){t.push(a?l.replace(Ju,"$1"):i||n)}),t});function je(e){if(typeof e=="string"||Te(e))return e;var t=e+"";return t=="0"&&1/e==-Ct?"-0":t}function Ot(e){if(e!=null){try{return qn.call(e)}catch{}try{return e+""}catch{}}return""}function ed(e,t){return Ae(Cu,function(n){var i="_."+n[0];t&n[1]&&!Wn(e,i)&&e.push(i)}),e.sort()}function Za(e){if(e instanceof k)return e.clone();var t=new Ne(e.__wrapped__,e.__chain__);return t.__actions__=we(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}function td(e,t,n){(n?ye(e,t,n):t===r)?t=1:t=oe(D(t),0);var i=e==null?0:e.length;if(!i||t<1)return[];for(var a=0,l=0,d=v(Zn(i/t));a<i;)d[l++]=Ue(e,a,a+=t);return d}function nd(e){for(var t=-1,n=e==null?0:e.length,i=0,a=[];++t<n;){var l=e[t];l&&(a[i++]=l)}return a}function rd(){var e=arguments.length;if(!e)return[];for(var t=v(e-1),n=arguments[0],i=e;i--;)t[i-1]=arguments[i];return yt(U(n)?we(n):[n],de(t,1))}var id=W(function(e,t){return ie(e)?Sn(e,de(t,1,ie,!0)):[]}),sd=W(function(e,t){var n=De(t);return ie(n)&&(n=r),ie(e)?Sn(e,de(t,1,ie,!0),L(n,2)):[]}),ad=W(function(e,t){var n=De(t);return ie(n)&&(n=r),ie(e)?Sn(e,de(t,1,ie,!0),r,n):[]});function od(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:D(t),Ue(e,t<0?0:t,i)):[]}function ud(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:D(t),t=i-t,Ue(e,0,t<0?0:t)):[]}function ld(e,t){return e&&e.length?or(e,L(t,3),!0,!0):[]}function cd(e,t){return e&&e.length?or(e,L(t,3),!0):[]}function fd(e,t,n,i){var a=e==null?0:e.length;return a?(n&&typeof n!="number"&&ye(e,t,n)&&(n=0,i=a),nf(e,t,n,i)):[]}function Xa(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=n==null?0:D(n);return a<0&&(a=oe(i+a,0)),Bn(e,L(t,3),a)}function Qa(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=i-1;return n!==r&&(a=D(n),a=n<0?oe(i+a,0):pe(a,i-1)),Bn(e,L(t,3),a,!0)}function eo(e){var t=e==null?0:e.length;return t?de(e,1):[]}function dd(e){var t=e==null?0:e.length;return t?de(e,Ct):[]}function pd(e,t){var n=e==null?0:e.length;return n?(t=t===r?1:D(t),de(e,t)):[]}function hd(e){for(var t=-1,n=e==null?0:e.length,i={};++t<n;){var a=e[t];Xe(i,a[0],a[1])}return i}function to(e){return e&&e.length?e[0]:r}function gd(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=n==null?0:D(n);return a<0&&(a=oe(i+a,0)),Vt(e,t,a)}function md(e){var t=e==null?0:e.length;return t?Ue(e,0,-1):[]}var vd=W(function(e){var t=ee(e,vi);return t.length&&t[0]===e[0]?oi(t):[]}),yd=W(function(e){var t=De(e),n=ee(e,vi);return t===De(n)?t=r:n.pop(),n.length&&n[0]===e[0]?oi(n,L(t,2)):[]}),_d=W(function(e){var t=De(e),n=ee(e,vi);return t=typeof t=="function"?t:r,t&&n.pop(),n.length&&n[0]===e[0]?oi(n,r,t):[]});function wd(e,t){return e==null?"":gc.call(e,t)}function De(e){var t=e==null?0:e.length;return t?e[t-1]:r}function Sd(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=i;return n!==r&&(a=D(n),a=a<0?oe(i+a,0):pe(a,i-1)),t===t?Ql(e,t,a):Bn(e,Os,a,!0)}function Id(e,t){return e&&e.length?da(e,D(t)):r}var xd=W(no);function no(e,t){return e&&e.length&&t&&t.length?fi(e,t):e}function Ed(e,t,n){return e&&e.length&&t&&t.length?fi(e,t,L(n,2)):e}function Ad(e,t,n){return e&&e.length&&t&&t.length?fi(e,t,r,n):e}var bd=lt(function(e,t){var n=e==null?0:e.length,i=ri(e,t);return ga(e,ee(t,function(a){return ct(a,n)?+a:a}).sort(Aa)),i});function Cd(e,t){var n=[];if(!(e&&e.length))return n;var i=-1,a=[],l=e.length;for(t=L(t,3);++i<l;){var d=e[i];t(d,i,e)&&(n.push(d),a.push(i))}return ga(e,a),n}function Fi(e){return e==null?e:_c.call(e)}function Td(e,t,n){var i=e==null?0:e.length;return i?(n&&typeof n!="number"&&ye(e,t,n)?(t=0,n=i):(t=t==null?0:D(t),n=n===r?i:D(n)),Ue(e,t,n)):[]}function Rd(e,t){return ar(e,t)}function Pd(e,t,n){return hi(e,t,L(n,2))}function Fd(e,t){var n=e==null?0:e.length;if(n){var i=ar(e,t);if(i<n&&ze(e[i],t))return i}return-1}function $d(e,t){return ar(e,t,!0)}function Ld(e,t,n){return hi(e,t,L(n,2),!0)}function Nd(e,t){var n=e==null?0:e.length;if(n){var i=ar(e,t,!0)-1;if(ze(e[i],t))return i}return-1}function Od(e){return e&&e.length?va(e):[]}function Ud(e,t){return e&&e.length?va(e,L(t,2)):[]}function Dd(e){var t=e==null?0:e.length;return t?Ue(e,1,t):[]}function Md(e,t,n){return e&&e.length?(t=n||t===r?1:D(t),Ue(e,0,t<0?0:t)):[]}function Wd(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:D(t),t=i-t,Ue(e,t<0?0:t,i)):[]}function Bd(e,t){return e&&e.length?or(e,L(t,3),!1,!0):[]}function kd(e,t){return e&&e.length?or(e,L(t,3)):[]}var Vd=W(function(e){return It(de(e,1,ie,!0))}),Gd=W(function(e){var t=De(e);return ie(t)&&(t=r),It(de(e,1,ie,!0),L(t,2))}),qd=W(function(e){var t=De(e);return t=typeof t=="function"?t:r,It(de(e,1,ie,!0),r,t)});function Hd(e){return e&&e.length?It(e):[]}function jd(e,t){return e&&e.length?It(e,L(t,2)):[]}function zd(e,t){return t=typeof t=="function"?t:r,e&&e.length?It(e,r,t):[]}function $i(e){if(!(e&&e.length))return[];var t=0;return e=vt(e,function(n){if(ie(n))return t=oe(n.length,t),!0}),Yr(t,function(n){return ee(e,jr(n))})}function ro(e,t){if(!(e&&e.length))return[];var n=$i(e);return t==null?n:ee(n,function(i){return Ee(t,r,i)})}var Kd=W(function(e,t){return ie(e)?Sn(e,t):[]}),Yd=W(function(e){return mi(vt(e,ie))}),Jd=W(function(e){var t=De(e);return ie(t)&&(t=r),mi(vt(e,ie),L(t,2))}),Zd=W(function(e){var t=De(e);return t=typeof t=="function"?t:r,mi(vt(e,ie),r,t)}),Xd=W($i);function Qd(e,t){return Sa(e||[],t||[],wn)}function ep(e,t){return Sa(e||[],t||[],En)}var tp=W(function(e){var t=e.length,n=t>1?e[t-1]:r;return n=typeof n=="function"?(e.pop(),n):r,ro(e,n)});function io(e){var t=o(e);return t.__chain__=!0,t}function np(e,t){return t(e),e}function mr(e,t){return t(e)}var rp=lt(function(e){var t=e.length,n=t?e[0]:0,i=this.__wrapped__,a=function(l){return ri(l,e)};return t>1||this.__actions__.length||!(i instanceof k)||!ct(n)?this.thru(a):(i=i.slice(n,+n+(t?1:0)),i.__actions__.push({func:mr,args:[a],thisArg:r}),new Ne(i,this.__chain__).thru(function(l){return t&&!l.length&&l.push(r),l}))});function ip(){return io(this)}function sp(){return new Ne(this.value(),this.__chain__)}function ap(){this.__values__===r&&(this.__values__=_o(this.value()));var e=this.__index__>=this.__values__.length,t=e?r:this.__values__[this.__index__++];return{done:e,value:t}}function op(){return this}function up(e){for(var t,n=this;n instanceof tr;){var i=Za(n);i.__index__=0,i.__values__=r,t?a.__wrapped__=i:t=i;var a=i;n=n.__wrapped__}return a.__wrapped__=e,t}function lp(){var e=this.__wrapped__;if(e instanceof k){var t=e;return this.__actions__.length&&(t=new k(this)),t=t.reverse(),t.__actions__.push({func:mr,args:[Fi],thisArg:r}),new Ne(t,this.__chain__)}return this.thru(Fi)}function cp(){return wa(this.__wrapped__,this.__actions__)}var fp=ur(function(e,t,n){j.call(e,n)?++e[n]:Xe(e,n,1)});function dp(e,t,n){var i=U(e)?Ls:tf;return n&&ye(e,t,n)&&(t=r),i(e,L(t,3))}function pp(e,t){var n=U(e)?vt:ra;return n(e,L(t,3))}var hp=Fa(Xa),gp=Fa(Qa);function mp(e,t){return de(vr(e,t),1)}function vp(e,t){return de(vr(e,t),Ct)}function yp(e,t,n){return n=n===r?1:D(n),de(vr(e,t),n)}function so(e,t){var n=U(e)?Ae:St;return n(e,L(t,3))}function ao(e,t){var n=U(e)?Ul:na;return n(e,L(t,3))}var _p=ur(function(e,t,n){j.call(e,n)?e[n].push(t):Xe(e,n,[t])});function wp(e,t,n,i){e=Se(e)?e:en(e),n=n&&!i?D(n):0;var a=e.length;return n<0&&(n=oe(a+n,0)),Ir(e)?n<=a&&e.indexOf(t,n)>-1:!!a&&Vt(e,t,n)>-1}var Sp=W(function(e,t,n){var i=-1,a=typeof t=="function",l=Se(e)?v(e.length):[];return St(e,function(d){l[++i]=a?Ee(t,d,n):In(d,t,n)}),l}),Ip=ur(function(e,t,n){Xe(e,n,t)});function vr(e,t){var n=U(e)?ee:la;return n(e,L(t,3))}function xp(e,t,n,i){return e==null?[]:(U(t)||(t=t==null?[]:[t]),n=i?r:n,U(n)||(n=n==null?[]:[n]),pa(e,t,n))}var Ep=ur(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]});function Ap(e,t,n){var i=U(e)?qr:Ds,a=arguments.length<3;return i(e,L(t,4),n,a,St)}function bp(e,t,n){var i=U(e)?Dl:Ds,a=arguments.length<3;return i(e,L(t,4),n,a,na)}function Cp(e,t){var n=U(e)?vt:ra;return n(e,wr(L(t,3)))}function Tp(e){var t=U(e)?Xs:wf;return t(e)}function Rp(e,t,n){(n?ye(e,t,n):t===r)?t=1:t=D(t);var i=U(e)?Jc:Sf;return i(e,t)}function Pp(e){var t=U(e)?Zc:xf;return t(e)}function Fp(e){if(e==null)return 0;if(Se(e))return Ir(e)?qt(e):e.length;var t=he(e);return t==Ve||t==Ge?e.size:li(e).length}function $p(e,t,n){var i=U(e)?Hr:Ef;return n&&ye(e,t,n)&&(t=r),i(e,L(t,3))}var Lp=W(function(e,t){if(e==null)return[];var n=t.length;return n>1&&ye(e,t[0],t[1])?t=[]:n>2&&ye(t[0],t[1],t[2])&&(t=[t[0]]),pa(e,de(t,1),[])}),yr=dc||function(){return fe.Date.now()};function Np(e,t){if(typeof t!="function")throw new Le(x);return e=D(e),function(){if(--e<1)return t.apply(this,arguments)}}function oo(e,t,n){return t=n?r:t,t=e&&t==null?e.length:t,ut(e,it,r,r,r,r,t)}function uo(e,t){var n;if(typeof t!="function")throw new Le(x);return e=D(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=r),n}}var Li=W(function(e,t,n){var i=me;if(n.length){var a=_t(n,Xt(Li));i|=ce}return ut(e,i,t,n,a)}),lo=W(function(e,t,n){var i=me|gt;if(n.length){var a=_t(n,Xt(lo));i|=ce}return ut(t,i,e,n,a)});function co(e,t,n){t=n?r:t;var i=ut(e,ke,r,r,r,r,r,t);return i.placeholder=co.placeholder,i}function fo(e,t,n){t=n?r:t;var i=ut(e,rt,r,r,r,r,r,t);return i.placeholder=fo.placeholder,i}function po(e,t,n){var i,a,l,d,p,g,S=0,I=!1,E=!1,A=!0;if(typeof e!="function")throw new Le(x);t=Me(t)||0,te(n)&&(I=!!n.leading,E="maxWait"in n,l=E?oe(Me(n.maxWait)||0,t):l,A="trailing"in n?!!n.trailing:A);function R(se){var Ke=i,pt=a;return i=a=r,S=se,d=e.apply(pt,Ke),d}function N(se){return S=se,p=Cn(B,t),I?R(se):d}function M(se){var Ke=se-g,pt=se-S,Lo=t-Ke;return E?pe(Lo,l-pt):Lo}function F(se){var Ke=se-g,pt=se-S;return g===r||Ke>=t||Ke<0||E&&pt>=l}function B(){var se=yr();if(F(se))return V(se);p=Cn(B,M(se))}function V(se){return p=r,A&&i?R(se):(i=a=r,d)}function Re(){p!==r&&Ia(p),S=0,i=g=a=p=r}function _e(){return p===r?d:V(yr())}function Pe(){var se=yr(),Ke=F(se);if(i=arguments,a=this,g=se,Ke){if(p===r)return N(g);if(E)return Ia(p),p=Cn(B,t),R(g)}return p===r&&(p=Cn(B,t)),d}return Pe.cancel=Re,Pe.flush=_e,Pe}var Op=W(function(e,t){return ta(e,1,t)}),Up=W(function(e,t,n){return ta(e,Me(t)||0,n)});function Dp(e){return ut(e,Er)}function _r(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new Le(x);var n=function(){var i=arguments,a=t?t.apply(this,i):i[0],l=n.cache;if(l.has(a))return l.get(a);var d=e.apply(this,i);return n.cache=l.set(a,d)||l,d};return n.cache=new(_r.Cache||ot),n}_r.Cache=ot;function wr(e){if(typeof e!="function")throw new Le(x);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 Mp(e){return uo(2,e)}var Wp=Af(function(e,t){t=t.length==1&&U(t[0])?ee(t[0],be(L())):ee(de(t,1),be(L()));var n=t.length;return W(function(i){for(var a=-1,l=pe(i.length,n);++a<l;)i[a]=t[a].call(this,i[a]);return Ee(e,this,i)})}),Ni=W(function(e,t){var n=_t(t,Xt(Ni));return ut(e,ce,r,t,n)}),ho=W(function(e,t){var n=_t(t,Xt(ho));return ut(e,sn,r,t,n)}),Bp=lt(function(e,t){return ut(e,an,r,r,r,t)});function kp(e,t){if(typeof e!="function")throw new Le(x);return t=t===r?t:D(t),W(e,t)}function Vp(e,t){if(typeof e!="function")throw new Le(x);return t=t==null?0:oe(D(t),0),W(function(n){var i=n[t],a=Et(n,0,t);return i&&yt(a,i),Ee(e,this,a)})}function Gp(e,t,n){var i=!0,a=!0;if(typeof e!="function")throw new Le(x);return te(n)&&(i="leading"in n?!!n.leading:i,a="trailing"in n?!!n.trailing:a),po(e,t,{leading:i,maxWait:t,trailing:a})}function qp(e){return oo(e,1)}function Hp(e,t){return Ni(yi(t),e)}function jp(){if(!arguments.length)return[];var e=arguments[0];return U(e)?e:[e]}function zp(e){return Oe(e,Be)}function Kp(e,t){return t=typeof t=="function"?t:r,Oe(e,Be,t)}function Yp(e){return Oe(e,Y|Be)}function Jp(e,t){return t=typeof t=="function"?t:r,Oe(e,Y|Be,t)}function Zp(e,t){return t==null||ea(e,t,ue(t))}function ze(e,t){return e===t||e!==e&&t!==t}var Xp=dr(ai),Qp=dr(function(e,t){return e>=t}),Ut=aa((function(){return arguments})())?aa:function(e){return re(e)&&j.call(e,"callee")&&!js.call(e,"callee")},U=v.isArray,eh=Cs?be(Cs):uf;function Se(e){return e!=null&&Sr(e.length)&&!ft(e)}function ie(e){return re(e)&&Se(e)}function th(e){return e===!0||e===!1||re(e)&&ve(e)==on}var At=hc||ji,nh=Ts?be(Ts):lf;function rh(e){return re(e)&&e.nodeType===1&&!Tn(e)}function ih(e){if(e==null)return!0;if(Se(e)&&(U(e)||typeof e=="string"||typeof e.splice=="function"||At(e)||Qt(e)||Ut(e)))return!e.length;var t=he(e);if(t==Ve||t==Ge)return!e.size;if(bn(e))return!li(e).length;for(var n in e)if(j.call(e,n))return!1;return!0}function sh(e,t){return xn(e,t)}function ah(e,t,n){n=typeof n=="function"?n:r;var i=n?n(e,t):r;return i===r?xn(e,t,r,n):!!i}function Oi(e){if(!re(e))return!1;var t=ve(e);return t==Ln||t==Ru||typeof e.message=="string"&&typeof e.name=="string"&&!Tn(e)}function oh(e){return typeof e=="number"&&Ks(e)}function ft(e){if(!te(e))return!1;var t=ve(e);return t==Nn||t==es||t==Tu||t==Fu}function go(e){return typeof e=="number"&&e==D(e)}function Sr(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=mt}function te(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function re(e){return e!=null&&typeof e=="object"}var mo=Rs?be(Rs):ff;function uh(e,t){return e===t||ui(e,t,Ai(t))}function lh(e,t,n){return n=typeof n=="function"?n:r,ui(e,t,Ai(t),n)}function ch(e){return vo(e)&&e!=+e}function fh(e){if(Kf(e))throw new O(w);return oa(e)}function dh(e){return e===null}function ph(e){return e==null}function vo(e){return typeof e=="number"||re(e)&&ve(e)==ln}function Tn(e){if(!re(e)||ve(e)!=st)return!1;var t=Kn(e);if(t===null)return!0;var n=j.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&qn.call(n)==uc}var Ui=Ps?be(Ps):df;function hh(e){return go(e)&&e>=-mt&&e<=mt}var yo=Fs?be(Fs):pf;function Ir(e){return typeof e=="string"||!U(e)&&re(e)&&ve(e)==fn}function Te(e){return typeof e=="symbol"||re(e)&&ve(e)==On}var Qt=$s?be($s):hf;function gh(e){return e===r}function mh(e){return re(e)&&he(e)==dn}function vh(e){return re(e)&&ve(e)==Lu}var yh=dr(ci),_h=dr(function(e,t){return e<=t});function _o(e){if(!e)return[];if(Se(e))return Ir(e)?qe(e):we(e);if(gn&&e[gn])return Jl(e[gn]());var t=he(e),n=t==Ve?Zr:t==Ge?kn:en;return n(e)}function dt(e){if(!e)return e===0?e:0;if(e=Me(e),e===Ct||e===-Ct){var t=e<0?-1:1;return t*Eu}return e===e?e:0}function D(e){var t=dt(e),n=t%1;return t===t?n?t-n:t:0}function wo(e){return e?$t(D(e),0,Ze):0}function Me(e){if(typeof e=="number")return e;if(Te(e))return Fn;if(te(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=te(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Ms(e);var n=Qu.test(e);return n||tl.test(e)?Ll(e.slice(2),n?2:8):Xu.test(e)?Fn:+e}function So(e){return et(e,Ie(e))}function wh(e){return e?$t(D(e),-mt,mt):e===0?e:0}function z(e){return e==null?"":Ce(e)}var Sh=Jt(function(e,t){if(bn(t)||Se(t)){et(t,ue(t),e);return}for(var n in t)j.call(t,n)&&wn(e,n,t[n])}),Io=Jt(function(e,t){et(t,Ie(t),e)}),xo=Jt(function(e,t,n,i){et(t,Ie(t),e,i)}),Di=Jt(function(e,t,n,i){et(t,ue(t),e,i)}),Ih=lt(ri);function xh(e,t){var n=Yt(e);return t==null?n:Qs(n,t)}var Eh=W(function(e,t){e=K(e);var n=-1,i=t.length,a=i>2?t[2]:r;for(a&&ye(t[0],t[1],a)&&(i=1);++n<i;)for(var l=t[n],d=Ie(l),p=-1,g=d.length;++p<g;){var S=d[p],I=e[S];(I===r||ze(I,jt[S])&&!j.call(e,S))&&(e[S]=l[S])}return e}),Ah=W(function(e){return e.push(r,Ma),Ee(Eo,r,e)});function bh(e,t){return Ns(e,L(t,3),Qe)}function Ch(e,t){return Ns(e,L(t,3),si)}function Th(e,t){return e==null?e:ii(e,L(t,3),Ie)}function Rh(e,t){return e==null?e:ia(e,L(t,3),Ie)}function Ph(e,t){return e&&Qe(e,L(t,3))}function Fh(e,t){return e&&si(e,L(t,3))}function $h(e){return e==null?[]:ir(e,ue(e))}function Lh(e){return e==null?[]:ir(e,Ie(e))}function Mi(e,t,n){var i=e==null?r:Lt(e,t);return i===r?n:i}function Nh(e,t){return e!=null&&ka(e,t,rf)}function Wi(e,t){return e!=null&&ka(e,t,sf)}var Oh=La(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=Hn.call(t)),e[t]=n},ki(xe)),Uh=La(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=Hn.call(t)),j.call(e,t)?e[t].push(n):e[t]=[n]},L),Dh=W(In);function ue(e){return Se(e)?Zs(e):li(e)}function Ie(e){return Se(e)?Zs(e,!0):gf(e)}function Mh(e,t){var n={};return t=L(t,3),Qe(e,function(i,a,l){Xe(n,t(i,a,l),i)}),n}function Wh(e,t){var n={};return t=L(t,3),Qe(e,function(i,a,l){Xe(n,a,t(i,a,l))}),n}var Bh=Jt(function(e,t,n){sr(e,t,n)}),Eo=Jt(function(e,t,n,i){sr(e,t,n,i)}),kh=lt(function(e,t){var n={};if(e==null)return n;var i=!1;t=ee(t,function(l){return l=xt(l,e),i||(i=l.length>1),l}),et(e,xi(e),n),i&&(n=Oe(n,Y|ht|Be,Uf));for(var a=t.length;a--;)gi(n,t[a]);return n});function Vh(e,t){return Ao(e,wr(L(t)))}var Gh=lt(function(e,t){return e==null?{}:vf(e,t)});function Ao(e,t){if(e==null)return{};var n=ee(xi(e),function(i){return[i]});return t=L(t),ha(e,n,function(i,a){return t(i,a[0])})}function qh(e,t,n){t=xt(t,e);var i=-1,a=t.length;for(a||(a=1,e=r);++i<a;){var l=e==null?r:e[je(t[i])];l===r&&(i=a,l=n),e=ft(l)?l.call(e):l}return e}function Hh(e,t,n){return e==null?e:En(e,t,n)}function jh(e,t,n,i){return i=typeof i=="function"?i:r,e==null?e:En(e,t,n,i)}var bo=Ua(ue),Co=Ua(Ie);function zh(e,t,n){var i=U(e),a=i||At(e)||Qt(e);if(t=L(t,4),n==null){var l=e&&e.constructor;a?n=i?new l:[]:te(e)?n=ft(l)?Yt(Kn(e)):{}:n={}}return(a?Ae:Qe)(e,function(d,p,g){return t(n,d,p,g)}),n}function Kh(e,t){return e==null?!0:gi(e,t)}function Yh(e,t,n){return e==null?e:_a(e,t,yi(n))}function Jh(e,t,n,i){return i=typeof i=="function"?i:r,e==null?e:_a(e,t,yi(n),i)}function en(e){return e==null?[]:Jr(e,ue(e))}function Zh(e){return e==null?[]:Jr(e,Ie(e))}function Xh(e,t,n){return n===r&&(n=t,t=r),n!==r&&(n=Me(n),n=n===n?n:0),t!==r&&(t=Me(t),t=t===t?t:0),$t(Me(e),t,n)}function Qh(e,t,n){return t=dt(t),n===r?(n=t,t=0):n=dt(n),e=Me(e),af(e,t,n)}function eg(e,t,n){if(n&&typeof n!="boolean"&&ye(e,t,n)&&(t=n=r),n===r&&(typeof t=="boolean"?(n=t,t=r):typeof e=="boolean"&&(n=e,e=r)),e===r&&t===r?(e=0,t=1):(e=dt(e),t===r?(t=e,e=0):t=dt(t)),e>t){var i=e;e=t,t=i}if(n||e%1||t%1){var a=Ys();return pe(e+a*(t-e+$l("1e-"+((a+"").length-1))),t)}return di(e,t)}var tg=Zt(function(e,t,n){return t=t.toLowerCase(),e+(n?To(t):t)});function To(e){return Bi(z(e).toLowerCase())}function Ro(e){return e=z(e),e&&e.replace(rl,Hl).replace(Il,"")}function ng(e,t,n){e=z(e),t=Ce(t);var i=e.length;n=n===r?i:$t(D(n),0,i);var a=n;return n-=t.length,n>=0&&e.slice(n,a)==t}function rg(e){return e=z(e),e&&Mu.test(e)?e.replace(rs,jl):e}function ig(e){return e=z(e),e&&qu.test(e)?e.replace(Nr,"\\$&"):e}var sg=Zt(function(e,t,n){return e+(n?"-":"")+t.toLowerCase()}),ag=Zt(function(e,t,n){return e+(n?" ":"")+t.toLowerCase()}),og=Pa("toLowerCase");function ug(e,t,n){e=z(e),t=D(t);var i=t?qt(e):0;if(!t||i>=t)return e;var a=(t-i)/2;return fr(Xn(a),n)+e+fr(Zn(a),n)}function lg(e,t,n){e=z(e),t=D(t);var i=t?qt(e):0;return t&&i<t?e+fr(t-i,n):e}function cg(e,t,n){e=z(e),t=D(t);var i=t?qt(e):0;return t&&i<t?fr(t-i,n)+e:e}function fg(e,t,n){return n||t==null?t=0:t&&(t=+t),yc(z(e).replace(Or,""),t||0)}function dg(e,t,n){return(n?ye(e,t,n):t===r)?t=1:t=D(t),pi(z(e),t)}function pg(){var e=arguments,t=z(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var hg=Zt(function(e,t,n){return e+(n?"_":"")+t.toLowerCase()});function gg(e,t,n){return n&&typeof n!="number"&&ye(e,t,n)&&(t=n=r),n=n===r?Ze:n>>>0,n?(e=z(e),e&&(typeof t=="string"||t!=null&&!Ui(t))&&(t=Ce(t),!t&&Gt(e))?Et(qe(e),0,n):e.split(t,n)):[]}var mg=Zt(function(e,t,n){return e+(n?" ":"")+Bi(t)});function vg(e,t,n){return e=z(e),n=n==null?0:$t(D(n),0,e.length),t=Ce(t),e.slice(n,n+t.length)==t}function yg(e,t,n){var i=o.templateSettings;n&&ye(e,t,n)&&(t=r),e=z(e),t=Di({},t,i,Da);var a=Di({},t.imports,i.imports,Da),l=ue(a),d=Jr(a,l);Ae(l,function(F){if(ss.test(F))throw new O($)});var p,g,S=0,I=t.interpolate||Un,E="__p += '",A=Xr((t.escape||Un).source+"|"+I.source+"|"+(I===is?Zu:Un).source+"|"+(t.evaluate||Un).source+"|$","g"),R="//# sourceURL="+(j.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Cl+"]")+`
12
+ `;e.replace(A,function(F,B,V,Re,_e,Pe){return V||(V=Re),E+=e.slice(S,Pe).replace(il,zl),B&&(p=!0,E+=`' +
13
13
  __e(`+B+`) +
14
- '`),ve&&(g=!0,I+=`';
15
- `+ve+`;
16
- __p += '`),V&&(I+=`' +
14
+ '`),_e&&(g=!0,E+=`';
15
+ `+_e+`;
16
+ __p += '`),V&&(E+=`' +
17
17
  ((__t = (`+V+`)) == null ? '' : __t) +
18
- '`),w=Pe+N.length,N}),I+=`';
19
- `;var L=K.call(t,"variable")&&t.variable;if(!L)I=`with (obj) {
20
- `+I+`
18
+ '`),S=Pe+F.length,F}),E+=`';
19
+ `;var N=j.call(t,"variable")&&t.variable;if(!N)E=`with (obj) {
20
+ `+E+`
21
21
  }
22
- `;else if(Hu.test(L))throw new O(C);I=(g?I.replace(Ru,""):I).replace(Pu,"$1").replace(Fu,"$1;"),I="function("+(L||"obj")+`) {
23
- `+(L?"":`obj || (obj = {});
22
+ `;else if(ss.test(N))throw new O(T);E=(g?E.replace(Nu,""):E).replace(Ou,"$1").replace(Uu,"$1;"),E="function("+(N||"obj")+`) {
23
+ `+(N?"":`obj || (obj = {});
24
24
  `)+"var __t, __p = ''"+(p?", __e = _.escape":"")+(g?`, __j = Array.prototype.join;
25
25
  function print() { __p += __j.call(arguments, '') }
26
26
  `:`;
27
- `)+I+`return __p
28
- }`;var M=To(function(){return H(u,R+"return "+I).apply(r,d)});if(M.source=I,$i(M))throw M;return M}function mg(e){return z(e).toLowerCase()}function vg(e){return z(e).toUpperCase()}function yg(e,t,n){if(e=z(e),e&&(n||t===r))return Us(e);if(!e||!(t=Ce(t)))return e;var i=He(e),a=He(t),u=Ds(i,a),d=Ms(i,a)+1;return Et(i,u,d).join("")}function _g(e,t,n){if(e=z(e),e&&(n||t===r))return e.slice(0,Bs(e)+1);if(!e||!(t=Ce(t)))return e;var i=He(e),a=Ms(i,He(t))+1;return Et(i,0,a).join("")}function wg(e,t,n){if(e=z(e),e&&(n||t===r))return e.replace($r,"");if(!e||!(t=Ce(t)))return e;var i=He(e),a=Ds(i,He(t));return Et(i,a).join("")}function Sg(e,t){var n=pu,i=hu;if(te(t)){var a="separator"in t?t.separator:a;n="length"in t?D(t.length):n,i="omission"in t?Ce(t.omission):i}e=z(e);var u=e.length;if(Gt(e)){var d=He(e);u=d.length}if(n>=u)return e;var p=n-qt(i);if(p<1)return i;var g=d?Et(d,0,p).join(""):e.slice(0,p);if(a===r)return g+i;if(d&&(p+=g.length-p),Ui(a)){if(e.slice(p).search(a)){var w,x=g;for(a.global||(a=Xr(a.source,z(is.exec(a))+"g")),a.lastIndex=0;w=a.exec(x);)var I=w.index;g=g.slice(0,I===r?p:I)}}else if(e.indexOf(Ce(a),p)!=p){var A=g.lastIndexOf(a);A>-1&&(g=g.slice(0,A))}return g+i}function xg(e){return e=z(e),e&&Lu.test(e)?e.replace(ts,Jl):e}var Ig=Zt(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Wi=Ta("toUpperCase");function Co(e,t,n){return e=z(e),t=n?r:t,t===r?Hl(e)?Ql(e):Ul(e):e.match(t)||[]}var To=W(function(e,t){try{return Ae(e,r,t)}catch(n){return $i(n)?n:new O(n)}}),Eg=ft(function(e,t){return Oe(t,function(n){n=tt(n),lt(e,n,Ni(e[n],e))}),e});function Ag(e){var t=e==null?0:e.length,n=F();return e=t?ee(e,function(i){if(typeof i[1]!="function")throw new $e(E);return[n(i[0]),i[1]]}):[],W(function(i){for(var a=-1;++a<t;){var u=e[a];if(Ae(u[0],this,i))return Ae(u[1],this,i)}})}function bg(e){return Jc(De(e,Y))}function Bi(e){return function(){return e}}function Cg(e,t){return e==null||e!==e?t:e}var Tg=Pa(),Rg=Pa(!0);function Se(e){return e}function ki(e){return aa(typeof e=="function"?e:De(e,Y))}function Pg(e){return ua(De(e,Y))}function Fg(e,t){return la(e,De(t,Y))}var Lg=W(function(e,t){return function(n){return wn(n,e,t)}}),Ng=W(function(e,t){return function(n){return wn(e,n,t)}});function Vi(e,t,n){var i=ue(t),a=rr(t,i);n==null&&!(te(t)&&(a.length||!i.length))&&(n=t,t=e,e=this,a=rr(t,ue(t)));var u=!(te(n)&&"chain"in n)||!!n.chain,d=pt(e);return Oe(a,function(p){var g=t[p];e[p]=g,d&&(e.prototype[p]=function(){var w=this.__chain__;if(u||w){var x=e(this.__wrapped__),I=x.__actions__=ye(this.__actions__);return I.push({func:g,args:arguments,thisArg:e}),x.__chain__=w,x}return g.apply(e,yt([this.value()],arguments))})}),e}function Og(){return ce._===this&&(ce._=sc),this}function Gi(){}function $g(e){return e=D(e),W(function(t){return ca(t,e)})}var Ug=wi(ee),Dg=wi(Fs),Mg=wi(Hr);function Ro(e){return Ci(e)?zr(tt(e)):hf(e)}function Wg(e){return function(t){return e==null?r:Ot(e,t)}}var Bg=La(),kg=La(!0);function qi(){return[]}function Hi(){return!1}function Vg(){return{}}function Gg(){return""}function qg(){return!0}function Hg(e,t){if(e=D(e),e<1||e>mt)return[];var n=Xe,i=de(e,Xe);t=F(t),e-=Xe;for(var a=Yr(i,t);++n<e;)t(n);return a}function zg(e){return U(e)?ee(e,tt):Te(e)?[e]:ye(ja(z(e)))}function Kg(e){var t=++rc;return z(e)+t}var jg=lr(function(e,t){return e+t},0),Yg=Si("ceil"),Jg=lr(function(e,t){return e/t},1),Zg=Si("floor");function Xg(e){return e&&e.length?nr(e,Se,ai):r}function Qg(e,t){return e&&e.length?nr(e,F(t,2),ai):r}function em(e){return Os(e,Se)}function tm(e,t){return Os(e,F(t,2))}function nm(e){return e&&e.length?nr(e,Se,ci):r}function rm(e,t){return e&&e.length?nr(e,F(t,2),ci):r}var im=lr(function(e,t){return e*t},1),sm=Si("round"),am=lr(function(e,t){return e-t},0);function om(e){return e&&e.length?jr(e,Se):0}function um(e,t){return e&&e.length?jr(e,F(t,2)):0}return o.after=Pp,o.ary=so,o.assign=vh,o.assignIn=wo,o.assignInWith=xr,o.assignWith=yh,o.at=_h,o.before=ao,o.bind=Ni,o.bindAll=Eg,o.bindKey=oo,o.castArray=Vp,o.chain=no,o.chunk=Zf,o.compact=Xf,o.concat=Qf,o.cond=Ag,o.conforms=bg,o.constant=Bi,o.countBy=op,o.create=wh,o.curry=uo,o.curryRight=lo,o.debounce=co,o.defaults=Sh,o.defaultsDeep=xh,o.defer=Fp,o.delay=Lp,o.difference=ed,o.differenceBy=td,o.differenceWith=nd,o.drop=rd,o.dropRight=id,o.dropRightWhile=sd,o.dropWhile=ad,o.fill=od,o.filter=lp,o.flatMap=dp,o.flatMapDeep=pp,o.flatMapDepth=hp,o.flatten=Xa,o.flattenDeep=ud,o.flattenDepth=ld,o.flip=Np,o.flow=Tg,o.flowRight=Rg,o.fromPairs=cd,o.functions=Rh,o.functionsIn=Ph,o.groupBy=gp,o.initial=dd,o.intersection=pd,o.intersectionBy=hd,o.intersectionWith=gd,o.invert=Lh,o.invertBy=Nh,o.invokeMap=vp,o.iteratee=ki,o.keyBy=yp,o.keys=ue,o.keysIn=we,o.map=mr,o.mapKeys=$h,o.mapValues=Uh,o.matches=Pg,o.matchesProperty=Fg,o.memoize=yr,o.merge=Dh,o.mergeWith=So,o.method=Lg,o.methodOf=Ng,o.mixin=Vi,o.negate=_r,o.nthArg=$g,o.omit=Mh,o.omitBy=Wh,o.once=Op,o.orderBy=_p,o.over=Ug,o.overArgs=$p,o.overEvery=Dg,o.overSome=Mg,o.partial=Oi,o.partialRight=fo,o.partition=wp,o.pick=Bh,o.pickBy=xo,o.property=Ro,o.propertyOf=Wg,o.pull=_d,o.pullAll=eo,o.pullAllBy=wd,o.pullAllWith=Sd,o.pullAt=xd,o.range=Bg,o.rangeRight=kg,o.rearg=Up,o.reject=Ip,o.remove=Id,o.rest=Dp,o.reverse=Fi,o.sampleSize=Ap,o.set=Vh,o.setWith=Gh,o.shuffle=bp,o.slice=Ed,o.sortBy=Rp,o.sortedUniq=Fd,o.sortedUniqBy=Ld,o.split=dg,o.spread=Mp,o.tail=Nd,o.take=Od,o.takeRight=$d,o.takeRightWhile=Ud,o.takeWhile=Dd,o.tap=Xd,o.throttle=Wp,o.thru=gr,o.toArray=vo,o.toPairs=Io,o.toPairsIn=Eo,o.toPath=zg,o.toPlainObject=_o,o.transform=qh,o.unary=Bp,o.union=Md,o.unionBy=Wd,o.unionWith=Bd,o.uniq=kd,o.uniqBy=Vd,o.uniqWith=Gd,o.unset=Hh,o.unzip=Li,o.unzipWith=to,o.update=zh,o.updateWith=Kh,o.values=en,o.valuesIn=jh,o.without=qd,o.words=Co,o.wrap=kp,o.xor=Hd,o.xorBy=zd,o.xorWith=Kd,o.zip=jd,o.zipObject=Yd,o.zipObjectDeep=Jd,o.zipWith=Zd,o.entries=Io,o.entriesIn=Eo,o.extend=wo,o.extendWith=xr,Vi(o,o),o.add=jg,o.attempt=To,o.camelCase=Xh,o.capitalize=Ao,o.ceil=Yg,o.clamp=Yh,o.clone=Gp,o.cloneDeep=Hp,o.cloneDeepWith=zp,o.cloneWith=qp,o.conformsTo=Kp,o.deburr=bo,o.defaultTo=Cg,o.divide=Jg,o.endsWith=Qh,o.eq=Ke,o.escape=eg,o.escapeRegExp=tg,o.every=up,o.find=cp,o.findIndex=Ja,o.findKey=Ih,o.findLast=fp,o.findLastIndex=Za,o.findLastKey=Eh,o.floor=Zg,o.forEach=ro,o.forEachRight=io,o.forIn=Ah,o.forInRight=bh,o.forOwn=Ch,o.forOwnRight=Th,o.get=Di,o.gt=jp,o.gte=Yp,o.has=Fh,o.hasIn=Mi,o.head=Qa,o.identity=Se,o.includes=mp,o.indexOf=fd,o.inRange=Jh,o.invoke=Oh,o.isArguments=Dt,o.isArray=U,o.isArrayBuffer=Jp,o.isArrayLike=_e,o.isArrayLikeObject=re,o.isBoolean=Zp,o.isBuffer=At,o.isDate=Xp,o.isElement=Qp,o.isEmpty=eh,o.isEqual=th,o.isEqualWith=nh,o.isError=$i,o.isFinite=rh,o.isFunction=pt,o.isInteger=po,o.isLength=wr,o.isMap=ho,o.isMatch=ih,o.isMatchWith=sh,o.isNaN=ah,o.isNative=oh,o.isNil=lh,o.isNull=uh,o.isNumber=go,o.isObject=te,o.isObjectLike=ne,o.isPlainObject=bn,o.isRegExp=Ui,o.isSafeInteger=ch,o.isSet=mo,o.isString=Sr,o.isSymbol=Te,o.isTypedArray=Qt,o.isUndefined=fh,o.isWeakMap=dh,o.isWeakSet=ph,o.join=md,o.kebabCase=ng,o.last=We,o.lastIndexOf=vd,o.lowerCase=rg,o.lowerFirst=ig,o.lt=hh,o.lte=gh,o.max=Xg,o.maxBy=Qg,o.mean=em,o.meanBy=tm,o.min=nm,o.minBy=rm,o.stubArray=qi,o.stubFalse=Hi,o.stubObject=Vg,o.stubString=Gg,o.stubTrue=qg,o.multiply=im,o.nth=yd,o.noConflict=Og,o.noop=Gi,o.now=vr,o.pad=sg,o.padEnd=ag,o.padStart=og,o.parseInt=ug,o.random=Zh,o.reduce=Sp,o.reduceRight=xp,o.repeat=lg,o.replace=cg,o.result=kh,o.round=sm,o.runInContext=h,o.sample=Ep,o.size=Cp,o.snakeCase=fg,o.some=Tp,o.sortedIndex=Ad,o.sortedIndexBy=bd,o.sortedIndexOf=Cd,o.sortedLastIndex=Td,o.sortedLastIndexBy=Rd,o.sortedLastIndexOf=Pd,o.startCase=pg,o.startsWith=hg,o.subtract=am,o.sum=om,o.sumBy=um,o.template=gg,o.times=Hg,o.toFinite=ht,o.toInteger=D,o.toLength=yo,o.toLower=mg,o.toNumber=Be,o.toSafeInteger=mh,o.toString=z,o.toUpper=vg,o.trim=yg,o.trimEnd=_g,o.trimStart=wg,o.truncate=Sg,o.unescape=xg,o.uniqueId=Kg,o.upperCase=Ig,o.upperFirst=Wi,o.each=ro,o.eachRight=io,o.first=Qa,Vi(o,(function(){var e={};return Qe(o,function(t,n){K.call(o.prototype,n)||(e[n]=t)}),e})(),{chain:!1}),o.VERSION=c,Oe(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){o[e].placeholder=o}),Oe(["drop","take"],function(e,t){k.prototype[e]=function(n){n=n===r?1:oe(D(n),0);var i=this.__filtered__&&!t?new k(this):this.clone();return i.__filtered__?i.__takeCount__=de(n,i.__takeCount__):i.__views__.push({size:de(n,Xe),type:e+(i.__dir__<0?"Right":"")}),i},k.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),Oe(["filter","map","takeWhile"],function(e,t){var n=t+1,i=n==Xi||n==yu;k.prototype[e]=function(a){var u=this.clone();return u.__iteratees__.push({iteratee:F(a,3),type:n}),u.__filtered__=u.__filtered__||i,u}}),Oe(["head","last"],function(e,t){var n="take"+(t?"Right":"");k.prototype[e]=function(){return this[n](1).value()[0]}}),Oe(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");k.prototype[e]=function(){return this.__filtered__?new k(this):this[n](1)}}),k.prototype.compact=function(){return this.filter(Se)},k.prototype.find=function(e){return this.filter(e).head()},k.prototype.findLast=function(e){return this.reverse().find(e)},k.prototype.invokeMap=W(function(e,t){return typeof e=="function"?new k(this):this.map(function(n){return wn(n,e,t)})}),k.prototype.reject=function(e){return this.filter(_r(F(e)))},k.prototype.slice=function(e,t){e=D(e);var n=this;return n.__filtered__&&(e>0||t<0)?new k(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(t=D(t),n=t<0?n.dropRight(-t):n.take(t-e)),n)},k.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},k.prototype.toArray=function(){return this.take(Xe)},Qe(k.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),a=o[i?"take"+(t=="last"?"Right":""):t],u=i||/^find/.test(t);a&&(o.prototype[t]=function(){var d=this.__wrapped__,p=i?[1]:arguments,g=d instanceof k,w=p[0],x=g||U(d),I=function(B){var V=a.apply(o,yt([B],p));return i&&A?V[0]:V};x&&n&&typeof w=="function"&&w.length!=1&&(g=x=!1);var A=this.__chain__,R=!!this.__actions__.length,L=u&&!A,M=g&&!R;if(!u&&x){d=M?d:new k(this);var N=e.apply(d,p);return N.__actions__.push({func:gr,args:[I],thisArg:r}),new Ue(N,A)}return L&&M?e.apply(this,p):(N=this.thru(I),L?i?N.value()[0]:N.value():N)})}),Oe(["pop","push","shift","sort","splice","unshift"],function(e){var t=kn[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);o.prototype[e]=function(){var a=arguments;if(i&&!this.__chain__){var u=this.value();return t.apply(U(u)?u:[],a)}return this[n](function(d){return t.apply(U(d)?d:[],a)})}}),Qe(k.prototype,function(e,t){var n=o[t];if(n){var i=n.name+"";K.call(jt,i)||(jt[i]=[]),jt[i].push({name:t,func:n})}}),jt[ur(r,Ze).name]=[{name:"wrapper",func:r}],k.prototype.clone=Sc,k.prototype.reverse=xc,k.prototype.value=Ic,o.prototype.at=Qd,o.prototype.chain=ep,o.prototype.commit=tp,o.prototype.next=np,o.prototype.plant=ip,o.prototype.reverse=sp,o.prototype.toJSON=o.prototype.valueOf=o.prototype.value=ap,o.prototype.first=o.prototype.head,pn&&(o.prototype[pn]=rp),o}),Ht=ec();Rt?((Rt.exports=Ht)._=Ht,kr._=Ht):ce._=Ht}).call(Am)})(Cn,Cn.exports)),Cn.exports}var Cm=bm();const zi=l=>{const s=Cm.startCase(l).toLowerCase();return s.charAt(0).toUpperCase()+s.slice(1)},Tm=["src/application.config.ts","src/application-config.ts","src/applicationConfig.ts"],$o=/serverVariables\s*:\s*\{/,Rm=/defineApplication\s*\(\s*\{/,Pm=async({projectRoot:l,variables:s})=>{const r=await Fm(l);if(r===null)return{status:"skipped-no-config"};const c=await rt.readFile(r,"utf8"),f=s.filter(C=>!new RegExp(`\\b${C.name}\\s*:`).test(c));if(f.length===0)return{status:"skipped-existing"};const S=Lm(f);if($o.test(c)){const C=c.replace($o,P=>`${P}
29
- ${S}`);return await rt.writeFile(r,C,"utf8"),{status:"appended",file:r}}if(!Rm.test(c))return{status:"skipped-no-app-call"};const E=c.replace(/\n(\s*)\}\s*\)\s*;?\s*$/,(C,P)=>{const $=Nm(f,P);return`
30
- ${P}${$}
31
- ${P}});
32
- `});return E===c?{status:"skipped-no-app-call"}:(await rt.writeFile(r,E,"utf8"),{status:"created",file:r})},Fm=async l=>{for(const s of Tm){const r=`${l}/${s}`;if(await m.pathExists(r))return r}return null},Lm=l=>l.map(({name:s,description:r,isSecret:c})=>` ${s}: {
27
+ `)+E+`return __p
28
+ }`;var M=Fo(function(){return H(l,R+"return "+E).apply(r,d)});if(M.source=E,Oi(M))throw M;return M}function _g(e){return z(e).toLowerCase()}function wg(e){return z(e).toUpperCase()}function Sg(e,t,n){if(e=z(e),e&&(n||t===r))return Ms(e);if(!e||!(t=Ce(t)))return e;var i=qe(e),a=qe(t),l=Ws(i,a),d=Bs(i,a)+1;return Et(i,l,d).join("")}function Ig(e,t,n){if(e=z(e),e&&(n||t===r))return e.slice(0,Vs(e)+1);if(!e||!(t=Ce(t)))return e;var i=qe(e),a=Bs(i,qe(t))+1;return Et(i,0,a).join("")}function xg(e,t,n){if(e=z(e),e&&(n||t===r))return e.replace(Or,"");if(!e||!(t=Ce(t)))return e;var i=qe(e),a=Ws(i,qe(t));return Et(i,a).join("")}function Eg(e,t){var n=yu,i=_u;if(te(t)){var a="separator"in t?t.separator:a;n="length"in t?D(t.length):n,i="omission"in t?Ce(t.omission):i}e=z(e);var l=e.length;if(Gt(e)){var d=qe(e);l=d.length}if(n>=l)return e;var p=n-qt(i);if(p<1)return i;var g=d?Et(d,0,p).join(""):e.slice(0,p);if(a===r)return g+i;if(d&&(p+=g.length-p),Ui(a)){if(e.slice(p).search(a)){var S,I=g;for(a.global||(a=Xr(a.source,z(as.exec(a))+"g")),a.lastIndex=0;S=a.exec(I);)var E=S.index;g=g.slice(0,E===r?p:E)}}else if(e.indexOf(Ce(a),p)!=p){var A=g.lastIndexOf(a);A>-1&&(g=g.slice(0,A))}return g+i}function Ag(e){return e=z(e),e&&Du.test(e)?e.replace(ns,ec):e}var bg=Zt(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Bi=Pa("toUpperCase");function Po(e,t,n){return e=z(e),t=n?r:t,t===r?Yl(e)?rc(e):Bl(e):e.match(t)||[]}var Fo=W(function(e,t){try{return Ee(e,r,t)}catch(n){return Oi(n)?n:new O(n)}}),Cg=lt(function(e,t){return Ae(t,function(n){n=je(n),Xe(e,n,Li(e[n],e))}),e});function Tg(e){var t=e==null?0:e.length,n=L();return e=t?ee(e,function(i){if(typeof i[1]!="function")throw new Le(x);return[n(i[0]),i[1]]}):[],W(function(i){for(var a=-1;++a<t;){var l=e[a];if(Ee(l[0],this,i))return Ee(l[1],this,i)}})}function Rg(e){return ef(Oe(e,Y))}function ki(e){return function(){return e}}function Pg(e,t){return e==null||e!==e?t:e}var Fg=$a(),$g=$a(!0);function xe(e){return e}function Vi(e){return ua(typeof e=="function"?e:Oe(e,Y))}function Lg(e){return ca(Oe(e,Y))}function Ng(e,t){return fa(e,Oe(t,Y))}var Og=W(function(e,t){return function(n){return In(n,e,t)}}),Ug=W(function(e,t){return function(n){return In(e,n,t)}});function Gi(e,t,n){var i=ue(t),a=ir(t,i);n==null&&!(te(t)&&(a.length||!i.length))&&(n=t,t=e,e=this,a=ir(t,ue(t)));var l=!(te(n)&&"chain"in n)||!!n.chain,d=ft(e);return Ae(a,function(p){var g=t[p];e[p]=g,d&&(e.prototype[p]=function(){var S=this.__chain__;if(l||S){var I=e(this.__wrapped__),E=I.__actions__=we(this.__actions__);return E.push({func:g,args:arguments,thisArg:e}),I.__chain__=S,I}return g.apply(e,yt([this.value()],arguments))})}),e}function Dg(){return fe._===this&&(fe._=lc),this}function qi(){}function Mg(e){return e=D(e),W(function(t){return da(t,e)})}var Wg=wi(ee),Bg=wi(Ls),kg=wi(Hr);function $o(e){return Ci(e)?jr(je(e)):yf(e)}function Vg(e){return function(t){return e==null?r:Lt(e,t)}}var Gg=Na(),qg=Na(!0);function Hi(){return[]}function ji(){return!1}function Hg(){return{}}function jg(){return""}function zg(){return!0}function Kg(e,t){if(e=D(e),e<1||e>mt)return[];var n=Ze,i=pe(e,Ze);t=L(t),e-=Ze;for(var a=Yr(i,t);++n<e;)t(n);return a}function Yg(e){return U(e)?ee(e,je):Te(e)?[e]:we(Ja(z(e)))}function Jg(e){var t=++oc;return z(e)+t}var Zg=cr(function(e,t){return e+t},0),Xg=Si("ceil"),Qg=cr(function(e,t){return e/t},1),em=Si("floor");function tm(e){return e&&e.length?rr(e,xe,ai):r}function nm(e,t){return e&&e.length?rr(e,L(t,2),ai):r}function rm(e){return Us(e,xe)}function im(e,t){return Us(e,L(t,2))}function sm(e){return e&&e.length?rr(e,xe,ci):r}function am(e,t){return e&&e.length?rr(e,L(t,2),ci):r}var om=cr(function(e,t){return e*t},1),um=Si("round"),lm=cr(function(e,t){return e-t},0);function cm(e){return e&&e.length?Kr(e,xe):0}function fm(e,t){return e&&e.length?Kr(e,L(t,2)):0}return o.after=Np,o.ary=oo,o.assign=Sh,o.assignIn=Io,o.assignInWith=xo,o.assignWith=Di,o.at=Ih,o.before=uo,o.bind=Li,o.bindAll=Cg,o.bindKey=lo,o.castArray=jp,o.chain=io,o.chunk=td,o.compact=nd,o.concat=rd,o.cond=Tg,o.conforms=Rg,o.constant=ki,o.countBy=fp,o.create=xh,o.curry=co,o.curryRight=fo,o.debounce=po,o.defaults=Eh,o.defaultsDeep=Ah,o.defer=Op,o.delay=Up,o.difference=id,o.differenceBy=sd,o.differenceWith=ad,o.drop=od,o.dropRight=ud,o.dropRightWhile=ld,o.dropWhile=cd,o.fill=fd,o.filter=pp,o.flatMap=mp,o.flatMapDeep=vp,o.flatMapDepth=yp,o.flatten=eo,o.flattenDeep=dd,o.flattenDepth=pd,o.flip=Dp,o.flow=Fg,o.flowRight=$g,o.fromPairs=hd,o.functions=$h,o.functionsIn=Lh,o.groupBy=_p,o.initial=md,o.intersection=vd,o.intersectionBy=yd,o.intersectionWith=_d,o.invert=Oh,o.invertBy=Uh,o.invokeMap=Sp,o.iteratee=Vi,o.keyBy=Ip,o.keys=ue,o.keysIn=Ie,o.map=vr,o.mapKeys=Mh,o.mapValues=Wh,o.matches=Lg,o.matchesProperty=Ng,o.memoize=_r,o.merge=Bh,o.mergeWith=Eo,o.method=Og,o.methodOf=Ug,o.mixin=Gi,o.negate=wr,o.nthArg=Mg,o.omit=kh,o.omitBy=Vh,o.once=Mp,o.orderBy=xp,o.over=Wg,o.overArgs=Wp,o.overEvery=Bg,o.overSome=kg,o.partial=Ni,o.partialRight=ho,o.partition=Ep,o.pick=Gh,o.pickBy=Ao,o.property=$o,o.propertyOf=Vg,o.pull=xd,o.pullAll=no,o.pullAllBy=Ed,o.pullAllWith=Ad,o.pullAt=bd,o.range=Gg,o.rangeRight=qg,o.rearg=Bp,o.reject=Cp,o.remove=Cd,o.rest=kp,o.reverse=Fi,o.sampleSize=Rp,o.set=Hh,o.setWith=jh,o.shuffle=Pp,o.slice=Td,o.sortBy=Lp,o.sortedUniq=Od,o.sortedUniqBy=Ud,o.split=gg,o.spread=Vp,o.tail=Dd,o.take=Md,o.takeRight=Wd,o.takeRightWhile=Bd,o.takeWhile=kd,o.tap=np,o.throttle=Gp,o.thru=mr,o.toArray=_o,o.toPairs=bo,o.toPairsIn=Co,o.toPath=Yg,o.toPlainObject=So,o.transform=zh,o.unary=qp,o.union=Vd,o.unionBy=Gd,o.unionWith=qd,o.uniq=Hd,o.uniqBy=jd,o.uniqWith=zd,o.unset=Kh,o.unzip=$i,o.unzipWith=ro,o.update=Yh,o.updateWith=Jh,o.values=en,o.valuesIn=Zh,o.without=Kd,o.words=Po,o.wrap=Hp,o.xor=Yd,o.xorBy=Jd,o.xorWith=Zd,o.zip=Xd,o.zipObject=Qd,o.zipObjectDeep=ep,o.zipWith=tp,o.entries=bo,o.entriesIn=Co,o.extend=Io,o.extendWith=xo,Gi(o,o),o.add=Zg,o.attempt=Fo,o.camelCase=tg,o.capitalize=To,o.ceil=Xg,o.clamp=Xh,o.clone=zp,o.cloneDeep=Yp,o.cloneDeepWith=Jp,o.cloneWith=Kp,o.conformsTo=Zp,o.deburr=Ro,o.defaultTo=Pg,o.divide=Qg,o.endsWith=ng,o.eq=ze,o.escape=rg,o.escapeRegExp=ig,o.every=dp,o.find=hp,o.findIndex=Xa,o.findKey=bh,o.findLast=gp,o.findLastIndex=Qa,o.findLastKey=Ch,o.floor=em,o.forEach=so,o.forEachRight=ao,o.forIn=Th,o.forInRight=Rh,o.forOwn=Ph,o.forOwnRight=Fh,o.get=Mi,o.gt=Xp,o.gte=Qp,o.has=Nh,o.hasIn=Wi,o.head=to,o.identity=xe,o.includes=wp,o.indexOf=gd,o.inRange=Qh,o.invoke=Dh,o.isArguments=Ut,o.isArray=U,o.isArrayBuffer=eh,o.isArrayLike=Se,o.isArrayLikeObject=ie,o.isBoolean=th,o.isBuffer=At,o.isDate=nh,o.isElement=rh,o.isEmpty=ih,o.isEqual=sh,o.isEqualWith=ah,o.isError=Oi,o.isFinite=oh,o.isFunction=ft,o.isInteger=go,o.isLength=Sr,o.isMap=mo,o.isMatch=uh,o.isMatchWith=lh,o.isNaN=ch,o.isNative=fh,o.isNil=ph,o.isNull=dh,o.isNumber=vo,o.isObject=te,o.isObjectLike=re,o.isPlainObject=Tn,o.isRegExp=Ui,o.isSafeInteger=hh,o.isSet=yo,o.isString=Ir,o.isSymbol=Te,o.isTypedArray=Qt,o.isUndefined=gh,o.isWeakMap=mh,o.isWeakSet=vh,o.join=wd,o.kebabCase=sg,o.last=De,o.lastIndexOf=Sd,o.lowerCase=ag,o.lowerFirst=og,o.lt=yh,o.lte=_h,o.max=tm,o.maxBy=nm,o.mean=rm,o.meanBy=im,o.min=sm,o.minBy=am,o.stubArray=Hi,o.stubFalse=ji,o.stubObject=Hg,o.stubString=jg,o.stubTrue=zg,o.multiply=om,o.nth=Id,o.noConflict=Dg,o.noop=qi,o.now=yr,o.pad=ug,o.padEnd=lg,o.padStart=cg,o.parseInt=fg,o.random=eg,o.reduce=Ap,o.reduceRight=bp,o.repeat=dg,o.replace=pg,o.result=qh,o.round=um,o.runInContext=h,o.sample=Tp,o.size=Fp,o.snakeCase=hg,o.some=$p,o.sortedIndex=Rd,o.sortedIndexBy=Pd,o.sortedIndexOf=Fd,o.sortedLastIndex=$d,o.sortedLastIndexBy=Ld,o.sortedLastIndexOf=Nd,o.startCase=mg,o.startsWith=vg,o.subtract=lm,o.sum=cm,o.sumBy=fm,o.template=yg,o.times=Kg,o.toFinite=dt,o.toInteger=D,o.toLength=wo,o.toLower=_g,o.toNumber=Me,o.toSafeInteger=wh,o.toString=z,o.toUpper=wg,o.trim=Sg,o.trimEnd=Ig,o.trimStart=xg,o.truncate=Eg,o.unescape=Ag,o.uniqueId=Jg,o.upperCase=bg,o.upperFirst=Bi,o.each=so,o.eachRight=ao,o.first=to,Gi(o,(function(){var e={};return Qe(o,function(t,n){j.call(o.prototype,n)||(e[n]=t)}),e})(),{chain:!1}),o.VERSION=c,Ae(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){o[e].placeholder=o}),Ae(["drop","take"],function(e,t){k.prototype[e]=function(n){n=n===r?1:oe(D(n),0);var i=this.__filtered__&&!t?new k(this):this.clone();return i.__filtered__?i.__takeCount__=pe(n,i.__takeCount__):i.__views__.push({size:pe(n,Ze),type:e+(i.__dir__<0?"Right":"")}),i},k.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),Ae(["filter","map","takeWhile"],function(e,t){var n=t+1,i=n==Qi||n==xu;k.prototype[e]=function(a){var l=this.clone();return l.__iteratees__.push({iteratee:L(a,3),type:n}),l.__filtered__=l.__filtered__||i,l}}),Ae(["head","last"],function(e,t){var n="take"+(t?"Right":"");k.prototype[e]=function(){return this[n](1).value()[0]}}),Ae(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");k.prototype[e]=function(){return this.__filtered__?new k(this):this[n](1)}}),k.prototype.compact=function(){return this.filter(xe)},k.prototype.find=function(e){return this.filter(e).head()},k.prototype.findLast=function(e){return this.reverse().find(e)},k.prototype.invokeMap=W(function(e,t){return typeof e=="function"?new k(this):this.map(function(n){return In(n,e,t)})}),k.prototype.reject=function(e){return this.filter(wr(L(e)))},k.prototype.slice=function(e,t){e=D(e);var n=this;return n.__filtered__&&(e>0||t<0)?new k(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(t=D(t),n=t<0?n.dropRight(-t):n.take(t-e)),n)},k.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},k.prototype.toArray=function(){return this.take(Ze)},Qe(k.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),a=o[i?"take"+(t=="last"?"Right":""):t],l=i||/^find/.test(t);a&&(o.prototype[t]=function(){var d=this.__wrapped__,p=i?[1]:arguments,g=d instanceof k,S=p[0],I=g||U(d),E=function(B){var V=a.apply(o,yt([B],p));return i&&A?V[0]:V};I&&n&&typeof S=="function"&&S.length!=1&&(g=I=!1);var A=this.__chain__,R=!!this.__actions__.length,N=l&&!A,M=g&&!R;if(!l&&I){d=M?d:new k(this);var F=e.apply(d,p);return F.__actions__.push({func:mr,args:[E],thisArg:r}),new Ne(F,A)}return N&&M?e.apply(this,p):(F=this.thru(E),N?i?F.value()[0]:F.value():F)})}),Ae(["pop","push","shift","sort","splice","unshift"],function(e){var t=Vn[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);o.prototype[e]=function(){var a=arguments;if(i&&!this.__chain__){var l=this.value();return t.apply(U(l)?l:[],a)}return this[n](function(d){return t.apply(U(d)?d:[],a)})}}),Qe(k.prototype,function(e,t){var n=o[t];if(n){var i=n.name+"";j.call(Kt,i)||(Kt[i]=[]),Kt[i].push({name:t,func:n})}}),Kt[lr(r,gt).name]=[{name:"wrapper",func:r}],k.prototype.clone=Ac,k.prototype.reverse=bc,k.prototype.value=Cc,o.prototype.at=rp,o.prototype.chain=ip,o.prototype.commit=sp,o.prototype.next=ap,o.prototype.plant=up,o.prototype.reverse=lp,o.prototype.toJSON=o.prototype.valueOf=o.prototype.value=cp,o.prototype.first=o.prototype.head,gn&&(o.prototype[gn]=op),o}),Ht=ic();Tt?((Tt.exports=Ht)._=Ht,kr._=Ht):fe._=Ht}).call(Tm)})(Rn,Rn.exports)),Rn.exports}var Pm=Rm();const zi=u=>{const s=Pm.startCase(u).toLowerCase();return s.charAt(0).toUpperCase()+s.slice(1)},Fm=["src/application.config.ts","src/application-config.ts","src/applicationConfig.ts"],Mo=/serverVariables\s*:\s*\{/,$m=/defineApplication\s*\(\s*\{/,Lm=async({projectRoot:u,variables:s})=>{const r=await Nm(u);if(r===null)return{status:"skipped-no-config"};const c=await nt.readFile(r,"utf8"),f=s.filter(T=>!new RegExp(`\\b${T.name}\\s*:`).test(c));if(f.length===0)return{status:"skipped-existing"};const w=Om(f);if(Mo.test(c)){const T=c.replace(Mo,$=>`${$}
29
+ ${w}`);return await nt.writeFile(r,T,"utf8"),{status:"appended",file:r}}if(!$m.test(c))return{status:"skipped-no-app-call"};const x=c.replace(/\n(\s*)\}\s*\)\s*;?\s*$/,(T,$)=>{const P=Um(f,$);return`
30
+ ${$}${P}
31
+ ${$}});
32
+ `});return x===c?{status:"skipped-no-app-call"}:(await nt.writeFile(r,x,"utf8"),{status:"created",file:r})},Nm=async u=>{for(const s of Fm){const r=`${u}/${s}`;if(await m.pathExists(r))return r}return null},Om=u=>u.map(({name:s,description:r,isSecret:c})=>` ${s}: {
33
33
  description: ${JSON.stringify(r)},
34
34
  isSecret: ${c},
35
35
  isRequired: true,
36
36
  },`).join(`
37
- `),Nm=(l,s)=>`serverVariables: {
38
- ${l.map(({name:c,description:f,isSecret:S})=>`${s} ${c}: {
37
+ `),Um=(u,s)=>`serverVariables: {
38
+ ${u.map(({name:c,description:f,isSecret:w})=>`${s} ${c}: {
39
39
  ${s} description: ${JSON.stringify(f)},
40
- ${s} isSecret: ${S},
40
+ ${s} isSecret: ${w},
41
41
  ${s} isRequired: true,
42
42
  ${s} },`).join(`
43
43
  `)}
44
- ${s}},`,Om=({data:l})=>{const s=Q.v4(),r=l.description?`
45
- description: '${l.description}',`:"";return`import { defineField, FieldType } from 'twenty-sdk/define';
44
+ ${s}},`,Dm=({data:u})=>{const s=X.v4(),r=u.description?`
45
+ description: '${u.description}',`:"";return`import { defineField, FieldType } from 'twenty-sdk/define';
46
46
 
47
47
  export default defineField({
48
48
  universalIdentifier: '${s}',
49
- name: '${l.name}',
50
- label: '${l.label}',
51
- type: FieldType.${l.type},
52
- objectUniversalIdentifier: '${l.objectUniversalIdentifier}',${r}
49
+ name: '${u.name}',
50
+ label: '${u.label}',
51
+ type: FieldType.${u.type},
52
+ objectUniversalIdentifier: '${u.objectUniversalIdentifier}',${r}
53
53
  });
54
- `},le=l=>l.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").replace(/([a-zA-Z])(\d)/g,"$1-$2").replace(/(\d)([a-zA-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").replace(/[^a-zA-Z0-9-]+/g,"-").toLowerCase(),$m=({name:l,universalIdentifier:s=Q.v4()})=>{const r=le(l);return`import { defineFrontComponent } from 'twenty-sdk/define';
54
+ `},le=u=>u.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").replace(/([a-zA-Z])(\d)/g,"$1-$2").replace(/(\d)([a-zA-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").replace(/[^a-zA-Z0-9-]+/g,"-").toLowerCase(),Mm=({name:u,universalIdentifier:s=X.v4()})=>{const r=le(u);return`import { defineFrontComponent } from 'twenty-sdk/define';
55
55
 
56
56
  // React component - implement your UI here
57
57
  const Component = () => {
@@ -69,7 +69,7 @@ export default defineFrontComponent({
69
69
  description: 'Add a description for your front component',
70
70
  component: Component,
71
71
  });
72
- `},Um=({name:l,universalIdentifier:s=Q.v4()})=>{const r=le(l);return`import { defineLogicFunction } from 'twenty-sdk/define';
72
+ `},Wm=({name:u,universalIdentifier:s=X.v4()})=>{const r=le(u);return`import { defineLogicFunction } from 'twenty-sdk/define';
73
73
 
74
74
  // Logic function handler - rename and implement your logic
75
75
  const handler = async (params: {
@@ -106,30 +106,30 @@ export default defineLogicFunction({
106
106
  // eventName: 'objectName.created',
107
107
  // },
108
108
  });
109
- `},Uo=({name:l,universalIdentifier:s=Q.v4(),type:r,viewUniversalIdentifier:c,targetObjectUniversalIdentifier:f})=>{const S=le(l);let E;return r==="OBJECT"&&f?E=` type: NavigationMenuItemType.OBJECT,
110
- targetObjectUniversalIdentifier: '${f}',`:r==="VIEW"&&c?E=` type: NavigationMenuItemType.VIEW,
111
- viewUniversalIdentifier: '${c}',`:r==="LINK"?E=` type: NavigationMenuItemType.LINK,
112
- link: 'https://example.com',`:r==="FOLDER"?E=" type: NavigationMenuItemType.FOLDER,":E=` type: NavigationMenuItemType.VIEW,
109
+ `},Wo=({name:u,universalIdentifier:s=X.v4(),type:r,viewUniversalIdentifier:c,targetObjectUniversalIdentifier:f})=>{const w=le(u);let x;return r==="OBJECT"&&f?x=` type: NavigationMenuItemType.OBJECT,
110
+ targetObjectUniversalIdentifier: '${f}',`:r==="VIEW"&&c?x=` type: NavigationMenuItemType.VIEW,
111
+ viewUniversalIdentifier: '${c}',`:r==="LINK"?x=` type: NavigationMenuItemType.LINK,
112
+ link: 'https://example.com',`:r==="FOLDER"?x=" type: NavigationMenuItemType.FOLDER,":x=` type: NavigationMenuItemType.VIEW,
113
113
  // viewUniversalIdentifier: '...',`,`import { defineNavigationMenuItem, NavigationMenuItemType } from 'twenty-sdk/define';
114
114
 
115
115
  export default defineNavigationMenuItem({
116
116
  universalIdentifier: '${s}',
117
- name: '${S}',
117
+ name: '${w}',
118
118
  icon: 'IconList',
119
119
  position: 0,
120
- ${E}
120
+ ${x}
121
121
  });
122
- `},Dm=({data:l,universalIdentifier:s=Q.v4(),nameFieldUniversalIdentifier:r=Q.v4()})=>`import { defineObject, FieldType } from 'twenty-sdk/define';
122
+ `},Bm=({data:u,universalIdentifier:s=X.v4(),nameFieldUniversalIdentifier:r=X.v4()})=>`import { defineObject, FieldType } from 'twenty-sdk/define';
123
123
 
124
124
  export const NAME_FIELD_UNIVERSAL_IDENTIFIER =
125
125
  '${r}';
126
126
 
127
127
  export default defineObject({
128
128
  universalIdentifier: '${s}',
129
- nameSingular: '${l.nameSingular}',
130
- namePlural: '${l.namePlural}',
131
- labelSingular: '${l.labelSingular}',
132
- labelPlural: '${l.labelPlural}',
129
+ nameSingular: '${u.nameSingular}',
130
+ namePlural: '${u.namePlural}',
131
+ labelSingular: '${u.labelSingular}',
132
+ labelPlural: '${u.labelPlural}',
133
133
  icon: 'IconBox',
134
134
  labelIdentifierFieldMetadataUniversalIdentifier: NAME_FIELD_UNIVERSAL_IDENTIFIER,
135
135
  fields: [
@@ -138,61 +138,61 @@ export default defineObject({
138
138
  type: FieldType.TEXT,
139
139
  name: 'name',
140
140
  label: 'Name',
141
- description: 'Name of the ${l.nameSingular}',
141
+ description: 'Name of the ${u.nameSingular}',
142
142
  icon: 'IconAbc',
143
143
  },
144
144
  ],
145
145
  });
146
- `,Mm=({name:l})=>`import { defineCommandMenuItem } from 'twenty-sdk/define';
146
+ `,km=({name:u})=>`import { defineCommandMenuItem } from 'twenty-sdk/define';
147
147
 
148
148
  export default defineCommandMenuItem({
149
- universalIdentifier: '${Q.v4()}',
149
+ universalIdentifier: '${X.v4()}',
150
150
  frontComponentUniversalIdentifier:
151
151
  'replace-with-existing-front-component-uuid',
152
- label: '${l}',
152
+ label: '${u}',
153
153
  availabilityType: 'GLOBAL',
154
154
  });
155
- `,Wm=({name:l})=>`import { definePageLayout } from 'twenty-sdk/define';
155
+ `,Vm=({name:u})=>`import { definePageLayout } from 'twenty-sdk/define';
156
156
 
157
157
  export default definePageLayout({
158
- universalIdentifier: '${Q.v4()}',
159
- name: '${l}',
158
+ universalIdentifier: '${X.v4()}',
159
+ name: '${u}',
160
160
  tabs: [
161
161
  {
162
- universalIdentifier: '${Q.v4()}',
162
+ universalIdentifier: '${X.v4()}',
163
163
  title: 'Overview',
164
164
  widgets: [],
165
165
  },
166
166
  ],
167
167
  });
168
- `,Bm=({name:l})=>`import { definePageLayoutTab, PageLayoutTabLayoutMode } from 'twenty-sdk/define';
168
+ `,Gm=({name:u})=>`import { definePageLayoutTab, PageLayoutTabLayoutMode } from 'twenty-sdk/define';
169
169
 
170
170
  export default definePageLayoutTab({
171
- universalIdentifier: '${Q.v4()}',
171
+ universalIdentifier: '${X.v4()}',
172
172
  pageLayoutUniversalIdentifier: 'replace-with-existing-page-layout-uuid',
173
- title: '${l}',
173
+ title: '${u}',
174
174
  position: 1000,
175
175
  icon: 'IconLayout',
176
176
  layoutMode: PageLayoutTabLayoutMode.CANVAS,
177
177
  widgets: [],
178
178
  });
179
- `,km=({objectLabelSingular:l,objectUniversalIdentifier:s,fieldsWidgetViewUniversalIdentifier:r})=>`import { definePageLayout, PageLayoutTabLayoutMode } from 'twenty-sdk/define';
179
+ `,qm=({objectLabelSingular:u,objectUniversalIdentifier:s,fieldsWidgetViewUniversalIdentifier:r})=>`import { definePageLayout, PageLayoutTabLayoutMode } from 'twenty-sdk/define';
180
180
 
181
181
  export default definePageLayout({
182
- universalIdentifier: '${Q.v4()}',
183
- name: 'Default ${l} Layout',
182
+ universalIdentifier: '${X.v4()}',
183
+ name: 'Default ${u} Layout',
184
184
  type: 'RECORD_PAGE',
185
185
  objectUniversalIdentifier: '${s}',
186
186
  tabs: [
187
187
  {
188
- universalIdentifier: '${Q.v4()}',
188
+ universalIdentifier: '${X.v4()}',
189
189
  title: 'Home',
190
190
  position: 10,
191
191
  icon: 'IconHome',
192
192
  layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
193
193
  widgets: [
194
194
  {
195
- universalIdentifier: '${Q.v4()}',
195
+ universalIdentifier: '${X.v4()}',
196
196
  title: 'Fields',
197
197
  type: 'FIELDS',
198
198
  configuration: {
@@ -203,14 +203,14 @@ export default definePageLayout({
203
203
  ],
204
204
  },
205
205
  {
206
- universalIdentifier: '${Q.v4()}',
206
+ universalIdentifier: '${X.v4()}',
207
207
  title: 'Timeline',
208
208
  position: 20,
209
209
  icon: 'IconTimelineEvent',
210
210
  layoutMode: PageLayoutTabLayoutMode.CANVAS,
211
211
  widgets: [
212
212
  {
213
- universalIdentifier: '${Q.v4()}',
213
+ universalIdentifier: '${X.v4()}',
214
214
  title: 'Timeline',
215
215
  type: 'TIMELINE',
216
216
  configuration: {
@@ -221,21 +221,21 @@ export default definePageLayout({
221
221
  },
222
222
  ],
223
223
  });
224
- `,Vm=({name:l,universalIdentifier:s=Q.v4()})=>{const r=le(l);return`import { defineRole } from 'twenty-sdk/define';
224
+ `,Hm=({name:u,universalIdentifier:s=X.v4()})=>{const r=le(u);return`import { defineRole } from 'twenty-sdk/define';
225
225
 
226
226
  export const ${r.toUpperCase().replace(/-/g,"_")}_ROLE_UNIVERSAL_IDENTIFIER =
227
227
  '${s}';
228
228
 
229
229
  export default defineRole({
230
230
  universalIdentifier: ${r.toUpperCase().replace(/-/g,"_")}_ROLE_UNIVERSAL_IDENTIFIER,
231
- label: '${l}',
231
+ label: '${u}',
232
232
  description: 'Add a description for your role',
233
233
  canReadAllObjectRecords: true,
234
234
  canUpdateAllObjectRecords: true,
235
235
  canSoftDeleteAllObjectRecords: true,
236
236
  canDestroyAllObjectRecords: false,
237
237
  });
238
- `},Gm=({name:l,universalIdentifier:s=Q.v4()})=>{const r=le(l);return`import { defineAgent } from 'twenty-sdk/define';
238
+ `},jm=({name:u,universalIdentifier:s=X.v4()})=>{const r=le(u);return`import { defineAgent } from 'twenty-sdk/define';
239
239
 
240
240
  export const ${r.toUpperCase().replace(/-/g,"_")}_AGENT_UNIVERSAL_IDENTIFIER =
241
241
  '${s}';
@@ -243,11 +243,12 @@ export const ${r.toUpperCase().replace(/-/g,"_")}_AGENT_UNIVERSAL_IDENTIFIER =
243
243
  export default defineAgent({
244
244
  universalIdentifier: ${r.toUpperCase().replace(/-/g,"_")}_AGENT_UNIVERSAL_IDENTIFIER,
245
245
  name: '${r}',
246
- label: '${l}',
246
+ label: '${u}',
247
247
  description: 'Add a description for your agent',
248
248
  prompt: 'Add the agent system prompt here',
249
+ responseFormat: {type: 'text'},
249
250
  });
250
- `},qm=({name:l,universalIdentifier:s=Q.v4()})=>{const r=le(l),c=r.toUpperCase().replace(/-/g,"_"),f=l.replace(/\\/g,"\\\\").replace(/'/g,"\\'");return`import { defineConnectionProvider } from 'twenty-sdk/define';
251
+ `},zm=({name:u,universalIdentifier:s=X.v4()})=>{const r=le(u),c=r.toUpperCase().replace(/-/g,"_"),f=u.replace(/\\/g,"\\\\").replace(/'/g,"\\'");return`import { defineConnectionProvider } from 'twenty-sdk/define';
251
252
 
252
253
  export const ${c}_CONNECTION_PROVIDER_UNIVERSAL_IDENTIFIER =
253
254
  '${s}';
@@ -267,7 +268,7 @@ export default defineConnectionProvider({
267
268
  clientSecretVariable: '${c}_CLIENT_SECRET',
268
269
  },
269
270
  });
270
- `},Hm=({name:l,universalIdentifier:s=Q.v4()})=>{const r=le(l);return`import { defineSkill } from 'twenty-sdk/define';
271
+ `},Km=({name:u,universalIdentifier:s=X.v4()})=>{const r=le(u);return`import { defineSkill } from 'twenty-sdk/define';
271
272
 
272
273
  export const ${r.toUpperCase().replace(/-/g,"_")}_SKILL_UNIVERSAL_IDENTIFIER =
273
274
  '${s}';
@@ -275,21 +276,21 @@ export const ${r.toUpperCase().replace(/-/g,"_")}_SKILL_UNIVERSAL_IDENTIFIER =
275
276
  export default defineSkill({
276
277
  universalIdentifier: ${r.toUpperCase().replace(/-/g,"_")}_SKILL_UNIVERSAL_IDENTIFIER,
277
278
  name: '${r}',
278
- label: '${l}',
279
+ label: '${u}',
279
280
  description: 'Add a description for your skill',
280
281
  content: 'Add the skill content here',
281
282
  });
282
- `},zm=({field:l,index:s,objectUniversalIdentifier:r})=>{const c=l.universalIdentifier??Q.v4(),f=l.position??s,S=l.isVisible??!0,E=l.size??200,C="defaultFieldName"in l?` fieldMetadataUniversalIdentifier: generateDefaultFieldUniversalIdentifier({
283
+ `},Ym=({field:u,index:s,objectUniversalIdentifier:r})=>{const c=u.universalIdentifier??X.v4(),f=u.position??s,w=u.isVisible??!0,x=u.size??200,T="defaultFieldName"in u?` fieldMetadataUniversalIdentifier: generateDefaultFieldUniversalIdentifier({
283
284
  objectUniversalIdentifier: '${r}',
284
- fieldName: '${l.defaultFieldName}',
285
- })`:` fieldMetadataUniversalIdentifier: '${l.fieldMetadataUniversalIdentifier}'`;return` {
285
+ fieldName: '${u.defaultFieldName}',
286
+ })`:` fieldMetadataUniversalIdentifier: '${u.fieldMetadataUniversalIdentifier}'`;return` {
286
287
  universalIdentifier: '${c}',
287
- ${C},
288
+ ${T},
288
289
  position: ${f},
289
- isVisible: ${S},
290
- size: ${E},
291
- }`},Ki=({name:l,universalIdentifier:s=Q.v4(),objectUniversalIdentifier:r="fill-later",fields:c=[],type:f})=>{const S=le(l),E=c.some(Y=>"defaultFieldName"in Y),P=c.length>0?` fields: [
292
- ${c.map((Y,se)=>zm({field:Y,index:se,objectUniversalIdentifier:r})).join(`,
290
+ isVisible: ${w},
291
+ size: ${x},
292
+ }`},Ki=({name:u,universalIdentifier:s=X.v4(),objectUniversalIdentifier:r="fill-later",fields:c=[],type:f})=>{const w=le(u),x=c.some(ne=>"defaultFieldName"in ne),$=c.length>0?` fields: [
293
+ ${c.map((ne,Y)=>Ym({field:ne,index:Y,objectUniversalIdentifier:r})).join(`,
293
294
  `)},
294
295
  ],`:` // fields: [
295
296
  // {
@@ -298,19 +299,19 @@ ${c.map((Y,se)=>zm({field:Y,index:se,objectUniversalIdentifier:r})).join(`,
298
299
  // position: 0,
299
300
  // isVisible: true,
300
301
  // },
301
- // ],`,$=f!==void 0?` type: '${f}',
302
- `:"";return`${E?`import {
302
+ // ],`,P=f!==void 0?` type: '${f}',
303
+ `:"";return`${x?`import {
303
304
  defineView,
304
305
  generateDefaultFieldUniversalIdentifier,
305
306
  } from 'twenty-sdk/define';`:"import { defineView } from 'twenty-sdk/define';"}
306
307
 
307
308
  export default defineView({
308
309
  universalIdentifier: '${s}',
309
- name: '${S}',
310
+ name: '${w}',
310
311
  objectUniversalIdentifier: '${r}',
311
- ${$} icon: 'IconList',
312
+ ${P} icon: 'IconList',
312
313
  position: 0,
313
- ${P}
314
+ ${$}
314
315
  // filters: [
315
316
  // {
316
317
  // universalIdentifier: '...',
@@ -327,17 +328,32 @@ ${P}
327
328
  // },
328
329
  // ],
329
330
  });
330
- `},Km="src/application.config.ts",Ir="src";class iu{async execute(s,r){try{const c=s??await this.getEntity(),f=this.getFolderName(c),S=r?q.join(Z,r):q.join(Z,Ir,f);await m.ensureDir(S);const{name:E,file:C}=await this.getEntityData(c),P=q.join(S,this.getFileName(E,c));if(await m.pathExists(P)){const{overwrite:$}=await this.handleFileExist();if(!$)return}await rt.writeFile(P,C),console.log(y.default.green(`✓ Created ${f}:`),y.default.cyan(q.relative(Z,P))),c===m.e.Object&&await this.promptAndCreateObjectCompanions(E,r),c===m.e.ConnectionProvider&&await this.registerConnectionProviderServerVariables(E)}catch(c){console.error(y.default.red("Add new entity failed:"),c instanceof Error?c.message:c),process.exit(1)}}async getEntityData(s){switch(s){case m.e.Object:{const r=await this.getObjectData(),c=r.nameSingular,f=Q.v4(),S=Q.v4();this.lastObjectUniversalIdentifier=f,this.lastNameFieldUniversalIdentifier=S,this.lastObjectLabelSingular=r.labelSingular;const E=Dm({data:r,universalIdentifier:f,nameFieldUniversalIdentifier:S});return{name:c,file:E}}case m.e.Field:{const r=await this.getFieldData(),c=r.name,f=Om({data:r});return{name:c,file:f}}case m.e.LogicFunction:{const r=await this.getEntityName(s),c=Um({name:r});return{name:r,file:c}}case m.e.FrontComponent:{const r=await this.getEntityName(s),c=$m({name:r});return{name:r,file:c}}case m.e.Role:{const r=await this.getEntityName(s),c=Vm({name:r});return{name:r,file:c}}case m.e.Skill:{const r=await this.getEntityName(s),c=Hm({name:r});return{name:r,file:c}}case m.e.Agent:{const r=await this.getEntityName(s),c=Gm({name:r});return{name:r,file:c}}case m.e.ConnectionProvider:{const r=await this.getEntityName(s),c=qm({name:r});return{name:r,file:c}}case m.e.View:{const c=(await this.getViewData()).name,f=Ki({name:c});return{name:c,file:f}}case m.e.NavigationMenuItem:{const r=await this.getEntityName(s),c=Uo({name:r});return{name:r,file:c}}case m.e.PageLayout:{const r=await this.getEntityName(s),c=Wm({name:r});return{name:r,file:c}}case m.e.PageLayoutTab:{const r=await this.getEntityName(s),c=Bm({name:r});return{name:r,file:c}}case m.e.CommandMenuItem:{const r=await this.getEntityName(s),c=Mm({name:r});return{name:r,file:c}}default:m.$()}}async promptAndCreateObjectCompanions(s,r){const{createCompanions:c}=await Ye.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;const f=Q.v4(),S=Q.v4(),E=Ki({name:`all-${le(s)}`,universalIdentifier:f,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,fields:this.lastNameFieldUniversalIdentifier?[{fieldMetadataUniversalIdentifier:this.lastNameFieldUniversalIdentifier,position:0,isVisible:!0,size:200}]:[]}),C=r?q.join(Z,r):q.join(Z,Ir,this.getFolderName(m.e.View));await m.ensureDir(C);const P=`all-${le(s)}.ts`,$=q.join(C,P);if(await m.pathExists($)){const{overwrite:Ee}=await this.handleFileExist();if(!Ee)return}await rt.writeFile($,E),console.log(y.default.green("✓ Created view:"),y.default.cyan(q.relative(Z,$)));const G=this.buildRecordPageFieldsViewFields(this.lastNameFieldUniversalIdentifier),Y=Ki({name:`${le(s)}-record-page-fields`,universalIdentifier:S,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,type:m.rE.FIELDS_WIDGET,fields:G}),se=`${le(s)}-record-page-fields.ts`,Fe=q.join(C,se);if(await m.pathExists(Fe)){const{overwrite:Ee}=await this.handleFileExist();if(!Ee)return}await rt.writeFile(Fe,Y),console.log(y.default.green("✓ Created record-page-fields view:"),y.default.cyan(q.relative(Z,Fe)));const Ve=Uo({name:s,type:"OBJECT",targetObjectUniversalIdentifier:this.lastObjectUniversalIdentifier}),Je=r?q.join(Z,r):q.join(Z,Ir,this.getFolderName(m.e.NavigationMenuItem));await m.ensureDir(Je);const xe=`${le(s)}.ts`,Ze=q.join(Je,xe);if(await m.pathExists(Ze)){const{overwrite:Ee}=await this.handleFileExist();if(!Ee)return}await rt.writeFile(Ze,Ve),console.log(y.default.green("✓ Created navigation menu item:"),y.default.cyan(q.relative(Z,Ze)));const Rn=km({objectLabelSingular:this.lastObjectLabelSingular??s,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,fieldsWidgetViewUniversalIdentifier:S}),Le=r?q.join(Z,r):q.join(Z,Ir,this.getFolderName(m.e.PageLayout));await m.ensureDir(Le);const Ct=`${le(s)}-record-page-layout.ts`,Ie=q.join(Le,Ct);if(await m.pathExists(Ie)){const{overwrite:Ee}=await this.handleFileExist();if(!Ee)return}await rt.writeFile(Ie,Rn),console.log(y.default.green("✓ Created record page layout:"),y.default.cyan(q.relative(Z,Ie)))}async registerConnectionProviderServerVariables(s){const r=le(s).toUpperCase().replace(/-/g,"_"),c=[{name:`${r}_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:`${r}_CLIENT_SECRET`,description:"OAuth client secret issued by the third-party provider. Stored encrypted; never echoed in API responses.",isSecret:!0}],f=await Pm({projectRoot:Z,variables:c});switch(f.status){case"appended":case"created":{console.log(y.default.green(`✓ Added ${c.map(S=>S.name).join(" + ")} to defineApplication.serverVariables:`),y.default.cyan(q.relative(Z,f.file)));break}case"skipped-existing":console.log(y.default.dim(` (${c.map(S=>S.name).join(" / ")} already declared on defineApplication.serverVariables)`));break;case"skipped-no-config":case"skipped-no-app-call":console.log(y.default.yellow(`! Couldn't auto-update ${Km}. Add these manually to defineApplication.serverVariables:
331
- `+c.map(S=>` ${S.name}: { description: '...', isSecret: ${S.isSecret}, isRequired: true },`).join(`
332
- `)));break}}buildRecordPageFieldsViewFields(s){const c=["createdAt","updatedAt","createdBy","updatedBy"].map(S=>({defaultFieldName:S,isVisible:!0,size:200}));return(s?[{fieldMetadataUniversalIdentifier:s,isVisible:!0,size:200},...c]:c).map((S,E)=>({...S,position:E}))}async getEntity(){const{entity:s}=await Ye.default.prompt([{type:"select",name:"entity",message:"What entity do you want to create?",default:"",choices:Object.values(m.e)}]);return s}async handleFileExist(){return await Ye.default.prompt([{type:"confirm",name:"overwrite",message:"File already exists. Do you want to overwrite it?",default:!1}])}async getEntityName(s){const{name:r}=await Ye.default.prompt([{type:"input",name:"name",message:`Enter a name for your new ${s}:`,default:"",validate:c=>c.length===0?`${s} name is required`:!0}]);return r}async getFieldData(){return Ye.default.prompt([{type:"input",name:"name",message:"Enter a name for your field:",default:"",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"label",message:"Enter a label for your field:",default:s=>zi(s.name),validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"select",name:"type",message:"Select the field type:",choices:Object.values(m.R),default:m.R.TEXT},{type:"input",name:"objectUniversalIdentifier",message:"Enter the universalIdentifier of the object this field belongs to:",default:"fill-later",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"description",message:"Enter a description for your field (optional):",default:""}])}async getObjectData(){return Ye.default.prompt([{type:"input",name:"nameSingular",message:"Enter a name singular for your object (eg: company):",default:"",validate:s=>!s||s.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:(s,r)=>s.trim()===r?.nameSingular.trim()?"Name plural must be different from name singular":!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"labelSingular",message:"Enter a label singular for your object:",default:s=>zi(s.nameSingular),validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"labelPlural",message:"Enter a label plural for your object:",default:s=>zi(s.namePlural),validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0}])}async getViewData(){return Ye.default.prompt([{type:"input",name:"name",message:"Enter a name for your view:",default:"",validate:s=>!s||s.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:s=>!s||s.trim().length===0?"Please enter a non empty string":!0}])}getFolderName(s){return`${le(s)}s`}getFileName(s,r){return r===m.e.FrontComponent?`${le(s)}.tsx`:`${le(s)}.ts`}}class su{async execute(s){const r=s.appPath??Z;await tn(r),console.log(y.default.blue("Building application...")),console.log(y.default.gray(`App path: ${r}
333
- `));const c=await m.appBuild({appPath:r,tarball:s.tarball,onProgress:f=>console.log(y.default.gray(f))});c.success||(console.error(y.default.red(c.error.message)),process.exit(1)),console.log(y.default.green(`✓ Build succeeded (${c.data.fileCount} file${c.data.fileCount===1?"":"s"})`)),console.log(y.default.gray(`Output: ${c.data.outputDir}`)),c.data.tarballPath&&console.log(y.default.gray(`Tarball: ${c.data.tarballPath}`))}}class au{async execute({appPath:s=Z,postInstall:r=!1,preInstall:c=!1,functionUniversalIdentifier:f,functionName:S,payload:E="{}"}){let C;try{C=JSON.parse(E)}catch{console.error(y.default.red("Invalid JSON payload. Please provide valid JSON.")),process.exit(1)}const P=r?"post install":c?"pre install":f??S,$=m.ConfigService.getActiveRemote();console.log(y.default.blue(`🚀 Executing function "${P}" on ${$}...`)),console.log(y.default.gray(` Payload: ${JSON.stringify(C)}
334
- `));const G=r?{appPath:s,postInstall:!0,payload:C}:c?{appPath:s,preInstall:!0,payload:C}:f?{appPath:s,functionUniversalIdentifier:f,payload:C}:{appPath:s,functionName:S,payload:C},Y=await m.functionExecute(G);if(!Y.success){switch(Y.error.code){case m.APP_ERROR_CODES.MANIFEST_NOT_FOUND:{console.error(y.default.red("Failed to build manifest."));break}case m.FUNCTION_ERROR_CODES.FETCH_FUNCTIONS_FAILED:{console.error(y.default.red("Failed to fetch functions:"),Y.error.message);break}case m.FUNCTION_ERROR_CODES.FUNCTION_NOT_FOUND:{console.error(y.default.red(Y.error.message),`
335
- `);const Ve=Y.error.details?.availableFunctions??[];Ve.length>0?(console.log(y.default.cyan("Available functions:")),Ve.forEach(Je=>{console.log(` - ${y.default.white(Je.name)} (${Je.universalIdentifier})`)})):console.log(y.default.yellow("No functions found for this application. Have you synced your app with `twenty dev`?"));break}case m.FUNCTION_ERROR_CODES.EXECUTION_FAILED:{console.error(y.default.red("Execution failed:"),Y.error.message);break}default:console.error(y.default.red(Y.error.message))}process.exit(1)}const se=Y.data;console.log(y.default.cyan("─".repeat(60))),console.log(y.default.cyan("Execution Result")),console.log(y.default.cyan("─".repeat(60)));const Fe=se.status==="SUCCESS"?y.default.green:y.default.red;console.log(`${y.default.bold("Status:")} ${Fe(se.status)}`),console.log(`${y.default.bold("Duration:")} ${se.duration}ms
336
- `),m.o(se.data)&&(console.log(y.default.bold("Data:")),console.log(y.default.white(JSON.stringify(se.data,null,2)))),se.error&&(console.log(y.default.bold.red("Error:")),console.log(y.default.red(` Type: ${se.error.errorType}`)),console.log(y.default.red(` Message: ${se.error.errorMessage}
337
- `)),se.error.stackTrace&&(console.log(y.default.gray("Stack trace:")),console.log(y.default.gray(se.error.stackTrace)))),se.logs&&(console.log(y.default.bold("Logs:")),console.log(y.default.gray(se.logs))),console.log(y.default.cyan("─".repeat(60))),se.status!=="SUCCESS"&&process.exit(1)}}class ou{constructor(){this.apiService=new m.ApiService}async execute({appPath:s=Z,functionUniversalIdentifier:r,functionName:c}){try{const f=await m.readManifestFromFile(s);f||process.exit(1),this.logWatchInfo({appName:f.application.displayName,functionUniversalIdentifier:r,functionName:c}),await this.apiService.subscribeToLogs({applicationUniversalIdentifier:f.application.universalIdentifier,functionUniversalIdentifier:r,functionName:c})}catch(f){console.error(y.default.red("Watch logs failed:"),f instanceof Error?f.message:f),process.exit(1)}}logWatchInfo({appName:s,functionUniversalIdentifier:r,functionName:c}){const f=s??"Twenty Application",S=r||c?`function "${r||c}"`:"functions",E=m.ConfigService.getActiveRemote();console.log(y.default.blue(`🚀 Watching ${f} ${S} logs on ${E}:
338
- `))}}const jm=l=>`${y.default.cyan(l.file)}:${y.default.yellow(String(l.line))}:${y.default.yellow(String(l.column+1))} - ${y.default.red("error")} ${l.text}`;class uu{async execute(s){const r=s.appPath??Z;console.log(y.default.blue("Running type check...")),console.log(y.default.gray(`App path: ${r}
339
- `));const c=await m.runTypecheck(r);c.length===0&&(console.log(y.default.green("✓ No type errors found")),process.exit(0));for(const f of c)console.log(jm(f));console.log(`
340
- `,y.default.red(`✗ Found ${c.length} type error${c.length===1?"":"s"}`)),process.exit(1)}}const nt=(l,s)=>console.warn(y.default.yellow(`⚠ \`twenty ${l}\` is deprecated. Use \`twenty ${s}\` instead.`)),Ym=l=>{const s=new su,r=new uu,c=new ou,f=new au,S=new iu,E=new tu,C=new nu,P=new ru;l.command("build [appPath]",{hidden:!0}).option("--tarball","Also pack into a .tgz tarball").action(async($,G)=>{nt("build","dev:build"),await s.execute({appPath:he($),tarball:G.tarball})}),l.command("typecheck [appPath]",{hidden:!0}).action(async $=>{nt("typecheck","dev:typecheck"),await r.execute({appPath:he($)})}),l.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($,G)=>{nt("logs","dev:function:logs"),await c.execute({...G,appPath:he($)})}),l.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($,G)=>{nt("exec","dev:function:exec"),!G?.postInstall&&!G?.preInstall&&!G?.functionUniversalIdentifier&&!G?.functionName&&(console.error(y.default.red("Error: Either --postInstall, --preInstall, --functionName (-n), or --functionUniversalIdentifier (-u) is required.")),process.exit(1)),await f.execute({...G,payload:G?.payload??"{}",appPath:he($)})}),l.command("add [entityType]",{hidden:!0}).option("--path <path>","Path in which the entity should be created.").action(async($,G)=>{nt("add","dev:add"),await S.execute($,G?.path)}),l.command("publish [appPath]",{hidden:!0}).option("--tag <tag>","npm dist-tag (e.g. beta, next)").action(async($,G)=>{nt("publish","app:publish"),await E.execute({appPath:he($),tag:G.tag})}),l.command("deploy [appPath]",{hidden:!0}).option("-r, --remote <name>","Deploy to a specific remote").action(async($,G)=>{nt("deploy","app:publish --private"),await E.execute({appPath:he($),private:!0,remote:G.remote})}),l.command("install [appPath]",{hidden:!0}).option("-r, --remote <name>","Install on a specific remote").action(async($,G)=>{nt("install","app:install"),await C.execute({appPath:he($),remote:G.remote})}),l.command("uninstall [appPath]",{hidden:!0}).option("-y, --yes","Skip confirmation prompt").action(async($,G)=>{nt("uninstall","app:uninstall");try{const Y=await P.execute({appPath:he($),askForConfirmation:!G?.yes});process.exit(Y.success?0:1)}catch{process.exit(1)}}),l.command("catalog-sync",{hidden:!0}).option("-r, --remote <name>","Sync on a specific remote").action(async $=>{nt("catalog-sync","dev:catalog-sync");const{CatalogSyncCommand:G}=await Promise.resolve().then(()=>require("./catalog-sync-BCebNxby.js"));await new G().execute({remote:$.remote})})};class Jm{constructor({state:s,notify:r}){this.state=s,this.notify=r}async execute(s){const r=this.state.steps.buildManifest;r.status="in_progress",this.state.updatePipeline({status:"building"});const c=[{message:"Building manifest",status:"info"}],f=await m.buildAndValidateManifest(s.appPath);if(!f.success){for(const E of f.errors)c.push({message:E,status:"error"});return r.output={result:null},r.status="error",this.state.updatePipeline({status:"error"}),this.state.applyStepEvents(c),null}if(f.warnings.length>0)for(const E of f.warnings)c.push({message:`⚠ ${E}`,status:"warning"});c.push({message:"Successfully built manifest",status:"success"});const S={manifest:f.manifest,filePaths:f.filePaths};return r.output={result:S},r.status="done",this.state.updatePipeline({appName:f.manifest.application.displayName}),this.state.updateEntitiesFromManifest(f.filePaths),this.state.applyStepEvents(c),S}}class Zm{constructor({apiService:s,state:r,notify:c}){this.hasRetried=!1,this.apiService=s,this.state=r,this.notify=c}async execute(){const s=this.state.steps.checkServer,r=await this.apiService.validateAuth();if(!r.serverUp){const f=await m.detectLocalServer();return f&&!this.hasRetried?(this.hasRetried=!0,await new m.ConfigService().setConfig({apiUrl:f}),this.execute()):(s.output.errorLogged||(s.output={isReady:!1,errorLogged:!0},s.status="error",this.state.applyStepEvents([{message:`Cannot reach Twenty server.
331
+ `},Jm=({universalIdentifier:u=X.v4()})=>`import {
332
+ defineViewField,
333
+ STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS,
334
+ } from 'twenty-sdk/define';
335
+
336
+ export default defineViewField({
337
+ universalIdentifier: '${u}',
338
+ // The universalIdentifier of the existing view to add this column to
339
+ viewUniversalIdentifier: 'STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS.<fill-later>.views.<fill-later>.universalIdentifier',
340
+ // The universalIdentifier of the field to display in that view
341
+ fieldMetadataUniversalIdentifier: '<fill-later>',
342
+ position: 0,
343
+ isVisible: true,
344
+ size: 150,
345
+ });
346
+ `,Zm="src/application.config.ts",xr="src";class ou{async execute(s,r){try{const c=s??await this.getEntity(),f=this.getFolderName(c),w=r?q.join(Z,r):q.join(Z,xr,f);await m.ensureDir(w);const{name:x,file:T}=await this.getEntityData(c),$=q.join(w,this.getFileName(x,c));if(await m.pathExists($)){const{overwrite:P}=await this.handleFileExist();if(!P)return}await nt.writeFile($,T),console.log(y.default.green(`✓ Created ${f}:`),y.default.cyan(q.relative(Z,$))),c===m.o$1.Object&&await this.promptAndCreateObjectCompanions(x,r),c===m.o$1.ConnectionProvider&&await this.registerConnectionProviderServerVariables(x)}catch(c){console.error(y.default.red("Add new entity failed:"),c instanceof Error?c.message:c),process.exit(1)}}async getEntityData(s){switch(s){case m.o$1.Object:{const r=await this.getObjectData(),c=r.nameSingular,f=X.v4(),w=X.v4();this.lastObjectUniversalIdentifier=f,this.lastNameFieldUniversalIdentifier=w,this.lastObjectLabelSingular=r.labelSingular;const x=Bm({data:r,universalIdentifier:f,nameFieldUniversalIdentifier:w});return{name:c,file:x}}case m.o$1.Field:{const r=await this.getFieldData(),c=r.name,f=Dm({data:r});return{name:c,file:f}}case m.o$1.LogicFunction:{const r=await this.getEntityName(s),c=Wm({name:r});return{name:r,file:c}}case m.o$1.FrontComponent:{const r=await this.getEntityName(s),c=Mm({name:r});return{name:r,file:c}}case m.o$1.Role:{const r=await this.getEntityName(s),c=Hm({name:r});return{name:r,file:c}}case m.o$1.Skill:{const r=await this.getEntityName(s),c=Km({name:r});return{name:r,file:c}}case m.o$1.Agent:{const r=await this.getEntityName(s),c=jm({name:r});return{name:r,file:c}}case m.o$1.ConnectionProvider:{const r=await this.getEntityName(s),c=zm({name:r});return{name:r,file:c}}case m.o$1.View:{const c=(await this.getViewData()).name,f=Ki({name:c});return{name:c,file:f}}case m.o$1.ViewField:{const r=await this.getEntityName(s),c=Jm({});return{name:r,file:c}}case m.o$1.NavigationMenuItem:{const r=await this.getEntityName(s),c=Wo({name:r});return{name:r,file:c}}case m.o$1.PageLayout:{const r=await this.getEntityName(s),c=Vm({name:r});return{name:r,file:c}}case m.o$1.PageLayoutTab:{const r=await this.getEntityName(s),c=Gm({name:r});return{name:r,file:c}}case m.o$1.CommandMenuItem:{const r=await this.getEntityName(s),c=km({name:r});return{name:r,file:c}}default:m.$()}}async promptAndCreateObjectCompanions(s,r){const{createCompanions:c}=await Ye.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;const f=X.v4(),w=X.v4(),x=Ki({name:`all-${le(s)}`,universalIdentifier:f,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,fields:this.lastNameFieldUniversalIdentifier?[{fieldMetadataUniversalIdentifier:this.lastNameFieldUniversalIdentifier,position:0,isVisible:!0,size:200}]:[]}),T=r?q.join(Z,r):q.join(Z,xr,this.getFolderName(m.o$1.View));await m.ensureDir(T);const $=`all-${le(s)}.ts`,P=q.join(T,$);if(await m.pathExists(P)){const{overwrite:ce}=await this.handleFileExist();if(!ce)return}await nt.writeFile(P,x),console.log(y.default.green("✓ Created view:"),y.default.cyan(q.relative(Z,P)));const G=this.buildRecordPageFieldsViewFields(this.lastNameFieldUniversalIdentifier),ne=Ki({name:`${le(s)}-record-page-fields`,universalIdentifier:w,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,type:m.TE.FIELDS_WIDGET,fields:G}),Y=`${le(s)}-record-page-fields.ts`,ht=q.join(T,Y);if(await m.pathExists(ht)){const{overwrite:ce}=await this.handleFileExist();if(!ce)return}await nt.writeFile(ht,ne),console.log(y.default.green("✓ Created record-page-fields view:"),y.default.cyan(q.relative(Z,ht)));const Be=Wo({name:s,type:"OBJECT",targetObjectUniversalIdentifier:this.lastObjectUniversalIdentifier}),Fe=r?q.join(Z,r):q.join(Z,xr,this.getFolderName(m.o$1.NavigationMenuItem));await m.ensureDir(Fe);const Mt=`${le(s)}.ts`,me=q.join(Fe,Mt);if(await m.pathExists(me)){const{overwrite:ce}=await this.handleFileExist();if(!ce)return}await nt.writeFile(me,Be),console.log(y.default.green("✓ Created navigation menu item:"),y.default.cyan(q.relative(Z,me)));const gt=qm({objectLabelSingular:this.lastObjectLabelSingular??s,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,fieldsWidgetViewUniversalIdentifier:w}),rn=r?q.join(Z,r):q.join(Z,xr,this.getFolderName(m.o$1.PageLayout));await m.ensureDir(rn);const ke=`${le(s)}-record-page-layout.ts`,rt=q.join(rn,ke);if(await m.pathExists(rt)){const{overwrite:ce}=await this.handleFileExist();if(!ce)return}await nt.writeFile(rt,gt),console.log(y.default.green("✓ Created record page layout:"),y.default.cyan(q.relative(Z,rt)))}async registerConnectionProviderServerVariables(s){const r=le(s).toUpperCase().replace(/-/g,"_"),c=[{name:`${r}_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:`${r}_CLIENT_SECRET`,description:"OAuth client secret issued by the third-party provider. Stored encrypted; never echoed in API responses.",isSecret:!0}],f=await Lm({projectRoot:Z,variables:c});switch(f.status){case"appended":case"created":{console.log(y.default.green(`✓ Added ${c.map(w=>w.name).join(" + ")} to defineApplication.serverVariables:`),y.default.cyan(q.relative(Z,f.file)));break}case"skipped-existing":console.log(y.default.dim(` (${c.map(w=>w.name).join(" / ")} already declared on defineApplication.serverVariables)`));break;case"skipped-no-config":case"skipped-no-app-call":console.log(y.default.yellow(`! Couldn't auto-update ${Zm}. Add these manually to defineApplication.serverVariables:
347
+ `+c.map(w=>` ${w.name}: { description: '...', isSecret: ${w.isSecret}, isRequired: true },`).join(`
348
+ `)));break}}buildRecordPageFieldsViewFields(s){const c=["createdAt","updatedAt","createdBy","updatedBy"].map(w=>({defaultFieldName:w,isVisible:!0,size:200}));return(s?[{fieldMetadataUniversalIdentifier:s,isVisible:!0,size:200},...c]:c).map((w,x)=>({...w,position:x}))}async getEntity(){const{entity:s}=await Ye.default.prompt([{type:"select",name:"entity",message:"What entity do you want to create?",default:"",choices:Object.values(m.o$1)}]);return s}async handleFileExist(){return await Ye.default.prompt([{type:"confirm",name:"overwrite",message:"File already exists. Do you want to overwrite it?",default:!1}])}async getEntityName(s){const{name:r}=await Ye.default.prompt([{type:"input",name:"name",message:`Enter a name for your new ${s}:`,default:"",validate:c=>c.length===0?`${s} name is required`:!0}]);return r}async getFieldData(){return Ye.default.prompt([{type:"input",name:"name",message:"Enter a name for your field:",default:"",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"label",message:"Enter a label for your field:",default:s=>zi(s.name),validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"select",name:"type",message:"Select the field type:",choices:Object.values(m.R),default:m.R.TEXT},{type:"input",name:"objectUniversalIdentifier",message:"Enter the universalIdentifier of the object this field belongs to:",default:"fill-later",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"description",message:"Enter a description for your field (optional):",default:""}])}async getObjectData(){return Ye.default.prompt([{type:"input",name:"nameSingular",message:"Enter a name singular for your object (eg: company):",default:"",validate:s=>!s||s.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:(s,r)=>s.trim()===r?.nameSingular.trim()?"Name plural must be different from name singular":!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"labelSingular",message:"Enter a label singular for your object:",default:s=>zi(s.nameSingular),validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"labelPlural",message:"Enter a label plural for your object:",default:s=>zi(s.namePlural),validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0}])}async getViewData(){return Ye.default.prompt([{type:"input",name:"name",message:"Enter a name for your view:",default:"",validate:s=>!s||s.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:s=>!s||s.trim().length===0?"Please enter a non empty string":!0}])}getFolderName(s){return`${le(s)}s`}getFileName(s,r){return r===m.o$1.FrontComponent?`${le(s)}.tsx`:`${le(s)}.ts`}}class uu{async execute(s){const r=s.appPath??Z;await tn(r),console.log(y.default.blue("Building application...")),console.log(y.default.gray(`App path: ${r}
349
+ `));const c=await m.appBuild({appPath:r,tarball:s.tarball,onProgress:f=>console.log(y.default.gray(f))});c.success||(console.error(y.default.red(c.error.message)),process.exit(1)),console.log(y.default.green(`✓ Build succeeded (${c.data.fileCount} file${c.data.fileCount===1?"":"s"})`)),console.log(y.default.gray(`Output: ${c.data.outputDir}`)),c.data.tarballPath&&console.log(y.default.gray(`Tarball: ${c.data.tarballPath}`))}}class lu{async execute({appPath:s=Z,postInstall:r=!1,preInstall:c=!1,functionUniversalIdentifier:f,functionName:w,payload:x="{}"}){let T;try{T=JSON.parse(x)}catch{console.error(y.default.red("Invalid JSON payload. Please provide valid JSON.")),process.exit(1)}const $=r?"post install":c?"pre install":f??w,P=m.ConfigService.getActiveRemote();console.log(y.default.blue(`🚀 Executing function "${$}" on ${P}...`)),console.log(y.default.gray(` Payload: ${JSON.stringify(T)}
350
+ `));const G=r?{appPath:s,postInstall:!0,payload:T}:c?{appPath:s,preInstall:!0,payload:T}:f?{appPath:s,functionUniversalIdentifier:f,payload:T}:{appPath:s,functionName:w,payload:T},ne=await m.functionExecute(G);if(!ne.success){switch(ne.error.code){case m.APP_ERROR_CODES.MANIFEST_NOT_FOUND:{console.error(y.default.red("Failed to build manifest."));break}case m.FUNCTION_ERROR_CODES.FETCH_FUNCTIONS_FAILED:{console.error(y.default.red("Failed to fetch functions:"),ne.error.message);break}case m.FUNCTION_ERROR_CODES.FUNCTION_NOT_FOUND:{console.error(y.default.red(ne.error.message),`
351
+ `);const Be=ne.error.details?.availableFunctions??[];Be.length>0?(console.log(y.default.cyan("Available functions:")),Be.forEach(Fe=>{console.log(` - ${y.default.white(Fe.name)} (${Fe.universalIdentifier})`)})):console.log(y.default.yellow("No functions found for this application. Have you synced your app with `twenty dev`?"));break}case m.FUNCTION_ERROR_CODES.EXECUTION_FAILED:{console.error(y.default.red("Execution failed:"),ne.error.message);break}default:console.error(y.default.red(ne.error.message))}process.exit(1)}const Y=ne.data;console.log(y.default.cyan("─".repeat(60))),console.log(y.default.cyan("Execution Result")),console.log(y.default.cyan("─".repeat(60)));const ht=Y.status==="SUCCESS"?y.default.green:y.default.red;console.log(`${y.default.bold("Status:")} ${ht(Y.status)}`),console.log(`${y.default.bold("Duration:")} ${Y.duration}ms
352
+ `),m.o(Y.data)&&(console.log(y.default.bold("Data:")),console.log(y.default.white(JSON.stringify(Y.data,null,2)))),Y.error&&(console.log(y.default.bold.red("Error:")),console.log(y.default.red(` Type: ${Y.error.errorType}`)),console.log(y.default.red(` Message: ${Y.error.errorMessage}
353
+ `)),Y.error.stackTrace&&(console.log(y.default.gray("Stack trace:")),console.log(y.default.gray(Y.error.stackTrace)))),Y.logs&&(console.log(y.default.bold("Logs:")),console.log(y.default.gray(Y.logs))),console.log(y.default.cyan("─".repeat(60))),Y.status!=="SUCCESS"&&process.exit(1)}}class cu{constructor(){this.apiService=new m.ApiService}async execute({appPath:s=Z,functionUniversalIdentifier:r,functionName:c}){try{const f=await m.readManifestFromFile(s);f||process.exit(1),this.logWatchInfo({appName:f.application.displayName,functionUniversalIdentifier:r,functionName:c}),await this.apiService.subscribeToLogs({applicationUniversalIdentifier:f.application.universalIdentifier,functionUniversalIdentifier:r,functionName:c})}catch(f){console.error(y.default.red("Watch logs failed:"),f instanceof Error?f.message:f),process.exit(1)}}logWatchInfo({appName:s,functionUniversalIdentifier:r,functionName:c}){const f=s??"Twenty Application",w=r||c?`function "${r||c}"`:"functions",x=m.ConfigService.getActiveRemote();console.log(y.default.blue(`🚀 Watching ${f} ${w} logs on ${x}:
354
+ `))}}const Xm=u=>`${y.default.cyan(u.file)}:${y.default.yellow(String(u.line))}:${y.default.yellow(String(u.column+1))} - ${y.default.red("error")} ${u.text}`;class fu{async execute(s){const r=s.appPath??Z;console.log(y.default.blue("Running type check...")),console.log(y.default.gray(`App path: ${r}
355
+ `));const c=await m.runTypecheck(r);c.length===0&&(console.log(y.default.green("✓ No type errors found")),process.exit(0));for(const f of c)console.log(Xm(f));console.log(`
356
+ `,y.default.red(`✗ Found ${c.length} type error${c.length===1?"":"s"}`)),process.exit(1)}}const tt=(u,s)=>console.warn(y.default.yellow(`⚠ \`twenty ${u}\` is deprecated. Use \`twenty ${s}\` instead.`)),Qm=u=>{const s=new uu,r=new fu,c=new cu,f=new lu,w=new ou,x=new iu,T=new su,$=new au;u.command("build [appPath]",{hidden:!0}).option("--tarball","Also pack into a .tgz tarball").action(async(P,G)=>{tt("build","dev:build"),await s.execute({appPath:ge(P),tarball:G.tarball})}),u.command("typecheck [appPath]",{hidden:!0}).action(async P=>{tt("typecheck","dev:typecheck"),await r.execute({appPath:ge(P)})}),u.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(P,G)=>{tt("logs","dev:function:logs"),await c.execute({...G,appPath:ge(P)})}),u.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(P,G)=>{tt("exec","dev:function:exec"),!G?.postInstall&&!G?.preInstall&&!G?.functionUniversalIdentifier&&!G?.functionName&&(console.error(y.default.red("Error: Either --postInstall, --preInstall, --functionName (-n), or --functionUniversalIdentifier (-u) is required.")),process.exit(1)),await f.execute({...G,payload:G?.payload??"{}",appPath:ge(P)})}),u.command("add [entityType]",{hidden:!0}).option("--path <path>","Path in which the entity should be created.").action(async(P,G)=>{tt("add","dev:add"),await w.execute(P,G?.path)}),u.command("publish [appPath]",{hidden:!0}).option("--tag <tag>","npm dist-tag (e.g. beta, next)").action(async(P,G)=>{tt("publish","app:publish"),await x.execute({appPath:ge(P),tag:G.tag})}),u.command("deploy [appPath]",{hidden:!0}).option("-r, --remote <name>","Deploy to a specific remote").action(async(P,G)=>{tt("deploy","app:publish --private"),await x.execute({appPath:ge(P),private:!0,remote:G.remote})}),u.command("install [appPath]",{hidden:!0}).option("-r, --remote <name>","Install on a specific remote").action(async(P,G)=>{tt("install","app:install"),await T.execute({appPath:ge(P),remote:G.remote})}),u.command("uninstall [appPath]",{hidden:!0}).option("-y, --yes","Skip confirmation prompt").action(async(P,G)=>{tt("uninstall","app:uninstall");try{const ne=await $.execute({appPath:ge(P),askForConfirmation:!G?.yes});process.exit(ne.success?0:1)}catch{process.exit(1)}}),u.command("catalog-sync",{hidden:!0}).option("-r, --remote <name>","Sync on a specific remote").action(async P=>{tt("catalog-sync","dev:catalog-sync");const{CatalogSyncCommand:G}=await Promise.resolve().then(()=>require("./catalog-sync-BjFX6eQu.js"));await new G().execute({remote:P.remote})})};class ev{constructor({state:s,notify:r}){this.state=s,this.notify=r}async execute(s){const r=this.state.steps.buildManifest;r.status="in_progress",this.state.updatePipeline({status:"building"});const c=[{message:"Building manifest",status:"info"}],f=await m.buildAndValidateManifest(s.appPath);if(!f.success){for(const x of f.errors)c.push({message:x,status:"error"});return r.output={result:null},r.status="error",this.state.updatePipeline({status:"error"}),this.state.applyStepEvents(c),null}if(f.warnings.length>0)for(const x of f.warnings)c.push({message:`⚠ ${x}`,status:"warning"});c.push({message:"Successfully built manifest",status:"success"});const w={manifest:f.manifest,filePaths:f.filePaths};return r.output={result:w},r.status="done",this.state.updatePipeline({appName:f.manifest.application.displayName}),this.state.updateEntitiesFromManifest(f.filePaths),this.state.applyStepEvents(c),w}}class tv{constructor({apiService:s,state:r,notify:c}){this.hasRetried=!1,this.apiService=s,this.state=r,this.notify=c}async execute(){const s=this.state.steps.checkServer,r=await this.apiService.validateAuth();if(!r.serverUp){const f=await m.detectLocalServer();return f&&!this.hasRetried?(this.hasRetried=!0,await new m.ConfigService().setConfig({apiUrl:f}),this.execute()):(s.output.errorLogged||(s.output={isReady:!1,errorLogged:!0},s.status="error",this.state.applyStepEvents([{message:`Cannot reach Twenty server.
341
357
 
342
358
  Start a local server:
343
359
  yarn twenty docker:start
@@ -345,9 +361,10 @@ ${P}
345
361
  Check server status:
346
362
  yarn twenty docker:status
347
363
 
348
- Waiting for server...`,status:"error"}]),this.state.updatePipeline({status:"error"})),!1)}if(!r.authValid)return s.output.errorLogged||(s.output={isReady:!1,errorLogged:!0},s.status="error",this.state.applyStepEvents([{message:"Authentication failed. Run `yarn twenty remote:add --local` to authenticate.",status:"error"}]),this.state.updatePipeline({status:"error"})),!1;const c=s.output.isReady;if(s.output={isReady:!0,errorLogged:!1},s.status="done",!m.o(this.state.frontendUrl)){const f=await this.apiService.getWorkspaceFrontendUrl();m.o(f)&&(this.state.frontendUrl=f)}return c||this.notify(),!0}}class Xm{constructor({clientService:s,configService:r,state:c,notify:f}){this.clientService=s,this.configService=r,this.state=c,this.notify=f}async execute(s){const r=this.state.steps.generateApiClient;r.status="in_progress",this.notify();try{const c=await m.ensureAppAccessTokenIsValidOrRefresh(this.configService,s.credentials);await this.clientService.generateCoreClient({appPath:s.appPath,appAccessToken:c}),r.status="done"}catch(c){this.state.applyStepEvents([{message:`Failed to generate API client: ${c instanceof Error?c.message:String(c)}`,status:"error"}]),r.status="error"}this.notify()}}class Qm{constructor({apiService:s,configService:r,state:c,notify:f}){this.apiService=s,this.configService=r,this.state=c,this.notify=f}async execute(s){try{const r=await m.ensureAppRegistration(this.apiService,this.configService,{name:s.manifest.application.displayName,universalIdentifier:s.manifest.application.universalIdentifier});this.registrationCredentials={clientId:r.clientId,clientSecret:r.clientSecret},this.state.applyStepEvents([{message:r.isNewRegistration?`App registration created: ${s.manifest.application.displayName}`:"Existing app registration found",status:r.isNewRegistration?"success":"info"},...r.isNewRegistration?[{message:"Credentials saved to config.",status:"info"}]:[]])}catch(r){throw this.state.applyStepEvents([{message:`Failed to register app: ${r instanceof Error?r.message:String(r)}`,status:"error"}]),r}this.notify()}}class Do{constructor(s){this.watcher=null,this.appPath=s.appPath,this.fileFolder=s.fileFolder,this.watchPaths=s.watchPaths,this.handleFileBuilt=s.handleFileBuilt}async start(){const s=(await Promise.all(this.watchPaths.map(async r=>{const c=q.join(this.appPath,r);return await m.pathExists(c)?c:null}))).filter(r=>r!==null);s.length!==0&&(this.watcher=Qo.default.watch(s,{awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on("all",(r,c)=>{r==="addDir"||r==="unlinkDir"||((r==="add"||r==="change")&&this.copyAndNotify(c),r==="unlink"&&this.handleUnlink(c))}))}async close(){await this.watcher?.close()}async copyAndNotify(s){const r=q.relative(this.appPath,s),c=q.join(m.u,r),f=q.join(this.appPath,c);await m.ensureDir(q.dirname(f)),await m.copy(s,f);const S=await rt.readFile(f),E=xm.default.createHash("md5").update(S).digest("hex");this.handleFileBuilt({fileFolder:this.fileFolder,builtPath:c,sourcePath:r,checksum:E})}async handleUnlink(s){const r=q.relative(this.appPath,s),c=q.join(m.u,r),f=q.join(this.appPath,c);await m.remove(f)}}class ev{constructor(s){this.process=null,this.pendingErrors=[],this.buffer="",this.hasErrors=!1,this.appPath=s.appPath,this.onErrors=s.onErrors}async start(){const s=Lo.default.join(this.appPath,"node_modules",".bin","tsc");if(!await m.pathExists(s))return;const r=Lo.default.join(this.appPath,"tsconfig.json");this.process=Tn.spawn(s,["--watch","--noEmit","--pretty","false","-p",r],{cwd:this.appPath,stdio:["ignore","pipe","pipe"]}),this.process.on("error",()=>{this.process=null}),this.process.stdout?.on("data",c=>{this.handleOutput(c.toString())}),this.process.stderr?.on("data",c=>{this.handleOutput(c.toString())})}close(){this.process?.kill(),this.process=null}handleOutput(s){this.buffer+=s;const r=this.buffer.split(`
349
- `);this.buffer=r.pop()??"";for(const c of r)this.processLine(c)}processLine(s){if(s.includes("Starting compilation in watch mode...")||s.includes("Starting incremental compilation...")){this.pendingErrors=[];return}if(s.includes("Watching for file changes.")){const c=this.hasErrors;this.hasErrors=this.pendingErrors.length>0,(this.hasErrors||c)&&this.onErrors(this.pendingErrors),this.pendingErrors=[];return}const r=m.parseTscOutputLine(s);r&&this.pendingErrors.push(r)}}const tv=new Set(["node_modules","dist",".twenty"]);class nv{constructor(s){this.watcher=null,this.appPath=s.appPath,this.handleChangeDetected=s.handleChangeDetected,this.verbose=s.verbose??!1}async start(){const s=this.appPath;this.watcher=Qo.default.watch(this.appPath,{ignoreInitial:!this.verbose,ignored:r=>{const c=q.relative(s,r);if(c==="")return!1;const f=c.split(Ji.default.sep)[0];return tv.has(f)||f.startsWith(".")},awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on("all",(r,c)=>{if(r==="addDir"||r==="unlinkDir")return;const f=q.relative(this.appPath,c),S=f.startsWith(m._),E=["package.json","yarn.lock"].includes(f);!(f.endsWith(".ts")||f.endsWith(".tsx"))&&!S&&!E||this.handleChangeDetected(f,r)})}async close(){await this.watcher?.close()}}class rv{constructor(s){this.manifestWatcher=null,this.logicFunctionsWatcher=null,this.frontComponentsWatcher=null,this.assetWatcher=null,this.dependencyWatcher=null,this.tscWatcher=null,this.state=s.state,this.scheduleSync=s.scheduleSync,this.notify=s.notify,this.onFileBuilt=s.onFileBuilt,this.shouldSkipTypecheck=s.shouldSkipTypecheck,this.verbose=s.verbose??!1}async start(){this.state.steps.startWatchers.status="in_progress",this.notify(),this.manifestWatcher=new nv({appPath:this.state.appPath,handleChangeDetected:this.handleChangeDetected.bind(this),verbose:this.verbose}),await this.manifestWatcher.start()}async handleWatcherRestarts(s){const{logicFunctions:r,frontComponents:c}=s.filePaths;if(!this.state.steps.startWatchers.output.watchersStarted){this.state.steps.startWatchers.output.watchersStarted=!0,this.state.steps.startWatchers.status="done",await this.startFileWatchers(r,c);return}this.logicFunctionsWatcher?.shouldRestart(r)&&await this.logicFunctionsWatcher.restart(r),this.frontComponentsWatcher?.shouldRestart(c)&&await this.frontComponentsWatcher.restart(c)}async close(){this.tscWatcher?.close(),await Promise.all([this.manifestWatcher?.close(),this.logicFunctionsWatcher?.close(),this.frontComponentsWatcher?.close(),this.assetWatcher?.close(),this.dependencyWatcher?.close()])}handleChangeDetected(s,r){this.state.addEvent({message:`Change detected: ${s}`,status:"info"}),r==="unlink"?this.state.removeEntity(s):this.state.updateEntityStatus(s,"building"),this.notify(),this.scheduleSync()}handleFileBuildError(s){this.state.addEvent({message:"Build failed:",status:"error"});for(const r of s)this.state.addEvent({message:r.error,status:"error"});this.notify()}handleFileBuilt(s){this.verbose&&this.state.addEvent({message:`Successfully built ${s.builtPath}`,status:"success"}),this.state.steps.uploadFiles.output.builtFileInfos.set(s.builtPath,{checksum:s.checksum,builtPath:s.builtPath,sourcePath:s.sourcePath,fileFolder:s.fileFolder,usesSdkClient:s.usesSdkClient}),this.onFileBuilt(s),this.notify(),this.scheduleSync()}async startFileWatchers(s,r){await Promise.all([this.startTscWatcher(),this.startLogicFunctionsWatcher(s),this.startFrontComponentsWatcher(r),this.startAssetWatcher(),this.startDependencyWatcher()])}async startLogicFunctionsWatcher(s){this.logicFunctionsWatcher=m.createLogicFunctionsWatcher({appPath:this.state.appPath,sourcePaths:s,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.logicFunctionsWatcher.start()}async startFrontComponentsWatcher(s){this.frontComponentsWatcher=m.createFrontComponentsWatcher({appPath:this.state.appPath,sourcePaths:s,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.frontComponentsWatcher.start()}async startAssetWatcher(){this.assetWatcher=new Do({appPath:this.state.appPath,fileFolder:m.b.PublicAsset,watchPaths:[m._],handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.assetWatcher.start()}async startDependencyWatcher(){this.dependencyWatcher=new Do({appPath:this.state.appPath,fileFolder:m.b.Dependencies,watchPaths:["package.json","yarn.lock"],handleFileBuilt:this.handleFileBuilt.bind(this)}),this.dependencyWatcher.start()}async startTscWatcher(){this.tscWatcher=new ev({appPath:this.state.appPath,onErrors:this.handleTypecheckErrors.bind(this)}),await this.tscWatcher.start()}handleTypecheckErrors(s){s.length===0?this.state.addEvent({message:"Typecheck passed",status:"success"}):this.state.applyStepEvents(s.map(r=>({message:`Type error in ${r.file}(${r.line},${r.column}): ${r.text}`,status:"error"}))),this.notify()}}class iv{constructor({apiService:s,state:r,notify:c,verbose:f}){this.apiService=s,this.state=r,this.notify=c,this.verbose=f??!1}async execute(s){const r=this.state.steps.syncApplication;r.status="in_progress",this.state.updatePipeline({status:"syncing"});const c=[],f=m.manifestUpdateChecksums({manifest:s.manifest,builtFileInfos:s.builtFileInfos});c.push({message:"Manifest checksums set",status:"info"}),await m.writeManifestToOutput(s.appPath,f),c.push({message:"Manifest saved to output directory",status:"info"}),c.push({message:"Syncing manifest",status:"info"});const S=await this.apiService.syncApplication(f);if(S.success){c.push({message:"✓ Synced",status:"success"}),r.output={syncStatus:"synced",error:null},r.status="done",this.state.updatePipeline({status:"synced",error:null}),this.state.updateAllEntitiesStatus("success"),this.state.applyStepEvents(c);return}const E=this.verbose?null:m.formatManifestValidationErrors(S.error);E?(c.push(...E),c.push({message:"Add --verbose to see full error log",status:"info"})):c.push({message:`Sync failed with error: ${m.serializeError(S.error)}`,status:"error"});const C=E?E[0].message:"Sync failed";r.output={syncStatus:"error",error:C},r.status="error",this.state.updatePipeline({status:"error",error:C}),this.state.updateAllEntitiesStatus("error"),this.state.applyStepEvents(c)}}class sv{constructor({state:s,notify:r,verbose:c}){this.uploadedCount=0,this.failedCount=0,this.totalQueued=0,this.state=s,this.notify=r,this.verbose=c??!1}get isInitialized(){return m.o(this.state.steps.uploadFiles.output.fileUploader)}initialize(s){const r=this.state.steps.uploadFiles;r.output={...r.output,fileUploader:new m.FileUploader({appPath:s.appPath,applicationUniversalIdentifier:s.universalIdentifier})},r.status="in_progress",this.notify(),this.uploadPendingFiles()}uploadFile(s,r,c){const f=this.state.steps.uploadFiles;if(!f.output.fileUploader)return;f.status="in_progress",this.totalQueued++,this.verbose&&this.state.addEvent({message:`Uploading ${s}`,status:"info"}),this.state.updateEntityStatus(r,"uploading"),this.notify();const S=f.output.fileUploader.uploadFile({builtPath:s,fileFolder:c}).then(E=>{E.success?(this.uploadedCount++,this.verbose&&this.state.addEvent({message:`Successfully uploaded ${s}`,status:"success"}),this.state.updateEntityStatus(r,"success")):(this.failedCount++,this.state.addEvent({message:`Failed to upload ${s}: ${E.error}`,status:"error"}))}).catch(E=>{this.failedCount++,this.state.addEvent({message:`Upload failed for ${s}: ${E}`,status:"error"})}).finally(()=>{f.output.activeUploads.delete(S),f.output.activeUploads.size===0&&(this.logUploadSummary(),f.status="done",this.notify())});f.output.activeUploads.add(S)}async waitForUploads(){const s=this.state.steps.uploadFiles;for(;s.output.activeUploads.size>0;)await Promise.all(s.output.activeUploads);s.status="done",this.notify()}logUploadSummary(){if(this.totalQueued===0){this.resetCounters();return}this.failedCount>0&&this.state.addEvent({message:`Uploaded ${this.uploadedCount}/${this.totalQueued} files (${this.failedCount} failed)`,status:"error"}),this.state.addEvent({message:`Successfully uploaded ${this.uploadedCount} file${this.uploadedCount!==1?"s":""}`,status:"success"}),this.resetCounters()}resetCounters(){this.uploadedCount=0,this.failedCount=0,this.totalQueued=0}uploadPendingFiles(){for(const[s,{fileFolder:r,sourcePath:c}]of this.state.steps.uploadFiles.output.builtFileInfos.entries())this.uploadFile(s,c,r)}}class av{constructor(s){this.syncTimer=null,this.serverCheckInterval=null,this.skipTypecheck=!0,this.debounceMs=s.debounceMs??2e3,this.state=s.state,this.verbose=s.verbose??!1,this.apiService=new m.ApiService({disableInterceptors:!0});const r=this.apiService,c=new m.ConfigService;this.clientService=new m.ClientService;const f={state:this.state,notify:()=>this.state.notify()};this.checkServerStep=new Zm({...f,apiService:r}),this.buildManifestStep=new Jm(f),this.registerAppStep=new Qm({...f,apiService:r,configService:c}),this.uploadFilesStep=new sv({...f,verbose:this.verbose}),this.generateApiClientStep=new Xm({...f,clientService:this.clientService,configService:c}),this.syncApplicationStep=new iv({...f,apiService:r,verbose:this.verbose}),this.startWatchersStep=new rv({...f,scheduleSync:this.scheduleSync.bind(this),onFileBuilt:this.handleFileBuilt.bind(this),shouldSkipTypecheck:()=>this.skipTypecheck,verbose:this.verbose})}async start(){const s=Ji.default.join(this.state.appPath,m.u);await m.ensureDir(s),await m.emptyDir(s),this.state.addEvent({message:`Using remote "${m.ConfigService.getActiveRemote()}"`,status:"info"}),this.verbose||this.state.addEvent({message:"Add --verbose to see fully detailed logs",status:"info"}),this.state.notify(),await this.startWatchersStep.start(),this.serverCheckInterval=setInterval(()=>{this.checkServerHealth()},2e3)}async close(){this.serverCheckInterval&&clearInterval(this.serverCheckInterval),await this.startWatchersStep.close()}getState(){return this.state}handleFileBuilt(s){this.state.steps.uploadFiles.output.fileUploader&&this.uploadFilesStep.uploadFile(s.builtPath,s.sourcePath,s.fileFolder)}async checkServerHealth(){const s=this.state.steps.checkServer.output.isReady;await this.checkServerStep.execute()&&!s&&this.scheduleSync()}scheduleSync(){this.syncTimer&&clearTimeout(this.syncTimer),this.syncTimer=setTimeout(()=>{this.syncTimer=null,this.performSync()},this.debounceMs)}async performSync(){if(!this.state.pipeline.isSyncing){this.state.updatePipeline({isSyncing:!0});try{await this.runSyncPipeline()}catch(s){this.state.addEvent({message:`Sync failed with error: ${m.serializeError(s)}`,status:"error"}),this.state.updatePipeline({status:"error"}),this.state.updateAllEntitiesStatus("error")}finally{this.state.updatePipeline({isSyncing:!1})}}}async runSyncPipeline(){if(!await this.checkServerStep.execute())return;this.state.steps.ensureValidTokens.status="done";const r=await this.buildManifestStep.execute({appPath:this.state.appPath});if(!r||(await this.startWatchersStep.handleWatcherRestarts(r),!this.uploadFilesStep.isInitialized&&!await this.initializePipeline(r.manifest)))return;const c=this.state.hasObjectsOrFieldsChanged(r.manifest);await this.uploadFilesStep.waitForUploads(),await this.syncApplicationStep.execute({manifest:r.manifest,builtFileInfos:this.state.steps.uploadFiles.output.builtFileInfos,appPath:this.state.appPath}),this.state.steps.syncApplication.status!=="error"&&c&&(await this.generateApiClientStep.execute({appPath:this.state.appPath,credentials:this.registerAppStep.registrationCredentials}),this.skipTypecheck=!1)}async initializePipeline(s){await this.registerAppStep.execute({manifest:s});const r=await this.apiService.createDevelopmentApplication({universalIdentifier:s.application.universalIdentifier,name:s.application.displayName});return!r.success||!r.data?(this.state.applyStepEvents([{message:"Failed to install development application",status:"error"},{message:JSON.stringify(r,null,2),status:"error"}]),this.state.updatePipeline({status:"error"}),!1):(this.state.steps.resolveApplication.output={applicationId:r.data.id,universalIdentifier:r.data.universalIdentifier},this.state.steps.resolveApplication.status="done",this.state.applyStepEvents([{message:"Application installed",status:"success"}]),this.uploadFilesStep.initialize({appPath:this.state.appPath,universalIdentifier:s.application.universalIdentifier}),!0)}}const ov={objects:m.e.Object,fields:m.e.Field,logicFunctions:m.e.LogicFunction,frontComponents:m.e.FrontComponent,roles:m.e.Role,skills:m.e.Skill,connectionProviders:m.e.ConnectionProvider,views:m.e.View,navigationMenuItems:m.e.NavigationMenuItem,pageLayouts:m.e.PageLayout,pageLayoutTabs:m.e.PageLayoutTab,commandMenuItems:m.e.CommandMenuItem},uv=200,lv={pending:["building","uploading","success","error"],building:["pending","uploading","success","error"],uploading:["pending","success","error"],success:["pending","building","uploading","error"],error:["pending","building","uploading","success"]};class cv{constructor(s){this.eventIdCounter=0,this.appPath=s.appPath,this.previousObjectsFieldsFingerprint=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(s){this.versionInfo=s,this.notify()}notify(){this.onChange?.()}updatePipeline(s){Object.assign(this.pipeline,s),this.notify()}applyStepEvents(s){const r=s.map(c=>(this.eventIdCounter+=1,{...c,id:this.eventIdCounter,timestamp:new Date,message:c.message.slice(0,5e3)}));this.events=[...this.events.slice(-(uv-r.length)),...r]}addEvent(s){this.applyStepEvents([s])}updateEntityStatus(s,r){const c=new Map(this.entities),f=c.get(s);f?.status&&!lv[f.status].includes(r)||(c.set(s,f?{...f,status:r}:{name:s,path:s,status:r}),this.entities=c)}removeEntity(s){const r=new Map(this.entities);r.delete(s),this.entities=r}updateAllEntitiesStatus(s){const r=new Map(this.entities);for(const[c,f]of r)r.set(c,{...f,status:s});this.entities=r}updateEntitiesFromManifest(s){const r=new Map;for(const[f,S]of Object.entries(s)){const E=ov[f];if(E)for(const C of S)r.set(C,E)}const c=new Map(this.entities);for(const[f,S]of c)c.set(f,{...S,type:r.get(f)});for(const[f,S]of r)c.has(f)||c.set(f,{name:f,path:f,type:S,status:"pending"});this.entities=c}hasObjectsOrFieldsChanged(s){const r=JSON.stringify({objects:s.objects,fields:s.fields}),c=r!==this.previousObjectsFieldsFingerprint;return this.previousObjectsFieldsFingerprint=r,c}}const ke={idle:{color:"gray",icon:"○"},in_progress:{color:"yellow",icon:"spinner"},uploading:{color:"cyan",icon:"upload"},done:{color:"green",icon:"✓"},error:{color:"red",icon:"✗"}},fv=l=>({idle:"idle",in_progress:"in_progress",done:"done",error:"error"})[l],dv=l=>({pending:"idle",building:"in_progress",uploading:"uploading",success:"done",error:"error"})[l],pv=l=>({idle:"idle",building:"in_progress",syncing:"in_progress",synced:"done",error:"error"})[l],hv={idle:"Idle",building:"Building...",syncing:"Syncing...",synced:"Synced",error:"Error"},ji=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],Yi=["↑","⇡","↟","⤒"],lu={[m.e.Object]:"Objects",[m.e.Field]:"Fields",[m.e.LogicFunction]:"Logic functions",[m.e.FrontComponent]:"Front components",[m.e.CommandMenuItem]:"Command menu items",[m.e.Role]:"Roles",[m.e.Skill]:"Skills",[m.e.View]:"Views",[m.e.NavigationMenuItem]:"Navigation menu items",[m.e.PageLayout]:"Page layouts",[m.e.PageLayoutTab]:"Page layout tabs",[m.e.Agent]:"Agents",[m.e.ConnectionProvider]:"Connection providers"},cu=Object.keys(lu),gv={info:"gray",success:"green",error:"red",warning:"yellow"},mv=l=>l.toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),vv=(l,s=40)=>{if(l.length<=s)return l;const r=l.split("/");return r.length<=2?l:`.../${r.slice(-2).join("/")}`},yv=l=>{const s=new Map;for(const r of cu)s.set(r,[]);for(const r of l.values()){if(!r.type)continue;const c=s.get(r.type)??[];c.push(r),s.set(r.type,c)}return s},_v=l=>{const s=l.steps.resolveApplication.output.applicationId;return!m.o(l.frontendUrl)||!m.o(s)?null:`${l.frontendUrl}/settings/applications/${s}`},wv=l=>l.some(s=>s==="error")?"error":l.some(s=>s==="in_progress")?"in_progress":l.every(s=>s==="done")?"done":"idle",Sv=l=>{const s=[...l.entities.values()],r=s.some(E=>E.status==="error"),c=s.some(E=>E.status==="building"),f=s.length>0&&s.every(E=>E.status==="uploading"||E.status==="success"),S=r?"error":c?"in_progress":f?"done":"idle";return[{label:"Application Initialization",status:wv([l.steps.checkServer.status,l.steps.ensureValidTokens.status,l.steps.resolveApplication.status])},{label:"Resources Build",status:S},{label:"Resources Upload",status:l.steps.uploadFiles.status},{label:"Manifest Build",status:l.steps.buildManifest.status},{label:"Application Synchronization",status:l.steps.syncApplication.status},{label:"Api Client Generation",status:l.steps.generateApiClient.status}]},fu=120,xv=Math.round(200/fu),Mo=()=>{const l=Math.floor(Date.now()/fu);return{spinnerFrame:ji[l%ji.length],uploadFrame:Yi[Math.floor(l/xv)%Yi.length]}},Zi=l=>{const s=ke[l];return s.icon==="spinner"?Mo().spinnerFrame:s.icon==="upload"?Mo().uploadFrame:s.icon},du=eu.default.createContext(null),Iv=du.Provider,it=()=>{const l=eu.default.useContext(du);if(!l)throw new Error("useInk must be used within InkProvider");return l},Ev=({uiStatus:l})=>{const{Text:s}=it(),r=Zi(l),c=ke[l];return T.jsxs(s,{color:c.color,children:[r," "]})},Av=({entity:l})=>{const{Box:s,Text:r}=it();return T.jsxs(s,{children:[T.jsx(Ev,{uiStatus:dv(l.status)}),T.jsx(r,{children:l.name}),l.path!==l.name&&T.jsxs(r,{dimColor:!0,children:[" (",vv(l.path),")"]})]})},bv=({type:l,entities:s})=>{const{Box:r,Text:c}=it();return s.length===0?null:T.jsxs(r,{flexDirection:"column",marginTop:1,children:[T.jsx(c,{bold:!0,dimColor:!0,children:lu[l]}),s.map(f=>T.jsx(Av,{entity:f},f.path))]})},Cv=()=>{const{Box:l,Text:s}=it();return T.jsx(l,{marginTop:1,children:T.jsxs(s,{dimColor:!0,children:[T.jsx(s,{color:ke.idle.color,children:ke.idle.icon})," ","pending"," ",T.jsx(s,{color:ke.in_progress.color,children:ji[0]})," ","building"," ",T.jsx(s,{color:ke.uploading.color,children:Yi[0]})," ","uploading"," ",T.jsx(s,{color:ke.done.color,children:ke.done.icon})," ","success"," ",T.jsx(s,{color:ke.error.color,children:ke.error.icon})," ","error"]})})},Tv=7,Rv=({versionInfo:l})=>{const{Box:s,Text:r}=it();if(l===null)return null;const{cliVersion:c,localServerVersion:f,latestServerVersion:S,isMinorOrMajorBehind:E,daysBehind:C}=l,P=E&&C!==null&&C>Tv,$=f!==null&&S!==null&&f===S;return T.jsxs(s,{children:[T.jsx(r,{dimColor:!0,children:"Versions: "}),T.jsx(r,{dimColor:!0,children:"CLI "}),T.jsxs(r,{children:["v",c]}),f!==null&&T.jsxs(T.Fragment,{children:[T.jsx(r,{dimColor:!0,children:" • Server "}),T.jsxs(r,{color:P?"yellow":void 0,children:["v",f]}),$&&T.jsx(r,{color:"green",children:" ✓ latest"}),P&&S!==null&&T.jsxs(T.Fragment,{children:[T.jsxs(r,{color:"yellow",children:[" → v",S]}),C!==null&&T.jsxs(r,{dimColor:!0,children:[" (",C,"d behind)"]})]})]})]})},Pv=({state:l})=>{const{Text:s}=it(),r=pv(l.pipeline.status),c=Zi(r),f=ke[r],S=hv[l.pipeline.status];return T.jsxs(s,{color:f.color,children:[c," ",S]})},Fv=({label:l,status:s})=>{const{Box:r,Text:c}=it(),f=fv(s),S=Zi(f),E=ke[f];return T.jsxs(r,{children:[T.jsxs(c,{dimColor:!0,children:[l,": "]}),T.jsxs(c,{color:E.color,children:[S," ",s.replace("_"," ")]})]})},Lv=({state:l})=>{const{Box:s,Text:r}=it(),c=yv(l.entities),f=_v(l);return T.jsxs(s,{flexDirection:"column",borderStyle:"classic",borderColor:"gray",paddingX:1,children:[T.jsx(r,{bold:!0,color:"cyan",children:"Application"}),T.jsxs(s,{marginLeft:2,flexDirection:"column",children:[T.jsxs(s,{children:[T.jsx(r,{dimColor:!0,children:"Name: "}),T.jsx(r,{bold:!0,children:l.pipeline.appName??"Loading..."})]}),T.jsxs(s,{children:[T.jsx(r,{dimColor:!0,children:"Overall Status: "}),T.jsx(Pv,{state:l})]}),f&&T.jsxs(s,{children:[T.jsx(r,{dimColor:!0,children:"Open:"}),T.jsxs(r,{bold:!0,color:"cyan",children:[" ",f]})]}),T.jsx(Rv,{versionInfo:l.versionInfo})]}),T.jsx(s,{marginLeft:2,flexDirection:"column",marginTop:1,children:Sv(l).map(S=>T.jsx(Fv,{label:S.label,status:S.status},S.label))}),T.jsx(s,{marginLeft:2,flexDirection:"column",children:cu.map(S=>{const E=c.get(S)??[];return T.jsx(bv,{type:S,entities:E},S)})})]})},Nv=({event:l})=>{const{Box:s,Text:r}=it(),c=gv[l.status],f=mv(l.timestamp);return T.jsxs(s,{children:[T.jsxs(r,{dimColor:!0,children:[f," "]}),T.jsx(r,{color:c,children:l.message})]})},Ov=new Set(["building","syncing"]),Wo=120,$v=80,Uv=({uiStateManager:l})=>{const{Box:s,Static:r}=it(),[,c]=bt.useReducer(P=>P+1,0),f=bt.useRef(null),S=bt.useRef(0),E=bt.useCallback(()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,S.current=Date.now(),c()},$v)},[]);bt.useEffect(()=>l.subscribe(()=>{E()}),[l,E]),bt.useEffect(()=>{const P=setInterval(()=>{const $=l.getSnapshot();Ov.has($.pipeline.status)&&(Date.now()-S.current<Wo||c())},Wo);return()=>clearInterval(P)},[l]),bt.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]);const C=l.getSnapshot();return T.jsxs(T.Fragment,{children:[T.jsx(r,{items:C.events,children:P=>T.jsx(Nv,{event:P},P.id)}),T.jsxs(s,{marginTop:1,flexDirection:"column",children:[T.jsx(Lv,{state:C}),T.jsx(Cv,{})]})]})},Dv=async l=>{const s=await import("ink"),{render:r,Box:c,Text:f,Static:S}=s,{unmount:E}=r(T.jsx(Iv,{value:{Box:c,Text:f,Static:S},children:T.jsx(Uv,{uiStateManager:l})}),{incrementalRendering:!0});return{unmount:E}};class Mv{constructor(s){this.listeners=new Set,this.pendingNotify=!1,this.orchestratorState=s}getSnapshot(){return this.orchestratorState}subscribe(s){return this.listeners.add(s),s(this.orchestratorState),()=>this.listeners.delete(s)}notify(){this.pendingNotify||(this.pendingNotify=!0,queueMicrotask(()=>{this.pendingNotify=!1;for(const s of this.listeners)s(this.orchestratorState)}))}}class Wv{constructor(){this.orchestrator=null,this.unmountUI=null}async close(){this.unmountUI?.(),await this.orchestrator?.close()}getOrchestrator(){return this.orchestrator}async execute(s){const r=s.appPath??Z;await tn(r),s.headless&&await m.checkServerVersionCompatibility();const c=new cv({appPath:r});if(!s.headless){const f=new Mv(c);c.onChange=()=>f.notify();const{unmount:S}=await Dv(f);this.unmountUI=S,m.getVersionInfo().then(E=>c.setVersionInfo(E))}this.orchestrator=new av({state:c,verbose:s.verbose,debounceMs:s.debounceMs}),await this.orchestrator.start(),s.headless||this.setupGracefulShutdown()}setupGracefulShutdown(){const s=()=>{this.close().then(()=>process.exit(0))};process.on("SIGINT",s),process.on("SIGTERM",s)}}class Bv{async execute(s){const r=s.appPath??Z;await tn(r);const c=m.ConfigService.getActiveRemote();console.log(y.default.blue(`Syncing application on ${c}...`)),console.log(y.default.gray(`App path: ${r}
350
- `));const f=await m.appDevOnce({appPath:r,verbose:s.verbose,onProgress:S=>console.log(y.default.gray(S))});f.success||(console.error(y.default.red(f.error.message)),process.exit(1)),console.log(y.default.green(`
351
- Synced ${f.data.applicationDisplayName} (${f.data.fileCount} file${f.data.fileCount===1?"":"s"})`)),console.log(y.default.gray(`Output: ${f.data.outputDir}`))}}const kv=l=>{const s=new ou,r=new au;l.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(c,f)=>{await s.execute({...f,appPath:he(c)})}),l.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("-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(c,f)=>{!f?.postInstall&&!f?.preInstall&&!f?.functionUniversalIdentifier&&!f?.functionName&&(console.error(y.default.red("Error: Either --postInstall, --preInstall, --functionName (-n), or --functionUniversalIdentifier (-u) is required.")),process.exit(1)),await r.execute({...f,payload:f?.payload??"{}",appPath:he(c)})})},Vv=l=>{const s=new su,r=new Wv,c=new Bv,f=new uu,S=new iu,E=async(C,P)=>{const $={appPath:he(C),verbose:P.verbose||P.debug,debounceMs:P.debounceMs?parseInt(P.debounceMs,10):void 0};if(P.once){await c.execute($);return}await r.execute($)};l.command("dev [appPath]",{isDefault:!0}).description("Build and sync local changes (default command)").option("-o, --once","Build and sync once, then exit (useful for CI, scripts, and pre-commit hooks)").option("--debounceMs <ms>","Debounce in ms (default: 2 000)").option("-v, --verbose","Show detailed logs").option("-d, --debug","Show detailed logs (alias for --verbose)").action(E),l.command("dev:build [appPath]").description("Build and generate API client").option("--tarball","Also pack into a .tgz tarball").action(async(C,P)=>{await s.execute({appPath:he(C),tarball:P.tarball})}),l.command("dev:typecheck [appPath]").description("Run TypeScript type checking").action(async C=>{await f.execute({appPath:he(C)})}),l.command("dev:add [entityType]").description(`Scaffold a new entity (${Object.values(m.e).join("|")})`).option("--path <path>","Path in which the entity should be created.").action(async(C,P)=>{await S.execute(C,P?.path)}),l.command("dev:catalog-sync").description("Trigger marketplace catalog sync").option("-r, --remote <name>","Sync on a specific remote").action(async C=>{const{CatalogSyncCommand:P}=await Promise.resolve().then(()=>require("./catalog-sync-BCebNxby.js"));await new P().execute({remote:C.remote})}),kv(l)},Bo=async l=>{const s=l.test?m.DEFAULT_TEST_PORT:m.DEFAULT_PORT,r=l.port?parseInt(l.port,10):s;(isNaN(r)||r<1||r>65535)&&(console.error(y.default.red("Invalid port number.")),process.exit(1));const c=await m.serverStart({port:r,test:l.test,onProgress:f=>console.log(y.default.gray(f))});c.success||(console.error(y.default.red(c.error.message)),process.exit(1))},ko=l=>{const s=l.test?m.TEST_CONTAINER_NAME:m.CONTAINER_NAME;if(!m.containerExists(s)){console.log(y.default.yellow("No Twenty server container found."));return}Tn.execSync(`docker stop ${s}`,{stdio:"ignore"}),console.log(y.default.green("Twenty server stopped."))},Vo=l=>{const s=l.test?m.TEST_CONTAINER_NAME:m.CONTAINER_NAME;if(!m.containerExists(s)){console.log(y.default.yellow("No Twenty server container found."));return}try{Tn.spawnSync("docker",["logs","-f","--tail",l.lines,s],{stdio:"inherit"})}catch{}},Go=async l=>{const s=l.test?m.TEST_CONTAINER_NAME:m.CONTAINER_NAME,r=l.test?m.DEFAULT_TEST_PORT:m.DEFAULT_PORT;if(!m.containerExists(s)){console.log(` Status: ${y.default.gray("not created")}`),console.log(y.default.gray(` Run 'yarn twenty docker:start${l.test?" --test":""}' to create one.`));return}const c=m.isContainerRunning(s),f=c?m.getContainerPort(s):r,S=c?await m.checkServerHealth(f):!1,E=S?y.default.green("running (healthy)"):c?y.default.yellow("running (starting...)"):y.default.gray("stopped"),C=m.getContainerEnvVar("APP_VERSION",s);console.log(` Status: ${E}`),console.log(` URL: http://localhost:${f}`),C&&console.log(` Version: ${y.default.gray(C)}`),S&&console.log(y.default.gray(" Login: tim@apple.dev / tim@apple.dev"))},qo=l=>{const s=l.test?m.TEST_CONTAINER_NAME:m.CONTAINER_NAME,r=l.test?"twenty-app-dev-test-data":"twenty-app-dev-data",c=l.test?"twenty-app-dev-test-storage":"twenty-app-dev-storage";m.containerExists(s)&&Tn.execSync(`docker rm -f ${s}`,{stdio:"ignore"});try{Tn.execSync(`docker volume rm ${r} ${c}`,{stdio:"ignore"})}catch{}console.log(y.default.green("Twenty server data reset.")),console.log(y.default.gray(`Run 'yarn twenty docker:start${l.test?" --test":""}' to start a fresh instance.`))},Ho=async(l,s)=>{const r=await m.serverUpgrade({version:l??"latest",test:s.test,onProgress:f=>console.log(y.default.gray(f))});r.success||(console.error(y.default.red(r.error.message)),process.exit(1));const{data:c}=r;if(!c.imageUpdated){console.log(y.default.green(` Already up to date (${c.image}).`));return}console.log(y.default.green(` Upgraded to: ${c.image}`)),c.containerRecreated&&console.log(y.default.gray(` Run 'yarn twenty docker:start${s.test?" --test":""}' to wait for the server to be ready.`))},Gv=l=>{l.command("docker:start").description("Start the local Twenty container").option("-p, --port <port>","HTTP port").option("--test","Start a separate test instance (port 2021)").action(Bo),l.command("docker:stop").description("Stop the local Twenty container").option("--test","Stop the test instance").action(ko),l.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(Vo),l.command("docker:status").description("Show container status").option("--test","Show status of the test instance").action(Go),l.command("docker:reset").description("Delete all data and start fresh").option("--test","Reset the test instance").action(qo),l.command("docker:upgrade [version]").description("Upgrade the Docker image").option("--test","Upgrade the test instance").action(Ho);const s=l.command("server",{hidden:!0}).description("Manage a Twenty server (local instance and server-side actions)"),r=(c,f)=>console.warn(y.default.yellow(`⚠ \`twenty server ${c}\` is deprecated. Use \`twenty ${f}\` instead.`));s.command("start").option("-p, --port <port>","HTTP port").option("--test","Start a separate test instance (port 2021)").action(async c=>{r("start","docker:start"),await Bo(c)}),s.command("stop").option("--test","Stop the test instance").action(c=>{r("stop","docker:stop"),ko(c)}),s.command("logs").option("-n, --lines <lines>","Number of lines to show","50").option("--test","Show logs for the test instance").action(c=>{r("logs","docker:logs"),Vo(c)}),s.command("status").option("--test","Show status of the test instance").action(async c=>{r("status","docker:status"),await Go(c)}),s.command("reset").option("--test","Reset the test instance").action(c=>{r("reset","docker:reset"),qo(c)}),s.command("upgrade [version]").option("--test","Upgrade the test instance").action(async(c,f)=>{r("upgrade","docker:upgrade"),await Ho(c,f)}),s.command("catalog-sync").option("-r, --remote <name>","Sync on a specific remote").action(async c=>{r("catalog-sync","dev:catalog-sync");const{CatalogSyncCommand:f}=await Promise.resolve().then(()=>require("./catalog-sync-BCebNxby.js"));await new f().execute({remote:c.remote})})},qv=l=>{try{return new URL(l).hostname.replace(/\./g,"-")}catch{return"remote"}},zo=async(l,s)=>s?((await m.authLogin({apiKey:s,apiUrl:l})).success||(console.error(y.default.red("✗ Authentication failed.")),process.exit(1)),"API key"):Hv(l),Hv=async l=>{console.log(y.default.gray("Opening browser for authentication..."));const s=await m.authLoginOAuth({apiUrl:l});if(s.success)return"OAuth";console.log(y.default.yellow(s.error.message));const r=await Ye.default.prompt([{type:"password",name:"apiKey",message:"API Key:",mask:"*",validate:f=>f.length>0||"API key is required"}]);return(await m.authLogin({apiKey:r.apiKey,apiUrl:l})).success||(console.error(y.default.red("✗ Authentication failed.")),process.exit(1)),"API key"},Ko=async l=>{l.apiUrl&&console.warn(y.default.yellow("⚠ --api-url is deprecated. Use --url instead."));const s=l.test?m.getConfigPath(!0):void 0,r=new m.ConfigService(s?{configPath:s}:void 0),c=await r.getRemotes();if(l.as!==void 0&&c.includes(l.as)){const C=await r.getConfigForRemote(l.as);m.ConfigService.setActiveRemote(l.as);const P=await zo(C.apiUrl,l.apiKey);console.log(y.default.green(`✓ Re-authenticated "${l.as}" via ${P}.`)),await r.setDefaultRemote(l.as),console.log(y.default.green(`✓ Default remote set to "${l.as}".`));return}let f=l.url??l.apiUrl;if(f)f=m.La(f);else{const C=await m.detectLocalServer();l.local?(C||(console.error(y.default.red(`No local Twenty server found.
352
- Start one with: yarn twenty docker:start`)),process.exit(1)),console.log(y.default.gray(`Found local server at ${C}`)),f=C):f=m.La((await Ye.default.prompt([{type:"input",name:"serverUrl",message:"Twenty server URL:",validate:P=>{try{return new URL(P),!0}catch{return"Please enter a valid URL"}}}])).serverUrl)}const S=l.as??qv(f);m.ConfigService.setActiveRemote(S);const E=await zo(f,l.apiKey);console.log(y.default.green(`✓ Remote "${S}" added (${f}) via ${E}.`)),await r.setDefaultRemote(S),console.log(y.default.green(`✓ Default remote set to "${S}".`))},jo=async()=>{const l=new m.ConfigService,s=await l.getRemotes(),r=await l.getDefaultRemote();if(s.length===0){console.log("No remotes configured."),console.log("Use 'twenty remote:add' to add one.");return}console.log("");for(const c of s){const f=await l.getConfigForRemote(c),S=f.twentyCLIAccessToken?"oauth":f.apiKey?"api-key":"none",E=c===r,C=E?"* ":" ",P=E?y.default.bold(c):c;console.log(`${C}${P} ${y.default.gray(f.apiUrl)} [${S}]`)}console.log(`
353
- `,y.default.gray("Use 'twenty remote:use <name>' to change default"))},Yo=async l=>{const s=new m.ConfigService,r=l??(await Ye.default.prompt([{type:"list",name:"remote",message:"Select default remote:",choices:await s.getRemotes()}])).remote;(await s.getRemotes()).includes(r)||(console.error(y.default.red(`Remote "${r}" not found.`)),process.exit(1)),await s.setDefaultRemote(r),console.log(y.default.green(`✓ Default remote set to "${r}".`))},Jo=async()=>{const l=new m.ConfigService,s=new m.ApiService,r=m.ConfigService.getActiveRemote(),c=await l.getConfig(),f=c.twentyCLIAccessToken?"oauth":c.apiKey?"api-key":"none";if(console.log(` Remote: ${y.default.bold(r)}`),console.log(` Server: ${c.apiUrl}`),f==="none"){console.log(` Auth: ${y.default.yellow("not configured")}`);return}const{authValid:S}=await s.validateAuth(),E=S?y.default.green(`${f} (valid)`):y.default.red(`${f} (invalid)`);console.log(` Auth: ${E}`)},Zo=async l=>{const s=new m.ConfigService;(await s.getRemotes()).includes(l)||(console.error(y.default.red(`Remote "${l}" not found.`)),process.exit(1)),m.ConfigService.setActiveRemote(l),await s.clearConfig(),console.log(y.default.green(`✓ Remote "${l}" removed.`))},zv=l=>{l.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(Ko),l.command("remote:list").description("List all configured remotes").action(jo),l.command("remote:use [name]").description("Set the default remote").action(Yo),l.command("remote:status").description("Show active remote auth status").action(Jo),l.command("remote:remove <name>").description("Remove a remote").action(Zo);const s=l.command("remote",{hidden:!0}).description("Manage remote Twenty servers"),r=(c,f)=>console.warn(y.default.yellow(`⚠ \`twenty remote ${c}\` is deprecated. Use \`twenty ${f}\` instead.`));s.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 c=>{r("add","remote:add"),await Ko(c)}),s.command("list").action(async()=>{r("list","remote:list"),await jo()}),s.command("switch [name]").action(async c=>{r("switch","remote:use"),await Yo(c)}),s.command("status").action(async()=>{r("status","remote:status"),await Jo()}),s.command("remove <name>").action(async c=>{r("remove","remote:remove"),await Zo(c)})},Kv=l=>{Vv(l),Em(l),Gv(l),zv(l),Ym(l)};Sm.inspect.defaultOptions.depth=10;const nn=new Xo.Command;nn.name("twenty").description("CLI for Twenty application development").version(m.packageJson.version);nn.option("-r, --remote <name>","Use a specific remote (overrides the default set by remote:use)");nn.hook("preAction",async l=>{let r=(l.optsWithGlobals?l.optsWithGlobals():l.opts()).remote;r?console.log(y.default.gray(`Using remote: ${r}`)):r=await new m.ConfigService().getDefaultRemote(),m.ConfigService.setActiveRemote(r)});Kv(nn);nn.exitOverride();try{nn.parse()}catch(l){l instanceof Xo.CommanderError&&process.exit(l.exitCode),l instanceof Error&&(console.error(y.default.red("Error:"),l.message),process.exit(1))}
364
+ Waiting for server...`,status:"error"}]),this.state.updatePipeline({status:"error"})),!1)}if(!r.authValid)return s.output.errorLogged||(s.output={isReady:!1,errorLogged:!0},s.status="error",this.state.applyStepEvents([{message:"Authentication failed. Run `yarn twenty remote:add --local` to authenticate.",status:"error"}]),this.state.updatePipeline({status:"error"})),!1;const c=s.output.isReady;if(s.output={isReady:!0,errorLogged:!1},s.status="done",!m.o(this.state.frontendUrl)){const f=await this.apiService.getWorkspaceFrontendUrl();m.o(f)&&(this.state.frontendUrl=f)}return c||this.notify(),!0}}class nv{constructor({clientService:s,configService:r,state:c,notify:f}){this.clientService=s,this.configService=r,this.state=c,this.notify=f}async execute(s){const r=this.state.steps.generateApiClient;r.status="in_progress",this.notify();try{const c=await m.ensureAppAccessTokenIsValidOrRefresh(this.configService,s.credentials);await this.clientService.generateCoreClient({appPath:s.appPath,appAccessToken:c}),r.status="done"}catch(c){this.state.applyStepEvents([{message:`Failed to generate API client: ${c instanceof Error?c.message:String(c)}`,status:"error"}]),r.status="error"}this.notify()}}class rv{constructor({apiService:s,configService:r,state:c,notify:f}){this.apiService=s,this.configService=r,this.state=c,this.notify=f}async execute(s){try{const r=await m.ensureAppRegistration(this.apiService,this.configService,{name:s.manifest.application.displayName,universalIdentifier:s.manifest.application.universalIdentifier});this.registrationCredentials={clientId:r.clientId,clientSecret:r.clientSecret},this.state.applyStepEvents([{message:r.isNewRegistration?`App registration created: ${s.manifest.application.displayName}`:"Existing app registration found",status:r.isNewRegistration?"success":"info"},...r.isNewRegistration?[{message:"Credentials saved to config.",status:"info"}]:[]])}catch(r){throw this.state.applyStepEvents([{message:`Failed to register app: ${r instanceof Error?r.message:String(r)}`,status:"error"}]),r}this.notify()}}class Bo{constructor(s){this.watcher=null,this.appPath=s.appPath,this.fileFolder=s.fileFolder,this.watchPaths=s.watchPaths,this.handleFileBuilt=s.handleFileBuilt}async start(){const s=(await Promise.all(this.watchPaths.map(async r=>{const c=q.join(this.appPath,r);return await m.pathExists(c)?c:null}))).filter(r=>r!==null);s.length!==0&&(this.watcher=nu.default.watch(s,{awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on("all",(r,c)=>{r==="addDir"||r==="unlinkDir"||((r==="add"||r==="change")&&this.copyAndNotify(c),r==="unlink"&&this.handleUnlink(c))}))}async close(){await this.watcher?.close()}async copyAndNotify(s){const r=q.relative(this.appPath,s),c=q.join(m.u,r),f=q.join(this.appPath,c);await m.ensureDir(q.dirname(f)),await m.copy(s,f);const w=await nt.readFile(f),x=Am.default.createHash("md5").update(w).digest("hex");this.handleFileBuilt({fileFolder:this.fileFolder,builtPath:c,sourcePath:r,checksum:x})}async handleUnlink(s){const r=q.relative(this.appPath,s),c=q.join(m.u,r),f=q.join(this.appPath,c);await m.remove(f)}}class iv{constructor(s){this.process=null,this.pendingErrors=[],this.buffer="",this.hasErrors=!1,this.appPath=s.appPath,this.onErrors=s.onErrors}async start(){const s=Oo.default.join(this.appPath,"node_modules",".bin","tsc");if(!await m.pathExists(s))return;const r=Oo.default.join(this.appPath,"tsconfig.json");this.process=Pn.spawn(s,["--watch","--noEmit","--pretty","false","-p",r],{cwd:this.appPath,stdio:["ignore","pipe","pipe"]}),this.process.on("error",()=>{this.process=null}),this.process.stdout?.on("data",c=>{this.handleOutput(c.toString())}),this.process.stderr?.on("data",c=>{this.handleOutput(c.toString())})}close(){this.process?.kill(),this.process=null}handleOutput(s){this.buffer+=s;const r=this.buffer.split(`
365
+ `);this.buffer=r.pop()??"";for(const c of r)this.processLine(c)}processLine(s){if(s.includes("Starting compilation in watch mode...")||s.includes("Starting incremental compilation...")){this.pendingErrors=[];return}if(s.includes("Watching for file changes.")){const c=this.hasErrors;this.hasErrors=this.pendingErrors.length>0,(this.hasErrors||c)&&this.onErrors(this.pendingErrors),this.pendingErrors=[];return}const r=m.parseTscOutputLine(s);r&&this.pendingErrors.push(r)}}const sv=new Set(["node_modules","dist",".twenty"]);class av{constructor(s){this.watcher=null,this.appPath=s.appPath,this.handleChangeDetected=s.handleChangeDetected,this.verbose=s.verbose??!1}async start(){const s=this.appPath;this.watcher=nu.default.watch(this.appPath,{ignoreInitial:!this.verbose,ignored:r=>{const c=q.relative(s,r);if(c==="")return!1;const f=c.split(Zi.default.sep)[0];return sv.has(f)||f.startsWith(".")},awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on("all",(r,c)=>{if(r==="addDir"||r==="unlinkDir")return;const f=q.relative(this.appPath,c),w=f.startsWith(m._),x=["package.json","yarn.lock"].includes(f);!(f.endsWith(".ts")||f.endsWith(".tsx"))&&!w&&!x||this.handleChangeDetected(f,r)})}async close(){await this.watcher?.close()}}class ov{constructor(s){this.manifestWatcher=null,this.logicFunctionsWatcher=null,this.frontComponentsWatcher=null,this.assetWatcher=null,this.dependencyWatcher=null,this.tscWatcher=null,this.state=s.state,this.scheduleSync=s.scheduleSync,this.notify=s.notify,this.onFileBuilt=s.onFileBuilt,this.shouldSkipTypecheck=s.shouldSkipTypecheck,this.verbose=s.verbose??!1}async start(){this.state.steps.startWatchers.status="in_progress",this.notify(),this.manifestWatcher=new av({appPath:this.state.appPath,handleChangeDetected:this.handleChangeDetected.bind(this),verbose:this.verbose}),await this.manifestWatcher.start()}async handleWatcherRestarts(s){const{logicFunctions:r,frontComponents:c}=s.filePaths;if(!this.state.steps.startWatchers.output.watchersStarted){this.state.steps.startWatchers.output.watchersStarted=!0,this.state.steps.startWatchers.status="done",await this.startFileWatchers(r,c);return}this.logicFunctionsWatcher?.shouldRestart(r)&&await this.logicFunctionsWatcher.restart(r),this.frontComponentsWatcher?.shouldRestart(c)&&await this.frontComponentsWatcher.restart(c)}async close(){this.tscWatcher?.close(),await Promise.all([this.manifestWatcher?.close(),this.logicFunctionsWatcher?.close(),this.frontComponentsWatcher?.close(),this.assetWatcher?.close(),this.dependencyWatcher?.close()])}handleChangeDetected(s,r){this.state.addEvent({message:`Change detected: ${s}`,status:"info"}),r==="unlink"?this.state.removeEntity(s):this.state.updateEntityStatus(s,"building"),this.notify(),this.scheduleSync()}handleFileBuildError(s){this.state.addEvent({message:"Build failed:",status:"error"});for(const r of s)this.state.addEvent({message:r.error,status:"error"});this.notify()}handleFileBuilt(s){this.verbose&&this.state.addEvent({message:`Successfully built ${s.builtPath}`,status:"success"}),this.state.steps.uploadFiles.output.builtFileInfos.set(s.builtPath,{checksum:s.checksum,builtPath:s.builtPath,sourcePath:s.sourcePath,fileFolder:s.fileFolder,usesSdkClient:s.usesSdkClient}),this.onFileBuilt(s),this.notify(),this.scheduleSync()}async startFileWatchers(s,r){await Promise.all([this.startTscWatcher(),this.startLogicFunctionsWatcher(s),this.startFrontComponentsWatcher(r),this.startAssetWatcher(),this.startDependencyWatcher()])}async startLogicFunctionsWatcher(s){this.logicFunctionsWatcher=m.createLogicFunctionsWatcher({appPath:this.state.appPath,sourcePaths:s,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.logicFunctionsWatcher.start()}async startFrontComponentsWatcher(s){this.frontComponentsWatcher=m.createFrontComponentsWatcher({appPath:this.state.appPath,sourcePaths:s,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.frontComponentsWatcher.start()}async startAssetWatcher(){this.assetWatcher=new Bo({appPath:this.state.appPath,fileFolder:m.v.PublicAsset,watchPaths:[m._],handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.assetWatcher.start()}async startDependencyWatcher(){this.dependencyWatcher=new Bo({appPath:this.state.appPath,fileFolder:m.v.Dependencies,watchPaths:["package.json","yarn.lock"],handleFileBuilt:this.handleFileBuilt.bind(this)}),this.dependencyWatcher.start()}async startTscWatcher(){this.tscWatcher=new iv({appPath:this.state.appPath,onErrors:this.handleTypecheckErrors.bind(this)}),await this.tscWatcher.start()}handleTypecheckErrors(s){s.length===0?this.state.addEvent({message:"Typecheck passed",status:"success"}):this.state.applyStepEvents(s.map(r=>({message:`Type error in ${r.file}(${r.line},${r.column}): ${r.text}`,status:"error"}))),this.notify()}}class uv{constructor({apiService:s,state:r,notify:c,verbose:f}){this.apiService=s,this.state=r,this.notify=c,this.verbose=f??!1}async execute(s){const r=this.state.steps.syncApplication;r.status="in_progress",this.state.updatePipeline({status:"syncing"});const c=[],f=m.manifestUpdateChecksums({manifest:s.manifest,builtFileInfos:s.builtFileInfos});c.push({message:"Manifest checksums set",status:"info"}),await m.writeManifestToOutput(s.appPath,f),c.push({message:"Manifest saved to output directory",status:"info"}),c.push({message:"Syncing manifest",status:"info"});const w=await this.apiService.syncApplication(f);if(w.success){const P=w.data;c.push(...m.formatSyncActionsSummary(P.actions)),c.push({message:"✓ Synced",status:"success"}),r.output={syncStatus:"synced",error:null},r.status="done",this.state.updatePipeline({status:"synced",error:null}),this.state.updateAllEntitiesStatus("success"),this.state.applyStepEvents(c);return}const x=this.verbose?null:m.formatManifestValidationErrors(w.error);x?(c.push(...x),c.push({message:"Add --verbose to see full error log",status:"info"})):c.push({message:`Sync failed with error: ${w.message??"Sync failed"}`,status:"error"});const T=m.getSyncErrorRecoveryHint(w.message);T&&c.push({message:T,status:"info"});const $=x?x[0].message:"Sync failed";r.output={syncStatus:"error",error:$},r.status="error",this.state.updatePipeline({status:"error",error:$}),this.state.updateAllEntitiesStatus("error"),this.state.applyStepEvents(c)}}class lv{constructor({state:s,notify:r,verbose:c}){this.uploadedCount=0,this.failedCount=0,this.totalQueued=0,this.state=s,this.notify=r,this.verbose=c??!1}get isInitialized(){return m.o(this.state.steps.uploadFiles.output.fileUploader)}initialize(s){const r=this.state.steps.uploadFiles;r.output={...r.output,fileUploader:new m.FileUploader({appPath:s.appPath,applicationUniversalIdentifier:s.universalIdentifier})},r.status="in_progress",this.notify(),this.uploadPendingFiles()}uploadFile(s,r,c){const f=this.state.steps.uploadFiles;if(!f.output.fileUploader)return;f.status="in_progress",this.totalQueued++,this.verbose&&this.state.addEvent({message:`Uploading ${s}`,status:"info"}),this.state.updateEntityStatus(r,"uploading"),this.notify();const w=f.output.fileUploader.uploadFile({builtPath:s,fileFolder:c}).then(x=>{x.success?(this.uploadedCount++,this.verbose&&this.state.addEvent({message:`Successfully uploaded ${s}`,status:"success"}),this.state.updateEntityStatus(r,"success")):(this.failedCount++,this.state.addEvent({message:`Failed to upload ${s}: ${x.error}`,status:"error"}))}).catch(x=>{this.failedCount++,this.state.addEvent({message:`Upload failed for ${s}: ${x}`,status:"error"})}).finally(()=>{f.output.activeUploads.delete(w),f.output.activeUploads.size===0&&(this.logUploadSummary(),f.status="done",this.notify())});f.output.activeUploads.add(w)}async waitForUploads(){const s=this.state.steps.uploadFiles;for(;s.output.activeUploads.size>0;)await Promise.all(s.output.activeUploads);s.status="done",this.notify()}logUploadSummary(){if(this.totalQueued===0){this.resetCounters();return}this.failedCount>0&&this.state.addEvent({message:`Uploaded ${this.uploadedCount}/${this.totalQueued} files (${this.failedCount} failed)`,status:"error"}),this.state.addEvent({message:`Successfully uploaded ${this.uploadedCount} file${this.uploadedCount!==1?"s":""}`,status:"success"}),this.resetCounters()}resetCounters(){this.uploadedCount=0,this.failedCount=0,this.totalQueued=0}uploadPendingFiles(){for(const[s,{fileFolder:r,sourcePath:c}]of this.state.steps.uploadFiles.output.builtFileInfos.entries())this.uploadFile(s,c,r)}}class cv{constructor(s){this.syncTimer=null,this.serverCheckInterval=null,this.skipTypecheck=!0,this.debounceMs=s.debounceMs??1e3,this.state=s.state,this.verbose=s.verbose??!1,this.apiService=new m.ApiService({disableInterceptors:!0});const r=this.apiService,c=new m.ConfigService;this.clientService=new m.ClientService;const f={state:this.state,notify:()=>this.state.notify()};this.checkServerStep=new tv({...f,apiService:r}),this.buildManifestStep=new ev(f),this.registerAppStep=new rv({...f,apiService:r,configService:c}),this.uploadFilesStep=new lv({...f,verbose:this.verbose}),this.generateApiClientStep=new nv({...f,clientService:this.clientService,configService:c}),this.syncApplicationStep=new uv({...f,apiService:r,verbose:this.verbose}),this.startWatchersStep=new ov({...f,scheduleSync:this.scheduleSync.bind(this),onFileBuilt:this.handleFileBuilt.bind(this),shouldSkipTypecheck:()=>this.skipTypecheck,verbose:this.verbose})}async start(){const s=Zi.default.join(this.state.appPath,m.u);await m.ensureDir(s),await m.emptyDir(s),this.state.addEvent({message:`Using remote "${m.ConfigService.getActiveRemote()}"`,status:"info"}),this.verbose||this.state.addEvent({message:"Add --verbose to see fully detailed logs",status:"info"}),this.state.notify(),await this.startWatchersStep.start(),this.serverCheckInterval=setInterval(()=>{this.checkServerHealth()},2e3)}async close(){this.serverCheckInterval&&clearInterval(this.serverCheckInterval),await this.startWatchersStep.close()}getState(){return this.state}handleFileBuilt(s){this.state.steps.uploadFiles.output.fileUploader&&this.uploadFilesStep.uploadFile(s.builtPath,s.sourcePath,s.fileFolder)}async checkServerHealth(){const s=this.state.steps.checkServer.output.isReady;await this.checkServerStep.execute()&&!s&&this.scheduleSync()}scheduleSync(){this.syncTimer&&clearTimeout(this.syncTimer),this.syncTimer=setTimeout(()=>{this.syncTimer=null,this.performSync()},this.debounceMs)}async performSync(){if(!this.state.pipeline.isSyncing){this.state.updatePipeline({isSyncing:!0});try{await this.runSyncPipeline()}catch(s){this.state.addEvent({message:`Sync failed with error: ${m.serializeError(s)}`,status:"error"}),this.state.updatePipeline({status:"error"}),this.state.updateAllEntitiesStatus("error")}finally{this.state.updatePipeline({isSyncing:!1})}}}async runSyncPipeline(){if(!await this.checkServerStep.execute())return;this.state.steps.ensureValidTokens.status="done";const r=await this.buildManifestStep.execute({appPath:this.state.appPath});if(!r||(await this.startWatchersStep.handleWatcherRestarts(r),!this.uploadFilesStep.isInitialized&&!await this.initializePipeline(r.manifest)))return;const c=this.state.hasObjectsOrFieldsChanged(r.manifest);await this.uploadFilesStep.waitForUploads(),await this.syncApplicationStep.execute({manifest:r.manifest,builtFileInfos:this.state.steps.uploadFiles.output.builtFileInfos,appPath:this.state.appPath}),this.state.steps.syncApplication.status!=="error"&&c&&(await this.generateApiClientStep.execute({appPath:this.state.appPath,credentials:this.registerAppStep.registrationCredentials}),this.skipTypecheck=!1)}async initializePipeline(s){await this.registerAppStep.execute({manifest:s});const r=await this.apiService.createDevelopmentApplication({universalIdentifier:s.application.universalIdentifier,name:s.application.displayName});return!r.success||!r.data?(this.state.applyStepEvents([{message:"Failed to install development application",status:"error"},{message:JSON.stringify(r,null,2),status:"error"}]),this.state.updatePipeline({status:"error"}),!1):(this.state.steps.resolveApplication.output={applicationId:r.data.id,universalIdentifier:r.data.universalIdentifier},this.state.steps.resolveApplication.status="done",this.state.applyStepEvents([{message:"Application installed",status:"success"}]),this.uploadFilesStep.initialize({appPath:this.state.appPath,universalIdentifier:s.application.universalIdentifier}),!0)}}const fv={objects:m.o$1.Object,fields:m.o$1.Field,logicFunctions:m.o$1.LogicFunction,frontComponents:m.o$1.FrontComponent,roles:m.o$1.Role,skills:m.o$1.Skill,connectionProviders:m.o$1.ConnectionProvider,views:m.o$1.View,viewFields:m.o$1.ViewField,navigationMenuItems:m.o$1.NavigationMenuItem,pageLayouts:m.o$1.PageLayout,pageLayoutTabs:m.o$1.PageLayoutTab,commandMenuItems:m.o$1.CommandMenuItem},dv=200,pv={pending:["building","uploading","success","error"],building:["pending","uploading","success","error"],uploading:["pending","success","error"],success:["pending","building","uploading","error"],error:["pending","building","uploading","success"]};class hv{constructor(s){this.eventIdCounter=0,this.appPath=s.appPath,this.previousObjectsFieldsFingerprint=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(s){this.versionInfo=s,this.notify()}notify(){this.onChange?.()}updatePipeline(s){Object.assign(this.pipeline,s),this.notify()}applyStepEvents(s){const r=s.map(c=>(this.eventIdCounter+=1,{...c,id:this.eventIdCounter,timestamp:new Date,message:c.message.slice(0,5e3)}));this.events=[...this.events.slice(-(dv-r.length)),...r]}addEvent(s){this.applyStepEvents([s])}updateEntityStatus(s,r){const c=new Map(this.entities),f=c.get(s);f?.status&&!pv[f.status].includes(r)||(c.set(s,f?{...f,status:r}:{name:s,path:s,status:r}),this.entities=c)}removeEntity(s){const r=new Map(this.entities);r.delete(s),this.entities=r}updateAllEntitiesStatus(s){const r=new Map(this.entities);for(const[c,f]of r)r.set(c,{...f,status:s});this.entities=r}updateEntitiesFromManifest(s){const r=new Map;for(const[f,w]of Object.entries(s)){const x=fv[f];if(x)for(const T of w)r.set(T,x)}const c=new Map(this.entities);for(const[f,w]of c)c.set(f,{...w,type:r.get(f)});for(const[f,w]of r)c.has(f)||c.set(f,{name:f,path:f,type:w,status:"pending"});this.entities=c}hasObjectsOrFieldsChanged(s){const r=JSON.stringify({objects:s.objects,fields:s.fields}),c=r!==this.previousObjectsFieldsFingerprint;return this.previousObjectsFieldsFingerprint=r,c}}const We={idle:{color:"gray",icon:"○"},in_progress:{color:"yellow",icon:"spinner"},uploading:{color:"cyan",icon:"upload"},done:{color:"green",icon:"✓"},error:{color:"red",icon:"✗"}},gv=u=>({idle:"idle",in_progress:"in_progress",done:"done",error:"error"})[u],du=u=>({pending:"idle",building:"in_progress",uploading:"uploading",success:"done",error:"error"})[u],mv=u=>({idle:"idle",building:"in_progress",syncing:"in_progress",synced:"done",error:"error"})[u],vv={idle:"Idle",building:"Building...",syncing:"Syncing...",synced:"Synced",error:"Error"},Yi=["◐","◓","◑","◒"],Ji=["↑","⇡","↑","⇡"],pu={[m.o$1.Object]:"Objects",[m.o$1.Field]:"Fields",[m.o$1.LogicFunction]:"Logic functions",[m.o$1.FrontComponent]:"Front components",[m.o$1.CommandMenuItem]:"Command menu items",[m.o$1.Role]:"Roles",[m.o$1.Skill]:"Skills",[m.o$1.View]:"Views",[m.o$1.ViewField]:"View fields",[m.o$1.NavigationMenuItem]:"Navigation menu items",[m.o$1.PageLayout]:"Page layouts",[m.o$1.PageLayoutTab]:"Page layout tabs",[m.o$1.Agent]:"Agents",[m.o$1.ConnectionProvider]:"Connection providers"},hu=Object.keys(pu),yv={info:"gray",success:"green",error:"red",warning:"yellow"},_v=u=>u.toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),wv=(u,s=40)=>{if(u.length<=s)return u;const r=u.split("/");return r.length<=2?u:`.../${r.slice(-2).join("/")}`},Sv=u=>{const s=new Map;for(const r of hu)s.set(r,[]);for(const r of u.values()){if(!r.type)continue;const c=s.get(r.type)??[];c.push(r),s.set(r.type,c)}return s},Iv=[{status:"success",label:"synced"},{status:"building",label:"building"},{status:"uploading",label:"uploading"},{status:"pending",label:"pending"},{status:"error",label:"error"}],xv=u=>{const s={pending:0,building:0,uploading:0,success:0,error:0};for(const r of u)s[r.status]+=1;return Iv.filter(({status:r})=>s[r]>0).map(({status:r,label:c})=>({status:r,count:s[r],label:c}))},Ev=u=>{const s=u.steps.resolveApplication.output.applicationId;return!m.o(u.frontendUrl)||!m.o(s)?null:`${u.frontendUrl}/settings/applications/${s}`},Av=u=>u.some(s=>s==="error")?"error":u.some(s=>s==="in_progress")?"in_progress":u.every(s=>s==="done")?"done":"idle",bv=u=>{const s=[...u.entities.values()],r=s.some(x=>x.status==="error"),c=s.some(x=>x.status==="building"),f=s.length>0&&s.every(x=>x.status==="uploading"||x.status==="success"),w=r?"error":c?"in_progress":f?"done":"idle";return[{label:"Application Initialization",status:Av([u.steps.checkServer.status,u.steps.ensureValidTokens.status,u.steps.resolveApplication.status])},{label:"Resources Build",status:w},{label:"Resources Upload",status:u.steps.uploadFiles.status},{label:"Manifest Build",status:u.steps.buildManifest.status},{label:"Application Synchronization",status:u.steps.syncApplication.status},{label:"Api Client Generation",status:u.steps.generateApiClient.status}]},gu=120,Cv=Math.round(200/gu),ko=()=>{const u=Math.floor(Date.now()/gu);return{spinnerFrame:Yi[u%Yi.length],uploadFrame:Ji[Math.floor(u/Cv)%Ji.length]}},Xi=u=>{const s=We[u];return s.icon==="spinner"?ko().spinnerFrame:s.icon==="upload"?ko().uploadFrame:s.icon},mu=ru.default.createContext(null),Tv=mu.Provider,Je=()=>{const u=ru.default.useContext(mu);if(!u)throw new Error("useInk must be used within InkProvider");return u},vu=({uiStatus:u})=>{const{Text:s}=Je(),r=Xi(u),c=We[u];return b.jsxs(s,{color:c.color,children:[r," "]})},Rv=({entity:u})=>{const{Box:s,Text:r}=Je();return b.jsxs(s,{children:[b.jsx(vu,{uiStatus:du(u.status)}),b.jsx(r,{children:u.name}),u.path!==u.name&&b.jsxs(r,{dimColor:!0,children:[" (",wv(u.path),")"]})]})},Pv=({type:u,entities:s})=>{const{Box:r,Text:c}=Je();return s.length===0?null:b.jsxs(r,{flexDirection:"column",marginTop:1,children:[b.jsx(c,{bold:!0,dimColor:!0,children:pu[u]}),s.map(f=>b.jsx(Rv,{entity:f},f.path))]})},Fv=({entities:u})=>{const{Box:s,Text:r}=Je();if(u.length===0)return null;const c=xv(u);return b.jsxs(s,{marginTop:1,children:[b.jsxs(r,{bold:!0,dimColor:!0,children:["Entities"," "]}),c.map((f,w)=>b.jsxs(s,{children:[w>0&&b.jsx(r,{dimColor:!0,children:" · "}),b.jsx(vu,{uiStatus:du(f.status)}),b.jsxs(r,{children:[f.count," ",f.label]})]},f.status))]})},$v=()=>{const{Box:u,Text:s}=Je();return b.jsx(u,{marginTop:1,children:b.jsxs(s,{dimColor:!0,children:[b.jsx(s,{color:We.idle.color,children:We.idle.icon})," ","pending"," ",b.jsx(s,{color:We.in_progress.color,children:Yi[0]})," ","building"," ",b.jsx(s,{color:We.uploading.color,children:Ji[0]})," ","uploading"," ",b.jsx(s,{color:We.done.color,children:We.done.icon})," ","success"," ",b.jsx(s,{color:We.error.color,children:We.error.icon})," ","error"]})})},Lv=7,Nv=({versionInfo:u})=>{const{Box:s,Text:r}=Je();if(u===null)return null;const{cliVersion:c,localServerVersion:f,latestServerVersion:w,isMinorOrMajorBehind:x,daysBehind:T}=u,$=x&&T!==null&&T>Lv,P=f!==null&&w!==null&&f===w;return b.jsxs(s,{children:[b.jsx(r,{dimColor:!0,children:"Versions: "}),b.jsx(r,{dimColor:!0,children:"CLI "}),b.jsxs(r,{children:["v",c]}),f!==null&&b.jsxs(b.Fragment,{children:[b.jsx(r,{dimColor:!0,children:" • Server "}),b.jsxs(r,{color:$?"yellow":void 0,children:["v",f]}),P&&b.jsx(r,{color:"green",children:" ✓ latest"}),$&&w!==null&&b.jsxs(b.Fragment,{children:[b.jsxs(r,{color:"yellow",children:[" → v",w]}),T!==null&&b.jsxs(r,{dimColor:!0,children:[" (",T,"d behind)"]})]})]})]})},Ov=({state:u})=>{const{Text:s}=Je(),r=mv(u.pipeline.status),c=Xi(r),f=We[r],w=vv[u.pipeline.status];return b.jsxs(s,{color:f.color,children:[c," ",w]})},Uv=({label:u,status:s})=>{const{Box:r,Text:c}=Je(),f=gv(s),w=Xi(f),x=We[f];return b.jsxs(r,{children:[b.jsxs(c,{dimColor:!0,children:[u,": "]}),b.jsxs(c,{color:x.color,children:[w," ",s.replace("_"," ")]})]})},Dv=({state:u,verbose:s=!1})=>{const{Box:r,Text:c}=Je(),f=Sv(u.entities),w=Ev(u);return b.jsxs(r,{flexDirection:"column",borderStyle:"classic",borderColor:"gray",paddingX:1,children:[b.jsx(c,{bold:!0,color:"cyan",children:"Application"}),b.jsxs(r,{marginLeft:2,flexDirection:"column",children:[b.jsxs(r,{children:[b.jsx(c,{dimColor:!0,children:"Name: "}),b.jsx(c,{bold:!0,children:u.pipeline.appName??"Loading..."})]}),b.jsxs(r,{children:[b.jsx(c,{dimColor:!0,children:"Overall Status: "}),b.jsx(Ov,{state:u})]}),w&&b.jsxs(r,{children:[b.jsx(c,{dimColor:!0,children:"Open:"}),b.jsxs(c,{bold:!0,color:"cyan",children:[" ",w]})]}),b.jsx(Nv,{versionInfo:u.versionInfo})]}),b.jsx(r,{marginLeft:2,flexDirection:"column",marginTop:1,children:bv(u).map(x=>b.jsx(Uv,{label:x.label,status:x.status},x.label))}),b.jsx(r,{marginLeft:2,flexDirection:"column",children:s?hu.map(x=>{const T=f.get(x)??[];return b.jsx(Pv,{type:x,entities:T},x)}):b.jsx(Fv,{entities:Array.from(u.entities.values())})})]})},Mv=({event:u})=>{const{Box:s,Text:r}=Je(),c=yv[u.status],f=_v(u.timestamp);return b.jsxs(s,{children:[b.jsxs(r,{dimColor:!0,children:[f," "]}),b.jsx(r,{color:c,children:u.message})]})},Wv=new Set(["building","syncing"]),Vo=120,Bv=80,kv=({uiStateManager:u,verbose:s})=>{const{Box:r,Static:c}=Je(),[,f]=bt.useReducer(P=>P+1,0),w=bt.useRef(null),x=bt.useRef(0),T=bt.useCallback(()=>{w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{w.current=null,x.current=Date.now(),f()},Bv)},[]);bt.useEffect(()=>u.subscribe(()=>{T()}),[u,T]),bt.useEffect(()=>{const P=setInterval(()=>{const G=u.getSnapshot();Wv.has(G.pipeline.status)&&(Date.now()-x.current<Vo||f())},Vo);return()=>clearInterval(P)},[u]),bt.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]);const $=u.getSnapshot();return b.jsxs(b.Fragment,{children:[b.jsx(c,{items:$.events,children:P=>b.jsx(Mv,{event:P},P.id)}),b.jsxs(r,{marginTop:1,flexDirection:"column",children:[b.jsx(Dv,{state:$,verbose:s}),s&&b.jsx($v,{})]})]})},Vv=async(u,s=!1)=>{const r=await import("ink"),{render:c,Box:f,Text:w,Static:x}=r,{unmount:T}=c(b.jsx(Tv,{value:{Box:f,Text:w,Static:x},children:b.jsx(kv,{uiStateManager:u,verbose:s})}));return{unmount:T}};class Gv{constructor(s){this.listeners=new Set,this.pendingNotify=!1,this.orchestratorState=s}getSnapshot(){return this.orchestratorState}subscribe(s){return this.listeners.add(s),s(this.orchestratorState),()=>this.listeners.delete(s)}notify(){this.pendingNotify||(this.pendingNotify=!0,queueMicrotask(()=>{this.pendingNotify=!1;for(const s of this.listeners)s(this.orchestratorState)}))}}class qv{constructor(){this.orchestrator=null,this.unmountUI=null}async close(){this.unmountUI?.(),await this.orchestrator?.close()}getOrchestrator(){return this.orchestrator}async execute(s){const r=s.appPath??Z;await tn(r),s.headless&&await m.checkServerVersionCompatibility();const c=new hv({appPath:r});if(!s.headless){const f=new Gv(c);c.onChange=()=>f.notify();const{unmount:w}=await Vv(f,s.verbose);this.unmountUI=w,m.getVersionInfo().then(x=>c.setVersionInfo(x))}this.orchestrator=new cv({state:c,verbose:s.verbose,debounceMs:s.debounceMs}),await this.orchestrator.start(),s.headless||this.setupGracefulShutdown()}setupGracefulShutdown(){const s=()=>{this.close().then(()=>process.exit(0))};process.on("SIGINT",s),process.on("SIGTERM",s)}}class Hv{async execute(s){const r=s.appPath??Z;await tn(r);const c=m.ConfigService.getActiveRemote();console.log(y.default.blue(`${s.dryRun?"Previewing application diff":"Syncing application"} on ${c}...`)),console.log(y.default.gray(`App path: ${r}
366
+ `));const f=await m.appDevOnce({appPath:r,verbose:s.verbose,dryRun:s.dryRun,onProgress:w=>console.log(y.default.gray(w))});if(f.success||(console.error(y.default.red(f.error.message)),process.exit(1)),s.dryRun){console.log(y.default.green(`
367
+ Dry run complete for ${f.data.applicationDisplayName} no changes were applied`));return}console.log(y.default.green(`
368
+ Synced ${f.data.applicationDisplayName} (${f.data.fileCount} file${f.data.fileCount===1?"":"s"})`)),console.log(y.default.gray(`Output: ${f.data.outputDir}`))}}const jv=u=>{const s=new cu,r=new lu;u.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(c,f)=>{await s.execute({...f,appPath:ge(c)})}),u.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("-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(c,f)=>{!f?.postInstall&&!f?.preInstall&&!f?.functionUniversalIdentifier&&!f?.functionName&&(console.error(y.default.red("Error: Either --postInstall, --preInstall, --functionName (-n), or --functionUniversalIdentifier (-u) is required.")),process.exit(1)),await r.execute({...f,payload:f?.payload??"{}",appPath:ge(c)})})},zv=u=>{const s=new uu,r=new qv,c=new Hv,f=new fu,w=new ou,x=async(T,$)=>{$.dryRun&&!$.once&&console.warn(y.default.yellow("--dry-run only applies with --once. Ignoring it; run `yarn twenty dev --once --dry-run` to preview changes."));const P={appPath:ge(T),verbose:$.verbose||$.debug,debounceMs:$.debounceMs?parseInt($.debounceMs,10):void 0};if($.once){await c.execute({...P,dryRun:$.dryRun});return}await r.execute(P)};u.command("dev [appPath]",{isDefault:!0}).description("Build and sync local changes (default command)").option("-o, --once","Build and sync once, then exit (useful for CI, scripts, and pre-commit hooks)").option("--dry-run","Preview the metadata changes without applying them (requires --once)").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(x),u.command("dev:build [appPath]").description("Build and generate API client").option("--tarball","Also pack into a .tgz tarball").action(async(T,$)=>{await s.execute({appPath:ge(T),tarball:$.tarball})}),u.command("dev:typecheck [appPath]").description("Run TypeScript type checking").action(async T=>{await f.execute({appPath:ge(T)})}),u.command("dev:add [entityType]").description(`Scaffold a new entity (${Object.values(m.o$1).join("|")})`).option("--path <path>","Path in which the entity should be created.").action(async(T,$)=>{await w.execute(T,$?.path)}),u.command("dev:catalog-sync").description("Trigger marketplace catalog sync").option("-r, --remote <name>","Sync on a specific remote").action(async T=>{const{CatalogSyncCommand:$}=await Promise.resolve().then(()=>require("./catalog-sync-BjFX6eQu.js"));await new $().execute({remote:T.remote})}),jv(u)},Go=async u=>{const s=u.test?m.DEFAULT_TEST_PORT:m.DEFAULT_PORT,r=u.port?parseInt(u.port,10):s;(isNaN(r)||r<1||r>65535)&&(console.error(y.default.red("Invalid port number.")),process.exit(1));const c=await m.serverStart({port:r,test:u.test,onProgress:f=>console.log(y.default.gray(f))});c.success||(console.error(y.default.red(c.error.message)),process.exit(1))},qo=u=>{const s=u.test?m.TEST_CONTAINER_NAME:m.CONTAINER_NAME;if(!m.containerExists(s)){console.log(y.default.yellow("No Twenty server container found."));return}Pn.execSync(`docker stop ${s}`,{stdio:"ignore"}),console.log(y.default.green("Twenty server stopped."))},Ho=u=>{const s=u.test?m.TEST_CONTAINER_NAME:m.CONTAINER_NAME;if(!m.containerExists(s)){console.log(y.default.yellow("No Twenty server container found."));return}try{Pn.spawnSync("docker",["logs","-f","--tail",u.lines,s],{stdio:"inherit"})}catch{}},jo=async u=>{const s=u.test?m.TEST_CONTAINER_NAME:m.CONTAINER_NAME,r=u.test?m.DEFAULT_TEST_PORT:m.DEFAULT_PORT;if(!m.containerExists(s)){console.log(` Status: ${y.default.gray("not created")}`),console.log(y.default.gray(` Run 'yarn twenty docker:start${u.test?" --test":""}' to create one.`));return}const c=m.isContainerRunning(s),f=c?m.getContainerPort(s):r,w=c?await m.checkServerHealth(f):!1,x=w?y.default.green("running (healthy)"):c?y.default.yellow("running (starting...)"):y.default.gray("stopped"),T=m.getContainerEnvVar("APP_VERSION",s);console.log(` Status: ${x}`),console.log(` URL: http://localhost:${f}`),T&&console.log(` Version: ${y.default.gray(T)}`),w&&console.log(y.default.gray(" Login: tim@apple.dev / tim@apple.dev"))},zo=u=>{const s=u.test?m.TEST_CONTAINER_NAME:m.CONTAINER_NAME,r=u.test?"twenty-app-dev-test-data":"twenty-app-dev-data",c=u.test?"twenty-app-dev-test-storage":"twenty-app-dev-storage";m.containerExists(s)&&Pn.execSync(`docker rm -f ${s}`,{stdio:"ignore"});try{Pn.execSync(`docker volume rm ${r} ${c}`,{stdio:"ignore"})}catch{}console.log(y.default.green("Twenty server data reset.")),console.log(y.default.gray(`Run 'yarn twenty docker:start${u.test?" --test":""}' to start a fresh instance.`))},Ko=async(u,s)=>{const r=await m.serverUpgrade({version:u??"latest",test:s.test,onProgress:f=>console.log(y.default.gray(f))});r.success||(console.error(y.default.red(r.error.message)),process.exit(1));const{data:c}=r;if(!c.imageUpdated){console.log(y.default.green(` Already up to date (${c.image}).`));return}console.log(y.default.green(` Upgraded to: ${c.image}`)),c.containerRecreated&&console.log(y.default.gray(` Run 'yarn twenty docker:start${s.test?" --test":""}' to wait for the server to be ready.`))},Kv=u=>{u.command("docker:start").description("Start the local Twenty container").option("-p, --port <port>","HTTP port").option("--test","Start a separate test instance (port 2021)").action(Go),u.command("docker:stop").description("Stop the local Twenty container").option("--test","Stop the test instance").action(qo),u.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(Ho),u.command("docker:status").description("Show container status").option("--test","Show status of the test instance").action(jo),u.command("docker:reset").description("Delete all data and start fresh").option("--test","Reset the test instance").action(zo),u.command("docker:upgrade [version]").description("Upgrade the Docker image").option("--test","Upgrade the test instance").action(Ko);const s=u.command("server",{hidden:!0}).description("Manage a Twenty server (local instance and server-side actions)"),r=(c,f)=>console.warn(y.default.yellow(`⚠ \`twenty server ${c}\` is deprecated. Use \`twenty ${f}\` instead.`));s.command("start").option("-p, --port <port>","HTTP port").option("--test","Start a separate test instance (port 2021)").action(async c=>{r("start","docker:start"),await Go(c)}),s.command("stop").option("--test","Stop the test instance").action(c=>{r("stop","docker:stop"),qo(c)}),s.command("logs").option("-n, --lines <lines>","Number of lines to show","50").option("--test","Show logs for the test instance").action(c=>{r("logs","docker:logs"),Ho(c)}),s.command("status").option("--test","Show status of the test instance").action(async c=>{r("status","docker:status"),await jo(c)}),s.command("reset").option("--test","Reset the test instance").action(c=>{r("reset","docker:reset"),zo(c)}),s.command("upgrade [version]").option("--test","Upgrade the test instance").action(async(c,f)=>{r("upgrade","docker:upgrade"),await Ko(c,f)}),s.command("catalog-sync").option("-r, --remote <name>","Sync on a specific remote").action(async c=>{r("catalog-sync","dev:catalog-sync");const{CatalogSyncCommand:f}=await Promise.resolve().then(()=>require("./catalog-sync-BjFX6eQu.js"));await new f().execute({remote:c.remote})})},Yv=u=>{try{return new URL(u).hostname.replace(/\./g,"-")}catch{return"remote"}},Yo=async(u,s)=>s?((await m.authLogin({apiKey:s,apiUrl:u})).success||(console.error(y.default.red("✗ Authentication failed.")),process.exit(1)),"API key"):Jv(u),Jv=async u=>{console.log(y.default.gray("Opening browser for authentication..."));const s=await m.authLoginOAuth({apiUrl:u});if(s.success)return"OAuth";console.log(y.default.yellow(s.error.message));const r=await Ye.default.prompt([{type:"password",name:"apiKey",message:"API Key:",mask:"*",validate:f=>f.length>0||"API key is required"}]);return(await m.authLogin({apiKey:r.apiKey,apiUrl:u})).success||(console.error(y.default.red("✗ Authentication failed.")),process.exit(1)),"API key"},Jo=async u=>{u.apiUrl&&console.warn(y.default.yellow("⚠ --api-url is deprecated. Use --url instead."));const s=u.test?m.getConfigPath(!0):void 0,r=new m.ConfigService(s?{configPath:s}:void 0),c=await r.getRemotes();if(u.as!==void 0&&c.includes(u.as)){const T=await r.getConfigForRemote(u.as);m.ConfigService.setActiveRemote(u.as);const $=await Yo(T.apiUrl,u.apiKey);console.log(y.default.green(`✓ Re-authenticated "${u.as}" via ${$}.`)),await r.setDefaultRemote(u.as),console.log(y.default.green(`✓ Default remote set to "${u.as}".`));return}let f=u.url??u.apiUrl;if(f)f=m.La(f);else{const T=await m.detectLocalServer();u.local?(T||(console.error(y.default.red(`No local Twenty server found.
369
+ Start one with: yarn twenty docker:start`)),process.exit(1)),console.log(y.default.gray(`Found local server at ${T}`)),f=T):f=m.La((await Ye.default.prompt([{type:"input",name:"serverUrl",message:"Twenty server URL:",validate:$=>{try{return new URL($),!0}catch{return"Please enter a valid URL"}}}])).serverUrl)}const w=u.as??Yv(f);m.ConfigService.setActiveRemote(w);const x=await Yo(f,u.apiKey);console.log(y.default.green(`✓ Remote "${w}" added (${f}) via ${x}.`)),await r.setDefaultRemote(w),console.log(y.default.green(`✓ Default remote set to "${w}".`))},Zo=async()=>{const u=new m.ConfigService,s=await u.getRemotes(),r=await u.getDefaultRemote();if(s.length===0){console.log("No remotes configured."),console.log("Use 'twenty remote:add' to add one.");return}console.log("");for(const c of s){const f=await u.getConfigForRemote(c),w=f.twentyCLIAccessToken?"oauth":f.apiKey?"api-key":"none",x=c===r,T=x?"* ":" ",$=x?y.default.bold(c):c;console.log(`${T}${$} ${y.default.gray(f.apiUrl)} [${w}]`)}console.log(`
370
+ `,y.default.gray("Use 'twenty remote:use <name>' to change default"))},Xo=async u=>{const s=new m.ConfigService,r=u??(await Ye.default.prompt([{type:"select",name:"remote",message:"Select default remote:",choices:await s.getRemotes()}])).remote;(await s.getRemotes()).includes(r)||(console.error(y.default.red(`Remote "${r}" not found.`)),process.exit(1)),await s.setDefaultRemote(r),console.log(y.default.green(`✓ Default remote set to "${r}".`))},Qo=async()=>{const u=new m.ConfigService,s=new m.ApiService,r=m.ConfigService.getActiveRemote(),c=await u.getConfig(),f=c.twentyCLIAccessToken?"oauth":c.apiKey?"api-key":"none";if(console.log(` Remote: ${y.default.bold(r)}`),console.log(` Server: ${c.apiUrl}`),f==="none"){console.log(` Auth: ${y.default.yellow("not configured")}`);return}const{authValid:w}=await s.validateAuth(),x=w?y.default.green(`${f} (valid)`):y.default.red(`${f} (invalid)`);console.log(` Auth: ${x}`)},eu=async u=>{const s=new m.ConfigService;(await s.getRemotes()).includes(u)||(console.error(y.default.red(`Remote "${u}" not found.`)),process.exit(1)),m.ConfigService.setActiveRemote(u),await s.clearConfig(),console.log(y.default.green(`✓ Remote "${u}" removed.`))},Zv=u=>{u.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(Jo),u.command("remote:list").description("List all configured remotes").action(Zo),u.command("remote:use [name]").description("Set the default remote").action(Xo),u.command("remote:status").description("Show active remote auth status").action(Qo),u.command("remote:remove <name>").description("Remove a remote").action(eu);const s=u.command("remote",{hidden:!0}).description("Manage remote Twenty servers"),r=(c,f)=>console.warn(y.default.yellow(`⚠ \`twenty remote ${c}\` is deprecated. Use \`twenty ${f}\` instead.`));s.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 c=>{r("add","remote:add"),await Jo(c)}),s.command("list").action(async()=>{r("list","remote:list"),await Zo()}),s.command("switch [name]").action(async c=>{r("switch","remote:use"),await Xo(c)}),s.command("status").action(async()=>{r("status","remote:status"),await Qo()}),s.command("remove <name>").action(async c=>{r("remove","remote:remove"),await eu(c)})},Xv=u=>{zv(u),Cm(u),Kv(u),Zv(u),Qm(u)};Em.inspect.defaultOptions.depth=10;const nn=new tu.Command;nn.name("twenty").description("CLI for Twenty application development").version(m.packageJson.version);nn.option("-r, --remote <name>","Use a specific remote (overrides the default set by remote:use)");nn.hook("preAction",async u=>{let r=(u.optsWithGlobals?u.optsWithGlobals():u.opts()).remote;r?console.log(y.default.gray(`Using remote: ${r}`)):r=await new m.ConfigService().getDefaultRemote(),m.ConfigService.setActiveRemote(r)});Xv(nn);nn.exitOverride();try{nn.parse()}catch(u){u instanceof tu.CommanderError&&process.exit(u.exitCode),u instanceof Error&&(console.error(y.default.red("Error:"),u.message),process.exit(1))}