twenty-sdk 2.10.1 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -1,57 +1,70 @@
1
1
  #!/usr/bin/env node
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
- `));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)),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,`{
2
+ "use strict";var dm=Object.create;var Lo=Object.defineProperty;var pm=Object.getOwnPropertyDescriptor;var hm=Object.getOwnPropertyNames;var gm=Object.getPrototypeOf,mm=Object.prototype.hasOwnProperty;var vm=(l,s,r,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let f of hm(s))!mm.call(l,f)&&f!==r&&Lo(l,f,{get:()=>s[f],enumerable:!(c=pm(s,f))||c.enumerable});return l};var ym=(l,s,r)=>(r=l!=null?dm(gm(l)):{},vm(s||!l||!l.__esModule?Lo(r,"default",{value:l,enumerable:!0}):r,l));const j=require("path"),h=require("./login-oauth-DzHcV9F2.js"),nt=require("node:fs/promises"),_m=require("chalk"),wm=require("inquirer"),J=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"),tl=require("commander"),Am=require("util"),Dt=l=>l&&l.__esModule?l:{default:l},Zi=Dt(j),v=Dt(_m),Ye=Dt(wm),nl=Dt(Sm),Em=Dt(Im),Oo=Dt(xm),rl=Dt(bt),Y=process.env.INIT_CWD||process.cwd(),pe=l=>l&&!l?.startsWith("/")?j.join(Y,l):l,bm=async l=>{const s=j.join(l,"package.json");if(await h.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=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=h.packageJson.version,r=await bm(l);if(!r)return;const c=Uo(s),f=Uo(r);c===null||f===null||c!==f&&(console.warn(v.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 il{async execute(s){s.private?await this.executePrivate(s):await this.executeNpm(s)}async executeNpm(s){const r=s.appPath??Y;await tn(r),console.log(v.default.blue("Publishing to npm...")),console.log(v.default.gray(`App path: ${r}
4
+ `));const c=await h.appPublish({appPath:r,npmTag:s.tag,onProgress:f=>console.log(v.default.gray(f))});c.success||(console.error(v.default.red(c.error.message)),process.exit(1)),console.log(v.default.green("✓ Published to npm successfully"))}async executePrivate(s){const r=s.appPath??Y;await tn(r);const c=s.remote??h.ConfigService.getActiveRemote();console.log(v.default.blue(`Deploying application on ${c}...`)),console.log(v.default.gray(`App path: ${r}
5
+ `));const f=B=>console.log(v.default.gray(B)),w=await h.appBuild({appPath:r,tarball:!0,onProgress:f});w.success||(console.error(v.default.red(w.error.message)),process.exit(1));const x=await h.appDeploy({tarballPath:w.data.tarballPath,remote:s.remote,onProgress:f});x.success||(console.error(v.default.red(x.error.message)),process.exit(1));const R=await h.readJson(Zi.default.join(r,"package.json")).catch(()=>{}),L=R?.name??x.data.name,T=R?.version??"unknown";console.log(v.default.green(`
6
+ ✓ Published ${L} v${T} to ${c}
7
+ `)),console.log(" To install deployed application: `yarn twenty app:install`")}}class sl{async execute(s){const r=s.appPath??Y;await tn(r),await h.checkServerVersionCompatibility();const c=s.remote??h.ConfigService.getActiveRemote();console.log(v.default.blue(`Installing application on ${c}...`)),console.log(v.default.gray(`App path: ${r}
8
+ `));const f=await h.appInstall({appPath:r,remote:s.remote});f.success||(console.error(v.default.red(f.error.message)),process.exit(1)),console.log(v.default.green("✓ Application installed"))}}class al{async execute({appPath:s=Y,askForConfirmation:r}){const c=h.ConfigService.getActiveRemote();console.log(v.default.blue(`🚀 Uninstall Twenty Application on ${c}`)),console.log(v.default.gray(`📁 App Path: ${s}
9
+ `)),r&&!await this.confirmationPrompt()&&(console.error(v.default.red("⛔️ Aborting uninstall")),process.exit(1));const f=await h.appUninstall({appPath:s});return f.success?(console.log(v.default.green("✅ Application uninstalled successfully")),{success:!0,data:void 0}):(console.error(v.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=l=>{const s=new il,r=new sl,c=new al;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,w)=>{await s.execute({appPath:pe(f),private:w.private,remote:w.remote,tag:w.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,w)=>{await r.execute({appPath:pe(f),remote:w.remote})}),l.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:pe(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(l,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",R="Invalid `variable` option passed into `_.template`",L="Invalid `imports` option passed into `_.template`",T="__lodash_hash_undefined__",B=500,ne="__lodash_placeholder__",Z=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,Ar=512,yl=30,_l="...",wl=800,Sl=16,Qi=1,Il=2,xl=3,Ct=1/0,mt=9007199254740991,Al=17976931348623157e292,Fn=NaN,Ze=4294967295,El=Ze-1,bl=Ze>>>1,Cl=[["ary",it],["bind",me],["bindKey",gt],["curry",ke],["curryRight",rt],["flip",Ar],["partial",ce],["partialRight",sn],["rearg",an]],Wt="[object Arguments]",$n="[object Array]",Tl="[object AsyncFunction]",on="[object Boolean]",ln="[object Date]",Rl="[object DOMException]",Nn="[object Error]",Ln="[object Function]",es="[object GeneratorFunction]",Ve="[object Map]",un="[object Number]",Pl="[object Null]",st="[object Object]",ts="[object Promise]",Fl="[object Proxy]",cn="[object RegExp]",Ge="[object Set]",fn="[object String]",On="[object Symbol]",$l="[object Undefined]",dn="[object WeakMap]",Nl="[object WeakSet]",pn="[object ArrayBuffer]",Bt="[object DataView]",Er="[object Float32Array]",br="[object Float64Array]",Cr="[object Int8Array]",Tr="[object Int16Array]",Rr="[object Int32Array]",Pr="[object Uint8Array]",Fr="[object Uint8ClampedArray]",$r="[object Uint16Array]",Nr="[object Uint32Array]",Ll=/\b__p \+= '';/g,Ol=/\b(__p \+=) '' \+/g,Ul=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ns=/&(?:amp|lt|gt|quot|#39);/g,rs=/[&<>"']/g,Dl=RegExp(ns.source),Ml=RegExp(rs.source),Wl=/<%-([\s\S]+?)%>/g,Bl=/<%([\s\S]+?)%>/g,is=/<%=([\s\S]+?)%>/g,kl=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Vl=/^\w*$/,Gl=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Lr=/[\\^$.*+?()[\]{}|]/g,jl=RegExp(Lr.source),Or=/^\s+/,ql=/\s/,Hl=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,zl=/\{\n\/\* \[wrapped with (.+)\] \*/,Kl=/,? & /,Yl=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ss=/[()=,{}\[\]\/\s]/,Jl=/\\(\\)?/g,Zl=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,as=/\w*$/,Xl=/^[-+]0x[0-9a-f]+$/i,Ql=/^0b[01]+$/i,eu=/^\[object .+?Constructor\]$/,tu=/^0o[0-7]+$/i,nu=/^(?:0|[1-9]\d*)$/,ru=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Un=/($^)/,iu=/['\n\r\u2028\u2029\\]/g,Dn="\\ud800-\\udfff",su="\\u0300-\\u036f",au="\\ufe20-\\ufe2f",ou="\\u20d0-\\u20ff",os=su+au+ou,ls="\\u2700-\\u27bf",us="a-z\\xdf-\\xf6\\xf8-\\xff",lu="\\xac\\xb1\\xd7\\xf7",uu="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",cu="\\u2000-\\u206f",fu=" \\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=lu+uu+cu+fu,Ur="['’]",du="["+Dn+"]",ps="["+ds+"]",Mn="["+os+"]",hs="\\d+",pu="["+ls+"]",gs="["+us+"]",ms="[^"+Dn+ds+hs+ls+us+cs+"]",Dr="\\ud83c[\\udffb-\\udfff]",hu="(?:"+Mn+"|"+Dr+")",vs="[^"+Dn+"]",Mr="(?:\\ud83c[\\udde6-\\uddff]){2}",Wr="[\\ud800-\\udbff][\\udc00-\\udfff]",kt="["+cs+"]",ys="\\u200d",_s="(?:"+gs+"|"+ms+")",gu="(?:"+kt+"|"+ms+")",ws="(?:"+Ur+"(?:d|ll|m|re|s|t|ve))?",Ss="(?:"+Ur+"(?:D|LL|M|RE|S|T|VE))?",Is=hu+"?",xs="["+fs+"]?",mu="(?:"+ys+"(?:"+[vs,Mr,Wr].join("|")+")"+xs+Is+")*",vu="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",yu="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",As=xs+Is+mu,_u="(?:"+[pu,Mr,Wr].join("|")+")"+As,wu="(?:"+[vs+Mn+"?",Mn,Mr,Wr,du].join("|")+")",Su=RegExp(Ur,"g"),Iu=RegExp(Mn,"g"),Br=RegExp(Dr+"(?="+Dr+")|"+wu+As,"g"),xu=RegExp([kt+"?"+gs+"+"+ws+"(?="+[ps,kt,"$"].join("|")+")",gu+"+"+Ss+"(?="+[ps,kt+_s,"$"].join("|")+")",kt+"?"+_s+"+"+ws,kt+"+"+Ss,yu,vu,hs,_u].join("|"),"g"),Au=RegExp("["+ys+Dn+os+fs+"]"),Eu=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,bu=["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"],Cu=-1,Q={};Q[Er]=Q[br]=Q[Cr]=Q[Tr]=Q[Rr]=Q[Pr]=Q[Fr]=Q[$r]=Q[Nr]=!0,Q[Wt]=Q[$n]=Q[pn]=Q[on]=Q[Bt]=Q[ln]=Q[Nn]=Q[Ln]=Q[Ve]=Q[un]=Q[st]=Q[cn]=Q[Ge]=Q[fn]=Q[dn]=!1;var X={};X[Wt]=X[$n]=X[pn]=X[Bt]=X[on]=X[ln]=X[Er]=X[br]=X[Cr]=X[Tr]=X[Rr]=X[Ve]=X[un]=X[st]=X[cn]=X[Ge]=X[fn]=X[On]=X[Pr]=X[Fr]=X[$r]=X[Nr]=!0,X[Nn]=X[Ln]=X[dn]=!1;var Tu={À:"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"},Ru={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Pu={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Fu={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},$u=parseFloat,Nu=parseInt,Es=typeof h.commonjsGlobal=="object"&&h.commonjsGlobal&&h.commonjsGlobal.Object===Object&&h.commonjsGlobal,Lu=typeof self=="object"&&self&&self.Object===Object&&self,fe=Es||Lu||Function("return this")(),kr=s&&!s.nodeType&&s,Tt=kr&&!0&&l&&!l.nodeType&&l,bs=Tt&&Tt.exports===kr,Vr=bs&&Es.process,$e=(function(){try{var g=Tt&&Tt.require&&Tt.require("util").types;return g||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 Ae(g,_,y){switch(y.length){case 0:return g.call(_);case 1:return g.call(_,y[0]);case 2:return g.call(_,y[0],y[1]);case 3:return g.call(_,y[0],y[1],y[2])}return g.apply(_,y)}function Ou(g,_,y,C){for(var O=-1,q=g==null?0:g.length;++O<q;){var ae=g[O];_(C,ae,y(ae),g)}return C}function Ee(g,_){for(var y=-1,C=g==null?0:g.length;++y<C&&_(g[y],y,g)!==!1;);return g}function Uu(g,_){for(var y=g==null?0:g.length;y--&&_(g[y],y,g)!==!1;);return g}function Ns(g,_){for(var y=-1,C=g==null?0:g.length;++y<C;)if(!_(g[y],y,g))return!1;return!0}function vt(g,_){for(var y=-1,C=g==null?0:g.length,O=0,q=[];++y<C;){var ae=g[y];_(ae,y,g)&&(q[O++]=ae)}return q}function Wn(g,_){var y=g==null?0:g.length;return!!y&&Vt(g,_,0)>-1}function Gr(g,_,y){for(var C=-1,O=g==null?0:g.length;++C<O;)if(y(_,g[C]))return!0;return!1}function ee(g,_){for(var y=-1,C=g==null?0:g.length,O=Array(C);++y<C;)O[y]=_(g[y],y,g);return O}function yt(g,_){for(var y=-1,C=_.length,O=g.length;++y<C;)g[O+y]=_[y];return g}function jr(g,_,y,C){var O=-1,q=g==null?0:g.length;for(C&&q&&(y=g[++O]);++O<q;)y=_(y,g[O],O,g);return y}function Du(g,_,y,C){var O=g==null?0:g.length;for(C&&O&&(y=g[--O]);O--;)y=_(y,g[O],O,g);return y}function qr(g,_){for(var y=-1,C=g==null?0:g.length;++y<C;)if(_(g[y],y,g))return!0;return!1}var Mu=Hr("length");function Wu(g){return g.split("")}function Bu(g){return g.match(Yl)||[]}function Ls(g,_,y){var C;return y(g,function(O,q,ae){if(_(O,q,ae))return C=q,!1}),C}function Bn(g,_,y,C){for(var O=g.length,q=y+(C?1:-1);C?q--:++q<O;)if(_(g[q],q,g))return q;return-1}function Vt(g,_,y){return _===_?Xu(g,_,y):Bn(g,Os,y)}function ku(g,_,y,C){for(var O=y-1,q=g.length;++O<q;)if(C(g[O],_))return O;return-1}function Os(g){return g!==g}function Us(g,_){var y=g==null?0:g.length;return y?Kr(g,_)/y:Fn}function Hr(g){return function(_){return _==null?r:_[g]}}function zr(g){return function(_){return g==null?r:g[_]}}function Ds(g,_,y,C,O){return O(g,function(q,ae,K){y=C?(C=!1,q):_(y,q,ae,K)}),y}function Vu(g,_){var y=g.length;for(g.sort(_);y--;)g[y]=g[y].value;return g}function Kr(g,_){for(var y,C=-1,O=g.length;++C<O;){var q=_(g[C]);q!==r&&(y=y===r?q:y+q)}return y}function Yr(g,_){for(var y=-1,C=Array(g);++y<g;)C[y]=_(y);return C}function Gu(g,_){return ee(_,function(y){return[y,g[y]]})}function Ms(g){return g&&g.slice(0,Vs(g)+1).replace(Or,"")}function be(g){return function(_){return g(_)}}function Jr(g,_){return ee(_,function(y){return g[y]})}function hn(g,_){return g.has(_)}function Ws(g,_){for(var y=-1,C=g.length;++y<C&&Vt(_,g[y],0)>-1;);return y}function Bs(g,_){for(var y=g.length;y--&&Vt(_,g[y],0)>-1;);return y}function ju(g,_){for(var y=g.length,C=0;y--;)g[y]===_&&++C;return C}var qu=zr(Tu),Hu=zr(Ru);function zu(g){return"\\"+Fu[g]}function Ku(g,_){return g==null?r:g[_]}function Gt(g){return Au.test(g)}function Yu(g){return Eu.test(g)}function Ju(g){for(var _,y=[];!(_=g.next()).done;)y.push(_.value);return y}function Zr(g){var _=-1,y=Array(g.size);return g.forEach(function(C,O){y[++_]=[O,C]}),y}function ks(g,_){return function(y){return g(_(y))}}function _t(g,_){for(var y=-1,C=g.length,O=0,q=[];++y<C;){var ae=g[y];(ae===_||ae===ne)&&(g[y]=ne,q[O++]=y)}return q}function kn(g){var _=-1,y=Array(g.size);return g.forEach(function(C){y[++_]=C}),y}function Zu(g){var _=-1,y=Array(g.size);return g.forEach(function(C){y[++_]=[C,C]}),y}function Xu(g,_,y){for(var C=y-1,O=g.length;++C<O;)if(g[C]===_)return C;return-1}function Qu(g,_,y){for(var C=y+1;C--;)if(g[C]===_)return C;return C}function jt(g){return Gt(g)?tc(g):Mu(g)}function je(g){return Gt(g)?nc(g):Wu(g)}function Vs(g){for(var _=g.length;_--&&ql.test(g.charAt(_)););return _}var ec=zr(Pu);function tc(g){for(var _=Br.lastIndex=0;Br.test(g);)++_;return _}function nc(g){return g.match(Br)||[]}function rc(g){return g.match(xu)||[]}var ic=(function g(_){_=_==null?fe:qt.defaults(fe.Object(),_,qt.pick(fe,bu));var y=_.Array,C=_.Date,O=_.Error,q=_.Function,ae=_.Math,K=_.Object,Xr=_.RegExp,sc=_.String,Ne=_.TypeError,Vn=y.prototype,ac=q.prototype,Ht=K.prototype,Gn=_["__core-js_shared__"],jn=ac.toString,H=Ht.hasOwnProperty,oc=0,Gs=(function(){var e=/[^.]+$/.exec(Gn&&Gn.keys&&Gn.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})(),qn=Ht.toString,lc=jn.call(K),uc=fe._,cc=Xr("^"+jn.call(H).replace(Lr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Hn=bs?_.Buffer:r,wt=_.Symbol,zn=_.Uint8Array,js=Hn?Hn.allocUnsafe:r,Kn=ks(K.getPrototypeOf,K),qs=K.create,Hs=Ht.propertyIsEnumerable,Yn=Vn.splice,zs=wt?wt.isConcatSpreadable:r,gn=wt?wt.iterator:r,Rt=wt?wt.toStringTag:r,Jn=(function(){try{var e=Lt(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=Hn?Hn.isBuffer:r,Ks=_.isFinite,gc=Vn.join,mc=ks(K.keys,K),oe=ae.max,he=ae.min,vc=C.now,yc=_.parseInt,Ys=ae.random,_c=Vn.reverse,ei=Lt(_,"DataView"),mn=Lt(_,"Map"),ti=Lt(_,"Promise"),zt=Lt(_,"Set"),vn=Lt(_,"WeakMap"),yn=Lt(K,"create"),Qn=vn&&new vn,Kt={},wc=Ot(ei),Sc=Ot(mn),Ic=Ot(ti),xc=Ot(zt),Ac=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 V)){if(e instanceof Le)return e;if(H.call(e,"__wrapped__"))return Za(e)}return new Le(e)}var Yt=(function(){function e(){}return function(t){if(!te(t))return{};if(qs)return qs(t);e.prototype=t;var n=new e;return e.prototype=r,n}})();function tr(){}function Le(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}o.templateSettings={escape:Wl,evaluate:Bl,interpolate:is,variable:"",imports:{_:o}},o.prototype=tr.prototype,o.prototype.constructor=o,Le.prototype=Yt(tr.prototype),Le.prototype.constructor=Le;function V(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Ze,this.__views__=[]}function Ec(){var e=new V(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 V(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,u=Bf(0,a,this.__views__),d=u.start,p=u.end,m=p-d,S=i?p:d-1,I=this.__iteratees__,A=I.length,E=0,P=he(m,this.__takeCount__);if(!n||!i&&a==m&&P==m)return wa(e,this.__actions__);var N=[];e:for(;m--&&E<P;){S+=t;for(var M=-1,F=e[S];++M<A;){var k=I[M],G=k.iteratee,Re=k.type,_e=G(F);if(Re==Il)F=_e;else if(!_e){if(Re==Qi)continue e;break e}}N[E++]=F}return N}V.prototype=Yt(tr.prototype),V.prototype.constructor=V;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===T?r:n}return H.call(t,e)?t[e]:r}function Fc(e){var t=this.__data__;return yn?t[e]!==r:H.call(t,e)}function $c(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=yn&&t===r?T: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 Nc(){this.__data__=[],this.size=0}function Lc(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=Nc,at.prototype.delete=Lc,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,T),this}function jc(e){return this.__data__.has(e)}Ft.prototype.add=Ft.prototype.push=Gc,Ft.prototype.has=jc;function qe(e){var t=this.__data__=new at(e);this.size=t.size}function qc(){this.__data__=new at,this.size=0}function Hc(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}qe.prototype.clear=qc,qe.prototype.delete=Hc,qe.prototype.get=zc,qe.prototype.has=Kc,qe.prototype.set=Yc;function Zs(e,t){var n=U(e),i=!n&&Ut(e),a=!n&&!i&&Et(e),u=!n&&!i&&!a&&Qt(e),d=n||i||a||u,p=d?Yr(e.length,sc):[],m=p.length;for(var S in e)(t||H.call(e,S))&&!(d&&(S=="length"||a&&(S=="offset"||S=="parent")||u&&(S=="buffer"||S=="byteLength"||S=="byteOffset")||ct(S,m)))&&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];(!(H.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,u,d){t(i,a,n(a),d)}),i}function Qs(e,t){return e&&et(t,le(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=y(i),u=e==null;++n<i;)a[n]=u?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,u){var d,p=t&Z,m=t&ht,S=t&Be;if(n&&(d=a?n(e,i,a,u):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 A=ge(e),E=A==Ln||A==es;if(Et(e))return xa(e,p);if(A==st||A==Wt||E&&!a){if(d=m||E?{}:Va(e),!p)return m?Ff(e,Qc(d,e)):Pf(e,Qs(d,e))}else{if(!X[A])return a?e:{};d=Gf(e,A,p)}}u||(u=new qe);var P=u.get(e);if(P)return P;u.set(e,d),yo(e)?e.forEach(function(F){d.add(Oe(F,t,n,F,e,u))}):mo(e)&&e.forEach(function(F,k){d.set(k,Oe(F,t,n,k,e,u))});var N=S?m?xi:Ii:m?Ie:le,M=I?r:N(e);return Ee(M||e,function(F,k){M&&(k=F,F=e[k]),wn(d,k,Oe(F,t,n,k,e,u))}),d}function ef(e){var t=le(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],u=t[a],d=e[a];if(d===r&&!(a in e)||!u(d))return!1}return!0}function ta(e,t,n){if(typeof e!="function")throw new Ne(x);return Cn(function(){e.apply(r,n)},t)}function Sn(e,t,n,i){var a=-1,u=Wn,d=!0,p=e.length,m=[],S=t.length;if(!p)return m;n&&(t=ee(t,be(n))),i?(u=Gr,d=!1):t.length>=f&&(u=hn,d=!1,t=new Ft(t));e:for(;++a<p;){var I=e[a],A=n==null?I:n(I);if(I=i||I!==0?I:0,d&&A===A){for(var E=S;E--;)if(t[E]===A)continue e;m.push(I)}else u(t,A,i)||m.push(I)}return m}var St=Ta(Qe),na=Ta(si,!0);function tf(e,t){var n=!0;return St(e,function(i,a,u){return n=!!t(i,a,u),n}),n}function rr(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,m=u}return m}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,u){t(i,a,u)&&n.push(i)}),n}function de(e,t,n,i,a){var u=-1,d=e.length;for(n||(n=qf),a||(a=[]);++u<d;){var p=e[u];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,le)}function si(e,t){return e&&ia(e,t,le)}function ir(e,t){return vt(t,function(n){return ft(e[n])})}function Nt(e,t){t=xt(t,e);for(var n=0,i=t.length;e!=null&&n<i;)e=e[He(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?$l:Pl:Rt&&Rt in K(e)?Wf(e):Xf(e)}function ai(e,t){return e>t}function rf(e,t){return e!=null&&H.call(e,t)}function sf(e,t){return e!=null&&t in K(e)}function af(e,t,n){return e>=he(t,n)&&e<oe(t,n)}function oi(e,t,n){for(var i=n?Gr:Wn,a=e[0].length,u=e.length,d=u,p=y(u),m=1/0,S=[];d--;){var I=e[d];d&&t&&(I=ee(I,be(t))),m=he(I.length,m),p[d]=!n&&(t||a>=120&&I.length>=120)?new Ft(d&&I):r}I=e[0];var A=-1,E=p[0];e:for(;++A<a&&S.length<m;){var P=I[A],N=t?t(P):P;if(P=n||P!==0?P:0,!(E?hn(E,N):i(S,N,n))){for(d=u;--d;){var M=p[d];if(!(M?hn(M,N):i(e[d],N,n)))continue e}E&&E.push(N),S.push(P)}}return S}function of(e,t,n,i){return Qe(e,function(a,u,d){t(i,n(a),u,d)}),i}function In(e,t,n){t=xt(t,e),e=Ha(e,t);var i=e==null?e:e[He(De(t))];return i==null?r:Ae(i,e,n)}function aa(e){return re(e)&&ve(e)==Wt}function lf(e){return re(e)&&ve(e)==pn}function uf(e){return re(e)&&ve(e)==ln}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,u){var d=U(e),p=U(t),m=d?$n:ge(e),S=p?$n:ge(t);m=m==Wt?st:m,S=S==Wt?st:S;var I=m==st,A=S==st,E=m==S;if(E&&Et(e)){if(!Et(t))return!1;d=!0,I=!1}if(E&&!I)return u||(u=new qe),d||Qt(e)?Wa(e,t,n,i,a,u):Df(e,t,m,n,i,a,u);if(!(n&Fe)){var P=I&&H.call(e,"__wrapped__"),N=A&&H.call(t,"__wrapped__");if(P||N){var M=P?e.value():e,F=N?t.value():t;return u||(u=new qe),a(M,F,n,i,u)}}return E?(u||(u=new qe),Mf(e,t,n,i,a,u)):!1}function ff(e){return re(e)&&ge(e)==Ve}function li(e,t,n,i){var a=n.length,u=a,d=!i;if(e==null)return!u;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<u;){p=n[a];var m=p[0],S=e[m],I=p[1];if(d&&p[2]){if(S===r&&!(m in e))return!1}else{var A=new qe;if(i)var E=i(S,I,m,e,t,A);if(!(E===r?xn(I,S,Fe|Mt,i,A):E))return!1}}return!0}function oa(e){if(!te(e)||zf(e))return!1;var t=ft(e)?cc:eu;return t.test(Ot(e))}function df(e){return re(e)&&ve(e)==cn}function pf(e){return re(e)&&ge(e)==Ge}function hf(e){return re(e)&&Sr(e.length)&&!!Q[ve(e)]}function la(e){return typeof e=="function"?e:e==null?xe:typeof e=="object"?U(e)?fa(e[0],e[1]):ca(e):$o(e)}function ui(e){if(!bn(e))return mc(e);var t=[];for(var n in K(e))H.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||!H.call(e,i))||n.push(i);return n}function ci(e,t){return e<t}function ua(e,t){var n=-1,i=Se(e)?y(e.length):[];return St(e,function(a,u,d){i[++n]=t(a,u,d)}),i}function ca(e){var t=Ei(e);return t.length==1&&t[0][2]?ja(t[0][0],t[0][1]):function(n){return n===e||li(n,e,t)}}function fa(e,t){return Ci(e)&&Ga(t)?ja(He(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(u,d){if(a||(a=new qe),te(u))mf(e,t,d,n,sr,i,a);else{var p=i?i(Ri(e,d),u,d+"",e,t,a):r;p===r&&(p=u),ni(e,d,p)}},Ie)}function mf(e,t,n,i,a,u,d){var p=Ri(e,n),m=Ri(t,n),S=d.get(m);if(S){ni(e,n,S);return}var I=u?u(p,m,n+"",e,t,d):r,A=I===r;if(A){var E=U(m),P=!E&&Et(m),N=!E&&!P&&Qt(m);I=m,E||P||N?U(p)?I=p:ie(p)?I=we(p):P?(A=!1,I=xa(m,!0)):N?(A=!1,I=Aa(m,!0)):I=[]:Tn(m)||Ut(m)?(I=p,Ut(p)?I=So(p):(!te(p)||ft(p))&&(I=Va(m))):A=!1}A&&(d.set(m,I),a(I,m,i,u,d),d.delete(m)),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(u){return U(u)?function(d){return Nt(d,u.length===1?u[0]:u)}:u}):t=[xe];var i=-1;t=ee(t,be($()));var a=ua(e,function(u,d,p){var m=ee(t,function(S){return S(u)});return{criteria:m,index:++i,value:u}});return Vu(a,function(u,d){return Rf(u,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,u={};++i<a;){var d=t[i],p=Nt(e,d);n(p,d)&&An(u,xt(d,e),p)}return u}function yf(e){return function(t){return Nt(t,e)}}function fi(e,t,n,i){var a=i?ku:Vt,u=-1,d=t.length,p=e;for(e===t&&(t=we(t)),n&&(p=ee(e,be(n)));++u<d;)for(var m=0,S=t[u],I=n?n(S):S;(m=a(p,I,m,i))>-1;)p!==e&&Yn.call(p,m,1),Yn.call(e,m,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!==u){var u=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,u=oe(Zn((t-e)/(n||1)),0),d=y(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=Xn(t/2),t&&(e+=e);while(t);return n}function W(e,t){return Pi(qa(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 An(e,t,n,i){if(!te(e))return e;t=xt(t,e);for(var a=-1,u=t.length,d=u-1,p=e;p!=null&&++a<u;){var m=He(t[a]),S=n;if(m==="__proto__"||m==="constructor"||m==="prototype")return e;if(a!=d){var I=p[m];S=i?i(I,m,p):r,S===r&&(S=te(I)?I:ct(t[a+1])?[]:{})}wn(p,m,S),p=p[m]}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 u=y(a);++i<a;)u[i]=e[i+t];return u}function Af(e,t){var n;return St(e,function(i,a,u){return n=t(i,a,u),!n}),!!n}function ar(e,t,n){var i=0,a=e==null?i:e.length;if(typeof t=="number"&&t===t&&a<=bl){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,xe,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,m=Te(t),S=t===r;a<u;){var I=Xn((a+u)/2),A=n(e[I]),E=A!==r,P=A===null,N=A===A,M=Te(A);if(d)var F=i||N;else S?F=N&&(i||E):p?F=N&&E&&(i||!P):m?F=N&&E&&!P&&(i||!M):P||M?F=!1:F=i?A<=t:A<t;F?a=I+1:u=I}return he(u,El)}function va(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||!ze(p,m)){var m=p;u[a++]=d===0?0:d}}return u}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,u=e.length,d=!0,p=[],m=p;if(n)d=!1,a=Gr;else if(u>=f){var S=t?null:Of(e);if(S)return kn(S);d=!1,a=hn,m=new Ft}else m=t?[]:p;e:for(;++i<u;){var I=e[i],A=t?t(I):I;if(I=n||I!==0?I:0,d&&A===A){for(var E=m.length;E--;)if(m[E]===A)continue e;t&&m.push(A),p.push(I)}else a(m,A,n)||(m!==p&&m.push(A),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=He(t[n]);if(a==="__proto__"&&!H.call(e,"__proto__")||(a==="constructor"||a==="prototype")&&n<i-1)return!1}var u=Ha(e,t);return u==null||delete u[He(De(t))]}function _a(e,t,n,i){return An(e,t,n(Nt(e,t)),i)}function or(e,t,n,i){for(var a=e.length,u=i?a:-1;(i?u--:++u<a)&&t(e[u],u,e););return n?Ue(e,i?0:u,i?u+1:a):Ue(e,i?u+1:0,i?a:u)}function wa(e,t){var n=e;return n instanceof V&&(n=n.value()),jr(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,u=y(i);++a<i;)for(var d=e[a],p=-1;++p<i;)p!=a&&(u[a]=Sn(u[a]||d,e[p],t,n));return It(de(u,1),t,n)}function Sa(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 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 Ef=W;function At(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=js?js(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 Aa(e,t){var n=t?_i(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Ea(e,t){if(e!==t){var n=e!==r,i=e===null,a=e===e,u=Te(e),d=t!==r,p=t===null,m=t===t,S=Te(t);if(!p&&!S&&!u&&e>t||u&&d&&m&&!p&&!S||i&&d&&m||!n&&m||!a)return 1;if(!i&&!u&&!S&&e<t||S&&n&&a&&!i&&!u||p&&n&&a||!d&&a||!m)return-1}return 0}function Rf(e,t,n){for(var i=-1,a=e.criteria,u=t.criteria,d=a.length,p=n.length;++i<d;){var m=Ea(a[i],u[i]);if(m){if(i>=p)return m;var S=n[i];return m*(S=="desc"?-1:1)}}return e.index-t.index}function ba(e,t,n,i){for(var a=-1,u=e.length,d=n.length,p=-1,m=t.length,S=oe(u-d,0),I=y(m+S),A=!i;++p<m;)I[p]=t[p];for(;++a<d;)(A||a<u)&&(I[n[a]]=e[a]);for(;S--;)I[p++]=e[a++];return I}function Ca(e,t,n,i){for(var a=-1,u=e.length,d=-1,p=n.length,m=-1,S=t.length,I=oe(u-p,0),A=y(I+S),E=!i;++a<I;)A[a]=e[a];for(var P=a;++m<S;)A[P+m]=t[m];for(;++d<p;)(E||a<u)&&(A[P+n[d]]=e[a++]);return A}function we(e,t){var n=-1,i=e.length;for(t||(t=y(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],m=i?i(n[p],e[p],p,n,e):r;m===r&&(m=e[p]),a?Xe(n,p,m):wn(n,p,m)}return n}function Pf(e,t){return et(e,bi(e),t)}function Ff(e,t){return et(e,Ba(e),t)}function lr(e,t){return function(n,i){var a=U(n)?Ou:Xc,u=t?t():{};return a(n,e,$(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&&ye(n[0],n[1],d)&&(u=a<3?r:u,a=1),t=K(t);++i<a;){var p=n[i];p&&e(t,p,i,u)}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,u=t?a:-1,d=K(n);(t?u--:++u<a)&&i(d[u],u,d)!==!1;);return n}}function Ra(e){return function(t,n,i){for(var a=-1,u=K(t),d=i(t),p=d.length;p--;){var m=d[e?p:++a];if(n(u[m],m,u)===!1)break}return t}}function $f(e,t,n){var i=t&me,a=En(e);function u(){var d=this&&this!==fe&&this instanceof u?a:e;return d.apply(i?n:this,arguments)}return u}function Pa(e){return function(t){t=z(t);var n=Gt(t)?je(t):r,i=n?n[0]:t.charAt(0),a=n?At(n,1).join(""):t.slice(1);return i[e]()+a}}function Zt(e){return function(t){return jr(Po(Ro(t).replace(Su,"")),e,"")}}function En(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 Nf(e,t,n){var i=En(e);function a(){for(var u=arguments.length,d=y(u),p=u,m=Xt(a);p--;)d[p]=arguments[p];var S=u<3&&d[0]!==m&&d[u-1]!==m?[]:_t(d,m);if(u-=S.length,u<n)return Oa(e,t,ur,a.placeholder,r,d,S,r,r,n-u);var I=this&&this!==fe&&this instanceof a?i:e;return Ae(I,this,d)}return a}function Fa(e){return function(t,n,i){var a=K(t);if(!Se(t)){var u=$(n,3);t=le(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 $a(e){return ut(function(t){var n=t.length,i=n,a=Le.prototype.thru;for(e&&t.reverse();i--;){var u=t[i];if(typeof u!="function")throw new Ne(x);if(a&&!d&&pr(u)=="wrapper")var d=new Le([],!0)}for(i=d?i:n;++i<n;){u=t[i];var p=pr(u),m=p=="wrapper"?Ai(u):r;m&&Ti(m[0])&&m[1]==(it|ke|ce|an)&&!m[4].length&&m[9]==1?d=d[pr(m[0])].apply(d,m[3]):d=u.length==1&&Ti(u)?d[p]():d.thru(u)}return function(){var S=arguments,I=S[0];if(d&&S.length==1&&U(I))return d.plant(I).value();for(var A=0,E=n?t[A].apply(this,S):I;++A<n;)E=t[A].call(this,E);return E}})}function ur(e,t,n,i,a,u,d,p,m,S){var I=t&it,A=t&me,E=t&gt,P=t&(ke|rt),N=t&Ar,M=E?r:En(e);function F(){for(var k=arguments.length,G=y(k),Re=k;Re--;)G[Re]=arguments[Re];if(P)var _e=Xt(F),Pe=ju(G,_e);if(i&&(G=ba(G,i,a,P)),u&&(G=Ca(G,u,d,P)),k-=Pe,P&&k<S){var se=_t(G,_e);return Oa(e,t,ur,F.placeholder,n,G,se,p,m,S-k)}var Ke=A?n:this,pt=E?Ke[e]:e;return k=G.length,p?G=Qf(G,p):N&&k>1&&G.reverse(),I&&m<k&&(G.length=m),this&&this!==fe&&this instanceof F&&(pt=M||En(pt)),pt.apply(Ke,G)}return F}function Na(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 ut(function(t){return t=ee(t,be($())),W(function(n){var i=this;return e(t,function(a){return Ae(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/jt(t)));return Gt(t)?At(je(i),0,e).join(""):i.slice(0,e)}function Lf(e,t,n,i){var a=t&me,u=En(e);function d(){for(var p=-1,m=arguments.length,S=-1,I=i.length,A=y(I+m),E=this&&this!==fe&&this instanceof d?u:e;++S<I;)A[S]=i[S];for(;m--;)A[S++]=arguments[++p];return Ae(E,a?n:this,A)}return d}function La(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,u,d,p,m,S){var I=t&ke,A=I?d:r,E=I?r:d,P=I?u:r,N=I?r:u;t|=I?ce:sn,t&=~(I?sn:ce),t&rn||(t&=-4);var M=[e,t,a,P,A,N,E,p,m,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:he(D(i),292),i&&Ks(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 Of=zt&&1/kn(new zt([,-0]))[1]==Ct?function(e){return new zt(e)}:ji;function Ua(e){return function(t){var n=ge(t);return n==Ve?Zr(t):n==Ge?Zu(t):Gu(t,e(t))}}function lt(e,t,n,i,a,u,d,p){var m=t&gt;if(!m&&typeof e!="function")throw new Ne(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,A=a;i=a=r}var E=m?r:Ai(e),P=[e,t,n,i,a,I,A,u,d,p];if(E&&Jf(P,E),e=P[0],t=P[1],n=P[2],i=P[3],a=P[4],p=P[9]=P[9]===r?m?0:e.length:oe(P[9]-S,0),!p&&t&(ke|rt)&&(t&=-25),!t||t==me)var N=$f(e,t,n);else t==ke||t==rt?N=Nf(e,t,p):(t==ce||t==(me|ce))&&!a.length?N=Lf(e,t,n,i):N=ur.apply(r,P);var M=E?ma:za;return Ka(M(N,P),e,t)}function Da(e,t,n,i){return e===r||ze(e,Ht[n])&&!H.call(i,n)?t:e}function Ma(e,t,n,i,a,u){return te(e)&&te(t)&&(u.set(t,e),sr(e,t,r,Ma,u),u.delete(t)),e}function Uf(e){return Tn(e)?r:e}function Wa(e,t,n,i,a,u){var d=n&Fe,p=e.length,m=t.length;if(p!=m&&!(d&&m>p))return!1;var S=u.get(e),I=u.get(t);if(S&&I)return S==t&&I==e;var A=-1,E=!0,P=n&Mt?new Ft:r;for(u.set(e,t),u.set(t,e);++A<p;){var N=e[A],M=t[A];if(i)var F=d?i(M,N,A,t,e,u):i(N,M,A,e,t,u);if(F!==r){if(F)continue;E=!1;break}if(P){if(!qr(t,function(k,G){if(!hn(P,G)&&(N===k||a(N,k,n,i,u)))return P.push(G)})){E=!1;break}}else if(!(N===M||a(N,M,n,i,u))){E=!1;break}}return u.delete(e),u.delete(t),E}function Df(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 pn:return!(e.byteLength!=t.byteLength||!u(new zn(e),new zn(t)));case on:case ln:case un:return ze(+e,+t);case Nn:return e.name==t.name&&e.message==t.message;case cn:case fn:return e==t+"";case Ve:var p=Zr;case Ge:var m=i&Fe;if(p||(p=kn),e.size!=t.size&&!m)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,u,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,u){var d=n&Fe,p=Ii(e),m=p.length,S=Ii(t),I=S.length;if(m!=I&&!d)return!1;for(var A=m;A--;){var E=p[A];if(!(d?E in t:H.call(t,E)))return!1}var P=u.get(e),N=u.get(t);if(P&&N)return P==t&&N==e;var M=!0;u.set(e,t),u.set(t,e);for(var F=d;++A<m;){E=p[A];var k=e[E],G=t[E];if(i)var Re=d?i(G,k,E,t,e,u):i(k,G,E,e,t,u);if(!(Re===r?k===G||a(k,G,n,i,u):Re)){M=!1;break}F||(F=E=="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 u.delete(e),u.delete(t),M}function ut(e){return Pi(qa(e,r,eo),e+"")}function Ii(e){return sa(e,le,bi)}function xi(e){return sa(e,Ie,Ba)}var Ai=Qn?function(e){return Qn.get(e)}:ji;function pr(e){for(var t=e.name+"",n=Kt[t],i=H.call(Kt,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=H.call(o,"placeholder")?o:e;return t.placeholder}function $(){var e=o.iteratee||Vi;return e=e===Vi?la:e,arguments.length?e(arguments[0],arguments[1]):e}function hr(e,t){var n=e.__data__;return Hf(t)?n[typeof t=="string"?"string":"hash"]:n.map}function Ei(e){for(var t=le(e),n=t.length;n--;){var i=t[n],a=e[i];t[n]=[i,a,Ga(a)]}return t}function Lt(e,t){var n=Ku(e,t);return oa(n)?n:r}function Wf(e){var t=H.call(e,Rt),n=e[Rt];try{e[Rt]=r;var i=!0}catch{}var a=qn.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 Hs.call(e,t)}))}:qi,Ba=Qr?function(e){for(var t=[];e;)yt(t,bi(e)),e=Kn(e);return t}:qi,ge=ve;(ei&&ge(new ei(new ArrayBuffer(1)))!=Bt||mn&&ge(new mn)!=Ve||ti&&ge(ti.resolve())!=ts||zt&&ge(new zt)!=Ge||vn&&ge(new vn)!=dn)&&(ge=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 Ac:return dn}return t});function Bf(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=he(t,e+d);break;case"takeRight":e=oe(e,t-d);break}}return{start:e,end:t}}function kf(e){var t=e.match(zl);return t?t[1].split(Kl):[]}function ka(e,t,n){t=xt(t,e);for(var i=-1,a=t.length,u=!1;++i<a;){var d=He(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&&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"&&H.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 ln:return new i(+e);case Bt:return bf(e,n);case Er:case br:case Cr:case Tr:case Rr:case Pr:case Fr:case $r:case Nr:return Aa(e,n);case Ve:return new i;case un:case fn:return new i(e);case cn:return Cf(e);case Ge:return new i;case On:return Tf(e)}}function jf(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(Hl,`{
10
10
  /* [wrapped with `+t+`] */
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
- __e(`+B+`) +
14
- '`),_e&&(g=!0,E+=`';
11
+ `)}function qf(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"&&nu.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:Vl.test(e)||!kl.test(e)||t!=null&&e in K(t)}function Hf(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 V.prototype))return!1;if(e===n)return!0;var i=Ai(n);return!!i&&e===i[0]}function zf(e){return!!Gs&&Gs in e}var Kf=Gn?ft:Hi;function bn(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||Ht;return e===n}function Ga(e){return e===e&&!te(e)}function ja(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===B&&n.clear(),i}),n=t.cache;return t}function Jf(e,t){var n=e[1],i=t[1],a=n|i,u=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(!(u||d))return e;i&me&&(e[2]=t[2],a|=n&me?0:rn);var p=t[3];if(p){var m=e[3];e[3]=m?ba(m,p,t[4]):p,e[4]=m?_t(e[3],ne):t[4]}return p=t[5],p&&(m=e[5],e[5]=m?Ca(m,p,t[6]):p,e[6]=m?_t(e[5],ne):t[6]),p=t[7],p&&(e[7]=p),i&it&&(e[8]=e[8]==null?t[8]:he(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 qn.call(e)}function qa(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=y(u);++a<u;)d[a]=i[t+a];a=-1;for(var p=y(t+1);++a<t;)p[a]=i[a];return p[t]=n(d),Ae(e,this,p)}}function Ha(e,t){return t.length<2?e:Nt(e,Ue(t,0,-1))}function Qf(e,t){for(var n=e.length,i=he(t.length,n),a=we(e);i--;){var u=t[i];e[i]=ct(u,n)?a[u]: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,jf(i,ed(kf(i),n)))}function Ya(e){var t=0,n=0;return function(){var i=vc(),a=Sl-(i-n);if(n=i,a>0){if(++t>=wl)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 u=di(n,a),d=e[u];e[u]=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(Gl,function(n,i,a,u){t.push(a?u.replace(Jl,"$1"):i||n)}),t});function He(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 jn.call(e)}catch{}try{return e+""}catch{}}return""}function ed(e,t){return Ee(Cl,function(n){var i="_."+n[0];t&n[1]&&!Wn(e,i)&&e.push(i)}),e.sort()}function Za(e){if(e instanceof V)return e.clone();var t=new Le(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,u=0,d=y(Zn(i/t));a<i;)d[u++]=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 u=e[t];u&&(a[i++]=u)}return a}function rd(){var e=arguments.length;if(!e)return[];for(var t=y(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),$(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 ld(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 ud(e,t){return e&&e.length?or(e,$(t,3),!0,!0):[]}function cd(e,t){return e&&e.length?or(e,$(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,$(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):he(a,i-1)),Bn(e,$(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,$(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):he(a,i-1)),t===t?Qu(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 Ad(e,t,n){return e&&e.length&&t&&t.length?fi(e,t,$(n,2)):e}function Ed(e,t,n){return e&&e.length&&t&&t.length?fi(e,t,r,n):e}var bd=ut(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(Ea)),i});function Cd(e,t){var n=[];if(!(e&&e.length))return n;var i=-1,a=[],u=e.length;for(t=$(t,3);++i<u;){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,$(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 Nd(e,t,n){return hi(e,t,$(n,2),!0)}function Ld(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,$(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,$(t,3),!1,!0):[]}function kd(e,t){return e&&e.length?or(e,$(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),$(t,2))}),jd=W(function(e){var t=De(e);return t=typeof t=="function"?t:r,It(de(e,1,ie,!0),r,t)});function qd(e){return e&&e.length?It(e):[]}function Hd(e,t){return e&&e.length?It(e,$(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,Hr(n))})}function ro(e,t){if(!(e&&e.length))return[];var n=$i(e);return t==null?n:ee(n,function(i){return Ae(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),$(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||[],An)}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=ut(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 V)||!ct(n)?this.thru(a):(i=i.slice(n,+n+(t?1:0)),i.__actions__.push({func:mr,args:[a],thisArg:r}),new Le(i,this.__chain__).thru(function(u){return t&&!u.length&&u.push(r),u}))});function ip(){return io(this)}function sp(){return new Le(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 lp(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 up(){var e=this.__wrapped__;if(e instanceof V){var t=e;return this.__actions__.length&&(t=new V(this)),t=t.reverse(),t.__actions__.push({func:mr,args:[Fi],thisArg:r}),new Le(t,this.__chain__)}return this.thru(Fi)}function cp(){return wa(this.__wrapped__,this.__actions__)}var fp=lr(function(e,t,n){H.call(e,n)?++e[n]:Xe(e,n,1)});function dp(e,t,n){var i=U(e)?Ns:tf;return n&&ye(e,t,n)&&(t=r),i(e,$(t,3))}function pp(e,t){var n=U(e)?vt:ra;return n(e,$(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)?Ee:St;return n(e,$(t,3))}function ao(e,t){var n=U(e)?Uu:na;return n(e,$(t,3))}var _p=lr(function(e,t,n){H.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",u=Se(e)?y(e.length):[];return St(e,function(d){u[++i]=a?Ae(t,d,n):In(d,t,n)}),u}),Ip=lr(function(e,t,n){Xe(e,n,t)});function vr(e,t){var n=U(e)?ee:ua;return n(e,$(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 Ap=lr(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]});function Ep(e,t,n){var i=U(e)?jr:Ds,a=arguments.length<3;return i(e,$(t,4),n,a,St)}function bp(e,t,n){var i=U(e)?Du:Ds,a=arguments.length<3;return i(e,$(t,4),n,a,na)}function Cp(e,t){var n=U(e)?vt:ra;return n(e,wr($(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)?jt(e):e.length;var t=ge(e);return t==Ve||t==Ge?e.size:ui(e).length}function $p(e,t,n){var i=U(e)?qr:Af;return n&&ye(e,t,n)&&(t=r),i(e,$(t,3))}var Np=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 Lp(e,t){if(typeof t!="function")throw new Ne(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,lt(e,it,r,r,r,r,t)}function lo(e,t){var n;if(typeof t!="function")throw new Ne(x);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=me;if(n.length){var a=_t(n,Xt(Ni));i|=ce}return lt(e,i,t,n,a)}),uo=W(function(e,t,n){var i=me|gt;if(n.length){var a=_t(n,Xt(uo));i|=ce}return lt(t,i,e,n,a)});function co(e,t,n){t=n?r:t;var i=lt(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=lt(e,rt,r,r,r,r,r,t);return i.placeholder=fo.placeholder,i}function po(e,t,n){var i,a,u,d,p,m,S=0,I=!1,A=!1,E=!0;if(typeof e!="function")throw new Ne(x);t=Me(t)||0,te(n)&&(I=!!n.leading,A="maxWait"in n,u=A?oe(Me(n.maxWait)||0,t):u,E="trailing"in n?!!n.trailing:E);function P(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(k,t),I?P(se):d}function M(se){var Ke=se-m,pt=se-S,No=t-Ke;return A?he(No,u-pt):No}function F(se){var Ke=se-m,pt=se-S;return m===r||Ke>=t||Ke<0||A&&pt>=u}function k(){var se=yr();if(F(se))return G(se);p=Cn(k,M(se))}function G(se){return p=r,E&&i?P(se):(i=a=r,d)}function Re(){p!==r&&Ia(p),S=0,i=m=a=p=r}function _e(){return p===r?d:G(yr())}function Pe(){var se=yr(),Ke=F(se);if(i=arguments,a=this,m=se,Ke){if(p===r)return N(m);if(A)return Ia(p),p=Cn(k,t),P(m)}return p===r&&(p=Cn(k,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 lt(e,Ar)}function _r(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new Ne(x);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(_r.Cache||ot),n}_r.Cache=ot;function wr(e){if(typeof e!="function")throw new Ne(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 lo(2,e)}var Wp=Ef(function(e,t){t=t.length==1&&U(t[0])?ee(t[0],be($())):ee(de(t,1),be($()));var n=t.length;return W(function(i){for(var a=-1,u=he(i.length,n);++a<u;)i[a]=t[a].call(this,i[a]);return Ae(e,this,i)})}),Li=W(function(e,t){var n=_t(t,Xt(Li));return lt(e,ce,r,t,n)}),ho=W(function(e,t){var n=_t(t,Xt(ho));return lt(e,sn,r,t,n)}),Bp=ut(function(e,t){return lt(e,an,r,r,r,t)});function kp(e,t){if(typeof e!="function")throw new Ne(x);return t=t===r?t:D(t),W(e,t)}function Vp(e,t){if(typeof e!="function")throw new Ne(x);return t=t==null?0:oe(D(t),0),W(function(n){var i=n[t],a=At(n,0,t);return i&&yt(a,i),Ae(e,this,a)})}function Gp(e,t,n){var i=!0,a=!0;if(typeof e!="function")throw new Ne(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 jp(e){return oo(e,1)}function qp(e,t){return Li(yi(t),e)}function Hp(){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,Z|Be)}function Jp(e,t){return t=typeof t=="function"?t:r,Oe(e,Z|Be,t)}function Zp(e,t){return t==null||ea(e,t,le(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)&&H.call(e,"callee")&&!Hs.call(e,"callee")},U=y.isArray,eh=Cs?be(Cs):lf;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 Et=hc||Hi,nh=Ts?be(Ts):uf;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"||Et(e)||Qt(e)||Ut(e)))return!e.length;var t=ge(e);if(t==Ve||t==Ge)return!e.size;if(bn(e))return!ui(e).length;for(var n in e)if(H.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==Nn||t==Rl||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==Ln||t==es||t==Tl||t==Fl}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 lh(e,t){return e===t||li(e,t,Ei(t))}function uh(e,t,n){return n=typeof n=="function"?n:r,li(e,t,Ei(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)==un}function Tn(e){if(!re(e)||ve(e)!=st)return!1;var t=Kn(e);if(t===null)return!0;var n=H.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&jn.call(n)==lc}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)&&ge(e)==dn}function vh(e){return re(e)&&ve(e)==Nl}var yh=dr(ci),_h=dr(function(e,t){return e<=t});function _o(e){if(!e)return[];if(Se(e))return Ir(e)?je(e):we(e);if(gn&&e[gn])return Ju(e[gn]());var t=ge(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*Al}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=Ql.test(e);return n||tu.test(e)?Nu(e.slice(2),n?2:8):Xl.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,le(t),e);return}for(var n in t)H.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,le(t),e,i)}),Ih=ut(ri);function xh(e,t){var n=Yt(e);return t==null?n:Qs(n,t)}var Ah=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 u=t[n],d=Ie(u),p=-1,m=d.length;++p<m;){var S=d[p],I=e[S];(I===r||ze(I,Ht[S])&&!H.call(e,S))&&(e[S]=u[S])}return e}),Eh=W(function(e){return e.push(r,Ma),Ae(Ao,r,e)});function bh(e,t){return Ls(e,$(t,3),Qe)}function Ch(e,t){return Ls(e,$(t,3),si)}function Th(e,t){return e==null?e:ii(e,$(t,3),Ie)}function Rh(e,t){return e==null?e:ia(e,$(t,3),Ie)}function Ph(e,t){return e&&Qe(e,$(t,3))}function Fh(e,t){return e&&si(e,$(t,3))}function $h(e){return e==null?[]:ir(e,le(e))}function Nh(e){return e==null?[]:ir(e,Ie(e))}function Mi(e,t,n){var i=e==null?r:Nt(e,t);return i===r?n:i}function Lh(e,t){return e!=null&&ka(e,t,rf)}function Wi(e,t){return e!=null&&ka(e,t,sf)}var Oh=Na(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=qn.call(t)),e[t]=n},ki(xe)),Uh=Na(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=qn.call(t)),H.call(e,t)?e[t].push(n):e[t]=[n]},$),Dh=W(In);function le(e){return Se(e)?Zs(e):ui(e)}function Ie(e){return Se(e)?Zs(e,!0):gf(e)}function Mh(e,t){var n={};return t=$(t,3),Qe(e,function(i,a,u){Xe(n,t(i,a,u),i)}),n}function Wh(e,t){var n={};return t=$(t,3),Qe(e,function(i,a,u){Xe(n,a,t(i,a,u))}),n}var Bh=Jt(function(e,t,n){sr(e,t,n)}),Ao=Jt(function(e,t,n,i){sr(e,t,n,i)}),kh=ut(function(e,t){var n={};if(e==null)return n;var i=!1;t=ee(t,function(u){return u=xt(u,e),i||(i=u.length>1),u}),et(e,xi(e),n),i&&(n=Oe(n,Z|ht|Be,Uf));for(var a=t.length;a--;)gi(n,t[a]);return n});function Vh(e,t){return Eo(e,wr($(t)))}var Gh=ut(function(e,t){return e==null?{}:vf(e,t)});function Eo(e,t){if(e==null)return{};var n=ee(xi(e),function(i){return[i]});return t=$(t),ha(e,n,function(i,a){return t(i,a[0])})}function jh(e,t,n){t=xt(t,e);var i=-1,a=t.length;for(a||(a=1,e=r);++i<a;){var u=e==null?r:e[He(t[i])];u===r&&(i=a,u=n),e=ft(u)?u.call(e):u}return e}function qh(e,t,n){return e==null?e:An(e,t,n)}function Hh(e,t,n,i){return i=typeof i=="function"?i:r,e==null?e:An(e,t,n,i)}var bo=Ua(le),Co=Ua(Ie);function zh(e,t,n){var i=U(e),a=i||Et(e)||Qt(e);if(t=$(t,4),n==null){var u=e&&e.constructor;a?n=i?new u:[]:te(e)?n=ft(u)?Yt(Kn(e)):{}:n={}}return(a?Ee:Qe)(e,function(d,p,m){return t(n,d,p,m)}),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,le(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 he(e+a*(t-e+$u("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(ru,qu).replace(Iu,"")}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&&Ml.test(e)?e.replace(rs,Hu):e}function ig(e){return e=z(e),e&&jl.test(e)?e.replace(Lr,"\\$&"):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 lg(e,t,n){e=z(e),t=D(t);var i=t?jt(e):0;if(!t||i>=t)return e;var a=(t-i)/2;return fr(Xn(a),n)+e+fr(Zn(a),n)}function ug(e,t,n){e=z(e),t=D(t);var i=t?jt(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?jt(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))?At(je(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),u=le(a),d=Jr(a,u);Ee(u,function(F){if(ss.test(F))throw new O(L)});var p,m,S=0,I=t.interpolate||Un,A="__p += '",E=Xr((t.escape||Un).source+"|"+I.source+"|"+(I===is?Zl:Un).source+"|"+(t.evaluate||Un).source+"|$","g"),P="//# sourceURL="+(H.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Cu+"]")+`
12
+ `;e.replace(E,function(F,k,G,Re,_e,Pe){return G||(G=Re),A+=e.slice(S,Pe).replace(iu,zu),k&&(p=!0,A+=`' +
13
+ __e(`+k+`) +
14
+ '`),_e&&(m=!0,A+=`';
15
15
  `+_e+`;
16
- __p += '`),V&&(E+=`' +
17
- ((__t = (`+V+`)) == null ? '' : __t) +
18
- '`),S=Pe+F.length,F}),E+=`';
19
- `;var N=j.call(t,"variable")&&t.variable;if(!N)E=`with (obj) {
20
- `+E+`
16
+ __p += '`),G&&(A+=`' +
17
+ ((__t = (`+G+`)) == null ? '' : __t) +
18
+ '`),S=Pe+F.length,F}),A+=`';
19
+ `;var N=H.call(t,"variable")&&t.variable;if(!N)A=`with (obj) {
20
+ `+A+`
21
21
  }
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")+`) {
22
+ `;else if(ss.test(N))throw new O(R);A=(m?A.replace(Ll,""):A).replace(Ol,"$1").replace(Ul,"$1;"),A="function("+(N||"obj")+`) {
23
23
  `+(N?"":`obj || (obj = {});
24
- `)+"var __t, __p = ''"+(p?", __e = _.escape":"")+(g?`, __j = Array.prototype.join;
24
+ `)+"var __t, __p = ''"+(p?", __e = _.escape":"")+(m?`, __j = Array.prototype.join;
25
25
  function print() { __p += __j.call(arguments, '') }
26
26
  `:`;
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}: {
27
+ `)+A+`return __p
28
+ }`;var M=Fo(function(){return q(u,P+"return "+A).apply(r,d)});if(M.source=A,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=je(e),a=je(t),u=Ws(i,a),d=Bs(i,a)+1;return At(i,u,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=je(e),a=Bs(i,je(t))+1;return At(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=je(e),a=Ws(i,je(t));return At(i,a).join("")}function Ag(e,t){var n=yl,i=_l;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=je(e);u=d.length}if(n>=u)return e;var p=n-jt(i);if(p<1)return i;var m=d?At(d,0,p).join(""):e.slice(0,p);if(a===r)return m+i;if(d&&(p+=m.length-p),Ui(a)){if(e.slice(p).search(a)){var S,I=m;for(a.global||(a=Xr(a.source,z(as.exec(a))+"g")),a.lastIndex=0;S=a.exec(I);)var A=S.index;m=m.slice(0,A===r?p:A)}}else if(e.indexOf(Ce(a),p)!=p){var E=m.lastIndexOf(a);E>-1&&(m=m.slice(0,E))}return m+i}function Eg(e){return e=z(e),e&&Dl.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?Yu(e)?rc(e):Bu(e):e.match(t)||[]}var Fo=W(function(e,t){try{return Ae(e,r,t)}catch(n){return Oi(n)?n:new O(n)}}),Cg=ut(function(e,t){return Ee(t,function(n){n=He(n),Xe(e,n,Ni(e[n],e))}),e});function Tg(e){var t=e==null?0:e.length,n=$();return e=t?ee(e,function(i){if(typeof i[1]!="function")throw new Ne(x);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 Rg(e){return ef(Oe(e,Z))}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 la(typeof e=="function"?e:Oe(e,Z))}function Ng(e){return ca(Oe(e,Z))}function Lg(e,t){return fa(e,Oe(t,Z))}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=le(t),a=ir(t,i);n==null&&!(te(t)&&(a.length||!i.length))&&(n=t,t=e,e=this,a=ir(t,le(t)));var u=!(te(n)&&"chain"in n)||!!n.chain,d=ft(e);return Ee(a,function(p){var m=t[p];e[p]=m,d&&(e.prototype[p]=function(){var S=this.__chain__;if(u||S){var I=e(this.__wrapped__),A=I.__actions__=we(this.__actions__);return A.push({func:m,args:arguments,thisArg:e}),I.__chain__=S,I}return m.apply(e,yt([this.value()],arguments))})}),e}function Dg(){return fe._===this&&(fe._=uc),this}function ji(){}function Mg(e){return e=D(e),W(function(t){return da(t,e)})}var Wg=wi(ee),Bg=wi(Ns),kg=wi(qr);function $o(e){return Ci(e)?Hr(He(e)):yf(e)}function Vg(e){return function(t){return e==null?r:Nt(e,t)}}var Gg=La(),jg=La(!0);function qi(){return[]}function Hi(){return!1}function qg(){return{}}function Hg(){return""}function zg(){return!0}function Kg(e,t){if(e=D(e),e<1||e>mt)return[];var n=Ze,i=he(e,Ze);t=$(t),e-=Ze;for(var a=Yr(i,t);++n<e;)t(n);return a}function Yg(e){return U(e)?ee(e,He):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,$(t,2),ai):r}function rm(e){return Us(e,xe)}function im(e,t){return Us(e,$(t,2))}function sm(e){return e&&e.length?rr(e,xe,ci):r}function am(e,t){return e&&e.length?rr(e,$(t,2),ci):r}var om=cr(function(e,t){return e*t},1),lm=Si("round"),um=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,$(t,2)):0}return o.after=Lp,o.ary=oo,o.assign=Sh,o.assignIn=Io,o.assignInWith=xo,o.assignWith=Di,o.at=Ih,o.before=lo,o.bind=Ni,o.bindAll=Cg,o.bindKey=uo,o.castArray=Hp,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=Ah,o.defaultsDeep=Eh,o.defer=Op,o.delay=Up,o.difference=id,o.differenceBy=sd,o.differenceWith=ad,o.drop=od,o.dropRight=ld,o.dropRightWhile=ud,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=Nh,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=le,o.keysIn=Ie,o.map=vr,o.mapKeys=Mh,o.mapValues=Wh,o.matches=Ng,o.matchesProperty=Lg,o.memoize=_r,o.merge=Bh,o.mergeWith=Ao,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=Li,o.partialRight=ho,o.partition=Ap,o.pick=Gh,o.pickBy=Eo,o.property=$o,o.propertyOf=Vg,o.pull=xd,o.pullAll=no,o.pullAllBy=Ad,o.pullAllWith=Ed,o.pullAt=bd,o.range=Gg,o.rangeRight=jg,o.rearg=Bp,o.reject=Cp,o.remove=Cd,o.rest=kp,o.reverse=Fi,o.sampleSize=Rp,o.set=qh,o.setWith=Hh,o.shuffle=Pp,o.slice=Td,o.sortBy=Np,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=jp,o.union=Vd,o.unionBy=Gd,o.unionWith=jd,o.uniq=qd,o.uniqBy=Hd,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=qp,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=Lh,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=Et,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=lh,o.isMatchWith=uh,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=qi,o.stubFalse=Hi,o.stubObject=qg,o.stubString=Hg,o.stubTrue=zg,o.multiply=om,o.nth=Id,o.noConflict=Dg,o.noop=ji,o.now=yr,o.pad=lg,o.padEnd=ug,o.padStart=cg,o.parseInt=fg,o.random=eg,o.reduce=Ep,o.reduceRight=bp,o.repeat=dg,o.replace=pg,o.result=jh,o.round=lm,o.runInContext=g,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=Nd,o.sortedLastIndexOf=Ld,o.startCase=mg,o.startsWith=vg,o.subtract=um,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=Ag,o.unescape=Eg,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){H.call(o.prototype,n)||(e[n]=t)}),e})(),{chain:!1}),o.VERSION=c,Ee(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){o[e].placeholder=o}),Ee(["drop","take"],function(e,t){V.prototype[e]=function(n){n=n===r?1:oe(D(n),0);var i=this.__filtered__&&!t?new V(this):this.clone();return i.__filtered__?i.__takeCount__=he(n,i.__takeCount__):i.__views__.push({size:he(n,Ze),type:e+(i.__dir__<0?"Right":"")}),i},V.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),Ee(["filter","map","takeWhile"],function(e,t){var n=t+1,i=n==Qi||n==xl;V.prototype[e]=function(a){var u=this.clone();return u.__iteratees__.push({iteratee:$(a,3),type:n}),u.__filtered__=u.__filtered__||i,u}}),Ee(["head","last"],function(e,t){var n="take"+(t?"Right":"");V.prototype[e]=function(){return this[n](1).value()[0]}}),Ee(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");V.prototype[e]=function(){return this.__filtered__?new V(this):this[n](1)}}),V.prototype.compact=function(){return this.filter(xe)},V.prototype.find=function(e){return this.filter(e).head()},V.prototype.findLast=function(e){return this.reverse().find(e)},V.prototype.invokeMap=W(function(e,t){return typeof e=="function"?new V(this):this.map(function(n){return In(n,e,t)})}),V.prototype.reject=function(e){return this.filter(wr($(e)))},V.prototype.slice=function(e,t){e=D(e);var n=this;return n.__filtered__&&(e>0||t<0)?new V(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)},V.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},V.prototype.toArray=function(){return this.take(Ze)},Qe(V.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,m=d instanceof V,S=p[0],I=m||U(d),A=function(k){var G=a.apply(o,yt([k],p));return i&&E?G[0]:G};I&&n&&typeof S=="function"&&S.length!=1&&(m=I=!1);var E=this.__chain__,P=!!this.__actions__.length,N=u&&!E,M=m&&!P;if(!u&&I){d=M?d:new V(this);var F=e.apply(d,p);return F.__actions__.push({func:mr,args:[A],thisArg:r}),new Le(F,E)}return N&&M?e.apply(this,p):(F=this.thru(A),N?i?F.value()[0]:F.value():F)})}),Ee(["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 u=this.value();return t.apply(U(u)?u:[],a)}return this[n](function(d){return t.apply(U(d)?d:[],a)})}}),Qe(V.prototype,function(e,t){var n=o[t];if(n){var i=n.name+"";H.call(Kt,i)||(Kt[i]=[]),Kt[i].push({name:t,func:n})}}),Kt[ur(r,gt).name]=[{name:"wrapper",func:r}],V.prototype.clone=Ec,V.prototype.reverse=bc,V.prototype.value=Cc,o.prototype.at=rp,o.prototype.chain=ip,o.prototype.commit=sp,o.prototype.next=ap,o.prototype.plant=lp,o.prototype.reverse=up,o.prototype.toJSON=o.prototype.valueOf=o.prototype.value=cp,o.prototype.first=o.prototype.head,gn&&(o.prototype[gn]=op),o}),qt=ic();Tt?((Tt.exports=qt)._=qt,kr._=qt):fe._=qt}).call(Tm)})(Rn,Rn.exports)),Rn.exports}var Pm=Rm();const zi=l=>{const s=Pm.startCase(l).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*\{/,Nm=async({projectRoot:l,variables:s})=>{const r=await Lm(l);if(r===null)return{status:"skipped-no-config"};const c=await nt.readFile(r,"utf8"),f=s.filter(R=>!new RegExp(`\\b${R.name}\\s*:`).test(c));if(f.length===0)return{status:"skipped-existing"};const w=Om(f);if(Mo.test(c)){const R=c.replace(Mo,L=>`${L}
29
+ ${w}`);return await nt.writeFile(r,R,"utf8"),{status:"appended",file:r}}if(!$m.test(c))return{status:"skipped-no-app-call"};const x=c.replace(/\n(\s*)\}\s*\)\s*;?\s*$/,(R,L)=>{const T=Um(f,L);return`
30
+ ${L}${T}
31
+ ${L}});
32
+ `});return x===c?{status:"skipped-no-app-call"}:(await nt.writeFile(r,x,"utf8"),{status:"created",file:r})},Lm=async l=>{for(const s of Fm){const r=`${l}/${s}`;if(await h.pathExists(r))return r}return null},Om=l=>l.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
- `),Um=(u,s)=>`serverVariables: {
38
- ${u.map(({name:c,description:f,isSecret:w})=>`${s} ${c}: {
37
+ `),Um=(l,s)=>`serverVariables: {
38
+ ${l.map(({name:c,description:f,isSecret:w})=>`${s} ${c}: {
39
39
  ${s} description: ${JSON.stringify(f)},
40
40
  ${s} isSecret: ${w},
41
41
  ${s} isRequired: true,
42
42
  ${s} },`).join(`
43
43
  `)}
44
- ${s}},`,Dm=({data:u})=>{const s=X.v4(),r=u.description?`
45
- description: '${u.description}',`:"";return`import { defineField, FieldType } from 'twenty-sdk/define';
44
+ ${s}},`,Dm=({data:l})=>{const s=J.v4(),r=l.description?`
45
+ description: '${l.description}',`:"";if(l.type===h.R.RELATION||l.type===h.R.MORPH_RELATION){const f=l.onDelete&&l.onDelete!=="None",w=`import { defineField, FieldType, RelationType${f?", OnDeleteAction":""} } from 'twenty-sdk/define';`,x=f?`, onDelete: OnDeleteAction.${l.onDelete}`:"",R=l.type===h.R.MORPH_RELATION?`
46
+ morphId: '${J.v4()}',`:"";return`${w}
46
47
 
