twenty-sdk 2.16.0 → 2.18.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.
Files changed (39) hide show
  1. package/dist/{catalog-sync-w6yKppKP.js → catalog-sync-CgKswjsE.js} +1 -1
  2. package/dist/{catalog-sync-BYM3GqZl.mjs → catalog-sync-YxvEEHz5.mjs} +1 -1
  3. package/dist/cli/commands/dev/i18n-extract.d.ts +7 -0
  4. package/dist/cli/utilities/build/common/front-component-build/css-injection-plugin.d.ts +2 -0
  5. package/dist/cli/utilities/i18n/collect-translatable-strings.d.ts +2 -0
  6. package/dist/cli/utilities/i18n/compile-application-translations.d.ts +1 -0
  7. package/dist/cli/utilities/i18n/constants.d.ts +1 -0
  8. package/dist/cli/utilities/i18n/extract-application-translations.d.ts +10 -0
  9. package/dist/cli/utilities/i18n/generate-message-id.d.ts +1 -0
  10. package/dist/cli.cjs +17 -15
  11. package/dist/cli.mjs +995 -935
  12. package/dist/define/index.cjs +2 -2
  13. package/dist/define/index.cjs.map +1 -1
  14. package/dist/define/index.d.ts +14 -5
  15. package/dist/define/index.mjs +28 -71
  16. package/dist/define/index.mjs.map +1 -1
  17. package/dist/front-component/index.cjs +1 -1
  18. package/dist/front-component/index.cjs.map +1 -1
  19. package/dist/front-component/index.d.ts +42 -12
  20. package/dist/front-component/index.mjs +134 -143
  21. package/dist/front-component/index.mjs.map +1 -1
  22. package/dist/front-component-renderer/build.cjs +1 -1
  23. package/dist/front-component-renderer/build.mjs +1 -1
  24. package/dist/{get-front-component-build-plugins-DBupR4cF.js → get-front-component-build-plugins-Dqpyup2W.js} +9 -5
  25. package/dist/get-front-component-build-plugins-taotEFOp.mjs +126 -0
  26. package/dist/{get-function-input-schema-GNk3NRLJ-zQkANyT3.mjs → get-function-input-schema-GNk3NRLJ-CfeAvjEl.mjs} +1 -1
  27. package/dist/{login-D7nyXinY.js → login-BOrzi4Z0.js} +50 -50
  28. package/dist/{login-rU5te3B6.mjs → login-Dg4Ap-uo.mjs} +3983 -3993
  29. package/dist/operations.cjs +1 -1
  30. package/dist/operations.mjs +1 -1
  31. package/package.json +3 -12
  32. package/dist/AllIcons-CdbaxNyc-CJcUHQBl.mjs +0 -66238
  33. package/dist/AllIcons-CdbaxNyc-DR-8e_UM.js +0 -1
  34. package/dist/get-front-component-build-plugins-BuE2QdIr.mjs +0 -113
  35. package/dist/icon-DMT-YeKi-C9-AduNa.mjs +0 -10168
  36. package/dist/icon-DMT-YeKi-Cz0W5sJA.js +0 -1
  37. package/dist/ui/index.cjs +0 -26
  38. package/dist/ui/index.d.ts +0 -18
  39. package/dist/ui/index.mjs +0 -15562
package/dist/cli.cjs CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./get-front-component-build-plugins-DBupR4cF.js"),t=require("./login-D7nyXinY.js"),n=require("./isDefined-Dtu5EYqP-Dp026Ry1.js");let r=require("path");r=e.i(r);let i=require("node:fs/promises"),a=require("uuid"),o=require("react");o=e.i(o);let s=require("node:path");s=e.i(s);let c=require("crypto");c=e.i(c);let l=require("node:child_process"),u=require("chalk");u=e.i(u);let d=require("inquirer");d=e.i(d);let f=require("chokidar");f=e.i(f);let p=require("react/jsx-runtime"),m=require("commander"),h=require("util");var g=e=>e&&!e?.startsWith(`/`)?(0,r.join)(t.vt,e):e,_=async e=>{let n=(0,r.join)(e,`package.json`);if(await t.at(n))try{let e=await(0,i.readFile)(n,`utf-8`),t=JSON.parse(e);return t.dependencies?.[`twenty-sdk`]??t.devDependencies?.[`twenty-sdk`]??void 0}catch{return}},v=e=>{let t=e.match(/(\d+)\./);if(t)return parseInt(t[1],10);let n=e.match(/^[~^>=<]*(\d+)$/);return n?parseInt(n[1],10):null},y=async e=>{let n=t.P.version,r=await _(e);if(!n||!r)return;let i=v(n),a=v(r);i===null||a===null||i!==a&&(console.warn(u.default.yellow(`⚠ Version mismatch: your app requires twenty-sdk@${a}.x but the CLI running is v${n}. Major version mismatches may cause unexpected behavior.\n Update with: npm install -g twenty-sdk@${a}`)),console.warn(``))},b=class{async execute(e){e.private?await this.executePrivate(e):await this.executeNpm(e)}async executeNpm(e){let n=e.appPath??t.vt;await y(n),console.log(u.default.blue(`Publishing to npm...`)),console.log(u.default.gray(`App path: ${n}\n`));let r=await t.F({appPath:n,npmTag:e.tag,onProgress:e=>console.log(u.default.gray(e))});r.success||(console.error(u.default.red(r.error.message)),process.exit(1)),console.log(u.default.green(`✓ Published to npm successfully`))}async executePrivate(e){let n=e.appPath??t.vt;await y(n);let i=e.remote??t.V.getActiveRemote();console.log(u.default.blue(`Deploying application on ${i}...`)),console.log(u.default.gray(`App path: ${n}\n`));let a=e=>console.log(u.default.gray(e)),o=await t.U({appPath:n,tarball:!0,onProgress:a});o.success||(console.error(u.default.red(o.error.message)),process.exit(1));let s=await t.I({tarballPath:o.data.tarballPath,remote:e.remote,onProgress:a});s.success||(console.error(u.default.red(s.error.message)),process.exit(1));let c=await t.ot(r.default.join(n,`package.json`)).catch(()=>void 0),l=c?.name??s.data.name,d=c?.version??`unknown`;console.log(u.default.green(`\n✓ Published ${l} v${d} to ${i}\n`)),console.log(" To install deployed application: `yarn twenty app:install`")}},x=class{async execute(e){let n=e.appPath??t.vt;await y(n),await t._();let r=e.remote??t.V.getActiveRemote();console.log(u.default.blue(`Installing application on ${r}...`)),console.log(u.default.gray(`App path: ${n}\n`));let i=await t.j({appPath:n,remote:e.remote});i.success||(console.error(u.default.red(i.error.message)),process.exit(1)),console.log(u.default.green(`✓ Application installed`))}},S=class{async execute({appPath:e=t.vt,askForConfirmation:n}){let r=t.V.getActiveRemote();console.log(u.default.blue(`🚀 Uninstall Twenty Application on ${r}`)),console.log(u.default.gray(`📁 App Path: ${e}\n`)),n&&!await this.confirmationPrompt()&&(console.error(u.default.red(`⛔️ Aborting uninstall`)),process.exit(1));let i=await t.g({appPath:e});return i.success?(console.log(u.default.green(`✅ Application uninstalled successfully`)),{success:!0,data:void 0}):(console.error(u.default.red(`❌ Uninstall failed:`),i.error.message),{success:!1,error:i.error.message})}async confirmationPrompt(){let{confirmation:e}=await d.default.prompt([{type:`confirm`,name:`confirmation`,message:`Are you sure you want to uninstall this application?`,default:!1}]);return e}},ee=e=>{let t=new b,n=new x,r=new S;e.command(`app:publish [appPath]`).description(`Build and publish to npm (default) or server registry`).option(`--private`,`Push to a Twenty server's registry instead of npm`).option(`-r, --remote <name>`,`Publish to a specific remote (with --private)`).option(`--tag <tag>`,`npm dist-tag (e.g. beta, next)`).action(async(e,n)=>{await t.execute({appPath:g(e),private:n.private,remote:n.remote,tag:n.tag})}),e.command(`app:install [appPath]`).description(`Install a deployed app on the server`).option(`-r, --remote <name>`,`Install on a specific remote`).action(async(e,t)=>{await n.execute({appPath:g(e),remote:t.remote})}),e.command(`app:uninstall [appPath]`).description(`Uninstall app from server`).option(`-y, --yes`,`Skip confirmation prompt`).action(async(e,t)=>{try{let n=await r.execute({appPath:g(e),askForConfirmation:!t?.yes});process.exit(+!n.success)}catch{process.exit(1)}})},te=e.n(((e,t)=>{(function(){var n,r=`4.18.1`,i=200,a=`Unsupported core-js use. Try https://npms.io/search?q=ponyfill.`,o=`Expected a function`,s="Invalid `variable` option passed into `_.template`",c="Invalid `imports` option passed into `_.template`",l=`__lodash_hash_undefined__`,u=500,d=`__lodash_placeholder__`,f=1,p=2,m=4,h=1,g=2,_=1,v=2,y=4,b=8,x=16,S=32,ee=64,te=128,ne=256,re=512,ie=30,ae=`...`,oe=800,se=16,ce=1,le=2,ue=3,C=1/0,de=9007199254740991,fe=17976931348623157e292,pe=NaN,me=4294967295,he=me-1,ge=me>>>1,_e=[[`ary`,te],[`bind`,_],[`bindKey`,v],[`curry`,b],[`curryRight`,x],[`flip`,re],[`partial`,S],[`partialRight`,ee],[`rearg`,ne]],ve=`[object Arguments]`,ye=`[object Array]`,be=`[object AsyncFunction]`,xe=`[object Boolean]`,Se=`[object Date]`,Ce=`[object DOMException]`,we=`[object Error]`,Te=`[object Function]`,Ee=`[object GeneratorFunction]`,w=`[object Map]`,De=`[object Number]`,Oe=`[object Null]`,ke=`[object Object]`,Ae=`[object Promise]`,je=`[object Proxy]`,Me=`[object RegExp]`,T=`[object Set]`,Ne=`[object String]`,Pe=`[object Symbol]`,Fe=`[object Undefined]`,Ie=`[object WeakMap]`,Le=`[object WeakSet]`,Re=`[object ArrayBuffer]`,ze=`[object DataView]`,Be=`[object Float32Array]`,Ve=`[object Float64Array]`,He=`[object Int8Array]`,Ue=`[object Int16Array]`,We=`[object Int32Array]`,Ge=`[object Uint8Array]`,Ke=`[object Uint8ClampedArray]`,qe=`[object Uint16Array]`,Je=`[object Uint32Array]`,Ye=/\b__p \+= '';/g,Xe=/\b(__p \+=) '' \+/g,Ze=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Qe=/&(?:amp|lt|gt|quot|#39);/g,$e=/[&<>"']/g,et=RegExp(Qe.source),tt=RegExp($e.source),nt=/<%-([\s\S]+?)%>/g,rt=/<%([\s\S]+?)%>/g,it=/<%=([\s\S]+?)%>/g,at=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ot=/^\w*$/,st=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ct=/[\\^$.*+?()[\]{}|]/g,lt=RegExp(ct.source),ut=/^\s+/,E=/\s/,dt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ft=/\{\n\/\* \[wrapped with (.+)\] \*/,pt=/,? & /,mt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ht=/[()=,{}\[\]\/\s]/,gt=/\\(\\)?/g,_t=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,vt=/\w*$/,yt=/^[-+]0x[0-9a-f]+$/i,bt=/^0b[01]+$/i,xt=/^\[object .+?Constructor\]$/,St=/^0o[0-7]+$/i,Ct=/^(?:0|[1-9]\d*)$/,wt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Tt=/($^)/,Et=/['\n\r\u2028\u2029\\]/g,Dt=`\\ud800-\\udfff`,Ot=`\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff`,kt=`\\u2700-\\u27bf`,D=`a-z\\xdf-\\xf6\\xf8-\\xff`,At=`\\xac\\xb1\\xd7\\xf7`,jt=`\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf`,O=`\\u2000-\\u206f`,Mt=` \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000`,Nt=`A-Z\\xc0-\\xd6\\xd8-\\xde`,Pt=`\\ufe0e\\ufe0f`,Ft=At+jt+O+Mt,It=`['’]`,k=`[`+Dt+`]`,Lt=`[`+Ft+`]`,Rt=`[`+Ot+`]`,zt=`\\d+`,Bt=`[`+kt+`]`,Vt=`[`+D+`]`,Ht=`[^`+Dt+Ft+zt+kt+D+Nt+`]`,Ut=`\\ud83c[\\udffb-\\udfff]`,Wt=`(?:`+Rt+`|`+Ut+`)`,Gt=`[^`+Dt+`]`,Kt=`(?:\\ud83c[\\udde6-\\uddff]){2}`,qt=`[\\ud800-\\udbff][\\udc00-\\udfff]`,Jt=`[`+Nt+`]`,Yt=`\\u200d`,Xt=`(?:`+Vt+`|`+Ht+`)`,Zt=`(?:`+Jt+`|`+Ht+`)`,Qt=`(?:`+It+`(?:d|ll|m|re|s|t|ve))?`,$t=`(?:`+It+`(?:D|LL|M|RE|S|T|VE))?`,en=Wt+`?`,tn=`[`+Pt+`]?`,nn=`(?:`+Yt+`(?:`+[Gt,Kt,qt].join(`|`)+`)`+tn+en+`)*`,rn=`\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])`,an=`\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])`,on=tn+en+nn,sn=`(?:`+[Bt,Kt,qt].join(`|`)+`)`+on,cn=`(?:`+[Gt+Rt+`?`,Rt,Kt,qt,k].join(`|`)+`)`,ln=RegExp(It,`g`),un=RegExp(Rt,`g`),dn=RegExp(Ut+`(?=`+Ut+`)|`+cn+on,`g`),fn=RegExp([Jt+`?`+Vt+`+`+Qt+`(?=`+[Lt,Jt,`$`].join(`|`)+`)`,Zt+`+`+$t+`(?=`+[Lt,Jt+Xt,`$`].join(`|`)+`)`,Jt+`?`+Xt+`+`+Qt,Jt+`+`+$t,an,rn,zt,sn].join(`|`),`g`),pn=RegExp(`[`+Yt+Dt+Ot+Pt+`]`),A=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,mn=`Array.Buffer.DataView.Date.Error.Float32Array.Float64Array.Function.Int8Array.Int16Array.Int32Array.Map.Math.Object.Promise.RegExp.Set.String.Symbol.TypeError.Uint8Array.Uint8ClampedArray.Uint16Array.Uint32Array.WeakMap._.clearTimeout.isFinite.parseInt.setTimeout`.split(`.`),hn=-1,j={};j[Be]=j[Ve]=j[He]=j[Ue]=j[We]=j[Ge]=j[Ke]=j[qe]=j[Je]=!0,j[ve]=j[ye]=j[Re]=j[xe]=j[ze]=j[Se]=j[we]=j[Te]=j[w]=j[De]=j[ke]=j[Me]=j[T]=j[Ne]=j[Ie]=!1;var M={};M[ve]=M[ye]=M[Re]=M[ze]=M[xe]=M[Se]=M[Be]=M[Ve]=M[He]=M[Ue]=M[We]=M[w]=M[De]=M[ke]=M[Me]=M[T]=M[Ne]=M[Pe]=M[Ge]=M[Ke]=M[qe]=M[Je]=!0,M[we]=M[Te]=M[Ie]=!1;var N={À:`A`,Á:`A`,Â:`A`,Ã:`A`,Ä:`A`,Å:`A`,à:`a`,á:`a`,â:`a`,ã:`a`,ä:`a`,å:`a`,Ç:`C`,ç:`c`,Ð:`D`,ð:`d`,È:`E`,É:`E`,Ê:`E`,Ë:`E`,è:`e`,é:`e`,ê:`e`,ë:`e`,Ì:`I`,Í:`I`,Î:`I`,Ï:`I`,ì:`i`,í:`i`,î:`i`,ï:`i`,Ñ:`N`,ñ:`n`,Ò:`O`,Ó:`O`,Ô:`O`,Õ:`O`,Ö:`O`,Ø:`O`,ò:`o`,ó:`o`,ô:`o`,õ:`o`,ö:`o`,ø:`o`,Ù:`U`,Ú:`U`,Û:`U`,Ü:`U`,ù:`u`,ú:`u`,û:`u`,ü:`u`,Ý:`Y`,ý:`y`,ÿ:`y`,Æ:`Ae`,æ:`ae`,Þ:`Th`,þ:`th`,ß:`ss`,Ā:`A`,Ă:`A`,Ą:`A`,ā:`a`,ă:`a`,ą:`a`,Ć:`C`,Ĉ:`C`,Ċ:`C`,Č:`C`,ć:`c`,ĉ:`c`,ċ:`c`,č:`c`,Ď:`D`,Đ:`D`,ď:`d`,đ:`d`,Ē:`E`,Ĕ:`E`,Ė:`E`,Ę:`E`,Ě:`E`,ē:`e`,ĕ:`e`,ė:`e`,ę:`e`,ě:`e`,Ĝ:`G`,Ğ:`G`,Ġ:`G`,Ģ:`G`,ĝ:`g`,ğ:`g`,ġ:`g`,ģ:`g`,Ĥ:`H`,Ħ:`H`,ĥ:`h`,ħ:`h`,Ĩ:`I`,Ī:`I`,Ĭ:`I`,Į:`I`,İ:`I`,ĩ:`i`,ī:`i`,ĭ:`i`,į:`i`,ı:`i`,Ĵ:`J`,ĵ:`j`,Ķ:`K`,ķ:`k`,ĸ:`k`,Ĺ:`L`,Ļ:`L`,Ľ:`L`,Ŀ:`L`,Ł:`L`,ĺ:`l`,ļ:`l`,ľ:`l`,ŀ:`l`,ł:`l`,Ń:`N`,Ņ:`N`,Ň:`N`,Ŋ:`N`,ń:`n`,ņ:`n`,ň:`n`,ŋ:`n`,Ō:`O`,Ŏ:`O`,Ő:`O`,ō:`o`,ŏ:`o`,ő:`o`,Ŕ:`R`,Ŗ:`R`,Ř:`R`,ŕ:`r`,ŗ:`r`,ř:`r`,Ś:`S`,Ŝ:`S`,Ş:`S`,Š:`S`,ś:`s`,ŝ:`s`,ş:`s`,š:`s`,Ţ:`T`,Ť:`T`,Ŧ:`T`,ţ:`t`,ť:`t`,ŧ:`t`,Ũ:`U`,Ū:`U`,Ŭ:`U`,Ů:`U`,Ű:`U`,Ų:`U`,ũ:`u`,ū:`u`,ŭ:`u`,ů:`u`,ű:`u`,ų:`u`,Ŵ:`W`,ŵ:`w`,Ŷ:`Y`,ŷ:`y`,Ÿ:`Y`,Ź:`Z`,Ż:`Z`,Ž:`Z`,ź:`z`,ż:`z`,ž:`z`,IJ:`IJ`,ij:`ij`,Œ:`Oe`,œ:`oe`,ʼn:`'n`,ſ:`s`},gn={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},_n={"&amp;":`&`,"&lt;":`<`,"&gt;":`>`,"&quot;":`"`,"&#39;":`'`},vn={"\\":`\\`,"'":`'`,"\n":`n`,"\r":`r`,"\u2028":`u2028`,"\u2029":`u2029`},yn=parseFloat,bn=parseInt,xn=typeof global==`object`&&global&&global.Object===Object&&global,Sn=typeof self==`object`&&self&&self.Object===Object&&self,P=xn||Sn||Function(`return this`)(),Cn=typeof e==`object`&&e&&!e.nodeType&&e,wn=Cn&&typeof t==`object`&&t&&!t.nodeType&&t,Tn=wn&&wn.exports===Cn,En=Tn&&xn.process,F=function(){try{return wn&&wn.require&&wn.require(`util`).types||En&&En.binding&&En.binding(`util`)}catch{}}(),Dn=F&&F.isArrayBuffer,On=F&&F.isDate,kn=F&&F.isMap,An=F&&F.isRegExp,jn=F&&F.isSet,Mn=F&&F.isTypedArray;function Nn(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function Pn(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}function Fn(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}function In(e,t){for(var n=e==null?0:e.length;n--&&t(e[n],n,e)!==!1;);return e}function Ln(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(!t(e[n],n,e))return!1;return!0}function Rn(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function zn(e,t){return!!(e!=null&&e.length)&&Xn(e,t,0)>-1}function Bn(e,t,n){for(var r=-1,i=e==null?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}function I(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}function Vn(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function Hn(e,t,n,r){var i=-1,a=e==null?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}function Un(e,t,n,r){var i=e==null?0:e.length;for(r&&i&&(n=e[--i]);i--;)n=t(n,e[i],i,e);return n}function Wn(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}var Gn=er(`length`);function Kn(e){return e.split(``)}function qn(e){return e.match(mt)||[]}function Jn(e,t,n){var r;return n(e,function(e,n,i){if(t(e,n,i))return r=n,!1}),r}function Yn(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1}function Xn(e,t,n){return t===t?Er(e,t,n):Yn(e,Qn,n)}function Zn(e,t,n,r){for(var i=n-1,a=e.length;++i<a;)if(r(e[i],t))return i;return-1}function Qn(e){return e!==e}function $n(e,t){var n=e==null?0:e.length;return n?ir(e,t)/n:pe}function er(e){return function(t){return t==null?n:t[e]}}function tr(e){return function(t){return e==null?n:e[t]}}function nr(e,t,n,r,i){return i(e,function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)}),n}function rr(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}function ir(e,t){for(var r,i=-1,a=e.length;++i<a;){var o=t(e[i]);o!==n&&(r=r===n?o:r+o)}return r}function ar(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function or(e,t){return I(t,function(t){return[t,e[t]]})}function sr(e){return e&&e.slice(0,Ar(e)+1).replace(ut,``)}function cr(e){return function(t){return e(t)}}function lr(e,t){return I(t,function(t){return e[t]})}function ur(e,t){return e.has(t)}function dr(e,t){for(var n=-1,r=e.length;++n<r&&Xn(t,e[n],0)>-1;);return n}function fr(e,t){for(var n=e.length;n--&&Xn(t,e[n],0)>-1;);return n}function pr(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}var mr=tr(N),hr=tr(gn);function gr(e){return`\\`+vn[e]}function _r(e,t){return e==null?n:e[t]}function vr(e){return pn.test(e)}function yr(e){return A.test(e)}function br(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}function xr(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function Sr(e,t){return function(n){return e(t(n))}}function Cr(e,t){for(var n=-1,r=e.length,i=0,a=[];++n<r;){var o=e[n];(o===t||o===d)&&(e[n]=d,a[i++]=n)}return a}function wr(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}function Tr(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=[e,e]}),n}function Er(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}function Dr(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}function Or(e){return vr(e)?Mr(e):Gn(e)}function kr(e){return vr(e)?Nr(e):Kn(e)}function Ar(e){for(var t=e.length;t--&&E.test(e.charAt(t)););return t}var jr=tr(_n);function Mr(e){for(var t=dn.lastIndex=0;dn.test(e);)++t;return t}function Nr(e){return e.match(dn)||[]}function Pr(e){return e.match(fn)||[]}var Fr=(function e(t){t=t==null?P:Fr.defaults(P.Object(),t,Fr.pick(P,mn));var E=t.Array,mt=t.Date,Dt=t.Error,Ot=t.Function,kt=t.Math,D=t.Object,At=t.RegExp,jt=t.String,O=t.TypeError,Mt=E.prototype,Nt=Ot.prototype,Pt=D.prototype,Ft=t[`__core-js_shared__`],It=Nt.toString,k=Pt.hasOwnProperty,Lt=0,Rt=function(){var e=/[^.]+$/.exec(Ft&&Ft.keys&&Ft.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}(),zt=Pt.toString,Bt=It.call(D),Vt=P._,Ht=At(`^`+It.call(k).replace(ct,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`),Ut=Tn?t.Buffer:n,Wt=t.Symbol,Gt=t.Uint8Array,Kt=Ut?Ut.allocUnsafe:n,qt=Sr(D.getPrototypeOf,D),Jt=D.create,Yt=Pt.propertyIsEnumerable,Xt=Mt.splice,Zt=Wt?Wt.isConcatSpreadable:n,Qt=Wt?Wt.iterator:n,$t=Wt?Wt.toStringTag:n,en=function(){try{var e=is(D,`defineProperty`);return e({},``,{}),e}catch{}}(),tn=t.clearTimeout!==P.clearTimeout&&t.clearTimeout,nn=mt&&mt.now!==P.Date.now&&mt.now,rn=t.setTimeout!==P.setTimeout&&t.setTimeout,an=kt.ceil,on=kt.floor,sn=D.getOwnPropertySymbols,cn=Ut?Ut.isBuffer:n,dn=t.isFinite,fn=Mt.join,pn=Sr(D.keys,D),A=kt.max,N=kt.min,gn=mt.now,_n=t.parseInt,vn=kt.random,xn=Mt.reverse,Sn=is(t,`DataView`),Cn=is(t,`Map`),wn=is(t,`Promise`),En=is(t,`Set`),F=is(t,`WeakMap`),Gn=is(D,`create`),Kn=F&&new F,tr={},Er=Vs(Sn),Mr=Vs(Cn),Nr=Vs(wn),Ir=Vs(En),Lr=Vs(F),Rr=Wt?Wt.prototype:n,zr=Rr?Rr.valueOf:n,Br=Rr?Rr.toString:n;function L(e){if(Y(e)&&!K(e)&&!(e instanceof R)){if(e instanceof Ur)return e;if(k.call(e,`__wrapped__`))return Us(e)}return new Ur(e)}var Vr=function(){function e(){}return function(t){if(!J(t))return{};if(Jt)return Jt(t);e.prototype=t;var r=new e;return e.prototype=n,r}}();function Hr(){}function Ur(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=n}L.templateSettings={escape:nt,evaluate:rt,interpolate:it,variable:``,imports:{_:L}},L.prototype=Hr.prototype,L.prototype.constructor=L,Ur.prototype=Vr(Hr.prototype),Ur.prototype.constructor=Ur;function R(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=me,this.__views__=[]}function Wr(){var e=new R(this.__wrapped__);return e.__actions__=H(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=H(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=H(this.__views__),e}function Gr(){if(this.__filtered__){var e=new R(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Kr(){var e=this.__wrapped__.value(),t=this.__dir__,n=K(e),r=t<0,i=n?e.length:0,a=cs(0,i,this.__views__),o=a.start,s=a.end,c=s-o,l=r?s:o-1,u=this.__iteratees__,d=u.length,f=0,p=N(c,this.__takeCount__);if(!n||!r&&i==c&&p==c)return Za(e,this.__actions__);var m=[];outer:for(;c--&&f<p;){l+=t;for(var h=-1,g=e[l];++h<d;){var _=u[h],v=_.iteratee,y=_.type,b=v(g);if(y==le)g=b;else if(!b){if(y==ce)continue outer;break outer}}m[f++]=g}return m}R.prototype=Vr(Hr.prototype),R.prototype.constructor=R;function qr(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Jr(){this.__data__=Gn?Gn(null):{},this.size=0}function Yr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}function Xr(e){var t=this.__data__;if(Gn){var r=t[e];return r===l?n:r}return k.call(t,e)?t[e]:n}function Zr(e){var t=this.__data__;return Gn?t[e]!==n:k.call(t,e)}function Qr(e,t){var r=this.__data__;return this.size+=+!this.has(e),r[e]=Gn&&t===n?l:t,this}qr.prototype.clear=Jr,qr.prototype.delete=Yr,qr.prototype.get=Xr,qr.prototype.has=Zr,qr.prototype.set=Qr;function $r(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ei(){this.__data__=[],this.size=0}function ti(e){var t=this.__data__,n=Ei(t,e);return n<0?!1:(n==t.length-1?t.pop():Xt.call(t,n,1),--this.size,!0)}function ni(e){var t=this.__data__,r=Ei(t,e);return r<0?n:t[r][1]}function ri(e){return Ei(this.__data__,e)>-1}function ii(e,t){var n=this.__data__,r=Ei(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}$r.prototype.clear=ei,$r.prototype.delete=ti,$r.prototype.get=ni,$r.prototype.has=ri,$r.prototype.set=ii;function ai(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function oi(){this.size=0,this.__data__={hash:new qr,map:new(Cn||$r),string:new qr}}function si(e){var t=ns(this,e).delete(e);return this.size-=+!!t,t}function ci(e){return ns(this,e).get(e)}function li(e){return ns(this,e).has(e)}function ui(e,t){var n=ns(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}ai.prototype.clear=oi,ai.prototype.delete=si,ai.prototype.get=ci,ai.prototype.has=li,ai.prototype.set=ui;function di(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new ai;++t<n;)this.add(e[t])}function fi(e){return this.__data__.set(e,l),this}function pi(e){return this.__data__.has(e)}di.prototype.add=di.prototype.push=fi,di.prototype.has=pi;function mi(e){var t=this.__data__=new $r(e);this.size=t.size}function hi(){this.__data__=new $r,this.size=0}function gi(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function _i(e){return this.__data__.get(e)}function vi(e){return this.__data__.has(e)}function yi(e,t){var n=this.__data__;if(n instanceof $r){var r=n.__data__;if(!Cn||r.length<i-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ai(r)}return n.set(e,t),this.size=n.size,this}mi.prototype.clear=hi,mi.prototype.delete=gi,mi.prototype.get=_i,mi.prototype.has=vi,mi.prototype.set=yi;function bi(e,t){var n=K(e),r=!n&&gu(e),i=!n&&!r&&bu(e),a=!n&&!r&&!i&&Gu(e),o=n||r||i||a,s=o?ar(e.length,jt):[],c=s.length;for(var l in e)(t||k.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||gs(l,c)))&&s.push(l);return s}function xi(e){var t=e.length;return t?e[ja(0,t-1)]:n}function Si(e,t){return Rs(H(e),Mi(t,0,e.length))}function Ci(e){return Rs(H(e))}function wi(e,t,r){(r!==n&&!pu(e[t],r)||r===n&&!(t in e))&&Ai(e,t,r)}function Ti(e,t,r){var i=e[t];(!(k.call(e,t)&&pu(i,r))||r===n&&!(t in e))&&Ai(e,t,r)}function Ei(e,t){for(var n=e.length;n--;)if(pu(e[n][0],t))return n;return-1}function Di(e,t,n,r){return Ri(e,function(e,i,a){t(r,e,n(e),a)}),r}function Oi(e,t){return e&&_o(t,Q(t),e)}function ki(e,t){return e&&_o(t,Td(t),e)}function Ai(e,t,n){t==`__proto__`&&en?en(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function ji(e,t){for(var r=-1,i=t.length,a=E(i),o=e==null;++r<i;)a[r]=o?n:yd(e,t[r]);return a}function Mi(e,t,r){return e===e&&(r!==n&&(e=e<=r?e:r),t!==n&&(e=e>=t?e:t)),e}function Ni(e,t,r,i,a,o){var s,c=t&f,l=t&p,u=t&m;if(r&&(s=a?r(e,i,a,o):r(e)),s!==n)return s;if(!J(e))return e;var d=K(e);if(d){if(s=ds(e),!c)return H(e,s)}else{var h=W(e),g=h==Te||h==Ee;if(bu(e))return oo(e,c);if(h==ke||h==ve||g&&!a){if(s=l||g?{}:fs(e),!c)return l?yo(e,ki(s,e)):vo(e,Oi(s,e))}else{if(!M[h])return a?e:{};s=ps(e,h,c)}}o||=new mi;var _=o.get(e);if(_)return _;o.set(e,s),Hu(e)?e.forEach(function(n){s.add(Ni(n,t,r,n,e,o))}):ju(e)&&e.forEach(function(n,i){s.set(i,Ni(n,t,r,i,e,o))});var v=d?n:(u?l?Qo:Zo:l?Td:Q)(e);return Fn(v||e,function(n,i){v&&(i=n,n=e[i]),Ti(s,i,Ni(n,t,r,i,e,o))}),s}function Pi(e){var t=Q(e);return function(n){return Fi(n,e,t)}}function Fi(e,t,r){var i=r.length;if(e==null)return!i;for(e=D(e);i--;){var a=r[i],o=t[a],s=e[a];if(s===n&&!(a in e)||!o(s))return!1}return!0}function Ii(e,t,r){if(typeof e!=`function`)throw new O(o);return Ps(function(){e.apply(n,r)},t)}function Li(e,t,n,r){var a=-1,o=zn,s=!0,c=e.length,l=[],u=t.length;if(!c)return l;n&&(t=I(t,cr(n))),r?(o=Bn,s=!1):t.length>=i&&(o=ur,s=!1,t=new di(t));outer:for(;++a<c;){var d=e[a],f=n==null?d:n(d);if(d=r||d!==0?d:0,s&&f===f){for(var p=u;p--;)if(t[p]===f)continue outer;l.push(d)}else o(t,f,r)||l.push(d)}return l}var Ri=So(Ki),zi=So(qi,!0);function Bi(e,t){var n=!0;return Ri(e,function(e,r,i){return n=!!t(e,r,i),n}),n}function Vi(e,t,r){for(var i=-1,a=e.length;++i<a;){var o=e[i],s=t(o);if(s!=null&&(c===n?s===s&&!Wu(s):r(s,c)))var c=s,l=o}return l}function Hi(e,t,r,i){var a=e.length;for(r=X(r),r<0&&(r=-r>a?0:a+r),i=i===n||i>a?a:X(i),i<0&&(i+=a),i=r>i?0:$u(i);r<i;)e[r++]=t;return e}function Ui(e,t){var n=[];return Ri(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function z(e,t,n,r,i){var a=-1,o=e.length;for(n||=hs,i||=[];++a<o;){var s=e[a];t>0&&n(s)?t>1?z(s,t-1,n,r,i):Vn(i,s):r||(i[i.length]=s)}return i}var Wi=Co(),Gi=Co(!0);function Ki(e,t){return e&&Wi(e,t,Q)}function qi(e,t){return e&&Gi(e,t,Q)}function Ji(e,t){return Rn(t,function(t){return Ou(e[t])})}function Yi(e,t){t=no(t,e);for(var r=0,i=t.length;e!=null&&r<i;)e=e[Bs(t[r++])];return r&&r==i?e:n}function Xi(e,t,n){var r=t(e);return K(e)?r:Vn(r,n(e))}function B(e){return e==null?e===n?Fe:Oe:$t&&$t in D(e)?as(e):Os(e)}function Zi(e,t){return e>t}function Qi(e,t){return e!=null&&k.call(e,t)}function $i(e,t){return e!=null&&t in D(e)}function ea(e,t,n){return e>=N(t,n)&&e<A(t,n)}function ta(e,t,r){for(var i=r?Bn:zn,a=e[0].length,o=e.length,s=o,c=E(o),l=1/0,u=[];s--;){var d=e[s];s&&t&&(d=I(d,cr(t))),l=N(d.length,l),c[s]=!r&&(t||a>=120&&d.length>=120)?new di(s&&d):n}d=e[0];var f=-1,p=c[0];outer:for(;++f<a&&u.length<l;){var m=d[f],h=t?t(m):m;if(m=r||m!==0?m:0,!(p?ur(p,h):i(u,h,r))){for(s=o;--s;){var g=c[s];if(!(g?ur(g,h):i(e[s],h,r)))continue outer}p&&p.push(h),u.push(m)}}return u}function na(e,t,n,r){return Ki(e,function(e,i,a){t(r,n(e),i,a)}),r}function ra(e,t,r){t=no(t,e),e=As(e,t);var i=e==null?e:e[Bs(mc(t))];return i==null?n:Nn(i,e,r)}function ia(e){return Y(e)&&B(e)==ve}function aa(e){return Y(e)&&B(e)==Re}function oa(e){return Y(e)&&B(e)==Se}function sa(e,t,n,r,i){return e===t?!0:e==null||t==null||!Y(e)&&!Y(t)?e!==e&&t!==t:ca(e,t,n,r,sa,i)}function ca(e,t,n,r,i,a){var o=K(e),s=K(t),c=o?ye:W(e),l=s?ye:W(t);c=c==ve?ke:c,l=l==ve?ke:l;var u=c==ke,d=l==ke,f=c==l;if(f&&bu(e)){if(!bu(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new mi,o||Gu(e)?qo(e,t,n,r,i,a):Jo(e,t,c,n,r,i,a);if(!(n&h)){var p=u&&k.call(e,`__wrapped__`),m=d&&k.call(t,`__wrapped__`);if(p||m){var g=p?e.value():e,_=m?t.value():t;return a||=new mi,i(g,_,n,r,a)}}return f?(a||=new mi,Yo(e,t,n,r,i,a)):!1}function la(e){return Y(e)&&W(e)==w}function ua(e,t,r,i){var a=r.length,o=a,s=!i;if(e==null)return!o;for(e=D(e);a--;){var c=r[a];if(s&&c[2]?c[1]!==e[c[0]]:!(c[0]in e))return!1}for(;++a<o;){c=r[a];var l=c[0],u=e[l],d=c[1];if(s&&c[2]){if(u===n&&!(l in e))return!1}else{var f=new mi;if(i)var p=i(u,d,l,e,t,f);if(!(p===n?sa(d,u,h|g,i,f):p))return!1}}return!0}function da(e){return!J(e)||bs(e)?!1:(Ou(e)?Ht:xt).test(Vs(e))}function fa(e){return Y(e)&&B(e)==Me}function pa(e){return Y(e)&&W(e)==T}function ma(e){return Y(e)&&Au(e.length)&&!!j[B(e)]}function ha(e){return typeof e==`function`?e:e==null?$:typeof e==`object`?K(e)?xa(e[0],e[1]):ba(e):Gf(e)}function ga(e){if(!Ss(e))return pn(e);var t=[];for(var n in D(e))k.call(e,n)&&n!=`constructor`&&t.push(n);return t}function _a(e){if(!J(e))return Ds(e);var t=Ss(e),n=[];for(var r in e)r==`constructor`&&(t||!k.call(e,r))||n.push(r);return n}function va(e,t){return e<t}function ya(e,t){var n=-1,r=vu(e)?E(e.length):[];return Ri(e,function(e,i,a){r[++n]=t(e,i,a)}),r}function ba(e){var t=rs(e);return t.length==1&&t[0][2]?ws(t[0][0],t[0][1]):function(n){return n===e||ua(n,e,t)}}function xa(e,t){return _s(e)&&Cs(t)?ws(Bs(e),t):function(r){var i=yd(r,e);return i===n&&i===t?xd(r,e):sa(t,i,h|g)}}function Sa(e,t,r,i,a){e!==t&&Wi(t,function(o,s){if(a||=new mi,J(o))Ca(e,t,s,r,Sa,i,a);else{var c=i?i(Ms(e,s),o,s+``,e,t,a):n;c===n&&(c=o),wi(e,s,c)}},Td)}function Ca(e,t,r,i,a,o,s){var c=Ms(e,r),l=Ms(t,r),u=s.get(l);if(u){wi(e,r,u);return}var d=o?o(c,l,r+``,e,t,s):n,f=d===n;if(f){var p=K(l),m=!p&&bu(l),h=!p&&!m&&Gu(l);d=l,p||m||h?K(c)?d=c:q(c)?d=H(c):m?(f=!1,d=oo(l,!0)):h?(f=!1,d=fo(l,!0)):d=[]:zu(l)||gu(l)?(d=c,gu(c)?d=td(c):(!J(c)||Ou(c))&&(d=fs(l))):f=!1}f&&(s.set(l,d),a(d,l,i,o,s),s.delete(l)),wi(e,r,d)}function wa(e,t){var r=e.length;if(r)return t+=t<0?r:0,gs(t,r)?e[t]:n}function Ta(e,t,n){t=t.length?I(t,function(e){return K(e)?function(t){return Yi(t,e.length===1?e[0]:e)}:e}):[$];var r=-1;return t=I(t,cr(U())),rr(ya(e,function(e,n,i){return{criteria:I(t,function(t){return t(e)}),index:++r,value:e}}),function(e,t){return mo(e,t,n)})}function Ea(e,t){return Da(e,t,function(t,n){return xd(e,n)})}function Da(e,t,n){for(var r=-1,i=t.length,a={};++r<i;){var o=t[r],s=Yi(e,o);n(s,o)&&Ia(a,no(o,e),s)}return a}function Oa(e){return function(t){return Yi(t,e)}}function ka(e,t,n,r){var i=r?Zn:Xn,a=-1,o=t.length,s=e;for(e===t&&(t=H(t)),n&&(s=I(e,cr(n)));++a<o;)for(var c=0,l=t[a],u=n?n(l):l;(c=i(s,u,c,r))>-1;)s!==e&&Xt.call(s,c,1),Xt.call(e,c,1);return e}function Aa(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==a){var a=i;gs(i)?Xt.call(e,i,1):Ja(e,i)}}return e}function ja(e,t){return e+on(vn()*(t-e+1))}function Ma(e,t,n,r){for(var i=-1,a=A(an((t-e)/(n||1)),0),o=E(a);a--;)o[r?a:++i]=e,e+=n;return o}function Na(e,t){var n=``;if(!e||t<1||t>de)return n;do t%2&&(n+=e),t=on(t/2),t&&(e+=e);while(t);return n}function V(e,t){return Fs(ks(e,t,$),e+``)}function Pa(e){return xi(Ud(e))}function Fa(e,t){var n=Ud(e);return Rs(n,Mi(t,0,n.length))}function Ia(e,t,r,i){if(!J(e))return e;t=no(t,e);for(var a=-1,o=t.length,s=o-1,c=e;c!=null&&++a<o;){var l=Bs(t[a]),u=r;if(l===`__proto__`||l===`constructor`||l===`prototype`)return e;if(a!=s){var d=c[l];u=i?i(d,l,c):n,u===n&&(u=J(d)?d:gs(t[a+1])?[]:{})}Ti(c,l,u),c=c[l]}return e}var La=Kn?function(e,t){return Kn.set(e,t),e}:$,Ra=en?function(e,t){return en(e,`toString`,{configurable:!0,enumerable:!1,value:kf(t),writable:!0})}:$;function za(e){return Rs(Ud(e))}function Ba(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var a=E(i);++r<i;)a[r]=e[r+t];return a}function Va(e,t){var n;return Ri(e,function(e,r,i){return n=t(e,r,i),!n}),!!n}function Ha(e,t,n){var r=0,i=e==null?r:e.length;if(typeof t==`number`&&t===t&&i<=ge){for(;r<i;){var a=r+i>>>1,o=e[a];o!==null&&!Wu(o)&&(n?o<=t:o<t)?r=a+1:i=a}return i}return Ua(e,t,$,n)}function Ua(e,t,r,i){var a=0,o=e==null?0:e.length;if(o===0)return 0;t=r(t);for(var s=t!==t,c=t===null,l=Wu(t),u=t===n;a<o;){var d=on((a+o)/2),f=r(e[d]),p=f!==n,m=f===null,h=f===f,g=Wu(f);if(s)var _=i||h;else _=u?h&&(i||p):c?h&&p&&(i||!m):l?h&&p&&!m&&(i||!g):m||g?!1:i?f<=t:f<t;_?a=d+1:o=d}return N(o,he)}function Wa(e,t){for(var n=-1,r=e.length,i=0,a=[];++n<r;){var o=e[n],s=t?t(o):o;if(!n||!pu(s,c)){var c=s;a[i++]=o===0?0:o}}return a}function Ga(e){return typeof e==`number`?e:Wu(e)?pe:+e}function Ka(e){if(typeof e==`string`)return e;if(K(e))return I(e,Ka)+``;if(Wu(e))return Br?Br.call(e):``;var t=e+``;return t==`0`&&1/e==-C?`-0`:t}function qa(e,t,n){var r=-1,a=zn,o=e.length,s=!0,c=[],l=c;if(n)s=!1,a=Bn;else if(o>=i){var u=t?null:Vo(e);if(u)return wr(u);s=!1,a=ur,l=new di}else l=t?[]:c;outer:for(;++r<o;){var d=e[r],f=t?t(d):d;if(d=n||d!==0?d:0,s&&f===f){for(var p=l.length;p--;)if(l[p]===f)continue outer;t&&l.push(f),c.push(d)}else a(l,f,n)||(l!==c&&l.push(f),c.push(d))}return c}function Ja(e,t){t=no(t,e);var n=-1,r=t.length;if(!r)return!0;for(;++n<r;){var i=Bs(t[n]);if(i===`__proto__`&&!k.call(e,`__proto__`)||(i===`constructor`||i===`prototype`)&&n<r-1)return!1}var a=As(e,t);return a==null||delete a[Bs(mc(t))]}function Ya(e,t,n,r){return Ia(e,t,n(Yi(e,t)),r)}function Xa(e,t,n,r){for(var i=e.length,a=r?i:-1;(r?a--:++a<i)&&t(e[a],a,e););return n?Ba(e,r?0:a,r?a+1:i):Ba(e,r?a+1:0,r?i:a)}function Za(e,t){var n=e;return n instanceof R&&(n=n.value()),Hn(t,function(e,t){return t.func.apply(t.thisArg,Vn([e],t.args))},n)}function Qa(e,t,n){var r=e.length;if(r<2)return r?qa(e[0]):[];for(var i=-1,a=E(r);++i<r;)for(var o=e[i],s=-1;++s<r;)s!=i&&(a[i]=Li(a[i]||o,e[s],t,n));return qa(z(a,1),t,n)}function $a(e,t,r){for(var i=-1,a=e.length,o=t.length,s={};++i<a;){var c=i<o?t[i]:n;r(s,e[i],c)}return s}function eo(e){return q(e)?e:[]}function to(e){return typeof e==`function`?e:$}function no(e,t){return K(e)?e:_s(e,t)?[e]:zs(Z(e))}var ro=V;function io(e,t,r){var i=e.length;return r=r===n?i:r,!t&&r>=i?e:Ba(e,t,r)}var ao=tn||function(e){return P.clearTimeout(e)};function oo(e,t){if(t)return e.slice();var n=e.length,r=Kt?Kt(n):new e.constructor(n);return e.copy(r),r}function so(e){var t=new e.constructor(e.byteLength);return new Gt(t).set(new Gt(e)),t}function co(e,t){var n=t?so(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function lo(e){var t=new e.constructor(e.source,vt.exec(e));return t.lastIndex=e.lastIndex,t}function uo(e){return zr?D(zr.call(e)):{}}function fo(e,t){var n=t?so(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function po(e,t){if(e!==t){var r=e!==n,i=e===null,a=e===e,o=Wu(e),s=t!==n,c=t===null,l=t===t,u=Wu(t);if(!c&&!u&&!o&&e>t||o&&s&&l&&!c&&!u||i&&s&&l||!r&&l||!a)return 1;if(!i&&!o&&!u&&e<t||u&&r&&a&&!i&&!o||c&&r&&a||!s&&a||!l)return-1}return 0}function mo(e,t,n){for(var r=-1,i=e.criteria,a=t.criteria,o=i.length,s=n.length;++r<o;){var c=po(i[r],a[r]);if(c)return r>=s?c:c*(n[r]==`desc`?-1:1)}return e.index-t.index}function ho(e,t,n,r){for(var i=-1,a=e.length,o=n.length,s=-1,c=t.length,l=A(a-o,0),u=E(c+l),d=!r;++s<c;)u[s]=t[s];for(;++i<o;)(d||i<a)&&(u[n[i]]=e[i]);for(;l--;)u[s++]=e[i++];return u}function go(e,t,n,r){for(var i=-1,a=e.length,o=-1,s=n.length,c=-1,l=t.length,u=A(a-s,0),d=E(u+l),f=!r;++i<u;)d[i]=e[i];for(var p=i;++c<l;)d[p+c]=t[c];for(;++o<s;)(f||i<a)&&(d[p+n[o]]=e[i++]);return d}function H(e,t){var n=-1,r=e.length;for(t||=E(r);++n<r;)t[n]=e[n];return t}function _o(e,t,r,i){var a=!r;r||={};for(var o=-1,s=t.length;++o<s;){var c=t[o],l=i?i(r[c],e[c],c,r,e):n;l===n&&(l=e[c]),a?Ai(r,c,l):Ti(r,c,l)}return r}function vo(e,t){return _o(e,os(e),t)}function yo(e,t){return _o(e,ss(e),t)}function bo(e,t){return function(n,r){var i=K(n)?Pn:Di,a=t?t():{};return i(n,e,U(r,2),a)}}function xo(e){return V(function(t,r){var i=-1,a=r.length,o=a>1?r[a-1]:n,s=a>2?r[2]:n;for(o=e.length>3&&typeof o==`function`?(a--,o):n,s&&G(r[0],r[1],s)&&(o=a<3?n:o,a=1),t=D(t);++i<a;){var c=r[i];c&&e(t,c,i,o)}return t})}function So(e,t){return function(n,r){if(n==null)return n;if(!vu(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=D(n);(t?a--:++a<i)&&r(o[a],a,o)!==!1;);return n}}function Co(e){return function(t,n,r){for(var i=-1,a=D(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}function wo(e,t,n){var r=t&_,i=Do(e);function a(){return(this&&this!==P&&this instanceof a?i:e).apply(r?n:this,arguments)}return a}function To(e){return function(t){t=Z(t);var r=vr(t)?kr(t):n,i=r?r[0]:t.charAt(0),a=r?io(r,1).join(``):t.slice(1);return i[e]()+a}}function Eo(e){return function(t){return Hn(wf(Xd(t).replace(ln,``)),e,``)}}function Do(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var n=Vr(e.prototype),r=e.apply(n,t);return J(r)?r:n}}function Oo(e,t,r){var i=Do(e);function a(){for(var o=arguments.length,s=E(o),c=o,l=ts(a);c--;)s[c]=arguments[c];var u=o<3&&s[0]!==l&&s[o-1]!==l?[]:Cr(s,l);return o-=u.length,o<r?zo(e,t,jo,a.placeholder,n,s,u,n,n,r-o):Nn(this&&this!==P&&this instanceof a?i:e,this,s)}return a}function ko(e){return function(t,r,i){var a=D(t);if(!vu(t)){var o=U(r,3);t=Q(t),r=function(e){return o(a[e],e,a)}}var s=e(t,r,i);return s>-1?a[o?t[s]:s]:n}}function Ao(e){return Xo(function(t){var r=t.length,i=r,a=Ur.prototype.thru;for(e&&t.reverse();i--;){var s=t[i];if(typeof s!=`function`)throw new O(o);if(a&&!c&&es(s)==`wrapper`)var c=new Ur([],!0)}for(i=c?i:r;++i<r;){s=t[i];var l=es(s),u=l==`wrapper`?$o(s):n;c=u&&ys(u[0])&&u[1]==(te|b|S|ne)&&!u[4].length&&u[9]==1?c[es(u[0])].apply(c,u[3]):s.length==1&&ys(s)?c[l]():c.thru(s)}return function(){var e=arguments,n=e[0];if(c&&e.length==1&&K(n))return c.plant(n).value();for(var i=0,a=r?t[i].apply(this,e):n;++i<r;)a=t[i].call(this,a);return a}})}function jo(e,t,r,i,a,o,s,c,l,u){var d=t&te,f=t&_,p=t&v,m=t&(b|x),h=t&re,g=p?n:Do(e);function y(){for(var n=arguments.length,_=E(n),v=n;v--;)_[v]=arguments[v];if(m)var b=ts(y),x=pr(_,b);if(i&&(_=ho(_,i,a,m)),o&&(_=go(_,o,s,m)),n-=x,m&&n<u){var S=Cr(_,b);return zo(e,t,jo,y.placeholder,r,_,S,c,l,u-n)}var ee=f?r:this,te=p?ee[e]:e;return n=_.length,c?_=js(_,c):h&&n>1&&_.reverse(),d&&l<n&&(_.length=l),this&&this!==P&&this instanceof y&&(te=g||Do(te)),te.apply(ee,_)}return y}function Mo(e,t){return function(n,r){return na(n,e,t(r),{})}}function No(e,t){return function(r,i){var a;if(r===n&&i===n)return t;if(r!==n&&(a=r),i!==n){if(a===n)return i;typeof r==`string`||typeof i==`string`?(r=Ka(r),i=Ka(i)):(r=Ga(r),i=Ga(i)),a=e(r,i)}return a}}function Po(e){return Xo(function(t){return t=I(t,cr(U())),V(function(n){var r=this;return e(t,function(e){return Nn(e,r,n)})})})}function Fo(e,t){t=t===n?` `:Ka(t);var r=t.length;if(r<2)return r?Na(t,e):t;var i=Na(t,an(e/Or(t)));return vr(t)?io(kr(i),0,e).join(``):i.slice(0,e)}function Io(e,t,n,r){var i=t&_,a=Do(e);function o(){for(var t=-1,s=arguments.length,c=-1,l=r.length,u=E(l+s),d=this&&this!==P&&this instanceof o?a:e;++c<l;)u[c]=r[c];for(;s--;)u[c++]=arguments[++t];return Nn(d,i?n:this,u)}return o}function Lo(e){return function(t,r,i){return i&&typeof i!=`number`&&G(t,r,i)&&(r=i=n),t=Qu(t),r===n?(r=t,t=0):r=Qu(r),i=i===n?t<r?1:-1:Qu(i),Ma(t,r,i,e)}}function Ro(e){return function(t,n){return typeof t==`string`&&typeof n==`string`||(t=ed(t),n=ed(n)),e(t,n)}}function zo(e,t,r,i,a,o,s,c,l,u){var d=t&b,f=d?s:n,p=d?n:s,m=d?o:n,h=d?n:o;t|=d?S:ee,t&=~(d?ee:S),t&y||(t&=~(_|v));var g=[e,t,a,m,f,h,p,c,l,u],x=r.apply(n,g);return ys(e)&&Ns(x,g),x.placeholder=i,Is(x,e,t)}function Bo(e){var t=kt[e];return function(e,n){if(e=ed(e),n=n==null?0:N(X(n),292),n&&dn(e)){var r=(Z(e)+`e`).split(`e`);return r=(Z(t(r[0]+`e`+(+r[1]+n)))+`e`).split(`e`),+(r[0]+`e`+(+r[1]-n))}return t(e)}}var Vo=En&&1/wr(new En([,-0]))[1]==C?function(e){return new En(e)}:Bf;function Ho(e){return function(t){var n=W(t);return n==w?xr(t):n==T?Tr(t):or(t,e(t))}}function Uo(e,t,r,i,a,s,c,l){var u=t&v;if(!u&&typeof e!=`function`)throw new O(o);var d=i?i.length:0;if(d||(t&=~(S|ee),i=a=n),c=c===n?c:A(X(c),0),l=l===n?l:X(l),d-=a?a.length:0,t&ee){var f=i,p=a;i=a=n}var m=u?n:$o(e),h=[e,t,r,i,a,f,p,s,c,l];if(m&&Es(h,m),e=h[0],t=h[1],r=h[2],i=h[3],a=h[4],l=h[9]=h[9]===n?u?0:e.length:A(h[9]-d,0),!l&&t&(b|x)&&(t&=~(b|x)),!t||t==_)var g=wo(e,t,r);else g=t==b||t==x?Oo(e,t,l):(t==S||t==(_|S))&&!a.length?Io(e,t,r,i):jo.apply(n,h);return Is((m?La:Ns)(g,h),e,t)}function Wo(e,t,r,i){return e===n||pu(e,Pt[r])&&!k.call(i,r)?t:e}function Go(e,t,r,i,a,o){return J(e)&&J(t)&&(o.set(t,e),Sa(e,t,n,Go,o),o.delete(t)),e}function Ko(e){return zu(e)?n:e}function qo(e,t,r,i,a,o){var s=r&h,c=e.length,l=t.length;if(c!=l&&!(s&&l>c))return!1;var u=o.get(e),d=o.get(t);if(u&&d)return u==t&&d==e;var f=-1,p=!0,m=r&g?new di:n;for(o.set(e,t),o.set(t,e);++f<c;){var _=e[f],v=t[f];if(i)var y=s?i(v,_,f,t,e,o):i(_,v,f,e,t,o);if(y!==n){if(y)continue;p=!1;break}if(m){if(!Wn(t,function(e,t){if(!ur(m,t)&&(_===e||a(_,e,r,i,o)))return m.push(t)})){p=!1;break}}else if(!(_===v||a(_,v,r,i,o))){p=!1;break}}return o.delete(e),o.delete(t),p}function Jo(e,t,n,r,i,a,o){switch(n){case ze:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Re:return!(e.byteLength!=t.byteLength||!a(new Gt(e),new Gt(t)));case xe:case Se:case De:return pu(+e,+t);case we:return e.name==t.name&&e.message==t.message;case Me:case Ne:return e==t+``;case w:var s=xr;case T:var c=r&h;if(s||=wr,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=g,o.set(e,t);var u=qo(s(e),s(t),r,i,a,o);return o.delete(e),u;case Pe:if(zr)return zr.call(e)==zr.call(t)}return!1}function Yo(e,t,r,i,a,o){var s=r&h,c=Zo(e),l=c.length;if(l!=Zo(t).length&&!s)return!1;for(var u=l;u--;){var d=c[u];if(!(s?d in t:k.call(t,d)))return!1}var f=o.get(e),p=o.get(t);if(f&&p)return f==t&&p==e;var m=!0;o.set(e,t),o.set(t,e);for(var g=s;++u<l;){d=c[u];var _=e[d],v=t[d];if(i)var y=s?i(v,_,d,t,e,o):i(_,v,d,e,t,o);if(!(y===n?_===v||a(_,v,r,i,o):y)){m=!1;break}g||=d==`constructor`}if(m&&!g){var b=e.constructor,x=t.constructor;b!=x&&`constructor`in e&&`constructor`in t&&!(typeof b==`function`&&b instanceof b&&typeof x==`function`&&x instanceof x)&&(m=!1)}return o.delete(e),o.delete(t),m}function Xo(e){return Fs(ks(e,n,rc),e+``)}function Zo(e){return Xi(e,Q,os)}function Qo(e){return Xi(e,Td,ss)}var $o=Kn?function(e){return Kn.get(e)}:Bf;function es(e){for(var t=e.name+``,n=tr[t],r=k.call(tr,t)?n.length:0;r--;){var i=n[r],a=i.func;if(a==null||a==e)return i.name}return t}function ts(e){return(k.call(L,`placeholder`)?L:e).placeholder}function U(){var e=L.iteratee||Nf;return e=e===Nf?ha:e,arguments.length?e(arguments[0],arguments[1]):e}function ns(e,t){var n=e.__data__;return vs(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function rs(e){for(var t=Q(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,Cs(i)]}return t}function is(e,t){var r=_r(e,t);return da(r)?r:n}function as(e){var t=k.call(e,$t),r=e[$t];try{e[$t]=n;var i=!0}catch{}var a=zt.call(e);return i&&(t?e[$t]=r:delete e[$t]),a}var os=sn?function(e){return e==null?[]:(e=D(e),Rn(sn(e),function(t){return Yt.call(e,t)}))}:Yf,ss=sn?function(e){for(var t=[];e;)Vn(t,os(e)),e=qt(e);return t}:Yf,W=B;(Sn&&W(new Sn(new ArrayBuffer(1)))!=ze||Cn&&W(new Cn)!=w||wn&&W(wn.resolve())!=Ae||En&&W(new En)!=T||F&&W(new F)!=Ie)&&(W=function(e){var t=B(e),r=t==ke?e.constructor:n,i=r?Vs(r):``;if(i)switch(i){case Er:return ze;case Mr:return w;case Nr:return Ae;case Ir:return T;case Lr:return Ie}return t});function cs(e,t,n){for(var r=-1,i=n.length;++r<i;){var a=n[r],o=a.size;switch(a.type){case`drop`:e+=o;break;case`dropRight`:t-=o;break;case`take`:t=N(t,e+o);break;case`takeRight`:e=A(e,t-o);break}}return{start:e,end:t}}function ls(e){var t=e.match(ft);return t?t[1].split(pt):[]}function us(e,t,n){t=no(t,e);for(var r=-1,i=t.length,a=!1;++r<i;){var o=Bs(t[r]);if(!(a=e!=null&&n(e,o)))break;e=e[o]}return a||++r!=i?a:(i=e==null?0:e.length,!!i&&Au(i)&&gs(o,i)&&(K(e)||gu(e)))}function ds(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]==`string`&&k.call(e,`index`)&&(n.index=e.index,n.input=e.input),n}function fs(e){return typeof e.constructor==`function`&&!Ss(e)?Vr(qt(e)):{}}function ps(e,t,n){var r=e.constructor;switch(t){case Re:return so(e);case xe:case Se:return new r(+e);case ze:return co(e,n);case Be:case Ve:case He:case Ue:case We:case Ge:case Ke:case qe:case Je:return fo(e,n);case w:return new r;case De:case Ne:return new r(e);case Me:return lo(e);case T:return new r;case Pe:return uo(e)}}function ms(e,t){var n=t.length;if(!n)return e;var r=n-1;return t[r]=(n>1?`& `:``)+t[r],t=t.join(n>2?`, `:` `),e.replace(dt,`{
2
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./get-front-component-build-plugins-Dqpyup2W.js"),t=require("./login-BOrzi4Z0.js"),n=require("./isDefined-Dtu5EYqP-Dp026Ry1.js");let r=require("path");r=e.i(r);let i=require("node:fs/promises"),a=require("uuid"),o=require("react");o=e.i(o);let s=require("node:path");s=e.i(s);let c=require("crypto");c=e.i(c);let l=require("node:child_process"),u=require("chalk");u=e.i(u);let d=require("inquirer");d=e.i(d);let f=require("chokidar");f=e.i(f);let p=require("react/jsx-runtime"),m=require("commander"),h=require("util");var g=e=>e&&!e?.startsWith(`/`)?(0,r.join)(t.xt,e):e,_=async e=>{let n=(0,r.join)(e,`package.json`);if(await t.ot(n))try{let e=await(0,i.readFile)(n,`utf-8`),t=JSON.parse(e);return t.dependencies?.[`twenty-sdk`]??t.devDependencies?.[`twenty-sdk`]??void 0}catch{return}},v=e=>{let t=e.match(/(\d+)\./);if(t)return parseInt(t[1],10);let n=e.match(/^[~^>=<]*(\d+)$/);return n?parseInt(n[1],10):null},y=async e=>{let n=t.P.version,r=await _(e);if(!n||!r)return;let i=v(n),a=v(r);i===null||a===null||i!==a&&(console.warn(u.default.yellow(`⚠ Version mismatch: your app requires twenty-sdk@${a}.x but the CLI running is v${n}. Major version mismatches may cause unexpected behavior.\n Update with: npm install -g twenty-sdk@${a}`)),console.warn(``))},b=class{async execute(e){e.private?await this.executePrivate(e):await this.executeNpm(e)}async executeNpm(e){let n=e.appPath??t.xt;await y(n),console.log(u.default.blue(`Publishing to npm...`)),console.log(u.default.gray(`App path: ${n}\n`));let r=await t.F({appPath:n,npmTag:e.tag,onProgress:e=>console.log(u.default.gray(e))});r.success||(console.error(u.default.red(r.error.message)),process.exit(1)),console.log(u.default.green(`✓ Published to npm successfully`))}async executePrivate(e){let n=e.appPath??t.xt;await y(n);let i=e.remote??t.V.getActiveRemote();console.log(u.default.blue(`Deploying application on ${i}...`)),console.log(u.default.gray(`App path: ${n}\n`));let a=e=>console.log(u.default.gray(e)),o=await t.U({appPath:n,tarball:!0,onProgress:a});o.success||(console.error(u.default.red(o.error.message)),process.exit(1));let s=await t.I({tarballPath:o.data.tarballPath,remote:e.remote,onProgress:a});s.success||(console.error(u.default.red(s.error.message)),process.exit(1));let c=await t.st(r.default.join(n,`package.json`)).catch(()=>void 0),l=c?.name??s.data.name,d=c?.version??`unknown`;console.log(u.default.green(`\n✓ Published ${l} v${d} to ${i}\n`)),console.log(" To install deployed application: `yarn twenty app:install`")}},x=class{async execute(e){let n=e.appPath??t.xt;await y(n),await t._();let r=e.remote??t.V.getActiveRemote();console.log(u.default.blue(`Installing application on ${r}...`)),console.log(u.default.gray(`App path: ${n}\n`));let i=await t.j({appPath:n,remote:e.remote});i.success||(console.error(u.default.red(i.error.message)),process.exit(1)),console.log(u.default.green(`✓ Application installed`))}},S=class{async execute({appPath:e=t.xt,askForConfirmation:n}){let r=t.V.getActiveRemote();console.log(u.default.blue(`🚀 Uninstall Twenty Application on ${r}`)),console.log(u.default.gray(`📁 App Path: ${e}\n`)),n&&!await this.confirmationPrompt()&&(console.error(u.default.red(`⛔️ Aborting uninstall`)),process.exit(1));let i=await t.g({appPath:e});return i.success?(console.log(u.default.green(`✅ Application uninstalled successfully`)),{success:!0,data:void 0}):(console.error(u.default.red(`❌ Uninstall failed:`),i.error.message),{success:!1,error:i.error.message})}async confirmationPrompt(){let{confirmation:e}=await d.default.prompt([{type:`confirm`,name:`confirmation`,message:`Are you sure you want to uninstall this application?`,default:!1}]);return e}},ee=e=>{let t=new b,n=new x,r=new S;e.command(`app:publish [appPath]`).description(`Build and publish to npm (default) or server registry`).option(`--private`,`Push to a Twenty server's registry instead of npm`).option(`-r, --remote <name>`,`Publish to a specific remote (with --private)`).option(`--tag <tag>`,`npm dist-tag (e.g. beta, next)`).action(async(e,n)=>{await t.execute({appPath:g(e),private:n.private,remote:n.remote,tag:n.tag})}),e.command(`app:install [appPath]`).description(`Install a deployed app on the server`).option(`-r, --remote <name>`,`Install on a specific remote`).action(async(e,t)=>{await n.execute({appPath:g(e),remote:t.remote})}),e.command(`app:uninstall [appPath]`).description(`Uninstall app from server`).option(`-y, --yes`,`Skip confirmation prompt`).action(async(e,t)=>{try{let n=await r.execute({appPath:g(e),askForConfirmation:!t?.yes});process.exit(+!n.success)}catch{process.exit(1)}})},te=e.n(((e,t)=>{(function(){var n,r=`4.18.1`,i=200,a=`Unsupported core-js use. Try https://npms.io/search?q=ponyfill.`,o=`Expected a function`,s="Invalid `variable` option passed into `_.template`",c="Invalid `imports` option passed into `_.template`",l=`__lodash_hash_undefined__`,u=500,d=`__lodash_placeholder__`,f=1,p=2,m=4,h=1,g=2,_=1,v=2,y=4,b=8,x=16,S=32,ee=64,te=128,ne=256,re=512,ie=30,ae=`...`,oe=800,se=16,ce=1,le=2,ue=3,C=1/0,de=9007199254740991,fe=17976931348623157e292,pe=NaN,me=4294967295,he=me-1,ge=me>>>1,_e=[[`ary`,te],[`bind`,_],[`bindKey`,v],[`curry`,b],[`curryRight`,x],[`flip`,re],[`partial`,S],[`partialRight`,ee],[`rearg`,ne]],ve=`[object Arguments]`,ye=`[object Array]`,be=`[object AsyncFunction]`,xe=`[object Boolean]`,Se=`[object Date]`,Ce=`[object DOMException]`,we=`[object Error]`,Te=`[object Function]`,Ee=`[object GeneratorFunction]`,w=`[object Map]`,De=`[object Number]`,Oe=`[object Null]`,ke=`[object Object]`,Ae=`[object Promise]`,je=`[object Proxy]`,Me=`[object RegExp]`,T=`[object Set]`,Ne=`[object String]`,Pe=`[object Symbol]`,Fe=`[object Undefined]`,Ie=`[object WeakMap]`,Le=`[object WeakSet]`,Re=`[object ArrayBuffer]`,ze=`[object DataView]`,Be=`[object Float32Array]`,Ve=`[object Float64Array]`,He=`[object Int8Array]`,Ue=`[object Int16Array]`,We=`[object Int32Array]`,Ge=`[object Uint8Array]`,Ke=`[object Uint8ClampedArray]`,qe=`[object Uint16Array]`,Je=`[object Uint32Array]`,Ye=/\b__p \+= '';/g,Xe=/\b(__p \+=) '' \+/g,Ze=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Qe=/&(?:amp|lt|gt|quot|#39);/g,$e=/[&<>"']/g,et=RegExp(Qe.source),tt=RegExp($e.source),nt=/<%-([\s\S]+?)%>/g,rt=/<%([\s\S]+?)%>/g,it=/<%=([\s\S]+?)%>/g,at=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ot=/^\w*$/,st=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ct=/[\\^$.*+?()[\]{}|]/g,lt=RegExp(ct.source),ut=/^\s+/,E=/\s/,dt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ft=/\{\n\/\* \[wrapped with (.+)\] \*/,pt=/,? & /,mt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ht=/[()=,{}\[\]\/\s]/,gt=/\\(\\)?/g,_t=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,vt=/\w*$/,yt=/^[-+]0x[0-9a-f]+$/i,bt=/^0b[01]+$/i,xt=/^\[object .+?Constructor\]$/,St=/^0o[0-7]+$/i,Ct=/^(?:0|[1-9]\d*)$/,wt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Tt=/($^)/,Et=/['\n\r\u2028\u2029\\]/g,Dt=`\\ud800-\\udfff`,Ot=`\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff`,kt=`\\u2700-\\u27bf`,D=`a-z\\xdf-\\xf6\\xf8-\\xff`,At=`\\xac\\xb1\\xd7\\xf7`,jt=`\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf`,Mt=`\\u2000-\\u206f`,Nt=` \\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`,Pt=`A-Z\\xc0-\\xd6\\xd8-\\xde`,Ft=`\\ufe0e\\ufe0f`,It=At+jt+Mt+Nt,Lt=`['’]`,O=`[`+Dt+`]`,Rt=`[`+It+`]`,zt=`[`+Ot+`]`,Bt=`\\d+`,Vt=`[`+kt+`]`,Ht=`[`+D+`]`,Ut=`[^`+Dt+It+Bt+kt+D+Pt+`]`,Wt=`\\ud83c[\\udffb-\\udfff]`,Gt=`(?:`+zt+`|`+Wt+`)`,Kt=`[^`+Dt+`]`,qt=`(?:\\ud83c[\\udde6-\\uddff]){2}`,Jt=`[\\ud800-\\udbff][\\udc00-\\udfff]`,Yt=`[`+Pt+`]`,Xt=`\\u200d`,Zt=`(?:`+Ht+`|`+Ut+`)`,Qt=`(?:`+Yt+`|`+Ut+`)`,$t=`(?:`+Lt+`(?:d|ll|m|re|s|t|ve))?`,en=`(?:`+Lt+`(?:D|LL|M|RE|S|T|VE))?`,tn=Gt+`?`,nn=`[`+Ft+`]?`,rn=`(?:`+Xt+`(?:`+[Kt,qt,Jt].join(`|`)+`)`+nn+tn+`)*`,an=`\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])`,on=`\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])`,sn=nn+tn+rn,cn=`(?:`+[Vt,qt,Jt].join(`|`)+`)`+sn,ln=`(?:`+[Kt+zt+`?`,zt,qt,Jt,O].join(`|`)+`)`,un=RegExp(Lt,`g`),dn=RegExp(zt,`g`),fn=RegExp(Wt+`(?=`+Wt+`)|`+ln+sn,`g`),pn=RegExp([Yt+`?`+Ht+`+`+$t+`(?=`+[Rt,Yt,`$`].join(`|`)+`)`,Qt+`+`+en+`(?=`+[Rt,Yt+Zt,`$`].join(`|`)+`)`,Yt+`?`+Zt+`+`+$t,Yt+`+`+en,on,an,Bt,cn].join(`|`),`g`),mn=RegExp(`[`+Xt+Dt+Ot+Ft+`]`),k=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,hn=`Array.Buffer.DataView.Date.Error.Float32Array.Float64Array.Function.Int8Array.Int16Array.Int32Array.Map.Math.Object.Promise.RegExp.Set.String.Symbol.TypeError.Uint8Array.Uint8ClampedArray.Uint16Array.Uint32Array.WeakMap._.clearTimeout.isFinite.parseInt.setTimeout`.split(`.`),gn=-1,A={};A[Be]=A[Ve]=A[He]=A[Ue]=A[We]=A[Ge]=A[Ke]=A[qe]=A[Je]=!0,A[ve]=A[ye]=A[Re]=A[xe]=A[ze]=A[Se]=A[we]=A[Te]=A[w]=A[De]=A[ke]=A[Me]=A[T]=A[Ne]=A[Ie]=!1;var j={};j[ve]=j[ye]=j[Re]=j[ze]=j[xe]=j[Se]=j[Be]=j[Ve]=j[He]=j[Ue]=j[We]=j[w]=j[De]=j[ke]=j[Me]=j[T]=j[Ne]=j[Pe]=j[Ge]=j[Ke]=j[qe]=j[Je]=!0,j[we]=j[Te]=j[Ie]=!1;var M={À:`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`},_n={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},vn={"&amp;":`&`,"&lt;":`<`,"&gt;":`>`,"&quot;":`"`,"&#39;":`'`},yn={"\\":`\\`,"'":`'`,"\n":`n`,"\r":`r`,"\u2028":`u2028`,"\u2029":`u2029`},bn=parseFloat,xn=parseInt,Sn=typeof global==`object`&&global&&global.Object===Object&&global,Cn=typeof self==`object`&&self&&self.Object===Object&&self,N=Sn||Cn||Function(`return this`)(),wn=typeof e==`object`&&e&&!e.nodeType&&e,Tn=wn&&typeof t==`object`&&t&&!t.nodeType&&t,En=Tn&&Tn.exports===wn,Dn=En&&Sn.process,P=function(){try{return Tn&&Tn.require&&Tn.require(`util`).types||Dn&&Dn.binding&&Dn.binding(`util`)}catch{}}(),On=P&&P.isArrayBuffer,kn=P&&P.isDate,An=P&&P.isMap,jn=P&&P.isRegExp,Mn=P&&P.isSet,Nn=P&&P.isTypedArray;function Pn(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function Fn(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}function In(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}function Ln(e,t){for(var n=e==null?0:e.length;n--&&t(e[n],n,e)!==!1;);return e}function Rn(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(!t(e[n],n,e))return!1;return!0}function zn(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function Bn(e,t){return!!(e!=null&&e.length)&&Zn(e,t,0)>-1}function Vn(e,t,n){for(var r=-1,i=e==null?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}function F(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}function Hn(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function Un(e,t,n,r){var i=-1,a=e==null?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}function Wn(e,t,n,r){var i=e==null?0:e.length;for(r&&i&&(n=e[--i]);i--;)n=t(n,e[i],i,e);return n}function Gn(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}var Kn=tr(`length`);function qn(e){return e.split(``)}function Jn(e){return e.match(mt)||[]}function Yn(e,t,n){var r;return n(e,function(e,n,i){if(t(e,n,i))return r=n,!1}),r}function Xn(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1}function Zn(e,t,n){return t===t?Dr(e,t,n):Xn(e,$n,n)}function Qn(e,t,n,r){for(var i=n-1,a=e.length;++i<a;)if(r(e[i],t))return i;return-1}function $n(e){return e!==e}function er(e,t){var n=e==null?0:e.length;return n?ar(e,t)/n:pe}function tr(e){return function(t){return t==null?n:t[e]}}function nr(e){return function(t){return e==null?n:e[t]}}function rr(e,t,n,r,i){return i(e,function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)}),n}function ir(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}function ar(e,t){for(var r,i=-1,a=e.length;++i<a;){var o=t(e[i]);o!==n&&(r=r===n?o:r+o)}return r}function or(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function sr(e,t){return F(t,function(t){return[t,e[t]]})}function cr(e){return e&&e.slice(0,jr(e)+1).replace(ut,``)}function lr(e){return function(t){return e(t)}}function ur(e,t){return F(t,function(t){return e[t]})}function dr(e,t){return e.has(t)}function fr(e,t){for(var n=-1,r=e.length;++n<r&&Zn(t,e[n],0)>-1;);return n}function pr(e,t){for(var n=e.length;n--&&Zn(t,e[n],0)>-1;);return n}function mr(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}var hr=nr(M),gr=nr(_n);function _r(e){return`\\`+yn[e]}function vr(e,t){return e==null?n:e[t]}function yr(e){return mn.test(e)}function br(e){return k.test(e)}function xr(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}function Sr(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function Cr(e,t){return function(n){return e(t(n))}}function wr(e,t){for(var n=-1,r=e.length,i=0,a=[];++n<r;){var o=e[n];(o===t||o===d)&&(e[n]=d,a[i++]=n)}return a}function Tr(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}function Er(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=[e,e]}),n}function Dr(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}function Or(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}function kr(e){return yr(e)?Nr(e):Kn(e)}function Ar(e){return yr(e)?Pr(e):qn(e)}function jr(e){for(var t=e.length;t--&&E.test(e.charAt(t)););return t}var Mr=nr(vn);function Nr(e){for(var t=fn.lastIndex=0;fn.test(e);)++t;return t}function Pr(e){return e.match(fn)||[]}function Fr(e){return e.match(pn)||[]}var Ir=(function e(t){t=t==null?N:Ir.defaults(N.Object(),t,Ir.pick(N,hn));var E=t.Array,mt=t.Date,Dt=t.Error,Ot=t.Function,kt=t.Math,D=t.Object,At=t.RegExp,jt=t.String,Mt=t.TypeError,Nt=E.prototype,Pt=Ot.prototype,Ft=D.prototype,It=t[`__core-js_shared__`],Lt=Pt.toString,O=Ft.hasOwnProperty,Rt=0,zt=function(){var e=/[^.]+$/.exec(It&&It.keys&&It.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}(),Bt=Ft.toString,Vt=Lt.call(D),Ht=N._,Ut=At(`^`+Lt.call(O).replace(ct,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`),Wt=En?t.Buffer:n,Gt=t.Symbol,Kt=t.Uint8Array,qt=Wt?Wt.allocUnsafe:n,Jt=Cr(D.getPrototypeOf,D),Yt=D.create,Xt=Ft.propertyIsEnumerable,Zt=Nt.splice,Qt=Gt?Gt.isConcatSpreadable:n,$t=Gt?Gt.iterator:n,en=Gt?Gt.toStringTag:n,tn=function(){try{var e=as(D,`defineProperty`);return e({},``,{}),e}catch{}}(),nn=t.clearTimeout!==N.clearTimeout&&t.clearTimeout,rn=mt&&mt.now!==N.Date.now&&mt.now,an=t.setTimeout!==N.setTimeout&&t.setTimeout,on=kt.ceil,sn=kt.floor,cn=D.getOwnPropertySymbols,ln=Wt?Wt.isBuffer:n,fn=t.isFinite,pn=Nt.join,mn=Cr(D.keys,D),k=kt.max,M=kt.min,_n=mt.now,vn=t.parseInt,yn=kt.random,Sn=Nt.reverse,Cn=as(t,`DataView`),wn=as(t,`Map`),Tn=as(t,`Promise`),Dn=as(t,`Set`),P=as(t,`WeakMap`),Kn=as(D,`create`),qn=P&&new P,nr={},Dr=Hs(Cn),Nr=Hs(wn),Pr=Hs(Tn),Lr=Hs(Dn),Rr=Hs(P),zr=Gt?Gt.prototype:n,Br=zr?zr.valueOf:n,Vr=zr?zr.toString:n;function I(e){if(Y(e)&&!G(e)&&!(e instanceof L)){if(e instanceof Wr)return e;if(O.call(e,`__wrapped__`))return Ws(e)}return new Wr(e)}var Hr=function(){function e(){}return function(t){if(!J(t))return{};if(Yt)return Yt(t);e.prototype=t;var r=new e;return e.prototype=n,r}}();function Ur(){}function Wr(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=n}I.templateSettings={escape:nt,evaluate:rt,interpolate:it,variable:``,imports:{_:I}},I.prototype=Ur.prototype,I.prototype.constructor=I,Wr.prototype=Hr(Ur.prototype),Wr.prototype.constructor=Wr;function L(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=me,this.__views__=[]}function Gr(){var e=new L(this.__wrapped__);return e.__actions__=V(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=V(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=V(this.__views__),e}function Kr(){if(this.__filtered__){var e=new L(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function qr(){var e=this.__wrapped__.value(),t=this.__dir__,n=G(e),r=t<0,i=n?e.length:0,a=ls(0,i,this.__views__),o=a.start,s=a.end,c=s-o,l=r?s:o-1,u=this.__iteratees__,d=u.length,f=0,p=M(c,this.__takeCount__);if(!n||!r&&i==c&&p==c)return Qa(e,this.__actions__);var m=[];outer:for(;c--&&f<p;){l+=t;for(var h=-1,g=e[l];++h<d;){var _=u[h],v=_.iteratee,y=_.type,b=v(g);if(y==le)g=b;else if(!b){if(y==ce)continue outer;break outer}}m[f++]=g}return m}L.prototype=Hr(Ur.prototype),L.prototype.constructor=L;function Jr(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Yr(){this.__data__=Kn?Kn(null):{},this.size=0}function Xr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}function Zr(e){var t=this.__data__;if(Kn){var r=t[e];return r===l?n:r}return O.call(t,e)?t[e]:n}function Qr(e){var t=this.__data__;return Kn?t[e]!==n:O.call(t,e)}function $r(e,t){var r=this.__data__;return this.size+=+!this.has(e),r[e]=Kn&&t===n?l:t,this}Jr.prototype.clear=Yr,Jr.prototype.delete=Xr,Jr.prototype.get=Zr,Jr.prototype.has=Qr,Jr.prototype.set=$r;function ei(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ti(){this.__data__=[],this.size=0}function ni(e){var t=this.__data__,n=Di(t,e);return n<0?!1:(n==t.length-1?t.pop():Zt.call(t,n,1),--this.size,!0)}function ri(e){var t=this.__data__,r=Di(t,e);return r<0?n:t[r][1]}function ii(e){return Di(this.__data__,e)>-1}function ai(e,t){var n=this.__data__,r=Di(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}ei.prototype.clear=ti,ei.prototype.delete=ni,ei.prototype.get=ri,ei.prototype.has=ii,ei.prototype.set=ai;function oi(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function si(){this.size=0,this.__data__={hash:new Jr,map:new(wn||ei),string:new Jr}}function ci(e){var t=rs(this,e).delete(e);return this.size-=+!!t,t}function li(e){return rs(this,e).get(e)}function ui(e){return rs(this,e).has(e)}function di(e,t){var n=rs(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}oi.prototype.clear=si,oi.prototype.delete=ci,oi.prototype.get=li,oi.prototype.has=ui,oi.prototype.set=di;function fi(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new oi;++t<n;)this.add(e[t])}function pi(e){return this.__data__.set(e,l),this}function mi(e){return this.__data__.has(e)}fi.prototype.add=fi.prototype.push=pi,fi.prototype.has=mi;function hi(e){var t=this.__data__=new ei(e);this.size=t.size}function gi(){this.__data__=new ei,this.size=0}function _i(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function vi(e){return this.__data__.get(e)}function yi(e){return this.__data__.has(e)}function bi(e,t){var n=this.__data__;if(n instanceof ei){var r=n.__data__;if(!wn||r.length<i-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new oi(r)}return n.set(e,t),this.size=n.size,this}hi.prototype.clear=gi,hi.prototype.delete=_i,hi.prototype.get=vi,hi.prototype.has=yi,hi.prototype.set=bi;function xi(e,t){var n=G(e),r=!n&&_u(e),i=!n&&!r&&bu(e),a=!n&&!r&&!i&&Gu(e),o=n||r||i||a,s=o?or(e.length,jt):[],c=s.length;for(var l in e)(t||O.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||_s(l,c)))&&s.push(l);return s}function Si(e){var t=e.length;return t?e[Ma(0,t-1)]:n}function Ci(e,t){return zs(V(e),Ni(t,0,e.length))}function wi(e){return zs(V(e))}function Ti(e,t,r){(r!==n&&!mu(e[t],r)||r===n&&!(t in e))&&ji(e,t,r)}function Ei(e,t,r){var i=e[t];(!(O.call(e,t)&&mu(i,r))||r===n&&!(t in e))&&ji(e,t,r)}function Di(e,t){for(var n=e.length;n--;)if(mu(e[n][0],t))return n;return-1}function Oi(e,t,n,r){return zi(e,function(e,i,a){t(r,e,n(e),a)}),r}function ki(e,t){return e&&vo(t,Q(t),e)}function Ai(e,t){return e&&vo(t,Td(t),e)}function ji(e,t,n){t==`__proto__`&&tn?tn(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function Mi(e,t){for(var r=-1,i=t.length,a=E(i),o=e==null;++r<i;)a[r]=o?n:yd(e,t[r]);return a}function Ni(e,t,r){return e===e&&(r!==n&&(e=e<=r?e:r),t!==n&&(e=e>=t?e:t)),e}function Pi(e,t,r,i,a,o){var s,c=t&f,l=t&p,u=t&m;if(r&&(s=a?r(e,i,a,o):r(e)),s!==n)return s;if(!J(e))return e;var d=G(e);if(d){if(s=fs(e),!c)return V(e,s)}else{var h=U(e),g=h==Te||h==Ee;if(bu(e))return so(e,c);if(h==ke||h==ve||g&&!a){if(s=l||g?{}:ps(e),!c)return l?bo(e,Ai(s,e)):yo(e,ki(s,e))}else{if(!j[h])return a?e:{};s=ms(e,h,c)}}o||=new hi;var _=o.get(e);if(_)return _;o.set(e,s),Hu(e)?e.forEach(function(n){s.add(Pi(n,t,r,n,e,o))}):ju(e)&&e.forEach(function(n,i){s.set(i,Pi(n,t,r,i,e,o))});var v=d?n:(u?l?$o:Qo:l?Td:Q)(e);return In(v||e,function(n,i){v&&(i=n,n=e[i]),Ei(s,i,Pi(n,t,r,i,e,o))}),s}function Fi(e){var t=Q(e);return function(n){return Ii(n,e,t)}}function Ii(e,t,r){var i=r.length;if(e==null)return!i;for(e=D(e);i--;){var a=r[i],o=t[a],s=e[a];if(s===n&&!(a in e)||!o(s))return!1}return!0}function Li(e,t,r){if(typeof e!=`function`)throw new Mt(o);return Fs(function(){e.apply(n,r)},t)}function Ri(e,t,n,r){var a=-1,o=Bn,s=!0,c=e.length,l=[],u=t.length;if(!c)return l;n&&(t=F(t,lr(n))),r?(o=Vn,s=!1):t.length>=i&&(o=dr,s=!1,t=new fi(t));outer:for(;++a<c;){var d=e[a],f=n==null?d:n(d);if(d=r||d!==0?d:0,s&&f===f){for(var p=u;p--;)if(t[p]===f)continue outer;l.push(d)}else o(t,f,r)||l.push(d)}return l}var zi=Co(qi),Bi=Co(Ji,!0);function Vi(e,t){var n=!0;return zi(e,function(e,r,i){return n=!!t(e,r,i),n}),n}function Hi(e,t,r){for(var i=-1,a=e.length;++i<a;){var o=e[i],s=t(o);if(s!=null&&(c===n?s===s&&!Wu(s):r(s,c)))var c=s,l=o}return l}function Ui(e,t,r,i){var a=e.length;for(r=X(r),r<0&&(r=-r>a?0:a+r),i=i===n||i>a?a:X(i),i<0&&(i+=a),i=r>i?0:$u(i);r<i;)e[r++]=t;return e}function Wi(e,t){var n=[];return zi(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function R(e,t,n,r,i){var a=-1,o=e.length;for(n||=gs,i||=[];++a<o;){var s=e[a];t>0&&n(s)?t>1?R(s,t-1,n,r,i):Hn(i,s):r||(i[i.length]=s)}return i}var Gi=wo(),Ki=wo(!0);function qi(e,t){return e&&Gi(e,t,Q)}function Ji(e,t){return e&&Ki(e,t,Q)}function Yi(e,t){return zn(t,function(t){return Ou(e[t])})}function Xi(e,t){t=ro(t,e);for(var r=0,i=t.length;e!=null&&r<i;)e=e[Vs(t[r++])];return r&&r==i?e:n}function Zi(e,t,n){var r=t(e);return G(e)?r:Hn(r,n(e))}function z(e){return e==null?e===n?Fe:Oe:en&&en in D(e)?os(e):ks(e)}function Qi(e,t){return e>t}function $i(e,t){return e!=null&&O.call(e,t)}function ea(e,t){return e!=null&&t in D(e)}function ta(e,t,n){return e>=M(t,n)&&e<k(t,n)}function na(e,t,r){for(var i=r?Vn:Bn,a=e[0].length,o=e.length,s=o,c=E(o),l=1/0,u=[];s--;){var d=e[s];s&&t&&(d=F(d,lr(t))),l=M(d.length,l),c[s]=!r&&(t||a>=120&&d.length>=120)?new fi(s&&d):n}d=e[0];var f=-1,p=c[0];outer:for(;++f<a&&u.length<l;){var m=d[f],h=t?t(m):m;if(m=r||m!==0?m:0,!(p?dr(p,h):i(u,h,r))){for(s=o;--s;){var g=c[s];if(!(g?dr(g,h):i(e[s],h,r)))continue outer}p&&p.push(h),u.push(m)}}return u}function ra(e,t,n,r){return qi(e,function(e,i,a){t(r,n(e),i,a)}),r}function ia(e,t,r){t=ro(t,e),e=js(e,t);var i=e==null?e:e[Vs(hc(t))];return i==null?n:Pn(i,e,r)}function aa(e){return Y(e)&&z(e)==ve}function oa(e){return Y(e)&&z(e)==Re}function sa(e){return Y(e)&&z(e)==Se}function ca(e,t,n,r,i){return e===t?!0:e==null||t==null||!Y(e)&&!Y(t)?e!==e&&t!==t:la(e,t,n,r,ca,i)}function la(e,t,n,r,i,a){var o=G(e),s=G(t),c=o?ye:U(e),l=s?ye:U(t);c=c==ve?ke:c,l=l==ve?ke:l;var u=c==ke,d=l==ke,f=c==l;if(f&&bu(e)){if(!bu(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new hi,o||Gu(e)?Jo(e,t,n,r,i,a):Yo(e,t,c,n,r,i,a);if(!(n&h)){var p=u&&O.call(e,`__wrapped__`),m=d&&O.call(t,`__wrapped__`);if(p||m){var g=p?e.value():e,_=m?t.value():t;return a||=new hi,i(g,_,n,r,a)}}return f?(a||=new hi,Xo(e,t,n,r,i,a)):!1}function ua(e){return Y(e)&&U(e)==w}function da(e,t,r,i){var a=r.length,o=a,s=!i;if(e==null)return!o;for(e=D(e);a--;){var c=r[a];if(s&&c[2]?c[1]!==e[c[0]]:!(c[0]in e))return!1}for(;++a<o;){c=r[a];var l=c[0],u=e[l],d=c[1];if(s&&c[2]){if(u===n&&!(l in e))return!1}else{var f=new hi;if(i)var p=i(u,d,l,e,t,f);if(!(p===n?ca(d,u,h|g,i,f):p))return!1}}return!0}function fa(e){return!J(e)||xs(e)?!1:(Ou(e)?Ut:xt).test(Hs(e))}function pa(e){return Y(e)&&z(e)==Me}function ma(e){return Y(e)&&U(e)==T}function ha(e){return Y(e)&&Au(e.length)&&!!A[z(e)]}function ga(e){return typeof e==`function`?e:e==null?$:typeof e==`object`?G(e)?Sa(e[0],e[1]):xa(e):Gf(e)}function _a(e){if(!Cs(e))return mn(e);var t=[];for(var n in D(e))O.call(e,n)&&n!=`constructor`&&t.push(n);return t}function va(e){if(!J(e))return Os(e);var t=Cs(e),n=[];for(var r in e)r==`constructor`&&(t||!O.call(e,r))||n.push(r);return n}function ya(e,t){return e<t}function ba(e,t){var n=-1,r=K(e)?E(e.length):[];return zi(e,function(e,i,a){r[++n]=t(e,i,a)}),r}function xa(e){var t=is(e);return t.length==1&&t[0][2]?Ts(t[0][0],t[0][1]):function(n){return n===e||da(n,e,t)}}function Sa(e,t){return vs(e)&&ws(t)?Ts(Vs(e),t):function(r){var i=yd(r,e);return i===n&&i===t?xd(r,e):ca(t,i,h|g)}}function Ca(e,t,r,i,a){e!==t&&Gi(t,function(o,s){if(a||=new hi,J(o))wa(e,t,s,r,Ca,i,a);else{var c=i?i(Ns(e,s),o,s+``,e,t,a):n;c===n&&(c=o),Ti(e,s,c)}},Td)}function wa(e,t,r,i,a,o,s){var c=Ns(e,r),l=Ns(t,r),u=s.get(l);if(u){Ti(e,r,u);return}var d=o?o(c,l,r+``,e,t,s):n,f=d===n;if(f){var p=G(l),m=!p&&bu(l),h=!p&&!m&&Gu(l);d=l,p||m||h?G(c)?d=c:q(c)?d=V(c):m?(f=!1,d=so(l,!0)):h?(f=!1,d=po(l,!0)):d=[]:zu(l)||_u(l)?(d=c,_u(c)?d=td(c):(!J(c)||Ou(c))&&(d=ps(l))):f=!1}f&&(s.set(l,d),a(d,l,i,o,s),s.delete(l)),Ti(e,r,d)}function Ta(e,t){var r=e.length;if(r)return t+=t<0?r:0,_s(t,r)?e[t]:n}function Ea(e,t,n){t=t.length?F(t,function(e){return G(e)?function(t){return Xi(t,e.length===1?e[0]:e)}:e}):[$];var r=-1;return t=F(t,lr(H())),ir(ba(e,function(e,n,i){return{criteria:F(t,function(t){return t(e)}),index:++r,value:e}}),function(e,t){return ho(e,t,n)})}function Da(e,t){return Oa(e,t,function(t,n){return xd(e,n)})}function Oa(e,t,n){for(var r=-1,i=t.length,a={};++r<i;){var o=t[r],s=Xi(e,o);n(s,o)&&La(a,ro(o,e),s)}return a}function ka(e){return function(t){return Xi(t,e)}}function Aa(e,t,n,r){var i=r?Qn:Zn,a=-1,o=t.length,s=e;for(e===t&&(t=V(t)),n&&(s=F(e,lr(n)));++a<o;)for(var c=0,l=t[a],u=n?n(l):l;(c=i(s,u,c,r))>-1;)s!==e&&Zt.call(s,c,1),Zt.call(e,c,1);return e}function ja(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==a){var a=i;_s(i)?Zt.call(e,i,1):Ya(e,i)}}return e}function Ma(e,t){return e+sn(yn()*(t-e+1))}function Na(e,t,n,r){for(var i=-1,a=k(on((t-e)/(n||1)),0),o=E(a);a--;)o[r?a:++i]=e,e+=n;return o}function Pa(e,t){var n=``;if(!e||t<1||t>de)return n;do t%2&&(n+=e),t=sn(t/2),t&&(e+=e);while(t);return n}function B(e,t){return Is(As(e,t,$),e+``)}function Fa(e){return Si(Ud(e))}function Ia(e,t){var n=Ud(e);return zs(n,Ni(t,0,n.length))}function La(e,t,r,i){if(!J(e))return e;t=ro(t,e);for(var a=-1,o=t.length,s=o-1,c=e;c!=null&&++a<o;){var l=Vs(t[a]),u=r;if(l===`__proto__`||l===`constructor`||l===`prototype`)return e;if(a!=s){var d=c[l];u=i?i(d,l,c):n,u===n&&(u=J(d)?d:_s(t[a+1])?[]:{})}Ei(c,l,u),c=c[l]}return e}var Ra=qn?function(e,t){return qn.set(e,t),e}:$,za=tn?function(e,t){return tn(e,`toString`,{configurable:!0,enumerable:!1,value:kf(t),writable:!0})}:$;function Ba(e){return zs(Ud(e))}function Va(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var a=E(i);++r<i;)a[r]=e[r+t];return a}function Ha(e,t){var n;return zi(e,function(e,r,i){return n=t(e,r,i),!n}),!!n}function Ua(e,t,n){var r=0,i=e==null?r:e.length;if(typeof t==`number`&&t===t&&i<=ge){for(;r<i;){var a=r+i>>>1,o=e[a];o!==null&&!Wu(o)&&(n?o<=t:o<t)?r=a+1:i=a}return i}return Wa(e,t,$,n)}function Wa(e,t,r,i){var a=0,o=e==null?0:e.length;if(o===0)return 0;t=r(t);for(var s=t!==t,c=t===null,l=Wu(t),u=t===n;a<o;){var d=sn((a+o)/2),f=r(e[d]),p=f!==n,m=f===null,h=f===f,g=Wu(f);if(s)var _=i||h;else _=u?h&&(i||p):c?h&&p&&(i||!m):l?h&&p&&!m&&(i||!g):m||g?!1:i?f<=t:f<t;_?a=d+1:o=d}return M(o,he)}function Ga(e,t){for(var n=-1,r=e.length,i=0,a=[];++n<r;){var o=e[n],s=t?t(o):o;if(!n||!mu(s,c)){var c=s;a[i++]=o===0?0:o}}return a}function Ka(e){return typeof e==`number`?e:Wu(e)?pe:+e}function qa(e){if(typeof e==`string`)return e;if(G(e))return F(e,qa)+``;if(Wu(e))return Vr?Vr.call(e):``;var t=e+``;return t==`0`&&1/e==-C?`-0`:t}function Ja(e,t,n){var r=-1,a=Bn,o=e.length,s=!0,c=[],l=c;if(n)s=!1,a=Vn;else if(o>=i){var u=t?null:Ho(e);if(u)return Tr(u);s=!1,a=dr,l=new fi}else l=t?[]:c;outer:for(;++r<o;){var d=e[r],f=t?t(d):d;if(d=n||d!==0?d:0,s&&f===f){for(var p=l.length;p--;)if(l[p]===f)continue outer;t&&l.push(f),c.push(d)}else a(l,f,n)||(l!==c&&l.push(f),c.push(d))}return c}function Ya(e,t){t=ro(t,e);var n=-1,r=t.length;if(!r)return!0;for(;++n<r;){var i=Vs(t[n]);if(i===`__proto__`&&!O.call(e,`__proto__`)||(i===`constructor`||i===`prototype`)&&n<r-1)return!1}var a=js(e,t);return a==null||delete a[Vs(hc(t))]}function Xa(e,t,n,r){return La(e,t,n(Xi(e,t)),r)}function Za(e,t,n,r){for(var i=e.length,a=r?i:-1;(r?a--:++a<i)&&t(e[a],a,e););return n?Va(e,r?0:a,r?a+1:i):Va(e,r?a+1:0,r?i:a)}function Qa(e,t){var n=e;return n instanceof L&&(n=n.value()),Un(t,function(e,t){return t.func.apply(t.thisArg,Hn([e],t.args))},n)}function $a(e,t,n){var r=e.length;if(r<2)return r?Ja(e[0]):[];for(var i=-1,a=E(r);++i<r;)for(var o=e[i],s=-1;++s<r;)s!=i&&(a[i]=Ri(a[i]||o,e[s],t,n));return Ja(R(a,1),t,n)}function eo(e,t,r){for(var i=-1,a=e.length,o=t.length,s={};++i<a;){var c=i<o?t[i]:n;r(s,e[i],c)}return s}function to(e){return q(e)?e:[]}function no(e){return typeof e==`function`?e:$}function ro(e,t){return G(e)?e:vs(e,t)?[e]:Bs(Z(e))}var io=B;function ao(e,t,r){var i=e.length;return r=r===n?i:r,!t&&r>=i?e:Va(e,t,r)}var oo=nn||function(e){return N.clearTimeout(e)};function so(e,t){if(t)return e.slice();var n=e.length,r=qt?qt(n):new e.constructor(n);return e.copy(r),r}function co(e){var t=new e.constructor(e.byteLength);return new Kt(t).set(new Kt(e)),t}function lo(e,t){var n=t?co(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function uo(e){var t=new e.constructor(e.source,vt.exec(e));return t.lastIndex=e.lastIndex,t}function fo(e){return Br?D(Br.call(e)):{}}function po(e,t){var n=t?co(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function mo(e,t){if(e!==t){var r=e!==n,i=e===null,a=e===e,o=Wu(e),s=t!==n,c=t===null,l=t===t,u=Wu(t);if(!c&&!u&&!o&&e>t||o&&s&&l&&!c&&!u||i&&s&&l||!r&&l||!a)return 1;if(!i&&!o&&!u&&e<t||u&&r&&a&&!i&&!o||c&&r&&a||!s&&a||!l)return-1}return 0}function ho(e,t,n){for(var r=-1,i=e.criteria,a=t.criteria,o=i.length,s=n.length;++r<o;){var c=mo(i[r],a[r]);if(c)return r>=s?c:c*(n[r]==`desc`?-1:1)}return e.index-t.index}function go(e,t,n,r){for(var i=-1,a=e.length,o=n.length,s=-1,c=t.length,l=k(a-o,0),u=E(c+l),d=!r;++s<c;)u[s]=t[s];for(;++i<o;)(d||i<a)&&(u[n[i]]=e[i]);for(;l--;)u[s++]=e[i++];return u}function _o(e,t,n,r){for(var i=-1,a=e.length,o=-1,s=n.length,c=-1,l=t.length,u=k(a-s,0),d=E(u+l),f=!r;++i<u;)d[i]=e[i];for(var p=i;++c<l;)d[p+c]=t[c];for(;++o<s;)(f||i<a)&&(d[p+n[o]]=e[i++]);return d}function V(e,t){var n=-1,r=e.length;for(t||=E(r);++n<r;)t[n]=e[n];return t}function vo(e,t,r,i){var a=!r;r||={};for(var o=-1,s=t.length;++o<s;){var c=t[o],l=i?i(r[c],e[c],c,r,e):n;l===n&&(l=e[c]),a?ji(r,c,l):Ei(r,c,l)}return r}function yo(e,t){return vo(e,ss(e),t)}function bo(e,t){return vo(e,cs(e),t)}function xo(e,t){return function(n,r){var i=G(n)?Fn:Oi,a=t?t():{};return i(n,e,H(r,2),a)}}function So(e){return B(function(t,r){var i=-1,a=r.length,o=a>1?r[a-1]:n,s=a>2?r[2]:n;for(o=e.length>3&&typeof o==`function`?(a--,o):n,s&&W(r[0],r[1],s)&&(o=a<3?n:o,a=1),t=D(t);++i<a;){var c=r[i];c&&e(t,c,i,o)}return t})}function Co(e,t){return function(n,r){if(n==null)return n;if(!K(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=D(n);(t?a--:++a<i)&&r(o[a],a,o)!==!1;);return n}}function wo(e){return function(t,n,r){for(var i=-1,a=D(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}function To(e,t,n){var r=t&_,i=Oo(e);function a(){return(this&&this!==N&&this instanceof a?i:e).apply(r?n:this,arguments)}return a}function Eo(e){return function(t){t=Z(t);var r=yr(t)?Ar(t):n,i=r?r[0]:t.charAt(0),a=r?ao(r,1).join(``):t.slice(1);return i[e]()+a}}function Do(e){return function(t){return Un(wf(Xd(t).replace(un,``)),e,``)}}function Oo(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=Hr(e.prototype),r=e.apply(n,t);return J(r)?r:n}}function ko(e,t,r){var i=Oo(e);function a(){for(var o=arguments.length,s=E(o),c=o,l=ns(a);c--;)s[c]=arguments[c];var u=o<3&&s[0]!==l&&s[o-1]!==l?[]:wr(s,l);return o-=u.length,o<r?Bo(e,t,Mo,a.placeholder,n,s,u,n,n,r-o):Pn(this&&this!==N&&this instanceof a?i:e,this,s)}return a}function Ao(e){return function(t,r,i){var a=D(t);if(!K(t)){var o=H(r,3);t=Q(t),r=function(e){return o(a[e],e,a)}}var s=e(t,r,i);return s>-1?a[o?t[s]:s]:n}}function jo(e){return Zo(function(t){var r=t.length,i=r,a=Wr.prototype.thru;for(e&&t.reverse();i--;){var s=t[i];if(typeof s!=`function`)throw new Mt(o);if(a&&!c&&ts(s)==`wrapper`)var c=new Wr([],!0)}for(i=c?i:r;++i<r;){s=t[i];var l=ts(s),u=l==`wrapper`?es(s):n;c=u&&bs(u[0])&&u[1]==(te|b|S|ne)&&!u[4].length&&u[9]==1?c[ts(u[0])].apply(c,u[3]):s.length==1&&bs(s)?c[l]():c.thru(s)}return function(){var e=arguments,n=e[0];if(c&&e.length==1&&G(n))return c.plant(n).value();for(var i=0,a=r?t[i].apply(this,e):n;++i<r;)a=t[i].call(this,a);return a}})}function Mo(e,t,r,i,a,o,s,c,l,u){var d=t&te,f=t&_,p=t&v,m=t&(b|x),h=t&re,g=p?n:Oo(e);function y(){for(var n=arguments.length,_=E(n),v=n;v--;)_[v]=arguments[v];if(m)var b=ns(y),x=mr(_,b);if(i&&(_=go(_,i,a,m)),o&&(_=_o(_,o,s,m)),n-=x,m&&n<u){var S=wr(_,b);return Bo(e,t,Mo,y.placeholder,r,_,S,c,l,u-n)}var ee=f?r:this,te=p?ee[e]:e;return n=_.length,c?_=Ms(_,c):h&&n>1&&_.reverse(),d&&l<n&&(_.length=l),this&&this!==N&&this instanceof y&&(te=g||Oo(te)),te.apply(ee,_)}return y}function No(e,t){return function(n,r){return ra(n,e,t(r),{})}}function Po(e,t){return function(r,i){var a;if(r===n&&i===n)return t;if(r!==n&&(a=r),i!==n){if(a===n)return i;typeof r==`string`||typeof i==`string`?(r=qa(r),i=qa(i)):(r=Ka(r),i=Ka(i)),a=e(r,i)}return a}}function Fo(e){return Zo(function(t){return t=F(t,lr(H())),B(function(n){var r=this;return e(t,function(e){return Pn(e,r,n)})})})}function Io(e,t){t=t===n?` `:qa(t);var r=t.length;if(r<2)return r?Pa(t,e):t;var i=Pa(t,on(e/kr(t)));return yr(t)?ao(Ar(i),0,e).join(``):i.slice(0,e)}function Lo(e,t,n,r){var i=t&_,a=Oo(e);function o(){for(var t=-1,s=arguments.length,c=-1,l=r.length,u=E(l+s),d=this&&this!==N&&this instanceof o?a:e;++c<l;)u[c]=r[c];for(;s--;)u[c++]=arguments[++t];return Pn(d,i?n:this,u)}return o}function Ro(e){return function(t,r,i){return i&&typeof i!=`number`&&W(t,r,i)&&(r=i=n),t=Qu(t),r===n?(r=t,t=0):r=Qu(r),i=i===n?t<r?1:-1:Qu(i),Na(t,r,i,e)}}function zo(e){return function(t,n){return typeof t==`string`&&typeof n==`string`||(t=ed(t),n=ed(n)),e(t,n)}}function Bo(e,t,r,i,a,o,s,c,l,u){var d=t&b,f=d?s:n,p=d?n:s,m=d?o:n,h=d?n:o;t|=d?S:ee,t&=~(d?ee:S),t&y||(t&=~(_|v));var g=[e,t,a,m,f,h,p,c,l,u],x=r.apply(n,g);return bs(e)&&Ps(x,g),x.placeholder=i,Ls(x,e,t)}function Vo(e){var t=kt[e];return function(e,n){if(e=ed(e),n=n==null?0:M(X(n),292),n&&fn(e)){var r=(Z(e)+`e`).split(`e`);return r=(Z(t(r[0]+`e`+(+r[1]+n)))+`e`).split(`e`),+(r[0]+`e`+(+r[1]-n))}return t(e)}}var Ho=Dn&&1/Tr(new Dn([,-0]))[1]==C?function(e){return new Dn(e)}:Bf;function Uo(e){return function(t){var n=U(t);return n==w?Sr(t):n==T?Er(t):sr(t,e(t))}}function Wo(e,t,r,i,a,s,c,l){var u=t&v;if(!u&&typeof e!=`function`)throw new Mt(o);var d=i?i.length:0;if(d||(t&=~(S|ee),i=a=n),c=c===n?c:k(X(c),0),l=l===n?l:X(l),d-=a?a.length:0,t&ee){var f=i,p=a;i=a=n}var m=u?n:es(e),h=[e,t,r,i,a,f,p,s,c,l];if(m&&Ds(h,m),e=h[0],t=h[1],r=h[2],i=h[3],a=h[4],l=h[9]=h[9]===n?u?0:e.length:k(h[9]-d,0),!l&&t&(b|x)&&(t&=~(b|x)),!t||t==_)var g=To(e,t,r);else g=t==b||t==x?ko(e,t,l):(t==S||t==(_|S))&&!a.length?Lo(e,t,r,i):Mo.apply(n,h);return Ls((m?Ra:Ps)(g,h),e,t)}function Go(e,t,r,i){return e===n||mu(e,Ft[r])&&!O.call(i,r)?t:e}function Ko(e,t,r,i,a,o){return J(e)&&J(t)&&(o.set(t,e),Ca(e,t,n,Ko,o),o.delete(t)),e}function qo(e){return zu(e)?n:e}function Jo(e,t,r,i,a,o){var s=r&h,c=e.length,l=t.length;if(c!=l&&!(s&&l>c))return!1;var u=o.get(e),d=o.get(t);if(u&&d)return u==t&&d==e;var f=-1,p=!0,m=r&g?new fi:n;for(o.set(e,t),o.set(t,e);++f<c;){var _=e[f],v=t[f];if(i)var y=s?i(v,_,f,t,e,o):i(_,v,f,e,t,o);if(y!==n){if(y)continue;p=!1;break}if(m){if(!Gn(t,function(e,t){if(!dr(m,t)&&(_===e||a(_,e,r,i,o)))return m.push(t)})){p=!1;break}}else if(!(_===v||a(_,v,r,i,o))){p=!1;break}}return o.delete(e),o.delete(t),p}function Yo(e,t,n,r,i,a,o){switch(n){case ze:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Re:return!(e.byteLength!=t.byteLength||!a(new Kt(e),new Kt(t)));case xe:case Se:case De:return mu(+e,+t);case we:return e.name==t.name&&e.message==t.message;case Me:case Ne:return e==t+``;case w:var s=Sr;case T:var c=r&h;if(s||=Tr,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=g,o.set(e,t);var u=Jo(s(e),s(t),r,i,a,o);return o.delete(e),u;case Pe:if(Br)return Br.call(e)==Br.call(t)}return!1}function Xo(e,t,r,i,a,o){var s=r&h,c=Qo(e),l=c.length;if(l!=Qo(t).length&&!s)return!1;for(var u=l;u--;){var d=c[u];if(!(s?d in t:O.call(t,d)))return!1}var f=o.get(e),p=o.get(t);if(f&&p)return f==t&&p==e;var m=!0;o.set(e,t),o.set(t,e);for(var g=s;++u<l;){d=c[u];var _=e[d],v=t[d];if(i)var y=s?i(v,_,d,t,e,o):i(_,v,d,e,t,o);if(!(y===n?_===v||a(_,v,r,i,o):y)){m=!1;break}g||=d==`constructor`}if(m&&!g){var b=e.constructor,x=t.constructor;b!=x&&`constructor`in e&&`constructor`in t&&!(typeof b==`function`&&b instanceof b&&typeof x==`function`&&x instanceof x)&&(m=!1)}return o.delete(e),o.delete(t),m}function Zo(e){return Is(As(e,n,ic),e+``)}function Qo(e){return Zi(e,Q,ss)}function $o(e){return Zi(e,Td,cs)}var es=qn?function(e){return qn.get(e)}:Bf;function ts(e){for(var t=e.name+``,n=nr[t],r=O.call(nr,t)?n.length:0;r--;){var i=n[r],a=i.func;if(a==null||a==e)return i.name}return t}function ns(e){return(O.call(I,`placeholder`)?I:e).placeholder}function H(){var e=I.iteratee||Nf;return e=e===Nf?ga:e,arguments.length?e(arguments[0],arguments[1]):e}function rs(e,t){var n=e.__data__;return ys(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function is(e){for(var t=Q(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,ws(i)]}return t}function as(e,t){var r=vr(e,t);return fa(r)?r:n}function os(e){var t=O.call(e,en),r=e[en];try{e[en]=n;var i=!0}catch{}var a=Bt.call(e);return i&&(t?e[en]=r:delete e[en]),a}var ss=cn?function(e){return e==null?[]:(e=D(e),zn(cn(e),function(t){return Xt.call(e,t)}))}:Yf,cs=cn?function(e){for(var t=[];e;)Hn(t,ss(e)),e=Jt(e);return t}:Yf,U=z;(Cn&&U(new Cn(new ArrayBuffer(1)))!=ze||wn&&U(new wn)!=w||Tn&&U(Tn.resolve())!=Ae||Dn&&U(new Dn)!=T||P&&U(new P)!=Ie)&&(U=function(e){var t=z(e),r=t==ke?e.constructor:n,i=r?Hs(r):``;if(i)switch(i){case Dr:return ze;case Nr:return w;case Pr:return Ae;case Lr:return T;case Rr:return Ie}return t});function ls(e,t,n){for(var r=-1,i=n.length;++r<i;){var a=n[r],o=a.size;switch(a.type){case`drop`:e+=o;break;case`dropRight`:t-=o;break;case`take`:t=M(t,e+o);break;case`takeRight`:e=k(e,t-o);break}}return{start:e,end:t}}function us(e){var t=e.match(ft);return t?t[1].split(pt):[]}function ds(e,t,n){t=ro(t,e);for(var r=-1,i=t.length,a=!1;++r<i;){var o=Vs(t[r]);if(!(a=e!=null&&n(e,o)))break;e=e[o]}return a||++r!=i?a:(i=e==null?0:e.length,!!i&&Au(i)&&_s(o,i)&&(G(e)||_u(e)))}function fs(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]==`string`&&O.call(e,`index`)&&(n.index=e.index,n.input=e.input),n}function ps(e){return typeof e.constructor==`function`&&!Cs(e)?Hr(Jt(e)):{}}function ms(e,t,n){var r=e.constructor;switch(t){case Re:return co(e);case xe:case Se:return new r(+e);case ze:return lo(e,n);case Be:case Ve:case He:case Ue:case We:case Ge:case Ke:case qe:case Je:return po(e,n);case w:return new r;case De:case Ne:return new r(e);case Me:return uo(e);case T:return new r;case Pe:return fo(e)}}function hs(e,t){var n=t.length;if(!n)return e;var r=n-1;return t[r]=(n>1?`& `:``)+t[r],t=t.join(n>2?`, `:` `),e.replace(dt,`{
3
3
  /* [wrapped with `+t+`] */
4
- `)}function hs(e){return K(e)||gu(e)||!!(Zt&&e&&e[Zt])}function gs(e,t){var n=typeof e;return t??=de,!!t&&(n==`number`||n!=`symbol`&&Ct.test(e))&&e>-1&&e%1==0&&e<t}function G(e,t,n){if(!J(n))return!1;var r=typeof t;return(r==`number`?vu(n)&&gs(t,n.length):r==`string`&&t in n)?pu(n[t],e):!1}function _s(e,t){if(K(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||Wu(e)?!0:ot.test(e)||!at.test(e)||t!=null&&e in D(t)}function vs(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function ys(e){var t=es(e),n=L[t];if(typeof n!=`function`||!(t in R.prototype))return!1;if(e===n)return!0;var r=$o(n);return!!r&&e===r[0]}function bs(e){return!!Rt&&Rt in e}var xs=Ft?Ou:Xf;function Ss(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||Pt)}function Cs(e){return e===e&&!J(e)}function ws(e,t){return function(r){return r==null?!1:r[e]===t&&(t!==n||e in D(r))}}function Ts(e){var t=Yl(e,function(e){return n.size===u&&n.clear(),e}),n=t.cache;return t}function Es(e,t){var n=e[1],r=t[1],i=n|r,a=i<(_|v|te),o=r==te&&n==b||r==te&&n==ne&&e[7].length<=t[8]||r==(te|ne)&&t[7].length<=t[8]&&n==b;if(!(a||o))return e;r&_&&(e[2]=t[2],i|=n&_?0:y);var s=t[3];if(s){var c=e[3];e[3]=c?ho(c,s,t[4]):s,e[4]=c?Cr(e[3],d):t[4]}return s=t[5],s&&(c=e[5],e[5]=c?go(c,s,t[6]):s,e[6]=c?Cr(e[5],d):t[6]),s=t[7],s&&(e[7]=s),r&te&&(e[8]=e[8]==null?t[8]:N(e[8],t[8])),e[9]??=t[9],e[0]=t[0],e[1]=i,e}function Ds(e){var t=[];if(e!=null)for(var n in D(e))t.push(n);return t}function Os(e){return zt.call(e)}function ks(e,t,r){return t=A(t===n?e.length-1:t,0),function(){for(var n=arguments,i=-1,a=A(n.length-t,0),o=E(a);++i<a;)o[i]=n[t+i];i=-1;for(var s=E(t+1);++i<t;)s[i]=n[i];return s[t]=r(o),Nn(e,this,s)}}function As(e,t){return t.length<2?e:Yi(e,Ba(t,0,-1))}function js(e,t){for(var r=e.length,i=N(t.length,r),a=H(e);i--;){var o=t[i];e[i]=gs(o,r)?a[o]:n}return e}function Ms(e,t){if(!(t===`constructor`&&typeof e[t]==`function`)&&t!=`__proto__`)return e[t]}var Ns=Ls(La),Ps=rn||function(e,t){return P.setTimeout(e,t)},Fs=Ls(Ra);function Is(e,t,n){var r=t+``;return Fs(e,ms(r,Hs(ls(r),n)))}function Ls(e){var t=0,r=0;return function(){var i=gn(),a=se-(i-r);if(r=i,a>0){if(++t>=oe)return arguments[0]}else t=0;return e.apply(n,arguments)}}function Rs(e,t){var r=-1,i=e.length,a=i-1;for(t=t===n?i:t;++r<t;){var o=ja(r,a),s=e[o];e[o]=e[r],e[r]=s}return e.length=t,e}var zs=Ts(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(st,function(e,n,r,i){t.push(r?i.replace(gt,`$1`):n||e)}),t});function Bs(e){if(typeof e==`string`||Wu(e))return e;var t=e+``;return t==`0`&&1/e==-C?`-0`:t}function Vs(e){if(e!=null){try{return It.call(e)}catch{}try{return e+``}catch{}}return``}function Hs(e,t){return Fn(_e,function(n){var r=`_.`+n[0];t&n[1]&&!zn(e,r)&&e.push(r)}),e.sort()}function Us(e){if(e instanceof R)return e.clone();var t=new Ur(e.__wrapped__,e.__chain__);return t.__actions__=H(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}function Ws(e,t,r){t=(r?G(e,t,r):t===n)?1:A(X(t),0);var i=e==null?0:e.length;if(!i||t<1)return[];for(var a=0,o=0,s=E(an(i/t));a<i;)s[o++]=Ba(e,a,a+=t);return s}function Gs(e){for(var t=-1,n=e==null?0:e.length,r=0,i=[];++t<n;){var a=e[t];a&&(i[r++]=a)}return i}function Ks(){var e=arguments.length;if(!e)return[];for(var t=E(e-1),n=arguments[0],r=e;r--;)t[r-1]=arguments[r];return Vn(K(n)?H(n):[n],z(t,1))}var qs=V(function(e,t){return q(e)?Li(e,z(t,1,q,!0)):[]}),Js=V(function(e,t){var r=mc(t);return q(r)&&(r=n),q(e)?Li(e,z(t,1,q,!0),U(r,2)):[]}),Ys=V(function(e,t){var r=mc(t);return q(r)&&(r=n),q(e)?Li(e,z(t,1,q,!0),n,r):[]});function Xs(e,t,r){var i=e==null?0:e.length;return i?(t=r||t===n?1:X(t),Ba(e,t<0?0:t,i)):[]}function Zs(e,t,r){var i=e==null?0:e.length;return i?(t=r||t===n?1:X(t),t=i-t,Ba(e,0,t<0?0:t)):[]}function Qs(e,t){return e&&e.length?Xa(e,U(t,3),!0,!0):[]}function $s(e,t){return e&&e.length?Xa(e,U(t,3),!0):[]}function ec(e,t,n,r){var i=e==null?0:e.length;return i?(n&&typeof n!=`number`&&G(e,t,n)&&(n=0,r=i),Hi(e,t,n,r)):[]}function tc(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:X(n);return i<0&&(i=A(r+i,0)),Yn(e,U(t,3),i)}function nc(e,t,r){var i=e==null?0:e.length;if(!i)return-1;var a=i-1;return r!==n&&(a=X(r),a=r<0?A(i+a,0):N(a,i-1)),Yn(e,U(t,3),a,!0)}function rc(e){return e!=null&&e.length?z(e,1):[]}function ic(e){return e!=null&&e.length?z(e,C):[]}function ac(e,t){return e!=null&&e.length?(t=t===n?1:X(t),z(e,t)):[]}function oc(e){for(var t=-1,n=e==null?0:e.length,r={};++t<n;){var i=e[t];Ai(r,i[0],i[1])}return r}function sc(e){return e&&e.length?e[0]:n}function cc(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:X(n);return i<0&&(i=A(r+i,0)),Xn(e,t,i)}function lc(e){return e!=null&&e.length?Ba(e,0,-1):[]}var uc=V(function(e){var t=I(e,eo);return t.length&&t[0]===e[0]?ta(t):[]}),dc=V(function(e){var t=mc(e),r=I(e,eo);return t===mc(r)?t=n:r.pop(),r.length&&r[0]===e[0]?ta(r,U(t,2)):[]}),fc=V(function(e){var t=mc(e),r=I(e,eo);return t=typeof t==`function`?t:n,t&&r.pop(),r.length&&r[0]===e[0]?ta(r,n,t):[]});function pc(e,t){return e==null?``:fn.call(e,t)}function mc(e){var t=e==null?0:e.length;return t?e[t-1]:n}function hc(e,t,r){var i=e==null?0:e.length;if(!i)return-1;var a=i;return r!==n&&(a=X(r),a=a<0?A(i+a,0):N(a,i-1)),t===t?Dr(e,t,a):Yn(e,Qn,a,!0)}function gc(e,t){return e&&e.length?wa(e,X(t)):n}var _c=V(vc);function vc(e,t){return e&&e.length&&t&&t.length?ka(e,t):e}function yc(e,t,n){return e&&e.length&&t&&t.length?ka(e,t,U(n,2)):e}function bc(e,t,r){return e&&e.length&&t&&t.length?ka(e,t,n,r):e}var xc=Xo(function(e,t){var n=e==null?0:e.length,r=ji(e,t);return Aa(e,I(t,function(e){return gs(e,n)?+e:e}).sort(po)),r});function Sc(e,t){var n=[];if(!(e&&e.length))return n;var r=-1,i=[],a=e.length;for(t=U(t,3);++r<a;){var o=e[r];t(o,r,e)&&(n.push(o),i.push(r))}return Aa(e,i),n}function Cc(e){return e==null?e:xn.call(e)}function wc(e,t,r){var i=e==null?0:e.length;return i?(r&&typeof r!=`number`&&G(e,t,r)?(t=0,r=i):(t=t==null?0:X(t),r=r===n?i:X(r)),Ba(e,t,r)):[]}function Tc(e,t){return Ha(e,t)}function Ec(e,t,n){return Ua(e,t,U(n,2))}function Dc(e,t){var n=e==null?0:e.length;if(n){var r=Ha(e,t);if(r<n&&pu(e[r],t))return r}return-1}function Oc(e,t){return Ha(e,t,!0)}function kc(e,t,n){return Ua(e,t,U(n,2),!0)}function Ac(e,t){if(e!=null&&e.length){var n=Ha(e,t,!0)-1;if(pu(e[n],t))return n}return-1}function jc(e){return e&&e.length?Wa(e):[]}function Mc(e,t){return e&&e.length?Wa(e,U(t,2)):[]}function Nc(e){var t=e==null?0:e.length;return t?Ba(e,1,t):[]}function Pc(e,t,r){return e&&e.length?(t=r||t===n?1:X(t),Ba(e,0,t<0?0:t)):[]}function Fc(e,t,r){var i=e==null?0:e.length;return i?(t=r||t===n?1:X(t),t=i-t,Ba(e,t<0?0:t,i)):[]}function Ic(e,t){return e&&e.length?Xa(e,U(t,3),!1,!0):[]}function Lc(e,t){return e&&e.length?Xa(e,U(t,3)):[]}var Rc=V(function(e){return qa(z(e,1,q,!0))}),zc=V(function(e){var t=mc(e);return q(t)&&(t=n),qa(z(e,1,q,!0),U(t,2))}),Bc=V(function(e){var t=mc(e);return t=typeof t==`function`?t:n,qa(z(e,1,q,!0),n,t)});function Vc(e){return e&&e.length?qa(e):[]}function Hc(e,t){return e&&e.length?qa(e,U(t,2)):[]}function Uc(e,t){return t=typeof t==`function`?t:n,e&&e.length?qa(e,n,t):[]}function Wc(e){if(!(e&&e.length))return[];var t=0;return e=Rn(e,function(e){if(q(e))return t=A(e.length,t),!0}),ar(t,function(t){return I(e,er(t))})}function Gc(e,t){if(!(e&&e.length))return[];var r=Wc(e);return t==null?r:I(r,function(e){return Nn(t,n,e)})}var Kc=V(function(e,t){return q(e)?Li(e,t):[]}),qc=V(function(e){return Qa(Rn(e,q))}),Jc=V(function(e){var t=mc(e);return q(t)&&(t=n),Qa(Rn(e,q),U(t,2))}),Yc=V(function(e){var t=mc(e);return t=typeof t==`function`?t:n,Qa(Rn(e,q),n,t)}),Xc=V(Wc);function Zc(e,t){return $a(e||[],t||[],Ti)}function Qc(e,t){return $a(e||[],t||[],Ia)}var $c=V(function(e){var t=e.length,r=t>1?e[t-1]:n;return r=typeof r==`function`?(e.pop(),r):n,Gc(e,r)});function el(e){var t=L(e);return t.__chain__=!0,t}function tl(e,t){return t(e),e}function nl(e,t){return t(e)}var rl=Xo(function(e){var t=e.length,r=t?e[0]:0,i=this.__wrapped__,a=function(t){return ji(t,e)};return t>1||this.__actions__.length||!(i instanceof R)||!gs(r)?this.thru(a):(i=i.slice(r,+r+ +!!t),i.__actions__.push({func:nl,args:[a],thisArg:n}),new Ur(i,this.__chain__).thru(function(e){return t&&!e.length&&e.push(n),e}))});function il(){return el(this)}function al(){return new Ur(this.value(),this.__chain__)}function ol(){this.__values__===n&&(this.__values__=Zu(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?n:this.__values__[this.__index__++]}}function sl(){return this}function cl(e){for(var t,r=this;r instanceof Hr;){var i=Us(r);i.__index__=0,i.__values__=n,t?a.__wrapped__=i:t=i;var a=i;r=r.__wrapped__}return a.__wrapped__=e,t}function ll(){var e=this.__wrapped__;if(e instanceof R){var t=e;return this.__actions__.length&&(t=new R(this)),t=t.reverse(),t.__actions__.push({func:nl,args:[Cc],thisArg:n}),new Ur(t,this.__chain__)}return this.thru(Cc)}function ul(){return Za(this.__wrapped__,this.__actions__)}var dl=bo(function(e,t,n){k.call(e,n)?++e[n]:Ai(e,n,1)});function fl(e,t,r){var i=K(e)?Ln:Bi;return r&&G(e,t,r)&&(t=n),i(e,U(t,3))}function pl(e,t){return(K(e)?Rn:Ui)(e,U(t,3))}var ml=ko(tc),hl=ko(nc);function gl(e,t){return z(Tl(e,t),1)}function _l(e,t){return z(Tl(e,t),C)}function vl(e,t,r){return r=r===n?1:X(r),z(Tl(e,t),r)}function yl(e,t){return(K(e)?Fn:Ri)(e,U(t,3))}function bl(e,t){return(K(e)?In:zi)(e,U(t,3))}var xl=bo(function(e,t,n){k.call(e,n)?e[n].push(t):Ai(e,n,[t])});function Sl(e,t,n,r){e=vu(e)?e:Ud(e),n=n&&!r?X(n):0;var i=e.length;return n<0&&(n=A(i+n,0)),Uu(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&Xn(e,t,n)>-1}var Cl=V(function(e,t,n){var r=-1,i=typeof t==`function`,a=vu(e)?E(e.length):[];return Ri(e,function(e){a[++r]=i?Nn(t,e,n):ra(e,t,n)}),a}),wl=bo(function(e,t,n){Ai(e,n,t)});function Tl(e,t){return(K(e)?I:ya)(e,U(t,3))}function El(e,t,r,i){return e==null?[]:(K(t)||(t=t==null?[]:[t]),r=i?n:r,K(r)||(r=r==null?[]:[r]),Ta(e,t,r))}var Dl=bo(function(e,t,n){e[+!n].push(t)},function(){return[[],[]]});function Ol(e,t,n){var r=K(e)?Hn:nr,i=arguments.length<3;return r(e,U(t,4),n,i,Ri)}function kl(e,t,n){var r=K(e)?Un:nr,i=arguments.length<3;return r(e,U(t,4),n,i,zi)}function Al(e,t){return(K(e)?Rn:Ui)(e,Xl(U(t,3)))}function jl(e){return(K(e)?xi:Pa)(e)}function Ml(e,t,r){return t=(r?G(e,t,r):t===n)?1:X(t),(K(e)?Si:Fa)(e,t)}function Nl(e){return(K(e)?Ci:za)(e)}function Pl(e){if(e==null)return 0;if(vu(e))return Uu(e)?Or(e):e.length;var t=W(e);return t==w||t==T?e.size:ga(e).length}function Fl(e,t,r){var i=K(e)?Wn:Va;return r&&G(e,t,r)&&(t=n),i(e,U(t,3))}var Il=V(function(e,t){if(e==null)return[];var n=t.length;return n>1&&G(e,t[0],t[1])?t=[]:n>2&&G(t[0],t[1],t[2])&&(t=[t[0]]),Ta(e,z(t,1),[])}),Ll=nn||function(){return P.Date.now()};function Rl(e,t){if(typeof t!=`function`)throw new O(o);return e=X(e),function(){if(--e<1)return t.apply(this,arguments)}}function zl(e,t,r){return t=r?n:t,t=e&&t==null?e.length:t,Uo(e,te,n,n,n,n,t)}function Bl(e,t){var r;if(typeof t!=`function`)throw new O(o);return e=X(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=n),r}}var Vl=V(function(e,t,n){var r=_;if(n.length){var i=Cr(n,ts(Vl));r|=S}return Uo(e,r,t,n,i)}),Hl=V(function(e,t,n){var r=_|v;if(n.length){var i=Cr(n,ts(Hl));r|=S}return Uo(t,r,e,n,i)});function Ul(e,t,r){t=r?n:t;var i=Uo(e,b,n,n,n,n,n,t);return i.placeholder=Ul.placeholder,i}function Wl(e,t,r){t=r?n:t;var i=Uo(e,x,n,n,n,n,n,t);return i.placeholder=Wl.placeholder,i}function Gl(e,t,r){var i,a,s,c,l,u,d=0,f=!1,p=!1,m=!0;if(typeof e!=`function`)throw new O(o);t=ed(t)||0,J(r)&&(f=!!r.leading,p=`maxWait`in r,s=p?A(ed(r.maxWait)||0,t):s,m=`trailing`in r?!!r.trailing:m);function h(t){var r=i,o=a;return i=a=n,d=t,c=e.apply(o,r),c}function g(e){return d=e,l=Ps(y,t),f?h(e):c}function _(e){var n=e-u,r=e-d,i=t-n;return p?N(i,s-r):i}function v(e){var r=e-u,i=e-d;return u===n||r>=t||r<0||p&&i>=s}function y(){var e=Ll();if(v(e))return b(e);l=Ps(y,_(e))}function b(e){return l=n,m&&i?h(e):(i=a=n,c)}function x(){l!==n&&ao(l),d=0,i=u=a=l=n}function S(){return l===n?c:b(Ll())}function ee(){var e=Ll(),r=v(e);if(i=arguments,a=this,u=e,r){if(l===n)return g(u);if(p)return ao(l),l=Ps(y,t),h(u)}return l===n&&(l=Ps(y,t)),c}return ee.cancel=x,ee.flush=S,ee}var Kl=V(function(e,t){return Ii(e,1,t)}),ql=V(function(e,t,n){return Ii(e,ed(t)||0,n)});function Jl(e){return Uo(e,re)}function Yl(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw new O(o);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(Yl.Cache||ai),n}Yl.Cache=ai;function Xl(e){if(typeof e!=`function`)throw new O(o);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}function Zl(e){return Bl(2,e)}var Ql=ro(function(e,t){t=t.length==1&&K(t[0])?I(t[0],cr(U())):I(z(t,1),cr(U()));var n=t.length;return V(function(r){for(var i=-1,a=N(r.length,n);++i<a;)r[i]=t[i].call(this,r[i]);return Nn(e,this,r)})}),$l=V(function(e,t){return Uo(e,S,n,t,Cr(t,ts($l)))}),eu=V(function(e,t){return Uo(e,ee,n,t,Cr(t,ts(eu)))}),tu=Xo(function(e,t){return Uo(e,ne,n,n,n,t)});function nu(e,t){if(typeof e!=`function`)throw new O(o);return t=t===n?t:X(t),V(e,t)}function ru(e,t){if(typeof e!=`function`)throw new O(o);return t=t==null?0:A(X(t),0),V(function(n){var r=n[t],i=io(n,0,t);return r&&Vn(i,r),Nn(e,this,i)})}function iu(e,t,n){var r=!0,i=!0;if(typeof e!=`function`)throw new O(o);return J(n)&&(r=`leading`in n?!!n.leading:r,i=`trailing`in n?!!n.trailing:i),Gl(e,t,{leading:r,maxWait:t,trailing:i})}function au(e){return zl(e,1)}function ou(e,t){return $l(to(t),e)}function su(){if(!arguments.length)return[];var e=arguments[0];return K(e)?e:[e]}function cu(e){return Ni(e,m)}function lu(e,t){return t=typeof t==`function`?t:n,Ni(e,m,t)}function uu(e){return Ni(e,f|m)}function du(e,t){return t=typeof t==`function`?t:n,Ni(e,f|m,t)}function fu(e,t){return t==null||Fi(e,t,Q(t))}function pu(e,t){return e===t||e!==e&&t!==t}var mu=Ro(Zi),hu=Ro(function(e,t){return e>=t}),gu=ia(function(){return arguments}())?ia:function(e){return Y(e)&&k.call(e,`callee`)&&!Yt.call(e,`callee`)},K=E.isArray,_u=Dn?cr(Dn):aa;function vu(e){return e!=null&&Au(e.length)&&!Ou(e)}function q(e){return Y(e)&&vu(e)}function yu(e){return e===!0||e===!1||Y(e)&&B(e)==xe}var bu=cn||Xf,xu=On?cr(On):oa;function Su(e){return Y(e)&&e.nodeType===1&&!zu(e)}function Cu(e){if(e==null)return!0;if(vu(e)&&(K(e)||typeof e==`string`||typeof e.splice==`function`||bu(e)||Gu(e)||gu(e)))return!e.length;var t=W(e);if(t==w||t==T)return!e.size;if(Ss(e))return!ga(e).length;for(var n in e)if(k.call(e,n))return!1;return!0}function wu(e,t){return sa(e,t)}function Tu(e,t,r){r=typeof r==`function`?r:n;var i=r?r(e,t):n;return i===n?sa(e,t,n,r):!!i}function Eu(e){if(!Y(e))return!1;var t=B(e);return t==we||t==Ce||typeof e.message==`string`&&typeof e.name==`string`&&!zu(e)}function Du(e){return typeof e==`number`&&dn(e)}function Ou(e){if(!J(e))return!1;var t=B(e);return t==Te||t==Ee||t==be||t==je}function ku(e){return typeof e==`number`&&e==X(e)}function Au(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=de}function J(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}function Y(e){return typeof e==`object`&&!!e}var ju=kn?cr(kn):la;function Mu(e,t){return e===t||ua(e,t,rs(t))}function Nu(e,t,r){return r=typeof r==`function`?r:n,ua(e,t,rs(t),r)}function Pu(e){return Ru(e)&&e!=+e}function Fu(e){if(xs(e))throw new Dt(a);return da(e)}function Iu(e){return e===null}function Lu(e){return e==null}function Ru(e){return typeof e==`number`||Y(e)&&B(e)==De}function zu(e){if(!Y(e)||B(e)!=ke)return!1;var t=qt(e);if(t===null)return!0;var n=k.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&It.call(n)==Bt}var Bu=An?cr(An):fa;function Vu(e){return ku(e)&&e>=-de&&e<=de}var Hu=jn?cr(jn):pa;function Uu(e){return typeof e==`string`||!K(e)&&Y(e)&&B(e)==Ne}function Wu(e){return typeof e==`symbol`||Y(e)&&B(e)==Pe}var Gu=Mn?cr(Mn):ma;function Ku(e){return e===n}function qu(e){return Y(e)&&W(e)==Ie}function Ju(e){return Y(e)&&B(e)==Le}var Yu=Ro(va),Xu=Ro(function(e,t){return e<=t});function Zu(e){if(!e)return[];if(vu(e))return Uu(e)?kr(e):H(e);if(Qt&&e[Qt])return br(e[Qt]());var t=W(e);return(t==w?xr:t==T?wr:Ud)(e)}function Qu(e){return e?(e=ed(e),e===C||e===-C?(e<0?-1:1)*fe:e===e?e:0):e===0?e:0}function X(e){var t=Qu(e),n=t%1;return t===t?n?t-n:t:0}function $u(e){return e?Mi(X(e),0,me):0}function ed(e){if(typeof e==`number`)return e;if(Wu(e))return pe;if(J(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=J(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=sr(e);var n=bt.test(e);return n||St.test(e)?bn(e.slice(2),n?2:8):yt.test(e)?pe:+e}function td(e){return _o(e,Td(e))}function nd(e){return e?Mi(X(e),-de,de):e===0?e:0}function Z(e){return e==null?``:Ka(e)}var rd=xo(function(e,t){if(Ss(t)||vu(t)){_o(t,Q(t),e);return}for(var n in t)k.call(t,n)&&Ti(e,n,t[n])}),id=xo(function(e,t){_o(t,Td(t),e)}),ad=xo(function(e,t,n,r){_o(t,Td(t),e,r)}),od=xo(function(e,t,n,r){_o(t,Q(t),e,r)}),sd=Xo(ji);function cd(e,t){var n=Vr(e);return t==null?n:Oi(n,t)}var ld=V(function(e,t){e=D(e);var r=-1,i=t.length,a=i>2?t[2]:n;for(a&&G(t[0],t[1],a)&&(i=1);++r<i;)for(var o=t[r],s=Td(o),c=-1,l=s.length;++c<l;){var u=s[c],d=e[u];(d===n||pu(d,Pt[u])&&!k.call(e,u))&&(e[u]=o[u])}return e}),ud=V(function(e){return e.push(n,Go),Nn(kd,n,e)});function dd(e,t){return Jn(e,U(t,3),Ki)}function fd(e,t){return Jn(e,U(t,3),qi)}function pd(e,t){return e==null?e:Wi(e,U(t,3),Td)}function md(e,t){return e==null?e:Gi(e,U(t,3),Td)}function hd(e,t){return e&&Ki(e,U(t,3))}function gd(e,t){return e&&qi(e,U(t,3))}function _d(e){return e==null?[]:Ji(e,Q(e))}function vd(e){return e==null?[]:Ji(e,Td(e))}function yd(e,t,r){var i=e==null?n:Yi(e,t);return i===n?r:i}function bd(e,t){return e!=null&&us(e,t,Qi)}function xd(e,t){return e!=null&&us(e,t,$i)}var Sd=Mo(function(e,t,n){t!=null&&typeof t.toString!=`function`&&(t=zt.call(t)),e[t]=n},kf($)),Cd=Mo(function(e,t,n){t!=null&&typeof t.toString!=`function`&&(t=zt.call(t)),k.call(e,t)?e[t].push(n):e[t]=[n]},U),wd=V(ra);function Q(e){return vu(e)?bi(e):ga(e)}function Td(e){return vu(e)?bi(e,!0):_a(e)}function Ed(e,t){var n={};return t=U(t,3),Ki(e,function(e,r,i){Ai(n,t(e,r,i),e)}),n}function Dd(e,t){var n={};return t=U(t,3),Ki(e,function(e,r,i){Ai(n,r,t(e,r,i))}),n}var Od=xo(function(e,t,n){Sa(e,t,n)}),kd=xo(function(e,t,n,r){Sa(e,t,n,r)}),Ad=Xo(function(e,t){var n={};if(e==null)return n;var r=!1;t=I(t,function(t){return t=no(t,e),r||=t.length>1,t}),_o(e,Qo(e),n),r&&(n=Ni(n,f|p|m,Ko));for(var i=t.length;i--;)Ja(n,t[i]);return n});function jd(e,t){return Nd(e,Xl(U(t)))}var Md=Xo(function(e,t){return e==null?{}:Ea(e,t)});function Nd(e,t){if(e==null)return{};var n=I(Qo(e),function(e){return[e]});return t=U(t),Da(e,n,function(e,n){return t(e,n[0])})}function Pd(e,t,r){t=no(t,e);var i=-1,a=t.length;for(a||(a=1,e=n);++i<a;){var o=e==null?n:e[Bs(t[i])];o===n&&(i=a,o=r),e=Ou(o)?o.call(e):o}return e}function Fd(e,t,n){return e==null?e:Ia(e,t,n)}function Id(e,t,r,i){return i=typeof i==`function`?i:n,e==null?e:Ia(e,t,r,i)}var Ld=Ho(Q),Rd=Ho(Td);function zd(e,t,n){var r=K(e),i=r||bu(e)||Gu(e);if(t=U(t,4),n==null){var a=e&&e.constructor;n=i?r?new a:[]:J(e)&&Ou(a)?Vr(qt(e)):{}}return(i?Fn:Ki)(e,function(e,r,i){return t(n,e,r,i)}),n}function Bd(e,t){return e==null?!0:Ja(e,t)}function Vd(e,t,n){return e==null?e:Ya(e,t,to(n))}function Hd(e,t,r,i){return i=typeof i==`function`?i:n,e==null?e:Ya(e,t,to(r),i)}function Ud(e){return e==null?[]:lr(e,Q(e))}function Wd(e){return e==null?[]:lr(e,Td(e))}function Gd(e,t,r){return r===n&&(r=t,t=n),r!==n&&(r=ed(r),r=r===r?r:0),t!==n&&(t=ed(t),t=t===t?t:0),Mi(ed(e),t,r)}function Kd(e,t,r){return t=Qu(t),r===n?(r=t,t=0):r=Qu(r),e=ed(e),ea(e,t,r)}function qd(e,t,r){if(r&&typeof r!=`boolean`&&G(e,t,r)&&(t=r=n),r===n&&(typeof t==`boolean`?(r=t,t=n):typeof e==`boolean`&&(r=e,e=n)),e===n&&t===n?(e=0,t=1):(e=Qu(e),t===n?(t=e,e=0):t=Qu(t)),e>t){var i=e;e=t,t=i}if(r||e%1||t%1){var a=vn();return N(e+a*(t-e+yn(`1e-`+((a+``).length-1))),t)}return ja(e,t)}var Jd=Eo(function(e,t,n){return t=t.toLowerCase(),e+(n?Yd(t):t)});function Yd(e){return Cf(Z(e).toLowerCase())}function Xd(e){return e=Z(e),e&&e.replace(wt,mr).replace(un,``)}function Zd(e,t,r){e=Z(e),t=Ka(t);var i=e.length;r=r===n?i:Mi(X(r),0,i);var a=r;return r-=t.length,r>=0&&e.slice(r,a)==t}function Qd(e){return e=Z(e),e&&tt.test(e)?e.replace($e,hr):e}function $d(e){return e=Z(e),e&&lt.test(e)?e.replace(ct,`\\$&`):e}var ef=Eo(function(e,t,n){return e+(n?`-`:``)+t.toLowerCase()}),tf=Eo(function(e,t,n){return e+(n?` `:``)+t.toLowerCase()}),nf=To(`toLowerCase`);function rf(e,t,n){e=Z(e),t=X(t);var r=t?Or(e):0;if(!t||r>=t)return e;var i=(t-r)/2;return Fo(on(i),n)+e+Fo(an(i),n)}function af(e,t,n){e=Z(e),t=X(t);var r=t?Or(e):0;return t&&r<t?e+Fo(t-r,n):e}function of(e,t,n){e=Z(e),t=X(t);var r=t?Or(e):0;return t&&r<t?Fo(t-r,n)+e:e}function sf(e,t,n){return n||t==null?t=0:t&&=+t,_n(Z(e).replace(ut,``),t||0)}function cf(e,t,r){return t=(r?G(e,t,r):t===n)?1:X(t),Na(Z(e),t)}function lf(){var e=arguments,t=Z(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var uf=Eo(function(e,t,n){return e+(n?`_`:``)+t.toLowerCase()});function df(e,t,r){return r&&typeof r!=`number`&&G(e,t,r)&&(t=r=n),r=r===n?me:r>>>0,r?(e=Z(e),e&&(typeof t==`string`||t!=null&&!Bu(t))&&(t=Ka(t),!t&&vr(e))?io(kr(e),0,r):e.split(t,r)):[]}var ff=Eo(function(e,t,n){return e+(n?` `:``)+Cf(t)});function pf(e,t,n){return e=Z(e),n=n==null?0:Mi(X(n),0,e.length),t=Ka(t),e.slice(n,n+t.length)==t}function mf(e,t,r){var i=L.templateSettings;r&&G(e,t,r)&&(t=n),e=Z(e),t=od({},t,i,Wo);var a=od({},t.imports,i.imports,Wo),o=Q(a),l=lr(a,o);Fn(o,function(e){if(ht.test(e))throw new Dt(c)});var u,d,f=0,p=t.interpolate||Tt,m=`__p += '`,h=At((t.escape||Tt).source+`|`+p.source+`|`+(p===it?_t:Tt).source+`|`+(t.evaluate||Tt).source+`|$`,`g`),g=`//# sourceURL=`+(k.call(t,`sourceURL`)?(t.sourceURL+``).replace(/\s/g,` `):`lodash.templateSources[`+ ++hn+`]`)+`
5
- `;e.replace(h,function(t,n,r,i,a,o){return r||=i,m+=e.slice(f,o).replace(Et,gr),n&&(u=!0,m+=`' +
4
+ `)}function gs(e){return G(e)||_u(e)||!!(Qt&&e&&e[Qt])}function _s(e,t){var n=typeof e;return t??=de,!!t&&(n==`number`||n!=`symbol`&&Ct.test(e))&&e>-1&&e%1==0&&e<t}function W(e,t,n){if(!J(n))return!1;var r=typeof t;return(r==`number`?K(n)&&_s(t,n.length):r==`string`&&t in n)?mu(n[t],e):!1}function vs(e,t){if(G(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||Wu(e)?!0:ot.test(e)||!at.test(e)||t!=null&&e in D(t)}function ys(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function bs(e){var t=ts(e),n=I[t];if(typeof n!=`function`||!(t in L.prototype))return!1;if(e===n)return!0;var r=es(n);return!!r&&e===r[0]}function xs(e){return!!zt&&zt in e}var Ss=It?Ou:Xf;function Cs(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||Ft)}function ws(e){return e===e&&!J(e)}function Ts(e,t){return function(r){return r==null?!1:r[e]===t&&(t!==n||e in D(r))}}function Es(e){var t=Xl(e,function(e){return n.size===u&&n.clear(),e}),n=t.cache;return t}function Ds(e,t){var n=e[1],r=t[1],i=n|r,a=i<(_|v|te),o=r==te&&n==b||r==te&&n==ne&&e[7].length<=t[8]||r==(te|ne)&&t[7].length<=t[8]&&n==b;if(!(a||o))return e;r&_&&(e[2]=t[2],i|=n&_?0:y);var s=t[3];if(s){var c=e[3];e[3]=c?go(c,s,t[4]):s,e[4]=c?wr(e[3],d):t[4]}return s=t[5],s&&(c=e[5],e[5]=c?_o(c,s,t[6]):s,e[6]=c?wr(e[5],d):t[6]),s=t[7],s&&(e[7]=s),r&te&&(e[8]=e[8]==null?t[8]:M(e[8],t[8])),e[9]??=t[9],e[0]=t[0],e[1]=i,e}function Os(e){var t=[];if(e!=null)for(var n in D(e))t.push(n);return t}function ks(e){return Bt.call(e)}function As(e,t,r){return t=k(t===n?e.length-1:t,0),function(){for(var n=arguments,i=-1,a=k(n.length-t,0),o=E(a);++i<a;)o[i]=n[t+i];i=-1;for(var s=E(t+1);++i<t;)s[i]=n[i];return s[t]=r(o),Pn(e,this,s)}}function js(e,t){return t.length<2?e:Xi(e,Va(t,0,-1))}function Ms(e,t){for(var r=e.length,i=M(t.length,r),a=V(e);i--;){var o=t[i];e[i]=_s(o,r)?a[o]:n}return e}function Ns(e,t){if(!(t===`constructor`&&typeof e[t]==`function`)&&t!=`__proto__`)return e[t]}var Ps=Rs(Ra),Fs=an||function(e,t){return N.setTimeout(e,t)},Is=Rs(za);function Ls(e,t,n){var r=t+``;return Is(e,hs(r,Us(us(r),n)))}function Rs(e){var t=0,r=0;return function(){var i=_n(),a=se-(i-r);if(r=i,a>0){if(++t>=oe)return arguments[0]}else t=0;return e.apply(n,arguments)}}function zs(e,t){var r=-1,i=e.length,a=i-1;for(t=t===n?i:t;++r<t;){var o=Ma(r,a),s=e[o];e[o]=e[r],e[r]=s}return e.length=t,e}var Bs=Es(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(st,function(e,n,r,i){t.push(r?i.replace(gt,`$1`):n||e)}),t});function Vs(e){if(typeof e==`string`||Wu(e))return e;var t=e+``;return t==`0`&&1/e==-C?`-0`:t}function Hs(e){if(e!=null){try{return Lt.call(e)}catch{}try{return e+``}catch{}}return``}function Us(e,t){return In(_e,function(n){var r=`_.`+n[0];t&n[1]&&!Bn(e,r)&&e.push(r)}),e.sort()}function Ws(e){if(e instanceof L)return e.clone();var t=new Wr(e.__wrapped__,e.__chain__);return t.__actions__=V(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}function Gs(e,t,r){t=(r?W(e,t,r):t===n)?1:k(X(t),0);var i=e==null?0:e.length;if(!i||t<1)return[];for(var a=0,o=0,s=E(on(i/t));a<i;)s[o++]=Va(e,a,a+=t);return s}function Ks(e){for(var t=-1,n=e==null?0:e.length,r=0,i=[];++t<n;){var a=e[t];a&&(i[r++]=a)}return i}function qs(){var e=arguments.length;if(!e)return[];for(var t=E(e-1),n=arguments[0],r=e;r--;)t[r-1]=arguments[r];return Hn(G(n)?V(n):[n],R(t,1))}var Js=B(function(e,t){return q(e)?Ri(e,R(t,1,q,!0)):[]}),Ys=B(function(e,t){var r=hc(t);return q(r)&&(r=n),q(e)?Ri(e,R(t,1,q,!0),H(r,2)):[]}),Xs=B(function(e,t){var r=hc(t);return q(r)&&(r=n),q(e)?Ri(e,R(t,1,q,!0),n,r):[]});function Zs(e,t,r){var i=e==null?0:e.length;return i?(t=r||t===n?1:X(t),Va(e,t<0?0:t,i)):[]}function Qs(e,t,r){var i=e==null?0:e.length;return i?(t=r||t===n?1:X(t),t=i-t,Va(e,0,t<0?0:t)):[]}function $s(e,t){return e&&e.length?Za(e,H(t,3),!0,!0):[]}function ec(e,t){return e&&e.length?Za(e,H(t,3),!0):[]}function tc(e,t,n,r){var i=e==null?0:e.length;return i?(n&&typeof n!=`number`&&W(e,t,n)&&(n=0,r=i),Ui(e,t,n,r)):[]}function nc(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:X(n);return i<0&&(i=k(r+i,0)),Xn(e,H(t,3),i)}function rc(e,t,r){var i=e==null?0:e.length;if(!i)return-1;var a=i-1;return r!==n&&(a=X(r),a=r<0?k(i+a,0):M(a,i-1)),Xn(e,H(t,3),a,!0)}function ic(e){return e!=null&&e.length?R(e,1):[]}function ac(e){return e!=null&&e.length?R(e,C):[]}function oc(e,t){return e!=null&&e.length?(t=t===n?1:X(t),R(e,t)):[]}function sc(e){for(var t=-1,n=e==null?0:e.length,r={};++t<n;){var i=e[t];ji(r,i[0],i[1])}return r}function cc(e){return e&&e.length?e[0]:n}function lc(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:X(n);return i<0&&(i=k(r+i,0)),Zn(e,t,i)}function uc(e){return e!=null&&e.length?Va(e,0,-1):[]}var dc=B(function(e){var t=F(e,to);return t.length&&t[0]===e[0]?na(t):[]}),fc=B(function(e){var t=hc(e),r=F(e,to);return t===hc(r)?t=n:r.pop(),r.length&&r[0]===e[0]?na(r,H(t,2)):[]}),pc=B(function(e){var t=hc(e),r=F(e,to);return t=typeof t==`function`?t:n,t&&r.pop(),r.length&&r[0]===e[0]?na(r,n,t):[]});function mc(e,t){return e==null?``:pn.call(e,t)}function hc(e){var t=e==null?0:e.length;return t?e[t-1]:n}function gc(e,t,r){var i=e==null?0:e.length;if(!i)return-1;var a=i;return r!==n&&(a=X(r),a=a<0?k(i+a,0):M(a,i-1)),t===t?Or(e,t,a):Xn(e,$n,a,!0)}function _c(e,t){return e&&e.length?Ta(e,X(t)):n}var vc=B(yc);function yc(e,t){return e&&e.length&&t&&t.length?Aa(e,t):e}function bc(e,t,n){return e&&e.length&&t&&t.length?Aa(e,t,H(n,2)):e}function xc(e,t,r){return e&&e.length&&t&&t.length?Aa(e,t,n,r):e}var Sc=Zo(function(e,t){var n=e==null?0:e.length,r=Mi(e,t);return ja(e,F(t,function(e){return _s(e,n)?+e:e}).sort(mo)),r});function Cc(e,t){var n=[];if(!(e&&e.length))return n;var r=-1,i=[],a=e.length;for(t=H(t,3);++r<a;){var o=e[r];t(o,r,e)&&(n.push(o),i.push(r))}return ja(e,i),n}function wc(e){return e==null?e:Sn.call(e)}function Tc(e,t,r){var i=e==null?0:e.length;return i?(r&&typeof r!=`number`&&W(e,t,r)?(t=0,r=i):(t=t==null?0:X(t),r=r===n?i:X(r)),Va(e,t,r)):[]}function Ec(e,t){return Ua(e,t)}function Dc(e,t,n){return Wa(e,t,H(n,2))}function Oc(e,t){var n=e==null?0:e.length;if(n){var r=Ua(e,t);if(r<n&&mu(e[r],t))return r}return-1}function kc(e,t){return Ua(e,t,!0)}function Ac(e,t,n){return Wa(e,t,H(n,2),!0)}function jc(e,t){if(e!=null&&e.length){var n=Ua(e,t,!0)-1;if(mu(e[n],t))return n}return-1}function Mc(e){return e&&e.length?Ga(e):[]}function Nc(e,t){return e&&e.length?Ga(e,H(t,2)):[]}function Pc(e){var t=e==null?0:e.length;return t?Va(e,1,t):[]}function Fc(e,t,r){return e&&e.length?(t=r||t===n?1:X(t),Va(e,0,t<0?0:t)):[]}function Ic(e,t,r){var i=e==null?0:e.length;return i?(t=r||t===n?1:X(t),t=i-t,Va(e,t<0?0:t,i)):[]}function Lc(e,t){return e&&e.length?Za(e,H(t,3),!1,!0):[]}function Rc(e,t){return e&&e.length?Za(e,H(t,3)):[]}var zc=B(function(e){return Ja(R(e,1,q,!0))}),Bc=B(function(e){var t=hc(e);return q(t)&&(t=n),Ja(R(e,1,q,!0),H(t,2))}),Vc=B(function(e){var t=hc(e);return t=typeof t==`function`?t:n,Ja(R(e,1,q,!0),n,t)});function Hc(e){return e&&e.length?Ja(e):[]}function Uc(e,t){return e&&e.length?Ja(e,H(t,2)):[]}function Wc(e,t){return t=typeof t==`function`?t:n,e&&e.length?Ja(e,n,t):[]}function Gc(e){if(!(e&&e.length))return[];var t=0;return e=zn(e,function(e){if(q(e))return t=k(e.length,t),!0}),or(t,function(t){return F(e,tr(t))})}function Kc(e,t){if(!(e&&e.length))return[];var r=Gc(e);return t==null?r:F(r,function(e){return Pn(t,n,e)})}var qc=B(function(e,t){return q(e)?Ri(e,t):[]}),Jc=B(function(e){return $a(zn(e,q))}),Yc=B(function(e){var t=hc(e);return q(t)&&(t=n),$a(zn(e,q),H(t,2))}),Xc=B(function(e){var t=hc(e);return t=typeof t==`function`?t:n,$a(zn(e,q),n,t)}),Zc=B(Gc);function Qc(e,t){return eo(e||[],t||[],Ei)}function $c(e,t){return eo(e||[],t||[],La)}var el=B(function(e){var t=e.length,r=t>1?e[t-1]:n;return r=typeof r==`function`?(e.pop(),r):n,Kc(e,r)});function tl(e){var t=I(e);return t.__chain__=!0,t}function nl(e,t){return t(e),e}function rl(e,t){return t(e)}var il=Zo(function(e){var t=e.length,r=t?e[0]:0,i=this.__wrapped__,a=function(t){return Mi(t,e)};return t>1||this.__actions__.length||!(i instanceof L)||!_s(r)?this.thru(a):(i=i.slice(r,+r+ +!!t),i.__actions__.push({func:rl,args:[a],thisArg:n}),new Wr(i,this.__chain__).thru(function(e){return t&&!e.length&&e.push(n),e}))});function al(){return tl(this)}function ol(){return new Wr(this.value(),this.__chain__)}function sl(){this.__values__===n&&(this.__values__=Zu(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?n:this.__values__[this.__index__++]}}function cl(){return this}function ll(e){for(var t,r=this;r instanceof Ur;){var i=Ws(r);i.__index__=0,i.__values__=n,t?a.__wrapped__=i:t=i;var a=i;r=r.__wrapped__}return a.__wrapped__=e,t}function ul(){var e=this.__wrapped__;if(e instanceof L){var t=e;return this.__actions__.length&&(t=new L(this)),t=t.reverse(),t.__actions__.push({func:rl,args:[wc],thisArg:n}),new Wr(t,this.__chain__)}return this.thru(wc)}function dl(){return Qa(this.__wrapped__,this.__actions__)}var fl=xo(function(e,t,n){O.call(e,n)?++e[n]:ji(e,n,1)});function pl(e,t,r){var i=G(e)?Rn:Vi;return r&&W(e,t,r)&&(t=n),i(e,H(t,3))}function ml(e,t){return(G(e)?zn:Wi)(e,H(t,3))}var hl=Ao(nc),gl=Ao(rc);function _l(e,t){return R(El(e,t),1)}function vl(e,t){return R(El(e,t),C)}function yl(e,t,r){return r=r===n?1:X(r),R(El(e,t),r)}function bl(e,t){return(G(e)?In:zi)(e,H(t,3))}function xl(e,t){return(G(e)?Ln:Bi)(e,H(t,3))}var Sl=xo(function(e,t,n){O.call(e,n)?e[n].push(t):ji(e,n,[t])});function Cl(e,t,n,r){e=K(e)?e:Ud(e),n=n&&!r?X(n):0;var i=e.length;return n<0&&(n=k(i+n,0)),Uu(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&Zn(e,t,n)>-1}var wl=B(function(e,t,n){var r=-1,i=typeof t==`function`,a=K(e)?E(e.length):[];return zi(e,function(e){a[++r]=i?Pn(t,e,n):ia(e,t,n)}),a}),Tl=xo(function(e,t,n){ji(e,n,t)});function El(e,t){return(G(e)?F:ba)(e,H(t,3))}function Dl(e,t,r,i){return e==null?[]:(G(t)||(t=t==null?[]:[t]),r=i?n:r,G(r)||(r=r==null?[]:[r]),Ea(e,t,r))}var Ol=xo(function(e,t,n){e[+!n].push(t)},function(){return[[],[]]});function kl(e,t,n){var r=G(e)?Un:rr,i=arguments.length<3;return r(e,H(t,4),n,i,zi)}function Al(e,t,n){var r=G(e)?Wn:rr,i=arguments.length<3;return r(e,H(t,4),n,i,Bi)}function jl(e,t){return(G(e)?zn:Wi)(e,Zl(H(t,3)))}function Ml(e){return(G(e)?Si:Fa)(e)}function Nl(e,t,r){return t=(r?W(e,t,r):t===n)?1:X(t),(G(e)?Ci:Ia)(e,t)}function Pl(e){return(G(e)?wi:Ba)(e)}function Fl(e){if(e==null)return 0;if(K(e))return Uu(e)?kr(e):e.length;var t=U(e);return t==w||t==T?e.size:_a(e).length}function Il(e,t,r){var i=G(e)?Gn:Ha;return r&&W(e,t,r)&&(t=n),i(e,H(t,3))}var Ll=B(function(e,t){if(e==null)return[];var n=t.length;return n>1&&W(e,t[0],t[1])?t=[]:n>2&&W(t[0],t[1],t[2])&&(t=[t[0]]),Ea(e,R(t,1),[])}),Rl=rn||function(){return N.Date.now()};function zl(e,t){if(typeof t!=`function`)throw new Mt(o);return e=X(e),function(){if(--e<1)return t.apply(this,arguments)}}function Bl(e,t,r){return t=r?n:t,t=e&&t==null?e.length:t,Wo(e,te,n,n,n,n,t)}function Vl(e,t){var r;if(typeof t!=`function`)throw new Mt(o);return e=X(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=n),r}}var Hl=B(function(e,t,n){var r=_;if(n.length){var i=wr(n,ns(Hl));r|=S}return Wo(e,r,t,n,i)}),Ul=B(function(e,t,n){var r=_|v;if(n.length){var i=wr(n,ns(Ul));r|=S}return Wo(t,r,e,n,i)});function Wl(e,t,r){t=r?n:t;var i=Wo(e,b,n,n,n,n,n,t);return i.placeholder=Wl.placeholder,i}function Gl(e,t,r){t=r?n:t;var i=Wo(e,x,n,n,n,n,n,t);return i.placeholder=Gl.placeholder,i}function Kl(e,t,r){var i,a,s,c,l,u,d=0,f=!1,p=!1,m=!0;if(typeof e!=`function`)throw new Mt(o);t=ed(t)||0,J(r)&&(f=!!r.leading,p=`maxWait`in r,s=p?k(ed(r.maxWait)||0,t):s,m=`trailing`in r?!!r.trailing:m);function h(t){var r=i,o=a;return i=a=n,d=t,c=e.apply(o,r),c}function g(e){return d=e,l=Fs(y,t),f?h(e):c}function _(e){var n=e-u,r=e-d,i=t-n;return p?M(i,s-r):i}function v(e){var r=e-u,i=e-d;return u===n||r>=t||r<0||p&&i>=s}function y(){var e=Rl();if(v(e))return b(e);l=Fs(y,_(e))}function b(e){return l=n,m&&i?h(e):(i=a=n,c)}function x(){l!==n&&oo(l),d=0,i=u=a=l=n}function S(){return l===n?c:b(Rl())}function ee(){var e=Rl(),r=v(e);if(i=arguments,a=this,u=e,r){if(l===n)return g(u);if(p)return oo(l),l=Fs(y,t),h(u)}return l===n&&(l=Fs(y,t)),c}return ee.cancel=x,ee.flush=S,ee}var ql=B(function(e,t){return Li(e,1,t)}),Jl=B(function(e,t,n){return Li(e,ed(t)||0,n)});function Yl(e){return Wo(e,re)}function Xl(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw new Mt(o);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(Xl.Cache||oi),n}Xl.Cache=oi;function Zl(e){if(typeof e!=`function`)throw new Mt(o);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}function Ql(e){return Vl(2,e)}var $l=io(function(e,t){t=t.length==1&&G(t[0])?F(t[0],lr(H())):F(R(t,1),lr(H()));var n=t.length;return B(function(r){for(var i=-1,a=M(r.length,n);++i<a;)r[i]=t[i].call(this,r[i]);return Pn(e,this,r)})}),eu=B(function(e,t){return Wo(e,S,n,t,wr(t,ns(eu)))}),tu=B(function(e,t){return Wo(e,ee,n,t,wr(t,ns(tu)))}),nu=Zo(function(e,t){return Wo(e,ne,n,n,n,t)});function ru(e,t){if(typeof e!=`function`)throw new Mt(o);return t=t===n?t:X(t),B(e,t)}function iu(e,t){if(typeof e!=`function`)throw new Mt(o);return t=t==null?0:k(X(t),0),B(function(n){var r=n[t],i=ao(n,0,t);return r&&Hn(i,r),Pn(e,this,i)})}function au(e,t,n){var r=!0,i=!0;if(typeof e!=`function`)throw new Mt(o);return J(n)&&(r=`leading`in n?!!n.leading:r,i=`trailing`in n?!!n.trailing:i),Kl(e,t,{leading:r,maxWait:t,trailing:i})}function ou(e){return Bl(e,1)}function su(e,t){return eu(no(t),e)}function cu(){if(!arguments.length)return[];var e=arguments[0];return G(e)?e:[e]}function lu(e){return Pi(e,m)}function uu(e,t){return t=typeof t==`function`?t:n,Pi(e,m,t)}function du(e){return Pi(e,f|m)}function fu(e,t){return t=typeof t==`function`?t:n,Pi(e,f|m,t)}function pu(e,t){return t==null||Ii(e,t,Q(t))}function mu(e,t){return e===t||e!==e&&t!==t}var hu=zo(Qi),gu=zo(function(e,t){return e>=t}),_u=aa(function(){return arguments}())?aa:function(e){return Y(e)&&O.call(e,`callee`)&&!Xt.call(e,`callee`)},G=E.isArray,vu=On?lr(On):oa;function K(e){return e!=null&&Au(e.length)&&!Ou(e)}function q(e){return Y(e)&&K(e)}function yu(e){return e===!0||e===!1||Y(e)&&z(e)==xe}var bu=ln||Xf,xu=kn?lr(kn):sa;function Su(e){return Y(e)&&e.nodeType===1&&!zu(e)}function Cu(e){if(e==null)return!0;if(K(e)&&(G(e)||typeof e==`string`||typeof e.splice==`function`||bu(e)||Gu(e)||_u(e)))return!e.length;var t=U(e);if(t==w||t==T)return!e.size;if(Cs(e))return!_a(e).length;for(var n in e)if(O.call(e,n))return!1;return!0}function wu(e,t){return ca(e,t)}function Tu(e,t,r){r=typeof r==`function`?r:n;var i=r?r(e,t):n;return i===n?ca(e,t,n,r):!!i}function Eu(e){if(!Y(e))return!1;var t=z(e);return t==we||t==Ce||typeof e.message==`string`&&typeof e.name==`string`&&!zu(e)}function Du(e){return typeof e==`number`&&fn(e)}function Ou(e){if(!J(e))return!1;var t=z(e);return t==Te||t==Ee||t==be||t==je}function ku(e){return typeof e==`number`&&e==X(e)}function Au(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=de}function J(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}function Y(e){return typeof e==`object`&&!!e}var ju=An?lr(An):ua;function Mu(e,t){return e===t||da(e,t,is(t))}function Nu(e,t,r){return r=typeof r==`function`?r:n,da(e,t,is(t),r)}function Pu(e){return Ru(e)&&e!=+e}function Fu(e){if(Ss(e))throw new Dt(a);return fa(e)}function Iu(e){return e===null}function Lu(e){return e==null}function Ru(e){return typeof e==`number`||Y(e)&&z(e)==De}function zu(e){if(!Y(e)||z(e)!=ke)return!1;var t=Jt(e);if(t===null)return!0;var n=O.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&Lt.call(n)==Vt}var Bu=jn?lr(jn):pa;function Vu(e){return ku(e)&&e>=-de&&e<=de}var Hu=Mn?lr(Mn):ma;function Uu(e){return typeof e==`string`||!G(e)&&Y(e)&&z(e)==Ne}function Wu(e){return typeof e==`symbol`||Y(e)&&z(e)==Pe}var Gu=Nn?lr(Nn):ha;function Ku(e){return e===n}function qu(e){return Y(e)&&U(e)==Ie}function Ju(e){return Y(e)&&z(e)==Le}var Yu=zo(ya),Xu=zo(function(e,t){return e<=t});function Zu(e){if(!e)return[];if(K(e))return Uu(e)?Ar(e):V(e);if($t&&e[$t])return xr(e[$t]());var t=U(e);return(t==w?Sr:t==T?Tr:Ud)(e)}function Qu(e){return e?(e=ed(e),e===C||e===-C?(e<0?-1:1)*fe:e===e?e:0):e===0?e:0}function X(e){var t=Qu(e),n=t%1;return t===t?n?t-n:t:0}function $u(e){return e?Ni(X(e),0,me):0}function ed(e){if(typeof e==`number`)return e;if(Wu(e))return pe;if(J(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=J(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=cr(e);var n=bt.test(e);return n||St.test(e)?xn(e.slice(2),n?2:8):yt.test(e)?pe:+e}function td(e){return vo(e,Td(e))}function nd(e){return e?Ni(X(e),-de,de):e===0?e:0}function Z(e){return e==null?``:qa(e)}var rd=So(function(e,t){if(Cs(t)||K(t)){vo(t,Q(t),e);return}for(var n in t)O.call(t,n)&&Ei(e,n,t[n])}),id=So(function(e,t){vo(t,Td(t),e)}),ad=So(function(e,t,n,r){vo(t,Td(t),e,r)}),od=So(function(e,t,n,r){vo(t,Q(t),e,r)}),sd=Zo(Mi);function cd(e,t){var n=Hr(e);return t==null?n:ki(n,t)}var ld=B(function(e,t){e=D(e);var r=-1,i=t.length,a=i>2?t[2]:n;for(a&&W(t[0],t[1],a)&&(i=1);++r<i;)for(var o=t[r],s=Td(o),c=-1,l=s.length;++c<l;){var u=s[c],d=e[u];(d===n||mu(d,Ft[u])&&!O.call(e,u))&&(e[u]=o[u])}return e}),ud=B(function(e){return e.push(n,Ko),Pn(kd,n,e)});function dd(e,t){return Yn(e,H(t,3),qi)}function fd(e,t){return Yn(e,H(t,3),Ji)}function pd(e,t){return e==null?e:Gi(e,H(t,3),Td)}function md(e,t){return e==null?e:Ki(e,H(t,3),Td)}function hd(e,t){return e&&qi(e,H(t,3))}function gd(e,t){return e&&Ji(e,H(t,3))}function _d(e){return e==null?[]:Yi(e,Q(e))}function vd(e){return e==null?[]:Yi(e,Td(e))}function yd(e,t,r){var i=e==null?n:Xi(e,t);return i===n?r:i}function bd(e,t){return e!=null&&ds(e,t,$i)}function xd(e,t){return e!=null&&ds(e,t,ea)}var Sd=No(function(e,t,n){t!=null&&typeof t.toString!=`function`&&(t=Bt.call(t)),e[t]=n},kf($)),Cd=No(function(e,t,n){t!=null&&typeof t.toString!=`function`&&(t=Bt.call(t)),O.call(e,t)?e[t].push(n):e[t]=[n]},H),wd=B(ia);function Q(e){return K(e)?xi(e):_a(e)}function Td(e){return K(e)?xi(e,!0):va(e)}function Ed(e,t){var n={};return t=H(t,3),qi(e,function(e,r,i){ji(n,t(e,r,i),e)}),n}function Dd(e,t){var n={};return t=H(t,3),qi(e,function(e,r,i){ji(n,r,t(e,r,i))}),n}var Od=So(function(e,t,n){Ca(e,t,n)}),kd=So(function(e,t,n,r){Ca(e,t,n,r)}),Ad=Zo(function(e,t){var n={};if(e==null)return n;var r=!1;t=F(t,function(t){return t=ro(t,e),r||=t.length>1,t}),vo(e,$o(e),n),r&&(n=Pi(n,f|p|m,qo));for(var i=t.length;i--;)Ya(n,t[i]);return n});function jd(e,t){return Nd(e,Zl(H(t)))}var Md=Zo(function(e,t){return e==null?{}:Da(e,t)});function Nd(e,t){if(e==null)return{};var n=F($o(e),function(e){return[e]});return t=H(t),Oa(e,n,function(e,n){return t(e,n[0])})}function Pd(e,t,r){t=ro(t,e);var i=-1,a=t.length;for(a||(a=1,e=n);++i<a;){var o=e==null?n:e[Vs(t[i])];o===n&&(i=a,o=r),e=Ou(o)?o.call(e):o}return e}function Fd(e,t,n){return e==null?e:La(e,t,n)}function Id(e,t,r,i){return i=typeof i==`function`?i:n,e==null?e:La(e,t,r,i)}var Ld=Uo(Q),Rd=Uo(Td);function zd(e,t,n){var r=G(e),i=r||bu(e)||Gu(e);if(t=H(t,4),n==null){var a=e&&e.constructor;n=i?r?new a:[]:J(e)&&Ou(a)?Hr(Jt(e)):{}}return(i?In:qi)(e,function(e,r,i){return t(n,e,r,i)}),n}function Bd(e,t){return e==null?!0:Ya(e,t)}function Vd(e,t,n){return e==null?e:Xa(e,t,no(n))}function Hd(e,t,r,i){return i=typeof i==`function`?i:n,e==null?e:Xa(e,t,no(r),i)}function Ud(e){return e==null?[]:ur(e,Q(e))}function Wd(e){return e==null?[]:ur(e,Td(e))}function Gd(e,t,r){return r===n&&(r=t,t=n),r!==n&&(r=ed(r),r=r===r?r:0),t!==n&&(t=ed(t),t=t===t?t:0),Ni(ed(e),t,r)}function Kd(e,t,r){return t=Qu(t),r===n?(r=t,t=0):r=Qu(r),e=ed(e),ta(e,t,r)}function qd(e,t,r){if(r&&typeof r!=`boolean`&&W(e,t,r)&&(t=r=n),r===n&&(typeof t==`boolean`?(r=t,t=n):typeof e==`boolean`&&(r=e,e=n)),e===n&&t===n?(e=0,t=1):(e=Qu(e),t===n?(t=e,e=0):t=Qu(t)),e>t){var i=e;e=t,t=i}if(r||e%1||t%1){var a=yn();return M(e+a*(t-e+bn(`1e-`+((a+``).length-1))),t)}return Ma(e,t)}var Jd=Do(function(e,t,n){return t=t.toLowerCase(),e+(n?Yd(t):t)});function Yd(e){return Cf(Z(e).toLowerCase())}function Xd(e){return e=Z(e),e&&e.replace(wt,hr).replace(dn,``)}function Zd(e,t,r){e=Z(e),t=qa(t);var i=e.length;r=r===n?i:Ni(X(r),0,i);var a=r;return r-=t.length,r>=0&&e.slice(r,a)==t}function Qd(e){return e=Z(e),e&&tt.test(e)?e.replace($e,gr):e}function $d(e){return e=Z(e),e&&lt.test(e)?e.replace(ct,`\\$&`):e}var ef=Do(function(e,t,n){return e+(n?`-`:``)+t.toLowerCase()}),tf=Do(function(e,t,n){return e+(n?` `:``)+t.toLowerCase()}),nf=Eo(`toLowerCase`);function rf(e,t,n){e=Z(e),t=X(t);var r=t?kr(e):0;if(!t||r>=t)return e;var i=(t-r)/2;return Io(sn(i),n)+e+Io(on(i),n)}function af(e,t,n){e=Z(e),t=X(t);var r=t?kr(e):0;return t&&r<t?e+Io(t-r,n):e}function of(e,t,n){e=Z(e),t=X(t);var r=t?kr(e):0;return t&&r<t?Io(t-r,n)+e:e}function sf(e,t,n){return n||t==null?t=0:t&&=+t,vn(Z(e).replace(ut,``),t||0)}function cf(e,t,r){return t=(r?W(e,t,r):t===n)?1:X(t),Pa(Z(e),t)}function lf(){var e=arguments,t=Z(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var uf=Do(function(e,t,n){return e+(n?`_`:``)+t.toLowerCase()});function df(e,t,r){return r&&typeof r!=`number`&&W(e,t,r)&&(t=r=n),r=r===n?me:r>>>0,r?(e=Z(e),e&&(typeof t==`string`||t!=null&&!Bu(t))&&(t=qa(t),!t&&yr(e))?ao(Ar(e),0,r):e.split(t,r)):[]}var ff=Do(function(e,t,n){return e+(n?` `:``)+Cf(t)});function pf(e,t,n){return e=Z(e),n=n==null?0:Ni(X(n),0,e.length),t=qa(t),e.slice(n,n+t.length)==t}function mf(e,t,r){var i=I.templateSettings;r&&W(e,t,r)&&(t=n),e=Z(e),t=od({},t,i,Go);var a=od({},t.imports,i.imports,Go),o=Q(a),l=ur(a,o);In(o,function(e){if(ht.test(e))throw new Dt(c)});var u,d,f=0,p=t.interpolate||Tt,m=`__p += '`,h=At((t.escape||Tt).source+`|`+p.source+`|`+(p===it?_t:Tt).source+`|`+(t.evaluate||Tt).source+`|$`,`g`),g=`//# sourceURL=`+(O.call(t,`sourceURL`)?(t.sourceURL+``).replace(/\s/g,` `):`lodash.templateSources[`+ ++gn+`]`)+`
5
+ `;e.replace(h,function(t,n,r,i,a,o){return r||=i,m+=e.slice(f,o).replace(Et,_r),n&&(u=!0,m+=`' +
6
6
  __e(`+n+`) +
7
7
  '`),a&&(d=!0,m+=`';
8
8
  `+a+`;
9
9
  __p += '`),r&&(m+=`' +
10
10
  ((__t = (`+r+`)) == null ? '' : __t) +
11
11
  '`),f=o+t.length,t}),m+=`';
12
- `;var _=k.call(t,`variable`)&&t.variable;if(!_)m=`with (obj) {
12
+ `;var _=O.call(t,`variable`)&&t.variable;if(!_)m=`with (obj) {
13
13
  `+m+`
14
14
  }
15
15
  `;else if(ht.test(_))throw new Dt(s);m=(d?m.replace(Ye,``):m).replace(Xe,`$1`).replace(Ze,`$1;`),m=`function(`+(_||`obj`)+`) {
@@ -18,9 +18,9 @@ __p += '`),r&&(m+=`' +
18
18
  function print() { __p += __j.call(arguments, '') }
19
19
  `:`;
20
20
  `)+m+`return __p
21
- }`;var v=Tf(function(){return Ot(o,g+`return `+m).apply(n,l)});if(v.source=m,Eu(v))throw v;return v}function hf(e){return Z(e).toLowerCase()}function gf(e){return Z(e).toUpperCase()}function _f(e,t,r){if(e=Z(e),e&&(r||t===n))return sr(e);if(!e||!(t=Ka(t)))return e;var i=kr(e),a=kr(t);return io(i,dr(i,a),fr(i,a)+1).join(``)}function vf(e,t,r){if(e=Z(e),e&&(r||t===n))return e.slice(0,Ar(e)+1);if(!e||!(t=Ka(t)))return e;var i=kr(e);return io(i,0,fr(i,kr(t))+1).join(``)}function yf(e,t,r){if(e=Z(e),e&&(r||t===n))return e.replace(ut,``);if(!e||!(t=Ka(t)))return e;var i=kr(e);return io(i,dr(i,kr(t))).join(``)}function bf(e,t){var r=ie,i=ae;if(J(t)){var a=`separator`in t?t.separator:a;r=`length`in t?X(t.length):r,i=`omission`in t?Ka(t.omission):i}e=Z(e);var o=e.length;if(vr(e)){var s=kr(e);o=s.length}if(r>=o)return e;var c=r-Or(i);if(c<1)return i;var l=s?io(s,0,c).join(``):e.slice(0,c);if(a===n)return l+i;if(s&&(c+=l.length-c),Bu(a)){if(e.slice(c).search(a)){var u,d=l;for(a.global||(a=At(a.source,Z(vt.exec(a))+`g`)),a.lastIndex=0;u=a.exec(d);)var f=u.index;l=l.slice(0,f===n?c:f)}}else if(e.indexOf(Ka(a),c)!=c){var p=l.lastIndexOf(a);p>-1&&(l=l.slice(0,p))}return l+i}function xf(e){return e=Z(e),e&&et.test(e)?e.replace(Qe,jr):e}var Sf=Eo(function(e,t,n){return e+(n?` `:``)+t.toUpperCase()}),Cf=To(`toUpperCase`);function wf(e,t,r){return e=Z(e),t=r?n:t,t===n?yr(e)?Pr(e):qn(e):e.match(t)||[]}var Tf=V(function(e,t){try{return Nn(e,n,t)}catch(e){return Eu(e)?e:new Dt(e)}}),Ef=Xo(function(e,t){return Fn(t,function(t){t=Bs(t),Ai(e,t,Vl(e[t],e))}),e});function Df(e){var t=e==null?0:e.length,n=U();return e=t?I(e,function(e){if(typeof e[1]!=`function`)throw new O(o);return[n(e[0]),e[1]]}):[],V(function(n){for(var r=-1;++r<t;){var i=e[r];if(Nn(i[0],this,n))return Nn(i[1],this,n)}})}function Of(e){return Pi(Ni(e,f))}function kf(e){return function(){return e}}function Af(e,t){return e==null||e!==e?t:e}var jf=Ao(),Mf=Ao(!0);function $(e){return e}function Nf(e){return ha(typeof e==`function`?e:Ni(e,f))}function Pf(e){return ba(Ni(e,f))}function Ff(e,t){return xa(e,Ni(t,f))}var If=V(function(e,t){return function(n){return ra(n,e,t)}}),Lf=V(function(e,t){return function(n){return ra(e,n,t)}});function Rf(e,t,n){var r=Q(t),i=Ji(t,r);n==null&&!(J(t)&&(i.length||!r.length))&&(n=t,t=e,e=this,i=Ji(t,Q(t)));var a=!(J(n)&&`chain`in n)||!!n.chain,o=Ou(e);return Fn(i,function(n){var r=t[n];e[n]=r,o&&(e.prototype[n]=function(){var t=this.__chain__;if(a||t){var n=e(this.__wrapped__);return(n.__actions__=H(this.__actions__)).push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,Vn([this.value()],arguments))})}),e}function zf(){return P._===this&&(P._=Vt),this}function Bf(){}function Vf(e){return e=X(e),V(function(t){return wa(t,e)})}var Hf=Po(I),Uf=Po(Ln),Wf=Po(Wn);function Gf(e){return _s(e)?er(Bs(e)):Oa(e)}function Kf(e){return function(t){return e==null?n:Yi(e,t)}}var qf=Lo(),Jf=Lo(!0);function Yf(){return[]}function Xf(){return!1}function Zf(){return{}}function Qf(){return``}function $f(){return!0}function ep(e,t){if(e=X(e),e<1||e>de)return[];var n=me,r=N(e,me);t=U(t),e-=me;for(var i=ar(r,t);++n<e;)t(n);return i}function tp(e){return K(e)?I(e,Bs):Wu(e)?[e]:H(zs(Z(e)))}function np(e){var t=++Lt;return Z(e)+t}var rp=No(function(e,t){return e+t},0),ip=Bo(`ceil`),ap=No(function(e,t){return e/t},1),op=Bo(`floor`);function sp(e){return e&&e.length?Vi(e,$,Zi):n}function cp(e,t){return e&&e.length?Vi(e,U(t,2),Zi):n}function lp(e){return $n(e,$)}function up(e,t){return $n(e,U(t,2))}function dp(e){return e&&e.length?Vi(e,$,va):n}function fp(e,t){return e&&e.length?Vi(e,U(t,2),va):n}var pp=No(function(e,t){return e*t},1),mp=Bo(`round`),hp=No(function(e,t){return e-t},0);function gp(e){return e&&e.length?ir(e,$):0}function _p(e,t){return e&&e.length?ir(e,U(t,2)):0}return L.after=Rl,L.ary=zl,L.assign=rd,L.assignIn=id,L.assignInWith=ad,L.assignWith=od,L.at=sd,L.before=Bl,L.bind=Vl,L.bindAll=Ef,L.bindKey=Hl,L.castArray=su,L.chain=el,L.chunk=Ws,L.compact=Gs,L.concat=Ks,L.cond=Df,L.conforms=Of,L.constant=kf,L.countBy=dl,L.create=cd,L.curry=Ul,L.curryRight=Wl,L.debounce=Gl,L.defaults=ld,L.defaultsDeep=ud,L.defer=Kl,L.delay=ql,L.difference=qs,L.differenceBy=Js,L.differenceWith=Ys,L.drop=Xs,L.dropRight=Zs,L.dropRightWhile=Qs,L.dropWhile=$s,L.fill=ec,L.filter=pl,L.flatMap=gl,L.flatMapDeep=_l,L.flatMapDepth=vl,L.flatten=rc,L.flattenDeep=ic,L.flattenDepth=ac,L.flip=Jl,L.flow=jf,L.flowRight=Mf,L.fromPairs=oc,L.functions=_d,L.functionsIn=vd,L.groupBy=xl,L.initial=lc,L.intersection=uc,L.intersectionBy=dc,L.intersectionWith=fc,L.invert=Sd,L.invertBy=Cd,L.invokeMap=Cl,L.iteratee=Nf,L.keyBy=wl,L.keys=Q,L.keysIn=Td,L.map=Tl,L.mapKeys=Ed,L.mapValues=Dd,L.matches=Pf,L.matchesProperty=Ff,L.memoize=Yl,L.merge=Od,L.mergeWith=kd,L.method=If,L.methodOf=Lf,L.mixin=Rf,L.negate=Xl,L.nthArg=Vf,L.omit=Ad,L.omitBy=jd,L.once=Zl,L.orderBy=El,L.over=Hf,L.overArgs=Ql,L.overEvery=Uf,L.overSome=Wf,L.partial=$l,L.partialRight=eu,L.partition=Dl,L.pick=Md,L.pickBy=Nd,L.property=Gf,L.propertyOf=Kf,L.pull=_c,L.pullAll=vc,L.pullAllBy=yc,L.pullAllWith=bc,L.pullAt=xc,L.range=qf,L.rangeRight=Jf,L.rearg=tu,L.reject=Al,L.remove=Sc,L.rest=nu,L.reverse=Cc,L.sampleSize=Ml,L.set=Fd,L.setWith=Id,L.shuffle=Nl,L.slice=wc,L.sortBy=Il,L.sortedUniq=jc,L.sortedUniqBy=Mc,L.split=df,L.spread=ru,L.tail=Nc,L.take=Pc,L.takeRight=Fc,L.takeRightWhile=Ic,L.takeWhile=Lc,L.tap=tl,L.throttle=iu,L.thru=nl,L.toArray=Zu,L.toPairs=Ld,L.toPairsIn=Rd,L.toPath=tp,L.toPlainObject=td,L.transform=zd,L.unary=au,L.union=Rc,L.unionBy=zc,L.unionWith=Bc,L.uniq=Vc,L.uniqBy=Hc,L.uniqWith=Uc,L.unset=Bd,L.unzip=Wc,L.unzipWith=Gc,L.update=Vd,L.updateWith=Hd,L.values=Ud,L.valuesIn=Wd,L.without=Kc,L.words=wf,L.wrap=ou,L.xor=qc,L.xorBy=Jc,L.xorWith=Yc,L.zip=Xc,L.zipObject=Zc,L.zipObjectDeep=Qc,L.zipWith=$c,L.entries=Ld,L.entriesIn=Rd,L.extend=id,L.extendWith=ad,Rf(L,L),L.add=rp,L.attempt=Tf,L.camelCase=Jd,L.capitalize=Yd,L.ceil=ip,L.clamp=Gd,L.clone=cu,L.cloneDeep=uu,L.cloneDeepWith=du,L.cloneWith=lu,L.conformsTo=fu,L.deburr=Xd,L.defaultTo=Af,L.divide=ap,L.endsWith=Zd,L.eq=pu,L.escape=Qd,L.escapeRegExp=$d,L.every=fl,L.find=ml,L.findIndex=tc,L.findKey=dd,L.findLast=hl,L.findLastIndex=nc,L.findLastKey=fd,L.floor=op,L.forEach=yl,L.forEachRight=bl,L.forIn=pd,L.forInRight=md,L.forOwn=hd,L.forOwnRight=gd,L.get=yd,L.gt=mu,L.gte=hu,L.has=bd,L.hasIn=xd,L.head=sc,L.identity=$,L.includes=Sl,L.indexOf=cc,L.inRange=Kd,L.invoke=wd,L.isArguments=gu,L.isArray=K,L.isArrayBuffer=_u,L.isArrayLike=vu,L.isArrayLikeObject=q,L.isBoolean=yu,L.isBuffer=bu,L.isDate=xu,L.isElement=Su,L.isEmpty=Cu,L.isEqual=wu,L.isEqualWith=Tu,L.isError=Eu,L.isFinite=Du,L.isFunction=Ou,L.isInteger=ku,L.isLength=Au,L.isMap=ju,L.isMatch=Mu,L.isMatchWith=Nu,L.isNaN=Pu,L.isNative=Fu,L.isNil=Lu,L.isNull=Iu,L.isNumber=Ru,L.isObject=J,L.isObjectLike=Y,L.isPlainObject=zu,L.isRegExp=Bu,L.isSafeInteger=Vu,L.isSet=Hu,L.isString=Uu,L.isSymbol=Wu,L.isTypedArray=Gu,L.isUndefined=Ku,L.isWeakMap=qu,L.isWeakSet=Ju,L.join=pc,L.kebabCase=ef,L.last=mc,L.lastIndexOf=hc,L.lowerCase=tf,L.lowerFirst=nf,L.lt=Yu,L.lte=Xu,L.max=sp,L.maxBy=cp,L.mean=lp,L.meanBy=up,L.min=dp,L.minBy=fp,L.stubArray=Yf,L.stubFalse=Xf,L.stubObject=Zf,L.stubString=Qf,L.stubTrue=$f,L.multiply=pp,L.nth=gc,L.noConflict=zf,L.noop=Bf,L.now=Ll,L.pad=rf,L.padEnd=af,L.padStart=of,L.parseInt=sf,L.random=qd,L.reduce=Ol,L.reduceRight=kl,L.repeat=cf,L.replace=lf,L.result=Pd,L.round=mp,L.runInContext=e,L.sample=jl,L.size=Pl,L.snakeCase=uf,L.some=Fl,L.sortedIndex=Tc,L.sortedIndexBy=Ec,L.sortedIndexOf=Dc,L.sortedLastIndex=Oc,L.sortedLastIndexBy=kc,L.sortedLastIndexOf=Ac,L.startCase=ff,L.startsWith=pf,L.subtract=hp,L.sum=gp,L.sumBy=_p,L.template=mf,L.times=ep,L.toFinite=Qu,L.toInteger=X,L.toLength=$u,L.toLower=hf,L.toNumber=ed,L.toSafeInteger=nd,L.toString=Z,L.toUpper=gf,L.trim=_f,L.trimEnd=vf,L.trimStart=yf,L.truncate=bf,L.unescape=xf,L.uniqueId=np,L.upperCase=Sf,L.upperFirst=Cf,L.each=yl,L.eachRight=bl,L.first=sc,Rf(L,function(){var e={};return Ki(L,function(t,n){k.call(L.prototype,n)||(e[n]=t)}),e}(),{chain:!1}),L.VERSION=r,Fn([`bind`,`bindKey`,`curry`,`curryRight`,`partial`,`partialRight`],function(e){L[e].placeholder=L}),Fn([`drop`,`take`],function(e,t){R.prototype[e]=function(r){r=r===n?1:A(X(r),0);var i=this.__filtered__&&!t?new R(this):this.clone();return i.__filtered__?i.__takeCount__=N(r,i.__takeCount__):i.__views__.push({size:N(r,me),type:e+(i.__dir__<0?`Right`:``)}),i},R.prototype[e+`Right`]=function(t){return this.reverse()[e](t).reverse()}}),Fn([`filter`,`map`,`takeWhile`],function(e,t){var n=t+1,r=n==ce||n==ue;R.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:U(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}}),Fn([`head`,`last`],function(e,t){var n=`take`+(t?`Right`:``);R.prototype[e]=function(){return this[n](1).value()[0]}}),Fn([`initial`,`tail`],function(e,t){var n=`drop`+(t?``:`Right`);R.prototype[e]=function(){return this.__filtered__?new R(this):this[n](1)}}),R.prototype.compact=function(){return this.filter($)},R.prototype.find=function(e){return this.filter(e).head()},R.prototype.findLast=function(e){return this.reverse().find(e)},R.prototype.invokeMap=V(function(e,t){return typeof e==`function`?new R(this):this.map(function(n){return ra(n,e,t)})}),R.prototype.reject=function(e){return this.filter(Xl(U(e)))},R.prototype.slice=function(e,t){e=X(e);var r=this;return r.__filtered__&&(e>0||t<0)?new R(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==n&&(t=X(t),r=t<0?r.dropRight(-t):r.take(t-e)),r)},R.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},R.prototype.toArray=function(){return this.take(me)},Ki(R.prototype,function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),a=L[i?`take`+(t==`last`?`Right`:``):t],o=i||/^find/.test(t);a&&(L.prototype[t]=function(){var t=this.__wrapped__,s=i?[1]:arguments,c=t instanceof R,l=s[0],u=c||K(t),d=function(e){var t=a.apply(L,Vn([e],s));return i&&f?t[0]:t};u&&r&&typeof l==`function`&&l.length!=1&&(c=u=!1);var f=this.__chain__,p=!!this.__actions__.length,m=o&&!f,h=c&&!p;if(!o&&u){t=h?t:new R(this);var g=e.apply(t,s);return g.__actions__.push({func:nl,args:[d],thisArg:n}),new Ur(g,f)}return m&&h?e.apply(this,s):(g=this.thru(d),m?i?g.value()[0]:g.value():g)})}),Fn([`pop`,`push`,`shift`,`sort`,`splice`,`unshift`],function(e){var t=Mt[e],n=/^(?:push|sort|unshift)$/.test(e)?`tap`:`thru`,r=/^(?:pop|shift)$/.test(e);L.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(K(i)?i:[],e)}return this[n](function(n){return t.apply(K(n)?n:[],e)})}}),Ki(R.prototype,function(e,t){var n=L[t];if(n){var r=n.name+``;k.call(tr,r)||(tr[r]=[]),tr[r].push({name:t,func:n})}}),tr[jo(n,v).name]=[{name:`wrapper`,func:n}],R.prototype.clone=Wr,R.prototype.reverse=Gr,R.prototype.value=Kr,L.prototype.at=rl,L.prototype.chain=il,L.prototype.commit=al,L.prototype.next=ol,L.prototype.plant=cl,L.prototype.reverse=ll,L.prototype.toJSON=L.prototype.valueOf=L.prototype.value=ul,L.prototype.first=L.prototype.head,Qt&&(L.prototype[Qt]=sl),L})();typeof define==`function`&&typeof define.amd==`object`&&define.amd?(P._=Fr,define(function(){return Fr})):wn?((wn.exports=Fr)._=Fr,Cn._=Fr):P._=Fr}).call(e)}))(),ne=e=>{let t=(0,te.startCase)(e).toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)},re=[`src/application.config.ts`,`src/application-config.ts`,`src/applicationConfig.ts`],ie=/serverVariables\s*:\s*\{/,ae=/defineApplication\s*\(\s*\{/,oe=async({projectRoot:e,variables:t})=>{let n=await se(e);if(n===null)return{status:`skipped-no-config`};let r=await(0,i.readFile)(n,`utf8`),a=t.filter(e=>!RegExp(`\\b${e.name}\\s*:`).test(r));if(a.length===0)return{status:`skipped-existing`};let o=ce(a);if(ie.test(r))return await(0,i.writeFile)(n,r.replace(ie,e=>`${e}\n${o}`),`utf8`),{status:`appended`,file:n};if(!ae.test(r))return{status:`skipped-no-app-call`};let s=r.replace(/\n(\s*)\}\s*\)\s*;?\s*$/,(e,t)=>`\n${t}${le(a,t)}\n${t}});\n`);return s===r?{status:`skipped-no-app-call`}:(await(0,i.writeFile)(n,s,`utf8`),{status:`created`,file:n})},se=async e=>{for(let n of re){let r=`${e}/${n}`;if(await t.at(r))return r}return null},ce=e=>e.map(({name:e,description:t,isSecret:n})=>` ${e}: {\n description: ${JSON.stringify(t)},\n isSecret: ${n},\n isRequired: true,\n },`).join(`
21
+ }`;var v=Tf(function(){return Ot(o,g+`return `+m).apply(n,l)});if(v.source=m,Eu(v))throw v;return v}function hf(e){return Z(e).toLowerCase()}function gf(e){return Z(e).toUpperCase()}function _f(e,t,r){if(e=Z(e),e&&(r||t===n))return cr(e);if(!e||!(t=qa(t)))return e;var i=Ar(e),a=Ar(t);return ao(i,fr(i,a),pr(i,a)+1).join(``)}function vf(e,t,r){if(e=Z(e),e&&(r||t===n))return e.slice(0,jr(e)+1);if(!e||!(t=qa(t)))return e;var i=Ar(e);return ao(i,0,pr(i,Ar(t))+1).join(``)}function yf(e,t,r){if(e=Z(e),e&&(r||t===n))return e.replace(ut,``);if(!e||!(t=qa(t)))return e;var i=Ar(e);return ao(i,fr(i,Ar(t))).join(``)}function bf(e,t){var r=ie,i=ae;if(J(t)){var a=`separator`in t?t.separator:a;r=`length`in t?X(t.length):r,i=`omission`in t?qa(t.omission):i}e=Z(e);var o=e.length;if(yr(e)){var s=Ar(e);o=s.length}if(r>=o)return e;var c=r-kr(i);if(c<1)return i;var l=s?ao(s,0,c).join(``):e.slice(0,c);if(a===n)return l+i;if(s&&(c+=l.length-c),Bu(a)){if(e.slice(c).search(a)){var u,d=l;for(a.global||(a=At(a.source,Z(vt.exec(a))+`g`)),a.lastIndex=0;u=a.exec(d);)var f=u.index;l=l.slice(0,f===n?c:f)}}else if(e.indexOf(qa(a),c)!=c){var p=l.lastIndexOf(a);p>-1&&(l=l.slice(0,p))}return l+i}function xf(e){return e=Z(e),e&&et.test(e)?e.replace(Qe,Mr):e}var Sf=Do(function(e,t,n){return e+(n?` `:``)+t.toUpperCase()}),Cf=Eo(`toUpperCase`);function wf(e,t,r){return e=Z(e),t=r?n:t,t===n?br(e)?Fr(e):Jn(e):e.match(t)||[]}var Tf=B(function(e,t){try{return Pn(e,n,t)}catch(e){return Eu(e)?e:new Dt(e)}}),Ef=Zo(function(e,t){return In(t,function(t){t=Vs(t),ji(e,t,Hl(e[t],e))}),e});function Df(e){var t=e==null?0:e.length,n=H();return e=t?F(e,function(e){if(typeof e[1]!=`function`)throw new Mt(o);return[n(e[0]),e[1]]}):[],B(function(n){for(var r=-1;++r<t;){var i=e[r];if(Pn(i[0],this,n))return Pn(i[1],this,n)}})}function Of(e){return Fi(Pi(e,f))}function kf(e){return function(){return e}}function Af(e,t){return e==null||e!==e?t:e}var jf=jo(),Mf=jo(!0);function $(e){return e}function Nf(e){return ga(typeof e==`function`?e:Pi(e,f))}function Pf(e){return xa(Pi(e,f))}function Ff(e,t){return Sa(e,Pi(t,f))}var If=B(function(e,t){return function(n){return ia(n,e,t)}}),Lf=B(function(e,t){return function(n){return ia(e,n,t)}});function Rf(e,t,n){var r=Q(t),i=Yi(t,r);n==null&&!(J(t)&&(i.length||!r.length))&&(n=t,t=e,e=this,i=Yi(t,Q(t)));var a=!(J(n)&&`chain`in n)||!!n.chain,o=Ou(e);return In(i,function(n){var r=t[n];e[n]=r,o&&(e.prototype[n]=function(){var t=this.__chain__;if(a||t){var n=e(this.__wrapped__);return(n.__actions__=V(this.__actions__)).push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,Hn([this.value()],arguments))})}),e}function zf(){return N._===this&&(N._=Ht),this}function Bf(){}function Vf(e){return e=X(e),B(function(t){return Ta(t,e)})}var Hf=Fo(F),Uf=Fo(Rn),Wf=Fo(Gn);function Gf(e){return vs(e)?tr(Vs(e)):ka(e)}function Kf(e){return function(t){return e==null?n:Xi(e,t)}}var qf=Ro(),Jf=Ro(!0);function Yf(){return[]}function Xf(){return!1}function Zf(){return{}}function Qf(){return``}function $f(){return!0}function ep(e,t){if(e=X(e),e<1||e>de)return[];var n=me,r=M(e,me);t=H(t),e-=me;for(var i=or(r,t);++n<e;)t(n);return i}function tp(e){return G(e)?F(e,Vs):Wu(e)?[e]:V(Bs(Z(e)))}function np(e){var t=++Rt;return Z(e)+t}var rp=Po(function(e,t){return e+t},0),ip=Vo(`ceil`),ap=Po(function(e,t){return e/t},1),op=Vo(`floor`);function sp(e){return e&&e.length?Hi(e,$,Qi):n}function cp(e,t){return e&&e.length?Hi(e,H(t,2),Qi):n}function lp(e){return er(e,$)}function up(e,t){return er(e,H(t,2))}function dp(e){return e&&e.length?Hi(e,$,ya):n}function fp(e,t){return e&&e.length?Hi(e,H(t,2),ya):n}var pp=Po(function(e,t){return e*t},1),mp=Vo(`round`),hp=Po(function(e,t){return e-t},0);function gp(e){return e&&e.length?ar(e,$):0}function _p(e,t){return e&&e.length?ar(e,H(t,2)):0}return I.after=zl,I.ary=Bl,I.assign=rd,I.assignIn=id,I.assignInWith=ad,I.assignWith=od,I.at=sd,I.before=Vl,I.bind=Hl,I.bindAll=Ef,I.bindKey=Ul,I.castArray=cu,I.chain=tl,I.chunk=Gs,I.compact=Ks,I.concat=qs,I.cond=Df,I.conforms=Of,I.constant=kf,I.countBy=fl,I.create=cd,I.curry=Wl,I.curryRight=Gl,I.debounce=Kl,I.defaults=ld,I.defaultsDeep=ud,I.defer=ql,I.delay=Jl,I.difference=Js,I.differenceBy=Ys,I.differenceWith=Xs,I.drop=Zs,I.dropRight=Qs,I.dropRightWhile=$s,I.dropWhile=ec,I.fill=tc,I.filter=ml,I.flatMap=_l,I.flatMapDeep=vl,I.flatMapDepth=yl,I.flatten=ic,I.flattenDeep=ac,I.flattenDepth=oc,I.flip=Yl,I.flow=jf,I.flowRight=Mf,I.fromPairs=sc,I.functions=_d,I.functionsIn=vd,I.groupBy=Sl,I.initial=uc,I.intersection=dc,I.intersectionBy=fc,I.intersectionWith=pc,I.invert=Sd,I.invertBy=Cd,I.invokeMap=wl,I.iteratee=Nf,I.keyBy=Tl,I.keys=Q,I.keysIn=Td,I.map=El,I.mapKeys=Ed,I.mapValues=Dd,I.matches=Pf,I.matchesProperty=Ff,I.memoize=Xl,I.merge=Od,I.mergeWith=kd,I.method=If,I.methodOf=Lf,I.mixin=Rf,I.negate=Zl,I.nthArg=Vf,I.omit=Ad,I.omitBy=jd,I.once=Ql,I.orderBy=Dl,I.over=Hf,I.overArgs=$l,I.overEvery=Uf,I.overSome=Wf,I.partial=eu,I.partialRight=tu,I.partition=Ol,I.pick=Md,I.pickBy=Nd,I.property=Gf,I.propertyOf=Kf,I.pull=vc,I.pullAll=yc,I.pullAllBy=bc,I.pullAllWith=xc,I.pullAt=Sc,I.range=qf,I.rangeRight=Jf,I.rearg=nu,I.reject=jl,I.remove=Cc,I.rest=ru,I.reverse=wc,I.sampleSize=Nl,I.set=Fd,I.setWith=Id,I.shuffle=Pl,I.slice=Tc,I.sortBy=Ll,I.sortedUniq=Mc,I.sortedUniqBy=Nc,I.split=df,I.spread=iu,I.tail=Pc,I.take=Fc,I.takeRight=Ic,I.takeRightWhile=Lc,I.takeWhile=Rc,I.tap=nl,I.throttle=au,I.thru=rl,I.toArray=Zu,I.toPairs=Ld,I.toPairsIn=Rd,I.toPath=tp,I.toPlainObject=td,I.transform=zd,I.unary=ou,I.union=zc,I.unionBy=Bc,I.unionWith=Vc,I.uniq=Hc,I.uniqBy=Uc,I.uniqWith=Wc,I.unset=Bd,I.unzip=Gc,I.unzipWith=Kc,I.update=Vd,I.updateWith=Hd,I.values=Ud,I.valuesIn=Wd,I.without=qc,I.words=wf,I.wrap=su,I.xor=Jc,I.xorBy=Yc,I.xorWith=Xc,I.zip=Zc,I.zipObject=Qc,I.zipObjectDeep=$c,I.zipWith=el,I.entries=Ld,I.entriesIn=Rd,I.extend=id,I.extendWith=ad,Rf(I,I),I.add=rp,I.attempt=Tf,I.camelCase=Jd,I.capitalize=Yd,I.ceil=ip,I.clamp=Gd,I.clone=lu,I.cloneDeep=du,I.cloneDeepWith=fu,I.cloneWith=uu,I.conformsTo=pu,I.deburr=Xd,I.defaultTo=Af,I.divide=ap,I.endsWith=Zd,I.eq=mu,I.escape=Qd,I.escapeRegExp=$d,I.every=pl,I.find=hl,I.findIndex=nc,I.findKey=dd,I.findLast=gl,I.findLastIndex=rc,I.findLastKey=fd,I.floor=op,I.forEach=bl,I.forEachRight=xl,I.forIn=pd,I.forInRight=md,I.forOwn=hd,I.forOwnRight=gd,I.get=yd,I.gt=hu,I.gte=gu,I.has=bd,I.hasIn=xd,I.head=cc,I.identity=$,I.includes=Cl,I.indexOf=lc,I.inRange=Kd,I.invoke=wd,I.isArguments=_u,I.isArray=G,I.isArrayBuffer=vu,I.isArrayLike=K,I.isArrayLikeObject=q,I.isBoolean=yu,I.isBuffer=bu,I.isDate=xu,I.isElement=Su,I.isEmpty=Cu,I.isEqual=wu,I.isEqualWith=Tu,I.isError=Eu,I.isFinite=Du,I.isFunction=Ou,I.isInteger=ku,I.isLength=Au,I.isMap=ju,I.isMatch=Mu,I.isMatchWith=Nu,I.isNaN=Pu,I.isNative=Fu,I.isNil=Lu,I.isNull=Iu,I.isNumber=Ru,I.isObject=J,I.isObjectLike=Y,I.isPlainObject=zu,I.isRegExp=Bu,I.isSafeInteger=Vu,I.isSet=Hu,I.isString=Uu,I.isSymbol=Wu,I.isTypedArray=Gu,I.isUndefined=Ku,I.isWeakMap=qu,I.isWeakSet=Ju,I.join=mc,I.kebabCase=ef,I.last=hc,I.lastIndexOf=gc,I.lowerCase=tf,I.lowerFirst=nf,I.lt=Yu,I.lte=Xu,I.max=sp,I.maxBy=cp,I.mean=lp,I.meanBy=up,I.min=dp,I.minBy=fp,I.stubArray=Yf,I.stubFalse=Xf,I.stubObject=Zf,I.stubString=Qf,I.stubTrue=$f,I.multiply=pp,I.nth=_c,I.noConflict=zf,I.noop=Bf,I.now=Rl,I.pad=rf,I.padEnd=af,I.padStart=of,I.parseInt=sf,I.random=qd,I.reduce=kl,I.reduceRight=Al,I.repeat=cf,I.replace=lf,I.result=Pd,I.round=mp,I.runInContext=e,I.sample=Ml,I.size=Fl,I.snakeCase=uf,I.some=Il,I.sortedIndex=Ec,I.sortedIndexBy=Dc,I.sortedIndexOf=Oc,I.sortedLastIndex=kc,I.sortedLastIndexBy=Ac,I.sortedLastIndexOf=jc,I.startCase=ff,I.startsWith=pf,I.subtract=hp,I.sum=gp,I.sumBy=_p,I.template=mf,I.times=ep,I.toFinite=Qu,I.toInteger=X,I.toLength=$u,I.toLower=hf,I.toNumber=ed,I.toSafeInteger=nd,I.toString=Z,I.toUpper=gf,I.trim=_f,I.trimEnd=vf,I.trimStart=yf,I.truncate=bf,I.unescape=xf,I.uniqueId=np,I.upperCase=Sf,I.upperFirst=Cf,I.each=bl,I.eachRight=xl,I.first=cc,Rf(I,function(){var e={};return qi(I,function(t,n){O.call(I.prototype,n)||(e[n]=t)}),e}(),{chain:!1}),I.VERSION=r,In([`bind`,`bindKey`,`curry`,`curryRight`,`partial`,`partialRight`],function(e){I[e].placeholder=I}),In([`drop`,`take`],function(e,t){L.prototype[e]=function(r){r=r===n?1:k(X(r),0);var i=this.__filtered__&&!t?new L(this):this.clone();return i.__filtered__?i.__takeCount__=M(r,i.__takeCount__):i.__views__.push({size:M(r,me),type:e+(i.__dir__<0?`Right`:``)}),i},L.prototype[e+`Right`]=function(t){return this.reverse()[e](t).reverse()}}),In([`filter`,`map`,`takeWhile`],function(e,t){var n=t+1,r=n==ce||n==ue;L.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:H(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}}),In([`head`,`last`],function(e,t){var n=`take`+(t?`Right`:``);L.prototype[e]=function(){return this[n](1).value()[0]}}),In([`initial`,`tail`],function(e,t){var n=`drop`+(t?``:`Right`);L.prototype[e]=function(){return this.__filtered__?new L(this):this[n](1)}}),L.prototype.compact=function(){return this.filter($)},L.prototype.find=function(e){return this.filter(e).head()},L.prototype.findLast=function(e){return this.reverse().find(e)},L.prototype.invokeMap=B(function(e,t){return typeof e==`function`?new L(this):this.map(function(n){return ia(n,e,t)})}),L.prototype.reject=function(e){return this.filter(Zl(H(e)))},L.prototype.slice=function(e,t){e=X(e);var r=this;return r.__filtered__&&(e>0||t<0)?new L(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==n&&(t=X(t),r=t<0?r.dropRight(-t):r.take(t-e)),r)},L.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},L.prototype.toArray=function(){return this.take(me)},qi(L.prototype,function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),a=I[i?`take`+(t==`last`?`Right`:``):t],o=i||/^find/.test(t);a&&(I.prototype[t]=function(){var t=this.__wrapped__,s=i?[1]:arguments,c=t instanceof L,l=s[0],u=c||G(t),d=function(e){var t=a.apply(I,Hn([e],s));return i&&f?t[0]:t};u&&r&&typeof l==`function`&&l.length!=1&&(c=u=!1);var f=this.__chain__,p=!!this.__actions__.length,m=o&&!f,h=c&&!p;if(!o&&u){t=h?t:new L(this);var g=e.apply(t,s);return g.__actions__.push({func:rl,args:[d],thisArg:n}),new Wr(g,f)}return m&&h?e.apply(this,s):(g=this.thru(d),m?i?g.value()[0]:g.value():g)})}),In([`pop`,`push`,`shift`,`sort`,`splice`,`unshift`],function(e){var t=Nt[e],n=/^(?:push|sort|unshift)$/.test(e)?`tap`:`thru`,r=/^(?:pop|shift)$/.test(e);I.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(G(i)?i:[],e)}return this[n](function(n){return t.apply(G(n)?n:[],e)})}}),qi(L.prototype,function(e,t){var n=I[t];if(n){var r=n.name+``;O.call(nr,r)||(nr[r]=[]),nr[r].push({name:t,func:n})}}),nr[Mo(n,v).name]=[{name:`wrapper`,func:n}],L.prototype.clone=Gr,L.prototype.reverse=Kr,L.prototype.value=qr,I.prototype.at=il,I.prototype.chain=al,I.prototype.commit=ol,I.prototype.next=sl,I.prototype.plant=ll,I.prototype.reverse=ul,I.prototype.toJSON=I.prototype.valueOf=I.prototype.value=dl,I.prototype.first=I.prototype.head,$t&&(I.prototype[$t]=cl),I})();typeof define==`function`&&typeof define.amd==`object`&&define.amd?(N._=Ir,define(function(){return Ir})):Tn?((Tn.exports=Ir)._=Ir,wn._=Ir):N._=Ir}).call(e)}))(),ne=e=>{let t=(0,te.startCase)(e).toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)},re=[`src/application.config.ts`,`src/application-config.ts`,`src/applicationConfig.ts`],ie=/serverVariables\s*:\s*\{/,ae=/defineApplication\s*\(\s*\{/,oe=async({projectRoot:e,variables:t})=>{let n=await se(e);if(n===null)return{status:`skipped-no-config`};let r=await(0,i.readFile)(n,`utf8`),a=t.filter(e=>!RegExp(`\\b${e.name}\\s*:`).test(r));if(a.length===0)return{status:`skipped-existing`};let o=ce(a);if(ie.test(r))return await(0,i.writeFile)(n,r.replace(ie,e=>`${e}\n${o}`),`utf8`),{status:`appended`,file:n};if(!ae.test(r))return{status:`skipped-no-app-call`};let s=r.replace(/\n(\s*)\}\s*\)\s*;?\s*$/,(e,t)=>`\n${t}${le(a,t)}\n${t}});\n`);return s===r?{status:`skipped-no-app-call`}:(await(0,i.writeFile)(n,s,`utf8`),{status:`created`,file:n})},se=async e=>{for(let n of re){let r=`${e}/${n}`;if(await t.ot(r))return r}return null},ce=e=>e.map(({name:e,description:t,isSecret:n})=>` ${e}: {\n description: ${JSON.stringify(t)},\n isSecret: ${n},\n isRequired: true,\n },`).join(`
22
22
  `),le=(e,t)=>`serverVariables: {\n${e.map(({name:e,description:n,isSecret:r})=>`${t} ${e}: {\n${t} description: ${JSON.stringify(n)},\n${t} isSecret: ${r},\n${t} isRequired: true,\n${t} },`).join(`
23
- `)}\n${t}},`,ue=({data:e})=>{let n=(0,a.v4)(),r=e.description?`\n description: '${e.description}',`:``;if(e.type===t.ht.RELATION||e.type===t.ht.MORPH_RELATION){let i=e.onDelete&&e.onDelete!==`None`,o=`import { defineField, FieldType, RelationType${i?`, OnDeleteAction`:``} } from 'twenty-sdk/define';`,s=i?`, onDelete: OnDeleteAction.${e.onDelete}`:``,c=e.type===t.ht.MORPH_RELATION?`\n morphId: '${(0,a.v4)()}',`:``;return`${o}
23
+ `)}\n${t}},`,ue=({data:e})=>{let n=(0,a.v4)(),r=e.description?`\n description: '${e.description}',`:``;if(e.type===t.yt.RELATION||e.type===t.yt.MORPH_RELATION){let i=e.onDelete&&e.onDelete!==`None`,o=`import { defineField, FieldType, RelationType${i?`, OnDeleteAction`:``} } from 'twenty-sdk/define';`,s=i?`, onDelete: OnDeleteAction.${e.onDelete}`:``,c=e.type===t.yt.MORPH_RELATION?`\n morphId: '${(0,a.v4)()}',`:``;return`${o}
24
24
 
25
25
  export default defineField({
26
26
  universalIdentifier: '${n}',
@@ -332,10 +332,10 @@ export default defineViewField({
332
332
  isVisible: true,
333
333
  size: 150,
334
334
  });
335
- `,Ee=`src/application.config.ts`,w=`src`,De=class{async execute(e,n){try{let a=e??await this.getEntity(),o=this.getFolderName(a),s=n?(0,r.join)(t.vt,n):(0,r.join)(t.vt,w,o);await t.it(s);let{name:c,file:l}=await this.getEntityData(a),d=(0,r.join)(s,this.getFileName(c,a));if(await t.at(d)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,i.writeFile)(d,l),console.log(u.default.green(`✓ Created ${o}:`),u.default.cyan((0,r.relative)(t.vt,d))),a===t.ct.Object&&await this.promptAndCreateObjectCompanions(c,n),a===t.ct.ConnectionProvider&&await this.registerConnectionProviderServerVariables(c)}catch(e){console.error(u.default.red(`Add new entity failed:`),e instanceof Error?e.message:e),process.exit(1)}}async getEntityData(e){switch(e){case t.ct.Object:{let e=await this.getObjectData(),t=e.nameSingular,n=(0,a.v4)(),r=(0,a.v4)();return this.lastObjectUniversalIdentifier=n,this.lastNameFieldUniversalIdentifier=r,this.lastObjectLabelSingular=e.labelSingular,{name:t,file:me({data:e,name:t,universalIdentifier:n,nameFieldUniversalIdentifier:r})}}case t.ct.Field:{let e=await this.getFieldData(),t=e.name;return{name:t,file:ue({data:e,name:t})}}case t.ct.LogicFunction:{let t=await this.getEntityName(e);return{name:t,file:fe({name:t})}}case t.ct.FrontComponent:{let t=await this.getEntityName(e);return{name:t,file:de({name:t})}}case t.ct.Role:{let t=await this.getEntityName(e);return{name:t,file:ye({name:t})}}case t.ct.Skill:{let t=await this.getEntityName(e);return{name:t,file:Se({name:t})}}case t.ct.Agent:{let t=await this.getEntityName(e);return{name:t,file:be({name:t})}}case t.ct.ConnectionProvider:{let t=await this.getEntityName(e);return{name:t,file:xe({name:t})}}case t.ct.View:{let e=(await this.getViewData()).name;return{name:e,file:we({name:e})}}case t.ct.ViewField:return{name:await this.getEntityName(e),file:Te({})};case t.ct.NavigationMenuItem:{let t=await this.getEntityName(e);return{name:t,file:pe({name:t})}}case t.ct.PageLayout:{let t=await this.getEntityName(e);return{name:t,file:ge({name:t})}}case t.ct.PageLayoutTab:{let t=await this.getEntityName(e);return{name:t,file:_e({name:t})}}case t.ct.CommandMenuItem:{let t=await this.getEntityName(e);return{name:t,file:he({name:t})}}default:t.dt(e)}}async promptAndCreateObjectCompanions(e,n){let{createCompanions:o}=await d.default.prompt([{type:`confirm`,name:`createCompanions`,message:`Also create a view, navigation menu item, and record page layout for this object? (recommended)`,default:!0}]);if(!o||!this.lastObjectUniversalIdentifier)return;let s=(0,a.v4)(),c=(0,a.v4)(),l=we({name:`all-${C(e)}`,universalIdentifier:s,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,fields:this.lastNameFieldUniversalIdentifier?[{fieldMetadataUniversalIdentifier:this.lastNameFieldUniversalIdentifier,position:0,isVisible:!0,size:200}]:[]}),f=n?(0,r.join)(t.vt,n):(0,r.join)(t.vt,w,this.getFolderName(t.ct.View));await t.it(f);let p=(0,r.join)(f,`all-${C(e)}.ts`);if(await t.at(p)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,i.writeFile)(p,l),console.log(u.default.green(`✓ Created view:`),u.default.cyan((0,r.relative)(t.vt,p)));let m=this.buildRecordPageFieldsViewFields(this.lastNameFieldUniversalIdentifier),h=we({name:`${C(e)}-record-page-fields`,universalIdentifier:c,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,type:t.pt.FIELDS_WIDGET,fields:m}),g=(0,r.join)(f,`${C(e)}-record-page-fields.ts`);if(await t.at(g)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,i.writeFile)(g,h),console.log(u.default.green(`✓ Created record-page-fields view:`),u.default.cyan((0,r.relative)(t.vt,g)));let _=pe({name:e,type:`OBJECT`,targetObjectUniversalIdentifier:this.lastObjectUniversalIdentifier}),v=n?(0,r.join)(t.vt,n):(0,r.join)(t.vt,w,this.getFolderName(t.ct.NavigationMenuItem));await t.it(v);let y=(0,r.join)(v,`${C(e)}.ts`);if(await t.at(y)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,i.writeFile)(y,_),console.log(u.default.green(`✓ Created navigation menu item:`),u.default.cyan((0,r.relative)(t.vt,y)));let b=ve({objectLabelSingular:this.lastObjectLabelSingular??e,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,fieldsWidgetViewUniversalIdentifier:c}),x=n?(0,r.join)(t.vt,n):(0,r.join)(t.vt,w,this.getFolderName(t.ct.PageLayout));await t.it(x);let S=(0,r.join)(x,`${C(e)}-record-page-layout.ts`);if(await t.at(S)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,i.writeFile)(S,b),console.log(u.default.green(`✓ Created record page layout:`),u.default.cyan((0,r.relative)(t.vt,S)))}async registerConnectionProviderServerVariables(e){let n=C(e).toUpperCase().replace(/-/g,`_`),i=[{name:`${n}_CLIENT_ID`,description:`OAuth client ID issued by the third-party provider. Filled in once by the server admin on the application registration.`,isSecret:!1},{name:`${n}_CLIENT_SECRET`,description:`OAuth client secret issued by the third-party provider. Stored encrypted; never echoed in API responses.`,isSecret:!0}],a=await oe({projectRoot:t.vt,variables:i});switch(a.status){case`appended`:case`created`:console.log(u.default.green(`✓ Added ${i.map(e=>e.name).join(` + `)} to defineApplication.serverVariables:`),u.default.cyan((0,r.relative)(t.vt,a.file)));break;case`skipped-existing`:console.log(u.default.dim(` (${i.map(e=>e.name).join(` / `)} already declared on defineApplication.serverVariables)`));break;case`skipped-no-config`:case`skipped-no-app-call`:console.log(u.default.yellow(`! Couldn't auto-update ${Ee}. Add these manually to defineApplication.serverVariables:\n`+i.map(e=>` ${e.name}: { description: '...', isSecret: ${e.isSecret}, isRequired: true },`).join(`
336
- `)));break}}buildRecordPageFieldsViewFields(e){let t=[`createdAt`,`updatedAt`,`createdBy`,`updatedBy`].map(e=>({defaultFieldName:e,isVisible:!0,size:200}));return(e?[{fieldMetadataUniversalIdentifier:e,isVisible:!0,size:200},...t]:t).map((e,t)=>({...e,position:t}))}async getEntity(){let{entity:e}=await d.default.prompt([{type:`select`,name:`entity`,message:`What entity do you want to create?`,default:``,choices:Object.values(t.ct)}]);return e}async handleFileExist(){return await d.default.prompt([{type:`confirm`,name:`overwrite`,message:`File already exists. Do you want to overwrite it?`,default:!1}])}async getEntityName(e){let{name:t}=await d.default.prompt([{type:`input`,name:`name`,message:`Enter a name for your new ${e}:`,default:``,validate:t=>t.length===0?`${e} name is required`:!0}]);return t}async getFieldData(){let e=e=>e===t.ht.RELATION||e===t.ht.MORPH_RELATION;return d.default.prompt([{type:`input`,name:`name`,message:`Enter a name for your field:`,default:``,validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`label`,message:`Enter a label for your field:`,default:e=>ne(e.name),validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`select`,name:`type`,message:`Select the field type:`,choices:Object.values(t.ht),default:t.ht.TEXT},{type:`input`,name:`objectUniversalIdentifier`,message:`Enter the universalIdentifier of the object this field belongs to:`,default:`fill-later`,validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`description`,message:`Enter a description for your field (optional):`,default:``},{type:`input`,name:`relationTargetObjectMetadataUniversalIdentifier`,message:`Enter the universalIdentifier of the target object of the relation:`,default:`fill-later`,when:t=>e(t.type),validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`relationTargetFieldMetadataUniversalIdentifier`,message:`Enter the universalIdentifier of the target field on the related object:`,default:`fill-later`,when:t=>e(t.type),validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`select`,name:`relationType`,message:`Select the relation type:`,choices:Object.values(t._t),default:t._t.ONE_TO_MANY,when:t=>e(t.type)},{type:`select`,name:`onDelete`,message:`Select the onDelete behavior:`,choices:Object.values(t.gt),default:t.gt.CASCADE,when:t=>e(t.type)}])}async getObjectData(){return d.default.prompt([{type:`input`,name:`nameSingular`,message:`Enter a name singular for your object (eg: company):`,default:``,validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`namePlural`,message:`Enter a name plural for your object (eg: companies):`,default:``,validate:(e,t)=>e.trim()===t?.nameSingular.trim()?`Name plural must be different from name singular`:!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`labelSingular`,message:`Enter a label singular for your object:`,default:e=>ne(e.nameSingular),validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`labelPlural`,message:`Enter a label plural for your object:`,default:e=>ne(e.namePlural),validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0}])}async getViewData(){return d.default.prompt([{type:`input`,name:`name`,message:`Enter a name for your view:`,default:``,validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`objectUniversalIdentifier`,message:`Enter the universalIdentifier of the object this view belongs to:`,default:`fill-later`,validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0}])}getFolderName(e){return`${C(e)}s`}getFileName(e,n){switch(n){case t.ct.FrontComponent:return`${C(e)}.tsx`;default:return`${C(e)}.ts`}}},Oe=class{async execute(e){let n=e.appPath??t.vt;await y(n),console.log(u.default.blue(`Building application...`)),console.log(u.default.gray(`App path: ${n}\n`));let r=await t.U({appPath:n,tarball:e.tarball,onProgress:e=>console.log(u.default.gray(e))});r.success||(console.error(u.default.red(r.error.message)),process.exit(1)),console.log(u.default.green(`✓ Build succeeded (${r.data.fileCount} file${r.data.fileCount===1?``:`s`})`)),console.log(u.default.gray(`Output: ${r.data.outputDir}`)),r.data.tarballPath&&console.log(u.default.gray(`Tarball: ${r.data.tarballPath}`))}},ke=class{async execute({appPath:e=t.vt,postInstall:r=!1,preInstall:i=!1,functionUniversalIdentifier:a,functionName:o,payload:s=`{}`}){let c;try{c=JSON.parse(s)}catch{console.error(u.default.red(`Invalid JSON payload. Please provide valid JSON.`)),process.exit(1)}let l=r?`post install`:i?`pre install`:a??o,d=t.V.getActiveRemote();console.log(u.default.blue(`🚀 Executing function "${l}" on ${d}...`)),console.log(u.default.gray(` Payload: ${JSON.stringify(c)}\n`));let f=await t.h(r?{appPath:e,postInstall:!0,payload:c}:i?{appPath:e,preInstall:!0,payload:c}:a?{appPath:e,functionUniversalIdentifier:a,payload:c}:{appPath:e,functionName:o,payload:c});if(!f.success){switch(f.error.code){case t.W.MANIFEST_NOT_FOUND:console.error(u.default.red(`Failed to build manifest.`));break;case t.K.FETCH_FUNCTIONS_FAILED:console.error(u.default.red(`Failed to fetch functions:`),f.error.message);break;case t.K.FUNCTION_NOT_FOUND:{console.error(u.default.red(f.error.message),`
337
- `);let e=f.error.details?.availableFunctions??[];e.length>0?(console.log(u.default.cyan(`Available functions:`)),e.forEach(e=>{console.log(` - ${u.default.white(e.name)} (${e.universalIdentifier})`)})):console.log(u.default.yellow("No functions found for this application. Have you synced your app with `twenty dev`?"));break}case t.K.EXECUTION_FAILED:console.error(u.default.red(`Execution failed:`),f.error.message);break;default:console.error(u.default.red(f.error.message))}process.exit(1)}let p=f.data;console.log(u.default.cyan(`─`.repeat(60))),console.log(u.default.cyan(`Execution Result`)),console.log(u.default.cyan(`─`.repeat(60)));let m=p.status===`SUCCESS`?u.default.green:u.default.red;console.log(`${u.default.bold(`Status:`)} ${m(p.status)}`),console.log(`${u.default.bold(`Duration:`)} ${p.duration}ms\n`),n.t(p.data)&&(console.log(u.default.bold(`Data:`)),console.log(u.default.white(JSON.stringify(p.data,null,2)))),p.error&&(console.log(u.default.bold.red(`Error:`)),console.log(u.default.red(` Type: ${p.error.errorType}`)),console.log(u.default.red(` Message: ${p.error.errorMessage}\n`)),p.error.stackTrace&&(console.log(u.default.gray(`Stack trace:`)),console.log(u.default.gray(p.error.stackTrace)))),p.logs&&(console.log(u.default.bold(`Logs:`)),console.log(u.default.gray(p.logs))),console.log(u.default.cyan(`─`.repeat(60))),p.status!==`SUCCESS`&&process.exit(1)}},Ae=class{constructor(){this.apiService=new t.L}async execute({appPath:e=t.vt,functionUniversalIdentifier:n,functionName:r}){try{let i=await t.N(e);i||process.exit(1),this.logWatchInfo({appName:i.application.displayName,functionUniversalIdentifier:n,functionName:r}),await this.apiService.subscribeToLogs({applicationUniversalIdentifier:i.application.universalIdentifier,functionUniversalIdentifier:n,functionName:r})}catch(e){console.error(u.default.red(`Watch logs failed:`),e instanceof Error?e.message:e),process.exit(1)}}logWatchInfo({appName:e,functionUniversalIdentifier:n,functionName:r}){let i=e??`Twenty Application`,a=n||r?`function "${n||r}"`:`functions`,o=t.V.getActiveRemote();console.log(u.default.blue(`🚀 Watching ${i} ${a} logs on ${o}:\n`))}},je=e=>`${u.default.cyan(e.file)}:${u.default.yellow(String(e.line))}:${u.default.yellow(String(e.column+1))} - ${u.default.red(`error`)} ${e.text}`,Me=class{async execute(e){let n=e.appPath??t.vt;console.log(u.default.blue(`Running type check...`)),console.log(u.default.gray(`App path: ${n}\n`));let r=await t.tt(n);r.length===0&&(console.log(u.default.green(`✓ No type errors found`)),process.exit(0));for(let e of r)console.log(je(e));console.log(`
338
- `,u.default.red(`✗ Found ${r.length} type error${r.length===1?``:`s`}`)),process.exit(1)}},T=(e,t)=>console.warn(u.default.yellow(`⚠ \`twenty ${e}\` is deprecated. Use \`twenty ${t}\` instead.`)),Ne=e=>{let t=new Oe,n=new Me,r=new Ae,i=new ke,a=new De,o=new b,s=new x,c=new S;e.command(`build [appPath]`,{hidden:!0}).option(`--tarball`,`Also pack into a .tgz tarball`).action(async(e,n)=>{T(`build`,`dev:build`),await t.execute({appPath:g(e),tarball:n.tarball})}),e.command(`typecheck [appPath]`,{hidden:!0}).action(async e=>{T(`typecheck`,`dev:typecheck`),await n.execute({appPath:g(e)})}),e.command(`logs [appPath]`,{hidden:!0}).option(`-u, --functionUniversalIdentifier <functionUniversalIdentifier>`,`Only show logs for the function with this universal ID`).option(`-n, --functionName <functionName>`,`Only show logs for the function with this name`).action(async(e,t)=>{T(`logs`,`dev:function:logs`),await r.execute({...t,appPath:g(e)})}),e.command(`exec [appPath]`,{hidden:!0}).option(`--postInstall`,`Execute post-install logic function if defined`).option(`--preInstall`,`Execute pre-install logic function if defined`).option(`-p, --payload <payload>`,`JSON payload to send to the function`,`{}`).option(`-u, --functionUniversalIdentifier <functionUniversalIdentifier>`,`Universal ID of the function to execute`).option(`-n, --functionName <functionName>`,`Name of the function to execute`).action(async(e,t)=>{T(`exec`,`dev:function:exec`),!t?.postInstall&&!t?.preInstall&&!t?.functionUniversalIdentifier&&!t?.functionName&&(console.error(u.default.red(`Error: Either --postInstall, --preInstall, --functionName (-n), or --functionUniversalIdentifier (-u) is required.`)),process.exit(1)),await i.execute({...t,payload:t?.payload??`{}`,appPath:g(e)})}),e.command(`add [entityType]`,{hidden:!0}).option(`--path <path>`,`Path in which the entity should be created.`).action(async(e,t)=>{T(`add`,`dev:add`),await a.execute(e,t?.path)}),e.command(`publish [appPath]`,{hidden:!0}).option(`--tag <tag>`,`npm dist-tag (e.g. beta, next)`).action(async(e,t)=>{T(`publish`,`app:publish`),await o.execute({appPath:g(e),tag:t.tag})}),e.command(`deploy [appPath]`,{hidden:!0}).option(`-r, --remote <name>`,`Deploy to a specific remote`).action(async(e,t)=>{T(`deploy`,`app:publish --private`),await o.execute({appPath:g(e),private:!0,remote:t.remote})}),e.command(`install [appPath]`,{hidden:!0}).option(`-r, --remote <name>`,`Install on a specific remote`).action(async(e,t)=>{T(`install`,`app:install`),await s.execute({appPath:g(e),remote:t.remote})}),e.command(`uninstall [appPath]`,{hidden:!0}).option(`-y, --yes`,`Skip confirmation prompt`).action(async(e,t)=>{T(`uninstall`,`app:uninstall`);try{let n=await c.execute({appPath:g(e),askForConfirmation:!t?.yes});process.exit(+!n.success)}catch{process.exit(1)}}),e.command(`catalog-sync`,{hidden:!0}).option(`-r, --remote <name>`,`Sync on a specific remote`).action(async e=>{T(`catalog-sync`,`dev:catalog-sync`);let{CatalogSyncCommand:t}=await Promise.resolve().then(()=>require("./catalog-sync-w6yKppKP.js"));await new t().execute({remote:e.remote})})},Pe=class{constructor({state:e,notify:t}){this.state=e,this.notify=t}async execute(e){let n=this.state.steps.buildManifest;n.status=`in_progress`,this.state.updatePipeline({status:`building`});let r=[{message:`Building manifest`,status:`info`}],i=await t.Z(e.appPath);if(!i.success){for(let e of i.errors)r.push({message:e,status:`error`});return n.output={result:null},n.status=`error`,this.state.updatePipeline({status:`error`}),this.state.applyStepEvents(r),null}if(i.warnings.length>0)for(let e of i.warnings)r.push({message:`⚠ ${e}`,status:`warning`});r.push({message:`Successfully built manifest`,status:`success`});let a={manifest:i.manifest,filePaths:i.filePaths};return n.output={result:a},n.status=`done`,this.state.updatePipeline({appName:i.manifest.application.displayName}),this.state.updateEntitiesFromManifest(i.filePaths),this.state.applyStepEvents(r),a}},Fe=class{constructor({apiService:e,state:t,notify:n}){this.hasRetried=!1,this.apiService=e,this.state=t,this.notify=n}async execute(){let e=this.state.steps.checkServer,r=await this.apiService.validateAuth();if(!r.serverUp){let n=await t.p();return n&&!this.hasRetried?(this.hasRetried=!0,await new t.V().setConfig({apiUrl:n}),this.execute()):(e.output.errorLogged||(e.output={isReady:!1,errorLogged:!0},e.status=`error`,this.state.applyStepEvents([{message:`Cannot reach Twenty server.
335
+ `,Ee=`src/application.config.ts`,w=`src`,De=class{async execute(e,n){try{let a=e??await this.getEntity(),o=this.getFolderName(a),s=n?(0,r.join)(t.xt,n):(0,r.join)(t.xt,w,o);await t.at(s);let{name:c,file:l}=await this.getEntityData(a),d=(0,r.join)(s,this.getFileName(c,a));if(await t.ot(d)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,i.writeFile)(d,l),console.log(u.default.green(`✓ Created ${o}:`),u.default.cyan((0,r.relative)(t.xt,d))),a===t.ut.Object&&await this.promptAndCreateObjectCompanions(c,n),a===t.ut.ConnectionProvider&&await this.registerConnectionProviderServerVariables(c)}catch(e){console.error(u.default.red(`Add new entity failed:`),e instanceof Error?e.message:e),process.exit(1)}}async getEntityData(e){switch(e){case t.ut.Object:{let e=await this.getObjectData(),t=e.nameSingular,n=(0,a.v4)(),r=(0,a.v4)();return this.lastObjectUniversalIdentifier=n,this.lastNameFieldUniversalIdentifier=r,this.lastObjectLabelSingular=e.labelSingular,{name:t,file:me({data:e,name:t,universalIdentifier:n,nameFieldUniversalIdentifier:r})}}case t.ut.Field:{let e=await this.getFieldData(),t=e.name;return{name:t,file:ue({data:e,name:t})}}case t.ut.LogicFunction:{let t=await this.getEntityName(e);return{name:t,file:fe({name:t})}}case t.ut.FrontComponent:{let t=await this.getEntityName(e);return{name:t,file:de({name:t})}}case t.ut.Role:{let t=await this.getEntityName(e);return{name:t,file:ye({name:t})}}case t.ut.Skill:{let t=await this.getEntityName(e);return{name:t,file:Se({name:t})}}case t.ut.Agent:{let t=await this.getEntityName(e);return{name:t,file:be({name:t})}}case t.ut.ConnectionProvider:{let t=await this.getEntityName(e);return{name:t,file:xe({name:t})}}case t.ut.View:{let e=(await this.getViewData()).name;return{name:e,file:we({name:e})}}case t.ut.ViewField:return{name:await this.getEntityName(e),file:Te({})};case t.ut.NavigationMenuItem:{let t=await this.getEntityName(e);return{name:t,file:pe({name:t})}}case t.ut.PageLayout:{let t=await this.getEntityName(e);return{name:t,file:ge({name:t})}}case t.ut.PageLayoutTab:{let t=await this.getEntityName(e);return{name:t,file:_e({name:t})}}case t.ut.CommandMenuItem:{let t=await this.getEntityName(e);return{name:t,file:he({name:t})}}default:t.mt(e)}}async promptAndCreateObjectCompanions(e,n){let{createCompanions:o}=await d.default.prompt([{type:`confirm`,name:`createCompanions`,message:`Also create a view, navigation menu item, and record page layout for this object? (recommended)`,default:!0}]);if(!o||!this.lastObjectUniversalIdentifier)return;let s=(0,a.v4)(),c=(0,a.v4)(),l=we({name:`all-${C(e)}`,universalIdentifier:s,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,fields:this.lastNameFieldUniversalIdentifier?[{fieldMetadataUniversalIdentifier:this.lastNameFieldUniversalIdentifier,position:0,isVisible:!0,size:200}]:[]}),f=n?(0,r.join)(t.xt,n):(0,r.join)(t.xt,w,this.getFolderName(t.ut.View));await t.at(f);let p=(0,r.join)(f,`all-${C(e)}.ts`);if(await t.ot(p)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,i.writeFile)(p,l),console.log(u.default.green(`✓ Created view:`),u.default.cyan((0,r.relative)(t.xt,p)));let m=this.buildRecordPageFieldsViewFields(this.lastNameFieldUniversalIdentifier),h=we({name:`${C(e)}-record-page-fields`,universalIdentifier:c,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,type:t._t.FIELDS_WIDGET,fields:m}),g=(0,r.join)(f,`${C(e)}-record-page-fields.ts`);if(await t.ot(g)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,i.writeFile)(g,h),console.log(u.default.green(`✓ Created record-page-fields view:`),u.default.cyan((0,r.relative)(t.xt,g)));let _=pe({name:e,type:`OBJECT`,targetObjectUniversalIdentifier:this.lastObjectUniversalIdentifier}),v=n?(0,r.join)(t.xt,n):(0,r.join)(t.xt,w,this.getFolderName(t.ut.NavigationMenuItem));await t.at(v);let y=(0,r.join)(v,`${C(e)}.ts`);if(await t.ot(y)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,i.writeFile)(y,_),console.log(u.default.green(`✓ Created navigation menu item:`),u.default.cyan((0,r.relative)(t.xt,y)));let b=ve({objectLabelSingular:this.lastObjectLabelSingular??e,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,fieldsWidgetViewUniversalIdentifier:c}),x=n?(0,r.join)(t.xt,n):(0,r.join)(t.xt,w,this.getFolderName(t.ut.PageLayout));await t.at(x);let S=(0,r.join)(x,`${C(e)}-record-page-layout.ts`);if(await t.ot(S)){let{overwrite:e}=await this.handleFileExist();if(!e)return}await(0,i.writeFile)(S,b),console.log(u.default.green(`✓ Created record page layout:`),u.default.cyan((0,r.relative)(t.xt,S)))}async registerConnectionProviderServerVariables(e){let n=C(e).toUpperCase().replace(/-/g,`_`),i=[{name:`${n}_CLIENT_ID`,description:`OAuth client ID issued by the third-party provider. Filled in once by the server admin on the application registration.`,isSecret:!1},{name:`${n}_CLIENT_SECRET`,description:`OAuth client secret issued by the third-party provider. Stored encrypted; never echoed in API responses.`,isSecret:!0}],a=await oe({projectRoot:t.xt,variables:i});switch(a.status){case`appended`:case`created`:console.log(u.default.green(`✓ Added ${i.map(e=>e.name).join(` + `)} to defineApplication.serverVariables:`),u.default.cyan((0,r.relative)(t.xt,a.file)));break;case`skipped-existing`:console.log(u.default.dim(` (${i.map(e=>e.name).join(` / `)} already declared on defineApplication.serverVariables)`));break;case`skipped-no-config`:case`skipped-no-app-call`:console.log(u.default.yellow(`! Couldn't auto-update ${Ee}. Add these manually to defineApplication.serverVariables:\n`+i.map(e=>` ${e.name}: { description: '...', isSecret: ${e.isSecret}, isRequired: true },`).join(`
336
+ `)));break}}buildRecordPageFieldsViewFields(e){let t=[`createdAt`,`updatedAt`,`createdBy`,`updatedBy`].map(e=>({defaultFieldName:e,isVisible:!0,size:200}));return(e?[{fieldMetadataUniversalIdentifier:e,isVisible:!0,size:200},...t]:t).map((e,t)=>({...e,position:t}))}async getEntity(){let{entity:e}=await d.default.prompt([{type:`select`,name:`entity`,message:`What entity do you want to create?`,default:``,choices:Object.values(t.ut)}]);return e}async handleFileExist(){return await d.default.prompt([{type:`confirm`,name:`overwrite`,message:`File already exists. Do you want to overwrite it?`,default:!1}])}async getEntityName(e){let{name:t}=await d.default.prompt([{type:`input`,name:`name`,message:`Enter a name for your new ${e}:`,default:``,validate:t=>t.length===0?`${e} name is required`:!0}]);return t}async getFieldData(){let e=e=>e===t.yt.RELATION||e===t.yt.MORPH_RELATION;return d.default.prompt([{type:`input`,name:`name`,message:`Enter a name for your field:`,default:``,validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`label`,message:`Enter a label for your field:`,default:e=>ne(e.name),validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`select`,name:`type`,message:`Select the field type:`,choices:Object.values(t.yt),default:t.yt.TEXT},{type:`input`,name:`objectUniversalIdentifier`,message:`Enter the universalIdentifier of the object this field belongs to:`,default:`fill-later`,validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`description`,message:`Enter a description for your field (optional):`,default:``},{type:`input`,name:`relationTargetObjectMetadataUniversalIdentifier`,message:`Enter the universalIdentifier of the target object of the relation:`,default:`fill-later`,when:t=>e(t.type),validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`relationTargetFieldMetadataUniversalIdentifier`,message:`Enter the universalIdentifier of the target field on the related object:`,default:`fill-later`,when:t=>e(t.type),validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`select`,name:`relationType`,message:`Select the relation type:`,choices:Object.values(t.bt),default:t.bt.ONE_TO_MANY,when:t=>e(t.type)},{type:`select`,name:`onDelete`,message:`Select the onDelete behavior:`,choices:Object.values(t.vt),default:t.vt.CASCADE,when:t=>e(t.type)}])}async getObjectData(){return d.default.prompt([{type:`input`,name:`nameSingular`,message:`Enter a name singular for your object (eg: company):`,default:``,validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`namePlural`,message:`Enter a name plural for your object (eg: companies):`,default:``,validate:(e,t)=>e.trim()===t?.nameSingular.trim()?`Name plural must be different from name singular`:!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`labelSingular`,message:`Enter a label singular for your object:`,default:e=>ne(e.nameSingular),validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`labelPlural`,message:`Enter a label plural for your object:`,default:e=>ne(e.namePlural),validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0}])}async getViewData(){return d.default.prompt([{type:`input`,name:`name`,message:`Enter a name for your view:`,default:``,validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0},{type:`input`,name:`objectUniversalIdentifier`,message:`Enter the universalIdentifier of the object this view belongs to:`,default:`fill-later`,validate:e=>!e||e.trim().length===0?`Please enter a non empty string`:!0}])}getFolderName(e){return`${C(e)}s`}getFileName(e,n){switch(n){case t.ut.FrontComponent:return`${C(e)}.tsx`;default:return`${C(e)}.ts`}}},Oe=class{async execute(e){let n=e.appPath??t.xt;await y(n),console.log(u.default.blue(`Building application...`)),console.log(u.default.gray(`App path: ${n}\n`));let r=await t.U({appPath:n,tarball:e.tarball,onProgress:e=>console.log(u.default.gray(e))});r.success||(console.error(u.default.red(r.error.message)),process.exit(1)),console.log(u.default.green(`✓ Build succeeded (${r.data.fileCount} file${r.data.fileCount===1?``:`s`})`)),console.log(u.default.gray(`Output: ${r.data.outputDir}`)),r.data.tarballPath&&console.log(u.default.gray(`Tarball: ${r.data.tarballPath}`))}},ke=class{async execute({appPath:e=t.xt,postInstall:r=!1,preInstall:i=!1,functionUniversalIdentifier:a,functionName:o,payload:s=`{}`}){let c;try{c=JSON.parse(s)}catch{console.error(u.default.red(`Invalid JSON payload. Please provide valid JSON.`)),process.exit(1)}let l=r?`post install`:i?`pre install`:a??o,d=t.V.getActiveRemote();console.log(u.default.blue(`🚀 Executing function "${l}" on ${d}...`)),console.log(u.default.gray(` Payload: ${JSON.stringify(c)}\n`));let f=await t.h(r?{appPath:e,postInstall:!0,payload:c}:i?{appPath:e,preInstall:!0,payload:c}:a?{appPath:e,functionUniversalIdentifier:a,payload:c}:{appPath:e,functionName:o,payload:c});if(!f.success){switch(f.error.code){case t.W.MANIFEST_NOT_FOUND:console.error(u.default.red(`Failed to build manifest.`));break;case t.K.FETCH_FUNCTIONS_FAILED:console.error(u.default.red(`Failed to fetch functions:`),f.error.message);break;case t.K.FUNCTION_NOT_FOUND:{console.error(u.default.red(f.error.message),`
337
+ `);let e=f.error.details?.availableFunctions??[];e.length>0?(console.log(u.default.cyan(`Available functions:`)),e.forEach(e=>{console.log(` - ${u.default.white(e.name)} (${e.universalIdentifier})`)})):console.log(u.default.yellow("No functions found for this application. Have you synced your app with `twenty dev`?"));break}case t.K.EXECUTION_FAILED:console.error(u.default.red(`Execution failed:`),f.error.message);break;default:console.error(u.default.red(f.error.message))}process.exit(1)}let p=f.data;console.log(u.default.cyan(`─`.repeat(60))),console.log(u.default.cyan(`Execution Result`)),console.log(u.default.cyan(`─`.repeat(60)));let m=p.status===`SUCCESS`?u.default.green:u.default.red;console.log(`${u.default.bold(`Status:`)} ${m(p.status)}`),console.log(`${u.default.bold(`Duration:`)} ${p.duration}ms\n`),n.t(p.data)&&(console.log(u.default.bold(`Data:`)),console.log(u.default.white(JSON.stringify(p.data,null,2)))),p.error&&(console.log(u.default.bold.red(`Error:`)),console.log(u.default.red(` Type: ${p.error.errorType}`)),console.log(u.default.red(` Message: ${p.error.errorMessage}\n`)),p.error.stackTrace&&(console.log(u.default.gray(`Stack trace:`)),console.log(u.default.gray(p.error.stackTrace)))),p.logs&&(console.log(u.default.bold(`Logs:`)),console.log(u.default.gray(p.logs))),console.log(u.default.cyan(`─`.repeat(60))),p.status!==`SUCCESS`&&process.exit(1)}},Ae=class{constructor(){this.apiService=new t.L}async execute({appPath:e=t.xt,functionUniversalIdentifier:n,functionName:r}){try{let i=await t.N(e);i||process.exit(1),this.logWatchInfo({appName:i.application.displayName,functionUniversalIdentifier:n,functionName:r}),await this.apiService.subscribeToLogs({applicationUniversalIdentifier:i.application.universalIdentifier,functionUniversalIdentifier:n,functionName:r})}catch(e){console.error(u.default.red(`Watch logs failed:`),e instanceof Error?e.message:e),process.exit(1)}}logWatchInfo({appName:e,functionUniversalIdentifier:n,functionName:r}){let i=e??`Twenty Application`,a=n||r?`function "${n||r}"`:`functions`,o=t.V.getActiveRemote();console.log(u.default.blue(`🚀 Watching ${i} ${a} logs on ${o}:\n`))}},je=e=>`${u.default.cyan(e.file)}:${u.default.yellow(String(e.line))}:${u.default.yellow(String(e.column+1))} - ${u.default.red(`error`)} ${e.text}`,Me=class{async execute(e){let n=e.appPath??t.xt;console.log(u.default.blue(`Running type check...`)),console.log(u.default.gray(`App path: ${n}\n`));let r=await t.nt(n);r.length===0&&(console.log(u.default.green(`✓ No type errors found`)),process.exit(0));for(let e of r)console.log(je(e));console.log(`
338
+ `,u.default.red(`✗ Found ${r.length} type error${r.length===1?``:`s`}`)),process.exit(1)}},T=(e,t)=>console.warn(u.default.yellow(`⚠ \`twenty ${e}\` is deprecated. Use \`twenty ${t}\` instead.`)),Ne=e=>{let t=new Oe,n=new Me,r=new Ae,i=new ke,a=new De,o=new b,s=new x,c=new S;e.command(`build [appPath]`,{hidden:!0}).option(`--tarball`,`Also pack into a .tgz tarball`).action(async(e,n)=>{T(`build`,`dev:build`),await t.execute({appPath:g(e),tarball:n.tarball})}),e.command(`typecheck [appPath]`,{hidden:!0}).action(async e=>{T(`typecheck`,`dev:typecheck`),await n.execute({appPath:g(e)})}),e.command(`logs [appPath]`,{hidden:!0}).option(`-u, --functionUniversalIdentifier <functionUniversalIdentifier>`,`Only show logs for the function with this universal ID`).option(`-n, --functionName <functionName>`,`Only show logs for the function with this name`).action(async(e,t)=>{T(`logs`,`dev:function:logs`),await r.execute({...t,appPath:g(e)})}),e.command(`exec [appPath]`,{hidden:!0}).option(`--postInstall`,`Execute post-install logic function if defined`).option(`--preInstall`,`Execute pre-install logic function if defined`).option(`-p, --payload <payload>`,`JSON payload to send to the function`,`{}`).option(`-u, --functionUniversalIdentifier <functionUniversalIdentifier>`,`Universal ID of the function to execute`).option(`-n, --functionName <functionName>`,`Name of the function to execute`).action(async(e,t)=>{T(`exec`,`dev:function:exec`),!t?.postInstall&&!t?.preInstall&&!t?.functionUniversalIdentifier&&!t?.functionName&&(console.error(u.default.red(`Error: Either --postInstall, --preInstall, --functionName (-n), or --functionUniversalIdentifier (-u) is required.`)),process.exit(1)),await i.execute({...t,payload:t?.payload??`{}`,appPath:g(e)})}),e.command(`add [entityType]`,{hidden:!0}).option(`--path <path>`,`Path in which the entity should be created.`).action(async(e,t)=>{T(`add`,`dev:add`),await a.execute(e,t?.path)}),e.command(`publish [appPath]`,{hidden:!0}).option(`--tag <tag>`,`npm dist-tag (e.g. beta, next)`).action(async(e,t)=>{T(`publish`,`app:publish`),await o.execute({appPath:g(e),tag:t.tag})}),e.command(`deploy [appPath]`,{hidden:!0}).option(`-r, --remote <name>`,`Deploy to a specific remote`).action(async(e,t)=>{T(`deploy`,`app:publish --private`),await o.execute({appPath:g(e),private:!0,remote:t.remote})}),e.command(`install [appPath]`,{hidden:!0}).option(`-r, --remote <name>`,`Install on a specific remote`).action(async(e,t)=>{T(`install`,`app:install`),await s.execute({appPath:g(e),remote:t.remote})}),e.command(`uninstall [appPath]`,{hidden:!0}).option(`-y, --yes`,`Skip confirmation prompt`).action(async(e,t)=>{T(`uninstall`,`app:uninstall`);try{let n=await c.execute({appPath:g(e),askForConfirmation:!t?.yes});process.exit(+!n.success)}catch{process.exit(1)}}),e.command(`catalog-sync`,{hidden:!0}).option(`-r, --remote <name>`,`Sync on a specific remote`).action(async e=>{T(`catalog-sync`,`dev:catalog-sync`);let{CatalogSyncCommand:t}=await Promise.resolve().then(()=>require("./catalog-sync-CgKswjsE.js"));await new t().execute({remote:e.remote})})},Pe=class{constructor({state:e,notify:t}){this.state=e,this.notify=t}async execute(e){let n=this.state.steps.buildManifest;n.status=`in_progress`,this.state.updatePipeline({status:`building`});let r=[{message:`Building manifest`,status:`info`}],i=await t.Q(e.appPath);if(!i.success){for(let e of i.errors)r.push({message:e,status:`error`});return n.output={result:null},n.status=`error`,this.state.updatePipeline({status:`error`}),this.state.applyStepEvents(r),null}if(i.warnings.length>0)for(let e of i.warnings)r.push({message:`⚠ ${e}`,status:`warning`});r.push({message:`Successfully built manifest`,status:`success`});let a={manifest:i.manifest,filePaths:i.filePaths};return n.output={result:a},n.status=`done`,this.state.updatePipeline({appName:i.manifest.application.displayName}),this.state.updateEntitiesFromManifest(i.filePaths),this.state.applyStepEvents(r),a}},Fe=class{constructor({apiService:e,state:t,notify:n}){this.hasRetried=!1,this.apiService=e,this.state=t,this.notify=n}async execute(){let e=this.state.steps.checkServer,r=await this.apiService.validateAuth();if(!r.serverUp){let n=await t.p();return n&&!this.hasRetried?(this.hasRetried=!0,await new t.V().setConfig({apiUrl:n}),this.execute()):(e.output.errorLogged||(e.output={isReady:!1,errorLogged:!0},e.status=`error`,this.state.applyStepEvents([{message:`Cannot reach Twenty server.
339
339
 
340
340
  Start a local server:
341
341
  yarn twenty docker:start
@@ -343,11 +343,13 @@ export default defineViewField({
343
343
  Check server status:
344
344
  yarn twenty docker:status
345
345
 
346
- Waiting for server...`,status:`error`}]),this.state.updatePipeline({status:`error`})),!1)}if(!r.authValid)return e.output.errorLogged||(e.output={isReady:!1,errorLogged:!0},e.status=`error`,this.state.applyStepEvents([{message:"Authentication failed. Run `yarn twenty remote:add` to authenticate.",status:`error`}]),this.state.updatePipeline({status:`error`})),!1;let i=e.output.isReady;if(e.output={isReady:!0,errorLogged:!1},e.status=`done`,!n.t(this.state.frontendUrl)){let e=await this.apiService.getWorkspaceFrontendUrl();n.t(e)&&(this.state.frontendUrl=e)}return i||this.notify(),!0}},Ie=class{constructor({clientService:e,configService:t,state:n,notify:r}){this.clientService=e,this.configService=t,this.state=n,this.notify=r}async execute(e){let n=this.state.steps.generateApiClient;n.status=`in_progress`,this.notify();try{let r=await t.d(this.configService,e.credentials);await this.clientService.generateCoreClient({appPath:e.appPath,appAccessToken:r}),n.status=`done`}catch(e){this.state.applyStepEvents([{message:`Failed to generate API client: ${e instanceof Error?e.message:String(e)}`,status:`error`}]),n.status=`error`}this.notify()}},Le=class{constructor({apiService:e,configService:t,state:n,notify:r}){this.apiService=e,this.configService=t,this.state=n,this.notify=r}async execute(e){try{let n=await t.u(this.apiService,this.configService,{name:e.manifest.application.displayName,universalIdentifier:e.manifest.application.universalIdentifier});this.registrationCredentials={clientId:n.clientId,clientSecret:n.clientSecret},this.state.applyStepEvents([{message:n.isNewRegistration?`App registration created: ${e.manifest.application.displayName}`:`Existing app registration found`,status:n.isNewRegistration?`success`:`info`},...n.isNewRegistration?[{message:`Credentials saved to config.`,status:`info`}]:[]])}catch(e){throw this.state.applyStepEvents([{message:`Failed to register app: ${e instanceof Error?e.message:String(e)}`,status:`error`}]),e}this.notify()}},Re=class{constructor(e){this.watcher=null,this.appPath=e.appPath,this.fileFolder=e.fileFolder,this.watchPaths=e.watchPaths,this.handleFileBuilt=e.handleFileBuilt}async start(){let e=(await Promise.all(this.watchPaths.map(async e=>{let n=(0,r.join)(this.appPath,e);return await t.at(n)?n:null}))).filter(e=>e!==null);e.length!==0&&(this.watcher=f.default.watch(e,{awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on(`all`,(e,t)=>{e===`addDir`||e===`unlinkDir`||((e===`add`||e===`change`)&&this.copyAndNotify(t),e===`unlink`&&this.handleUnlink(t))}))}async close(){await this.watcher?.close()}async copyAndNotify(e){let n=(0,r.relative)(this.appPath,e),a=(0,r.join)(t.lt,n),o=(0,r.join)(this.appPath,a);await t.it((0,r.dirname)(o)),await t.nt(e,o);let s=await(0,i.readFile)(o),l=c.default.createHash(`md5`).update(s).digest(`hex`);this.handleFileBuilt({fileFolder:this.fileFolder,builtPath:a,sourcePath:n,checksum:l})}async handleUnlink(e){let n=(0,r.join)(t.lt,(0,r.relative)(this.appPath,e));await t.st((0,r.join)(this.appPath,n))}},ze=class{constructor(e){this.process=null,this.pendingErrors=[],this.buffer=``,this.hasErrors=!1,this.appPath=e.appPath,this.onErrors=e.onErrors}async start(){let e=s.default.join(this.appPath,`node_modules`,`.bin`,`tsc`);if(!await t.at(e))return;let n=s.default.join(this.appPath,`tsconfig.json`);this.process=(0,l.spawn)(e,[`--watch`,`--noEmit`,`--pretty`,`false`,`-p`,n],{cwd:this.appPath,stdio:[`ignore`,`pipe`,`pipe`]}),this.process.on(`error`,()=>{this.process=null}),this.process.stdout?.on(`data`,e=>{this.handleOutput(e.toString())}),this.process.stderr?.on(`data`,e=>{this.handleOutput(e.toString())})}close(){this.process?.kill(),this.process=null}handleOutput(e){this.buffer+=e;let t=this.buffer.split(`
347
- `);this.buffer=t.pop()??``;for(let e of t)this.processLine(e)}processLine(e){if(e.includes(`Starting compilation in watch mode...`)||e.includes(`Starting incremental compilation...`)){this.pendingErrors=[];return}if(e.includes(`Watching for file changes.`)){let e=this.hasErrors;this.hasErrors=this.pendingErrors.length>0,(this.hasErrors||e)&&this.onErrors(this.pendingErrors),this.pendingErrors=[];return}let n=t.et(e);n&&this.pendingErrors.push(n)}},Be=new Set([`node_modules`,`dist`,`.twenty`]),Ve=class{constructor(e){this.watcher=null,this.appPath=e.appPath,this.handleChangeDetected=e.handleChangeDetected,this.verbose=e.verbose??!1}async start(){let e=this.appPath;this.watcher=f.default.watch(this.appPath,{ignoreInitial:!this.verbose,ignored:t=>{let n=(0,r.relative)(e,t);if(n===``)return!1;let i=n.split(r.default.sep)[0];return Be.has(i)||i.startsWith(`.`)},awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on(`all`,(e,n)=>{if(e===`addDir`||e===`unlinkDir`)return;let i=(0,r.relative)(this.appPath,n),a=i.startsWith(t.ut),o=[`package.json`,`yarn.lock`].includes(i);!(i.endsWith(`.ts`)||i.endsWith(`.tsx`))&&!a&&!o||this.handleChangeDetected(i,e)})}async close(){await this.watcher?.close()}},He=class{constructor(e){this.manifestWatcher=null,this.logicFunctionsWatcher=null,this.frontComponentsWatcher=null,this.assetWatcher=null,this.dependencyWatcher=null,this.tscWatcher=null,this.state=e.state,this.scheduleSync=e.scheduleSync,this.notify=e.notify,this.onFileBuilt=e.onFileBuilt,this.shouldSkipTypecheck=e.shouldSkipTypecheck,this.verbose=e.verbose??!1}async start(){this.state.steps.startWatchers.status=`in_progress`,this.notify(),this.manifestWatcher=new Ve({appPath:this.state.appPath,handleChangeDetected:this.handleChangeDetected.bind(this),verbose:this.verbose}),await this.manifestWatcher.start()}async handleWatcherRestarts(e){let{logicFunctions:t,frontComponents:n}=e.filePaths;if(!this.state.steps.startWatchers.output.watchersStarted){this.state.steps.startWatchers.output.watchersStarted=!0,this.state.steps.startWatchers.status=`done`,await this.startFileWatchers(t,n);return}this.logicFunctionsWatcher?.shouldRestart(t)&&await this.logicFunctionsWatcher.restart(t),this.frontComponentsWatcher?.shouldRestart(n)&&await this.frontComponentsWatcher.restart(n)}async close(){this.tscWatcher?.close(),await Promise.all([this.manifestWatcher?.close(),this.logicFunctionsWatcher?.close(),this.frontComponentsWatcher?.close(),this.assetWatcher?.close(),this.dependencyWatcher?.close()])}handleChangeDetected(e,t){this.state.addEvent({message:`Change detected: ${e}`,status:`info`,spacingBefore:!0}),t===`unlink`?this.state.removeEntity(e):this.state.updateEntityStatus(e,`building`),this.notify(),this.scheduleSync()}handleFileBuildError(e){this.state.addEvent({message:`Build failed:`,status:`error`});for(let t of e)this.state.addEvent({message:t.error,status:`error`});this.notify()}handleFileBuilt(e){this.verbose&&this.state.addEvent({message:`Successfully built ${e.builtPath}`,status:`success`}),this.state.steps.uploadFiles.output.builtFileInfos.set(e.builtPath,{checksum:e.checksum,builtPath:e.builtPath,sourcePath:e.sourcePath,fileFolder:e.fileFolder,usesSdkClient:e.usesSdkClient}),this.onFileBuilt(e),this.notify(),this.scheduleSync()}async startFileWatchers(e,t){await Promise.all([this.startTscWatcher(),this.startLogicFunctionsWatcher(e),this.startFrontComponentsWatcher(t),this.startAssetWatcher(),this.startDependencyWatcher()])}async startLogicFunctionsWatcher(e){this.logicFunctionsWatcher=t.$({appPath:this.state.appPath,sourcePaths:e,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.logicFunctionsWatcher.start()}async startFrontComponentsWatcher(e){this.frontComponentsWatcher=t.Q({appPath:this.state.appPath,sourcePaths:e,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.frontComponentsWatcher.start()}async startAssetWatcher(){this.assetWatcher=new Re({appPath:this.state.appPath,fileFolder:t.mt.PublicAsset,watchPaths:[t.ut],handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.assetWatcher.start()}async startDependencyWatcher(){this.dependencyWatcher=new Re({appPath:this.state.appPath,fileFolder:t.mt.Dependencies,watchPaths:[`package.json`,`yarn.lock`],handleFileBuilt:this.handleFileBuilt.bind(this)}),this.dependencyWatcher.start()}async startTscWatcher(){this.tscWatcher=new ze({appPath:this.state.appPath,onErrors:this.handleTypecheckErrors.bind(this)}),await this.tscWatcher.start()}handleTypecheckErrors(e){e.length===0?this.state.addEvent({message:`Typecheck passed`,status:`success`}):this.state.applyStepEvents(e.map(e=>({message:`Type error in ${e.file}(${e.line},${e.column}): ${e.text}`,status:`error`}))),this.notify()}},Ue=class{constructor({apiService:e,state:t,notify:n,verbose:r}){this.apiService=e,this.state=t,this.notify=n,this.verbose=r??!1}async execute(e){let n=this.state.steps.syncApplication;n.status=`in_progress`,this.state.updatePipeline({status:`syncing`});let r=[],i=t.X({manifest:e.manifest,builtFileInfos:e.builtFileInfos});r.push({message:`Manifest checksums set`,status:`info`}),await t.Y(e.appPath,i),r.push({message:`Manifest saved to output directory`,status:`info`}),r.push({message:`Syncing manifest`,status:`info`});let a=await this.apiService.syncApplication(i);if(a.success){let e=a.data;r.push(...t.l(e.actions)),r.push({message:`✓ Synced`,status:`success`}),n.output={syncStatus:`synced`,error:null},n.status=`done`,this.state.updatePipeline({status:`synced`,error:null}),this.state.updateAllEntitiesStatus(`success`),this.state.applyStepEvents(r);return}let o=this.verbose?null:t.M(a.error);o?(r.push(...o),r.push({message:`Add --verbose to see full error log`,status:`info`})):r.push({message:`Sync failed with error: ${a.message??`Sync failed`}`,status:`error`});let s=t.c(a.message);s&&r.push({message:s,status:`info`});let c=o?o[0].message:`Sync failed`;n.output={syncStatus:`error`,error:c},n.status=`error`,this.state.updatePipeline({status:`error`,error:c}),this.state.updateAllEntitiesStatus(`error`),this.state.applyStepEvents(r)}},We=class{constructor({state:e,notify:t,verbose:n}){this.uploadedCount=0,this.failedCount=0,this.totalQueued=0,this.state=e,this.notify=t,this.verbose=n??!1}get isInitialized(){return n.t(this.state.steps.uploadFiles.output.fileUploader)}initialize(e){let n=this.state.steps.uploadFiles;n.output={...n.output,fileUploader:new t.s({appPath:e.appPath,applicationUniversalIdentifier:e.universalIdentifier})},n.status=`in_progress`,this.notify(),this.uploadPendingFiles()}uploadFile(e,t,n){let r=this.state.steps.uploadFiles;if(!r.output.fileUploader)return;r.status=`in_progress`,this.totalQueued++,this.verbose&&this.state.addEvent({message:`Uploading ${e}`,status:`info`}),this.state.updateEntityStatus(t,`uploading`),this.notify();let i=r.output.fileUploader.uploadFile({builtPath:e,fileFolder:n}).then(n=>{n.success?(this.uploadedCount++,this.verbose&&this.state.addEvent({message:`Successfully uploaded ${e}`,status:`success`}),this.state.updateEntityStatus(t,`success`)):(this.failedCount++,this.state.addEvent({message:`Failed to upload ${e}: ${n.error}`,status:`error`}))}).catch(t=>{this.failedCount++,this.state.addEvent({message:`Upload failed for ${e}: ${t}`,status:`error`})}).finally(()=>{r.output.activeUploads.delete(i),r.output.activeUploads.size===0&&(this.logUploadSummary(),r.status=`done`,this.notify())});r.output.activeUploads.add(i)}async waitForUploads(){let e=this.state.steps.uploadFiles;for(;e.output.activeUploads.size>0;)await Promise.all(e.output.activeUploads);e.status=`done`,this.notify()}logUploadSummary(){if(this.totalQueued===0){this.resetCounters();return}this.failedCount>0&&this.state.addEvent({message:`Uploaded ${this.uploadedCount}/${this.totalQueued} files (${this.failedCount} failed)`,status:`error`}),this.state.addEvent({message:`Successfully uploaded ${this.uploadedCount} file${this.uploadedCount===1?``:`s`}`,status:`success`}),this.resetCounters()}resetCounters(){this.uploadedCount=0,this.failedCount=0,this.totalQueued=0}uploadPendingFiles(){for(let[e,{fileFolder:t,sourcePath:n}]of this.state.steps.uploadFiles.output.builtFileInfos.entries())this.uploadFile(e,n,t)}},Ge=class{constructor(e){this.syncTimer=null,this.serverCheckInterval=null,this.skipTypecheck=!0,this.debounceMs=e.debounceMs??1e3,this.state=e.state,this.verbose=e.verbose??!1,this.apiService=new t.L({disableInterceptors:!0});let n=this.apiService,r=new t.V;this.clientService=new t.m;let i={state:this.state,notify:()=>this.state.notify()};this.checkServerStep=new Fe({...i,apiService:n}),this.buildManifestStep=new Pe(i),this.registerAppStep=new Le({...i,apiService:n,configService:r}),this.uploadFilesStep=new We({...i,verbose:this.verbose}),this.generateApiClientStep=new Ie({...i,clientService:this.clientService,configService:r}),this.syncApplicationStep=new Ue({...i,apiService:n,verbose:this.verbose}),this.startWatchersStep=new He({...i,scheduleSync:this.scheduleSync.bind(this),onFileBuilt:this.handleFileBuilt.bind(this),shouldSkipTypecheck:()=>this.skipTypecheck,verbose:this.verbose})}async start(){let e=r.default.join(this.state.appPath,t.lt);await t.it(e),await t.rt(e),this.state.addEvent({message:`Using remote "${t.V.getActiveRemote()}"`,status:`info`}),this.verbose||this.state.addEvent({message:`Add --verbose to see fully detailed logs`,status:`info`}),this.state.notify(),await this.startWatchersStep.start(),this.serverCheckInterval=setInterval(()=>{this.checkServerHealth()},2e3)}async close(){this.serverCheckInterval&&clearInterval(this.serverCheckInterval),await this.startWatchersStep.close()}getState(){return this.state}handleFileBuilt(e){this.state.steps.uploadFiles.output.fileUploader&&this.uploadFilesStep.uploadFile(e.builtPath,e.sourcePath,e.fileFolder)}async checkServerHealth(){let e=this.state.steps.checkServer.output.isReady;await this.checkServerStep.execute()&&!e&&this.scheduleSync()}scheduleSync(){this.syncTimer&&clearTimeout(this.syncTimer),this.syncTimer=setTimeout(()=>{this.syncTimer=null,this.performSync()},this.debounceMs)}async performSync(){if(!this.state.pipeline.isSyncing){this.state.updatePipeline({isSyncing:!0});try{await this.runSyncPipeline()}catch(e){this.state.addEvent({message:`Sync failed with error: ${t.R(e)}`,status:`error`}),this.state.updatePipeline({status:`error`}),this.state.updateAllEntitiesStatus(`error`)}finally{this.state.updatePipeline({isSyncing:!1})}}}async runSyncPipeline(){if(!await this.checkServerStep.execute())return;this.state.steps.ensureValidTokens.status=`done`;let e=await this.buildManifestStep.execute({appPath:this.state.appPath});if(!e||(await this.startWatchersStep.handleWatcherRestarts(e),!this.uploadFilesStep.isInitialized&&!await this.initializePipeline(e.manifest)))return;let t=this.state.hasObjectsOrFieldsChanged(e.manifest);await this.uploadFilesStep.waitForUploads(),await this.syncApplicationStep.execute({manifest:e.manifest,builtFileInfos:this.state.steps.uploadFiles.output.builtFileInfos,appPath:this.state.appPath}),this.state.steps.syncApplication.status!==`error`&&t&&(await this.generateApiClientStep.execute({appPath:this.state.appPath,credentials:this.registerAppStep.registrationCredentials}),this.skipTypecheck=!1)}async initializePipeline(e){await this.registerAppStep.execute({manifest:e});let t=await this.apiService.createDevelopmentApplication({universalIdentifier:e.application.universalIdentifier,name:e.application.displayName});return!t.success||!t.data?(this.state.applyStepEvents([{message:`Failed to install development application`,status:`error`},{message:JSON.stringify(t,null,2),status:`error`}]),this.state.updatePipeline({status:`error`}),!1):(this.state.steps.resolveApplication.output={applicationId:t.data.id,universalIdentifier:t.data.universalIdentifier},this.state.steps.resolveApplication.status=`done`,this.state.applyStepEvents([{message:`Application installed`,status:`success`}]),this.uploadFilesStep.initialize({appPath:this.state.appPath,universalIdentifier:e.application.universalIdentifier}),!0)}},Ke={objects:t.ct.Object,fields:t.ct.Field,logicFunctions:t.ct.LogicFunction,frontComponents:t.ct.FrontComponent,roles:t.ct.Role,skills:t.ct.Skill,connectionProviders:t.ct.ConnectionProvider,views:t.ct.View,viewFields:t.ct.ViewField,navigationMenuItems:t.ct.NavigationMenuItem,pageLayouts:t.ct.PageLayout,pageLayoutTabs:t.ct.PageLayoutTab,commandMenuItems:t.ct.CommandMenuItem},qe=200,Je={pending:[`building`,`uploading`,`success`,`error`],building:[`pending`,`uploading`,`success`,`error`],uploading:[`pending`,`success`,`error`],success:[`pending`,`building`,`uploading`,`error`],error:[`pending`,`building`,`uploading`,`success`]},Ye=class{constructor(e){this.eventIdCounter=0,this.appPath=e.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(e){this.versionInfo=e,this.notify()}notify(){this.onChange?.()}updatePipeline(e){Object.assign(this.pipeline,e),this.notify()}applyStepEvents(e){let t=e.map(e=>(this.eventIdCounter+=1,{...e,id:this.eventIdCounter,timestamp:new Date,message:e.message.slice(0,5e3)}));this.events=[...this.events.slice(-(qe-t.length)),...t]}addEvent(e){this.applyStepEvents([e])}updateEntityStatus(e,t){let n=new Map(this.entities),r=n.get(e);r?.status&&!Je[r.status].includes(t)||(n.set(e,r?{...r,status:t}:{name:e,path:e,status:t}),this.entities=n)}removeEntity(e){let t=new Map(this.entities);t.delete(e),this.entities=t}updateAllEntitiesStatus(e){let t=new Map(this.entities);for(let[n,r]of t)t.set(n,{...r,status:e});this.entities=t}updateEntitiesFromManifest(e){let t=new Map;for(let[n,r]of Object.entries(e)){let e=Ke[n];if(e)for(let n of r)t.set(n,e)}let n=new Map(this.entities);for(let[e,r]of n)n.set(e,{...r,type:t.get(e)});for(let[e,r]of t)n.has(e)||n.set(e,{name:e,path:e,type:r,status:`pending`});this.entities=n}hasObjectsOrFieldsChanged(e){let t=JSON.stringify({objects:e.objects,fields:e.fields}),n=t!==this.previousObjectsFieldsFingerprint;return this.previousObjectsFieldsFingerprint=t,n}},Xe={idle:{color:`gray`,icon:`○`},in_progress:{color:`yellow`,icon:`spinner`},uploading:{color:`cyan`,icon:`upload`},done:{color:`green`,icon:`✓`},error:{color:`red`,icon:`✗`}},Ze=e=>({idle:`idle`,in_progress:`in_progress`,done:`done`,error:`error`})[e],Qe=e=>({pending:`idle`,building:`in_progress`,uploading:`uploading`,success:`done`,error:`error`})[e],$e=e=>({idle:`idle`,building:`in_progress`,syncing:`in_progress`,synced:`done`,error:`error`})[e],et={idle:`Idle`,building:`Building...`,syncing:`Syncing...`,synced:`Synced`,error:`Error`},tt=[`◐`,`◓`,`◑`,`◒`],nt=[`↑`,`⇡`,`↑`,`⇡`],rt={[t.ct.Object]:`Objects`,[t.ct.Field]:`Fields`,[t.ct.LogicFunction]:`Logic functions`,[t.ct.FrontComponent]:`Front components`,[t.ct.CommandMenuItem]:`Command menu items`,[t.ct.Role]:`Roles`,[t.ct.Skill]:`Skills`,[t.ct.View]:`Views`,[t.ct.ViewField]:`View fields`,[t.ct.NavigationMenuItem]:`Navigation menu items`,[t.ct.PageLayout]:`Page layouts`,[t.ct.PageLayoutTab]:`Page layout tabs`,[t.ct.Agent]:`Agents`,[t.ct.ConnectionProvider]:`Connection providers`},it=Object.keys(rt),at={info:`gray`,success:`green`,error:`red`,warning:`yellow`},ot=e=>e.toLocaleTimeString(`en-US`,{hour12:!1,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),st=(e,t=40)=>{if(e.length<=t)return e;let n=e.split(`/`);return n.length<=2?e:`.../${n.slice(-2).join(`/`)}`},ct=e=>{let t=new Map;for(let e of it)t.set(e,[]);for(let n of e.values()){if(!n.type)continue;let e=t.get(n.type)??[];e.push(n),t.set(n.type,e)}return t},lt=[{status:`success`,label:`synced`},{status:`building`,label:`building`},{status:`uploading`,label:`uploading`},{status:`pending`,label:`pending`},{status:`error`,label:`error`}],ut=e=>{let t={pending:0,building:0,uploading:0,success:0,error:0};for(let n of e)t[n.status]+=1;return lt.filter(({status:e})=>t[e]>0).map(({status:e,label:n})=>({status:e,count:t[e],label:n}))},E=e=>{let t=e.steps.resolveApplication.output.applicationId;return!n.t(e.frontendUrl)||!n.t(t)?null:`${e.frontendUrl}/settings/applications/${t}`},dt=e=>e.some(e=>e===`error`)?`error`:e.some(e=>e===`in_progress`)?`in_progress`:e.every(e=>e===`done`)?`done`:`idle`,ft=e=>{let t=[...e.entities.values()],n=t.some(e=>e.status===`error`),r=t.some(e=>e.status===`building`),i=t.length>0&&t.every(e=>e.status===`uploading`||e.status===`success`),a=n?`error`:r?`in_progress`:i?`done`:`idle`;return[{label:`Application Initialization`,status:dt([e.steps.checkServer.status,e.steps.ensureValidTokens.status,e.steps.resolveApplication.status])},{label:`Resources Build`,status:a},{label:`Resources Upload`,status:e.steps.uploadFiles.status},{label:`Manifest Build`,status:e.steps.buildManifest.status},{label:`Application Synchronization`,status:e.steps.syncApplication.status},{label:`Api Client Generation`,status:e.steps.generateApiClient.status}]},pt=120,mt=Math.round(200/pt),ht=()=>{let e=Math.floor(Date.now()/pt);return{spinnerFrame:tt[e%tt.length],uploadFrame:nt[Math.floor(e/mt)%nt.length]}},gt=e=>{let t=Xe[e];return t.icon===`spinner`?ht().spinnerFrame:t.icon===`upload`?ht().uploadFrame:t.icon},_t=o.default.createContext(null),vt=_t.Provider,yt=()=>{let e=o.default.useContext(_t);if(!e)throw Error(`useInk must be used within InkProvider`);return e},bt=({uiStatus:e})=>{let{Text:t}=yt(),n=gt(e),r=Xe[e];return(0,p.jsxs)(t,{color:r.color,children:[n,` `]})},xt=({entity:e})=>{let{Box:t,Text:n}=yt();return(0,p.jsxs)(t,{children:[(0,p.jsx)(bt,{uiStatus:Qe(e.status)}),(0,p.jsx)(n,{children:e.name}),e.path!==e.name&&(0,p.jsxs)(n,{dimColor:!0,children:[` (`,st(e.path),`)`]})]})},St=({type:e,entities:t})=>{let{Box:n,Text:r}=yt();return t.length===0?null:(0,p.jsxs)(n,{flexDirection:`column`,marginTop:1,children:[(0,p.jsx)(r,{bold:!0,dimColor:!0,children:rt[e]}),t.map(e=>(0,p.jsx)(xt,{entity:e},e.path))]})},Ct=({entities:e})=>{let{Box:t,Text:n}=yt();if(e.length===0)return null;let r=ut(e);return(0,p.jsxs)(t,{marginTop:1,children:[(0,p.jsxs)(n,{bold:!0,dimColor:!0,children:[`Entities`,` `]}),r.map((e,r)=>(0,p.jsxs)(t,{children:[r>0&&(0,p.jsx)(n,{dimColor:!0,children:` · `}),(0,p.jsx)(bt,{uiStatus:Qe(e.status)}),(0,p.jsxs)(n,{children:[e.count,` `,e.label]})]},e.status))]})},wt=()=>{let{Box:e,Text:t}=yt();return(0,p.jsx)(e,{marginTop:1,children:(0,p.jsxs)(t,{dimColor:!0,children:[(0,p.jsx)(t,{color:Xe.idle.color,children:Xe.idle.icon}),` `,`pending`,` `,(0,p.jsx)(t,{color:Xe.in_progress.color,children:tt[0]}),` `,`building`,` `,(0,p.jsx)(t,{color:Xe.uploading.color,children:nt[0]}),` `,`uploading`,` `,(0,p.jsx)(t,{color:Xe.done.color,children:Xe.done.icon}),` `,`success`,` `,(0,p.jsx)(t,{color:Xe.error.color,children:Xe.error.icon}),` `,`error`]})})},Tt=7,Et=({versionInfo:e})=>{let{Box:t,Text:n}=yt();if(e===null)return null;let{cliVersion:r,localServerVersion:i,latestServerVersion:a,isMinorOrMajorBehind:o,daysBehind:s}=e,c=o&&s!==null&&s>Tt;return(0,p.jsxs)(t,{children:[(0,p.jsx)(n,{dimColor:!0,children:`Versions: `}),(0,p.jsx)(n,{dimColor:!0,children:`CLI `}),(0,p.jsxs)(n,{children:[`v`,r]}),i!==null&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(n,{dimColor:!0,children:` • Server `}),(0,p.jsxs)(n,{color:c?`yellow`:void 0,children:[`v`,i]}),i!==null&&a!==null&&i===a&&(0,p.jsx)(n,{color:`green`,children:` ✓ latest`}),c&&a!==null&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(n,{color:`yellow`,children:[` → v`,a]}),s!==null&&(0,p.jsxs)(n,{dimColor:!0,children:[` (`,s,`d behind)`]})]})]})]})},Dt=({state:e})=>{let{Text:t}=yt(),n=$e(e.pipeline.status),r=gt(n),i=Xe[n],a=et[e.pipeline.status];return(0,p.jsxs)(t,{color:i.color,children:[r,` `,a]})},Ot=({label:e,status:t})=>{let{Box:n,Text:r}=yt(),i=Ze(t),a=gt(i),o=Xe[i];return(0,p.jsxs)(n,{children:[(0,p.jsxs)(r,{dimColor:!0,children:[e,`: `]}),(0,p.jsxs)(r,{color:o.color,children:[a,` `,t.replace(`_`,` `)]})]})},kt=({state:e,verbose:t=!1})=>{let{Box:n,Text:r}=yt(),i=ct(e.entities),a=E(e);return(0,p.jsxs)(n,{flexDirection:`column`,borderStyle:`classic`,borderColor:`gray`,paddingX:1,children:[(0,p.jsx)(r,{bold:!0,color:`cyan`,children:`Application`}),(0,p.jsxs)(n,{marginLeft:2,flexDirection:`column`,children:[(0,p.jsxs)(n,{children:[(0,p.jsx)(r,{dimColor:!0,children:`Name: `}),(0,p.jsx)(r,{bold:!0,children:e.pipeline.appName??`Loading...`})]}),(0,p.jsxs)(n,{children:[(0,p.jsx)(r,{dimColor:!0,children:`Overall Status: `}),(0,p.jsx)(Dt,{state:e})]}),a&&(0,p.jsxs)(n,{children:[(0,p.jsx)(r,{dimColor:!0,children:`Open:`}),(0,p.jsxs)(r,{bold:!0,color:`cyan`,children:[` `,a]})]}),(0,p.jsx)(Et,{versionInfo:e.versionInfo})]}),(0,p.jsx)(n,{marginLeft:2,flexDirection:`column`,marginTop:1,children:ft(e).map(e=>(0,p.jsx)(Ot,{label:e.label,status:e.status},e.label))}),(0,p.jsx)(n,{marginLeft:2,flexDirection:`column`,children:t?it.map(e=>(0,p.jsx)(St,{type:e,entities:i.get(e)??[]},e)):(0,p.jsx)(Ct,{entities:Array.from(e.entities.values())})})]})},D=({event:e})=>{let{Box:t,Text:n}=yt(),r=at[e.status],i=ot(e.timestamp);return(0,p.jsxs)(t,{marginTop:+!!e.spacingBefore,children:[(0,p.jsxs)(n,{dimColor:!0,children:[i,` `]}),(0,p.jsx)(n,{color:r,children:e.message})]})},At=new Set([`building`,`syncing`]),jt=120,O=80,Mt=({uiStateManager:e,verbose:t})=>{let{Box:n,Static:r}=yt(),[,i]=(0,o.useReducer)(e=>e+1,0),a=(0,o.useRef)(null),s=(0,o.useRef)(0),c=(0,o.useCallback)(()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,s.current=Date.now(),i()},O)},[]);(0,o.useEffect)(()=>e.subscribe(()=>{c()}),[e,c]),(0,o.useEffect)(()=>{let t=setInterval(()=>{let t=e.getSnapshot();At.has(t.pipeline.status)&&(Date.now()-s.current<jt||i())},jt);return()=>clearInterval(t)},[e]),(0,o.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]);let l=e.getSnapshot();return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r,{items:l.events,children:e=>(0,p.jsx)(D,{event:e},e.id)}),(0,p.jsxs)(n,{marginTop:1,flexDirection:`column`,children:[(0,p.jsx)(kt,{state:l,verbose:t}),t&&(0,p.jsx)(wt,{})]})]})},Nt=async(e,t=!1)=>{let{render:n,Box:r,Text:i,Static:a}=await import(`ink`),{unmount:o}=n((0,p.jsx)(vt,{value:{Box:r,Text:i,Static:a},children:(0,p.jsx)(Mt,{uiStateManager:e,verbose:t})}));return{unmount:o}},Pt=class{constructor(e){this.listeners=new Set,this.pendingNotify=!1,this.orchestratorState=e}getSnapshot(){return this.orchestratorState}subscribe(e){return this.listeners.add(e),e(this.orchestratorState),()=>this.listeners.delete(e)}notify(){this.pendingNotify||(this.pendingNotify=!0,queueMicrotask(()=>{this.pendingNotify=!1;for(let e of this.listeners)e(this.orchestratorState)}))}},Ft=class{constructor(){this.orchestrator=null,this.unmountUI=null}async close(){this.unmountUI?.(),await this.orchestrator?.close()}getOrchestrator(){return this.orchestrator}async ensureAuthenticatedBeforeLaunch(){let{serverUp:e,authValid:n}=await new t.L({disableInterceptors:!0}).validateAuth();e&&!n&&await t.z(t.V.getActiveRemote())}async execute(e){let n=e.appPath??t.vt;await y(n),e.headless&&await t._(),await this.ensureAuthenticatedBeforeLaunch();let r=new Ye({appPath:n});if(!e.headless){let n=new Pt(r);r.onChange=()=>n.notify();let{unmount:i}=await Nt(n,e.verbose);this.unmountUI=i,t.v().then(e=>r.setVersionInfo(e))}this.orchestrator=new Ge({state:r,verbose:e.verbose,debounceMs:e.debounceMs}),await this.orchestrator.start(),e.headless||this.setupGracefulShutdown()}setupGracefulShutdown(){let e=()=>void this.close().then(()=>process.exit(0));process.on(`SIGINT`,e),process.on(`SIGTERM`,e)}},It=class{async execute(e){let n=e.appPath??t.vt;await y(n);let r=t.V.getActiveRemote();console.log(u.default.blue(`${e.dryRun?`Previewing application diff`:`Syncing application`} on ${r}...`)),console.log(u.default.gray(`App path: ${n}\n`));let i=await t.o({appPath:n,verbose:e.verbose,dryRun:e.dryRun,onProgress:e=>console.log(u.default.gray(e))});if(i.success||(console.error(u.default.red(i.error.message)),process.exit(1)),e.dryRun){console.log(u.default.green(`\n✓ Dry run complete for ${i.data.applicationDisplayName} — no changes were applied`));return}console.log(u.default.green(`\n✓ Synced ${i.data.applicationDisplayName} (${i.data.fileCount} file${i.data.fileCount===1?``:`s`})`)),console.log(u.default.gray(`Output: ${i.data.outputDir}`))}},k=class{async execute(e){let n=e.appPath??t.vt,i=(0,r.join)(n,`node_modules`,`twenty-client-sdk`);await t.at(i)||(console.error(u.default.red(`Cannot find twenty-client-sdk in ${n}.\n\n Install it first:
346
+ Waiting for server...`,status:`error`}]),this.state.updatePipeline({status:`error`})),!1)}if(!r.authValid)return e.output.errorLogged||(e.output={isReady:!1,errorLogged:!0},e.status=`error`,this.state.applyStepEvents([{message:"Authentication failed. Run `yarn twenty remote:add` to authenticate.",status:`error`}]),this.state.updatePipeline({status:`error`})),!1;let i=e.output.isReady;if(e.output={isReady:!0,errorLogged:!1},e.status=`done`,!n.t(this.state.frontendUrl)){let e=await this.apiService.getWorkspaceFrontendUrl();n.t(e)&&(this.state.frontendUrl=e)}return i||this.notify(),!0}},Ie=class{constructor({clientService:e,configService:t,state:n,notify:r}){this.clientService=e,this.configService=t,this.state=n,this.notify=r}async execute(e){let n=this.state.steps.generateApiClient;n.status=`in_progress`,this.notify();try{let r=await t.d(this.configService,e.credentials);await this.clientService.generateCoreClient({appPath:e.appPath,appAccessToken:r}),n.status=`done`}catch(e){this.state.applyStepEvents([{message:`Failed to generate API client: ${e instanceof Error?e.message:String(e)}`,status:`error`}]),n.status=`error`}this.notify()}},Le=class{constructor({apiService:e,configService:t,state:n,notify:r}){this.apiService=e,this.configService=t,this.state=n,this.notify=r}async execute(e){try{let n=await t.u(this.apiService,this.configService,{name:e.manifest.application.displayName,universalIdentifier:e.manifest.application.universalIdentifier});this.registrationCredentials={clientId:n.clientId,clientSecret:n.clientSecret},this.state.applyStepEvents([{message:n.isNewRegistration?`App registration created: ${e.manifest.application.displayName}`:`Existing app registration found`,status:n.isNewRegistration?`success`:`info`},...n.isNewRegistration?[{message:`Credentials saved to config.`,status:`info`}]:[]])}catch(e){throw this.state.applyStepEvents([{message:`Failed to register app: ${e instanceof Error?e.message:String(e)}`,status:`error`}]),e}this.notify()}},Re=class{constructor(e){this.watcher=null,this.appPath=e.appPath,this.fileFolder=e.fileFolder,this.watchPaths=e.watchPaths,this.handleFileBuilt=e.handleFileBuilt}async start(){let e=(await Promise.all(this.watchPaths.map(async e=>{let n=(0,r.join)(this.appPath,e);return await t.ot(n)?n:null}))).filter(e=>e!==null);e.length!==0&&(this.watcher=f.default.watch(e,{awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on(`all`,(e,t)=>{e===`addDir`||e===`unlinkDir`||((e===`add`||e===`change`)&&this.copyAndNotify(t),e===`unlink`&&this.handleUnlink(t))}))}async close(){await this.watcher?.close()}async copyAndNotify(e){let n=(0,r.relative)(this.appPath,e),a=(0,r.join)(t.dt,n),o=(0,r.join)(this.appPath,a);await t.at((0,r.dirname)(o)),await t.rt(e,o);let s=await(0,i.readFile)(o),l=c.default.createHash(`md5`).update(s).digest(`hex`);this.handleFileBuilt({fileFolder:this.fileFolder,builtPath:a,sourcePath:n,checksum:l})}async handleUnlink(e){let n=(0,r.join)(t.dt,(0,r.relative)(this.appPath,e));await t.ct((0,r.join)(this.appPath,n))}},ze=class{constructor(e){this.process=null,this.pendingErrors=[],this.buffer=``,this.hasErrors=!1,this.appPath=e.appPath,this.onErrors=e.onErrors}async start(){let e=s.default.join(this.appPath,`node_modules`,`.bin`,`tsc`);if(!await t.ot(e))return;let n=s.default.join(this.appPath,`tsconfig.json`);this.process=(0,l.spawn)(e,[`--watch`,`--noEmit`,`--pretty`,`false`,`-p`,n],{cwd:this.appPath,stdio:[`ignore`,`pipe`,`pipe`]}),this.process.on(`error`,()=>{this.process=null}),this.process.stdout?.on(`data`,e=>{this.handleOutput(e.toString())}),this.process.stderr?.on(`data`,e=>{this.handleOutput(e.toString())})}close(){this.process?.kill(),this.process=null}handleOutput(e){this.buffer+=e;let t=this.buffer.split(`
347
+ `);this.buffer=t.pop()??``;for(let e of t)this.processLine(e)}processLine(e){if(e.includes(`Starting compilation in watch mode...`)||e.includes(`Starting incremental compilation...`)){this.pendingErrors=[];return}if(e.includes(`Watching for file changes.`)){let e=this.hasErrors;this.hasErrors=this.pendingErrors.length>0,(this.hasErrors||e)&&this.onErrors(this.pendingErrors),this.pendingErrors=[];return}let n=t.tt(e);n&&this.pendingErrors.push(n)}},Be=new Set([`node_modules`,`dist`,`.twenty`]),Ve=class{constructor(e){this.watcher=null,this.appPath=e.appPath,this.handleChangeDetected=e.handleChangeDetected,this.verbose=e.verbose??!1}async start(){let e=this.appPath;this.watcher=f.default.watch(this.appPath,{ignoreInitial:!this.verbose,ignored:t=>{let n=(0,r.relative)(e,t);if(n===``)return!1;let i=n.split(r.default.sep)[0];return Be.has(i)||i.startsWith(`.`)},awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on(`all`,(e,n)=>{if(e===`addDir`||e===`unlinkDir`)return;let i=(0,r.relative)(this.appPath,n),a=i.startsWith(t.ft),o=[`package.json`,`yarn.lock`].includes(i);!(i.endsWith(`.ts`)||i.endsWith(`.tsx`))&&!a&&!o||this.handleChangeDetected(i,e)})}async close(){await this.watcher?.close()}},He=class{constructor(e){this.manifestWatcher=null,this.logicFunctionsWatcher=null,this.frontComponentsWatcher=null,this.assetWatcher=null,this.dependencyWatcher=null,this.tscWatcher=null,this.state=e.state,this.scheduleSync=e.scheduleSync,this.notify=e.notify,this.onFileBuilt=e.onFileBuilt,this.shouldSkipTypecheck=e.shouldSkipTypecheck,this.verbose=e.verbose??!1}async start(){this.state.steps.startWatchers.status=`in_progress`,this.notify(),this.manifestWatcher=new Ve({appPath:this.state.appPath,handleChangeDetected:this.handleChangeDetected.bind(this),verbose:this.verbose}),await this.manifestWatcher.start()}async handleWatcherRestarts(e){let{logicFunctions:t,frontComponents:n}=e.filePaths;if(!this.state.steps.startWatchers.output.watchersStarted){this.state.steps.startWatchers.output.watchersStarted=!0,this.state.steps.startWatchers.status=`done`,await this.startFileWatchers(t,n);return}this.logicFunctionsWatcher?.shouldRestart(t)&&await this.logicFunctionsWatcher.restart(t),this.frontComponentsWatcher?.shouldRestart(n)&&await this.frontComponentsWatcher.restart(n)}async close(){this.tscWatcher?.close(),await Promise.all([this.manifestWatcher?.close(),this.logicFunctionsWatcher?.close(),this.frontComponentsWatcher?.close(),this.assetWatcher?.close(),this.dependencyWatcher?.close()])}handleChangeDetected(e,t){this.state.addEvent({message:`Change detected: ${e}`,status:`info`,spacingBefore:!0}),t===`unlink`?this.state.removeEntity(e):this.state.updateEntityStatus(e,`building`),this.notify(),this.scheduleSync()}handleFileBuildError(e){this.state.addEvent({message:`Build failed:`,status:`error`});for(let t of e)this.state.addEvent({message:t.error,status:`error`});this.notify()}handleFileBuilt(e){this.verbose&&this.state.addEvent({message:`Successfully built ${e.builtPath}`,status:`success`}),this.state.steps.uploadFiles.output.builtFileInfos.set(e.builtPath,{checksum:e.checksum,builtPath:e.builtPath,sourcePath:e.sourcePath,fileFolder:e.fileFolder,usesSdkClient:e.usesSdkClient}),this.onFileBuilt(e),this.notify(),this.scheduleSync()}async startFileWatchers(e,t){await Promise.all([this.startTscWatcher(),this.startLogicFunctionsWatcher(e),this.startFrontComponentsWatcher(t),this.startAssetWatcher(),this.startDependencyWatcher()])}async startLogicFunctionsWatcher(e){this.logicFunctionsWatcher=t.et({appPath:this.state.appPath,sourcePaths:e,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.logicFunctionsWatcher.start()}async startFrontComponentsWatcher(e){this.frontComponentsWatcher=t.$({appPath:this.state.appPath,sourcePaths:e,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.frontComponentsWatcher.start()}async startAssetWatcher(){this.assetWatcher=new Re({appPath:this.state.appPath,fileFolder:t.gt.PublicAsset,watchPaths:[t.ft],handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.assetWatcher.start()}async startDependencyWatcher(){this.dependencyWatcher=new Re({appPath:this.state.appPath,fileFolder:t.gt.Dependencies,watchPaths:[`package.json`,`yarn.lock`],handleFileBuilt:this.handleFileBuilt.bind(this)}),this.dependencyWatcher.start()}async startTscWatcher(){this.tscWatcher=new ze({appPath:this.state.appPath,onErrors:this.handleTypecheckErrors.bind(this)}),await this.tscWatcher.start()}handleTypecheckErrors(e){e.length===0?this.state.addEvent({message:`Typecheck passed`,status:`success`}):this.state.applyStepEvents(e.map(e=>({message:`Type error in ${e.file}(${e.line},${e.column}): ${e.text}`,status:`error`}))),this.notify()}},Ue=class{constructor({apiService:e,state:t,notify:n,verbose:r}){this.apiService=e,this.state=t,this.notify=n,this.verbose=r??!1}async execute(e){let n=this.state.steps.syncApplication;n.status=`in_progress`,this.state.updatePipeline({status:`syncing`});let r=[],i=t.Z({manifest:e.manifest,builtFileInfos:e.builtFileInfos});r.push({message:`Manifest checksums set`,status:`info`}),await t.X(e.appPath,i),r.push({message:`Manifest saved to output directory`,status:`info`}),r.push({message:`Syncing manifest`,status:`info`});let a=await this.apiService.syncApplication(i);if(a.success){let e=a.data;r.push(...t.l(e.actions)),r.push({message:`✓ Synced`,status:`success`}),n.output={syncStatus:`synced`,error:null},n.status=`done`,this.state.updatePipeline({status:`synced`,error:null}),this.state.updateAllEntitiesStatus(`success`),this.state.applyStepEvents(r);return}let o=this.verbose?null:t.M(a.error);o?(r.push(...o),r.push({message:`Add --verbose to see full error log`,status:`info`})):r.push({message:`Sync failed with error: ${a.message??`Sync failed`}`,status:`error`});let s=t.c(a.message);s&&r.push({message:s,status:`info`});let c=o?o[0].message:`Sync failed`;n.output={syncStatus:`error`,error:c},n.status=`error`,this.state.updatePipeline({status:`error`,error:c}),this.state.updateAllEntitiesStatus(`error`),this.state.applyStepEvents(r)}},We=class{constructor({state:e,notify:t,verbose:n}){this.uploadedCount=0,this.failedCount=0,this.totalQueued=0,this.state=e,this.notify=t,this.verbose=n??!1}get isInitialized(){return n.t(this.state.steps.uploadFiles.output.fileUploader)}initialize(e){let n=this.state.steps.uploadFiles;n.output={...n.output,fileUploader:new t.s({appPath:e.appPath,applicationUniversalIdentifier:e.universalIdentifier})},n.status=`in_progress`,this.notify(),this.uploadPendingFiles()}uploadFile(e,t,n){let r=this.state.steps.uploadFiles;if(!r.output.fileUploader)return;r.status=`in_progress`,this.totalQueued++,this.verbose&&this.state.addEvent({message:`Uploading ${e}`,status:`info`}),this.state.updateEntityStatus(t,`uploading`),this.notify();let i=r.output.fileUploader.uploadFile({builtPath:e,fileFolder:n}).then(n=>{n.success?(this.uploadedCount++,this.verbose&&this.state.addEvent({message:`Successfully uploaded ${e}`,status:`success`}),this.state.updateEntityStatus(t,`success`)):(this.failedCount++,this.state.addEvent({message:`Failed to upload ${e}: ${n.error}`,status:`error`}))}).catch(t=>{this.failedCount++,this.state.addEvent({message:`Upload failed for ${e}: ${t}`,status:`error`})}).finally(()=>{r.output.activeUploads.delete(i),r.output.activeUploads.size===0&&(this.logUploadSummary(),r.status=`done`,this.notify())});r.output.activeUploads.add(i)}async waitForUploads(){let e=this.state.steps.uploadFiles;for(;e.output.activeUploads.size>0;)await Promise.all(e.output.activeUploads);e.status=`done`,this.notify()}logUploadSummary(){if(this.totalQueued===0){this.resetCounters();return}this.failedCount>0&&this.state.addEvent({message:`Uploaded ${this.uploadedCount}/${this.totalQueued} files (${this.failedCount} failed)`,status:`error`}),this.state.addEvent({message:`Successfully uploaded ${this.uploadedCount} file${this.uploadedCount===1?``:`s`}`,status:`success`}),this.resetCounters()}resetCounters(){this.uploadedCount=0,this.failedCount=0,this.totalQueued=0}uploadPendingFiles(){for(let[e,{fileFolder:t,sourcePath:n}]of this.state.steps.uploadFiles.output.builtFileInfos.entries())this.uploadFile(e,n,t)}},Ge=class{constructor(e){this.syncTimer=null,this.serverCheckInterval=null,this.skipTypecheck=!0,this.debounceMs=e.debounceMs??1e3,this.state=e.state,this.verbose=e.verbose??!1,this.apiService=new t.L({disableInterceptors:!0});let n=this.apiService,r=new t.V;this.clientService=new t.m;let i={state:this.state,notify:()=>this.state.notify()};this.checkServerStep=new Fe({...i,apiService:n}),this.buildManifestStep=new Pe(i),this.registerAppStep=new Le({...i,apiService:n,configService:r}),this.uploadFilesStep=new We({...i,verbose:this.verbose}),this.generateApiClientStep=new Ie({...i,clientService:this.clientService,configService:r}),this.syncApplicationStep=new Ue({...i,apiService:n,verbose:this.verbose}),this.startWatchersStep=new He({...i,scheduleSync:this.scheduleSync.bind(this),onFileBuilt:this.handleFileBuilt.bind(this),shouldSkipTypecheck:()=>this.skipTypecheck,verbose:this.verbose})}async start(){let e=r.default.join(this.state.appPath,t.dt);await t.at(e),await t.it(e),this.state.addEvent({message:`Using remote "${t.V.getActiveRemote()}"`,status:`info`}),this.verbose||this.state.addEvent({message:`Add --verbose to see fully detailed logs`,status:`info`}),this.state.notify(),await this.startWatchersStep.start(),this.serverCheckInterval=setInterval(()=>{this.checkServerHealth()},2e3)}async close(){this.serverCheckInterval&&clearInterval(this.serverCheckInterval),await this.startWatchersStep.close()}getState(){return this.state}handleFileBuilt(e){this.state.steps.uploadFiles.output.fileUploader&&this.uploadFilesStep.uploadFile(e.builtPath,e.sourcePath,e.fileFolder)}async checkServerHealth(){let e=this.state.steps.checkServer.output.isReady;await this.checkServerStep.execute()&&!e&&this.scheduleSync()}scheduleSync(){this.syncTimer&&clearTimeout(this.syncTimer),this.syncTimer=setTimeout(()=>{this.syncTimer=null,this.performSync()},this.debounceMs)}async performSync(){if(!this.state.pipeline.isSyncing){this.state.updatePipeline({isSyncing:!0});try{await this.runSyncPipeline()}catch(e){this.state.addEvent({message:`Sync failed with error: ${t.R(e)}`,status:`error`}),this.state.updatePipeline({status:`error`}),this.state.updateAllEntitiesStatus(`error`)}finally{this.state.updatePipeline({isSyncing:!1})}}}async runSyncPipeline(){if(!await this.checkServerStep.execute())return;this.state.steps.ensureValidTokens.status=`done`;let e=await this.buildManifestStep.execute({appPath:this.state.appPath});if(!e||(await this.startWatchersStep.handleWatcherRestarts(e),!this.uploadFilesStep.isInitialized&&!await this.initializePipeline(e.manifest)))return;let t=this.state.hasObjectsOrFieldsChanged(e.manifest);await this.uploadFilesStep.waitForUploads(),await this.syncApplicationStep.execute({manifest:e.manifest,builtFileInfos:this.state.steps.uploadFiles.output.builtFileInfos,appPath:this.state.appPath}),this.state.steps.syncApplication.status!==`error`&&t&&(await this.generateApiClientStep.execute({appPath:this.state.appPath,credentials:this.registerAppStep.registrationCredentials}),this.skipTypecheck=!1)}async initializePipeline(e){await this.registerAppStep.execute({manifest:e});let t=await this.apiService.createDevelopmentApplication({universalIdentifier:e.application.universalIdentifier,name:e.application.displayName});return!t.success||!t.data?(this.state.applyStepEvents([{message:`Failed to install development application`,status:`error`},{message:JSON.stringify(t,null,2),status:`error`}]),this.state.updatePipeline({status:`error`}),!1):(this.state.steps.resolveApplication.output={applicationId:t.data.id,universalIdentifier:t.data.universalIdentifier},this.state.steps.resolveApplication.status=`done`,this.state.applyStepEvents([{message:`Application installed`,status:`success`}]),this.uploadFilesStep.initialize({appPath:this.state.appPath,universalIdentifier:e.application.universalIdentifier}),!0)}},Ke={objects:t.ut.Object,fields:t.ut.Field,logicFunctions:t.ut.LogicFunction,frontComponents:t.ut.FrontComponent,roles:t.ut.Role,skills:t.ut.Skill,connectionProviders:t.ut.ConnectionProvider,views:t.ut.View,viewFields:t.ut.ViewField,navigationMenuItems:t.ut.NavigationMenuItem,pageLayouts:t.ut.PageLayout,pageLayoutTabs:t.ut.PageLayoutTab,commandMenuItems:t.ut.CommandMenuItem},qe=200,Je={pending:[`building`,`uploading`,`success`,`error`],building:[`pending`,`uploading`,`success`,`error`],uploading:[`pending`,`success`,`error`],success:[`pending`,`building`,`uploading`,`error`],error:[`pending`,`building`,`uploading`,`success`]},Ye=class{constructor(e){this.eventIdCounter=0,this.appPath=e.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(e){this.versionInfo=e,this.notify()}notify(){this.onChange?.()}updatePipeline(e){Object.assign(this.pipeline,e),this.notify()}applyStepEvents(e){let t=e.map(e=>(this.eventIdCounter+=1,{...e,id:this.eventIdCounter,timestamp:new Date,message:e.message.slice(0,5e3)}));this.events=[...this.events.slice(-(qe-t.length)),...t]}addEvent(e){this.applyStepEvents([e])}updateEntityStatus(e,t){let n=new Map(this.entities),r=n.get(e);r?.status&&!Je[r.status].includes(t)||(n.set(e,r?{...r,status:t}:{name:e,path:e,status:t}),this.entities=n)}removeEntity(e){let t=new Map(this.entities);t.delete(e),this.entities=t}updateAllEntitiesStatus(e){let t=new Map(this.entities);for(let[n,r]of t)t.set(n,{...r,status:e});this.entities=t}updateEntitiesFromManifest(e){let t=new Map;for(let[n,r]of Object.entries(e)){let e=Ke[n];if(e)for(let n of r)t.set(n,e)}let n=new Map(this.entities);for(let[e,r]of n)n.set(e,{...r,type:t.get(e)});for(let[e,r]of t)n.has(e)||n.set(e,{name:e,path:e,type:r,status:`pending`});this.entities=n}hasObjectsOrFieldsChanged(e){let t=JSON.stringify({objects:e.objects,fields:e.fields}),n=t!==this.previousObjectsFieldsFingerprint;return this.previousObjectsFieldsFingerprint=t,n}},Xe={idle:{color:`gray`,icon:`○`},in_progress:{color:`yellow`,icon:`spinner`},uploading:{color:`cyan`,icon:`upload`},done:{color:`green`,icon:`✓`},error:{color:`red`,icon:`✗`}},Ze=e=>({idle:`idle`,in_progress:`in_progress`,done:`done`,error:`error`})[e],Qe=e=>({pending:`idle`,building:`in_progress`,uploading:`uploading`,success:`done`,error:`error`})[e],$e=e=>({idle:`idle`,building:`in_progress`,syncing:`in_progress`,synced:`done`,error:`error`})[e],et={idle:`Idle`,building:`Building...`,syncing:`Syncing...`,synced:`Synced`,error:`Error`},tt=[`◐`,`◓`,`◑`,`◒`],nt=[`↑`,`⇡`,`↑`,`⇡`],rt={[t.ut.Object]:`Objects`,[t.ut.Field]:`Fields`,[t.ut.LogicFunction]:`Logic functions`,[t.ut.FrontComponent]:`Front components`,[t.ut.CommandMenuItem]:`Command menu items`,[t.ut.Role]:`Roles`,[t.ut.Skill]:`Skills`,[t.ut.View]:`Views`,[t.ut.ViewField]:`View fields`,[t.ut.NavigationMenuItem]:`Navigation menu items`,[t.ut.PageLayout]:`Page layouts`,[t.ut.PageLayoutTab]:`Page layout tabs`,[t.ut.Agent]:`Agents`,[t.ut.ConnectionProvider]:`Connection providers`},it=Object.keys(rt),at={info:`gray`,success:`green`,error:`red`,warning:`yellow`},ot=e=>e.toLocaleTimeString(`en-US`,{hour12:!1,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),st=(e,t=40)=>{if(e.length<=t)return e;let n=e.split(`/`);return n.length<=2?e:`.../${n.slice(-2).join(`/`)}`},ct=e=>{let t=new Map;for(let e of it)t.set(e,[]);for(let n of e.values()){if(!n.type)continue;let e=t.get(n.type)??[];e.push(n),t.set(n.type,e)}return t},lt=[{status:`success`,label:`synced`},{status:`building`,label:`building`},{status:`uploading`,label:`uploading`},{status:`pending`,label:`pending`},{status:`error`,label:`error`}],ut=e=>{let t={pending:0,building:0,uploading:0,success:0,error:0};for(let n of e)t[n.status]+=1;return lt.filter(({status:e})=>t[e]>0).map(({status:e,label:n})=>({status:e,count:t[e],label:n}))},E=e=>{let t=e.steps.resolveApplication.output.applicationId;return!n.t(e.frontendUrl)||!n.t(t)?null:`${e.frontendUrl}/settings/applications/${t}`},dt=e=>e.some(e=>e===`error`)?`error`:e.some(e=>e===`in_progress`)?`in_progress`:e.every(e=>e===`done`)?`done`:`idle`,ft=e=>{let t=[...e.entities.values()],n=t.some(e=>e.status===`error`),r=t.some(e=>e.status===`building`),i=t.length>0&&t.every(e=>e.status===`uploading`||e.status===`success`),a=n?`error`:r?`in_progress`:i?`done`:`idle`;return[{label:`Application Initialization`,status:dt([e.steps.checkServer.status,e.steps.ensureValidTokens.status,e.steps.resolveApplication.status])},{label:`Resources Build`,status:a},{label:`Resources Upload`,status:e.steps.uploadFiles.status},{label:`Manifest Build`,status:e.steps.buildManifest.status},{label:`Application Synchronization`,status:e.steps.syncApplication.status},{label:`Api Client Generation`,status:e.steps.generateApiClient.status}]},pt=120,mt=Math.round(200/pt),ht=()=>{let e=Math.floor(Date.now()/pt);return{spinnerFrame:tt[e%tt.length],uploadFrame:nt[Math.floor(e/mt)%nt.length]}},gt=e=>{let t=Xe[e];return t.icon===`spinner`?ht().spinnerFrame:t.icon===`upload`?ht().uploadFrame:t.icon},_t=o.default.createContext(null),vt=_t.Provider,yt=()=>{let e=o.default.useContext(_t);if(!e)throw Error(`useInk must be used within InkProvider`);return e},bt=({uiStatus:e})=>{let{Text:t}=yt(),n=gt(e),r=Xe[e];return(0,p.jsxs)(t,{color:r.color,children:[n,` `]})},xt=({entity:e})=>{let{Box:t,Text:n}=yt();return(0,p.jsxs)(t,{children:[(0,p.jsx)(bt,{uiStatus:Qe(e.status)}),(0,p.jsx)(n,{children:e.name}),e.path!==e.name&&(0,p.jsxs)(n,{dimColor:!0,children:[` (`,st(e.path),`)`]})]})},St=({type:e,entities:t})=>{let{Box:n,Text:r}=yt();return t.length===0?null:(0,p.jsxs)(n,{flexDirection:`column`,marginTop:1,children:[(0,p.jsx)(r,{bold:!0,dimColor:!0,children:rt[e]}),t.map(e=>(0,p.jsx)(xt,{entity:e},e.path))]})},Ct=({entities:e})=>{let{Box:t,Text:n}=yt();if(e.length===0)return null;let r=ut(e);return(0,p.jsxs)(t,{marginTop:1,children:[(0,p.jsxs)(n,{bold:!0,dimColor:!0,children:[`Entities`,` `]}),r.map((e,r)=>(0,p.jsxs)(t,{children:[r>0&&(0,p.jsx)(n,{dimColor:!0,children:` · `}),(0,p.jsx)(bt,{uiStatus:Qe(e.status)}),(0,p.jsxs)(n,{children:[e.count,` `,e.label]})]},e.status))]})},wt=()=>{let{Box:e,Text:t}=yt();return(0,p.jsx)(e,{marginTop:1,children:(0,p.jsxs)(t,{dimColor:!0,children:[(0,p.jsx)(t,{color:Xe.idle.color,children:Xe.idle.icon}),` `,`pending`,` `,(0,p.jsx)(t,{color:Xe.in_progress.color,children:tt[0]}),` `,`building`,` `,(0,p.jsx)(t,{color:Xe.uploading.color,children:nt[0]}),` `,`uploading`,` `,(0,p.jsx)(t,{color:Xe.done.color,children:Xe.done.icon}),` `,`success`,` `,(0,p.jsx)(t,{color:Xe.error.color,children:Xe.error.icon}),` `,`error`]})})},Tt=7,Et=({versionInfo:e})=>{let{Box:t,Text:n}=yt();if(e===null)return null;let{cliVersion:r,localServerVersion:i,latestServerVersion:a,isMinorOrMajorBehind:o,daysBehind:s}=e,c=o&&s!==null&&s>Tt;return(0,p.jsxs)(t,{children:[(0,p.jsx)(n,{dimColor:!0,children:`Versions: `}),(0,p.jsx)(n,{dimColor:!0,children:`CLI `}),(0,p.jsxs)(n,{children:[`v`,r]}),i!==null&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(n,{dimColor:!0,children:` • Server `}),(0,p.jsxs)(n,{color:c?`yellow`:void 0,children:[`v`,i]}),i!==null&&a!==null&&i===a&&(0,p.jsx)(n,{color:`green`,children:` ✓ latest`}),c&&a!==null&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(n,{color:`yellow`,children:[` → v`,a]}),s!==null&&(0,p.jsxs)(n,{dimColor:!0,children:[` (`,s,`d behind)`]})]})]})]})},Dt=({state:e})=>{let{Text:t}=yt(),n=$e(e.pipeline.status),r=gt(n),i=Xe[n],a=et[e.pipeline.status];return(0,p.jsxs)(t,{color:i.color,children:[r,` `,a]})},Ot=({label:e,status:t})=>{let{Box:n,Text:r}=yt(),i=Ze(t),a=gt(i),o=Xe[i];return(0,p.jsxs)(n,{children:[(0,p.jsxs)(r,{dimColor:!0,children:[e,`: `]}),(0,p.jsxs)(r,{color:o.color,children:[a,` `,t.replace(`_`,` `)]})]})},kt=({state:e,verbose:t=!1})=>{let{Box:n,Text:r}=yt(),i=ct(e.entities),a=E(e);return(0,p.jsxs)(n,{flexDirection:`column`,borderStyle:`classic`,borderColor:`gray`,paddingX:1,children:[(0,p.jsx)(r,{bold:!0,color:`cyan`,children:`Application`}),(0,p.jsxs)(n,{marginLeft:2,flexDirection:`column`,children:[(0,p.jsxs)(n,{children:[(0,p.jsx)(r,{dimColor:!0,children:`Name: `}),(0,p.jsx)(r,{bold:!0,children:e.pipeline.appName??`Loading...`})]}),(0,p.jsxs)(n,{children:[(0,p.jsx)(r,{dimColor:!0,children:`Overall Status: `}),(0,p.jsx)(Dt,{state:e})]}),a&&(0,p.jsxs)(n,{children:[(0,p.jsx)(r,{dimColor:!0,children:`Open:`}),(0,p.jsxs)(r,{bold:!0,color:`cyan`,children:[` `,a]})]}),(0,p.jsx)(Et,{versionInfo:e.versionInfo})]}),(0,p.jsx)(n,{marginLeft:2,flexDirection:`column`,marginTop:1,children:ft(e).map(e=>(0,p.jsx)(Ot,{label:e.label,status:e.status},e.label))}),(0,p.jsx)(n,{marginLeft:2,flexDirection:`column`,children:t?it.map(e=>(0,p.jsx)(St,{type:e,entities:i.get(e)??[]},e)):(0,p.jsx)(Ct,{entities:Array.from(e.entities.values())})})]})},D=({event:e})=>{let{Box:t,Text:n}=yt(),r=at[e.status],i=ot(e.timestamp);return(0,p.jsxs)(t,{marginTop:+!!e.spacingBefore,children:[(0,p.jsxs)(n,{dimColor:!0,children:[i,` `]}),(0,p.jsx)(n,{color:r,children:e.message})]})},At=new Set([`building`,`syncing`]),jt=120,Mt=80,Nt=({uiStateManager:e,verbose:t})=>{let{Box:n,Static:r}=yt(),[,i]=(0,o.useReducer)(e=>e+1,0),a=(0,o.useRef)(null),s=(0,o.useRef)(0),c=(0,o.useCallback)(()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,s.current=Date.now(),i()},Mt)},[]);(0,o.useEffect)(()=>e.subscribe(()=>{c()}),[e,c]),(0,o.useEffect)(()=>{let t=setInterval(()=>{let t=e.getSnapshot();At.has(t.pipeline.status)&&(Date.now()-s.current<jt||i())},jt);return()=>clearInterval(t)},[e]),(0,o.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]);let l=e.getSnapshot();return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r,{items:l.events,children:e=>(0,p.jsx)(D,{event:e},e.id)}),(0,p.jsxs)(n,{marginTop:1,flexDirection:`column`,children:[(0,p.jsx)(kt,{state:l,verbose:t}),t&&(0,p.jsx)(wt,{})]})]})},Pt=async(e,t=!1)=>{let{render:n,Box:r,Text:i,Static:a}=await import(`ink`),{unmount:o}=n((0,p.jsx)(vt,{value:{Box:r,Text:i,Static:a},children:(0,p.jsx)(Nt,{uiStateManager:e,verbose:t})}));return{unmount:o}},Ft=class{constructor(e){this.listeners=new Set,this.pendingNotify=!1,this.orchestratorState=e}getSnapshot(){return this.orchestratorState}subscribe(e){return this.listeners.add(e),e(this.orchestratorState),()=>this.listeners.delete(e)}notify(){this.pendingNotify||(this.pendingNotify=!0,queueMicrotask(()=>{this.pendingNotify=!1;for(let e of this.listeners)e(this.orchestratorState)}))}},It=class{constructor(){this.orchestrator=null,this.unmountUI=null}async close(){this.unmountUI?.(),await this.orchestrator?.close()}getOrchestrator(){return this.orchestrator}async ensureAuthenticatedBeforeLaunch(){let{serverUp:e,authValid:n}=await new t.L({disableInterceptors:!0}).validateAuth();e&&!n&&await t.z(t.V.getActiveRemote())}async execute(e){let n=e.appPath??t.xt;await y(n),e.headless&&await t._(),await this.ensureAuthenticatedBeforeLaunch();let r=new Ye({appPath:n});if(!e.headless){let n=new Ft(r);r.onChange=()=>n.notify();let{unmount:i}=await Pt(n,e.verbose);this.unmountUI=i,t.v().then(e=>r.setVersionInfo(e))}this.orchestrator=new Ge({state:r,verbose:e.verbose,debounceMs:e.debounceMs}),await this.orchestrator.start(),e.headless||this.setupGracefulShutdown()}setupGracefulShutdown(){let e=()=>void this.close().then(()=>process.exit(0));process.on(`SIGINT`,e),process.on(`SIGTERM`,e)}},Lt=class{async execute(e){let n=e.appPath??t.xt;await y(n);let r=t.V.getActiveRemote();console.log(u.default.blue(`${e.dryRun?`Previewing application diff`:`Syncing application`} on ${r}...`)),console.log(u.default.gray(`App path: ${n}\n`));let i=await t.o({appPath:n,verbose:e.verbose,dryRun:e.dryRun,onProgress:e=>console.log(u.default.gray(e))});if(i.success||(console.error(u.default.red(i.error.message)),process.exit(1)),e.dryRun){console.log(u.default.green(`\n✓ Dry run complete for ${i.data.applicationDisplayName} — no changes were applied`));return}console.log(u.default.green(`\n✓ Synced ${i.data.applicationDisplayName} (${i.data.fileCount} file${i.data.fileCount===1?``:`s`})`)),console.log(u.default.gray(`Output: ${i.data.outputDir}`))}},O=class{async execute(e){let n=e.appPath??t.xt,i=(0,r.join)(n,`node_modules`,`twenty-client-sdk`);await t.ot(i)||(console.error(u.default.red(`Cannot find twenty-client-sdk in ${n}.\n\n Install it first:
348
348
  yarn add twenty-client-sdk`)),process.exit(1));let a=await new t.L({disableInterceptors:!0}).validateAuth();a.serverUp||(console.error(u.default.red(`Cannot reach Twenty server.
349
349
 
350
350
  Check your remotes:
351
- yarn twenty remote:status`)),process.exit(1)),a.authValid||(console.error(u.default.red("Authentication failed. Run `yarn twenty remote:add` to authenticate.")),process.exit(1)),console.log(u.default.blue(`Generating API client...`));try{await new t.m({skipAuth:!1}).generateCoreClient({appPath:n})}catch(e){console.error(u.default.red(`Failed to generate API client: ${t.R(e)}`)),process.exit(1)}console.log(u.default.green(`✓ API client generated`)),console.log(u.default.gray(`Output: ${(0,r.join)(i,`dist`,`core`,`generated`)}`))}},Lt=e=>{let t=new Ae,n=new ke;e.command(`dev:function:logs [appPath]`).description(`Stream logic function logs`).option(`-u, --functionUniversalIdentifier <functionUniversalIdentifier>`,`Only show logs for the function with this universal ID`).option(`-n, --functionName <functionName>`,`Only show logs for the function with this name`).action(async(e,n)=>{await t.execute({...n,appPath:g(e)})}),e.command(`dev:function:exec [appPath]`).description(`Execute a logic function`).option(`--postInstall`,`Execute post-install logic function if defined`).option(`--preInstall`,`Execute pre-install logic function if defined`).option(`-p, --payload <payload>`,`JSON payload to send to the function`,`{}`).option(`-u, --functionUniversalIdentifier <functionUniversalIdentifier>`,`Universal ID of the function to execute`).option(`-n, --functionName <functionName>`,`Name of the function to execute`).action(async(e,t)=>{!t?.postInstall&&!t?.preInstall&&!t?.functionUniversalIdentifier&&!t?.functionName&&(console.error(u.default.red(`Error: Either --postInstall, --preInstall, --functionName (-n), or --functionUniversalIdentifier (-u) is required.`)),process.exit(1)),await n.execute({...t,payload:t?.payload??`{}`,appPath:g(e)})})},Rt=e=>{let n=new Oe,r=new Ft,i=new It,a=new Me,o=new De,s=new k;e.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(async(e,t)=>{t.dryRun&&!t.once&&console.warn(u.default.yellow("--dry-run only applies with --once. Ignoring it; run `yarn twenty dev --once --dry-run` to preview changes."));let n={appPath:g(e),verbose:t.verbose||t.debug,debounceMs:t.debounceMs?parseInt(t.debounceMs,10):void 0};if(t.once){await i.execute({...n,dryRun:t.dryRun});return}await r.execute(n)}),e.command(`dev:build [appPath]`).description(`Build and generate API client`).option(`--tarball`,`Also pack into a .tgz tarball`).action(async(e,t)=>{await n.execute({appPath:g(e),tarball:t.tarball})}),e.command(`dev:typecheck [appPath]`).description(`Run TypeScript type checking`).action(async e=>{await a.execute({appPath:g(e)})}),e.command(`dev:add [entityType]`).description(`Scaffold a new entity (${Object.values(t.ct).join(`|`)})`).option(`--path <path>`,`Path in which the entity should be created.`).action(async(e,t)=>{await o.execute(e,t?.path)}),e.command(`dev:catalog-sync`).description(`Trigger marketplace catalog sync`).option(`-r, --remote <name>`,`Sync on a specific remote`).action(async e=>{let{CatalogSyncCommand:t}=await Promise.resolve().then(()=>require("./catalog-sync-w6yKppKP.js"));await new t().execute({remote:e.remote})}),e.command(`dev:generate-client [appPath]`).description(`Generate the typed API client from the active remote (no app definition required)`).action(async e=>{await s.execute({appPath:g(e)})}),Lt(e)},zt=async(e,n)=>{let r=n.test?t.x:t.b,i=n.port?parseInt(n.port,10):r;(isNaN(i)||i<1||i>65535)&&(console.error(u.default.red(`Invalid port number.`)),process.exit(1));let a=await t.n({port:i,test:n.test,version:e,onProgress:e=>console.log(u.default.gray(e))});a.success||(console.error(u.default.red(a.error.message)),process.exit(1))},Bt=e=>{let n=e.test?t.S:t.y;if(!t.w(n)){console.log(u.default.yellow(`No Twenty server container found.`));return}(0,l.execSync)(`docker stop ${n}`,{stdio:`ignore`}),console.log(u.default.green(`Twenty server stopped.`))},Vt=e=>{let n=e.test?t.S:t.y;if(!t.w(n)){console.log(u.default.yellow(`No Twenty server container found.`));return}try{(0,l.spawnSync)(`docker`,[`logs`,`-f`,`--tail`,e.lines,n],{stdio:`inherit`})}catch{}},Ht=async e=>{let n=e.test?t.S:t.y,r=e.test?t.x:t.b;if(!t.w(n)){console.log(` Status: ${u.default.gray(`not created`)}`),console.log(u.default.gray(` Run 'yarn twenty docker:start${e.test?` --test`:``}' to create one.`));return}let i=t.A(n),a=i?t.D(n):r,o=i?await t.f(a):!1,s=o?u.default.green(`running (healthy)`):i?u.default.yellow(`running (starting...)`):u.default.gray(`stopped`),c=t.E(`APP_VERSION`,n);console.log(` Status: ${s}`),console.log(` URL: http://localhost:${a}`),c&&console.log(` Version: ${u.default.gray(c)}`),o&&console.log(u.default.gray(` Login: tim@apple.dev / tim@apple.dev`))},Ut=e=>{let n=e.test?t.S:t.y,r=e.test?`twenty-app-dev-test-data`:`twenty-app-dev-data`,i=e.test?`twenty-app-dev-test-storage`:`twenty-app-dev-storage`;t.w(n)&&(0,l.execSync)(`docker rm -f ${n}`,{stdio:`ignore`});try{(0,l.execSync)(`docker volume rm ${r} ${i}`,{stdio:`ignore`})}catch{}console.log(u.default.green(`Twenty server data reset.`)),console.log(u.default.gray(`Run 'yarn twenty docker:start${e.test?` --test`:``}' to start a fresh instance.`))},Wt=async(e,n)=>{let r=await t.a({version:e??`latest`,test:n.test,onProgress:e=>console.log(u.default.gray(e))});r.success||(console.error(u.default.red(r.error.message)),process.exit(1));let{data:i}=r;if(!i.imageUpdated){console.log(u.default.green(` Already up to date (${i.image}).`));return}console.log(u.default.green(` Upgraded to: ${i.image}`)),i.containerRecreated&&console.log(u.default.gray(` Run 'yarn twenty docker:start${n.test?` --test`:``}' to wait for the server to be ready.`))},Gt=e=>{e.command(`docker:start [version]`).description("Start the local Twenty container (version defaults to the app `engines.twenty` range, then `latest`)").option(`-p, --port <port>`,`HTTP port`).option(`--test`,`Start a separate test instance (port 2021)`).action(zt),e.command(`docker:stop`).description(`Stop the local Twenty container`).option(`--test`,`Stop the test instance`).action(Bt),e.command(`docker:logs`).description(`Stream container logs`).option(`-n, --lines <lines>`,`Number of lines to show`,`50`).option(`--test`,`Show logs for the test instance`).action(Vt),e.command(`docker:status`).description(`Show container status`).option(`--test`,`Show status of the test instance`).action(Ht),e.command(`docker:reset`).description(`Delete all data and start fresh`).option(`--test`,`Reset the test instance`).action(Ut),e.command(`docker:upgrade [version]`).description(`Upgrade the Docker image`).option(`--test`,`Upgrade the test instance`).action(Wt);let t=e.command(`server`,{hidden:!0}).description(`Manage a Twenty server (local instance and server-side actions)`),n=(e,t)=>console.warn(u.default.yellow(`⚠ \`twenty server ${e}\` is deprecated. Use \`twenty ${t}\` instead.`));t.command(`start [version]`).option(`-p, --port <port>`,`HTTP port`).option(`--test`,`Start a separate test instance (port 2021)`).action(async(e,t)=>{n(`start`,`docker:start`),await zt(e,t)}),t.command(`stop`).option(`--test`,`Stop the test instance`).action(e=>{n(`stop`,`docker:stop`),Bt(e)}),t.command(`logs`).option(`-n, --lines <lines>`,`Number of lines to show`,`50`).option(`--test`,`Show logs for the test instance`).action(e=>{n(`logs`,`docker:logs`),Vt(e)}),t.command(`status`).option(`--test`,`Show status of the test instance`).action(async e=>{n(`status`,`docker:status`),await Ht(e)}),t.command(`reset`).option(`--test`,`Reset the test instance`).action(e=>{n(`reset`,`docker:reset`),Ut(e)}),t.command(`upgrade [version]`).option(`--test`,`Upgrade the test instance`).action(async(e,t)=>{n(`upgrade`,`docker:upgrade`),await Wt(e,t)}),t.command(`catalog-sync`).option(`-r, --remote <name>`,`Sync on a specific remote`).action(async e=>{n(`catalog-sync`,`dev:catalog-sync`);let{CatalogSyncCommand:t}=await Promise.resolve().then(()=>require("./catalog-sync-w6yKppKP.js"));await new t().execute({remote:e.remote})})},Kt=e=>{try{return new URL(e).hostname.replace(/\./g,`-`)}catch{return`remote`}},qt=async(e,n)=>n?((await t.t({apiKey:n,apiUrl:e})).success||(console.error(u.default.red(`✗ Authentication failed.`)),process.exit(1)),`API key`):Jt(e),Jt=async e=>{console.log(u.default.gray(`Opening browser for authentication...`));let n=await t.B({apiUrl:e});return n.success?`OAuth`:(console.log(u.default.yellow(n.error.message)),(await t.t({apiKey:(await d.default.prompt([{type:`password`,name:`apiKey`,message:`API Key:`,mask:`*`,validate:e=>e.length>0||`API key is required`}])).apiKey,apiUrl:e})).success||(console.error(u.default.red(`✗ Authentication failed.`)),process.exit(1)),`API key`)},Yt=async e=>{e.apiUrl&&console.warn(u.default.yellow(`⚠ --api-url is deprecated. Use --url instead.`));let n=e.test?t.H(!0):void 0,r=new t.V(n?{configPath:n}:void 0),i=await r.getRemotes();if(e.as!==void 0&&i.includes(e.as)){let n=await r.getConfigForRemote(e.as);t.V.setActiveRemote(e.as);let i=await qt(n.apiUrl,e.apiKey);console.log(u.default.green(`✓ Re-authenticated "${e.as}" via ${i}.`)),await r.setDefaultRemote(e.as),console.log(u.default.green(`✓ Default remote set to "${e.as}".`));return}let a=e.url??e.apiUrl;if(a)a=t.ft(a);else{let n=await t.p();e.local?(n||(console.error(u.default.red(`No local Twenty server found.
352
- Start one with: yarn twenty docker:start`)),process.exit(1)),console.log(u.default.gray(`Found local server at ${n}`)),a=n):a=t.ft((await d.default.prompt([{type:`input`,name:`serverUrl`,message:`Twenty server URL:`,validate:e=>{try{return new URL(e),!0}catch{return`Please enter a valid URL`}}}])).serverUrl)}let o=e.as??Kt(a);t.V.setActiveRemote(o);let s=await qt(a,e.apiKey);console.log(u.default.green(`✓ Remote "${o}" added (${a}) via ${s}.`)),await r.setDefaultRemote(o),console.log(u.default.green(`✓ Default remote set to "${o}".`))},Xt=async()=>{let e=new t.V,n=await e.getRemotes(),r=await e.getDefaultRemote();if(n.length===0){console.log(`No remotes configured.`),console.log(`Use 'twenty remote:add' to add one.`);return}console.log(``);for(let t of n){let n=await e.getConfigForRemote(t),i=n.twentyCLIAccessToken?`oauth`:n.apiKey?`api-key`:`none`,a=t===r,o=a?`* `:` `,s=a?u.default.bold(t):t;console.log(`${o}${s} ${u.default.gray(n.apiUrl)} [${i}]`)}console.log(`
353
- `,u.default.gray(`Use 'twenty remote:use <name>' to change default`))},Zt=async e=>{let n=new t.V,r=e??(await d.default.prompt([{type:`select`,name:`remote`,message:`Select default remote:`,choices:await n.getRemotes()}])).remote;(await n.getRemotes()).includes(r)||(console.error(u.default.red(`Remote "${r}" not found.`)),process.exit(1)),await n.setDefaultRemote(r),console.log(u.default.green(`✓ Default remote set to "${r}".`))},Qt=async()=>{let e=new t.V,n=new t.L,r=t.V.getActiveRemote(),i=await e.getConfig(),a=i.twentyCLIAccessToken?`oauth`:i.apiKey?`api-key`:`none`;if(console.log(` Remote: ${u.default.bold(r)}`),console.log(` Server: ${i.apiUrl}`),a===`none`){console.log(` Auth: ${u.default.yellow(`not configured`)}`);return}let{authValid:o}=await n.validateAuth(),s=o?u.default.green(`${a} (valid)`):u.default.red(`${a} (invalid)`);console.log(` Auth: ${s}`)},$t=async e=>{let n=new t.V;(await n.getRemotes()).includes(e)||(console.error(u.default.red(`Remote "${e}" not found.`)),process.exit(1)),t.V.setActiveRemote(e),await n.clearConfig(),console.log(u.default.green(`✓ Remote "${e}" removed.`))},en=e=>{e.command(`remote:add`).description(`Add or re-authenticate a remote`).option(`--as <name>`,`Name for this remote`).option(`--api-key <apiKey>`,`API key for non-interactive auth`).option(`--url <url>`,`Server URL`).option(`--api-url <apiUrl>`,`[deprecated: use --url]`).option(`--local`,`Connect to a local Twenty server (auto-detect)`).option(`--test`,`Write to config.test.json (for integration tests)`).action(Yt),e.command(`remote:list`).description(`List all configured remotes`).action(Xt),e.command(`remote:use [name]`).description(`Set the default remote`).action(Zt),e.command(`remote:status`).description(`Show active remote auth status`).action(Qt),e.command(`remote:remove <name>`).description(`Remove a remote`).action($t);let t=e.command(`remote`,{hidden:!0}).description(`Manage remote Twenty servers`),n=(e,t)=>console.warn(u.default.yellow(`⚠ \`twenty remote ${e}\` is deprecated. Use \`twenty ${t}\` instead.`));t.command(`add`).option(`--as <name>`,`Name for this remote`).option(`--api-key <apiKey>`,`API key for non-interactive auth`).option(`--url <url>`,`Server URL`).option(`--api-url <apiUrl>`,`[deprecated: use --url]`).option(`--local`,`Connect to a local Twenty server (auto-detect)`).option(`--test`,`Write to config.test.json (for integration tests)`).action(async e=>{n(`add`,`remote:add`),await Yt(e)}),t.command(`list`).action(async()=>{n(`list`,`remote:list`),await Xt()}),t.command(`switch [name]`).action(async e=>{n(`switch`,`remote:use`),await Zt(e)}),t.command(`status`).action(async()=>{n(`status`,`remote:status`),await Qt()}),t.command(`remove <name>`).action(async e=>{n(`remove`,`remote:remove`),await $t(e)})},tn=e=>{Rt(e),ee(e),Gt(e),en(e),Ne(e)};h.inspect.defaultOptions.depth=10;var nn=new m.Command;nn.name(`twenty`).description(`CLI for Twenty application development`).version(t.P.version),nn.option(`-r, --remote <name>`,`Use a specific remote (overrides the default set by remote:use)`),nn.hook(`preAction`,async e=>{let n=(e.optsWithGlobals?e.optsWithGlobals():e.opts()).remote;n?console.log(u.default.gray(`Using remote: ${n}`)):n=await new t.V().getDefaultRemote(),t.V.setActiveRemote(n)}),tn(nn),nn.exitOverride();try{nn.parse()}catch(e){e instanceof m.CommanderError&&process.exit(e.exitCode),e instanceof Error&&(console.error(u.default.red(`Error:`),e.message),process.exit(1))}
351
+ yarn twenty remote:status`)),process.exit(1)),a.authValid||(console.error(u.default.red("Authentication failed. Run `yarn twenty remote:add` to authenticate.")),process.exit(1)),console.log(u.default.blue(`Generating API client...`));try{await new t.m({skipAuth:!1}).generateCoreClient({appPath:n})}catch(e){console.error(u.default.red(`Failed to generate API client: ${t.R(e)}`)),process.exit(1)}console.log(u.default.green(`✓ API client generated`)),console.log(u.default.gray(`Output: ${(0,r.join)(i,`dist`,`core`,`generated`)}`))}},Rt={objects:[`labelSingular`,`labelPlural`,`description`],fields:[`label`,`description`],views:[`name`],pageLayoutTabs:[`title`],commandMenuItems:[`label`,`shortLabel`],navigationMenuItems:[`label`]},zt=e=>{let t=new Set;for(let[n,r]of Object.entries(Rt)){let i=e[n];if(Array.isArray(i)){for(let e of i)if(!(typeof e!=`object`||!e))for(let n of r){let r=e[n];typeof r==`string`&&r.length>0&&t.add(r)}}}return[...t].sort()},Bt=async({appPath:e,manifest:n,scaffoldLocale:a})=>{let o=zt(n),s=r.default.join(e,t.Y);await t.at(s);let c={};for(let e of o)c[e]=e;if(await t.lt(r.default.join(s,`en.json`),c),a!==void 0&&a!==`en`){let e=r.default.join(s,`${a}.json`);await t.ot(e)||await t.lt(e,{})}let l=(await(0,i.readdir)(s)).filter(e=>e.endsWith(`.json`)&&e!==`en.json`);for(let e of l){let n=r.default.join(s,e),i=await t.st(n)??{},a={};for(let e of o)a[e]=i[e]??``;await t.lt(n,a)}return{sourceCount:o.length,updatedLocaleFiles:l}},Vt=e=>Object.prototype.hasOwnProperty.call(t.ht,e),Ht=class{async execute(e){let n=e.appPath??t.xt,r;e.locale!==void 0&&((e.locale===`en`||!Vt(e.locale))&&(console.error(u.default.red(`"${e.locale}" is not a supported target locale. Choose one of: ${Object.keys(t.ht).filter(e=>e!==`en`).join(`, `)}`)),process.exit(1)),r=e.locale),console.log(u.default.blue(`Extracting translatable strings...`));let i=await t.Q(n);i.success||(console.error(u.default.red(i.errors.join(`
352
+ `))),process.exit(1)),i.warnings.length>0&&console.warn(u.default.yellow(i.warnings.join(`
353
+ `)));let{sourceCount:a,updatedLocaleFiles:o}=await Bt({appPath:n,manifest:i.manifest,scaffoldLocale:r});console.log(u.default.green(`✓ Extracted ${a} string${a===1?``:`s`} to locales/`)),o.length>0&&console.log(u.default.gray(`Updated: ${o.join(`, `)}`))}},Ut=e=>{let t=new Ae,n=new ke;e.command(`dev:function:logs [appPath]`).description(`Stream logic function logs`).option(`-u, --functionUniversalIdentifier <functionUniversalIdentifier>`,`Only show logs for the function with this universal ID`).option(`-n, --functionName <functionName>`,`Only show logs for the function with this name`).action(async(e,n)=>{await t.execute({...n,appPath:g(e)})}),e.command(`dev:function:exec [appPath]`).description(`Execute a logic function`).option(`--postInstall`,`Execute post-install logic function if defined`).option(`--preInstall`,`Execute pre-install logic function if defined`).option(`-p, --payload <payload>`,`JSON payload to send to the function`,`{}`).option(`-u, --functionUniversalIdentifier <functionUniversalIdentifier>`,`Universal ID of the function to execute`).option(`-n, --functionName <functionName>`,`Name of the function to execute`).action(async(e,t)=>{!t?.postInstall&&!t?.preInstall&&!t?.functionUniversalIdentifier&&!t?.functionName&&(console.error(u.default.red(`Error: Either --postInstall, --preInstall, --functionName (-n), or --functionUniversalIdentifier (-u) is required.`)),process.exit(1)),await n.execute({...t,payload:t?.payload??`{}`,appPath:g(e)})})},Wt=e=>{let n=new Oe,r=new It,i=new Lt,a=new Me,o=new De,s=new O,c=new Ht;e.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(async(e,t)=>{t.dryRun&&!t.once&&console.warn(u.default.yellow("--dry-run only applies with --once. Ignoring it; run `yarn twenty dev --once --dry-run` to preview changes."));let n={appPath:g(e),verbose:t.verbose||t.debug,debounceMs:t.debounceMs?parseInt(t.debounceMs,10):void 0};if(t.once){await i.execute({...n,dryRun:t.dryRun});return}await r.execute(n)}),e.command(`dev:build [appPath]`).description(`Build and generate API client`).option(`--tarball`,`Also pack into a .tgz tarball`).action(async(e,t)=>{await n.execute({appPath:g(e),tarball:t.tarball})}),e.command(`dev:typecheck [appPath]`).description(`Run TypeScript type checking`).action(async e=>{await a.execute({appPath:g(e)})}),e.command(`dev:add [entityType]`).description(`Scaffold a new entity (${Object.values(t.ut).join(`|`)})`).option(`--path <path>`,`Path in which the entity should be created.`).action(async(e,t)=>{await o.execute(e,t?.path)}),e.command(`dev:catalog-sync`).description(`Trigger marketplace catalog sync`).option(`-r, --remote <name>`,`Sync on a specific remote`).action(async e=>{let{CatalogSyncCommand:t}=await Promise.resolve().then(()=>require("./catalog-sync-CgKswjsE.js"));await new t().execute({remote:e.remote})}),e.command(`dev:generate-client [appPath]`).description(`Generate the typed API client from the active remote (no app definition required)`).action(async e=>{await s.execute({appPath:g(e)})}),e.command(`dev:i18n-extract [appPath]`).description(`Extract translatable strings into locales/ catalogs`).option(`--locale <locale>`,`Scaffold an empty catalog for a target locale (e.g. fr-FR)`).action(async(e,t)=>{await c.execute({appPath:g(e),locale:t.locale})}),Ut(e)},Gt=async(e,n)=>{let r=n.test?t.x:t.b,i=n.port?parseInt(n.port,10):r;(isNaN(i)||i<1||i>65535)&&(console.error(u.default.red(`Invalid port number.`)),process.exit(1));let a=await t.n({port:i,test:n.test,version:e,onProgress:e=>console.log(u.default.gray(e))});a.success||(console.error(u.default.red(a.error.message)),process.exit(1))},Kt=e=>{let n=e.test?t.S:t.y;if(!t.w(n)){console.log(u.default.yellow(`No Twenty server container found.`));return}(0,l.execSync)(`docker stop ${n}`,{stdio:`ignore`}),console.log(u.default.green(`Twenty server stopped.`))},qt=e=>{let n=e.test?t.S:t.y;if(!t.w(n)){console.log(u.default.yellow(`No Twenty server container found.`));return}try{(0,l.spawnSync)(`docker`,[`logs`,`-f`,`--tail`,e.lines,n],{stdio:`inherit`})}catch{}},Jt=async e=>{let n=e.test?t.S:t.y,r=e.test?t.x:t.b;if(!t.w(n)){console.log(` Status: ${u.default.gray(`not created`)}`),console.log(u.default.gray(` Run 'yarn twenty docker:start${e.test?` --test`:``}' to create one.`));return}let i=t.A(n),a=i?t.D(n):r,o=i?await t.f(a):!1,s=o?u.default.green(`running (healthy)`):i?u.default.yellow(`running (starting...)`):u.default.gray(`stopped`),c=t.E(`APP_VERSION`,n);console.log(` Status: ${s}`),console.log(` URL: http://localhost:${a}`),c&&console.log(` Version: ${u.default.gray(c)}`),o&&console.log(u.default.gray(` Login: tim@apple.dev / tim@apple.dev`))},Yt=e=>{let n=e.test?t.S:t.y,r=e.test?`twenty-app-dev-test-data`:`twenty-app-dev-data`,i=e.test?`twenty-app-dev-test-storage`:`twenty-app-dev-storage`;t.w(n)&&(0,l.execSync)(`docker rm -f ${n}`,{stdio:`ignore`});try{(0,l.execSync)(`docker volume rm ${r} ${i}`,{stdio:`ignore`})}catch{}console.log(u.default.green(`Twenty server data reset.`)),console.log(u.default.gray(`Run 'yarn twenty docker:start${e.test?` --test`:``}' to start a fresh instance.`))},Xt=async(e,n)=>{let r=await t.a({version:e??`latest`,test:n.test,onProgress:e=>console.log(u.default.gray(e))});r.success||(console.error(u.default.red(r.error.message)),process.exit(1));let{data:i}=r;if(!i.imageUpdated){console.log(u.default.green(` Already up to date (${i.image}).`));return}console.log(u.default.green(` Upgraded to: ${i.image}`)),i.containerRecreated&&console.log(u.default.gray(` Run 'yarn twenty docker:start${n.test?` --test`:``}' to wait for the server to be ready.`))},Zt=e=>{e.command(`docker:start [version]`).description("Start the local Twenty container (version defaults to the app `engines.twenty` range, then `latest`)").option(`-p, --port <port>`,`HTTP port`).option(`--test`,`Start a separate test instance (port 2021)`).action(Gt),e.command(`docker:stop`).description(`Stop the local Twenty container`).option(`--test`,`Stop the test instance`).action(Kt),e.command(`docker:logs`).description(`Stream container logs`).option(`-n, --lines <lines>`,`Number of lines to show`,`50`).option(`--test`,`Show logs for the test instance`).action(qt),e.command(`docker:status`).description(`Show container status`).option(`--test`,`Show status of the test instance`).action(Jt),e.command(`docker:reset`).description(`Delete all data and start fresh`).option(`--test`,`Reset the test instance`).action(Yt),e.command(`docker:upgrade [version]`).description(`Upgrade the Docker image`).option(`--test`,`Upgrade the test instance`).action(Xt);let t=e.command(`server`,{hidden:!0}).description(`Manage a Twenty server (local instance and server-side actions)`),n=(e,t)=>console.warn(u.default.yellow(`⚠ \`twenty server ${e}\` is deprecated. Use \`twenty ${t}\` instead.`));t.command(`start [version]`).option(`-p, --port <port>`,`HTTP port`).option(`--test`,`Start a separate test instance (port 2021)`).action(async(e,t)=>{n(`start`,`docker:start`),await Gt(e,t)}),t.command(`stop`).option(`--test`,`Stop the test instance`).action(e=>{n(`stop`,`docker:stop`),Kt(e)}),t.command(`logs`).option(`-n, --lines <lines>`,`Number of lines to show`,`50`).option(`--test`,`Show logs for the test instance`).action(e=>{n(`logs`,`docker:logs`),qt(e)}),t.command(`status`).option(`--test`,`Show status of the test instance`).action(async e=>{n(`status`,`docker:status`),await Jt(e)}),t.command(`reset`).option(`--test`,`Reset the test instance`).action(e=>{n(`reset`,`docker:reset`),Yt(e)}),t.command(`upgrade [version]`).option(`--test`,`Upgrade the test instance`).action(async(e,t)=>{n(`upgrade`,`docker:upgrade`),await Xt(e,t)}),t.command(`catalog-sync`).option(`-r, --remote <name>`,`Sync on a specific remote`).action(async e=>{n(`catalog-sync`,`dev:catalog-sync`);let{CatalogSyncCommand:t}=await Promise.resolve().then(()=>require("./catalog-sync-CgKswjsE.js"));await new t().execute({remote:e.remote})})},Qt=e=>{try{return new URL(e).hostname.replace(/\./g,`-`)}catch{return`remote`}},$t=async(e,n)=>n?((await t.t({apiKey:n,apiUrl:e})).success||(console.error(u.default.red(`✗ Authentication failed.`)),process.exit(1)),`API key`):en(e),en=async e=>{console.log(u.default.gray(`Opening browser for authentication...`));let n=await t.B({apiUrl:e});return n.success?`OAuth`:(console.log(u.default.yellow(n.error.message)),(await t.t({apiKey:(await d.default.prompt([{type:`password`,name:`apiKey`,message:`API Key:`,mask:`*`,validate:e=>e.length>0||`API key is required`}])).apiKey,apiUrl:e})).success||(console.error(u.default.red(`✗ Authentication failed.`)),process.exit(1)),`API key`)},tn=async e=>{e.apiUrl&&console.warn(u.default.yellow(`⚠ --api-url is deprecated. Use --url instead.`));let n=e.test?t.H(!0):void 0,r=new t.V(n?{configPath:n}:void 0),i=await r.getRemotes();if(e.as!==void 0&&i.includes(e.as)){let n=await r.getConfigForRemote(e.as);t.V.setActiveRemote(e.as);let i=await $t(n.apiUrl,e.apiKey);console.log(u.default.green(`✓ Re-authenticated "${e.as}" via ${i}.`)),await r.setDefaultRemote(e.as),console.log(u.default.green(`✓ Default remote set to "${e.as}".`));return}let a=e.url??e.apiUrl;if(a)a=t.pt(a);else{let n=await t.p();e.local?(n||(console.error(u.default.red(`No local Twenty server found.
354
+ Start one with: yarn twenty docker:start`)),process.exit(1)),console.log(u.default.gray(`Found local server at ${n}`)),a=n):a=t.pt((await d.default.prompt([{type:`input`,name:`serverUrl`,message:`Twenty server URL:`,validate:e=>{try{return new URL(e),!0}catch{return`Please enter a valid URL`}}}])).serverUrl)}let o=e.as??Qt(a);t.V.setActiveRemote(o);let s=await $t(a,e.apiKey);console.log(u.default.green(`✓ Remote "${o}" added (${a}) via ${s}.`)),await r.setDefaultRemote(o),console.log(u.default.green(`✓ Default remote set to "${o}".`))},nn=async()=>{let e=new t.V,n=await e.getRemotes(),r=await e.getDefaultRemote();if(n.length===0){console.log(`No remotes configured.`),console.log(`Use 'twenty remote:add' to add one.`);return}console.log(``);for(let t of n){let n=await e.getConfigForRemote(t),i=n.twentyCLIAccessToken?`oauth`:n.apiKey?`api-key`:`none`,a=t===r,o=a?`* `:` `,s=a?u.default.bold(t):t;console.log(`${o}${s} ${u.default.gray(n.apiUrl)} [${i}]`)}console.log(`
355
+ `,u.default.gray(`Use 'twenty remote:use <name>' to change default`))},rn=async e=>{let n=new t.V,r=e??(await d.default.prompt([{type:`select`,name:`remote`,message:`Select default remote:`,choices:await n.getRemotes()}])).remote;(await n.getRemotes()).includes(r)||(console.error(u.default.red(`Remote "${r}" not found.`)),process.exit(1)),await n.setDefaultRemote(r),console.log(u.default.green(`✓ Default remote set to "${r}".`))},an=async()=>{let e=new t.V,n=new t.L,r=t.V.getActiveRemote(),i=await e.getConfig(),a=i.twentyCLIAccessToken?`oauth`:i.apiKey?`api-key`:`none`;if(console.log(` Remote: ${u.default.bold(r)}`),console.log(` Server: ${i.apiUrl}`),a===`none`){console.log(` Auth: ${u.default.yellow(`not configured`)}`);return}let{authValid:o}=await n.validateAuth(),s=o?u.default.green(`${a} (valid)`):u.default.red(`${a} (invalid)`);console.log(` Auth: ${s}`)},on=async e=>{let n=new t.V;(await n.getRemotes()).includes(e)||(console.error(u.default.red(`Remote "${e}" not found.`)),process.exit(1)),t.V.setActiveRemote(e),await n.clearConfig(),console.log(u.default.green(`✓ Remote "${e}" removed.`))},sn=e=>{e.command(`remote:add`).description(`Add or re-authenticate a remote`).option(`--as <name>`,`Name for this remote`).option(`--api-key <apiKey>`,`API key for non-interactive auth`).option(`--url <url>`,`Server URL`).option(`--api-url <apiUrl>`,`[deprecated: use --url]`).option(`--local`,`Connect to a local Twenty server (auto-detect)`).option(`--test`,`Write to config.test.json (for integration tests)`).action(tn),e.command(`remote:list`).description(`List all configured remotes`).action(nn),e.command(`remote:use [name]`).description(`Set the default remote`).action(rn),e.command(`remote:status`).description(`Show active remote auth status`).action(an),e.command(`remote:remove <name>`).description(`Remove a remote`).action(on);let t=e.command(`remote`,{hidden:!0}).description(`Manage remote Twenty servers`),n=(e,t)=>console.warn(u.default.yellow(`⚠ \`twenty remote ${e}\` is deprecated. Use \`twenty ${t}\` instead.`));t.command(`add`).option(`--as <name>`,`Name for this remote`).option(`--api-key <apiKey>`,`API key for non-interactive auth`).option(`--url <url>`,`Server URL`).option(`--api-url <apiUrl>`,`[deprecated: use --url]`).option(`--local`,`Connect to a local Twenty server (auto-detect)`).option(`--test`,`Write to config.test.json (for integration tests)`).action(async e=>{n(`add`,`remote:add`),await tn(e)}),t.command(`list`).action(async()=>{n(`list`,`remote:list`),await nn()}),t.command(`switch [name]`).action(async e=>{n(`switch`,`remote:use`),await rn(e)}),t.command(`status`).action(async()=>{n(`status`,`remote:status`),await an()}),t.command(`remove <name>`).action(async e=>{n(`remove`,`remote:remove`),await on(e)})},cn=e=>{Wt(e),ee(e),Zt(e),sn(e),Ne(e)};h.inspect.defaultOptions.depth=10;var ln=new m.Command;ln.name(`twenty`).description(`CLI for Twenty application development`).version(t.P.version),ln.option(`-r, --remote <name>`,`Use a specific remote (overrides the default set by remote:use)`),ln.hook(`preAction`,async e=>{let n=(e.optsWithGlobals?e.optsWithGlobals():e.opts()).remote;n?console.log(u.default.gray(`Using remote: ${n}`)):n=await new t.V().getDefaultRemote(),t.V.setActiveRemote(n)}),cn(ln),ln.exitOverride();try{ln.parse()}catch(e){e instanceof m.CommanderError&&process.exit(e.exitCode),e instanceof Error&&(console.error(u.default.red(`Error:`),e.message),process.exit(1))}