47
48
  export default defineField({
48
49
  universalIdentifier: '${s}',
49
- name: '${u.name}',
50
- label: '${u.label}',
51
- type: FieldType.${u.type},
52
- objectUniversalIdentifier: '${u.objectUniversalIdentifier}',${r}
50
+ name: '${l.name}',
51
+ label: '${l.label}',
52
+ type: FieldType.${l.type},
53
+ objectUniversalIdentifier: '${l.objectUniversalIdentifier}',
54
+ relationTargetObjectMetadataUniversalIdentifier: '${l.relationTargetObjectMetadataUniversalIdentifier}',
55
+ relationTargetFieldMetadataUniversalIdentifier: '${l.relationTargetFieldMetadataUniversalIdentifier}',
56
+ universalSettings: { relationType: RelationType.${l.relationType}${x} },${R}${r}
53
57
  });
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';
58
+ `}return`import { defineField, FieldType } from 'twenty-sdk/define';
59
+
60
+ export default defineField({
61
+ universalIdentifier: '${s}',
62
+ name: '${l.name}',
63
+ label: '${l.label}',
64
+ type: FieldType.${l.type},
65
+ objectUniversalIdentifier: '${l.objectUniversalIdentifier}',${r}
66
+ });
67
+ `},ue=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(),Mm=({name:l,universalIdentifier:s=J.v4()})=>{const r=ue(l);return`import { defineFrontComponent } from 'twenty-sdk/define';
55
68
 
56
69
  // React component - implement your UI here
57
70
  const Component = () => {
@@ -69,7 +82,7 @@ export default defineFrontComponent({
69
82
  description: 'Add a description for your front component',
70
83
  component: Component,
71
84
  });
72
- `},Wm=({name:u,universalIdentifier:s=X.v4()})=>{const r=le(u);return`import { defineLogicFunction } from 'twenty-sdk/define';
85
+ `},Wm=({name:l,universalIdentifier:s=J.v4()})=>{const r=ue(l);return`import { defineLogicFunction } from 'twenty-sdk/define';
73
86
 
74
87
  // Logic function handler - rename and implement your logic
75
88
  const handler = async (params: {
@@ -106,7 +119,7 @@ export default defineLogicFunction({
106
119
  // eventName: 'objectName.created',
107
120
  // },
108
121
  });
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,
122
+ `},Wo=({name:l,universalIdentifier:s=J.v4(),type:r,viewUniversalIdentifier:c,targetObjectUniversalIdentifier:f})=>{const w=ue(l);let x;return r==="OBJECT"&&f?x=` type: NavigationMenuItemType.OBJECT,
110
123
  targetObjectUniversalIdentifier: '${f}',`:r==="VIEW"&&c?x=` type: NavigationMenuItemType.VIEW,
111
124
  viewUniversalIdentifier: '${c}',`:r==="LINK"?x=` type: NavigationMenuItemType.LINK,
112
125
  link: 'https://example.com',`:r==="FOLDER"?x=" type: NavigationMenuItemType.FOLDER,":x=` type: NavigationMenuItemType.VIEW,
@@ -119,17 +132,17 @@ export default defineNavigationMenuItem({
119
132
  position: 0,
120
133
  ${x}
121
134
  });
122
- `},Bm=({data:u,universalIdentifier:s=X.v4(),nameFieldUniversalIdentifier:r=X.v4()})=>`import { defineObject, FieldType } from 'twenty-sdk/define';
135
+ `},Bm=({data:l,universalIdentifier:s=J.v4(),nameFieldUniversalIdentifier:r=J.v4()})=>`import { defineObject, FieldType } from 'twenty-sdk/define';
123
136
 
124
137
  export const NAME_FIELD_UNIVERSAL_IDENTIFIER =
125
138
  '${r}';
126
139
 
127
140
  export default defineObject({
128
141
  universalIdentifier: '${s}',
129
- nameSingular: '${u.nameSingular}',
130
- namePlural: '${u.namePlural}',
131
- labelSingular: '${u.labelSingular}',
132
- labelPlural: '${u.labelPlural}',
142
+ nameSingular: '${l.nameSingular}',
143
+ namePlural: '${l.namePlural}',
144
+ labelSingular: '${l.labelSingular}',
145
+ labelPlural: '${l.labelPlural}',
133
146
  icon: 'IconBox',
134
147
  labelIdentifierFieldMetadataUniversalIdentifier: NAME_FIELD_UNIVERSAL_IDENTIFIER,
135
148
  fields: [
@@ -138,61 +151,61 @@ export default defineObject({
138
151
  type: FieldType.TEXT,
139
152
  name: 'name',
140
153
  label: 'Name',
141
- description: 'Name of the ${u.nameSingular}',
154
+ description: 'Name of the ${l.nameSingular}',
142
155
  icon: 'IconAbc',
143
156
  },
144
157
  ],
145
158
  });
146
- `,km=({name:u})=>`import { defineCommandMenuItem } from 'twenty-sdk/define';
159
+ `,km=({name:l})=>`import { defineCommandMenuItem } from 'twenty-sdk/define';
147
160
 
148
161
  export default defineCommandMenuItem({
149
- universalIdentifier: '${X.v4()}',
162
+ universalIdentifier: '${J.v4()}',
150
163
  frontComponentUniversalIdentifier:
151
164
  'replace-with-existing-front-component-uuid',
152
- label: '${u}',
165
+ label: '${l}',
153
166
  availabilityType: 'GLOBAL',
154
167
  });
155
- `,Vm=({name:u})=>`import { definePageLayout } from 'twenty-sdk/define';
168
+ `,Vm=({name:l})=>`import { definePageLayout } from 'twenty-sdk/define';
156
169
 
157
170
  export default definePageLayout({
158
- universalIdentifier: '${X.v4()}',
159
- name: '${u}',
171
+ universalIdentifier: '${J.v4()}',
172
+ name: '${l}',
160
173
  tabs: [
161
174
  {
162
- universalIdentifier: '${X.v4()}',
175
+ universalIdentifier: '${J.v4()}',
163
176
  title: 'Overview',
164
177
  widgets: [],
165
178
  },
166
179
  ],
167
180
  });
168
- `,Gm=({name:u})=>`import { definePageLayoutTab, PageLayoutTabLayoutMode } from 'twenty-sdk/define';
181
+ `,Gm=({name:l})=>`import { definePageLayoutTab, PageLayoutTabLayoutMode } from 'twenty-sdk/define';
169
182
 
170
183
  export default definePageLayoutTab({
171
- universalIdentifier: '${X.v4()}',
184
+ universalIdentifier: '${J.v4()}',
172
185
  pageLayoutUniversalIdentifier: 'replace-with-existing-page-layout-uuid',
173
- title: '${u}',
186
+ title: '${l}',
174
187
  position: 1000,
175
188
  icon: 'IconLayout',
176
189
  layoutMode: PageLayoutTabLayoutMode.CANVAS,
177
190
  widgets: [],
178
191
  });
179
- `,qm=({objectLabelSingular:u,objectUniversalIdentifier:s,fieldsWidgetViewUniversalIdentifier:r})=>`import { definePageLayout, PageLayoutTabLayoutMode } from 'twenty-sdk/define';
192
+ `,jm=({objectLabelSingular:l,objectUniversalIdentifier:s,fieldsWidgetViewUniversalIdentifier:r})=>`import { definePageLayout, PageLayoutTabLayoutMode } from 'twenty-sdk/define';
180
193
 
181
194
  export default definePageLayout({
182
- universalIdentifier: '${X.v4()}',
183
- name: 'Default ${u} Layout',
195
+ universalIdentifier: '${J.v4()}',
196
+ name: 'Default ${l} Layout',
184
197
  type: 'RECORD_PAGE',
185
198
  objectUniversalIdentifier: '${s}',
186
199
  tabs: [
187
200
  {
188
- universalIdentifier: '${X.v4()}',
201
+ universalIdentifier: '${J.v4()}',
189
202
  title: 'Home',
190
203
  position: 10,
191
204
  icon: 'IconHome',
192
205
  layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
193
206
  widgets: [
194
207
  {
195
- universalIdentifier: '${X.v4()}',
208
+ universalIdentifier: '${J.v4()}',
196
209
  title: 'Fields',
197
210
  type: 'FIELDS',
198
211
  configuration: {
@@ -203,14 +216,14 @@ export default definePageLayout({
203
216
  ],
204
217
  },
205
218
  {
206
- universalIdentifier: '${X.v4()}',
219
+ universalIdentifier: '${J.v4()}',
207
220
  title: 'Timeline',
208
221
  position: 20,
209
222
  icon: 'IconTimelineEvent',
210
223
  layoutMode: PageLayoutTabLayoutMode.CANVAS,
211
224
  widgets: [
212
225
  {
213
- universalIdentifier: '${X.v4()}',
226
+ universalIdentifier: '${J.v4()}',
214
227
  title: 'Timeline',
215
228
  type: 'TIMELINE',
216
229
  configuration: {
@@ -221,21 +234,21 @@ export default definePageLayout({
221
234
  },
222
235
  ],
223
236
  });
224
- `,Hm=({name:u,universalIdentifier:s=X.v4()})=>{const r=le(u);return`import { defineRole } from 'twenty-sdk/define';
237
+ `,qm=({name:l,universalIdentifier:s=J.v4()})=>{const r=ue(l);return`import { defineRole } from 'twenty-sdk/define';
225
238
 
226
239
  export const ${r.toUpperCase().replace(/-/g,"_")}_ROLE_UNIVERSAL_IDENTIFIER =
227
240
  '${s}';
228
241
 
229
242
  export default defineRole({
230
243
  universalIdentifier: ${r.toUpperCase().replace(/-/g,"_")}_ROLE_UNIVERSAL_IDENTIFIER,
231
- label: '${u}',
244
+ label: '${l}',
232
245
  description: 'Add a description for your role',
233
246
  canReadAllObjectRecords: true,
234
247
  canUpdateAllObjectRecords: true,
235
248
  canSoftDeleteAllObjectRecords: true,
236
249
  canDestroyAllObjectRecords: false,
237
250
  });
238
- `},jm=({name:u,universalIdentifier:s=X.v4()})=>{const r=le(u);return`import { defineAgent } from 'twenty-sdk/define';
251
+ `},Hm=({name:l,universalIdentifier:s=J.v4()})=>{const r=ue(l);return`import { defineAgent } from 'twenty-sdk/define';
239
252
 
240
253
  export const ${r.toUpperCase().replace(/-/g,"_")}_AGENT_UNIVERSAL_IDENTIFIER =
241
254
  '${s}';
@@ -243,12 +256,12 @@ export const ${r.toUpperCase().replace(/-/g,"_")}_AGENT_UNIVERSAL_IDENTIFIER =
243
256
  export default defineAgent({
244
257
  universalIdentifier: ${r.toUpperCase().replace(/-/g,"_")}_AGENT_UNIVERSAL_IDENTIFIER,
245
258
  name: '${r}',
246
- label: '${u}',
259
+ label: '${l}',
247
260
  description: 'Add a description for your agent',
248
261
  prompt: 'Add the agent system prompt here',
249
262
  responseFormat: {type: 'text'},
250
263
  });
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';
264
+ `},zm=({name:l,universalIdentifier:s=J.v4()})=>{const r=ue(l),c=r.toUpperCase().replace(/-/g,"_"),f=l.replace(/\\/g,"\\\\").replace(/'/g,"\\'");return`import { defineConnectionProvider } from 'twenty-sdk/define';
252
265
 
253
266
  export const ${c}_CONNECTION_PROVIDER_UNIVERSAL_IDENTIFIER =
254
267
  '${s}';
@@ -268,7 +281,7 @@ export default defineConnectionProvider({
268
281
  clientSecretVariable: '${c}_CLIENT_SECRET',
269
282
  },
270
283
  });
271
- `},Km=({name:u,universalIdentifier:s=X.v4()})=>{const r=le(u);return`import { defineSkill } from 'twenty-sdk/define';
284
+ `},Km=({name:l,universalIdentifier:s=J.v4()})=>{const r=ue(l);return`import { defineSkill } from 'twenty-sdk/define';
272
285
 
273
286
  export const ${r.toUpperCase().replace(/-/g,"_")}_SKILL_UNIVERSAL_IDENTIFIER =
274
287
  '${s}';
@@ -276,21 +289,21 @@ export const ${r.toUpperCase().replace(/-/g,"_")}_SKILL_UNIVERSAL_IDENTIFIER =
276
289
  export default defineSkill({
277
290
  universalIdentifier: ${r.toUpperCase().replace(/-/g,"_")}_SKILL_UNIVERSAL_IDENTIFIER,
278
291
  name: '${r}',
279
- label: '${u}',
292
+ label: '${l}',
280
293
  description: 'Add a description for your skill',
281
294
  content: 'Add the skill content here',
282
295
  });
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({
296
+ `},Ym=({field:l,index:s,objectUniversalIdentifier:r})=>{const c=l.universalIdentifier??J.v4(),f=l.position??s,w=l.isVisible??!0,x=l.size??200,R="defaultFieldName"in l?` fieldMetadataUniversalIdentifier: generateDefaultFieldUniversalIdentifier({
284
297
  objectUniversalIdentifier: '${r}',
285
- fieldName: '${u.defaultFieldName}',
286
- })`:` fieldMetadataUniversalIdentifier: '${u.fieldMetadataUniversalIdentifier}'`;return` {
298
+ fieldName: '${l.defaultFieldName}',
299
+ })`:` fieldMetadataUniversalIdentifier: '${l.fieldMetadataUniversalIdentifier}'`;return` {
287
300
  universalIdentifier: '${c}',
288
- ${T},
301
+ ${R},
289
302
  position: ${f},
290
303
  isVisible: ${w},
291
304
  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(`,
305
+ }`},Ki=({name:l,universalIdentifier:s=J.v4(),objectUniversalIdentifier:r="fill-later",fields:c=[],type:f})=>{const w=ue(l),x=c.some(ne=>"defaultFieldName"in ne),L=c.length>0?` fields: [
306
+ ${c.map((ne,Z)=>Ym({field:ne,index:Z,objectUniversalIdentifier:r})).join(`,
294
307
  `)},
295
308
  ],`:` // fields: [
296
309
  // {
@@ -299,7 +312,7 @@ ${c.map((ne,Y)=>Ym({field:ne,index:Y,objectUniversalIdentifier:r})).join(`,
299
312
  // position: 0,
300
313
  // isVisible: true,
301
314
  // },
302
- // ],`,P=f!==void 0?` type: '${f}',
315
+ // ],`,T=f!==void 0?` type: '${f}',
303
316
  `:"";return`${x?`import {
304
317
  defineView,
305
318
  generateDefaultFieldUniversalIdentifier,
@@ -309,9 +322,9 @@ export default defineView({
309
322
  universalIdentifier: '${s}',
310
323
  name: '${w}',
311
324
  objectUniversalIdentifier: '${r}',
312
- ${P} icon: 'IconList',
325
+ ${T} icon: 'IconList',
313
326
  position: 0,
314
- ${$}
327
+ ${L}
315
328
  // filters: [
316
329
  // {
317
330
  // universalIdentifier: '...',
@@ -328,13 +341,13 @@ ${$}
328
341
  // },
329
342
  // ],
330
343
  });
331
- `},Jm=({universalIdentifier:u=X.v4()})=>`import {
344
+ `},Jm=({universalIdentifier:l=J.v4()})=>`import {
332
345
  defineViewField,
333
346
  STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS,
334
347
  } from 'twenty-sdk/define';
335
348
 
336
349
  export default defineViewField({
337
- universalIdentifier: '${u}',
350
+ universalIdentifier: '${l}',
338
351
  // The universalIdentifier of the existing view to add this column to
339
352
  viewUniversalIdentifier: 'STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS.<fill-later>.views.<fill-later>.universalIdentifier',
340
353
  // The universalIdentifier of the field to display in that view
@@ -343,17 +356,17 @@ export default defineViewField({
343
356
  isVisible: true,
344
357
  size: 150,
345
358
  });
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:
359
+ `,Zm="src/application.config.ts",xr="src";class ol{async execute(s,r){try{const c=s??await this.getEntity(),f=this.getFolderName(c),w=r?j.join(Y,r):j.join(Y,xr,f);await h.ensureDir(w);const{name:x,file:R}=await this.getEntityData(c),L=j.join(w,this.getFileName(x,c));if(await h.pathExists(L)){const{overwrite:T}=await this.handleFileExist();if(!T)return}await nt.writeFile(L,R),console.log(v.default.green(`✓ Created ${f}:`),v.default.cyan(j.relative(Y,L))),c===h.o$1.Object&&await this.promptAndCreateObjectCompanions(x,r),c===h.o$1.ConnectionProvider&&await this.registerConnectionProviderServerVariables(x)}catch(c){console.error(v.default.red("Add new entity failed:"),c instanceof Error?c.message:c),process.exit(1)}}async getEntityData(s){switch(s){case h.o$1.Object:{const r=await this.getObjectData(),c=r.nameSingular,f=J.v4(),w=J.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 h.o$1.Field:{const r=await this.getFieldData(),c=r.name,f=Dm({data:r});return{name:c,file:f}}case h.o$1.LogicFunction:{const r=await this.getEntityName(s),c=Wm({name:r});return{name:r,file:c}}case h.o$1.FrontComponent:{const r=await this.getEntityName(s),c=Mm({name:r});return{name:r,file:c}}case h.o$1.Role:{const r=await this.getEntityName(s),c=qm({name:r});return{name:r,file:c}}case h.o$1.Skill:{const r=await this.getEntityName(s),c=Km({name:r});return{name:r,file:c}}case h.o$1.Agent:{const r=await this.getEntityName(s),c=Hm({name:r});return{name:r,file:c}}case h.o$1.ConnectionProvider:{const r=await this.getEntityName(s),c=zm({name:r});return{name:r,file:c}}case h.o$1.View:{const c=(await this.getViewData()).name,f=Ki({name:c});return{name:c,file:f}}case h.o$1.ViewField:{const r=await this.getEntityName(s),c=Jm({});return{name:r,file:c}}case h.o$1.NavigationMenuItem:{const r=await this.getEntityName(s),c=Wo({name:r});return{name:r,file:c}}case h.o$1.PageLayout:{const r=await this.getEntityName(s),c=Vm({name:r});return{name:r,file:c}}case h.o$1.PageLayoutTab:{const r=await this.getEntityName(s),c=Gm({name:r});return{name:r,file:c}}case h.o$1.CommandMenuItem:{const r=await this.getEntityName(s),c=km({name:r});return{name:r,file:c}}default:h.$()}}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=J.v4(),w=J.v4(),x=Ki({name:`all-${ue(s)}`,universalIdentifier:f,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,fields:this.lastNameFieldUniversalIdentifier?[{fieldMetadataUniversalIdentifier:this.lastNameFieldUniversalIdentifier,position:0,isVisible:!0,size:200}]:[]}),R=r?j.join(Y,r):j.join(Y,xr,this.getFolderName(h.o$1.View));await h.ensureDir(R);const L=`all-${ue(s)}.ts`,T=j.join(R,L);if(await h.pathExists(T)){const{overwrite:ce}=await this.handleFileExist();if(!ce)return}await nt.writeFile(T,x),console.log(v.default.green("✓ Created view:"),v.default.cyan(j.relative(Y,T)));const B=this.buildRecordPageFieldsViewFields(this.lastNameFieldUniversalIdentifier),ne=Ki({name:`${ue(s)}-record-page-fields`,universalIdentifier:w,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,type:h.NE.FIELDS_WIDGET,fields:B}),Z=`${ue(s)}-record-page-fields.ts`,ht=j.join(R,Z);if(await h.pathExists(ht)){const{overwrite:ce}=await this.handleFileExist();if(!ce)return}await nt.writeFile(ht,ne),console.log(v.default.green("✓ Created record-page-fields view:"),v.default.cyan(j.relative(Y,ht)));const Be=Wo({name:s,type:"OBJECT",targetObjectUniversalIdentifier:this.lastObjectUniversalIdentifier}),Fe=r?j.join(Y,r):j.join(Y,xr,this.getFolderName(h.o$1.NavigationMenuItem));await h.ensureDir(Fe);const Mt=`${ue(s)}.ts`,me=j.join(Fe,Mt);if(await h.pathExists(me)){const{overwrite:ce}=await this.handleFileExist();if(!ce)return}await nt.writeFile(me,Be),console.log(v.default.green("✓ Created navigation menu item:"),v.default.cyan(j.relative(Y,me)));const gt=jm({objectLabelSingular:this.lastObjectLabelSingular??s,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,fieldsWidgetViewUniversalIdentifier:w}),rn=r?j.join(Y,r):j.join(Y,xr,this.getFolderName(h.o$1.PageLayout));await h.ensureDir(rn);const ke=`${ue(s)}-record-page-layout.ts`,rt=j.join(rn,ke);if(await h.pathExists(rt)){const{overwrite:ce}=await this.handleFileExist();if(!ce)return}await nt.writeFile(rt,gt),console.log(v.default.green("✓ Created record page layout:"),v.default.cyan(j.relative(Y,rt)))}async registerConnectionProviderServerVariables(s){const r=ue(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 Nm({projectRoot:Y,variables:c});switch(f.status){case"appended":case"created":{console.log(v.default.green(`✓ Added ${c.map(w=>w.name).join(" + ")} to defineApplication.serverVariables:`),v.default.cyan(j.relative(Y,f.file)));break}case"skipped-existing":console.log(v.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(v.default.yellow(`! Couldn't auto-update ${Zm}. Add these manually to defineApplication.serverVariables:
347
360
  `+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.
361
+ `)));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(h.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(){const s=r=>r===h.R.RELATION||r===h.R.MORPH_RELATION;return Ye.default.prompt([{type:"input",name:"name",message:"Enter a name for your field:",default:"",validate:r=>!r||r.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"label",message:"Enter a label for your field:",default:r=>zi(r.name),validate:r=>!r||r.trim().length===0?"Please enter a non empty string":!0},{type:"select",name:"type",message:"Select the field type:",choices:Object.values(h.R),default:h.R.TEXT},{type:"input",name:"objectUniversalIdentifier",message:"Enter the universalIdentifier of the object this field belongs to:",default:"fill-later",validate:r=>!r||r.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"description",message:"Enter a description for your field (optional):",default:""},{type:"input",name:"relationTargetObjectMetadataUniversalIdentifier",message:"Enter the universalIdentifier of the target object of the relation:",default:"fill-later",when:r=>s(r.type),validate:r=>!r||r.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"relationTargetFieldMetadataUniversalIdentifier",message:"Enter the universalIdentifier of the target field on the related object:",default:"fill-later",when:r=>s(r.type),validate:r=>!r||r.trim().length===0?"Please enter a non empty string":!0},{type:"select",name:"relationType",message:"Select the relation type:",choices:Object.values(h.d),default:h.d.ONE_TO_MANY,when:r=>s(r.type)},{type:"select",name:"onDelete",message:"Select the onDelete behavior:",choices:Object.values(h.$$1),default:h.$$1.CASCADE,when:r=>s(r.type)}])}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`${ue(s)}s`}getFileName(s,r){return r===h.o$1.FrontComponent?`${ue(s)}.tsx`:`${ue(s)}.ts`}}class ll{async execute(s){const r=s.appPath??Y;await tn(r),console.log(v.default.blue("Building application...")),console.log(v.default.gray(`App path: ${r}
362
+ `));const c=await h.appBuild({appPath:r,tarball:s.tarball,onProgress:f=>console.log(v.default.gray(f))});c.success||(console.error(v.default.red(c.error.message)),process.exit(1)),console.log(v.default.green(`✓ Build succeeded (${c.data.fileCount} file${c.data.fileCount===1?"":"s"})`)),console.log(v.default.gray(`Output: ${c.data.outputDir}`)),c.data.tarballPath&&console.log(v.default.gray(`Tarball: ${c.data.tarballPath}`))}}class ul{async execute({appPath:s=Y,postInstall:r=!1,preInstall:c=!1,functionUniversalIdentifier:f,functionName:w,payload:x="{}"}){let R;try{R=JSON.parse(x)}catch{console.error(v.default.red("Invalid JSON payload. Please provide valid JSON.")),process.exit(1)}const L=r?"post install":c?"pre install":f??w,T=h.ConfigService.getActiveRemote();console.log(v.default.blue(`🚀 Executing function "${L}" on ${T}...`)),console.log(v.default.gray(` Payload: ${JSON.stringify(R)}
363
+ `));const B=r?{appPath:s,postInstall:!0,payload:R}:c?{appPath:s,preInstall:!0,payload:R}:f?{appPath:s,functionUniversalIdentifier:f,payload:R}:{appPath:s,functionName:w,payload:R},ne=await h.functionExecute(B);if(!ne.success){switch(ne.error.code){case h.APP_ERROR_CODES.MANIFEST_NOT_FOUND:{console.error(v.default.red("Failed to build manifest."));break}case h.FUNCTION_ERROR_CODES.FETCH_FUNCTIONS_FAILED:{console.error(v.default.red("Failed to fetch functions:"),ne.error.message);break}case h.FUNCTION_ERROR_CODES.FUNCTION_NOT_FOUND:{console.error(v.default.red(ne.error.message),`
364
+ `);const Be=ne.error.details?.availableFunctions??[];Be.length>0?(console.log(v.default.cyan("Available functions:")),Be.forEach(Fe=>{console.log(` - ${v.default.white(Fe.name)} (${Fe.universalIdentifier})`)})):console.log(v.default.yellow("No functions found for this application. Have you synced your app with `twenty dev`?"));break}case h.FUNCTION_ERROR_CODES.EXECUTION_FAILED:{console.error(v.default.red("Execution failed:"),ne.error.message);break}default:console.error(v.default.red(ne.error.message))}process.exit(1)}const Z=ne.data;console.log(v.default.cyan("─".repeat(60))),console.log(v.default.cyan("Execution Result")),console.log(v.default.cyan("─".repeat(60)));const ht=Z.status==="SUCCESS"?v.default.green:v.default.red;console.log(`${v.default.bold("Status:")} ${ht(Z.status)}`),console.log(`${v.default.bold("Duration:")} ${Z.duration}ms
365
+ `),h.o(Z.data)&&(console.log(v.default.bold("Data:")),console.log(v.default.white(JSON.stringify(Z.data,null,2)))),Z.error&&(console.log(v.default.bold.red("Error:")),console.log(v.default.red(` Type: ${Z.error.errorType}`)),console.log(v.default.red(` Message: ${Z.error.errorMessage}
366
+ `)),Z.error.stackTrace&&(console.log(v.default.gray("Stack trace:")),console.log(v.default.gray(Z.error.stackTrace)))),Z.logs&&(console.log(v.default.bold("Logs:")),console.log(v.default.gray(Z.logs))),console.log(v.default.cyan("─".repeat(60))),Z.status!=="SUCCESS"&&process.exit(1)}}class cl{constructor(){this.apiService=new h.ApiService}async execute({appPath:s=Y,functionUniversalIdentifier:r,functionName:c}){try{const f=await h.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(v.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=h.ConfigService.getActiveRemote();console.log(v.default.blue(`🚀 Watching ${f} ${w} logs on ${x}:
367
+ `))}}const Xm=l=>`${v.default.cyan(l.file)}:${v.default.yellow(String(l.line))}:${v.default.yellow(String(l.column+1))} - ${v.default.red("error")} ${l.text}`;class fl{async execute(s){const r=s.appPath??Y;console.log(v.default.blue("Running type check...")),console.log(v.default.gray(`App path: ${r}
368
+ `));const c=await h.runTypecheck(r);c.length===0&&(console.log(v.default.green("✓ No type errors found")),process.exit(0));for(const f of c)console.log(Xm(f));console.log(`
369
+ `,v.default.red(`✗ Found ${c.length} type error${c.length===1?"":"s"}`)),process.exit(1)}}const tt=(l,s)=>console.warn(v.default.yellow(`⚠ \`twenty ${l}\` is deprecated. Use \`twenty ${s}\` instead.`)),Qm=l=>{const s=new ll,r=new fl,c=new cl,f=new ul,w=new ol,x=new il,R=new sl,L=new al;l.command("build [appPath]",{hidden:!0}).option("--tarball","Also pack into a .tgz tarball").action(async(T,B)=>{tt("build","dev:build"),await s.execute({appPath:pe(T),tarball:B.tarball})}),l.command("typecheck [appPath]",{hidden:!0}).action(async T=>{tt("typecheck","dev:typecheck"),await r.execute({appPath:pe(T)})}),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(T,B)=>{tt("logs","dev:function:logs"),await c.execute({...B,appPath:pe(T)})}),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(T,B)=>{tt("exec","dev:function:exec"),!B?.postInstall&&!B?.preInstall&&!B?.functionUniversalIdentifier&&!B?.functionName&&(console.error(v.default.red("Error: Either --postInstall, --preInstall, --functionName (-n), or --functionUniversalIdentifier (-u) is required.")),process.exit(1)),await f.execute({...B,payload:B?.payload??"{}",appPath:pe(T)})}),l.command("add [entityType]",{hidden:!0}).option("--path <path>","Path in which the entity should be created.").action(async(T,B)=>{tt("add","dev:add"),await w.execute(T,B?.path)}),l.command("publish [appPath]",{hidden:!0}).option("--tag <tag>","npm dist-tag (e.g. beta, next)").action(async(T,B)=>{tt("publish","app:publish"),await x.execute({appPath:pe(T),tag:B.tag})}),l.command("deploy [appPath]",{hidden:!0}).option("-r, --remote <name>","Deploy to a specific remote").action(async(T,B)=>{tt("deploy","app:publish --private"),await x.execute({appPath:pe(T),private:!0,remote:B.remote})}),l.command("install [appPath]",{hidden:!0}).option("-r, --remote <name>","Install on a specific remote").action(async(T,B)=>{tt("install","app:install"),await R.execute({appPath:pe(T),remote:B.remote})}),l.command("uninstall [appPath]",{hidden:!0}).option("-y, --yes","Skip confirmation prompt").action(async(T,B)=>{tt("uninstall","app:uninstall");try{const ne=await L.execute({appPath:pe(T),askForConfirmation:!B?.yes});process.exit(ne.success?0:1)}catch{process.exit(1)}}),l.command("catalog-sync",{hidden:!0}).option("-r, --remote <name>","Sync on a specific remote").action(async T=>{tt("catalog-sync","dev:catalog-sync");const{CatalogSyncCommand:B}=await Promise.resolve().then(()=>require("./catalog-sync-GJcaViDU.js"));await new B().execute({remote:T.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 h.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 h.detectLocalServer();return f&&!this.hasRetried?(this.hasRetried=!0,await new h.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.
357
370
 
358
371
  Start a local server:
359
372
  yarn twenty docker:start
@@ -361,10 +374,16 @@ export default defineViewField({
361
374
  Check server status:
362
375
  yarn twenty docker:status
363
376
 
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))}
377
+ 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",!h.o(this.state.frontendUrl)){const f=await this.apiService.getWorkspaceFrontendUrl();h.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 h.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 h.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=j.join(this.appPath,r);return await h.pathExists(c)?c:null}))).filter(r=>r!==null);s.length!==0&&(this.watcher=nl.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=j.relative(this.appPath,s),c=j.join(h.u,r),f=j.join(this.appPath,c);await h.ensureDir(j.dirname(f)),await h.copy(s,f);const w=await nt.readFile(f),x=Em.default.createHash("md5").update(w).digest("hex");this.handleFileBuilt({fileFolder:this.fileFolder,builtPath:c,sourcePath:r,checksum:x})}async handleUnlink(s){const r=j.relative(this.appPath,s),c=j.join(h.u,r),f=j.join(this.appPath,c);await h.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 h.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(`
378
+ `);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=h.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=nl.default.watch(this.appPath,{ignoreInitial:!this.verbose,ignored:r=>{const c=j.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=j.relative(this.appPath,c),w=f.startsWith(h._),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",spacingBefore:!0}),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=h.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=h.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:h.v.PublicAsset,watchPaths:[h._],handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.assetWatcher.start()}async startDependencyWatcher(){this.dependencyWatcher=new Bo({appPath:this.state.appPath,fileFolder:h.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 lv{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=h.manifestUpdateChecksums({manifest:s.manifest,builtFileInfos:s.builtFileInfos});c.push({message:"Manifest checksums set",status:"info"}),await h.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 T=w.data;c.push(...h.formatSyncActionsSummary(T.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:h.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 R=h.getSyncErrorRecoveryHint(w.message);R&&c.push({message:R,status:"info"});const L=x?x[0].message:"Sync failed";r.output={syncStatus:"error",error:L},r.status="error",this.state.updatePipeline({status:"error",error:L}),this.state.updateAllEntitiesStatus("error"),this.state.applyStepEvents(c)}}class uv{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 h.o(this.state.steps.uploadFiles.output.fileUploader)}initialize(s){const r=this.state.steps.uploadFiles;r.output={...r.output,fileUploader:new h.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 h.ApiService({disableInterceptors:!0});const r=this.apiService,c=new h.ConfigService;this.clientService=new h.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 uv({...f,verbose:this.verbose}),this.generateApiClientStep=new nv({...f,clientService:this.clientService,configService:c}),this.syncApplicationStep=new lv({...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,h.u);await h.ensureDir(s),await h.emptyDir(s),this.state.addEvent({message:`Using remote "${h.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: ${h.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:h.o$1.Object,fields:h.o$1.Field,logicFunctions:h.o$1.LogicFunction,frontComponents:h.o$1.FrontComponent,roles:h.o$1.Role,skills:h.o$1.Skill,connectionProviders:h.o$1.ConnectionProvider,views:h.o$1.View,viewFields:h.o$1.ViewField,navigationMenuItems:h.o$1.NavigationMenuItem,pageLayouts:h.o$1.PageLayout,pageLayoutTabs:h.o$1.PageLayoutTab,commandMenuItems:h.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 R of w)r.set(R,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=l=>({idle:"idle",in_progress:"in_progress",done:"done",error:"error"})[l],dl=l=>({pending:"idle",building:"in_progress",uploading:"uploading",success:"done",error:"error"})[l],mv=l=>({idle:"idle",building:"in_progress",syncing:"in_progress",synced:"done",error:"error"})[l],vv={idle:"Idle",building:"Building...",syncing:"Syncing...",synced:"Synced",error:"Error"},Yi=["◐","◓","◑","◒"],Ji=["↑","⇡","↑","⇡"],pl={[h.o$1.Object]:"Objects",[h.o$1.Field]:"Fields",[h.o$1.LogicFunction]:"Logic functions",[h.o$1.FrontComponent]:"Front components",[h.o$1.CommandMenuItem]:"Command menu items",[h.o$1.Role]:"Roles",[h.o$1.Skill]:"Skills",[h.o$1.View]:"Views",[h.o$1.ViewField]:"View fields",[h.o$1.NavigationMenuItem]:"Navigation menu items",[h.o$1.PageLayout]:"Page layouts",[h.o$1.PageLayoutTab]:"Page layout tabs",[h.o$1.Agent]:"Agents",[h.o$1.ConnectionProvider]:"Connection providers"},hl=Object.keys(pl),yv={info:"gray",success:"green",error:"red",warning:"yellow"},_v=l=>l.toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),wv=(l,s=40)=>{if(l.length<=s)return l;const r=l.split("/");return r.length<=2?l:`.../${r.slice(-2).join("/")}`},Sv=l=>{const s=new Map;for(const r of hl)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},Iv=[{status:"success",label:"synced"},{status:"building",label:"building"},{status:"uploading",label:"uploading"},{status:"pending",label:"pending"},{status:"error",label:"error"}],xv=l=>{const s={pending:0,building:0,uploading:0,success:0,error:0};for(const r of l)s[r.status]+=1;return Iv.filter(({status:r})=>s[r]>0).map(({status:r,label:c})=>({status:r,count:s[r],label:c}))},Av=l=>{const s=l.steps.resolveApplication.output.applicationId;return!h.o(l.frontendUrl)||!h.o(s)?null:`${l.frontendUrl}/settings/applications/${s}`},Ev=l=>l.some(s=>s==="error")?"error":l.some(s=>s==="in_progress")?"in_progress":l.every(s=>s==="done")?"done":"idle",bv=l=>{const s=[...l.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:Ev([l.steps.checkServer.status,l.steps.ensureValidTokens.status,l.steps.resolveApplication.status])},{label:"Resources Build",status:w},{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}]},gl=120,Cv=Math.round(200/gl),ko=()=>{const l=Math.floor(Date.now()/gl);return{spinnerFrame:Yi[l%Yi.length],uploadFrame:Ji[Math.floor(l/Cv)%Ji.length]}},Xi=l=>{const s=We[l];return s.icon==="spinner"?ko().spinnerFrame:s.icon==="upload"?ko().uploadFrame:s.icon},ml=rl.default.createContext(null),Tv=ml.Provider,Je=()=>{const l=rl.default.useContext(ml);if(!l)throw new Error("useInk must be used within InkProvider");return l},vl=({uiStatus:l})=>{const{Text:s}=Je(),r=Xi(l),c=We[l];return b.jsxs(s,{color:c.color,children:[r," "]})},Rv=({entity:l})=>{const{Box:s,Text:r}=Je();return b.jsxs(s,{children:[b.jsx(vl,{uiStatus:dl(l.status)}),b.jsx(r,{children:l.name}),l.path!==l.name&&b.jsxs(r,{dimColor:!0,children:[" (",wv(l.path),")"]})]})},Pv=({type:l,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:pl[l]}),s.map(f=>b.jsx(Rv,{entity:f},f.path))]})},Fv=({entities:l})=>{const{Box:s,Text:r}=Je();if(l.length===0)return null;const c=xv(l);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(vl,{uiStatus:dl(f.status)}),b.jsxs(r,{children:[f.count," ",f.label]})]},f.status))]})},$v=()=>{const{Box:l,Text:s}=Je();return b.jsx(l,{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"]})})},Nv=7,Lv=({versionInfo:l})=>{const{Box:s,Text:r}=Je();if(l===null)return null;const{cliVersion:c,localServerVersion:f,latestServerVersion:w,isMinorOrMajorBehind:x,daysBehind:R}=l,L=x&&R!==null&&R>Nv,T=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:L?"yellow":void 0,children:["v",f]}),T&&b.jsx(r,{color:"green",children:" ✓ latest"}),L&&w!==null&&b.jsxs(b.Fragment,{children:[b.jsxs(r,{color:"yellow",children:[" → v",w]}),R!==null&&b.jsxs(r,{dimColor:!0,children:[" (",R,"d behind)"]})]})]})]})},Ov=({state:l})=>{const{Text:s}=Je(),r=mv(l.pipeline.status),c=Xi(r),f=We[r],w=vv[l.pipeline.status];return b.jsxs(s,{color:f.color,children:[c," ",w]})},Uv=({label:l,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:[l,": "]}),b.jsxs(c,{color:x.color,children:[w," ",s.replace("_"," ")]})]})},Dv=({state:l,verbose:s=!1})=>{const{Box:r,Text:c}=Je(),f=Sv(l.entities),w=Av(l);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:l.pipeline.appName??"Loading..."})]}),b.jsxs(r,{children:[b.jsx(c,{dimColor:!0,children:"Overall Status: "}),b.jsx(Ov,{state:l})]}),w&&b.jsxs(r,{children:[b.jsx(c,{dimColor:!0,children:"Open:"}),b.jsxs(c,{bold:!0,color:"cyan",children:[" ",w]})]}),b.jsx(Lv,{versionInfo:l.versionInfo})]}),b.jsx(r,{marginLeft:2,flexDirection:"column",marginTop:1,children:bv(l).map(x=>b.jsx(Uv,{label:x.label,status:x.status},x.label))}),b.jsx(r,{marginLeft:2,flexDirection:"column",children:s?hl.map(x=>{const R=f.get(x)??[];return b.jsx(Pv,{type:x,entities:R},x)}):b.jsx(Fv,{entities:Array.from(l.entities.values())})})]})},Mv=({event:l})=>{const{Box:s,Text:r}=Je(),c=yv[l.status],f=_v(l.timestamp);return b.jsxs(s,{marginTop:l.spacingBefore?1:0,children:[b.jsxs(r,{dimColor:!0,children:[f," "]}),b.jsx(r,{color:c,children:l.message})]})},Wv=new Set(["building","syncing"]),Vo=120,Bv=80,kv=({uiStateManager:l,verbose:s})=>{const{Box:r,Static:c}=Je(),[,f]=bt.useReducer(T=>T+1,0),w=bt.useRef(null),x=bt.useRef(0),R=bt.useCallback(()=>{w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{w.current=null,x.current=Date.now(),f()},Bv)},[]);bt.useEffect(()=>l.subscribe(()=>{R()}),[l,R]),bt.useEffect(()=>{const T=setInterval(()=>{const B=l.getSnapshot();Wv.has(B.pipeline.status)&&(Date.now()-x.current<Vo||f())},Vo);return()=>clearInterval(T)},[l]),bt.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]);const L=l.getSnapshot();return b.jsxs(b.Fragment,{children:[b.jsx(c,{items:L.events,children:T=>b.jsx(Mv,{event:T},T.id)}),b.jsxs(r,{marginTop:1,flexDirection:"column",children:[b.jsx(Dv,{state:L,verbose:s}),s&&b.jsx($v,{})]})]})},Vv=async(l,s=!1)=>{const r=await import("ink"),{render:c,Box:f,Text:w,Static:x}=r,{unmount:R}=c(b.jsx(Tv,{value:{Box:f,Text:w,Static:x},children:b.jsx(kv,{uiStateManager:l,verbose:s})}));return{unmount:R}};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 jv{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??Y;await tn(r),s.headless&&await h.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,h.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 qv{async execute(s){const r=s.appPath??Y;await tn(r);const c=h.ConfigService.getActiveRemote();console.log(v.default.blue(`${s.dryRun?"Previewing application diff":"Syncing application"} on ${c}...`)),console.log(v.default.gray(`App path: ${r}
379
+ `));const f=await h.appDevOnce({appPath:r,verbose:s.verbose,dryRun:s.dryRun,onProgress:w=>console.log(v.default.gray(w))});if(f.success||(console.error(v.default.red(f.error.message)),process.exit(1)),s.dryRun){console.log(v.default.green(`
380
+ ✓ Dry run complete for ${f.data.applicationDisplayName} — no changes were applied`));return}console.log(v.default.green(`
381
+ ✓ Synced ${f.data.applicationDisplayName} (${f.data.fileCount} file${f.data.fileCount===1?"":"s"})`)),console.log(v.default.gray(`Output: ${f.data.outputDir}`))}}class Hv{async execute(s){const r=s.appPath??Y,c=j.join(r,"node_modules","twenty-client-sdk");await h.pathExists(c)||(console.error(v.default.red(`Cannot find twenty-client-sdk in ${r}.
382
+
383
+ Install it first:
384
+ yarn add twenty-client-sdk`)),process.exit(1));const w=await new h.ApiService({disableInterceptors:!0}).validateAuth();w.serverUp||(console.error(v.default.red(`Cannot reach Twenty server.
385
+
386
+ Check your remotes:
387
+ yarn twenty remote:status`)),process.exit(1)),w.authValid||(console.error(v.default.red("Authentication failed. Run `yarn twenty remote:add` to authenticate.")),process.exit(1)),console.log(v.default.blue("Generating API client..."));try{await new h.ClientService({skipAuth:!1}).generateCoreClient({appPath:r})}catch(x){console.error(v.default.red(`Failed to generate API client: ${h.serializeError(x)}`)),process.exit(1)}console.log(v.default.green("✓ API client generated")),console.log(v.default.gray(`Output: ${j.join(c,"dist","core","generated")}`))}}const zv=l=>{const s=new cl,r=new ul;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:pe(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(v.default.red("Error: Either --postInstall, --preInstall, --functionName (-n), or --functionUniversalIdentifier (-u) is required.")),process.exit(1)),await r.execute({...f,payload:f?.payload??"{}",appPath:pe(c)})})},Kv=l=>{const s=new ll,r=new jv,c=new qv,f=new fl,w=new ol,x=new Hv,R=async(L,T)=>{T.dryRun&&!T.once&&console.warn(v.default.yellow("--dry-run only applies with --once. Ignoring it; run `yarn twenty dev --once --dry-run` to preview changes."));const B={appPath:pe(L),verbose:T.verbose||T.debug,debounceMs:T.debounceMs?parseInt(T.debounceMs,10):void 0};if(T.once){await c.execute({...B,dryRun:T.dryRun});return}await r.execute(B)};l.command("dev [appPath]").description("Build and sync local changes").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(R),l.command("dev:build [appPath]").description("Build and generate API client").option("--tarball","Also pack into a .tgz tarball").action(async(L,T)=>{await s.execute({appPath:pe(L),tarball:T.tarball})}),l.command("dev:typecheck [appPath]").description("Run TypeScript type checking").action(async L=>{await f.execute({appPath:pe(L)})}),l.command("dev:add [entityType]").description(`Scaffold a new entity (${Object.values(h.o$1).join("|")})`).option("--path <path>","Path in which the entity should be created.").action(async(L,T)=>{await w.execute(L,T?.path)}),l.command("dev:catalog-sync").description("Trigger marketplace catalog sync").option("-r, --remote <name>","Sync on a specific remote").action(async L=>{const{CatalogSyncCommand:T}=await Promise.resolve().then(()=>require("./catalog-sync-GJcaViDU.js"));await new T().execute({remote:L.remote})}),l.command("dev:generate-client [appPath]").description("Generate the typed API client from the active remote (no app definition required)").action(async L=>{await x.execute({appPath:pe(L)})}),zv(l)},Go=async l=>{const s=l.test?h.DEFAULT_TEST_PORT:h.DEFAULT_PORT,r=l.port?parseInt(l.port,10):s;(isNaN(r)||r<1||r>65535)&&(console.error(v.default.red("Invalid port number.")),process.exit(1));const c=await h.serverStart({port:r,test:l.test,onProgress:f=>console.log(v.default.gray(f))});c.success||(console.error(v.default.red(c.error.message)),process.exit(1))},jo=l=>{const s=l.test?h.TEST_CONTAINER_NAME:h.CONTAINER_NAME;if(!h.containerExists(s)){console.log(v.default.yellow("No Twenty server container found."));return}Pn.execSync(`docker stop ${s}`,{stdio:"ignore"}),console.log(v.default.green("Twenty server stopped."))},qo=l=>{const s=l.test?h.TEST_CONTAINER_NAME:h.CONTAINER_NAME;if(!h.containerExists(s)){console.log(v.default.yellow("No Twenty server container found."));return}try{Pn.spawnSync("docker",["logs","-f","--tail",l.lines,s],{stdio:"inherit"})}catch{}},Ho=async l=>{const s=l.test?h.TEST_CONTAINER_NAME:h.CONTAINER_NAME,r=l.test?h.DEFAULT_TEST_PORT:h.DEFAULT_PORT;if(!h.containerExists(s)){console.log(` Status: ${v.default.gray("not created")}`),console.log(v.default.gray(` Run 'yarn twenty docker:start${l.test?" --test":""}' to create one.`));return}const c=h.isContainerRunning(s),f=c?h.getContainerPort(s):r,w=c?await h.checkServerHealth(f):!1,x=w?v.default.green("running (healthy)"):c?v.default.yellow("running (starting...)"):v.default.gray("stopped"),R=h.getContainerEnvVar("APP_VERSION",s);console.log(` Status: ${x}`),console.log(` URL: http://localhost:${f}`),R&&console.log(` Version: ${v.default.gray(R)}`),w&&console.log(v.default.gray(" Login: tim@apple.dev / tim@apple.dev"))},zo=l=>{const s=l.test?h.TEST_CONTAINER_NAME:h.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";h.containerExists(s)&&Pn.execSync(`docker rm -f ${s}`,{stdio:"ignore"});try{Pn.execSync(`docker volume rm ${r} ${c}`,{stdio:"ignore"})}catch{}console.log(v.default.green("Twenty server data reset.")),console.log(v.default.gray(`Run 'yarn twenty docker:start${l.test?" --test":""}' to start a fresh instance.`))},Ko=async(l,s)=>{const r=await h.serverUpgrade({version:l??"latest",test:s.test,onProgress:f=>console.log(v.default.gray(f))});r.success||(console.error(v.default.red(r.error.message)),process.exit(1));const{data:c}=r;if(!c.imageUpdated){console.log(v.default.green(` Already up to date (${c.image}).`));return}console.log(v.default.green(` Upgraded to: ${c.image}`)),c.containerRecreated&&console.log(v.default.gray(` Run 'yarn twenty docker:start${s.test?" --test":""}' to wait for the server to be ready.`))},Yv=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(Go),l.command("docker:stop").description("Stop the local Twenty container").option("--test","Stop the test instance").action(jo),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(qo),l.command("docker:status").description("Show container status").option("--test","Show status of the test instance").action(Ho),l.command("docker:reset").description("Delete all data and start fresh").option("--test","Reset the test instance").action(zo),l.command("docker:upgrade [version]").description("Upgrade the Docker image").option("--test","Upgrade the test instance").action(Ko);const s=l.command("server",{hidden:!0}).description("Manage a Twenty server (local instance and server-side actions)"),r=(c,f)=>console.warn(v.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"),jo(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"),qo(c)}),s.command("status").option("--test","Show status of the test instance").action(async c=>{r("status","docker:status"),await Ho(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-GJcaViDU.js"));await new f().execute({remote:c.remote})})},Jv=l=>{try{return new URL(l).hostname.replace(/\./g,"-")}catch{return"remote"}},Yo=async(l,s)=>s?((await h.authLogin({apiKey:s,apiUrl:l})).success||(console.error(v.default.red("✗ Authentication failed.")),process.exit(1)),"API key"):Zv(l),Zv=async l=>{console.log(v.default.gray("Opening browser for authentication..."));const s=await h.authLoginOAuth({apiUrl:l});if(s.success)return"OAuth";console.log(v.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 h.authLogin({apiKey:r.apiKey,apiUrl:l})).success||(console.error(v.default.red("✗ Authentication failed.")),process.exit(1)),"API key"},Jo=async l=>{l.apiUrl&&console.warn(v.default.yellow("⚠ --api-url is deprecated. Use --url instead."));const s=l.test?h.getConfigPath(!0):void 0,r=new h.ConfigService(s?{configPath:s}:void 0),c=await r.getRemotes();if(l.as!==void 0&&c.includes(l.as)){const R=await r.getConfigForRemote(l.as);h.ConfigService.setActiveRemote(l.as);const L=await Yo(R.apiUrl,l.apiKey);console.log(v.default.green(`✓ Re-authenticated "${l.as}" via ${L}.`)),await r.setDefaultRemote(l.as),console.log(v.default.green(`✓ Default remote set to "${l.as}".`));return}let f=l.url??l.apiUrl;if(f)f=h.Da(f);else{const R=await h.detectLocalServer();l.local?(R||(console.error(v.default.red(`No local Twenty server found.
388
+ Start one with: yarn twenty docker:start`)),process.exit(1)),console.log(v.default.gray(`Found local server at ${R}`)),f=R):f=h.Da((await Ye.default.prompt([{type:"input",name:"serverUrl",message:"Twenty server URL:",validate:L=>{try{return new URL(L),!0}catch{return"Please enter a valid URL"}}}])).serverUrl)}const w=l.as??Jv(f);h.ConfigService.setActiveRemote(w);const x=await Yo(f,l.apiKey);console.log(v.default.green(`✓ Remote "${w}" added (${f}) via ${x}.`)),await r.setDefaultRemote(w),console.log(v.default.green(`✓ Default remote set to "${w}".`))},Zo=async()=>{const l=new h.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),w=f.twentyCLIAccessToken?"oauth":f.apiKey?"api-key":"none",x=c===r,R=x?"* ":" ",L=x?v.default.bold(c):c;console.log(`${R}${L} ${v.default.gray(f.apiUrl)} [${w}]`)}console.log(`
389
+ `,v.default.gray("Use 'twenty remote:use <name>' to change default"))},Xo=async l=>{const s=new h.ConfigService,r=l??(await Ye.default.prompt([{type:"select",name:"remote",message:"Select default remote:",choices:await s.getRemotes()}])).remote;(await s.getRemotes()).includes(r)||(console.error(v.default.red(`Remote "${r}" not found.`)),process.exit(1)),await s.setDefaultRemote(r),console.log(v.default.green(`✓ Default remote set to "${r}".`))},Qo=async()=>{const l=new h.ConfigService,s=new h.ApiService,r=h.ConfigService.getActiveRemote(),c=await l.getConfig(),f=c.twentyCLIAccessToken?"oauth":c.apiKey?"api-key":"none";if(console.log(` Remote: ${v.default.bold(r)}`),console.log(` Server: ${c.apiUrl}`),f==="none"){console.log(` Auth: ${v.default.yellow("not configured")}`);return}const{authValid:w}=await s.validateAuth(),x=w?v.default.green(`${f} (valid)`):v.default.red(`${f} (invalid)`);console.log(` Auth: ${x}`)},el=async l=>{const s=new h.ConfigService;(await s.getRemotes()).includes(l)||(console.error(v.default.red(`Remote "${l}" not found.`)),process.exit(1)),h.ConfigService.setActiveRemote(l),await s.clearConfig(),console.log(v.default.green(`✓ Remote "${l}" removed.`))},Xv=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(Jo),l.command("remote:list").description("List all configured remotes").action(Zo),l.command("remote:use [name]").description("Set the default remote").action(Xo),l.command("remote:status").description("Show active remote auth status").action(Qo),l.command("remote:remove <name>").description("Remove a remote").action(el);const s=l.command("remote",{hidden:!0}).description("Manage remote Twenty servers"),r=(c,f)=>console.warn(v.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 el(c)})},Qv=l=>{Kv(l),Cm(l),Yv(l),Xv(l),Qm(l)};Am.inspect.defaultOptions.depth=10;const nn=new tl.Command;nn.name("twenty").description("CLI for Twenty application development").version(h.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(v.default.gray(`Using remote: ${r}`)):r=await new h.ConfigService().getDefaultRemote(),h.ConfigService.setActiveRemote(r)});Qv(nn);nn.exitOverride();try{nn.parse()}catch(l){l instanceof tl.CommanderError&&process.exit(l.exitCode),l instanceof Error&&(console.error(v.default.red("Error:"),l.message),process.exit(1))}