twenty-sdk 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/README.md +1 -1
  2. package/dist/{HtmlTagToRemoteComponent-DBOkvIRB.mjs → HtmlTagToRemoteComponent-CALlgbCB.mjs} +283 -231
  3. package/dist/{HtmlTagToRemoteComponent-DzQ2I9Lz.js → HtmlTagToRemoteComponent-DvFlyCDv.js} +11 -11
  4. package/dist/cli/utilities/api/api-service.d.ts +4 -0
  5. package/dist/cli/utilities/build/common/esbuild-watcher.d.ts +5 -2
  6. package/dist/cli/utilities/build/common/typecheck-plugin.d.ts +1 -1
  7. package/dist/cli/utilities/client/client-service.d.ts +6 -1
  8. package/dist/cli/utilities/dev/orchestrator/dev-mode-orchestrator.d.ts +2 -0
  9. package/dist/cli/utilities/dev/orchestrator/steps/start-watchers-orchestrator-step.d.ts +2 -0
  10. package/dist/cli.cjs +376 -70
  11. package/dist/cli.mjs +2139 -1769
  12. package/dist/front-component-renderer/index.cjs +10 -10
  13. package/dist/front-component-renderer/index.d.ts +3 -3
  14. package/dist/front-component-renderer/index.mjs +2048 -1877
  15. package/dist/front-component-renderer/remote/generated/remote-components.d.ts +4 -0
  16. package/dist/front-component-renderer/remote/generated/remote-elements.d.ts +43 -0
  17. package/dist/front-component-renderer/types/FrontComponentHostCommunicationApi.d.ts +2 -1
  18. package/dist/{get-function-input-schema-BZ7_XyUh-By3UDh4s.mjs → get-function-input-schema-BZ7_XyUh-C9RBS5oC.mjs} +1 -1
  19. package/dist/{get-function-input-schema-BZ7_XyUh-GxSybvDe.js → get-function-input-schema-BZ7_XyUh-CzwPUwwE.js} +1 -1
  20. package/dist/index.cjs +1 -1
  21. package/dist/index.mjs +2 -2
  22. package/dist/sdk/front-component-api/constants/AllowedHtmlElements.js +53 -1
  23. package/dist/sdk/front-component-api/constants/AllowedHtmlElements.js.map +1 -1
  24. package/dist/sdk/front-component-api/globals/frontComponentHostCommunicationApi.d.ts +2 -0
  25. package/dist/sdk/front-component-api/globals/frontComponentHostCommunicationApi.js.map +1 -1
  26. package/package.json +17 -1
package/dist/cli.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var wm=Object.create;var tl=Object.defineProperty;var xm=Object.getOwnPropertyDescriptor;var Sm=Object.getOwnPropertyNames;var Am=Object.getPrototypeOf,Im=Object.prototype.hasOwnProperty;var Fm=(o,s,r,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let p of Sm(s))!Im.call(o,p)&&p!==r&&tl(o,p,{get:()=>s[p],enumerable:!(l=xm(s,p))||l.enumerable});return o};var Em=(o,s,r)=>(r=o!=null?wm(Am(o)):{},Fm(s||!o||!o.__esModule?tl(r,"default",{value:o,enumerable:!0}):r,o));const $=require("path"),Tm=require("chalk"),L=require("react/jsx-runtime"),Gn=require("react"),fl=require("fs-extra"),bm=require("os"),Cm=require("axios"),Pm=require("fs"),Rm=require("graphql-sse"),ds=require("graphql"),P=require("./HtmlTagToRemoteComponent-DzQ2I9Lz.js"),Om=require("@genql/cli"),Lm=require("typescript"),km=require("esbuild"),Nm=require("module"),pl=require("fast-glob");require("@sniptt/guards");const We=require("uuid"),Um=require("crypto"),Dm=require("node:fs/promises"),Wm=require("fs/promises"),dl=require("node:child_process"),$m=require("node:path"),Mm=require("chokidar"),Bm=require("inquirer"),jm=require("lodash.kebabcase"),hl=require("commander"),qm=require("util"),Mt=o=>o&&o.__esModule?o:{default:o};function Bt(o){if(o&&o.__esModule)return o;const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const r in o)if(r!=="default"){const l=Object.getOwnPropertyDescriptor(o,r);Object.defineProperty(s,r,l.get?l:{enumerable:!0,get:()=>o[r]})}}return s.default=o,Object.freeze(s)}const Y=Bt($),A=Mt(Tm),gl=Mt(Gn),k=Bt(fl),ms=Bt(bm),hn=Mt(Cm),nl=Bt(Pm),gn=Bt(Lm),ml=Bt(km),Hr=Mt(Um),Hm=Bt(Dm),rl=Bt(Wm),jr=Mt($m),vl=Mt(Mm),ot=Mt(Bm),Ze=Mt(jm);var Mr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};const Ie=process.env.INIT_CWD||process.cwd(),jn=o=>o&&!o?.startsWith("/")?$.join(Ie,o):o,Br="api-client",vs="public",Gm="TWENTY_API_KEY",il="TWENTY_API_URL",Gr="generated",Jm={js:`import { createRequire as __createRequire } from 'module';
3
- const require = __createRequire(import.meta.url);`},Qe=".twenty/output";var K=(o=>(o.Object="object",o.Field="field",o.LogicFunction="logicFunction",o.FrontComponent="frontComponent",o.Role="role",o.Skill="skill",o.View="view",o.NavigationMenuItem="navigationMenuItem",o.PageLayout="pageLayout",o))(K||{});const Xe={idle:{color:"gray",icon:"○"},in_progress:{color:"yellow",icon:"spinner"},uploading:{color:"cyan",icon:"upload"},done:{color:"green",icon:"✓"},error:{color:"red",icon:"✗"}},zm=o=>({idle:"idle",in_progress:"in_progress",done:"done",error:"error"})[o],Km=o=>({pending:"idle",building:"in_progress",uploading:"uploading",success:"done",error:"error"})[o],Vm=o=>({idle:"idle",building:"in_progress",syncing:"in_progress",synced:"done",error:"error"})[o],Ym={idle:"Idle",building:"Building...",syncing:"Syncing...",synced:"Synced",error:"Error"},yl=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],_l=["↑","⇡","↟","⤒"],wl={[K.Object]:"Objects",[K.Field]:"Fields",[K.LogicFunction]:"Logic functions",[K.FrontComponent]:"Front components",[K.Role]:"Roles",[K.Skill]:"Skills",[K.View]:"Views",[K.NavigationMenuItem]:"Navigation menu items",[K.PageLayout]:"Page layouts"},xl=Object.keys(wl),Xm={info:"gray",success:"green",error:"red",warning:"yellow"},Zm=o=>o.toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),Qm=(o,s=40)=>{if(o.length<=s)return o;const r=o.split("/");return r.length<=2?o:`.../${r.slice(-2).join("/")}`},ev=o=>{const s=new Map;for(const r of xl)s.set(r,[]);for(const r of o.values()){if(!r.type)continue;const l=s.get(r.type)??[];l.push(r),s.set(r.type,l)}return s},tv=o=>!o.frontendUrl||!o.steps.resolveApplication.output.universalIdentifier?null:`${o.frontendUrl}/settings/applications`,nv=o=>o.some(s=>s==="error")?"error":o.some(s=>s==="in_progress")?"in_progress":o.every(s=>s==="done")?"done":"idle",rv=o=>{const s=[...o.entities.values()],r=s.some(v=>v.status==="error"),l=s.some(v=>v.status==="building"),p=s.length>0&&s.every(v=>v.status==="uploading"||v.status==="success"),m=r?"error":l?"in_progress":p?"done":"idle";return[{label:"Application Initialization",status:nv([o.steps.checkServer.status,o.steps.ensureValidTokens.status,o.steps.resolveApplication.status])},{label:"Resources Build",status:m},{label:"Resources Upload",status:o.steps.uploadFiles.status},{label:"Manifest Build",status:o.steps.buildManifest.status},{label:"Application Synchronization",status:o.steps.syncApplication.status},{label:"Api Client Generation",status:o.steps.generateApiClient.status}]},sl=(o,s=80,r=!0)=>{const[l,p]=Gn.useState(0);return Gn.useEffect(()=>{if(!r)return;const m=setInterval(()=>{p(v=>(v+1)%o.length)},s);return()=>clearInterval(m)},[o,s,r]),o[l]},ys=o=>{const s=Xe[o],r=sl(yl,80,s.icon==="spinner"),l=sl(_l,200,s.icon==="upload");return s.icon==="spinner"?r:s.icon==="upload"?l:s.icon},Sl=gl.default.createContext(null),iv=Sl.Provider,Et=()=>{const o=gl.default.useContext(Sl);if(!o)throw new Error("useInk must be used within InkProvider");return o},sv=({uiStatus:o})=>{const{Text:s}=Et(),r=ys(o),l=Xe[o];return L.jsxs(s,{color:l.color,children:[r," "]})},av=({entity:o})=>{const{Box:s,Text:r}=Et();return L.jsxs(s,{children:[L.jsx(sv,{uiStatus:Km(o.status)}),L.jsx(r,{children:o.name}),o.path!==o.name&&L.jsxs(r,{dimColor:!0,children:[" (",Qm(o.path),")"]})]})},ov=({type:o,entities:s})=>{const{Box:r,Text:l}=Et();return s.length===0?null:L.jsxs(r,{flexDirection:"column",marginTop:1,children:[L.jsx(l,{bold:!0,dimColor:!0,children:wl[o]}),s.map(p=>L.jsx(av,{entity:p},p.path))]})},lv=()=>{const{Box:o,Text:s}=Et();return L.jsx(o,{marginTop:1,children:L.jsxs(s,{dimColor:!0,children:[L.jsx(s,{color:Xe.idle.color,children:Xe.idle.icon})," ","pending"," ",L.jsx(s,{color:Xe.in_progress.color,children:yl[0]})," ","building"," ",L.jsx(s,{color:Xe.uploading.color,children:_l[0]})," ","uploading"," ",L.jsx(s,{color:Xe.done.color,children:Xe.done.icon})," ","success"," ",L.jsx(s,{color:Xe.error.color,children:Xe.error.icon})," ","error"]})})},uv=({state:o})=>{const{Text:s}=Et(),r=Vm(o.pipeline.status),l=ys(r),p=Xe[r],m=Ym[o.pipeline.status];return L.jsxs(s,{color:p.color,children:[l," ",m,o.pipeline.error&&`: ${o.pipeline.error}`]})},cv=({label:o,status:s})=>{const{Box:r,Text:l}=Et(),p=zm(s),m=ys(p),v=Xe[p];return L.jsxs(r,{children:[L.jsxs(l,{dimColor:!0,children:[o,": "]}),L.jsxs(l,{color:v.color,children:[m," ",s.replace("_"," ")]})]})},fv=({state:o})=>{const{Box:s,Text:r}=Et(),l=ev(o.entities),p=tv(o);return L.jsxs(s,{flexDirection:"column",borderStyle:"classic",borderColor:"gray",paddingX:1,children:[L.jsx(r,{bold:!0,color:"cyan",children:"Application"}),L.jsxs(s,{marginLeft:2,flexDirection:"column",children:[L.jsxs(s,{children:[L.jsx(r,{dimColor:!0,children:"Name: "}),L.jsx(r,{bold:!0,children:o.pipeline.appName??"Loading..."})]}),L.jsxs(s,{children:[L.jsx(r,{dimColor:!0,children:"Overall Status: "}),L.jsx(uv,{state:o})]}),p&&L.jsxs(s,{children:[L.jsx(r,{dimColor:!0,children:"Open:"}),L.jsxs(r,{bold:!0,color:"cyan",children:[" ",p]})]})]}),L.jsx(s,{marginLeft:2,flexDirection:"column",marginTop:1,children:rv(o).map(m=>L.jsx(cv,{label:m.label,status:m.status},m.label))}),L.jsx(s,{marginLeft:2,flexDirection:"column",children:xl.map(m=>{const v=l.get(m)??[];return L.jsx(ov,{type:m,entities:v},m)})})]})},pv=({event:o})=>{const{Box:s,Text:r}=Et(),l=Xm[o.status],p=Zm(o.timestamp);return L.jsxs(s,{children:[L.jsxs(r,{dimColor:!0,children:[p," "]}),L.jsx(r,{color:l,children:o.message})]})},dv=({uiStateManager:o})=>{const{Box:s,Static:r}=Et(),[,l]=Gn.useReducer(m=>m+1,0);Gn.useEffect(()=>o.subscribe(()=>l()),[o]);const p=o.getSnapshot();return L.jsxs(L.Fragment,{children:[L.jsx(r,{items:p.events,children:m=>L.jsx(pv,{event:m},m.id)}),L.jsxs(s,{marginTop:1,flexDirection:"column",children:[L.jsx(fv,{state:p}),L.jsx(lv,{})]})]})},hv=async o=>{const s=await import("ink"),{render:r,Box:l,Text:p,Static:m}=s,{unmount:v}=r(L.jsx(iv,{value:{Box:l,Text:p,Static:m},children:L.jsx(dv,{uiStateManager:o})}));return{unmount:v}};class gv{constructor(s){this.listeners=new Set,this.orchestratorState=s}getSnapshot(){return this.orchestratorState}subscribe(s){return this.listeners.add(s),s(this.orchestratorState),()=>this.listeners.delete(s)}notify(){for(const s of this.listeners)s(this.orchestratorState)}}const mv=Y.join(ms.tmpdir(),".twenty-sdk-test"),vv=()=>process.env.NODE_ENV==="test"?Y.join(mv,"config.json"):Y.join(ms.homedir(),".twenty","config.json"),Ft="default",qr=class qr{constructor(){this.configPath=vv()}static setActiveWorkspace(s){this.activeWorkspace=s??Ft}static getActiveWorkspace(){return this.activeWorkspace}getActiveWorkspaceName(){return qr.getActiveWorkspace()}async readRawConfig(){await k.ensureFile(this.configPath);const s=await k.readFile(this.configPath,"utf8");return JSON.parse(s||"{}")}async getConfig(){return this.getConfigForWorkspace(this.getActiveWorkspaceName())}async getConfigForWorkspace(s){const r=this.getDefaultConfig();try{const l=await this.readRawConfig(),p=s===Ft&&!l.profiles?.[Ft]?l:l.profiles?.[s],m=p?.apiUrl??r.apiUrl,v=p?.apiKey,E=p?.applicationAccessToken,b=p?.applicationRefreshToken;return{apiUrl:m,apiKey:v,applicationAccessToken:E,applicationRefreshToken:b}}catch{return r}}async setConfig(s){const r=await this.readRawConfig(),l=this.getActiveWorkspaceName();r.profiles||(r.profiles={});const p=r.profiles[l]||{apiUrl:""};r.profiles[l]={...p,...s},await k.ensureDir(Y.dirname(this.configPath)),await k.writeFile(this.configPath,JSON.stringify(r,null,2))}async clearConfig(){const s=await this.readRawConfig(),r=this.getActiveWorkspaceName();if(s.profiles||(s.profiles={}),s.profiles[r]&&delete s.profiles[r],r===Ft){const l=this.getDefaultConfig();delete s.apiKey,s.apiUrl=l.apiUrl}await k.ensureDir(Y.dirname(this.configPath)),await k.writeFile(this.configPath,JSON.stringify(s,null,2))}getDefaultConfig(){return{apiUrl:"http://localhost:3000"}}async getAvailableWorkspaces(){try{const s=await this.readRawConfig(),r=new Set;return r.add(Ft),s.profiles&&Object.keys(s.profiles).forEach(l=>r.add(l)),Array.from(r).sort()}catch{return[Ft]}}async getDefaultWorkspace(){try{return(await this.readRawConfig()).defaultWorkspace??Ft}catch{return Ft}}async setDefaultWorkspace(s){const r=await this.readRawConfig();r.defaultWorkspace=s,await k.ensureDir(Y.dirname(this.configPath)),await k.writeFile(this.configPath,JSON.stringify(r,null,2))}};qr.activeWorkspace=Ft;let we=qr;class Tt{constructor(s){const{disableInterceptors:r=!1}=s||{};this.configService=new we,this.client=hn.default.create(),this.client.interceptors.request.use(async l=>{const p=await this.configService.getConfig();return l.baseURL=p.apiUrl,!l.headers.Authorization&&p.apiKey&&(l.headers.Authorization=`Bearer ${p.apiKey}`),l}),!r&&this.client.interceptors.response.use(l=>l,l=>{throw l.response?.status===401?console.error(A.default.red("Authentication failed. Please run `twenty auth:login` first.")):l.response?.status===403?console.error(A.default.red("Access denied. Check your API key and workspace permissions.")):l.code==="ECONNREFUSED"&&console.error(A.default.red("Cannot connect to Twenty server. Is it running?")),l})}async validateAuth(){try{const r=await this.client.post("/metadata",{query:`
2
+ "use strict";var Am=Object.create;var tl=Object.defineProperty;var Sm=Object.getOwnPropertyDescriptor;var Im=Object.getOwnPropertyNames;var Tm=Object.getPrototypeOf,Em=Object.prototype.hasOwnProperty;var Fm=(o,s,r,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let f of Im(s))!Em.call(o,f)&&f!==r&&tl(o,f,{get:()=>s[f],enumerable:!(l=Sm(s,f))||l.enumerable});return o};var bm=(o,s,r)=>(r=o!=null?Am(Tm(o)):{},Fm(s||!o||!o.__esModule?tl(r,"default",{value:o,enumerable:!0}):r,o));const R=require("path"),Cm=require("chalk"),N=require("react/jsx-runtime"),Gn=require("react"),dl=require("fs-extra"),Pm=require("os"),Rm=require("axios"),km=require("fs"),Om=require("graphql-sse"),ds=require("graphql"),k=require("./HtmlTagToRemoteComponent-DvFlyCDv.js"),nl=require("@genql/cli"),Lm=require("typescript"),Nm=require("esbuild"),Um=require("module"),hl=require("fast-glob");require("@sniptt/guards");const $e=require("uuid"),Dm=require("crypto"),$m=require("node:fs/promises"),Wm=require("fs/promises"),gl=require("node:child_process"),Mm=require("node:path"),Bm=require("chokidar"),jm=require("inquirer"),qm=require("lodash.kebabcase"),ml=require("commander"),Hm=require("util"),Mt=o=>o&&o.__esModule?o:{default:o};function Bt(o){if(o&&o.__esModule)return o;const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const r in o)if(r!=="default"){const l=Object.getOwnPropertyDescriptor(o,r);Object.defineProperty(s,r,l.get?l:{enumerable:!0,get:()=>o[r]})}}return s.default=o,Object.freeze(s)}const Y=Bt(R),S=Mt(Cm),vl=Mt(Gn),C=Bt(dl),ms=Bt(Pm),hn=Mt(Rm),rl=Bt(km),gn=Bt(Lm),yl=Bt(Nm),Hr=Mt(Dm),Gm=Bt($m),il=Bt(Wm),jr=Mt(Mm),_l=Mt(Bm),ot=Mt(jm),Ze=Mt(qm);var Mr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};const Ie=process.env.INIT_CWD||process.cwd(),jn=o=>o&&!o?.startsWith("/")?R.join(Ie,o):o,Br="api-client",vs="public",zm="TWENTY_API_KEY",sl="TWENTY_API_URL",Km="TWENTY_APP_ACCESS_TOKEN",Gr="generated",Jm={js:`import { createRequire as __createRequire } from 'module';
3
+ const require = __createRequire(import.meta.url);`},Qe=".twenty/output";var J=(o=>(o.Object="object",o.Field="field",o.LogicFunction="logicFunction",o.FrontComponent="frontComponent",o.Role="role",o.Skill="skill",o.View="view",o.NavigationMenuItem="navigationMenuItem",o.PageLayout="pageLayout",o))(J||{});const Xe={idle:{color:"gray",icon:"○"},in_progress:{color:"yellow",icon:"spinner"},uploading:{color:"cyan",icon:"upload"},done:{color:"green",icon:"✓"},error:{color:"red",icon:"✗"}},Vm=o=>({idle:"idle",in_progress:"in_progress",done:"done",error:"error"})[o],Ym=o=>({pending:"idle",building:"in_progress",uploading:"uploading",success:"done",error:"error"})[o],Xm=o=>({idle:"idle",building:"in_progress",syncing:"in_progress",synced:"done",error:"error"})[o],Zm={idle:"Idle",building:"Building...",syncing:"Syncing...",synced:"Synced",error:"Error"},wl=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],xl=["↑","⇡","↟","⤒"],Al={[J.Object]:"Objects",[J.Field]:"Fields",[J.LogicFunction]:"Logic functions",[J.FrontComponent]:"Front components",[J.Role]:"Roles",[J.Skill]:"Skills",[J.View]:"Views",[J.NavigationMenuItem]:"Navigation menu items",[J.PageLayout]:"Page layouts"},Sl=Object.keys(Al),Qm={info:"gray",success:"green",error:"red",warning:"yellow"},ev=o=>o.toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),tv=(o,s=40)=>{if(o.length<=s)return o;const r=o.split("/");return r.length<=2?o:`.../${r.slice(-2).join("/")}`},nv=o=>{const s=new Map;for(const r of Sl)s.set(r,[]);for(const r of o.values()){if(!r.type)continue;const l=s.get(r.type)??[];l.push(r),s.set(r.type,l)}return s},rv=o=>!o.frontendUrl||!o.steps.resolveApplication.output.universalIdentifier?null:`${o.frontendUrl}/settings/applications`,iv=o=>o.some(s=>s==="error")?"error":o.some(s=>s==="in_progress")?"in_progress":o.every(s=>s==="done")?"done":"idle",sv=o=>{const s=[...o.entities.values()],r=s.some(v=>v.status==="error"),l=s.some(v=>v.status==="building"),f=s.length>0&&s.every(v=>v.status==="uploading"||v.status==="success"),m=r?"error":l?"in_progress":f?"done":"idle";return[{label:"Application Initialization",status:iv([o.steps.checkServer.status,o.steps.ensureValidTokens.status,o.steps.resolveApplication.status])},{label:"Resources Build",status:m},{label:"Resources Upload",status:o.steps.uploadFiles.status},{label:"Manifest Build",status:o.steps.buildManifest.status},{label:"Application Synchronization",status:o.steps.syncApplication.status},{label:"Api Client Generation",status:o.steps.generateApiClient.status}]},al=(o,s=80,r=!0)=>{const[l,f]=Gn.useState(0);return Gn.useEffect(()=>{if(!r)return;const m=setInterval(()=>{f(v=>(v+1)%o.length)},s);return()=>clearInterval(m)},[o,s,r]),o[l]},ys=o=>{const s=Xe[o],r=al(wl,80,s.icon==="spinner"),l=al(xl,200,s.icon==="upload");return s.icon==="spinner"?r:s.icon==="upload"?l:s.icon},Il=vl.default.createContext(null),av=Il.Provider,Et=()=>{const o=vl.default.useContext(Il);if(!o)throw new Error("useInk must be used within InkProvider");return o},ov=({uiStatus:o})=>{const{Text:s}=Et(),r=ys(o),l=Xe[o];return N.jsxs(s,{color:l.color,children:[r," "]})},lv=({entity:o})=>{const{Box:s,Text:r}=Et();return N.jsxs(s,{children:[N.jsx(ov,{uiStatus:Ym(o.status)}),N.jsx(r,{children:o.name}),o.path!==o.name&&N.jsxs(r,{dimColor:!0,children:[" (",tv(o.path),")"]})]})},uv=({type:o,entities:s})=>{const{Box:r,Text:l}=Et();return s.length===0?null:N.jsxs(r,{flexDirection:"column",marginTop:1,children:[N.jsx(l,{bold:!0,dimColor:!0,children:Al[o]}),s.map(f=>N.jsx(lv,{entity:f},f.path))]})},cv=()=>{const{Box:o,Text:s}=Et();return N.jsx(o,{marginTop:1,children:N.jsxs(s,{dimColor:!0,children:[N.jsx(s,{color:Xe.idle.color,children:Xe.idle.icon})," ","pending"," ",N.jsx(s,{color:Xe.in_progress.color,children:wl[0]})," ","building"," ",N.jsx(s,{color:Xe.uploading.color,children:xl[0]})," ","uploading"," ",N.jsx(s,{color:Xe.done.color,children:Xe.done.icon})," ","success"," ",N.jsx(s,{color:Xe.error.color,children:Xe.error.icon})," ","error"]})})},fv=({state:o})=>{const{Text:s}=Et(),r=Xm(o.pipeline.status),l=ys(r),f=Xe[r],m=Zm[o.pipeline.status];return N.jsxs(s,{color:f.color,children:[l," ",m,o.pipeline.error&&`: ${o.pipeline.error}`]})},pv=({label:o,status:s})=>{const{Box:r,Text:l}=Et(),f=Vm(s),m=ys(f),v=Xe[f];return N.jsxs(r,{children:[N.jsxs(l,{dimColor:!0,children:[o,": "]}),N.jsxs(l,{color:v.color,children:[m," ",s.replace("_"," ")]})]})},dv=({state:o})=>{const{Box:s,Text:r}=Et(),l=nv(o.entities),f=rv(o);return N.jsxs(s,{flexDirection:"column",borderStyle:"classic",borderColor:"gray",paddingX:1,children:[N.jsx(r,{bold:!0,color:"cyan",children:"Application"}),N.jsxs(s,{marginLeft:2,flexDirection:"column",children:[N.jsxs(s,{children:[N.jsx(r,{dimColor:!0,children:"Name: "}),N.jsx(r,{bold:!0,children:o.pipeline.appName??"Loading..."})]}),N.jsxs(s,{children:[N.jsx(r,{dimColor:!0,children:"Overall Status: "}),N.jsx(fv,{state:o})]}),f&&N.jsxs(s,{children:[N.jsx(r,{dimColor:!0,children:"Open:"}),N.jsxs(r,{bold:!0,color:"cyan",children:[" ",f]})]})]}),N.jsx(s,{marginLeft:2,flexDirection:"column",marginTop:1,children:sv(o).map(m=>N.jsx(pv,{label:m.label,status:m.status},m.label))}),N.jsx(s,{marginLeft:2,flexDirection:"column",children:Sl.map(m=>{const v=l.get(m)??[];return N.jsx(uv,{type:m,entities:v},m)})})]})},hv=({event:o})=>{const{Box:s,Text:r}=Et(),l=Qm[o.status],f=ev(o.timestamp);return N.jsxs(s,{children:[N.jsxs(r,{dimColor:!0,children:[f," "]}),N.jsx(r,{color:l,children:o.message})]})},gv=({uiStateManager:o})=>{const{Box:s,Static:r}=Et(),[,l]=Gn.useReducer(m=>m+1,0);Gn.useEffect(()=>o.subscribe(()=>l()),[o]);const f=o.getSnapshot();return N.jsxs(N.Fragment,{children:[N.jsx(r,{items:f.events,children:m=>N.jsx(hv,{event:m},m.id)}),N.jsxs(s,{marginTop:1,flexDirection:"column",children:[N.jsx(dv,{state:f}),N.jsx(cv,{})]})]})},mv=async o=>{const s=await import("ink"),{render:r,Box:l,Text:f,Static:m}=s,{unmount:v}=r(N.jsx(av,{value:{Box:l,Text:f,Static:m},children:N.jsx(gv,{uiStateManager:o})}));return{unmount:v}};class vv{constructor(s){this.listeners=new Set,this.orchestratorState=s}getSnapshot(){return this.orchestratorState}subscribe(s){return this.listeners.add(s),s(this.orchestratorState),()=>this.listeners.delete(s)}notify(){for(const s of this.listeners)s(this.orchestratorState)}}const yv=Y.join(ms.tmpdir(),".twenty-sdk-test"),_v=()=>process.env.NODE_ENV==="test"?Y.join(yv,"config.json"):Y.join(ms.homedir(),".twenty","config.json"),Tt="default",qr=class qr{constructor(){this.configPath=_v()}static setActiveWorkspace(s){this.activeWorkspace=s??Tt}static getActiveWorkspace(){return this.activeWorkspace}getActiveWorkspaceName(){return qr.getActiveWorkspace()}async readRawConfig(){await C.ensureFile(this.configPath);const s=await C.readFile(this.configPath,"utf8");return JSON.parse(s||"{}")}async getConfig(){return this.getConfigForWorkspace(this.getActiveWorkspaceName())}async getConfigForWorkspace(s){const r=this.getDefaultConfig();try{const l=await this.readRawConfig(),f=s===Tt&&!l.profiles?.[Tt]?l:l.profiles?.[s],m=f?.apiUrl??r.apiUrl,v=f?.apiKey,E=f?.applicationAccessToken,b=f?.applicationRefreshToken;return{apiUrl:m,apiKey:v,applicationAccessToken:E,applicationRefreshToken:b}}catch{return r}}async setConfig(s){const r=await this.readRawConfig(),l=this.getActiveWorkspaceName();r.profiles||(r.profiles={});const f=r.profiles[l]||{apiUrl:""};r.profiles[l]={...f,...s},await C.ensureDir(Y.dirname(this.configPath)),await C.writeFile(this.configPath,JSON.stringify(r,null,2))}async clearConfig(){const s=await this.readRawConfig(),r=this.getActiveWorkspaceName();if(s.profiles||(s.profiles={}),s.profiles[r]&&delete s.profiles[r],r===Tt){const l=this.getDefaultConfig();delete s.apiKey,s.apiUrl=l.apiUrl}await C.ensureDir(Y.dirname(this.configPath)),await C.writeFile(this.configPath,JSON.stringify(s,null,2))}getDefaultConfig(){return{apiUrl:"http://localhost:3000"}}async getAvailableWorkspaces(){try{const s=await this.readRawConfig(),r=new Set;return r.add(Tt),s.profiles&&Object.keys(s.profiles).forEach(l=>r.add(l)),Array.from(r).sort()}catch{return[Tt]}}async getDefaultWorkspace(){try{return(await this.readRawConfig()).defaultWorkspace??Tt}catch{return Tt}}async setDefaultWorkspace(s){const r=await this.readRawConfig();r.defaultWorkspace=s,await C.ensureDir(Y.dirname(this.configPath)),await C.writeFile(this.configPath,JSON.stringify(r,null,2))}};qr.activeWorkspace=Tt;let we=qr;class Ft{constructor(s){const{disableInterceptors:r=!1}=s||{};this.configService=new we,this.client=hn.default.create(),this.client.interceptors.request.use(async l=>{const f=await this.configService.getConfig();return l.baseURL=f.apiUrl,!l.headers.Authorization&&f.apiKey&&(l.headers.Authorization=`Bearer ${f.apiKey}`),l}),!r&&this.client.interceptors.response.use(l=>l,l=>{throw l.response?.status===401?console.error(S.default.red("Authentication failed. Please run `twenty auth:login` first.")):l.response?.status===403?console.error(S.default.red("Access denied. Check your API key and workspace permissions.")):l.code==="ECONNREFUSED"&&console.error(S.default.red("Cannot connect to Twenty server. Is it running?")),l})}async validateAuth(){try{const r=await this.client.post("/metadata",{query:`
4
4
  query CurrentWorkspace {
5
5
  currentWorkspace {
6
6
  id
@@ -46,18 +46,18 @@ const require = __createRequire(import.meta.url);`},Qe=".twenty/output";var K=(o
46
46
  universalIdentifier
47
47
  }
48
48
  }
49
- `,l={input:{universalIdentifier:s.application.universalIdentifier,name:s.application.displayName,version:"0.0.1",sourcePath:"cli-sync"}},p=await this.client.post("/metadata",{query:r,variables:l},{headers:{"Content-Type":"application/json",Accept:"*/*"}});return p.data.errors?{success:!1,error:p.data.errors[0]}:{success:!0,data:p.data.data.createOneApplication,message:`Successfully create application: ${s.application.displayName}`}}catch(r){return{success:!1,error:r}}}async syncApplication(s){try{const r=`
49
+ `,l={input:{universalIdentifier:s.application.universalIdentifier,name:s.application.displayName,version:"0.0.1",sourcePath:"cli-sync"}},f=await this.client.post("/metadata",{query:r,variables:l},{headers:{"Content-Type":"application/json",Accept:"*/*"}});return f.data.errors?{success:!1,error:f.data.errors[0]}:{success:!0,data:f.data.data.createOneApplication,message:`Successfully create application: ${s.application.displayName}`}}catch(r){return{success:!1,error:r}}}async syncApplication(s){try{const r=`
50
50
  mutation SyncApplication($manifest: JSON!) {
51
51
  syncApplication(manifest: $manifest) {
52
52
  applicationUniversalIdentifier
53
53
  actions
54
54
  }
55
55
  }
56
- `,l={manifest:s},p=await this.client.post("/metadata",{query:r,variables:l},{headers:{"Content-Type":"application/json",Accept:"*/*"}});return p.data.errors?{success:!1,error:p.data.errors[0]}:{success:!0,data:p.data.data.syncApplication,message:`Successfully synced application: ${s.application.displayName}`}}catch(r){if(hn.default.isAxiosError(r)&&r.response){const l=r.response.data?.errors;return Array.isArray(l)&&l.length>0?{success:!1,error:l[0]?.message||r.message}:{success:!1,error:r.response.data?.message||`HTTP ${r.response.status}: ${r.message}`}}return{success:!1,error:r instanceof Error?r.message:r}}}async uninstallApplication(s){try{const r=`
56
+ `,l={manifest:s},f=await this.client.post("/metadata",{query:r,variables:l},{headers:{"Content-Type":"application/json",Accept:"*/*"}});return f.data.errors?{success:!1,error:f.data.errors[0]}:{success:!0,data:f.data.data.syncApplication,message:`Successfully synced application: ${s.application.displayName}`}}catch(r){if(hn.default.isAxiosError(r)&&r.response){const l=r.response.data?.errors;return Array.isArray(l)&&l.length>0?{success:!1,error:l[0]?.message||r.message}:{success:!1,error:r.response.data?.message||`HTTP ${r.response.status}: ${r.message}`}}return{success:!1,error:r instanceof Error?r.message:r}}}async uninstallApplication(s){try{const r=`
57
57
  mutation UninstallApplication($universalIdentifier: String!) {
58
58
  uninstallApplication(universalIdentifier: $universalIdentifier)
59
59
  }
60
- `,l={universalIdentifier:s},p=await this.client.post("/metadata",{query:r,variables:l},{headers:{"Content-Type":"application/json",Accept:"*/*"}});return p.data.errors?{success:!1,error:p.data.errors[0]?.message||"Failed to delete application"}:{success:!0,data:p.data.data.uninstallApplication,message:"Successfully uninstalled application"}}catch(r){if(hn.default.isAxiosError(r)&&r.response)return{success:!1,error:r.response.data?.errors?.[0]?.message||r.message};throw r}}async getSchema(s){try{const r=ds.getIntrospectionQuery(),l={"Content-Type":"application/json",Accept:"*/*"};s?.authToken&&(l.Authorization=`Bearer ${s.authToken}`);const p=await this.client.post("/graphql",{query:r},{headers:l});if(p.data.errors)return{success:!1,error:`GraphQL introspection errors: ${JSON.stringify(p.data.errors)}`};const m=ds.buildClientSchema(p.data.data);return{success:!0,data:ds.printSchema(m),message:"Successfully load schema"}}catch(r){if(hn.default.isAxiosError(r)&&r.response)return{success:!1,error:r.response.data.errors[0]?.message||"Failed to load graphql Schema"};throw r}}async findLogicFunctions(){try{const r=await this.client.post("/metadata",{query:`
60
+ `,l={universalIdentifier:s},f=await this.client.post("/metadata",{query:r,variables:l},{headers:{"Content-Type":"application/json",Accept:"*/*"}});return f.data.errors?{success:!1,error:f.data.errors[0]?.message||"Failed to delete application"}:{success:!0,data:f.data.data.uninstallApplication,message:"Successfully uninstalled application"}}catch(r){if(hn.default.isAxiosError(r)&&r.response)return{success:!1,error:r.response.data?.errors?.[0]?.message||r.message};throw r}}async getSchema(s){return this.introspectEndpoint("/graphql",s)}async getMetadataSchema(s){return this.introspectEndpoint("/metadata",s)}async introspectEndpoint(s,r){try{const l=ds.getIntrospectionQuery(),f={"Content-Type":"application/json",Accept:"*/*"};r?.authToken&&(f.Authorization=`Bearer ${r.authToken}`);const m=await this.client.post(s,{query:l},{headers:f});if(m.data.errors)return{success:!1,error:`GraphQL introspection errors: ${JSON.stringify(m.data.errors)}`};const v=ds.buildClientSchema(m.data.data);return{success:!0,data:ds.printSchema(v),message:`Successfully loaded schema from ${s}`}}catch(l){if(hn.default.isAxiosError(l)&&l.response)return{success:!1,error:l.response.data.errors[0]?.message||`Failed to load schema from ${s}`};throw l}}async findLogicFunctions(){try{const r=await this.client.post("/metadata",{query:`
61
61
  query FindManyLogicFunctions {
62
62
  findManyLogicFunctions {
63
63
  id
@@ -76,51 +76,177 @@ const require = __createRequire(import.meta.url);`},Qe=".twenty/output";var K=(o
76
76
  error
77
77
  }
78
78
  }
79
- `,p={input:{id:s,payload:r}},m=await this.client.post("/metadata",{query:l,variables:p},{headers:{"Content-Type":"application/json",Accept:"*/*"}});return m.data.errors?{success:!1,error:m.data.errors[0]?.message||"Failed to execute logic function"}:{success:!0,data:m.data.data.executeOneLogicFunction}}catch(l){return{success:!1,error:l}}}async subscribeToLogs({applicationUniversalIdentifier:s,functionUniversalIdentifier:r,functionName:l}){const p=await this.configService.getConfig(),m=Rm.createClient({url:p.apiUrl+"/graphql",headers:{Authorization:`Bearer ${p.apiKey}`,"Content-Type":"application/json",Accept:"text/event-stream"}}),v=`
79
+ `,f={input:{id:s,payload:r}},m=await this.client.post("/metadata",{query:l,variables:f},{headers:{"Content-Type":"application/json",Accept:"*/*"}});return m.data.errors?{success:!1,error:m.data.errors[0]?.message||"Failed to execute logic function"}:{success:!0,data:m.data.data.executeOneLogicFunction}}catch(l){return{success:!1,error:l}}}async subscribeToLogs({applicationUniversalIdentifier:s,functionUniversalIdentifier:r,functionName:l}){const f=await this.configService.getConfig(),m=Om.createClient({url:f.apiUrl+"/metadata",headers:{Authorization:`Bearer ${f.apiKey}`,"Content-Type":"application/json",Accept:"text/event-stream"}}),v=`
80
80
  subscription SubscribeToLogs($input: LogicFunctionLogsInput!) {
81
81
  logicFunctionLogs(input: $input) {
82
82
  logs
83
83
  }
84
84
  }
85
- `,E={input:{applicationUniversalIdentifier:s,universalIdentifier:r,name:l}};m.subscribe({query:v,variables:E},{next:({data:b})=>console.log(b?.logicFunctionLogs.logs),error:b=>console.error(b),complete:()=>console.log("Completed")})}async uploadFile({filePath:s,builtHandlerPath:r,fileFolder:l,applicationUniversalIdentifier:p}){try{const m=Y.resolve(s);if(!nl.existsSync(m))return{success:!1,error:`File not found: ${m}`};const v=Y.basename(m),E=nl.readFileSync(m),b=this.getMimeType(v),M=`
85
+ `,E={input:{applicationUniversalIdentifier:s,universalIdentifier:r,name:l}};m.subscribe({query:v,variables:E},{next:({data:b})=>console.log(b?.logicFunctionLogs.logs),error:b=>console.error(b),complete:()=>console.log("Completed")})}async uploadFile({filePath:s,builtHandlerPath:r,fileFolder:l,applicationUniversalIdentifier:f}){try{const m=Y.resolve(s);if(!rl.existsSync(m))return{success:!1,error:`File not found: ${m}`};const v=Y.basename(m),E=rl.readFileSync(m),b=this.getMimeType(v),M=`
86
86
  mutation UploadApplicationFile($file: Upload!, $applicationUniversalIdentifier: String!, $fileFolder: FileFolder!, $filePath: String!) {
87
87
  uploadApplicationFile(file: $file, applicationUniversalIdentifier: $applicationUniversalIdentifier, fileFolder: $fileFolder, filePath: $filePath)
88
88
  { path }
89
89
  }
90
- `,H=P.AO(l),X=JSON.stringify({query:M,variables:{file:null,applicationUniversalIdentifier:p,filePath:r,fileFolder:H}}),N=JSON.stringify({0:["variables.file"]}),V=new FormData;V.append("operations",X),V.append("map",N),V.append("0",new Blob([new Uint8Array(E)],{type:b}),v);const ie=await this.client.post("/metadata",V);return ie.data.errors?{success:!1,error:ie.data.errors[0]?.message||"Failed to upload file"}:{success:!0,data:ie.data.data.uploadApplicationFile,message:`Successfully uploaded ${v}`}}catch(m){return hn.default.isAxiosError(m)&&m.response?{success:!1,error:m.response.data?.errors?.[0]?.message||m.message}:{success:!1,error:m}}}getMimeType(s){const r=Y.extname(s).toLowerCase();return{".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".csv":"text/csv",".json":"application/json",".xml":"application/xml",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".mp3":"audio/mpeg",".mp4":"video/mp4",".avi":"video/x-msvideo",".mov":"video/quicktime",".js":"application/javascript",".ts":"application/typescript",".jsx":"application/javascript",".tsx":"application/typescript",".html":"text/html",".css":"text/css"}[r]||"application/octet-stream"}}class yv{constructor(){this.apiService=new Tt({disableInterceptors:!0})}async generate({appPath:s,authToken:r}){const l=this.resolveGeneratedPath(s),p=`${l}.tmp`,m=await this.apiService.getSchema({authToken:r});if(!m.success)throw new Error(`Failed to introspect schema: ${JSON.stringify(m.error)}`);const{data:v}=m;await k.ensureDir(p),await k.emptyDir(p),await Om.generate({schema:v,output:p,scalarTypes:{DateTime:"string",JSON:"Record<string, unknown>",UUID:"string"}}),await this.injectTwentyClient(p),await k.remove(l),await k.move(p,l)}resolveGeneratedPath(s){return $.join(s,"node_modules","twenty-sdk",Gr)}async injectTwentyClient(s){const r=`
90
+ `,H=k.AO(l),X=JSON.stringify({query:M,variables:{file:null,applicationUniversalIdentifier:f,filePath:r,fileFolder:H}}),U=JSON.stringify({0:["variables.file"]}),V=new FormData;V.append("operations",X),V.append("map",U),V.append("0",new Blob([new Uint8Array(E)],{type:b}),v);const ie=await this.client.post("/metadata",V);return ie.data.errors?{success:!1,error:ie.data.errors[0]?.message||"Failed to upload file"}:{success:!0,data:ie.data.data.uploadApplicationFile,message:`Successfully uploaded ${v}`}}catch(m){return hn.default.isAxiosError(m)&&m.response?{success:!1,error:m.response.data?.errors?.[0]?.message||m.message}:{success:!1,error:m}}}getMimeType(s){const r=Y.extname(s).toLowerCase();return{".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".csv":"text/csv",".json":"application/json",".xml":"application/xml",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".mp3":"audio/mpeg",".mp4":"video/mp4",".avi":"video/x-msvideo",".mov":"video/quicktime",".js":"application/javascript",".ts":"application/typescript",".jsx":"application/javascript",".tsx":"application/typescript",".html":"text/html",".css":"text/css"}[r]||"application/octet-stream"}}const ol={DateTime:"string",JSON:"Record<string, unknown>",UUID:"string"};class wv{constructor(){this.apiService=new Ft({disableInterceptors:!0})}async generate({appPath:s,authToken:r}){const l=this.resolveGeneratedPath(s),f=`${l}.tmp`,[m,v]=await Promise.all([this.apiService.getSchema({authToken:r}),this.apiService.getMetadataSchema({authToken:r})]);if(!m.success)throw new Error(`Failed to introspect core schema: ${JSON.stringify(m.error)}`);if(!v.success)throw new Error(`Failed to introspect metadata schema: ${JSON.stringify(v.error)}`);await C.ensureDir(f),await C.emptyDir(f),await Promise.all([nl.generate({schema:m.data,output:R.join(f,"core"),scalarTypes:ol}),nl.generate({schema:v.data,output:R.join(f,"metadata"),scalarTypes:{...ol,Upload:"File"}})]),await this.injectClientWrapper(R.join(f,"core"),{className:"CoreApiClient",defaultUrl:`\`\${process.env.${sl}}/graphql\``,includeUploadFile:!1}),await this.injectClientWrapper(R.join(f,"metadata"),{className:"MetadataApiClient",defaultUrl:`\`\${process.env.${sl}}/metadata\``,includeUploadFile:!0}),await this.writeBarrelIndex(f),await C.remove(l),await C.move(f,l)}async ensureGeneratedClientStub({appPath:s}){const r=this.resolveGeneratedPath(s);await C.pathExists(R.join(r,"index.ts"))||(await C.ensureDir(R.join(r,"core")),await C.ensureDir(R.join(r,"metadata")),await C.writeFile(R.join(r,"core","index.ts"),`export class CoreApiClient {}
91
+ `),await C.writeFile(R.join(r,"metadata","index.ts"),`export class MetadataApiClient {}
92
+ `),await this.writeBarrelIndex(r))}resolveGeneratedPath(s){return R.join(s,"node_modules","twenty-sdk",Gr)}async writeBarrelIndex(s){await C.writeFile(R.join(s,"index.ts"),`export { CoreApiClient } from './core/index';
93
+ export { MetadataApiClient } from './metadata/index';
94
+ `)}async injectClientWrapper(s,r){const l=this.buildClientWrapperTemplate(r);await C.appendFile(R.join(s,"index.ts"),l)}buildClientWrapperTemplate(s){const{className:r,defaultUrl:l,includeUploadFile:f}=s;return`
91
95
 
92
96
  // ----------------------------------------------------
93
- // Custom Twenty client (auto-injected)
97
+ // ${r} (auto-injected)
94
98
  // ----------------------------------------------------
95
99
 
96
- const defaultOptions: ClientOptions = {
97
- url: \`\${process.env.${il}}/graphql\`,
98
- metadataUrl: \`\${process.env.${il}}/metadata\`,
100
+ const APP_ACCESS_TOKEN_ENV_KEY = '${Km}';
101
+ const API_KEY_ENV_KEY = '${zm}';
102
+
103
+ type ${r}Options = ClientOptions
104
+
105
+ type ProcessEnvironment = Record<string, string | undefined>
106
+
107
+ type GraphqlError = {
108
+ message?: string;
109
+ extensions?: { code?: string };
110
+ }
111
+
112
+ type GraphqlResponsePayload = {
113
+ data?: Record<string, unknown>
114
+ errors?: GraphqlError[];
115
+ }
116
+
117
+ type GraphqlResponse = {
118
+ status: number;
119
+ statusText: string;
120
+ payload: GraphqlResponsePayload | null;
121
+ rawBody: string;
122
+ }
123
+
124
+ const getProcessEnvironment = (): ProcessEnvironment => {
125
+ const processObject = (globalThis as { process?: { env?: ProcessEnvironment } })
126
+ .process;
127
+
128
+ return processObject?.env ?? {};
129
+ }
130
+
131
+ const getTokenFromAuthorizationHeader = (
132
+ authorizationHeader: string | undefined,
133
+ ): string | null => {
134
+ if (typeof authorizationHeader !== 'string') {
135
+ return null;
136
+ }
137
+
138
+ const trimmedAuthorizationHeader = authorizationHeader.trim();
139
+
140
+ if (trimmedAuthorizationHeader.length === 0) {
141
+ return null;
142
+ }
143
+
144
+ if (trimmedAuthorizationHeader === 'Bearer') {
145
+ return null;
146
+ }
147
+
148
+ if (trimmedAuthorizationHeader.startsWith('Bearer ')) {
149
+ return trimmedAuthorizationHeader.slice('Bearer '.length).trim();
150
+ }
151
+
152
+ return trimmedAuthorizationHeader;
153
+ }
154
+
155
+ const getTokenFromHeaders = (headers: HeadersInit | undefined): string | null => {
156
+ if (!headers) {
157
+ return null;
158
+ }
159
+
160
+ if (headers instanceof Headers) {
161
+ return getTokenFromAuthorizationHeader(headers.get('Authorization') ?? undefined);
162
+ }
163
+
164
+ if (Array.isArray(headers)) {
165
+ const matchedAuthorizationHeader = headers.find(
166
+ ([headerName]) => headerName.toLowerCase() === 'authorization',
167
+ );
168
+
169
+ return getTokenFromAuthorizationHeader(matchedAuthorizationHeader?.[1]);
170
+ }
171
+
172
+ const headersRecord = headers as Record<string, string | undefined>;
173
+
174
+ return getTokenFromAuthorizationHeader(
175
+ headersRecord.Authorization ?? headersRecord.authorization,
176
+ );
177
+ }
178
+
179
+ const hasAuthenticationErrorInGraphqlPayload = (
180
+ payload: GraphqlResponsePayload | null,
181
+ ): boolean => {
182
+ if (!payload?.errors) {
183
+ return false;
184
+ }
185
+
186
+ return payload.errors.some((error) => {
187
+ return (
188
+ error.extensions?.code === 'UNAUTHENTICATED' ||
189
+ error.message?.toLowerCase() === 'unauthorized'
190
+ );
191
+ });
192
+ }
193
+
194
+ const defaultOptions: ${r}Options = {
195
+ url: ${l},
99
196
  headers: {
100
197
  'Content-Type': 'application/json',
101
- Authorization: \`Bearer \${process.env.${Gm}}\`,
102
198
  },
103
199
  }
104
200
 
105
- export default class Twenty {
201
+ export class ${r} {
106
202
  private client: Client;
107
203
  private url: string;
108
- private metadataUrl: string;
109
- private authorizationToken: string;
110
-
111
- constructor(options?: ClientOptions) {
112
- const merged: ClientOptions = {
204
+ private requestOptions: RequestInit;
205
+ private headers: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
206
+ private fetchImplementation: typeof globalThis.fetch | null;
207
+ private authorizationToken: string | null;
208
+ private refreshAccessTokenPromise: Promise<string | null> | null = null;
209
+
210
+ constructor(options?: ${r}Options) {
211
+ const merged: ${r}Options = {
113
212
  ...defaultOptions,
114
213
  ...options,
115
- headers: {
116
- ...defaultOptions.headers,
117
- ...(options?.headers ?? {}),
118
- },
119
- };
120
- this.client = createClient(merged);
121
- this.url = merged.url;
122
- this.metadataUrl = merged.metadataUrl;
123
- this.authorizationToken = merged.headers.Authorization;
214
+ }
215
+
216
+ const {
217
+ url,
218
+ headers,
219
+ fetch: customFetchImplementation,
220
+ fetcher: _fetcher,
221
+ batch: _batch,
222
+ ...requestOptions
223
+ } = merged;
224
+
225
+ this.url = url ?? '';
226
+ this.requestOptions = requestOptions;
227
+ this.headers = headers ?? {};
228
+ this.fetchImplementation = customFetchImplementation ?? globalThis.fetch ?? null;
229
+
230
+ const processEnvironment = getProcessEnvironment();
231
+ const tokenFromHeaders = getTokenFromHeaders(
232
+ typeof headers === 'function' ? undefined : headers,
233
+ );
234
+
235
+ // Priority: explicit header > TWENTY_APP_ACCESS_TOKEN > TWENTY_API_KEY (legacy fallback).
236
+ this.authorizationToken =
237
+ tokenFromHeaders ??
238
+ processEnvironment[APP_ACCESS_TOKEN_ENV_KEY] ??
239
+ processEnvironment[API_KEY_ENV_KEY] ??
240
+ null;
241
+
242
+ this.client = createClient({
243
+ ...merged,
244
+ headers: undefined,
245
+ fetcher: async (operation) =>
246
+ this.executeGraphqlRequestWithOptionalRefresh({
247
+ operation,
248
+ }),
249
+ });
124
250
  }
125
251
 
126
252
  query<R extends QueryGenqlSelection>(request: R & { __name?: string }) {
@@ -130,7 +256,7 @@ export default class Twenty {
130
256
  mutation<R extends MutationGenqlSelection>(request: R & { __name?: string }) {
131
257
  return this.client.mutation(request);
132
258
  }
133
-
259
+ ${f?`
134
260
  async uploadFile(
135
261
  fileBuffer: Buffer,
136
262
  filename: string,
@@ -157,25 +283,205 @@ export default class Twenty {
157
283
  form.append('map', JSON.stringify({ '0': ['variables.file'] }));
158
284
  form.append('0', new Blob([fileBuffer], { type: contentType }), filename);
159
285
 
160
- const response = await fetch(this.metadataUrl, {
161
- method: 'POST',
162
- headers: {
163
- Authorization: this.authorizationToken,
286
+ const result = await this.executeGraphqlRequestWithOptionalRefresh({
287
+ operation: form,
288
+ headers: {},
289
+ requestInit: {
290
+ method: 'POST',
164
291
  },
165
- body: form,
166
292
  });
167
293
 
168
- const result = await response.json();
169
-
170
294
  if (result.errors) {
171
295
  throw new GenqlError(result.errors, result.data);
172
296
  }
173
297
 
174
- return result.data.uploadFilesFieldFileByUniversalIdentifier;
298
+ const data = result.data as Record<string, unknown>;
299
+
300
+ return data.uploadFilesFieldFileByUniversalIdentifier as {
301
+ id: string;
302
+ path: string;
303
+ size: number;
304
+ createdAt: string;
305
+ url: string;
306
+ }
307
+ }
308
+ `:""}
309
+ private async executeGraphqlRequestWithOptionalRefresh({
310
+ operation,
311
+ headers,
312
+ requestInit,
313
+ }: {
314
+ operation: GraphqlOperation | GraphqlOperation[] | FormData;
315
+ headers?: HeadersInit;
316
+ requestInit?: RequestInit;
317
+ }) {
318
+ const firstResponse = await this.executeGraphqlRequest({
319
+ operation,
320
+ headers,
321
+ requestInit,
322
+ token: this.authorizationToken,
323
+ });
324
+
325
+ if (this.shouldRefreshToken(firstResponse)) {
326
+ const refreshedAccessToken = await this.requestRefreshedAccessToken();
327
+
328
+ if (refreshedAccessToken) {
329
+ const retryResponse = await this.executeGraphqlRequest({
330
+ operation,
331
+ headers,
332
+ requestInit,
333
+ token: refreshedAccessToken,
334
+ });
335
+
336
+ return this.assertResponseIsSuccessful(retryResponse);
337
+ }
338
+ }
339
+
340
+ return this.assertResponseIsSuccessful(firstResponse);
341
+ }
342
+
343
+ private async executeGraphqlRequest({
344
+ operation,
345
+ headers,
346
+ requestInit,
347
+ token,
348
+ }: {
349
+ operation: GraphqlOperation | GraphqlOperation[] | FormData;
350
+ headers?: HeadersInit;
351
+ requestInit?: RequestInit;
352
+ token: string | null;
353
+ }): Promise<GraphqlResponse> {
354
+ if (!this.fetchImplementation) {
355
+ throw new Error(
356
+ 'Global \`fetch\` function is not available, pass a fetch implementation to the Twenty client',
357
+ );
358
+ }
359
+
360
+ const resolvedHeaders = await this.resolveHeaders();
361
+ const requestHeaders = new Headers(resolvedHeaders);
362
+
363
+ if (headers) {
364
+ new Headers(headers).forEach((value, key) => requestHeaders.set(key, value));
365
+ }
366
+
367
+ if (operation instanceof FormData) {
368
+ requestHeaders.delete('Content-Type');
369
+ } else {
370
+ requestHeaders.set('Content-Type', 'application/json');
371
+ }
372
+
373
+ if (token) {
374
+ requestHeaders.set('Authorization', \`Bearer \${token}\`);
375
+ } else {
376
+ requestHeaders.delete('Authorization');
377
+ }
378
+
379
+ const response = await this.fetchImplementation.call(globalThis, this.url, {
380
+ ...this.requestOptions,
381
+ ...requestInit,
382
+ method: requestInit?.method ?? 'POST',
383
+ headers: requestHeaders,
384
+ body: operation instanceof FormData ? operation : JSON.stringify(operation),
385
+ });
386
+
387
+ const rawBody = await response.text();
388
+ let payload: GraphqlResponsePayload | null = null;
389
+
390
+ if (rawBody.trim().length > 0) {
391
+ try {
392
+ payload = JSON.parse(rawBody) as GraphqlResponsePayload;
393
+ } catch {
394
+ payload = null;
395
+ }
396
+ }
397
+
398
+ return {
399
+ status: response.status,
400
+ statusText: response.statusText,
401
+ payload,
402
+ rawBody,
403
+ }
404
+ }
405
+
406
+ private async resolveHeaders(): Promise<HeadersInit> {
407
+ if (typeof this.headers === 'function') {
408
+ return (await this.headers()) ?? {};
409
+ }
410
+
411
+ return this.headers ?? {};
412
+ }
413
+
414
+ private shouldRefreshToken(response: GraphqlResponse): boolean {
415
+ if (response.status === 401) {
416
+ return true;
417
+ }
418
+
419
+ return hasAuthenticationErrorInGraphqlPayload(response.payload);
420
+ }
421
+
422
+ private assertResponseIsSuccessful(response: GraphqlResponse) {
423
+ if (response.status < 200 || response.status >= 300) {
424
+ throw new Error(\`\${response.statusText}: \${response.rawBody}\`);
425
+ }
426
+
427
+ if (response.payload === null) {
428
+ throw new Error('Invalid JSON response');
429
+ }
430
+
431
+ return response.payload;
432
+ }
433
+
434
+ private async requestRefreshedAccessToken(): Promise<string | null> {
435
+ const refreshAccessTokenFunction = (
436
+ globalThis as {
437
+ frontComponentHostCommunicationApi?: {
438
+ requestAccessTokenRefresh?: () => Promise<string>
439
+ }
440
+ }
441
+ ).frontComponentHostCommunicationApi?.requestAccessTokenRefresh;
442
+
443
+ if (typeof refreshAccessTokenFunction !== 'function') {
444
+ return null;
445
+ }
446
+
447
+ if (!this.refreshAccessTokenPromise) {
448
+ this.refreshAccessTokenPromise = refreshAccessTokenFunction()
449
+ .then((refreshedAccessToken) => {
450
+ if (
451
+ typeof refreshedAccessToken !== 'string' ||
452
+ refreshedAccessToken.length === 0
453
+ ) {
454
+ return null;
455
+ }
456
+
457
+ this.setAuthorizationToken(refreshedAccessToken);
458
+
459
+ return refreshedAccessToken;
460
+ })
461
+ .catch((error) => {
462
+ console.error('Twenty client: token refresh failed', error);
463
+
464
+ return null;
465
+ })
466
+ .finally(() => {
467
+ this.refreshAccessTokenPromise = null;
468
+ });
469
+ }
470
+
471
+ return this.refreshAccessTokenPromise;
472
+ }
473
+
474
+ private setAuthorizationToken(token: string) {
475
+ this.authorizationToken = token;
476
+
477
+ const processEnvironment = getProcessEnvironment();
478
+
479
+ processEnvironment[APP_ACCESS_TOKEN_ENV_KEY] = token;
480
+ processEnvironment[API_KEY_ENV_KEY] = token;
175
481
  }
176
482
  }
177
483
 
178
- `;await k.appendFile($.join(s,"index.ts"),r)}}var Al=(o=>(o.DefineApplication="defineApplication",o.DefineField="defineField",o.DefineLogicFunction="defineLogicFunction",o.DefineObject="defineObject",o.DefineRole="defineRole",o.DefineSkill="defineSkill",o.DefineFrontComponent="defineFrontComponent",o.DefineView="defineView",o.DefineNavigationMenuItem="defineNavigationMenuItem",o.DefinePageLayout="definePageLayout",o))(Al||{}),Ye=(o=>(o.Application="application",o.Fields="fields",o.LogicFunctions="logicFunctions",o.Objects="objects",o.Roles="roles",o.Skills="skills",o.FrontComponents="frontComponents",o.PublicAssets="publicAssets",o.Views="views",o.NavigationMenuItems="navigationMenuItems",o.PageLayouts="pageLayouts",o))(Ye||{});const _v={defineApplication:"application",defineField:"fields",defineLogicFunction:"logicFunctions",defineObject:"objects",defineRole:"roles",defineSkill:"skills",defineFrontComponent:"frontComponents",defineView:"views",defineNavigationMenuItem:"navigationMenuItems",definePageLayout:"pageLayouts"},wv=o=>{if(!gn.isCallExpression(o))return;const s=o.expression;if(gn.isIdentifier(s)&&Object.values(Al).includes(s.text))return s.text},xv=o=>{const s=gn.createSourceFile("temp.ts",o,gn.ScriptTarget.Latest,!0),r=[];gn.forEachChild(s,l=>{r.push(l)});for(const l of r)if(gn.isExportAssignment(l)){if(l.isExportEquals||!l.expression)return;const p=wv(l.expression);if(p)return p}},Sv=["twenty-sdk/ui"],Av={name:"manifest-mock",setup:o=>{const s=new RegExp(`^(${Sv.map(r=>r.replace("/","\\/")).join("|")})$`);o.onResolve({filter:s},({path:r})=>({path:r,namespace:"manifest-mock"})),o.onLoad({filter:/.*/,namespace:"manifest-mock"},()=>({contents:"module.exports = new Proxy({}, { get: () => () => {} });",loader:"js"}))}},pt=async({filePath:o,appPath:s})=>{const r=await Iv({filePath:o,appPath:s});return Fv(r,o)},Iv=async({filePath:o,appPath:s})=>{const r=Y.default.join(s,"tsconfig.json"),l=await k.pathExists(r),p=Nm.createRequire(Y.default.join(s,"package.json"));let m,v;try{m=Y.default.dirname(p.resolve("react/package.json")),v=Y.default.dirname(p.resolve("react-dom/package.json"))}catch{}const b=(await ml.build({entryPoints:[o],bundle:!0,write:!1,format:"cjs",platform:"node",target:"node18",jsx:"automatic",tsconfig:l?r:void 0,alias:{...m&&{react:m},...v&&{"react-dom":v}},plugins:[Av],logLevel:"silent"})).outputFiles[0].text,M=await k.mkdtemp(Y.default.join(ms.default.tmpdir(),"twenty-manifest-")),H=Y.default.join(M,"module.cjs");try{return await k.writeFile(H,b),require(H)}finally{await k.remove(M)}},Fv=(o,s)=>{if(P.o(o.default)&&P.AN(o.default))return o.default;throw new Error(`Config file ${s} must export a config object default export`)},Ev={type:"object",properties:{}},Tv=async o=>{const{getFunctionInputSchema:s}=await Promise.resolve().then(()=>require("./get-function-input-schema-BZ7_XyUh-GxSybvDe.js")),r=s(o)[0];return r?.type==="object"&&P.o(r.properties)?{type:"object",properties:r.properties}:Ev},bv="142046f0-4d80-48b5-ad56-26ad410e895c",at=({objectConfig:o,fieldName:s})=>{const r=`${o.universalIdentifier}-${s}`;return We.v5(r,bv)},Cv=o=>{const s={name:"id",label:"Id",description:"Id",icon:"Icon123",isNullable:!1,defaultValue:"uuid",type:P.R.UUID,universalIdentifier:at({objectConfig:o,fieldName:"id"})},r={name:"name",label:"Name",description:"Name",icon:"IconAbc",isNullable:!0,defaultValue:null,type:P.R.TEXT,universalIdentifier:at({objectConfig:o,fieldName:"name"})},l={name:"createdAt",label:"Creation date",description:"Creation date",icon:"IconCalendar",isNullable:!1,defaultValue:"now",type:P.R.DATE_TIME,universalIdentifier:at({objectConfig:o,fieldName:"createdAt"})},p={name:"updatedAt",label:"Last update",description:"Last time the record was changed",icon:"IconCalendarClock",isNullable:!1,defaultValue:"now",type:P.R.DATE_TIME,universalIdentifier:at({objectConfig:o,fieldName:"updatedAt"})},m={name:"deletedAt",label:"Deleted at",description:"Deletion date",icon:"IconCalendarClock",isNullable:!0,defaultValue:null,type:P.R.DATE_TIME,universalIdentifier:at({objectConfig:o,fieldName:"deletedAt"})},v={name:"createdBy",label:"Created by",description:"The creator of the record",icon:"IconCreativeCommonsSa",isNullable:!1,defaultValue:{name:"''",source:"'MANUAL'"},type:P.R.ACTOR,universalIdentifier:at({objectConfig:o,fieldName:"createdBy"})},E={name:"updatedBy",label:"Updated by",description:"The workspace member who last updated the record",icon:"IconUserCircle",isNullable:!1,defaultValue:{name:"''",source:"'MANUAL'"},type:P.R.ACTOR,universalIdentifier:at({objectConfig:o,fieldName:"updatedBy"})},b={name:"position",label:"Position",description:"Position",icon:"IconHierarchy2",isNullable:!1,defaultValue:0,type:P.R.POSITION,universalIdentifier:at({objectConfig:o,fieldName:"position"})},M={name:"searchVector",label:"Search vector",icon:"IconSearch",description:"Search vector",isNullable:!0,defaultValue:null,type:P.R.TS_VECTOR,universalIdentifier:at({objectConfig:o,fieldName:"searchVector"})};return[s,r,l,p,m,v,E,b,M]},qn={targetFieldName:o=>`target${P.cs(o.nameSingular)}`,targetLabel:o=>P.cs(o.nameSingular),icon:"IconBuildingSkyscraper"},Pv=[{...qn,fieldName:"timelineActivities",label:"Timeline Activities",targetIcon:"IconTimelineEvent",targetFieldType:P.R.MORPH_RELATION,standardObjectKey:"timelineActivity",morphId:P.y.timelineActivity.morphIds.targetMorphId.morphId},{...qn,fieldName:"favorites",label:"Favorites",icon:"IconBuildingSkyscraper",targetIcon:"IconHeart",targetFieldType:P.R.RELATION,standardObjectKey:"favorite"},{...qn,fieldName:"attachments",label:"Attachments",icon:"IconBuildingSkyscraper",targetIcon:"IconFileImport",targetFieldType:P.R.MORPH_RELATION,standardObjectKey:"attachment",morphId:P.y.attachment.morphIds.targetMorphId.morphId},{...qn,fieldName:"noteTargets",label:"Note Targets",icon:"IconBuildingSkyscraper",targetIcon:"IconCheckbox",targetFieldType:P.R.MORPH_RELATION,standardObjectKey:"noteTarget",morphId:P.y.noteTarget.morphIds.targetMorphId.morphId},{...qn,fieldName:"taskTargets",label:"Task Targets",icon:"IconBuildingSkyscraper",targetIcon:"IconCheckbox",targetFieldType:P.R.MORPH_RELATION,standardObjectKey:"taskTarget",morphId:P.y.taskTarget.morphIds.targetMorphId.morphId}],Rv=({config:o,forwardFieldUniversalIdentifier:s,objectConfig:r,universalIdentifier:l})=>{const p=P.y[o.standardObjectKey],m={name:o.targetFieldName(r),label:o.targetLabel(r),description:`${o.targetLabel(r)} ${r.labelSingular}`,icon:o.targetIcon,isNullable:!0,universalSettings:{relationType:P.V.MANY_TO_ONE,onDelete:P.W.SET_NULL,joinColumnName:`target${P.cs(r.nameSingular)}Id`},universalIdentifier:l,objectUniversalIdentifier:p.universalIdentifier,relationTargetFieldMetadataUniversalIdentifier:s,relationTargetObjectMetadataUniversalIdentifier:r.universalIdentifier};return o.targetFieldType===P.R.MORPH_RELATION?{...m,type:o.targetFieldType,morphId:o.morphId}:{...m,type:o.targetFieldType}},Ov=o=>{const s=[],r=[];for(const l of Pv){const p=P.y[l.standardObjectKey],m=at({objectConfig:o,fieldName:l.fieldName}),v=at({objectConfig:o,fieldName:`${l.fieldName}Inverse`}),E={name:l.fieldName,label:l.label,description:`${o.labelPlural} tied to the ${l.targetLabel(o)}`,icon:l.icon,isNullable:!1,type:P.R.RELATION,universalSettings:{relationType:P.V.ONE_TO_MANY},universalIdentifier:m,relationTargetFieldMetadataUniversalIdentifier:v,relationTargetObjectMetadataUniversalIdentifier:p.universalIdentifier},b=Rv({config:l,objectConfig:o,universalIdentifier:v,forwardFieldUniversalIdentifier:m});s.push(E),r.push(b)}return{objectFields:s,fields:r}},Lv=o=>{const s=Cv(o),{objectFields:r,fields:l}=Ov(o),p=(o.fields??[]).map(v=>v.name),m=[...o.fields];for(const v of s)p.includes(v.name)||m.push(v);for(const v of r)p.includes(v.name)||m.push(v);return{objectFields:m,fields:l}},kv=async o=>await pl.glob(["**/*.ts","**/*.tsx"],{cwd:o,absolute:!0,ignore:["**/node_modules/**","**/*.d.ts","**/dist/**","**/.twenty/**"],onlyFiles:!0}),Nv=async o=>await pl.glob([`${vs}/**/*`],{cwd:o,onlyFiles:!0}),Il=async o=>{const s=await kv(o),r=[];let l;const p=[],m=[],v=[],E=[],b=[],M=[],H=[],X=[],N=[],V=[],ie=[],lt=[],Fe=[],dt=[],vn=[],$e=[],bt=[],Me=[],Ct=[],Be=[],Pt=[];for(const le of s){const Jn=await fl.readFile(le,"utf-8"),Pe=$.relative(o,le),zn=xv(Jn);if(!zn)continue;switch(_v[zn]){case Ye.Application:{const B=await pt({appPath:o,filePath:le});l={...B.config,yarnLockChecksum:null,packageJsonChecksum:null,apiClientChecksum:null},r.push(...B.errors),ie.push(Pe);break}case Ye.Objects:{const B=await pt({appPath:o,filePath:le}),{objectFields:de,fields:ht}=Lv(B.config),Re=B.config.labelIdentifierFieldMetadataUniversalIdentifier??de.find(_n=>_n.name==="name")?.universalIdentifier;if(!Re){r.push(`No label identifier field found for object ${B.config.nameSingular}. Please add a field with name "name" to your object.`);break}const ve={...B.config,fields:de,labelIdentifierFieldMetadataUniversalIdentifier:Re};p.push(ve),m.push(...ht),r.push(...B.errors),lt.push(Pe);break}case Ye.Fields:{const B=await pt({appPath:o,filePath:le});m.push(B.config),r.push(...B.errors),Fe.push(Pe);break}case Ye.Roles:{const B=await pt({appPath:o,filePath:le});v.push(B.config),r.push(...B.errors),dt.push(Pe);break}case Ye.Skills:{const B=await pt({appPath:o,filePath:le});E.push(B.config),r.push(...B.errors),vn.push(Pe);break}case Ye.LogicFunctions:{const B=await pt({appPath:o,filePath:le});r.push(...B.errors);const{handler:de,...ht}=B.config,Re=$.relative(o,le),ve=ht.toolInputSchema??await Tv(Jn),_n={...ht,toolInputSchema:ve,handlerName:"default.config.handler",sourceHandlerPath:Re,builtHandlerPath:Re.replace(/\.tsx?$/,".mjs"),builtHandlerChecksum:"[default-checksum]"};b.push(_n),$e.push(Pe);break}case Ye.FrontComponents:{const B=await pt({appPath:o,filePath:le});r.push(...B.errors);const{component:de,...ht}=B.config,Re=$.relative(o,le),ve={...ht,componentName:de.name,sourceComponentPath:Re,builtComponentPath:Re.replace(/\.tsx?$/,".mjs"),builtComponentChecksum:"",isHeadless:ht.isHeadless??!1};M.push(ve),bt.push(Pe);break}case Ye.Views:{const B=await pt({appPath:o,filePath:le}),de={...B.config};X.push(de),r.push(...B.errors),Ct.push(Pe);break}case Ye.NavigationMenuItems:{const B=await pt({appPath:o,filePath:le});N.push(B.config),r.push(...B.errors),Be.push(Pe);break}case Ye.PageLayouts:{const B=await pt({appPath:o,filePath:le}),de={...B.config};V.push(de),r.push(...B.errors),Pt.push(Pe);break}case Ye.PublicAssets:break;default:P.dt()}}const yn=await Nv(o);for(const le of yn)H.push({filePath:le,fileName:$.basename(le),fileType:$.extname(le).replace(/^\./,""),checksum:null}),Me.push($.relative(o,le));return l||r.push("Cannot build application, please export default defineApplication() to define an application"),{manifest:l?{application:l,objects:p,fields:m,roles:v,skills:E,logicFunctions:b,frontComponents:M,publicAssets:H,views:X,navigationMenuItems:N,pageLayouts:V}:null,filePaths:{application:ie,objects:lt,fields:Fe,roles:dt,skills:vn,logicFunctions:$e,frontComponents:bt,publicAssets:Me,views:Ct,navigationMenuItems:Be,pageLayouts:Pt},errors:r}},Uv=o=>{const s=new Set,r=new Set;for(const l of o)s.has(l)?r.add(l):s.add(l);return Array.from(r)},Fl=o=>{const s=[];if(!o)return[];for(const[r,l]of Object.entries(o))r==="universalIdentifier"&&typeof l=="string"&&s.push(l),typeof l=="object"&&s.push(...Fl(l));return s},Dv=o=>{const s=[],r=[],l=Uv(Fl(o));return l.length>0&&s.push(`Duplicate universal identifiers: ${l.join(", ")}`),P.na(o.objects)||r.push("No object defined"),P.na(o.logicFunctions)||r.push("No logic function defined"),P.na(o.frontComponents)||r.push("No front component defined"),{errors:s,warnings:r,isValid:s.length===0}};class Wv{constructor({state:s,notify:r}){this.state=s,this.notify=r}async execute(s){const r=this.state.steps.buildManifest;r.status="in_progress",this.state.updatePipeline({status:"building"});const l=[{message:"Building manifest",status:"info"}],p=await Il(s.appPath);if(p.errors.length>0||!p.manifest){for(const v of p.errors)l.push({message:v,status:"error"});return r.output={result:null},r.status="error",this.state.updatePipeline({status:"error"}),this.state.applyStepEvents(l),null}const m=Dv(p.manifest);if(!m.isValid){for(const v of m.errors)l.push({message:v,status:"error"});return r.output={result:null},r.status="error",this.state.updatePipeline({status:"error"}),this.state.applyStepEvents(l),null}if(m.warnings.length>0)for(const v of m.warnings)l.push({message:`⚠ ${v}`,status:"warning"});return l.push({message:"Successfully built manifest",status:"success"}),r.output={result:p},r.status="done",this.state.updatePipeline({appName:p.manifest.application.displayName}),this.state.updateEntitiesFromManifest(p.filePaths),this.state.applyStepEvents(l),p}}class $v{constructor({apiService:s,state:r,notify:l}){this.apiService=s,this.state=r,this.notify=l}async execute(){const s=this.state.steps.checkServer,r=await this.apiService.validateAuth();return r.serverUp?r.authValid?(s.output={isReady:!0,errorLogged:!1},s.status="done",this.notify(),!0):(s.output.errorLogged||(s.output={isReady:!1,errorLogged:!0},s.status="error",this.state.applyStepEvents([{message:"Authentication failed",status:"error"}]),this.state.updatePipeline({status:"error"})),!1):(s.output.errorLogged||(s.output={isReady:!1,errorLogged:!0},s.status="error",this.state.applyStepEvents([{message:"Cannot reach server",status:"error"}]),this.state.updatePipeline({status:"error"})),!1)}}class Mv{constructor({apiService:s,configService:r,state:l,notify:p}){this.apiService=s,this.configService=r,this.state=l,this.notify=p}async execute(s){if(!s.applicationId)return;const r=this.state.steps.ensureValidTokens;r.status="in_progress",this.notify();const l=await this.configService.getConfig();if(l.applicationAccessToken&&!this.isTokenExpired(l.applicationAccessToken)){r.status="done",this.notify();return}if(l.applicationRefreshToken&&!this.isTokenExpired(l.applicationRefreshToken)){const p=await this.apiService.renewApplicationToken(l.applicationRefreshToken);if(p.success){await this.configService.setConfig({applicationAccessToken:p.data.applicationAccessToken.token,applicationRefreshToken:p.data.applicationRefreshToken.token}),this.state.applyStepEvents([{message:"Renewing application tokens",status:"info"},{message:"Application tokens renewed",status:"success"}]),r.status="done",this.notify();return}this.state.applyStepEvents([{message:"Renewing application tokens",status:"info"},{message:`Failed to renew application tokens: ${JSON.stringify(p.error,null,2)}`,status:"error"}]),await this.exchangeTokens({applicationId:s.applicationId});return}await this.exchangeTokens({applicationId:s.applicationId})}async exchangeTokens(s){const r=await this.apiService.generateApplicationToken(s.applicationId);if(!r.success){this.state.applyStepEvents([{message:"Generating application tokens",status:"info"},{message:`Failed to generate application tokens: ${JSON.stringify(r.error,null,2)}`,status:"error"}]),this.state.steps.ensureValidTokens.status="error",this.notify();return}await this.configService.setConfig({applicationAccessToken:r.data.applicationAccessToken.token,applicationRefreshToken:r.data.applicationRefreshToken.token}),this.state.applyStepEvents([{message:"Generating application tokens",status:"info"},{message:"Application tokens stored in config",status:"success"}]),this.state.steps.ensureValidTokens.status="done",this.notify()}isTokenExpired(s){try{const r=JSON.parse(Buffer.from(s.split(".")[1],"base64").toString());return Date.now()>=r.exp*1e3-6e4}catch{return!0}}}class Bv{constructor({clientService:s,configService:r,state:l,notify:p}){this.clientService=s,this.configService=r,this.state=l,this.notify=p}async execute(s){const r=this.state.steps.generateApiClient;r.status="in_progress",this.notify();try{const l=await this.configService.getConfig();await this.clientService.generate({appPath:s.appPath,authToken:l.applicationAccessToken}),r.status="done"}catch(l){this.state.applyStepEvents([{message:`Failed to generate API client: ${l instanceof Error?l.message:String(l)}`,status:"error"}]),r.status="error"}this.notify()}}class jv{constructor({apiService:s,state:r,notify:l}){this.apiService=s,this.state=r,this.notify=l}async execute(s){const r=this.state.steps.resolveApplication;r.status="in_progress",this.notify();const l=s.manifest.application.universalIdentifier,p=await this.apiService.findOneApplication(l);if(!p.success)return this.state.applyStepEvents([{message:`Failed to find application ${l}`,status:"error"}]),r.status="error",this.state.updatePipeline({status:"error"}),r.output;if(p.data)return r.output={applicationId:p.data.id,universalIdentifier:p.data.universalIdentifier},r.status="done",this.notify(),r.output;const m=await this.apiService.createApplication(s.manifest);return m.success?(r.output={applicationId:m.data.id,universalIdentifier:m.data.universalIdentifier},this.state.applyStepEvents([{message:"Creating application",status:"info"},{message:"Application created",status:"success"}]),r.status="done",this.notify(),r.output):(this.state.applyStepEvents([{message:"Creating application",status:"info"},{message:`Application creation failed with error ${JSON.stringify(m.error,null,2)}`,status:"error"}]),r.status="error",this.state.updatePipeline({status:"error"}),r.output)}}const qv=async(o,s,r)=>{const l=new Set(r),p=s.filter(m=>!l.has(m));for(const m of p){const v=m.replace(/\.tsx?$/,".mjs"),E=Y.default.join(o,v),b=`${E}.map`;await k.remove(E),await k.remove(b)}},Hv=async({result:o,appPath:s,fileFolder:r,lastChecksums:l,onFileBuilt:p})=>{const m=Object.keys(o.metafile?.outputs??{}).filter(v=>v.endsWith(".mjs"));for(const v of m){const E=Y.default.resolve(v),b=Y.default.relative(s,E),M=o.metafile?.outputs?.[v]?.entryPoint||"",H=Y.default.relative(s,M),X=await k.readFile(E),N=Hr.default.createHash("md5").update(X).digest("hex");l.get(b)!==N&&(l.set(b,N),p&&await p({fileFolder:r,builtPath:b,sourcePath:H,checksum:N}))}},Gv=[],Jv=`
484
+ `}}var Tl=(o=>(o.DefineApplication="defineApplication",o.DefineField="defineField",o.DefineLogicFunction="defineLogicFunction",o.DefineObject="defineObject",o.DefineRole="defineRole",o.DefineSkill="defineSkill",o.DefineFrontComponent="defineFrontComponent",o.DefineView="defineView",o.DefineNavigationMenuItem="defineNavigationMenuItem",o.DefinePageLayout="definePageLayout",o))(Tl||{}),Ye=(o=>(o.Application="application",o.Fields="fields",o.LogicFunctions="logicFunctions",o.Objects="objects",o.Roles="roles",o.Skills="skills",o.FrontComponents="frontComponents",o.PublicAssets="publicAssets",o.Views="views",o.NavigationMenuItems="navigationMenuItems",o.PageLayouts="pageLayouts",o))(Ye||{});const xv={defineApplication:"application",defineField:"fields",defineLogicFunction:"logicFunctions",defineObject:"objects",defineRole:"roles",defineSkill:"skills",defineFrontComponent:"frontComponents",defineView:"views",defineNavigationMenuItem:"navigationMenuItems",definePageLayout:"pageLayouts"},Av=o=>{if(!gn.isCallExpression(o))return;const s=o.expression;if(gn.isIdentifier(s)&&Object.values(Tl).includes(s.text))return s.text},Sv=o=>{const s=gn.createSourceFile("temp.ts",o,gn.ScriptTarget.Latest,!0),r=[];gn.forEachChild(s,l=>{r.push(l)});for(const l of r)if(gn.isExportAssignment(l)){if(l.isExportEquals||!l.expression)return;const f=Av(l.expression);if(f)return f}},Iv=["twenty-sdk/ui"],Tv={name:"manifest-mock",setup:o=>{const s=new RegExp(`^(${Iv.map(r=>r.replace("/","\\/")).join("|")})$`);o.onResolve({filter:s},({path:r})=>({path:r,namespace:"manifest-mock"})),o.onLoad({filter:/.*/,namespace:"manifest-mock"},()=>({contents:"module.exports = new Proxy({}, { get: () => () => {} });",loader:"js"}))}},pt=async({filePath:o,appPath:s})=>{const r=await Ev({filePath:o,appPath:s});return Fv(r,o)},Ev=async({filePath:o,appPath:s})=>{const r=Y.default.join(s,"tsconfig.json"),l=await C.pathExists(r),f=Um.createRequire(Y.default.join(s,"package.json"));let m,v;try{m=Y.default.dirname(f.resolve("react/package.json")),v=Y.default.dirname(f.resolve("react-dom/package.json"))}catch{}const b=(await yl.build({entryPoints:[o],bundle:!0,write:!1,format:"cjs",platform:"node",target:"node18",jsx:"automatic",tsconfig:l?r:void 0,alias:{...m&&{react:m},...v&&{"react-dom":v}},plugins:[Tv],logLevel:"silent"})).outputFiles[0].text,M=await C.mkdtemp(Y.default.join(ms.default.tmpdir(),"twenty-manifest-")),H=Y.default.join(M,"module.cjs");try{return await C.writeFile(H,b),require(H)}finally{await C.remove(M)}},Fv=(o,s)=>{if(k.o(o.default)&&k.AN(o.default))return o.default;throw new Error(`Config file ${s} must export a config object default export`)},bv={type:"object",properties:{}},Cv=async o=>{const{getFunctionInputSchema:s}=await Promise.resolve().then(()=>require("./get-function-input-schema-BZ7_XyUh-CzwPUwwE.js")),r=s(o)[0];return r?.type==="object"&&k.o(r.properties)?{type:"object",properties:r.properties}:bv},Pv="142046f0-4d80-48b5-ad56-26ad410e895c",at=({objectConfig:o,fieldName:s})=>{const r=`${o.universalIdentifier}-${s}`;return $e.v5(r,Pv)},Rv=o=>{const s={name:"id",label:"Id",description:"Id",icon:"Icon123",isNullable:!1,defaultValue:"uuid",type:k.R.UUID,universalIdentifier:at({objectConfig:o,fieldName:"id"})},r={name:"name",label:"Name",description:"Name",icon:"IconAbc",isNullable:!0,defaultValue:null,type:k.R.TEXT,universalIdentifier:at({objectConfig:o,fieldName:"name"})},l={name:"createdAt",label:"Creation date",description:"Creation date",icon:"IconCalendar",isNullable:!1,defaultValue:"now",type:k.R.DATE_TIME,universalIdentifier:at({objectConfig:o,fieldName:"createdAt"})},f={name:"updatedAt",label:"Last update",description:"Last time the record was changed",icon:"IconCalendarClock",isNullable:!1,defaultValue:"now",type:k.R.DATE_TIME,universalIdentifier:at({objectConfig:o,fieldName:"updatedAt"})},m={name:"deletedAt",label:"Deleted at",description:"Deletion date",icon:"IconCalendarClock",isNullable:!0,defaultValue:null,type:k.R.DATE_TIME,universalIdentifier:at({objectConfig:o,fieldName:"deletedAt"})},v={name:"createdBy",label:"Created by",description:"The creator of the record",icon:"IconCreativeCommonsSa",isNullable:!1,defaultValue:{name:"''",source:"'MANUAL'"},type:k.R.ACTOR,universalIdentifier:at({objectConfig:o,fieldName:"createdBy"})},E={name:"updatedBy",label:"Updated by",description:"The workspace member who last updated the record",icon:"IconUserCircle",isNullable:!1,defaultValue:{name:"''",source:"'MANUAL'"},type:k.R.ACTOR,universalIdentifier:at({objectConfig:o,fieldName:"updatedBy"})},b={name:"position",label:"Position",description:"Position",icon:"IconHierarchy2",isNullable:!1,defaultValue:0,type:k.R.POSITION,universalIdentifier:at({objectConfig:o,fieldName:"position"})},M={name:"searchVector",label:"Search vector",icon:"IconSearch",description:"Search vector",isNullable:!0,defaultValue:null,type:k.R.TS_VECTOR,universalIdentifier:at({objectConfig:o,fieldName:"searchVector"})};return[s,r,l,f,m,v,E,b,M]},qn={targetFieldName:o=>`target${k.cs(o.nameSingular)}`,targetLabel:o=>k.cs(o.nameSingular),icon:"IconBuildingSkyscraper"},kv=[{...qn,fieldName:"timelineActivities",label:"Timeline Activities",targetIcon:"IconTimelineEvent",targetFieldType:k.R.MORPH_RELATION,standardObjectKey:"timelineActivity",morphId:k.y.timelineActivity.morphIds.targetMorphId.morphId},{...qn,fieldName:"favorites",label:"Favorites",icon:"IconBuildingSkyscraper",targetIcon:"IconHeart",targetFieldType:k.R.RELATION,standardObjectKey:"favorite"},{...qn,fieldName:"attachments",label:"Attachments",icon:"IconBuildingSkyscraper",targetIcon:"IconFileImport",targetFieldType:k.R.MORPH_RELATION,standardObjectKey:"attachment",morphId:k.y.attachment.morphIds.targetMorphId.morphId},{...qn,fieldName:"noteTargets",label:"Note Targets",icon:"IconBuildingSkyscraper",targetIcon:"IconCheckbox",targetFieldType:k.R.MORPH_RELATION,standardObjectKey:"noteTarget",morphId:k.y.noteTarget.morphIds.targetMorphId.morphId},{...qn,fieldName:"taskTargets",label:"Task Targets",icon:"IconBuildingSkyscraper",targetIcon:"IconCheckbox",targetFieldType:k.R.MORPH_RELATION,standardObjectKey:"taskTarget",morphId:k.y.taskTarget.morphIds.targetMorphId.morphId}],Ov=({config:o,forwardFieldUniversalIdentifier:s,objectConfig:r,universalIdentifier:l})=>{const f=k.y[o.standardObjectKey],m={name:o.targetFieldName(r),label:o.targetLabel(r),description:`${o.targetLabel(r)} ${r.labelSingular}`,icon:o.targetIcon,isNullable:!0,universalSettings:{relationType:k.V.MANY_TO_ONE,onDelete:k.W.SET_NULL,joinColumnName:`target${k.cs(r.nameSingular)}Id`},universalIdentifier:l,objectUniversalIdentifier:f.universalIdentifier,relationTargetFieldMetadataUniversalIdentifier:s,relationTargetObjectMetadataUniversalIdentifier:r.universalIdentifier};return o.targetFieldType===k.R.MORPH_RELATION?{...m,type:o.targetFieldType,morphId:o.morphId}:{...m,type:o.targetFieldType}},Lv=o=>{const s=[],r=[];for(const l of kv){const f=k.y[l.standardObjectKey],m=at({objectConfig:o,fieldName:l.fieldName}),v=at({objectConfig:o,fieldName:`${l.fieldName}Inverse`}),E={name:l.fieldName,label:l.label,description:`${o.labelPlural} tied to the ${l.targetLabel(o)}`,icon:l.icon,isNullable:!1,type:k.R.RELATION,universalSettings:{relationType:k.V.ONE_TO_MANY},universalIdentifier:m,relationTargetFieldMetadataUniversalIdentifier:v,relationTargetObjectMetadataUniversalIdentifier:f.universalIdentifier},b=Ov({config:l,objectConfig:o,universalIdentifier:v,forwardFieldUniversalIdentifier:m});s.push(E),r.push(b)}return{objectFields:s,fields:r}},Nv=o=>{const s=Rv(o),{objectFields:r,fields:l}=Lv(o),f=(o.fields??[]).map(v=>v.name),m=[...o.fields];for(const v of s)f.includes(v.name)||m.push(v);for(const v of r)f.includes(v.name)||m.push(v);return{objectFields:m,fields:l}},Uv=async o=>await hl.glob(["**/*.ts","**/*.tsx"],{cwd:o,absolute:!0,ignore:["**/node_modules/**","**/*.d.ts","**/dist/**","**/.twenty/**"],onlyFiles:!0}),Dv=async o=>await hl.glob([`${vs}/**/*`],{cwd:o,onlyFiles:!0}),El=async o=>{const s=await Uv(o),r=[];let l;const f=[],m=[],v=[],E=[],b=[],M=[],H=[],X=[],U=[],V=[],ie=[],lt=[],Te=[],dt=[],vn=[],We=[],bt=[],Me=[],Ct=[],Be=[],Pt=[];for(const le of s){const zn=await dl.readFile(le,"utf-8"),Pe=R.relative(o,le),Kn=Sv(zn);if(!Kn)continue;switch(xv[Kn]){case Ye.Application:{const B=await pt({appPath:o,filePath:le});l={...B.config,yarnLockChecksum:null,packageJsonChecksum:null,apiClientChecksum:null},r.push(...B.errors),ie.push(Pe);break}case Ye.Objects:{const B=await pt({appPath:o,filePath:le}),{objectFields:de,fields:ht}=Nv(B.config),Re=B.config.labelIdentifierFieldMetadataUniversalIdentifier??de.find(_n=>_n.name==="name")?.universalIdentifier;if(!Re){r.push(`No label identifier field found for object ${B.config.nameSingular}. Please add a field with name "name" to your object.`);break}const ve={...B.config,fields:de,labelIdentifierFieldMetadataUniversalIdentifier:Re};f.push(ve),m.push(...ht),r.push(...B.errors),lt.push(Pe);break}case Ye.Fields:{const B=await pt({appPath:o,filePath:le});m.push(B.config),r.push(...B.errors),Te.push(Pe);break}case Ye.Roles:{const B=await pt({appPath:o,filePath:le});v.push(B.config),r.push(...B.errors),dt.push(Pe);break}case Ye.Skills:{const B=await pt({appPath:o,filePath:le});E.push(B.config),r.push(...B.errors),vn.push(Pe);break}case Ye.LogicFunctions:{const B=await pt({appPath:o,filePath:le});r.push(...B.errors);const{handler:de,...ht}=B.config,Re=R.relative(o,le),ve=ht.toolInputSchema??await Cv(zn),_n={...ht,toolInputSchema:ve,handlerName:"default.config.handler",sourceHandlerPath:Re,builtHandlerPath:Re.replace(/\.tsx?$/,".mjs"),builtHandlerChecksum:"[default-checksum]"};b.push(_n),We.push(Pe);break}case Ye.FrontComponents:{const B=await pt({appPath:o,filePath:le});r.push(...B.errors);const{component:de,...ht}=B.config,Re=R.relative(o,le),ve={...ht,componentName:de.name,sourceComponentPath:Re,builtComponentPath:Re.replace(/\.tsx?$/,".mjs"),builtComponentChecksum:"",isHeadless:ht.isHeadless??!1};M.push(ve),bt.push(Pe);break}case Ye.Views:{const B=await pt({appPath:o,filePath:le}),de={...B.config};X.push(de),r.push(...B.errors),Ct.push(Pe);break}case Ye.NavigationMenuItems:{const B=await pt({appPath:o,filePath:le});U.push(B.config),r.push(...B.errors),Be.push(Pe);break}case Ye.PageLayouts:{const B=await pt({appPath:o,filePath:le}),de={...B.config};V.push(de),r.push(...B.errors),Pt.push(Pe);break}case Ye.PublicAssets:break;default:k.dt()}}const yn=await Dv(o);for(const le of yn)H.push({filePath:le,fileName:R.basename(le),fileType:R.extname(le).replace(/^\./,""),checksum:null}),Me.push(R.relative(o,le));return l||r.push("Cannot build application, please export default defineApplication() to define an application"),{manifest:l?{application:l,objects:f,fields:m,roles:v,skills:E,logicFunctions:b,frontComponents:M,publicAssets:H,views:X,navigationMenuItems:U,pageLayouts:V}:null,filePaths:{application:ie,objects:lt,fields:Te,roles:dt,skills:vn,logicFunctions:We,frontComponents:bt,publicAssets:Me,views:Ct,navigationMenuItems:Be,pageLayouts:Pt},errors:r}},$v=o=>{const s=new Set,r=new Set;for(const l of o)s.has(l)?r.add(l):s.add(l);return Array.from(r)},Fl=o=>{const s=[];if(!o)return[];for(const[r,l]of Object.entries(o))r==="universalIdentifier"&&typeof l=="string"&&s.push(l),typeof l=="object"&&s.push(...Fl(l));return s},Wv=o=>{const s=[],r=[],l=$v(Fl(o));return l.length>0&&s.push(`Duplicate universal identifiers: ${l.join(", ")}`),k.na(o.objects)||r.push("No object defined"),k.na(o.logicFunctions)||r.push("No logic function defined"),k.na(o.frontComponents)||r.push("No front component defined"),{errors:s,warnings:r,isValid:s.length===0}};class Mv{constructor({state:s,notify:r}){this.state=s,this.notify=r}async execute(s){const r=this.state.steps.buildManifest;r.status="in_progress",this.state.updatePipeline({status:"building"});const l=[{message:"Building manifest",status:"info"}],f=await El(s.appPath);if(f.errors.length>0||!f.manifest){for(const v of f.errors)l.push({message:v,status:"error"});return r.output={result:null},r.status="error",this.state.updatePipeline({status:"error"}),this.state.applyStepEvents(l),null}const m=Wv(f.manifest);if(!m.isValid){for(const v of m.errors)l.push({message:v,status:"error"});return r.output={result:null},r.status="error",this.state.updatePipeline({status:"error"}),this.state.applyStepEvents(l),null}if(m.warnings.length>0)for(const v of m.warnings)l.push({message:`⚠ ${v}`,status:"warning"});return l.push({message:"Successfully built manifest",status:"success"}),r.output={result:f},r.status="done",this.state.updatePipeline({appName:f.manifest.application.displayName}),this.state.updateEntitiesFromManifest(f.filePaths),this.state.applyStepEvents(l),f}}class Bv{constructor({apiService:s,state:r,notify:l}){this.apiService=s,this.state=r,this.notify=l}async execute(){const s=this.state.steps.checkServer,r=await this.apiService.validateAuth();return r.serverUp?r.authValid?(s.output={isReady:!0,errorLogged:!1},s.status="done",this.notify(),!0):(s.output.errorLogged||(s.output={isReady:!1,errorLogged:!0},s.status="error",this.state.applyStepEvents([{message:"Authentication failed",status:"error"}]),this.state.updatePipeline({status:"error"})),!1):(s.output.errorLogged||(s.output={isReady:!1,errorLogged:!0},s.status="error",this.state.applyStepEvents([{message:"Cannot reach server",status:"error"}]),this.state.updatePipeline({status:"error"})),!1)}}class jv{constructor({apiService:s,configService:r,state:l,notify:f}){this.apiService=s,this.configService=r,this.state=l,this.notify=f}async execute(s){if(!s.applicationId)return;const r=this.state.steps.ensureValidTokens;r.status="in_progress",this.notify();const l=await this.configService.getConfig();if(l.applicationAccessToken&&!this.isTokenExpired(l.applicationAccessToken)){r.status="done",this.notify();return}if(l.applicationRefreshToken&&!this.isTokenExpired(l.applicationRefreshToken)){const f=await this.apiService.renewApplicationToken(l.applicationRefreshToken);if(f.success){await this.configService.setConfig({applicationAccessToken:f.data.applicationAccessToken.token,applicationRefreshToken:f.data.applicationRefreshToken.token}),this.state.applyStepEvents([{message:"Renewing application tokens",status:"info"},{message:"Application tokens renewed",status:"success"}]),r.status="done",this.notify();return}this.state.applyStepEvents([{message:"Renewing application tokens",status:"info"},{message:`Failed to renew application tokens: ${JSON.stringify(f.error,null,2)}`,status:"error"}]),await this.exchangeTokens({applicationId:s.applicationId});return}await this.exchangeTokens({applicationId:s.applicationId})}async exchangeTokens(s){const r=await this.apiService.generateApplicationToken(s.applicationId);if(!r.success){this.state.applyStepEvents([{message:"Generating application tokens",status:"info"},{message:`Failed to generate application tokens: ${JSON.stringify(r.error,null,2)}`,status:"error"}]),this.state.steps.ensureValidTokens.status="error",this.notify();return}await this.configService.setConfig({applicationAccessToken:r.data.applicationAccessToken.token,applicationRefreshToken:r.data.applicationRefreshToken.token}),this.state.applyStepEvents([{message:"Generating application tokens",status:"info"},{message:"Application tokens stored in config",status:"success"}]),this.state.steps.ensureValidTokens.status="done",this.notify()}isTokenExpired(s){try{const r=JSON.parse(Buffer.from(s.split(".")[1],"base64").toString());return Date.now()>=r.exp*1e3-6e4}catch{return!0}}}class qv{constructor({clientService:s,configService:r,state:l,notify:f}){this.clientService=s,this.configService=r,this.state=l,this.notify=f}async execute(s){const r=this.state.steps.generateApiClient;r.status="in_progress",this.notify();try{const l=await this.configService.getConfig();await this.clientService.generate({appPath:s.appPath,authToken:l.applicationAccessToken}),r.status="done"}catch(l){this.state.applyStepEvents([{message:`Failed to generate API client: ${l instanceof Error?l.message:String(l)}`,status:"error"}]),r.status="error"}this.notify()}}class Hv{constructor({apiService:s,state:r,notify:l}){this.apiService=s,this.state=r,this.notify=l}async execute(s){const r=this.state.steps.resolveApplication;r.status="in_progress",this.notify();const l=s.manifest.application.universalIdentifier,f=await this.apiService.findOneApplication(l);if(!f.success)return this.state.applyStepEvents([{message:`Failed to find application ${l}`,status:"error"}]),r.status="error",this.state.updatePipeline({status:"error"}),r.output;if(f.data)return r.output={applicationId:f.data.id,universalIdentifier:f.data.universalIdentifier},r.status="done",this.notify(),r.output;const m=await this.apiService.createApplication(s.manifest);return m.success?(r.output={applicationId:m.data.id,universalIdentifier:m.data.universalIdentifier},this.state.applyStepEvents([{message:"Creating application",status:"info"},{message:"Application created",status:"success"}]),r.status="done",this.notify(),r.output):(this.state.applyStepEvents([{message:"Creating application",status:"info"},{message:`Application creation failed with error ${JSON.stringify(m.error,null,2)}`,status:"error"}]),r.status="error",this.state.updatePipeline({status:"error"}),r.output)}}const Gv=async(o,s,r)=>{const l=new Set(r),f=s.filter(m=>!l.has(m));for(const m of f){const v=m.replace(/\.tsx?$/,".mjs"),E=Y.default.join(o,v),b=`${E}.map`;await C.remove(E),await C.remove(b)}},zv=async({result:o,appPath:s,fileFolder:r,lastChecksums:l,onFileBuilt:f})=>{const m=Object.keys(o.metafile?.outputs??{}).filter(v=>v.endsWith(".mjs"));for(const v of m){const E=Y.default.resolve(v),b=Y.default.relative(s,E),M=o.metafile?.outputs?.[v]?.entryPoint||"",H=Y.default.relative(s,M),X=await C.readFile(E),U=Hr.default.createHash("md5").update(X).digest("hex");l.get(b)!==U&&(l.set(b,U),f&&await f({fileFolder:r,builtPath:b,sourcePath:H,checksum:U}))}},Kv=[],Jv=`
179
485
  export var customElementMap = globalThis.__HTML_TAG_TO_CUSTOM_ELEMENT_TAG__ || {};
180
486
 
181
487
  var _injectedStyleKeys = {};
@@ -252,7 +558,7 @@ export function makeEventRef(events, userRef) {
252
558
  else if (userRef != null && typeof userRef === 'object') userRef.current = el;
253
559
  };
254
560
  }
255
- `.trim(),zv=`
561
+ `.trim(),Vv=`
256
562
  import {
257
563
  jsx as _originalJsx,
258
564
  jsxs as _originalJsxs,
@@ -297,7 +603,7 @@ function _wrapJsxFactory(originalFactory) {
297
603
  export var jsx = _wrapJsxFactory(_originalJsx);
298
604
  export var jsxs = _wrapJsxFactory(_originalJsxs);
299
605
  export { Fragment };
300
- `.trim(),Kv=`
606
+ `.trim(),Yv=`
301
607
  export * from '__real_react__';
302
608
  import _React from '__real_react__';
303
609
 
@@ -346,12 +652,12 @@ function createElement(type) {
346
652
 
347
653
  export { createElement };
348
654
  export default Object.assign({}, _React, { createElement: createElement });
349
- `.trim(),Vv=o=>{const s="react/jsx-runtime",r="react";return{name:"jsx-runtime-remote-wrapper",setup:l=>{let p,m;l.onResolve({filter:/^__jsx_shared_helpers__$/},()=>({path:"__jsx_shared_helpers__",namespace:"jsx-shared-helpers"})),l.onLoad({filter:/.*/,namespace:"jsx-shared-helpers"},()=>({contents:Jv,loader:"js"})),l.onResolve({filter:/^react\/jsx-runtime$/},async v=>{if(!v.pluginData?.skipJsxWrapper)return p||(p=(await l.resolve(s,{kind:v.kind,resolveDir:v.resolveDir,pluginData:{skipJsxWrapper:!0}})).path),{path:"react/jsx-runtime",namespace:"jsx-runtime-wrapper"}}),l.onResolve({filter:/^__real_react_jsx_runtime__$/},()=>{if(!p)throw new Error("jsx-runtime-remote-wrapper: real jsx-runtime path not resolved yet");return{path:p}}),l.onLoad({filter:/.*/,namespace:"jsx-runtime-wrapper"},()=>({contents:zv,loader:"js"})),l.onResolve({filter:/^react$/},async v=>{if(!v.pluginData?.skipJsxWrapper)return m||(m=(await l.resolve(r,{kind:v.kind,resolveDir:v.resolveDir,pluginData:{skipJsxWrapper:!0}})).path),{path:"react",namespace:"react-wrapper"}}),l.onResolve({filter:/^__real_react__$/},()=>{if(!m)throw new Error("jsx-runtime-remote-wrapper: real react path not resolved yet");return{path:m}}),l.onLoad({filter:/.*/,namespace:"react-wrapper"},()=>({contents:Kv,loader:"js"}))}}},Yv=/import\s*\{\s*defineFrontComponent\s*\}\s*from\s*['"][^'"]+['"];?\n?/g,al=/export\s+default\s+defineFrontComponent\s*\(\s*\{[\s\S]*?component\s*:\s*(\w+)[\s\S]*?\}\s*\)\s*;?/s,Xv=o=>{let s=o.replace(Yv,"");const r=s.match(al);if(r){const l=r[1],p=new RegExp(`export\\s+(const|function)\\s+${l}\\b`);s=s.replace(p,`$1 ${l}`),s=`import { createRoot as __createRoot } from 'react-dom/client';
655
+ `.trim(),Xv=o=>{const s="react/jsx-runtime",r="react";return{name:"jsx-runtime-remote-wrapper",setup:l=>{let f,m;l.onResolve({filter:/^__jsx_shared_helpers__$/},()=>({path:"__jsx_shared_helpers__",namespace:"jsx-shared-helpers"})),l.onLoad({filter:/.*/,namespace:"jsx-shared-helpers"},()=>({contents:Jv,loader:"js"})),l.onResolve({filter:/^react\/jsx-runtime$/},async v=>{if(!v.pluginData?.skipJsxWrapper)return f||(f=(await l.resolve(s,{kind:v.kind,resolveDir:v.resolveDir,pluginData:{skipJsxWrapper:!0}})).path),{path:"react/jsx-runtime",namespace:"jsx-runtime-wrapper"}}),l.onResolve({filter:/^__real_react_jsx_runtime__$/},()=>{if(!f)throw new Error("jsx-runtime-remote-wrapper: real jsx-runtime path not resolved yet");return{path:f}}),l.onLoad({filter:/.*/,namespace:"jsx-runtime-wrapper"},()=>({contents:Vv,loader:"js"})),l.onResolve({filter:/^react$/},async v=>{if(!v.pluginData?.skipJsxWrapper)return m||(m=(await l.resolve(r,{kind:v.kind,resolveDir:v.resolveDir,pluginData:{skipJsxWrapper:!0}})).path),{path:"react",namespace:"react-wrapper"}}),l.onResolve({filter:/^__real_react__$/},()=>{if(!m)throw new Error("jsx-runtime-remote-wrapper: real react path not resolved yet");return{path:m}}),l.onLoad({filter:/.*/,namespace:"react-wrapper"},()=>({contents:Yv,loader:"js"}))}}},Zv=/import\s*\{\s*defineFrontComponent\s*\}\s*from\s*['"][^'"]+['"];?\n?/g,ll=/export\s+default\s+defineFrontComponent\s*\(\s*\{[\s\S]*?component\s*:\s*(\w+)[\s\S]*?\}\s*\)\s*;?/s,Qv=o=>{let s=o.replace(Zv,"");const r=s.match(ll);if(r){const l=r[1],f=new RegExp(`export\\s+(const|function)\\s+${l}\\b`);s=s.replace(f,`$1 ${l}`),s=`import { createRoot as __createRoot } from 'react-dom/client';
350
656
  import { jsx as __frontComponentJsx } from 'react/jsx-runtime';
351
- `+s,s=s.replace(al,`export default function __renderFrontComponent(__container) { __createRoot(__container).render(__frontComponentJsx(${l}, {})); }`)}return s},Zv={name:"jsx-transform-to-remote-dom-worker-format-plugin",setup:o=>{o.onLoad({filter:/\.tsx$/},async({path:s})=>{try{const r=await Hm.readFile(s,"utf8");return{contents:Xv(r),loader:"tsx"}}catch(r){return{errors:[{text:`Failed to transform front component: ${r instanceof Error?r.message:String(r)}`,location:{file:s}}]}}})}},Qv=/^\/\/.*$\n/gm,ey={name:"strip-comments",setup:o=>{o.onEnd(async s=>{if(s.errors.length>0)return;const r=Object.keys(s.metafile?.outputs??{}).filter(l=>l.endsWith(".mjs"));for(const l of r){const p=Y.default.resolve(l),m=await rl.readFile(p,"utf-8"),v=m.replace(Qv,"");v!==m&&await rl.writeFile(p,v,"utf-8")}})}},ty=o=>[Vv(),Zv,ey],ny=/^(.+)\((\d+),(\d+)\): error TS\d+: (.+)$/,El=o=>{const s=o.match(ny);if(!s)return null;const[,r,l,p,m]=s;return{text:m,file:r,line:Number(l),column:Number(p)-1}},ry=o=>{const s=[];for(const r of o.split(`
352
- `)){const l=El(r);l&&s.push(l)}return s},Tl=o=>{const s=jr.default.join(o,"tsconfig.json"),r=jr.default.join(o,"node_modules",".bin","tsc");return new Promise(l=>{dl.execFile(r,["--noEmit","--pretty","false","-p",s],{cwd:o},(p,m,v)=>{l(ry(v||m))})})},iy=o=>o.map(s=>({text:s.text,location:{file:s.file,line:s.line,column:s.column,lineText:"",length:0,namespace:"",suggestion:""}})),bl=o=>({name:"typecheck",setup:s=>{s.onStart(async()=>{const r=await Tl(o);return{errors:iy(r)}})}}),sy=["path","fs","crypto","stream","util","os","url","http","https","events","buffer","querystring","assert","zlib","net","tls","child_process","worker_threads","twenty-sdk","twenty-sdk/*","twenty-shared","twenty-shared/*"];class Cl{constructor(s){this.esBuildContext=null,this.isRestarting=!1,this.lastChecksums=new Map,this.buildCompletePromise=Promise.resolve(),this.resolveBuildComplete=null,this.appPath=s.appPath,this.sourcePaths=s.sourcePaths,this.watchMode=s.watch??!0,this.onFileBuilt=s.handleFileBuilt,this.onBuildError=s.handleBuildError,this.config=s.config}shouldRestart(s){const r=this.sourcePaths.sort().join(","),l=[...s].sort().join(",");return r!==l}async start(){this.sourcePaths.length>0&&await this.createContext()}async close(){await this.esBuildContext?.dispose(),this.esBuildContext=null}async restart(s){if(!this.isRestarting){this.isRestarting=!0;try{await this.close();const r=Y.default.join(this.appPath,Qe);await qv(r,this.sourcePaths,s),this.sourcePaths=s,this.lastChecksums.clear(),this.sourcePaths.length>0&&await this.createContext()}finally{this.isRestarting=!1}}}async createContext(){const s=Y.default.join(this.appPath,Qe),r={};for(const m of this.sourcePaths){const v=m.replace(/\.tsx?$/,"");r[v]=Y.default.join(this.appPath,m)}const l=this,p=[...this.config.extraPlugins??[],{name:"build-notifications",setup:m=>{m.onEnd(async v=>{try{if(v.errors.length>0){v.errors[0].text.includes("Could not resolve")||await this.onBuildError?.(v.errors.map(E=>({error:E.text,location:E.location})));return}await Hv({result:v,appPath:this.appPath,fileFolder:this.config.fileFolder,lastChecksums:l.lastChecksums,onFileBuilt:l.onFileBuilt})}finally{l.resolveBuildComplete?.()}})}}];this.esBuildContext=await ml.context({entryPoints:r,bundle:!0,splitting:!1,format:"esm",platform:this.config.platform,outdir:s,outExtension:{".js":".mjs"},external:this.config.externalModules,tsconfig:Y.default.join(this.appPath,"tsconfig.json"),jsx:this.config.jsx,sourcemap:!0,metafile:!0,logLevel:"silent",minify:this.config.minify,banner:this.config.banner,plugins:p}),this.buildCompletePromise=new Promise(m=>{this.resolveBuildComplete=m}),await this.esBuildContext.rebuild(),await this.buildCompletePromise,this.watchMode&&await this.esBuildContext.watch()}}const Pl=o=>({name:"sdk-generated-resolver",setup:s=>{s.onResolve({filter:/^twenty-sdk\/generated/},()=>({path:Y.default.join(o,"node_modules","twenty-sdk",Gr,"index.ts")}))}}),ay=o=>new Cl({...o,config:{externalModules:sy,fileFolder:P.U.BuiltLogicFunction,platform:"node",extraPlugins:[bl(o.appPath),Pl(o.appPath)],banner:Jm}}),oy=o=>new Cl({...o,config:{externalModules:Gv,fileFolder:P.U.BuiltFrontComponent,jsx:"automatic",extraPlugins:[bl(o.appPath),Pl(o.appPath),...ty()]}});class ol{constructor(s){this.watcher=null,this.appPath=s.appPath,this.fileFolder=s.fileFolder,this.watchPaths=s.watchPaths,this.handleFileBuilt=s.handleFileBuilt}async start(){const s=this.watchPaths.map(r=>$.join(this.appPath,r));for(const r of s)if(!await k.pathExists(r))return;this.watcher=vl.default.watch(s,{awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on("all",(r,l)=>{r==="addDir"||r==="unlinkDir"||((r==="add"||r==="change")&&this.copyAndNotify(l),r==="unlink"&&this.handleUnlink(l))})}async close(){await this.watcher?.close()}async copyAndNotify(s){const r=$.relative(this.appPath,s),l=$.join(Qe,r),p=$.join(this.appPath,l);await k.ensureDir($.dirname(p)),await k.copy(s,p);const m=await k.readFile(p),v=Hr.default.createHash("md5").update(m).digest("hex");this.handleFileBuilt({fileFolder:this.fileFolder,builtPath:l,sourcePath:r,checksum:v})}async handleUnlink(s){const r=$.relative(this.appPath,s),l=$.join(Qe,r),p=$.join(this.appPath,l);await k.remove(p)}}class ly{constructor(s){this.process=null,this.pendingErrors=[],this.buffer="",this.hasErrors=!1,this.appPath=s.appPath,this.onErrors=s.onErrors}async start(){const s=jr.default.join(this.appPath,"node_modules",".bin","tsc");if(!await k.pathExists(s))return;const r=jr.default.join(this.appPath,"tsconfig.json");this.process=dl.spawn(s,["--watch","--noEmit","--pretty","false","-p",r],{cwd:this.appPath,stdio:["ignore","pipe","pipe"]}),this.process.on("error",()=>{this.process=null}),this.process.stdout?.on("data",l=>{this.handleOutput(l.toString())}),this.process.stderr?.on("data",l=>{this.handleOutput(l.toString())})}close(){this.process?.kill(),this.process=null}handleOutput(s){this.buffer+=s;const r=this.buffer.split(`
353
- `);this.buffer=r.pop()??"";for(const l of r)this.processLine(l)}processLine(s){if(s.includes("Starting compilation in watch mode...")||s.includes("Starting incremental compilation...")){this.pendingErrors=[];return}if(s.includes("Watching for file changes.")){const l=this.hasErrors;this.hasErrors=this.pendingErrors.length>0,(this.hasErrors||l)&&this.onErrors(this.pendingErrors),this.pendingErrors=[];return}const r=El(s);r&&this.pendingErrors.push(r)}}const uy=new Set(["node_modules",Gr,"dist",".twenty"]);class cy{constructor(s){this.watcher=null,this.appPath=s.appPath,this.handleChangeDetected=s.handleChangeDetected}async start(){const s=this.appPath;this.watcher=vl.default.watch(this.appPath,{ignored:r=>{const l=$.relative(s,r);if(l==="")return!1;const p=l.split(Y.default.sep)[0];return uy.has(p)||p.startsWith(".")},awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on("all",(r,l)=>{if(r==="addDir"||r==="unlinkDir")return;const p=$.relative(this.appPath,l),m=p.startsWith(vs),v=["package.json","yarn.lock"].includes(p);!(p.endsWith(".ts")||p.endsWith(".tsx"))&&!m&&!v||this.handleChangeDetected(p,r)})}async close(){await this.watcher?.close()}}class fy{constructor(s){this.manifestWatcher=null,this.logicFunctionsWatcher=null,this.frontComponentsWatcher=null,this.assetWatcher=null,this.dependencyWatcher=null,this.tscWatcher=null,this.state=s.state,this.scheduleSync=s.scheduleSync,this.notify=s.notify,this.onFileBuilt=s.onFileBuilt}async start(){this.state.steps.startWatchers.status="in_progress",this.notify(),this.manifestWatcher=new cy({appPath:this.state.appPath,handleChangeDetected:this.handleChangeDetected.bind(this)}),await this.manifestWatcher.start()}async handleWatcherRestarts(s){const{logicFunctions:r,frontComponents:l}=s.filePaths;if(!this.state.steps.startWatchers.output.watchersStarted){this.state.steps.startWatchers.output.watchersStarted=!0,this.state.steps.startWatchers.status="done",await this.startFileWatchers(r,l);return}this.logicFunctionsWatcher?.shouldRestart(r)&&await this.logicFunctionsWatcher.restart(r),this.frontComponentsWatcher?.shouldRestart(l)&&await this.frontComponentsWatcher.restart(l)}async close(){this.tscWatcher?.close(),await Promise.all([this.manifestWatcher?.close(),this.logicFunctionsWatcher?.close(),this.frontComponentsWatcher?.close(),this.assetWatcher?.close(),this.dependencyWatcher?.close()])}handleChangeDetected(s,r){this.state.addEvent({message:`Change detected: ${s}`,status:"info"}),r==="unlink"?this.state.removeEntity(s):this.state.updateEntityStatus(s,"building"),this.notify(),this.scheduleSync()}handleFileBuildError(s){this.state.addEvent({message:"Build failed:",status:"error"});for(const r of s)this.state.addEvent({message:r.error,status:"error"});this.notify()}handleFileBuilt(s){this.state.addEvent({message:`Successfully built ${s.builtPath}`,status:"success"}),this.state.steps.uploadFiles.output.builtFileInfos.set(s.builtPath,{checksum:s.checksum,builtPath:s.builtPath,sourcePath:s.sourcePath,fileFolder:s.fileFolder}),this.onFileBuilt(s),this.notify(),this.scheduleSync()}async startFileWatchers(s,r){await Promise.all([this.startTscWatcher(),this.startLogicFunctionsWatcher(s),this.startFrontComponentsWatcher(r),this.startAssetWatcher(),this.startDependencyWatcher()])}async startLogicFunctionsWatcher(s){this.logicFunctionsWatcher=ay({appPath:this.state.appPath,sourcePaths:s,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.logicFunctionsWatcher.start()}async startFrontComponentsWatcher(s){this.frontComponentsWatcher=oy({appPath:this.state.appPath,sourcePaths:s,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.frontComponentsWatcher.start()}async startAssetWatcher(){this.assetWatcher=new ol({appPath:this.state.appPath,fileFolder:P.U.PublicAsset,watchPaths:[vs],handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.assetWatcher.start()}async startDependencyWatcher(){this.dependencyWatcher=new ol({appPath:this.state.appPath,fileFolder:P.U.Dependencies,watchPaths:["package.json","yarn.lock"],handleFileBuilt:this.handleFileBuilt.bind(this)}),this.dependencyWatcher.start()}async startTscWatcher(){this.tscWatcher=new ly({appPath:this.state.appPath,onErrors:this.handleTypecheckErrors.bind(this)}),await this.tscWatcher.start()}handleTypecheckErrors(s){s.length===0?this.state.addEvent({message:"Typecheck passed",status:"success"}):this.state.applyStepEvents(s.map(r=>({message:`Type error in ${r.file}(${r.line},${r.column}): ${r.text}`,status:"error"}))),this.notify()}}const py=({manifest:o,builtFileInfos:s})=>{let r=structuredClone(o);for(const[p,{fileFolder:m,checksum:v}]of s.entries()){const E=$.relative(Qe,p);if(m===P.U.BuiltLogicFunction){const b=r.logicFunctions,M=b.findIndex(H=>H.builtHandlerPath===E);if(M===-1)continue;r={...r,logicFunctions:b.map((H,X)=>X===M?{...H,builtHandlerChecksum:v}:H)}}if(m===P.U.PublicAsset){const b=r.publicAssets,M=b.findIndex(H=>H.filePath===E);if(M===-1)continue;r={...r,publicAssets:b.map((H,X)=>X===M?{...H,checksum:v}:H)};continue}if(m===P.U.BuiltFrontComponent){const b=r.frontComponents,M=b.findIndex(H=>H.builtComponentPath===E)??-1;if(M===-1)continue;r={...r,frontComponents:b.map((H,X)=>X===M?{...H,builtComponentChecksum:v}:H)}}m===P.U.Dependencies&&(E==="package.json"&&(r.application.packageJsonChecksum=v),E==="yarn.lock"&&(r.application.yarnLockChecksum=v))}const l=[];for(const[p,{fileFolder:m}]of s.entries()){const v=$.relative(Qe,p);if(m===P.U.Dependencies&&v.startsWith(`${Br}/`)){const E=s.get(p);E&&l.push(E.checksum)}}return l.length>0&&(r.application.apiClientChecksum=Hr.default.createHash("md5").update(l.sort().join("")).digest("hex")),r},dy=async(o,s)=>{const r=Y.default.join(o,Qe);await k.ensureDir(r);const l=Y.default.join(r,"manifest.json");return await k.writeJSON(l,s,{spaces:2}),l},Rl=o=>{if(typeof o=="string")return o;if(hn.default.isAxiosError(o)){const r=[],l=o.response?.status,p=o.response?.statusText;l&&r.push(`HTTP ${l}${p?` ${p}`:""}`);const m=o.response?.data?.errors;if(Array.isArray(m)&&m.length>0){const v=m.map(E=>E.message??"Unknown GraphQL error").join("; ");r.push(v)}else o.response?.data?.message?r.push(o.response.data.message):o.message&&r.push(o.message);return o.code&&r.push(`(${o.code})`),r.join(" - ")||"Unknown Axios error"}if(o instanceof Error)return o.message||o.toString();const s=JSON.stringify(o,null,2);return s==="{}"||s===void 0?String(o):s};class hy{constructor({apiService:s,state:r,notify:l}){this.apiService=s,this.state=r,this.notify=l}async execute(s){const r=this.state.steps.syncApplication;r.status="in_progress",this.state.updatePipeline({status:"syncing"});const l=[],p=py({manifest:s.manifest,builtFileInfos:s.builtFileInfos});l.push({message:"Manifest checksums set",status:"info"}),await dy(s.appPath,p),l.push({message:"Manifest saved to output directory",status:"info"}),l.push({message:"Syncing manifest",status:"info"});const m=await this.apiService.syncApplication(p);if(m.success){l.push({message:"✓ Synced",status:"success"}),r.output={syncStatus:"synced",error:null},r.status="done",this.state.updatePipeline({status:"synced",error:null}),this.state.updateAllEntitiesStatus("success"),this.state.applyStepEvents(l);return}const v=`Sync failed with error: ${Rl(m.error)}`;l.push({message:v,status:"error"}),r.output={syncStatus:"error",error:v},r.status="error",this.state.updatePipeline({status:"error",error:v}),this.state.updateAllEntitiesStatus("error"),this.state.applyStepEvents(l)}}class gy{constructor(s){this.apiService=new Tt,this.applicationUniversalIdentifier=s.applicationUniversalIdentifier,this.appPath=s.appPath}async uploadFile({builtPath:s,fileFolder:r}){const l=$.relative(Qe,s);return await this.apiService.uploadFile({filePath:Y.default.join(this.appPath,s),builtHandlerPath:l,fileFolder:r,applicationUniversalIdentifier:this.applicationUniversalIdentifier})}}const my=["types.ts","schema.ts"];class vy{constructor({state:s,notify:r}){this.state=s,this.notify=r}get isInitialized(){return this.state.steps.uploadFiles.output.fileUploader!==null}initialize(s){const r=this.state.steps.uploadFiles;r.output={...r.output,fileUploader:new gy({appPath:s.appPath,applicationUniversalIdentifier:s.universalIdentifier})},r.status="in_progress",this.notify(),this.uploadPendingFiles()}uploadFile(s,r,l){const p=this.state.steps.uploadFiles;if(!p.output.fileUploader)return;this.state.addEvent({message:`Uploading ${s}`,status:"info"}),this.state.updateEntityStatus(r,"uploading");const m=p.output.fileUploader.uploadFile({builtPath:s,fileFolder:l}).then(v=>{v.success?(this.state.addEvent({message:`Successfully uploaded ${s}`,status:"success"}),this.state.updateEntityStatus(r,"success")):this.state.addEvent({message:`Failed to upload ${s}: ${v.error}`,status:"error"})}).catch(v=>{this.state.addEvent({message:`Upload failed for ${s}: ${v}`,status:"error"})}).finally(()=>{p.output.activeUploads.delete(m)});p.output.activeUploads.add(m)}async waitForUploads(){const s=this.state.steps.uploadFiles;for(;s.output.activeUploads.size>0;)await Promise.all(s.output.activeUploads);s.status="done",this.notify()}async copyAndUploadApiClientFiles(s){const r=$.join(s,"node_modules","twenty-sdk",Gr);if(!await k.pathExists(r))return;const l=$.join(s,Qe,Br);await k.ensureDir(l);for(const p of my){const m=$.join(r,p);if(!await k.pathExists(m))continue;await k.copy(m,$.join(l,p));const v=await k.readFile(m),E=Hr.default.createHash("md5").update(v).digest("hex"),b=$.join(Qe,Br,p),M=$.join(Br,p);this.state.steps.uploadFiles.output.builtFileInfos.set(b,{checksum:E,builtPath:b,sourcePath:M,fileFolder:P.U.Dependencies}),this.uploadFile(b,M,P.U.Dependencies)}}uploadPendingFiles(){for(const[s,{fileFolder:r,sourcePath:l}]of this.state.steps.uploadFiles.output.builtFileInfos.entries())this.uploadFile(s,l,r)}}class yy{constructor(s){this.syncTimer=null,this.serverCheckInterval=null,this.debounceMs=s.debounceMs??200,this.state=s.state;const r=new Tt({disableInterceptors:!0}),l=new we,p=new yv,m={state:this.state,notify:()=>this.state.notify()};this.checkServerStep=new $v({...m,apiService:r}),this.ensureValidTokensStep=new Mv({...m,apiService:r,configService:l}),this.buildManifestStep=new Wv(m),this.resolveApplicationStep=new jv({...m,apiService:r}),this.uploadFilesStep=new vy(m),this.generateApiClientStep=new Bv({...m,clientService:p,configService:l}),this.syncApplicationStep=new hy({...m,apiService:r}),this.startWatchersStep=new fy({...m,scheduleSync:this.scheduleSync.bind(this),onFileBuilt:this.handleFileBuilt.bind(this)})}async start(){const s=Y.default.join(this.state.appPath,Qe);await k.ensureDir(s),await k.emptyDir(s),await this.startWatchersStep.start(),this.serverCheckInterval=setInterval(()=>{this.checkServerHealth()},2e3)}async close(){this.serverCheckInterval&&clearInterval(this.serverCheckInterval),await this.startWatchersStep.close()}getState(){return this.state}handleFileBuilt(s){this.state.steps.uploadFiles.output.fileUploader&&this.uploadFilesStep.uploadFile(s.builtPath,s.sourcePath,s.fileFolder)}async checkServerHealth(){const s=this.state.steps.checkServer.output.isReady;await this.checkServerStep.execute()&&!s&&this.scheduleSync()}scheduleSync(){this.syncTimer&&clearTimeout(this.syncTimer),this.syncTimer=setTimeout(()=>{this.syncTimer=null,this.performSync()},this.debounceMs)}async performSync(){if(!this.state.pipeline.isSyncing){this.state.updatePipeline({isSyncing:!0});try{await this.runSyncPipeline()}catch(s){this.state.addEvent({message:`Sync failed with error: ${Rl(s)}`,status:"error"}),this.state.updatePipeline({status:"error"}),this.state.updateAllEntitiesStatus("error")}finally{this.state.updatePipeline({isSyncing:!1})}}}async runSyncPipeline(){if(!await this.checkServerStep.execute())return;await this.ensureValidTokensStep.execute({applicationId:this.state.steps.resolveApplication.output.applicationId});const r=await this.buildManifestStep.execute({appPath:this.state.appPath});if(!r||(await this.startWatchersStep.handleWatcherRestarts(r),!this.uploadFilesStep.isInitialized&&!await this.initializePipeline(r.manifest)))return;const l=this.state.hasObjectsOrFieldsChanged(r.manifest);await this.uploadFilesStep.waitForUploads(),await this.syncApplicationStep.execute({manifest:r.manifest,builtFileInfos:this.state.steps.uploadFiles.output.builtFileInfos,appPath:this.state.appPath}),l&&(await this.generateApiClientStep.execute({appPath:this.state.appPath}),await this.uploadFilesStep.copyAndUploadApiClientFiles(this.state.appPath))}async initializePipeline(s){const r=await this.resolveApplicationStep.execute({manifest:s});return r.applicationId?(await this.ensureValidTokensStep.exchangeTokens({applicationId:r.applicationId}),this.uploadFilesStep.initialize({appPath:this.state.appPath,universalIdentifier:s.application.universalIdentifier}),!0):!1}}const _y={objects:K.Object,fields:K.Field,logicFunctions:K.LogicFunction,frontComponents:K.FrontComponent,roles:K.Role,skills:K.Skill,views:K.View,navigationMenuItems:K.NavigationMenuItem,pageLayouts:K.PageLayout},wy=200,xy={pending:["building","uploading","success","error"],building:["pending","uploading","success","error"],uploading:["pending","success","error"],success:["pending","building","uploading","error"],error:["pending","building","uploading","success"]};class Sy{constructor(s){this.eventIdCounter=0,this.appPath=s.appPath,this.frontendUrl=s.frontendUrl,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.entities=new Map,this.events=[]}notify(){this.onChange?.()}updatePipeline(s){Object.assign(this.pipeline,s),this.notify()}applyStepEvents(s){const r=s.map(l=>(this.eventIdCounter+=1,{...l,id:this.eventIdCounter,timestamp:new Date,message:l.message.slice(0,5e3)}));this.events=[...this.events.slice(-(wy-r.length)),...r]}addEvent(s){this.applyStepEvents([s])}updateEntityStatus(s,r){const l=new Map(this.entities),p=l.get(s);p?.status&&!xy[p.status].includes(r)||(l.set(s,p?{...p,status:r}:{name:s,path:s,status:r}),this.entities=l)}removeEntity(s){const r=new Map(this.entities);r.delete(s),this.entities=r}updateAllEntitiesStatus(s){const r=new Map(this.entities);for(const[l,p]of r)r.set(l,{...p,status:s});this.entities=r}updateEntitiesFromManifest(s){const r=new Map;for(const[p,m]of Object.entries(s)){const v=_y[p];if(v)for(const E of m)r.set(E,v)}const l=new Map(this.entities);for(const[p,m]of l)l.set(p,{...m,type:r.get(p)});this.entities=l}hasObjectsOrFieldsChanged(s){const r=JSON.stringify({objects:s.objects,fields:s.fields}),l=r!==this.previousObjectsFieldsFingerprint;return this.previousObjectsFieldsFingerprint=r,l}}class Ay{constructor(){this.orchestrator=null,this.unmountUI=null}async close(){this.unmountUI?.(),await this.orchestrator?.close()}async execute(s){const r=s.appPath??Ie,l=new Sy({appPath:r,frontendUrl:process.env.FRONTEND_URL}),p=new gv(l);l.onChange=()=>p.notify();const{unmount:m}=await hv(p);this.unmountUI=m,this.orchestrator=new yy({state:l}),await this.orchestrator.start(),this.setupGracefulShutdown()}setupGracefulShutdown(){const s=()=>void this.close().then(()=>process.exit(0));process.on("SIGINT",s),process.on("SIGTERM",s)}}const Iy=o=>`${A.default.cyan(o.file)}:${A.default.yellow(String(o.line))}:${A.default.yellow(String(o.column+1))} - ${A.default.red("error")} ${o.text}`;class Fy{async execute(s){const r=s.appPath??Ie;console.log(A.default.blue("Running type check...")),console.log(A.default.gray(`App path: ${r}`)),console.log("");const l=await Tl(r);l.length===0&&(console.log(A.default.green("✓ No type errors found")),process.exit(0));for(const p of l)console.log(Iy(p));console.log(""),console.log(A.default.red(`✗ Found ${l.length} type error${l.length===1?"":"s"}`)),process.exit(1)}}const _s=async o=>{const s=Y.default.join(o,Qe);await k.ensureDir(s);const r=Y.default.join(s,"manifest.json");if(!await k.pathExists(r)){const{manifest:l}=await Il(o);return l}return await k.readJson(r)};class Ey{constructor(){this.apiService=new Tt}async execute({appPath:s=Ie,askForConfirmation:r}){try{console.log(A.default.blue("🚀 Uninstall Twenty Application")),console.log(A.default.gray(`📁 App Path: ${s}`)),console.log(""),r&&!await this.confirmationPrompt()&&(console.error(A.default.red("⛔️ Aborting uninstall")),process.exit(1));const l=await _s(s);if(!l)return{success:!1,error:"Build failed"};const p=await this.apiService.uninstallApplication(l.application.universalIdentifier);return p.success===!1?console.error(A.default.red("❌ Uninstall failed:"),p.error):console.log(A.default.green("✅ Application uninstalled successfully")),p}catch(l){throw console.error(A.default.red("Uninstall failed:"),l instanceof Error?l.message:l),l}}async confirmationPrompt(){const{confirmation:s}=await ot.default.prompt([{type:"confirm",name:"confirmation",message:"Are you sure you want to uninstall this application?",default:!1}]);return s}}class Ty{constructor(){this.configService=new we}async execute(){try{const s=await this.configService.getAvailableWorkspaces(),r=await this.configService.getDefaultWorkspace();if(s.length===0){console.log(A.default.yellow("⚠ No workspaces configured. Use `twenty auth:login` to create one."));return}console.log(A.default.blue(`Available workspaces:
354
- `));for(const l of s){const p=await this.configService.getConfigForWorkspace(l),m=!!p.apiKey,E=l===r?A.default.green(" (default)"):"",b=m?A.default.green("●"):A.default.gray("○");console.log(` ${b} ${l}${E}`),console.log(A.default.gray(` API URL: ${p.apiUrl}`))}console.log(""),console.log(A.default.gray("● = authenticated, ○ = no credentials")),console.log(A.default.gray("Use `twenty auth:switch <workspace>` to change default"))}catch(s){console.error(A.default.red("List failed:"),s instanceof Error?s.message:s),process.exit(1)}}}class by{constructor(){this.configService=new we,this.apiService=new Tt}async execute(s){try{let{apiKey:r,apiUrl:l}=s;const p=await this.configService.getConfig();if(l||(l=(await ot.default.prompt([{type:"input",name:"apiUrl",message:"Twenty API URL:",default:p.apiUrl,validate:E=>{try{return new URL(E),!0}catch{return"Please enter a valid URL"}}}])).apiUrl),r||(r=(await ot.default.prompt([{type:"password",name:"apiKey",message:"API Key:",mask:"*",validate:E=>E.length>0||"API key is required"}])).apiKey),await this.configService.setConfig({apiUrl:l,apiKey:r}),(await this.apiService.validateAuth()).authValid){const v=we.getActiveWorkspace();console.log(A.default.green(`✓ Successfully authenticated with Twenty (workspace: ${v})`))}else console.log(A.default.red("✗ Authentication failed. Please check your credentials.")),process.exit(1)}catch(r){console.error(A.default.red("Login failed:"),r instanceof Error?r.message:r),process.exit(1)}}}class Cy{constructor(){this.configService=new we}async execute(){try{await this.configService.clearConfig();const s=we.getActiveWorkspace();console.log(A.default.green(`✓ Successfully logged out (workspace: ${s})`))}catch(s){console.error(A.default.red("Logout failed:"),s instanceof Error?s.message:s),process.exit(1)}}}class Py{constructor(){this.configService=new we,this.apiService=new Tt}async execute(){try{const s=we.getActiveWorkspace(),r=await this.configService.getConfig();if(console.log(A.default.blue("Authentication Status:")),console.log(`Workspace: ${s}`),console.log(`API URL: ${r.apiUrl}`),console.log(`API Key: ${r.apiKey?"***"+r.apiKey.slice(-4):"Not set"}`),r.apiKey){const l=await this.apiService.validateAuth();console.log(`Status: ${l.authValid?A.default.green("✓ Valid"):A.default.red("✗ Invalid")}`)}else console.log(`Status: ${A.default.yellow("⚠ Not authenticated")}`)}catch(s){console.error(A.default.red("Status check failed:"),s instanceof Error?s.message:s),process.exit(1)}}}class Ry{constructor(){this.apiService=new Tt}async execute({appPath:s=Ie,postInstall:r=!1,functionUniversalIdentifier:l,functionName:p,payload:m="{}"}){try{let v;try{v=JSON.parse(m)}catch{console.error(A.default.red("Invalid JSON payload. Please provide valid JSON.")),process.exit(1)}const E=await _s(s);E||(console.error(A.default.red("Failed to build manifest.")),process.exit(1));const b=await this.apiService.findLogicFunctions();b.success||(console.error(A.default.red("Failed to fetch functions:"),b.error instanceof Error?b.error.message:b.error),process.exit(1));const M=b.data.filter(ie=>ie.universalIdentifier&&this.belongsToApplication(ie,E)),H=M.find(ie=>r?ie.universalIdentifier===E.application.postInstallLogicFunctionUniversalIdentifier:l?ie.universalIdentifier===l:p?ie.name===p:!1);if(!H){const ie=r?"post install":l||p;console.error(A.default.red(`Function "${ie}" not found in application.`)),console.log(""),M.length>0?(console.log(A.default.cyan("Available functions:")),M.forEach(lt=>{console.log(` - ${A.default.white(lt.name)} (${lt.universalIdentifier})`)})):console.log(A.default.yellow("No functions found for this application. Have you synced your app with `yarn app:dev`?")),process.exit(1)}console.log(A.default.blue(`🚀 Executing function "${H.name}"...`)),console.log(A.default.gray(` Payload: ${JSON.stringify(v)}`)),console.log("");const X=await this.apiService.executeLogicFunction({functionId:H.id,payload:v});X.success||(console.error(A.default.red("Execution failed:"),X.error instanceof Error?X.error.message:X.error),process.exit(1));const N=X.data;console.log(A.default.cyan("─".repeat(60))),console.log(A.default.cyan("Execution Result")),console.log(A.default.cyan("─".repeat(60)));const V=N.status==="SUCCESS"?A.default.green:A.default.red;console.log(`${A.default.bold("Status:")} ${V(N.status)}`),console.log(`${A.default.bold("Duration:")} ${N.duration}ms`),P.o(N.data)&&(console.log(""),console.log(A.default.bold("Data:")),console.log(A.default.white(JSON.stringify(N.data,null,2)))),N.error&&(console.log(""),console.log(A.default.bold.red("Error:")),console.log(A.default.red(` Type: ${N.error.errorType}`)),console.log(A.default.red(` Message: ${N.error.errorMessage}`)),N.error.stackTrace&&(console.log(""),console.log(A.default.gray("Stack trace:")),console.log(A.default.gray(N.error.stackTrace)))),N.logs&&(console.log(""),console.log(A.default.bold("Logs:")),console.log(A.default.gray(N.logs))),console.log(A.default.cyan("─".repeat(60))),N.status!=="SUCCESS"&&process.exit(1)}catch(v){console.error(A.default.red("Execution failed:"),v instanceof Error?v.message:v),process.exit(1)}}belongsToApplication(s,r){return r.logicFunctions.some(l=>l.universalIdentifier===s.universalIdentifier)}}class Oy{constructor(){this.apiService=new Tt}async execute({appPath:s=Ie,functionUniversalIdentifier:r,functionName:l}){try{const p=await _s(s);p||process.exit(1),this.logWatchInfo({appName:p.application.displayName,functionUniversalIdentifier:r,functionName:l}),await this.apiService.subscribeToLogs({applicationUniversalIdentifier:p.application.universalIdentifier,functionUniversalIdentifier:r,functionName:l})}catch(p){console.error(A.default.red("Watch logs failed:"),p instanceof Error?p.message:p),process.exit(1)}}logWatchInfo({appName:s,functionUniversalIdentifier:r,functionName:l}){const p=s??"Twenty Application",m=r||l?`function "${r||l}"`:"functions";console.log(A.default.blue(`🚀 Watching ${p} ${m} logs:`)),console.log("")}}class Ly{constructor(){this.configService=new we,this.apiService=new Tt}async execute(s){try{let{workspace:r}=s;const l=await this.configService.getAvailableWorkspaces(),p=await this.configService.getDefaultWorkspace();if(l.length===0){console.log(A.default.yellow("⚠ No workspaces configured. Use `twenty auth:login` to create one."));return}if(!r){const E=l.map(M=>({name:M===p?`${M} (current default)`:M,value:M}));r=(await ot.default.prompt([{type:"list",name:"workspace",message:"Select a workspace to set as default:",choices:E,default:p}])).workspace}if(l.includes(r)||(console.log(A.default.red(`✗ Workspace "${r}" not found. Available workspaces: ${l.join(", ")}`)),process.exit(1)),r===p){console.log(A.default.blue(`ℹ "${r}" is already the default workspace.`));return}await this.configService.setDefaultWorkspace(r),we.setActiveWorkspace(r);const v=!!(await this.configService.getConfig()).apiKey;console.log(A.default.green(`✓ Switched default workspace to "${r}"`)),v?(await this.apiService.validateAuth()).authValid?console.log(A.default.green("✓ Authentication is valid")):console.log(A.default.yellow("⚠ Authentication credentials exist but are invalid. Run `twenty auth:login` to re-authenticate.")):console.log(A.default.yellow("⚠ No credentials configured for this workspace. Run `twenty auth:login` to authenticate."))}catch(r){console.error(A.default.red("Switch failed:"),r instanceof Error?r.message:r),process.exit(1)}}}const ky=({name:o,universalIdentifier:s=We.v4()})=>{const r=Ze.default(o);return`import { defineFrontComponent } from 'twenty-sdk';
657
+ `+s,s=s.replace(ll,`export default function __renderFrontComponent(__container) { __createRoot(__container).render(__frontComponentJsx(${l}, {})); }`)}return s},ey={name:"jsx-transform-to-remote-dom-worker-format-plugin",setup:o=>{o.onLoad({filter:/\.tsx$/},async({path:s})=>{try{const r=await Gm.readFile(s,"utf8");return{contents:Qv(r),loader:"tsx"}}catch(r){return{errors:[{text:`Failed to transform front component: ${r instanceof Error?r.message:String(r)}`,location:{file:s}}]}}})}},ty=/^\/\/.*$\n/gm,ny={name:"strip-comments",setup:o=>{o.onEnd(async s=>{if(s.errors.length>0)return;const r=Object.keys(s.metafile?.outputs??{}).filter(l=>l.endsWith(".mjs"));for(const l of r){const f=Y.default.resolve(l),m=await il.readFile(f,"utf-8"),v=m.replace(ty,"");v!==m&&await il.writeFile(f,v,"utf-8")}})}},ry=o=>[Xv(),ey,ny],iy=/^(.+)\((\d+),(\d+)\): error TS\d+: (.+)$/,bl=o=>{const s=o.match(iy);if(!s)return null;const[,r,l,f,m]=s;return{text:m,file:r,line:Number(l),column:Number(f)-1}},sy=o=>{const s=[];for(const r of o.split(`
658
+ `)){const l=bl(r);l&&s.push(l)}return s},Cl=o=>{const s=jr.default.join(o,"tsconfig.json"),r=jr.default.join(o,"node_modules",".bin","tsc");return new Promise(l=>{gl.execFile(r,["--noEmit","--pretty","false","-p",s],{cwd:o},(f,m,v)=>{l(sy(v||m))})})},ay=o=>o.map(s=>({text:s.text,location:{file:s.file,line:s.line,column:s.column,lineText:"",length:0,namespace:"",suggestion:""}})),Pl=(o,s)=>({name:"typecheck",setup:r=>{r.onStart(async()=>{if(s())return;const l=await Cl(o);return{errors:ay(l)}})}}),oy=["path","fs","crypto","stream","util","os","url","http","https","events","buffer","querystring","assert","zlib","net","tls","child_process","worker_threads","twenty-sdk","twenty-sdk/*","twenty-shared","twenty-shared/*"];class Rl{constructor(s){this.esBuildContext=null,this.isRestarting=!1,this.lastChecksums=new Map,this.buildCompletePromise=Promise.resolve(),this.resolveBuildComplete=null,this.appPath=s.appPath,this.sourcePaths=s.sourcePaths,this.watchMode=s.watch??!0,this.onFileBuilt=s.handleFileBuilt,this.onBuildError=s.handleBuildError,this.config=s.config}shouldRestart(s){const r=this.sourcePaths.sort().join(","),l=[...s].sort().join(",");return r!==l}async start(){this.sourcePaths.length>0&&await this.createContext()}async close(){await this.esBuildContext?.dispose(),this.esBuildContext=null}async restart(s){if(!this.isRestarting){this.isRestarting=!0;try{await this.close();const r=Y.default.join(this.appPath,Qe);await Gv(r,this.sourcePaths,s),this.sourcePaths=s,this.lastChecksums.clear(),this.sourcePaths.length>0&&await this.createContext()}finally{this.isRestarting=!1}}}async createContext(){const s=Y.default.join(this.appPath,Qe),r={};for(const m of this.sourcePaths){const v=m.replace(/\.tsx?$/,"");r[v]=Y.default.join(this.appPath,m)}const l=this,f=[...this.config.extraPlugins??[],{name:"build-notifications",setup:m=>{m.onEnd(async v=>{try{if(v.errors.length>0){v.errors[0].text.includes("Could not resolve")||await this.onBuildError?.(v.errors.map(E=>({error:E.text,location:E.location})));return}await zv({result:v,appPath:this.appPath,fileFolder:this.config.fileFolder,lastChecksums:l.lastChecksums,onFileBuilt:l.onFileBuilt})}finally{l.resolveBuildComplete?.()}})}}];this.esBuildContext=await yl.context({entryPoints:r,bundle:!0,splitting:!1,format:"esm",platform:this.config.platform,outdir:s,outExtension:{".js":".mjs"},external:this.config.externalModules,tsconfig:Y.default.join(this.appPath,"tsconfig.json"),jsx:this.config.jsx,sourcemap:!0,metafile:!0,logLevel:"silent",minify:this.config.minify,banner:this.config.banner,plugins:f}),this.buildCompletePromise=new Promise(m=>{this.resolveBuildComplete=m}),await this.esBuildContext.rebuild(),await this.buildCompletePromise,this.watchMode&&await this.esBuildContext.watch()}}const kl=o=>({name:"sdk-generated-resolver",setup:s=>{s.onResolve({filter:/^twenty-sdk\/generated/},()=>({path:Y.default.join(o,"node_modules","twenty-sdk",Gr,"index.ts")}))}}),ly=o=>new Rl({...o,config:{externalModules:oy,fileFolder:k.U.BuiltLogicFunction,platform:"node",extraPlugins:[Pl(o.appPath,o.shouldSkipTypecheck),kl(o.appPath)],banner:Jm}}),uy=o=>new Rl({...o,config:{externalModules:Kv,fileFolder:k.U.BuiltFrontComponent,jsx:"automatic",extraPlugins:[Pl(o.appPath,o.shouldSkipTypecheck),kl(o.appPath),...ry()]}});class ul{constructor(s){this.watcher=null,this.appPath=s.appPath,this.fileFolder=s.fileFolder,this.watchPaths=s.watchPaths,this.handleFileBuilt=s.handleFileBuilt}async start(){const s=this.watchPaths.map(r=>R.join(this.appPath,r));for(const r of s)if(!await C.pathExists(r))return;this.watcher=_l.default.watch(s,{awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on("all",(r,l)=>{r==="addDir"||r==="unlinkDir"||((r==="add"||r==="change")&&this.copyAndNotify(l),r==="unlink"&&this.handleUnlink(l))})}async close(){await this.watcher?.close()}async copyAndNotify(s){const r=R.relative(this.appPath,s),l=R.join(Qe,r),f=R.join(this.appPath,l);await C.ensureDir(R.dirname(f)),await C.copy(s,f);const m=await C.readFile(f),v=Hr.default.createHash("md5").update(m).digest("hex");this.handleFileBuilt({fileFolder:this.fileFolder,builtPath:l,sourcePath:r,checksum:v})}async handleUnlink(s){const r=R.relative(this.appPath,s),l=R.join(Qe,r),f=R.join(this.appPath,l);await C.remove(f)}}class cy{constructor(s){this.process=null,this.pendingErrors=[],this.buffer="",this.hasErrors=!1,this.appPath=s.appPath,this.onErrors=s.onErrors}async start(){const s=jr.default.join(this.appPath,"node_modules",".bin","tsc");if(!await C.pathExists(s))return;const r=jr.default.join(this.appPath,"tsconfig.json");this.process=gl.spawn(s,["--watch","--noEmit","--pretty","false","-p",r],{cwd:this.appPath,stdio:["ignore","pipe","pipe"]}),this.process.on("error",()=>{this.process=null}),this.process.stdout?.on("data",l=>{this.handleOutput(l.toString())}),this.process.stderr?.on("data",l=>{this.handleOutput(l.toString())})}close(){this.process?.kill(),this.process=null}handleOutput(s){this.buffer+=s;const r=this.buffer.split(`
659
+ `);this.buffer=r.pop()??"";for(const l of r)this.processLine(l)}processLine(s){if(s.includes("Starting compilation in watch mode...")||s.includes("Starting incremental compilation...")){this.pendingErrors=[];return}if(s.includes("Watching for file changes.")){const l=this.hasErrors;this.hasErrors=this.pendingErrors.length>0,(this.hasErrors||l)&&this.onErrors(this.pendingErrors),this.pendingErrors=[];return}const r=bl(s);r&&this.pendingErrors.push(r)}}const fy=new Set(["node_modules",Gr,"dist",".twenty"]);class py{constructor(s){this.watcher=null,this.appPath=s.appPath,this.handleChangeDetected=s.handleChangeDetected}async start(){const s=this.appPath;this.watcher=_l.default.watch(this.appPath,{ignored:r=>{const l=R.relative(s,r);if(l==="")return!1;const f=l.split(Y.default.sep)[0];return fy.has(f)||f.startsWith(".")},awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on("all",(r,l)=>{if(r==="addDir"||r==="unlinkDir")return;const f=R.relative(this.appPath,l),m=f.startsWith(vs),v=["package.json","yarn.lock"].includes(f);!(f.endsWith(".ts")||f.endsWith(".tsx"))&&!m&&!v||this.handleChangeDetected(f,r)})}async close(){await this.watcher?.close()}}class dy{constructor(s){this.manifestWatcher=null,this.logicFunctionsWatcher=null,this.frontComponentsWatcher=null,this.assetWatcher=null,this.dependencyWatcher=null,this.tscWatcher=null,this.state=s.state,this.scheduleSync=s.scheduleSync,this.notify=s.notify,this.onFileBuilt=s.onFileBuilt,this.shouldSkipTypecheck=s.shouldSkipTypecheck}async start(){this.state.steps.startWatchers.status="in_progress",this.notify(),this.manifestWatcher=new py({appPath:this.state.appPath,handleChangeDetected:this.handleChangeDetected.bind(this)}),await this.manifestWatcher.start()}async handleWatcherRestarts(s){const{logicFunctions:r,frontComponents:l}=s.filePaths;if(!this.state.steps.startWatchers.output.watchersStarted){this.state.steps.startWatchers.output.watchersStarted=!0,this.state.steps.startWatchers.status="done",await this.startFileWatchers(r,l);return}this.logicFunctionsWatcher?.shouldRestart(r)&&await this.logicFunctionsWatcher.restart(r),this.frontComponentsWatcher?.shouldRestart(l)&&await this.frontComponentsWatcher.restart(l)}async close(){this.tscWatcher?.close(),await Promise.all([this.manifestWatcher?.close(),this.logicFunctionsWatcher?.close(),this.frontComponentsWatcher?.close(),this.assetWatcher?.close(),this.dependencyWatcher?.close()])}handleChangeDetected(s,r){this.state.addEvent({message:`Change detected: ${s}`,status:"info"}),r==="unlink"?this.state.removeEntity(s):this.state.updateEntityStatus(s,"building"),this.notify(),this.scheduleSync()}handleFileBuildError(s){this.state.addEvent({message:"Build failed:",status:"error"});for(const r of s)this.state.addEvent({message:r.error,status:"error"});this.notify()}handleFileBuilt(s){this.state.addEvent({message:`Successfully built ${s.builtPath}`,status:"success"}),this.state.steps.uploadFiles.output.builtFileInfos.set(s.builtPath,{checksum:s.checksum,builtPath:s.builtPath,sourcePath:s.sourcePath,fileFolder:s.fileFolder}),this.onFileBuilt(s),this.notify(),this.scheduleSync()}async startFileWatchers(s,r){await Promise.all([this.startTscWatcher(),this.startLogicFunctionsWatcher(s),this.startFrontComponentsWatcher(r),this.startAssetWatcher(),this.startDependencyWatcher()])}async startLogicFunctionsWatcher(s){this.logicFunctionsWatcher=ly({appPath:this.state.appPath,sourcePaths:s,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.logicFunctionsWatcher.start()}async startFrontComponentsWatcher(s){this.frontComponentsWatcher=uy({appPath:this.state.appPath,sourcePaths:s,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.frontComponentsWatcher.start()}async startAssetWatcher(){this.assetWatcher=new ul({appPath:this.state.appPath,fileFolder:k.U.PublicAsset,watchPaths:[vs],handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.assetWatcher.start()}async startDependencyWatcher(){this.dependencyWatcher=new ul({appPath:this.state.appPath,fileFolder:k.U.Dependencies,watchPaths:["package.json","yarn.lock"],handleFileBuilt:this.handleFileBuilt.bind(this)}),this.dependencyWatcher.start()}async startTscWatcher(){this.tscWatcher=new cy({appPath:this.state.appPath,onErrors:this.handleTypecheckErrors.bind(this)}),await this.tscWatcher.start()}handleTypecheckErrors(s){s.length===0?this.state.addEvent({message:"Typecheck passed",status:"success"}):this.state.applyStepEvents(s.map(r=>({message:`Type error in ${r.file}(${r.line},${r.column}): ${r.text}`,status:"error"}))),this.notify()}}const hy=({manifest:o,builtFileInfos:s})=>{let r=structuredClone(o);for(const[f,{fileFolder:m,checksum:v}]of s.entries()){const E=R.relative(Qe,f);if(m===k.U.BuiltLogicFunction){const b=r.logicFunctions,M=b.findIndex(H=>H.builtHandlerPath===E);if(M===-1)continue;r={...r,logicFunctions:b.map((H,X)=>X===M?{...H,builtHandlerChecksum:v}:H)}}if(m===k.U.PublicAsset){const b=r.publicAssets,M=b.findIndex(H=>H.filePath===E);if(M===-1)continue;r={...r,publicAssets:b.map((H,X)=>X===M?{...H,checksum:v}:H)};continue}if(m===k.U.BuiltFrontComponent){const b=r.frontComponents,M=b.findIndex(H=>H.builtComponentPath===E)??-1;if(M===-1)continue;r={...r,frontComponents:b.map((H,X)=>X===M?{...H,builtComponentChecksum:v}:H)}}m===k.U.Dependencies&&(E==="package.json"&&(r.application.packageJsonChecksum=v),E==="yarn.lock"&&(r.application.yarnLockChecksum=v))}const l=[];for(const[f,{fileFolder:m}]of s.entries()){const v=R.relative(Qe,f);if(m===k.U.Dependencies&&v.startsWith(`${Br}/`)){const E=s.get(f);E&&l.push(E.checksum)}}return l.length>0&&(r.application.apiClientChecksum=Hr.default.createHash("md5").update(l.sort().join("")).digest("hex")),r},gy=async(o,s)=>{const r=Y.default.join(o,Qe);await C.ensureDir(r);const l=Y.default.join(r,"manifest.json");return await C.writeJSON(l,s,{spaces:2}),l},Ol=o=>{if(typeof o=="string")return o;if(hn.default.isAxiosError(o)){const r=[],l=o.response?.status,f=o.response?.statusText;l&&r.push(`HTTP ${l}${f?` ${f}`:""}`);const m=o.response?.data?.errors;if(Array.isArray(m)&&m.length>0){const v=m.map(E=>E.message??"Unknown GraphQL error").join("; ");r.push(v)}else o.response?.data?.message?r.push(o.response.data.message):o.message&&r.push(o.message);return o.code&&r.push(`(${o.code})`),r.join(" - ")||"Unknown Axios error"}if(o instanceof Error)return o.message||o.toString();const s=JSON.stringify(o,null,2);return s==="{}"||s===void 0?String(o):s};class my{constructor({apiService:s,state:r,notify:l}){this.apiService=s,this.state=r,this.notify=l}async execute(s){const r=this.state.steps.syncApplication;r.status="in_progress",this.state.updatePipeline({status:"syncing"});const l=[],f=hy({manifest:s.manifest,builtFileInfos:s.builtFileInfos});l.push({message:"Manifest checksums set",status:"info"}),await gy(s.appPath,f),l.push({message:"Manifest saved to output directory",status:"info"}),l.push({message:"Syncing manifest",status:"info"});const m=await this.apiService.syncApplication(f);if(m.success){l.push({message:"✓ Synced",status:"success"}),r.output={syncStatus:"synced",error:null},r.status="done",this.state.updatePipeline({status:"synced",error:null}),this.state.updateAllEntitiesStatus("success"),this.state.applyStepEvents(l);return}const v=`Sync failed with error: ${Ol(m.error)}`;l.push({message:v,status:"error"}),r.output={syncStatus:"error",error:v},r.status="error",this.state.updatePipeline({status:"error",error:v}),this.state.updateAllEntitiesStatus("error"),this.state.applyStepEvents(l)}}class vy{constructor(s){this.apiService=new Ft,this.applicationUniversalIdentifier=s.applicationUniversalIdentifier,this.appPath=s.appPath}async uploadFile({builtPath:s,fileFolder:r}){const l=R.relative(Qe,s);return await this.apiService.uploadFile({filePath:Y.default.join(this.appPath,s),builtHandlerPath:l,fileFolder:r,applicationUniversalIdentifier:this.applicationUniversalIdentifier})}}const yy=["core/types.ts","core/schema.ts","metadata/types.ts","metadata/schema.ts"];class _y{constructor({state:s,notify:r}){this.state=s,this.notify=r}get isInitialized(){return this.state.steps.uploadFiles.output.fileUploader!==null}initialize(s){const r=this.state.steps.uploadFiles;r.output={...r.output,fileUploader:new vy({appPath:s.appPath,applicationUniversalIdentifier:s.universalIdentifier})},r.status="in_progress",this.notify(),this.uploadPendingFiles()}uploadFile(s,r,l){const f=this.state.steps.uploadFiles;if(!f.output.fileUploader)return;this.state.addEvent({message:`Uploading ${s}`,status:"info"}),this.state.updateEntityStatus(r,"uploading");const m=f.output.fileUploader.uploadFile({builtPath:s,fileFolder:l}).then(v=>{v.success?(this.state.addEvent({message:`Successfully uploaded ${s}`,status:"success"}),this.state.updateEntityStatus(r,"success")):this.state.addEvent({message:`Failed to upload ${s}: ${v.error}`,status:"error"})}).catch(v=>{this.state.addEvent({message:`Upload failed for ${s}: ${v}`,status:"error"})}).finally(()=>{f.output.activeUploads.delete(m)});f.output.activeUploads.add(m)}async waitForUploads(){const s=this.state.steps.uploadFiles;for(;s.output.activeUploads.size>0;)await Promise.all(s.output.activeUploads);s.status="done",this.notify()}async copyAndUploadApiClientFiles(s){const r=R.join(s,"node_modules","twenty-sdk",Gr);if(!await C.pathExists(r))return;const l=R.join(s,Qe,Br);await C.ensureDir(l);for(const f of yy){const m=R.join(r,f);if(!await C.pathExists(m))continue;await C.copy(m,R.join(l,f));const v=await C.readFile(m),E=Hr.default.createHash("md5").update(v).digest("hex"),b=R.join(Qe,Br,f),M=R.join(Br,f);this.state.steps.uploadFiles.output.builtFileInfos.set(b,{checksum:E,builtPath:b,sourcePath:M,fileFolder:k.U.Dependencies}),this.uploadFile(b,M,k.U.Dependencies)}}uploadPendingFiles(){for(const[s,{fileFolder:r,sourcePath:l}]of this.state.steps.uploadFiles.output.builtFileInfos.entries())this.uploadFile(s,l,r)}}class wy{constructor(s){this.syncTimer=null,this.serverCheckInterval=null,this.skipTypecheck=!0,this.debounceMs=s.debounceMs??200,this.state=s.state;const r=new Ft({disableInterceptors:!0}),l=new we;this.clientService=new wv;const f={state:this.state,notify:()=>this.state.notify()};this.checkServerStep=new Bv({...f,apiService:r}),this.ensureValidTokensStep=new jv({...f,apiService:r,configService:l}),this.buildManifestStep=new Mv(f),this.resolveApplicationStep=new Hv({...f,apiService:r}),this.uploadFilesStep=new _y(f),this.generateApiClientStep=new qv({...f,clientService:this.clientService,configService:l}),this.syncApplicationStep=new my({...f,apiService:r}),this.startWatchersStep=new dy({...f,scheduleSync:this.scheduleSync.bind(this),onFileBuilt:this.handleFileBuilt.bind(this),shouldSkipTypecheck:()=>this.skipTypecheck})}async start(){const s=Y.default.join(this.state.appPath,Qe);await C.ensureDir(s),await C.emptyDir(s),await this.clientService.ensureGeneratedClientStub({appPath:this.state.appPath}),await this.startWatchersStep.start(),this.serverCheckInterval=setInterval(()=>{this.checkServerHealth()},2e3)}async close(){this.serverCheckInterval&&clearInterval(this.serverCheckInterval),await this.startWatchersStep.close()}getState(){return this.state}handleFileBuilt(s){this.state.steps.uploadFiles.output.fileUploader&&this.uploadFilesStep.uploadFile(s.builtPath,s.sourcePath,s.fileFolder)}async checkServerHealth(){const s=this.state.steps.checkServer.output.isReady;await this.checkServerStep.execute()&&!s&&this.scheduleSync()}scheduleSync(){this.syncTimer&&clearTimeout(this.syncTimer),this.syncTimer=setTimeout(()=>{this.syncTimer=null,this.performSync()},this.debounceMs)}async performSync(){if(!this.state.pipeline.isSyncing){this.state.updatePipeline({isSyncing:!0});try{await this.runSyncPipeline()}catch(s){this.state.addEvent({message:`Sync failed with error: ${Ol(s)}`,status:"error"}),this.state.updatePipeline({status:"error"}),this.state.updateAllEntitiesStatus("error")}finally{this.state.updatePipeline({isSyncing:!1})}}}async runSyncPipeline(){if(!await this.checkServerStep.execute())return;await this.ensureValidTokensStep.execute({applicationId:this.state.steps.resolveApplication.output.applicationId});const r=await this.buildManifestStep.execute({appPath:this.state.appPath});if(!r||(await this.startWatchersStep.handleWatcherRestarts(r),!this.uploadFilesStep.isInitialized&&!await this.initializePipeline(r.manifest)))return;const l=this.state.hasObjectsOrFieldsChanged(r.manifest);await this.uploadFilesStep.waitForUploads(),await this.syncApplicationStep.execute({manifest:r.manifest,builtFileInfos:this.state.steps.uploadFiles.output.builtFileInfos,appPath:this.state.appPath}),l&&(await this.generateApiClientStep.execute({appPath:this.state.appPath}),this.skipTypecheck=!1,await this.uploadFilesStep.copyAndUploadApiClientFiles(this.state.appPath))}async initializePipeline(s){const r=await this.resolveApplicationStep.execute({manifest:s});return r.applicationId?(await this.ensureValidTokensStep.exchangeTokens({applicationId:r.applicationId}),this.uploadFilesStep.initialize({appPath:this.state.appPath,universalIdentifier:s.application.universalIdentifier}),!0):!1}}const xy={objects:J.Object,fields:J.Field,logicFunctions:J.LogicFunction,frontComponents:J.FrontComponent,roles:J.Role,skills:J.Skill,views:J.View,navigationMenuItems:J.NavigationMenuItem,pageLayouts:J.PageLayout},Ay=200,Sy={pending:["building","uploading","success","error"],building:["pending","uploading","success","error"],uploading:["pending","success","error"],success:["pending","building","uploading","error"],error:["pending","building","uploading","success"]};class Iy{constructor(s){this.eventIdCounter=0,this.appPath=s.appPath,this.frontendUrl=s.frontendUrl,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.entities=new Map,this.events=[]}notify(){this.onChange?.()}updatePipeline(s){Object.assign(this.pipeline,s),this.notify()}applyStepEvents(s){const r=s.map(l=>(this.eventIdCounter+=1,{...l,id:this.eventIdCounter,timestamp:new Date,message:l.message.slice(0,5e3)}));this.events=[...this.events.slice(-(Ay-r.length)),...r]}addEvent(s){this.applyStepEvents([s])}updateEntityStatus(s,r){const l=new Map(this.entities),f=l.get(s);f?.status&&!Sy[f.status].includes(r)||(l.set(s,f?{...f,status:r}:{name:s,path:s,status:r}),this.entities=l)}removeEntity(s){const r=new Map(this.entities);r.delete(s),this.entities=r}updateAllEntitiesStatus(s){const r=new Map(this.entities);for(const[l,f]of r)r.set(l,{...f,status:s});this.entities=r}updateEntitiesFromManifest(s){const r=new Map;for(const[f,m]of Object.entries(s)){const v=xy[f];if(v)for(const E of m)r.set(E,v)}const l=new Map(this.entities);for(const[f,m]of l)l.set(f,{...m,type:r.get(f)});this.entities=l}hasObjectsOrFieldsChanged(s){const r=JSON.stringify({objects:s.objects,fields:s.fields}),l=r!==this.previousObjectsFieldsFingerprint;return this.previousObjectsFieldsFingerprint=r,l}}class Ty{constructor(){this.orchestrator=null,this.unmountUI=null}async close(){this.unmountUI?.(),await this.orchestrator?.close()}async execute(s){const r=s.appPath??Ie,l=new Iy({appPath:r,frontendUrl:process.env.FRONTEND_URL}),f=new vv(l);l.onChange=()=>f.notify();const{unmount:m}=await mv(f);this.unmountUI=m,this.orchestrator=new wy({state:l}),await this.orchestrator.start(),this.setupGracefulShutdown()}setupGracefulShutdown(){const s=()=>void this.close().then(()=>process.exit(0));process.on("SIGINT",s),process.on("SIGTERM",s)}}const Ey=o=>`${S.default.cyan(o.file)}:${S.default.yellow(String(o.line))}:${S.default.yellow(String(o.column+1))} - ${S.default.red("error")} ${o.text}`;class Fy{async execute(s){const r=s.appPath??Ie;console.log(S.default.blue("Running type check...")),console.log(S.default.gray(`App path: ${r}`)),console.log("");const l=await Cl(r);l.length===0&&(console.log(S.default.green("✓ No type errors found")),process.exit(0));for(const f of l)console.log(Ey(f));console.log(""),console.log(S.default.red(`✗ Found ${l.length} type error${l.length===1?"":"s"}`)),process.exit(1)}}const _s=async o=>{const s=Y.default.join(o,Qe);await C.ensureDir(s);const r=Y.default.join(s,"manifest.json");if(!await C.pathExists(r)){const{manifest:l}=await El(o);return l}return await C.readJson(r)};class by{constructor(){this.apiService=new Ft}async execute({appPath:s=Ie,askForConfirmation:r}){try{console.log(S.default.blue("🚀 Uninstall Twenty Application")),console.log(S.default.gray(`📁 App Path: ${s}`)),console.log(""),r&&!await this.confirmationPrompt()&&(console.error(S.default.red("⛔️ Aborting uninstall")),process.exit(1));const l=await _s(s);if(!l)return{success:!1,error:"Build failed"};const f=await this.apiService.uninstallApplication(l.application.universalIdentifier);return f.success===!1?console.error(S.default.red("❌ Uninstall failed:"),f.error):console.log(S.default.green("✅ Application uninstalled successfully")),f}catch(l){throw console.error(S.default.red("Uninstall failed:"),l instanceof Error?l.message:l),l}}async confirmationPrompt(){const{confirmation:s}=await ot.default.prompt([{type:"confirm",name:"confirmation",message:"Are you sure you want to uninstall this application?",default:!1}]);return s}}class Cy{constructor(){this.configService=new we}async execute(){try{const s=await this.configService.getAvailableWorkspaces(),r=await this.configService.getDefaultWorkspace();if(s.length===0){console.log(S.default.yellow("⚠ No workspaces configured. Use `twenty auth:login` to create one."));return}console.log(S.default.blue(`Available workspaces:
660
+ `));for(const l of s){const f=await this.configService.getConfigForWorkspace(l),m=!!f.apiKey,E=l===r?S.default.green(" (default)"):"",b=m?S.default.green("●"):S.default.gray("○");console.log(` ${b} ${l}${E}`),console.log(S.default.gray(` API URL: ${f.apiUrl}`))}console.log(""),console.log(S.default.gray("● = authenticated, ○ = no credentials")),console.log(S.default.gray("Use `twenty auth:switch <workspace>` to change default"))}catch(s){console.error(S.default.red("List failed:"),s instanceof Error?s.message:s),process.exit(1)}}}class Py{constructor(){this.configService=new we,this.apiService=new Ft}async execute(s){try{let{apiKey:r,apiUrl:l}=s;const f=await this.configService.getConfig();if(l||(l=(await ot.default.prompt([{type:"input",name:"apiUrl",message:"Twenty API URL:",default:f.apiUrl,validate:E=>{try{return new URL(E),!0}catch{return"Please enter a valid URL"}}}])).apiUrl),r||(r=(await ot.default.prompt([{type:"password",name:"apiKey",message:"API Key:",mask:"*",validate:E=>E.length>0||"API key is required"}])).apiKey),await this.configService.setConfig({apiUrl:l,apiKey:r}),(await this.apiService.validateAuth()).authValid){const v=we.getActiveWorkspace();console.log(S.default.green(`✓ Successfully authenticated with Twenty (workspace: ${v})`))}else console.log(S.default.red("✗ Authentication failed. Please check your credentials.")),process.exit(1)}catch(r){console.error(S.default.red("Login failed:"),r instanceof Error?r.message:r),process.exit(1)}}}class Ry{constructor(){this.configService=new we}async execute(){try{await this.configService.clearConfig();const s=we.getActiveWorkspace();console.log(S.default.green(`✓ Successfully logged out (workspace: ${s})`))}catch(s){console.error(S.default.red("Logout failed:"),s instanceof Error?s.message:s),process.exit(1)}}}class ky{constructor(){this.configService=new we,this.apiService=new Ft}async execute(){try{const s=we.getActiveWorkspace(),r=await this.configService.getConfig();if(console.log(S.default.blue("Authentication Status:")),console.log(`Workspace: ${s}`),console.log(`API URL: ${r.apiUrl}`),console.log(`API Key: ${r.apiKey?"***"+r.apiKey.slice(-4):"Not set"}`),r.apiKey){const l=await this.apiService.validateAuth();console.log(`Status: ${l.authValid?S.default.green("✓ Valid"):S.default.red("✗ Invalid")}`)}else console.log(`Status: ${S.default.yellow("⚠ Not authenticated")}`)}catch(s){console.error(S.default.red("Status check failed:"),s instanceof Error?s.message:s),process.exit(1)}}}class Oy{constructor(){this.apiService=new Ft}async execute({appPath:s=Ie,postInstall:r=!1,functionUniversalIdentifier:l,functionName:f,payload:m="{}"}){try{let v;try{v=JSON.parse(m)}catch{console.error(S.default.red("Invalid JSON payload. Please provide valid JSON.")),process.exit(1)}const E=await _s(s);E||(console.error(S.default.red("Failed to build manifest.")),process.exit(1));const b=await this.apiService.findLogicFunctions();b.success||(console.error(S.default.red("Failed to fetch functions:"),b.error instanceof Error?b.error.message:b.error),process.exit(1));const M=b.data.filter(ie=>ie.universalIdentifier&&this.belongsToApplication(ie,E)),H=M.find(ie=>r?ie.universalIdentifier===E.application.postInstallLogicFunctionUniversalIdentifier:l?ie.universalIdentifier===l:f?ie.name===f:!1);if(!H){const ie=r?"post install":l||f;console.error(S.default.red(`Function "${ie}" not found in application.`)),console.log(""),M.length>0?(console.log(S.default.cyan("Available functions:")),M.forEach(lt=>{console.log(` - ${S.default.white(lt.name)} (${lt.universalIdentifier})`)})):console.log(S.default.yellow("No functions found for this application. Have you synced your app with `yarn app:dev`?")),process.exit(1)}console.log(S.default.blue(`🚀 Executing function "${H.name}"...`)),console.log(S.default.gray(` Payload: ${JSON.stringify(v)}`)),console.log("");const X=await this.apiService.executeLogicFunction({functionId:H.id,payload:v});X.success||(console.error(S.default.red("Execution failed:"),X.error instanceof Error?X.error.message:X.error),process.exit(1));const U=X.data;console.log(S.default.cyan("─".repeat(60))),console.log(S.default.cyan("Execution Result")),console.log(S.default.cyan("─".repeat(60)));const V=U.status==="SUCCESS"?S.default.green:S.default.red;console.log(`${S.default.bold("Status:")} ${V(U.status)}`),console.log(`${S.default.bold("Duration:")} ${U.duration}ms`),k.o(U.data)&&(console.log(""),console.log(S.default.bold("Data:")),console.log(S.default.white(JSON.stringify(U.data,null,2)))),U.error&&(console.log(""),console.log(S.default.bold.red("Error:")),console.log(S.default.red(` Type: ${U.error.errorType}`)),console.log(S.default.red(` Message: ${U.error.errorMessage}`)),U.error.stackTrace&&(console.log(""),console.log(S.default.gray("Stack trace:")),console.log(S.default.gray(U.error.stackTrace)))),U.logs&&(console.log(""),console.log(S.default.bold("Logs:")),console.log(S.default.gray(U.logs))),console.log(S.default.cyan("─".repeat(60))),U.status!=="SUCCESS"&&process.exit(1)}catch(v){console.error(S.default.red("Execution failed:"),v instanceof Error?v.message:v),process.exit(1)}}belongsToApplication(s,r){return r.logicFunctions.some(l=>l.universalIdentifier===s.universalIdentifier)}}class Ly{constructor(){this.apiService=new Ft}async execute({appPath:s=Ie,functionUniversalIdentifier:r,functionName:l}){try{const f=await _s(s);f||process.exit(1),this.logWatchInfo({appName:f.application.displayName,functionUniversalIdentifier:r,functionName:l}),await this.apiService.subscribeToLogs({applicationUniversalIdentifier:f.application.universalIdentifier,functionUniversalIdentifier:r,functionName:l})}catch(f){console.error(S.default.red("Watch logs failed:"),f instanceof Error?f.message:f),process.exit(1)}}logWatchInfo({appName:s,functionUniversalIdentifier:r,functionName:l}){const f=s??"Twenty Application",m=r||l?`function "${r||l}"`:"functions";console.log(S.default.blue(`🚀 Watching ${f} ${m} logs:`)),console.log("")}}class Ny{constructor(){this.configService=new we,this.apiService=new Ft}async execute(s){try{let{workspace:r}=s;const l=await this.configService.getAvailableWorkspaces(),f=await this.configService.getDefaultWorkspace();if(l.length===0){console.log(S.default.yellow("⚠ No workspaces configured. Use `twenty auth:login` to create one."));return}if(!r){const E=l.map(M=>({name:M===f?`${M} (current default)`:M,value:M}));r=(await ot.default.prompt([{type:"list",name:"workspace",message:"Select a workspace to set as default:",choices:E,default:f}])).workspace}if(l.includes(r)||(console.log(S.default.red(`✗ Workspace "${r}" not found. Available workspaces: ${l.join(", ")}`)),process.exit(1)),r===f){console.log(S.default.blue(`ℹ "${r}" is already the default workspace.`));return}await this.configService.setDefaultWorkspace(r),we.setActiveWorkspace(r);const v=!!(await this.configService.getConfig()).apiKey;console.log(S.default.green(`✓ Switched default workspace to "${r}"`)),v?(await this.apiService.validateAuth()).authValid?console.log(S.default.green("✓ Authentication is valid")):console.log(S.default.yellow("⚠ Authentication credentials exist but are invalid. Run `twenty auth:login` to re-authenticate.")):console.log(S.default.yellow("⚠ No credentials configured for this workspace. Run `twenty auth:login` to authenticate."))}catch(r){console.error(S.default.red("Switch failed:"),r instanceof Error?r.message:r),process.exit(1)}}}const Uy=({name:o,universalIdentifier:s=$e.v4()})=>{const r=Ze.default(o);return`import { defineFrontComponent } from 'twenty-sdk';
355
661
 
356
662
  // React component - implement your UI here
357
663
  const Component = () => {
@@ -369,7 +675,7 @@ export default defineFrontComponent({
369
675
  description: 'Add a description for your front component',
370
676
  component: Component,
371
677
  });
372
- `},Ny=({name:o,universalIdentifier:s=We.v4()})=>{const r=Ze.default(o);return`import { defineLogicFunction } from 'twenty-sdk';
678
+ `},Dy=({name:o,universalIdentifier:s=$e.v4()})=>{const r=Ze.default(o);return`import { defineLogicFunction } from 'twenty-sdk';
373
679
 
374
680
  // Logic function handler - rename and implement your logic
375
681
  const handler = async (params: {
@@ -406,7 +712,7 @@ export default defineLogicFunction({
406
712
  // eventName: 'objectName.created',
407
713
  // },
408
714
  });
409
- `},ll=({name:o,universalIdentifier:s=We.v4(),viewUniversalIdentifier:r})=>{const l=Ze.default(o),p=r?` viewUniversalIdentifier: '${r}',`:` // Link to a view:
715
+ `},cl=({name:o,universalIdentifier:s=$e.v4(),viewUniversalIdentifier:r})=>{const l=Ze.default(o),f=r?` viewUniversalIdentifier: '${r}',`:` // Link to a view:
410
716
  // viewUniversalIdentifier: '...',
411
717
  // Or link to an object:
412
718
  // targetObjectUniversalIdentifier: '...',
@@ -418,7 +724,7 @@ export default defineNavigationMenuItem({
418
724
  name: '${l}',
419
725
  icon: 'IconList',
420
726
  position: 0,
421
- ${p}
727
+ ${f}
422
728
  });
423
729
  `};var Hn={exports:{}};/**
424
730
  * @license
@@ -427,26 +733,26 @@ ${p}
427
733
  * Released under MIT license <https://lodash.com/license>
428
734
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
429
735
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
430
- */var Uy=Hn.exports,ul;function Dy(){return ul||(ul=1,function(o,s){(function(){var r,l="4.17.21",p=200,m="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",v="Expected a function",E="Invalid `variable` option passed into `_.template`",b="__lodash_hash_undefined__",M=500,H="__lodash_placeholder__",X=1,N=2,V=4,ie=1,lt=2,Fe=1,dt=2,vn=4,$e=8,bt=16,Me=32,Ct=64,Be=128,Pt=256,yn=512,ws=30,xs="...",le=800,Jn=16,Pe=1,zn=2,Ss=3,B=1/0,de=9007199254740991,ht=17976931348623157e292,Re=NaN,ve=4294967295,_n=ve-1,Ol=ve>>>1,Ll=[["ary",Be],["bind",Fe],["bindKey",dt],["curry",$e],["curryRight",bt],["flip",yn],["partial",Me],["partialRight",Ct],["rearg",Pt]],Xt="[object Arguments]",Kn="[object Array]",kl="[object AsyncFunction]",wn="[object Boolean]",xn="[object Date]",Nl="[object DOMException]",Vn="[object Error]",Yn="[object Function]",As="[object GeneratorFunction]",et="[object Map]",Sn="[object Number]",Ul="[object Null]",gt="[object Object]",Is="[object Promise]",Dl="[object Proxy]",An="[object RegExp]",tt="[object Set]",In="[object String]",Xn="[object Symbol]",Wl="[object Undefined]",Fn="[object WeakMap]",$l="[object WeakSet]",En="[object ArrayBuffer]",Zt="[object DataView]",Jr="[object Float32Array]",zr="[object Float64Array]",Kr="[object Int8Array]",Vr="[object Int16Array]",Yr="[object Int32Array]",Xr="[object Uint8Array]",Zr="[object Uint8ClampedArray]",Qr="[object Uint16Array]",ei="[object Uint32Array]",Ml=/\b__p \+= '';/g,Bl=/\b(__p \+=) '' \+/g,jl=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Fs=/&(?:amp|lt|gt|quot|#39);/g,Es=/[&<>"']/g,ql=RegExp(Fs.source),Hl=RegExp(Es.source),Gl=/<%-([\s\S]+?)%>/g,Jl=/<%([\s\S]+?)%>/g,Ts=/<%=([\s\S]+?)%>/g,zl=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Kl=/^\w*$/,Vl=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ti=/[\\^$.*+?()[\]{}|]/g,Yl=RegExp(ti.source),ni=/^\s+/,Xl=/\s/,Zl=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ql=/\{\n\/\* \[wrapped with (.+)\] \*/,eu=/,? & /,tu=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,nu=/[()=,{}\[\]\/\s]/,ru=/\\(\\)?/g,iu=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,bs=/\w*$/,su=/^[-+]0x[0-9a-f]+$/i,au=/^0b[01]+$/i,ou=/^\[object .+?Constructor\]$/,lu=/^0o[0-7]+$/i,uu=/^(?:0|[1-9]\d*)$/,cu=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Zn=/($^)/,fu=/['\n\r\u2028\u2029\\]/g,Qn="\\ud800-\\udfff",pu="\\u0300-\\u036f",du="\\ufe20-\\ufe2f",hu="\\u20d0-\\u20ff",Cs=pu+du+hu,Ps="\\u2700-\\u27bf",Rs="a-z\\xdf-\\xf6\\xf8-\\xff",gu="\\xac\\xb1\\xd7\\xf7",mu="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",vu="\\u2000-\\u206f",yu=" \\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",Os="A-Z\\xc0-\\xd6\\xd8-\\xde",Ls="\\ufe0e\\ufe0f",ks=gu+mu+vu+yu,ri="['’]",_u="["+Qn+"]",Ns="["+ks+"]",er="["+Cs+"]",Us="\\d+",wu="["+Ps+"]",Ds="["+Rs+"]",Ws="[^"+Qn+ks+Us+Ps+Rs+Os+"]",ii="\\ud83c[\\udffb-\\udfff]",xu="(?:"+er+"|"+ii+")",$s="[^"+Qn+"]",si="(?:\\ud83c[\\udde6-\\uddff]){2}",ai="[\\ud800-\\udbff][\\udc00-\\udfff]",Qt="["+Os+"]",Ms="\\u200d",Bs="(?:"+Ds+"|"+Ws+")",Su="(?:"+Qt+"|"+Ws+")",js="(?:"+ri+"(?:d|ll|m|re|s|t|ve))?",qs="(?:"+ri+"(?:D|LL|M|RE|S|T|VE))?",Hs=xu+"?",Gs="["+Ls+"]?",Au="(?:"+Ms+"(?:"+[$s,si,ai].join("|")+")"+Gs+Hs+")*",Iu="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Fu="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Js=Gs+Hs+Au,Eu="(?:"+[wu,si,ai].join("|")+")"+Js,Tu="(?:"+[$s+er+"?",er,si,ai,_u].join("|")+")",bu=RegExp(ri,"g"),Cu=RegExp(er,"g"),oi=RegExp(ii+"(?="+ii+")|"+Tu+Js,"g"),Pu=RegExp([Qt+"?"+Ds+"+"+js+"(?="+[Ns,Qt,"$"].join("|")+")",Su+"+"+qs+"(?="+[Ns,Qt+Bs,"$"].join("|")+")",Qt+"?"+Bs+"+"+js,Qt+"+"+qs,Fu,Iu,Us,Eu].join("|"),"g"),Ru=RegExp("["+Ms+Qn+Cs+Ls+"]"),Ou=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Lu=["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"],ku=-1,re={};re[Jr]=re[zr]=re[Kr]=re[Vr]=re[Yr]=re[Xr]=re[Zr]=re[Qr]=re[ei]=!0,re[Xt]=re[Kn]=re[En]=re[wn]=re[Zt]=re[xn]=re[Vn]=re[Yn]=re[et]=re[Sn]=re[gt]=re[An]=re[tt]=re[In]=re[Fn]=!1;var ne={};ne[Xt]=ne[Kn]=ne[En]=ne[Zt]=ne[wn]=ne[xn]=ne[Jr]=ne[zr]=ne[Kr]=ne[Vr]=ne[Yr]=ne[et]=ne[Sn]=ne[gt]=ne[An]=ne[tt]=ne[In]=ne[Xn]=ne[Xr]=ne[Zr]=ne[Qr]=ne[ei]=!0,ne[Vn]=ne[Yn]=ne[Fn]=!1;var Nu={À:"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"},Uu={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Du={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Wu={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},$u=parseFloat,Mu=parseInt,zs=typeof Mr=="object"&&Mr&&Mr.Object===Object&&Mr,Bu=typeof self=="object"&&self&&self.Object===Object&&self,ge=zs||Bu||Function("return this")(),li=s&&!s.nodeType&&s,jt=li&&!0&&o&&!o.nodeType&&o,Ks=jt&&jt.exports===li,ui=Ks&&zs.process,je=function(){try{var h=jt&&jt.require&&jt.require("util").types;return h||ui&&ui.binding&&ui.binding("util")}catch{}}(),Vs=je&&je.isArrayBuffer,Ys=je&&je.isDate,Xs=je&&je.isMap,Zs=je&&je.isRegExp,Qs=je&&je.isSet,ea=je&&je.isTypedArray;function Oe(h,_,y){switch(y.length){case 0:return h.call(_);case 1:return h.call(_,y[0]);case 2:return h.call(_,y[0],y[1]);case 3:return h.call(_,y[0],y[1],y[2])}return h.apply(_,y)}function ju(h,_,y,F){for(var U=-1,Z=h==null?0:h.length;++U<Z;){var fe=h[U];_(F,fe,y(fe),h)}return F}function qe(h,_){for(var y=-1,F=h==null?0:h.length;++y<F&&_(h[y],y,h)!==!1;);return h}function qu(h,_){for(var y=h==null?0:h.length;y--&&_(h[y],y,h)!==!1;);return h}function ta(h,_){for(var y=-1,F=h==null?0:h.length;++y<F;)if(!_(h[y],y,h))return!1;return!0}function Rt(h,_){for(var y=-1,F=h==null?0:h.length,U=0,Z=[];++y<F;){var fe=h[y];_(fe,y,h)&&(Z[U++]=fe)}return Z}function tr(h,_){var y=h==null?0:h.length;return!!y&&en(h,_,0)>-1}function ci(h,_,y){for(var F=-1,U=h==null?0:h.length;++F<U;)if(y(_,h[F]))return!0;return!1}function se(h,_){for(var y=-1,F=h==null?0:h.length,U=Array(F);++y<F;)U[y]=_(h[y],y,h);return U}function Ot(h,_){for(var y=-1,F=_.length,U=h.length;++y<F;)h[U+y]=_[y];return h}function fi(h,_,y,F){var U=-1,Z=h==null?0:h.length;for(F&&Z&&(y=h[++U]);++U<Z;)y=_(y,h[U],U,h);return y}function Hu(h,_,y,F){var U=h==null?0:h.length;for(F&&U&&(y=h[--U]);U--;)y=_(y,h[U],U,h);return y}function pi(h,_){for(var y=-1,F=h==null?0:h.length;++y<F;)if(_(h[y],y,h))return!0;return!1}var Gu=di("length");function Ju(h){return h.split("")}function zu(h){return h.match(tu)||[]}function na(h,_,y){var F;return y(h,function(U,Z,fe){if(_(U,Z,fe))return F=Z,!1}),F}function nr(h,_,y,F){for(var U=h.length,Z=y+(F?1:-1);F?Z--:++Z<U;)if(_(h[Z],Z,h))return Z;return-1}function en(h,_,y){return _===_?sc(h,_,y):nr(h,ra,y)}function Ku(h,_,y,F){for(var U=y-1,Z=h.length;++U<Z;)if(F(h[U],_))return U;return-1}function ra(h){return h!==h}function ia(h,_){var y=h==null?0:h.length;return y?gi(h,_)/y:Re}function di(h){return function(_){return _==null?r:_[h]}}function hi(h){return function(_){return h==null?r:h[_]}}function sa(h,_,y,F,U){return U(h,function(Z,fe,te){y=F?(F=!1,Z):_(y,Z,fe,te)}),y}function Vu(h,_){var y=h.length;for(h.sort(_);y--;)h[y]=h[y].value;return h}function gi(h,_){for(var y,F=-1,U=h.length;++F<U;){var Z=_(h[F]);Z!==r&&(y=y===r?Z:y+Z)}return y}function mi(h,_){for(var y=-1,F=Array(h);++y<h;)F[y]=_(y);return F}function Yu(h,_){return se(_,function(y){return[y,h[y]]})}function aa(h){return h&&h.slice(0,ca(h)+1).replace(ni,"")}function Le(h){return function(_){return h(_)}}function vi(h,_){return se(_,function(y){return h[y]})}function Tn(h,_){return h.has(_)}function oa(h,_){for(var y=-1,F=h.length;++y<F&&en(_,h[y],0)>-1;);return y}function la(h,_){for(var y=h.length;y--&&en(_,h[y],0)>-1;);return y}function Xu(h,_){for(var y=h.length,F=0;y--;)h[y]===_&&++F;return F}var Zu=hi(Nu),Qu=hi(Uu);function ec(h){return"\\"+Wu[h]}function tc(h,_){return h==null?r:h[_]}function tn(h){return Ru.test(h)}function nc(h){return Ou.test(h)}function rc(h){for(var _,y=[];!(_=h.next()).done;)y.push(_.value);return y}function yi(h){var _=-1,y=Array(h.size);return h.forEach(function(F,U){y[++_]=[U,F]}),y}function ua(h,_){return function(y){return h(_(y))}}function Lt(h,_){for(var y=-1,F=h.length,U=0,Z=[];++y<F;){var fe=h[y];(fe===_||fe===H)&&(h[y]=H,Z[U++]=y)}return Z}function rr(h){var _=-1,y=Array(h.size);return h.forEach(function(F){y[++_]=F}),y}function ic(h){var _=-1,y=Array(h.size);return h.forEach(function(F){y[++_]=[F,F]}),y}function sc(h,_,y){for(var F=y-1,U=h.length;++F<U;)if(h[F]===_)return F;return-1}function ac(h,_,y){for(var F=y+1;F--;)if(h[F]===_)return F;return F}function nn(h){return tn(h)?lc(h):Gu(h)}function nt(h){return tn(h)?uc(h):Ju(h)}function ca(h){for(var _=h.length;_--&&Xl.test(h.charAt(_)););return _}var oc=hi(Du);function lc(h){for(var _=oi.lastIndex=0;oi.test(h);)++_;return _}function uc(h){return h.match(oi)||[]}function cc(h){return h.match(Pu)||[]}var fc=function h(_){_=_==null?ge:rn.defaults(ge.Object(),_,rn.pick(ge,Lu));var y=_.Array,F=_.Date,U=_.Error,Z=_.Function,fe=_.Math,te=_.Object,_i=_.RegExp,pc=_.String,He=_.TypeError,ir=y.prototype,dc=Z.prototype,sn=te.prototype,sr=_["__core-js_shared__"],ar=dc.toString,ee=sn.hasOwnProperty,hc=0,fa=function(){var e=/[^.]+$/.exec(sr&&sr.keys&&sr.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),or=sn.toString,gc=ar.call(te),mc=ge._,vc=_i("^"+ar.call(ee).replace(ti,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),lr=Ks?_.Buffer:r,kt=_.Symbol,ur=_.Uint8Array,pa=lr?lr.allocUnsafe:r,cr=ua(te.getPrototypeOf,te),da=te.create,ha=sn.propertyIsEnumerable,fr=ir.splice,ga=kt?kt.isConcatSpreadable:r,bn=kt?kt.iterator:r,qt=kt?kt.toStringTag:r,pr=function(){try{var e=Kt(te,"defineProperty");return e({},"",{}),e}catch{}}(),yc=_.clearTimeout!==ge.clearTimeout&&_.clearTimeout,_c=F&&F.now!==ge.Date.now&&F.now,wc=_.setTimeout!==ge.setTimeout&&_.setTimeout,dr=fe.ceil,hr=fe.floor,wi=te.getOwnPropertySymbols,xc=lr?lr.isBuffer:r,ma=_.isFinite,Sc=ir.join,Ac=ua(te.keys,te),pe=fe.max,ye=fe.min,Ic=F.now,Fc=_.parseInt,va=fe.random,Ec=ir.reverse,xi=Kt(_,"DataView"),Cn=Kt(_,"Map"),Si=Kt(_,"Promise"),an=Kt(_,"Set"),Pn=Kt(_,"WeakMap"),Rn=Kt(te,"create"),gr=Pn&&new Pn,on={},Tc=Vt(xi),bc=Vt(Cn),Cc=Vt(Si),Pc=Vt(an),Rc=Vt(Pn),mr=kt?kt.prototype:r,On=mr?mr.valueOf:r,ya=mr?mr.toString:r;function u(e){if(oe(e)&&!D(e)&&!(e instanceof J)){if(e instanceof Ge)return e;if(ee.call(e,"__wrapped__"))return wo(e)}return new Ge(e)}var ln=function(){function e(){}return function(t){if(!ae(t))return{};if(da)return da(t);e.prototype=t;var n=new e;return e.prototype=r,n}}();function vr(){}function Ge(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}u.templateSettings={escape:Gl,evaluate:Jl,interpolate:Ts,variable:"",imports:{_:u}},u.prototype=vr.prototype,u.prototype.constructor=u,Ge.prototype=ln(vr.prototype),Ge.prototype.constructor=Ge;function J(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ve,this.__views__=[]}function Oc(){var e=new J(this.__wrapped__);return e.__actions__=Ee(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ee(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ee(this.__views__),e}function Lc(){if(this.__filtered__){var e=new J(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function kc(){var e=this.__wrapped__.value(),t=this.__dir__,n=D(e),i=t<0,a=n?e.length:0,c=zf(0,a,this.__views__),f=c.start,d=c.end,g=d-f,w=i?d:f-1,x=this.__iteratees__,S=x.length,I=0,T=ye(g,this.__takeCount__);if(!n||!i&&a==g&&T==g)return ja(e,this.__actions__);var R=[];e:for(;g--&&I<T;){w+=t;for(var j=-1,O=e[w];++j<S;){var G=x[j],z=G.iteratee,Ue=G.type,Ae=z(O);if(Ue==zn)O=Ae;else if(!Ae){if(Ue==Pe)continue e;break e}}R[I++]=O}return R}J.prototype=ln(vr.prototype),J.prototype.constructor=J;function Ht(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Nc(){this.__data__=Rn?Rn(null):{},this.size=0}function Uc(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function Dc(e){var t=this.__data__;if(Rn){var n=t[e];return n===b?r:n}return ee.call(t,e)?t[e]:r}function Wc(e){var t=this.__data__;return Rn?t[e]!==r:ee.call(t,e)}function $c(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Rn&&t===r?b:t,this}Ht.prototype.clear=Nc,Ht.prototype.delete=Uc,Ht.prototype.get=Dc,Ht.prototype.has=Wc,Ht.prototype.set=$c;function mt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Mc(){this.__data__=[],this.size=0}function Bc(e){var t=this.__data__,n=yr(t,e);if(n<0)return!1;var i=t.length-1;return n==i?t.pop():fr.call(t,n,1),--this.size,!0}function jc(e){var t=this.__data__,n=yr(t,e);return n<0?r:t[n][1]}function qc(e){return yr(this.__data__,e)>-1}function Hc(e,t){var n=this.__data__,i=yr(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this}mt.prototype.clear=Mc,mt.prototype.delete=Bc,mt.prototype.get=jc,mt.prototype.has=qc,mt.prototype.set=Hc;function vt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Gc(){this.size=0,this.__data__={hash:new Ht,map:new(Cn||mt),string:new Ht}}function Jc(e){var t=Pr(this,e).delete(e);return this.size-=t?1:0,t}function zc(e){return Pr(this,e).get(e)}function Kc(e){return Pr(this,e).has(e)}function Vc(e,t){var n=Pr(this,e),i=n.size;return n.set(e,t),this.size+=n.size==i?0:1,this}vt.prototype.clear=Gc,vt.prototype.delete=Jc,vt.prototype.get=zc,vt.prototype.has=Kc,vt.prototype.set=Vc;function Gt(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new vt;++t<n;)this.add(e[t])}function Yc(e){return this.__data__.set(e,b),this}function Xc(e){return this.__data__.has(e)}Gt.prototype.add=Gt.prototype.push=Yc,Gt.prototype.has=Xc;function rt(e){var t=this.__data__=new mt(e);this.size=t.size}function Zc(){this.__data__=new mt,this.size=0}function Qc(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function ef(e){return this.__data__.get(e)}function tf(e){return this.__data__.has(e)}function nf(e,t){var n=this.__data__;if(n instanceof mt){var i=n.__data__;if(!Cn||i.length<p-1)return i.push([e,t]),this.size=++n.size,this;n=this.__data__=new vt(i)}return n.set(e,t),this.size=n.size,this}rt.prototype.clear=Zc,rt.prototype.delete=Qc,rt.prototype.get=ef,rt.prototype.has=tf,rt.prototype.set=nf;function _a(e,t){var n=D(e),i=!n&&Yt(e),a=!n&&!i&&$t(e),c=!n&&!i&&!a&&pn(e),f=n||i||a||c,d=f?mi(e.length,pc):[],g=d.length;for(var w in e)(t||ee.call(e,w))&&!(f&&(w=="length"||a&&(w=="offset"||w=="parent")||c&&(w=="buffer"||w=="byteLength"||w=="byteOffset")||xt(w,g)))&&d.push(w);return d}function wa(e){var t=e.length;return t?e[Li(0,t-1)]:r}function rf(e,t){return Rr(Ee(e),Jt(t,0,e.length))}function sf(e){return Rr(Ee(e))}function Ai(e,t,n){(n!==r&&!it(e[t],n)||n===r&&!(t in e))&&yt(e,t,n)}function Ln(e,t,n){var i=e[t];(!(ee.call(e,t)&&it(i,n))||n===r&&!(t in e))&&yt(e,t,n)}function yr(e,t){for(var n=e.length;n--;)if(it(e[n][0],t))return n;return-1}function af(e,t,n,i){return Nt(e,function(a,c,f){t(i,a,n(a),f)}),i}function xa(e,t){return e&&ct(t,he(t),e)}function of(e,t){return e&&ct(t,be(t),e)}function yt(e,t,n){t=="__proto__"&&pr?pr(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function Ii(e,t){for(var n=-1,i=t.length,a=y(i),c=e==null;++n<i;)a[n]=c?r:is(e,t[n]);return a}function Jt(e,t,n){return e===e&&(n!==r&&(e=e<=n?e:n),t!==r&&(e=e>=t?e:t)),e}function Je(e,t,n,i,a,c){var f,d=t&X,g=t&N,w=t&V;if(n&&(f=a?n(e,i,a,c):n(e)),f!==r)return f;if(!ae(e))return e;var x=D(e);if(x){if(f=Vf(e),!d)return Ee(e,f)}else{var S=_e(e),I=S==Yn||S==As;if($t(e))return Ga(e,d);if(S==gt||S==Xt||I&&!a){if(f=g||I?{}:co(e),!d)return g?Wf(e,of(f,e)):Df(e,xa(f,e))}else{if(!ne[S])return a?e:{};f=Yf(e,S,d)}}c||(c=new rt);var T=c.get(e);if(T)return T;c.set(e,f),Mo(e)?e.forEach(function(O){f.add(Je(O,t,n,O,e,c))}):Wo(e)&&e.forEach(function(O,G){f.set(G,Je(O,t,n,G,e,c))});var R=w?g?Hi:qi:g?be:he,j=x?r:R(e);return qe(j||e,function(O,G){j&&(G=O,O=e[G]),Ln(f,G,Je(O,t,n,G,e,c))}),f}function lf(e){var t=he(e);return function(n){return Sa(n,e,t)}}function Sa(e,t,n){var i=n.length;if(e==null)return!i;for(e=te(e);i--;){var a=n[i],c=t[a],f=e[a];if(f===r&&!(a in e)||!c(f))return!1}return!0}function Aa(e,t,n){if(typeof e!="function")throw new He(v);return Mn(function(){e.apply(r,n)},t)}function kn(e,t,n,i){var a=-1,c=tr,f=!0,d=e.length,g=[],w=t.length;if(!d)return g;n&&(t=se(t,Le(n))),i?(c=ci,f=!1):t.length>=p&&(c=Tn,f=!1,t=new Gt(t));e:for(;++a<d;){var x=e[a],S=n==null?x:n(x);if(x=i||x!==0?x:0,f&&S===S){for(var I=w;I--;)if(t[I]===S)continue e;g.push(x)}else c(t,S,i)||g.push(x)}return g}var Nt=Ya(ut),Ia=Ya(Ei,!0);function uf(e,t){var n=!0;return Nt(e,function(i,a,c){return n=!!t(i,a,c),n}),n}function _r(e,t,n){for(var i=-1,a=e.length;++i<a;){var c=e[i],f=t(c);if(f!=null&&(d===r?f===f&&!Ne(f):n(f,d)))var d=f,g=c}return g}function cf(e,t,n,i){var a=e.length;for(n=W(n),n<0&&(n=-n>a?0:a+n),i=i===r||i>a?a:W(i),i<0&&(i+=a),i=n>i?0:jo(i);n<i;)e[n++]=t;return e}function Fa(e,t){var n=[];return Nt(e,function(i,a,c){t(i,a,c)&&n.push(i)}),n}function me(e,t,n,i,a){var c=-1,f=e.length;for(n||(n=Zf),a||(a=[]);++c<f;){var d=e[c];t>0&&n(d)?t>1?me(d,t-1,n,i,a):Ot(a,d):i||(a[a.length]=d)}return a}var Fi=Xa(),Ea=Xa(!0);function ut(e,t){return e&&Fi(e,t,he)}function Ei(e,t){return e&&Ea(e,t,he)}function wr(e,t){return Rt(t,function(n){return St(e[n])})}function zt(e,t){t=Dt(t,e);for(var n=0,i=t.length;e!=null&&n<i;)e=e[ft(t[n++])];return n&&n==i?e:r}function Ta(e,t,n){var i=t(e);return D(e)?i:Ot(i,n(e))}function xe(e){return e==null?e===r?Wl:Ul:qt&&qt in te(e)?Jf(e):sp(e)}function Ti(e,t){return e>t}function ff(e,t){return e!=null&&ee.call(e,t)}function pf(e,t){return e!=null&&t in te(e)}function df(e,t,n){return e>=ye(t,n)&&e<pe(t,n)}function bi(e,t,n){for(var i=n?ci:tr,a=e[0].length,c=e.length,f=c,d=y(c),g=1/0,w=[];f--;){var x=e[f];f&&t&&(x=se(x,Le(t))),g=ye(x.length,g),d[f]=!n&&(t||a>=120&&x.length>=120)?new Gt(f&&x):r}x=e[0];var S=-1,I=d[0];e:for(;++S<a&&w.length<g;){var T=x[S],R=t?t(T):T;if(T=n||T!==0?T:0,!(I?Tn(I,R):i(w,R,n))){for(f=c;--f;){var j=d[f];if(!(j?Tn(j,R):i(e[f],R,n)))continue e}I&&I.push(R),w.push(T)}}return w}function hf(e,t,n,i){return ut(e,function(a,c,f){t(i,n(a),c,f)}),i}function Nn(e,t,n){t=Dt(t,e),e=go(e,t);var i=e==null?e:e[ft(Ke(t))];return i==null?r:Oe(i,e,n)}function ba(e){return oe(e)&&xe(e)==Xt}function gf(e){return oe(e)&&xe(e)==En}function mf(e){return oe(e)&&xe(e)==xn}function Un(e,t,n,i,a){return e===t?!0:e==null||t==null||!oe(e)&&!oe(t)?e!==e&&t!==t:vf(e,t,n,i,Un,a)}function vf(e,t,n,i,a,c){var f=D(e),d=D(t),g=f?Kn:_e(e),w=d?Kn:_e(t);g=g==Xt?gt:g,w=w==Xt?gt:w;var x=g==gt,S=w==gt,I=g==w;if(I&&$t(e)){if(!$t(t))return!1;f=!0,x=!1}if(I&&!x)return c||(c=new rt),f||pn(e)?oo(e,t,n,i,a,c):Hf(e,t,g,n,i,a,c);if(!(n&ie)){var T=x&&ee.call(e,"__wrapped__"),R=S&&ee.call(t,"__wrapped__");if(T||R){var j=T?e.value():e,O=R?t.value():t;return c||(c=new rt),a(j,O,n,i,c)}}return I?(c||(c=new rt),Gf(e,t,n,i,a,c)):!1}function yf(e){return oe(e)&&_e(e)==et}function Ci(e,t,n,i){var a=n.length,c=a,f=!i;if(e==null)return!c;for(e=te(e);a--;){var d=n[a];if(f&&d[2]?d[1]!==e[d[0]]:!(d[0]in e))return!1}for(;++a<c;){d=n[a];var g=d[0],w=e[g],x=d[1];if(f&&d[2]){if(w===r&&!(g in e))return!1}else{var S=new rt;if(i)var I=i(w,x,g,e,t,S);if(!(I===r?Un(x,w,ie|lt,i,S):I))return!1}}return!0}function Ca(e){if(!ae(e)||ep(e))return!1;var t=St(e)?vc:ou;return t.test(Vt(e))}function _f(e){return oe(e)&&xe(e)==An}function wf(e){return oe(e)&&_e(e)==tt}function xf(e){return oe(e)&&Dr(e.length)&&!!re[xe(e)]}function Pa(e){return typeof e=="function"?e:e==null?Ce:typeof e=="object"?D(e)?La(e[0],e[1]):Oa(e):Qo(e)}function Pi(e){if(!$n(e))return Ac(e);var t=[];for(var n in te(e))ee.call(e,n)&&n!="constructor"&&t.push(n);return t}function Sf(e){if(!ae(e))return ip(e);var t=$n(e),n=[];for(var i in e)i=="constructor"&&(t||!ee.call(e,i))||n.push(i);return n}function Ri(e,t){return e<t}function Ra(e,t){var n=-1,i=Te(e)?y(e.length):[];return Nt(e,function(a,c,f){i[++n]=t(a,c,f)}),i}function Oa(e){var t=Ji(e);return t.length==1&&t[0][2]?po(t[0][0],t[0][1]):function(n){return n===e||Ci(n,e,t)}}function La(e,t){return Ki(e)&&fo(t)?po(ft(e),t):function(n){var i=is(n,e);return i===r&&i===t?ss(n,e):Un(t,i,ie|lt)}}function xr(e,t,n,i,a){e!==t&&Fi(t,function(c,f){if(a||(a=new rt),ae(c))Af(e,t,f,n,xr,i,a);else{var d=i?i(Yi(e,f),c,f+"",e,t,a):r;d===r&&(d=c),Ai(e,f,d)}},be)}function Af(e,t,n,i,a,c,f){var d=Yi(e,n),g=Yi(t,n),w=f.get(g);if(w){Ai(e,n,w);return}var x=c?c(d,g,n+"",e,t,f):r,S=x===r;if(S){var I=D(g),T=!I&&$t(g),R=!I&&!T&&pn(g);x=g,I||T||R?D(d)?x=d:ue(d)?x=Ee(d):T?(S=!1,x=Ga(g,!0)):R?(S=!1,x=Ja(g,!0)):x=[]:Bn(g)||Yt(g)?(x=d,Yt(d)?x=qo(d):(!ae(d)||St(d))&&(x=co(g))):S=!1}S&&(f.set(g,x),a(x,g,i,c,f),f.delete(g)),Ai(e,n,x)}function ka(e,t){var n=e.length;if(n)return t+=t<0?n:0,xt(t,n)?e[t]:r}function Na(e,t,n){t.length?t=se(t,function(c){return D(c)?function(f){return zt(f,c.length===1?c[0]:c)}:c}):t=[Ce];var i=-1;t=se(t,Le(C()));var a=Ra(e,function(c,f,d){var g=se(t,function(w){return w(c)});return{criteria:g,index:++i,value:c}});return Vu(a,function(c,f){return Uf(c,f,n)})}function If(e,t){return Ua(e,t,function(n,i){return ss(e,i)})}function Ua(e,t,n){for(var i=-1,a=t.length,c={};++i<a;){var f=t[i],d=zt(e,f);n(d,f)&&Dn(c,Dt(f,e),d)}return c}function Ff(e){return function(t){return zt(t,e)}}function Oi(e,t,n,i){var a=i?Ku:en,c=-1,f=t.length,d=e;for(e===t&&(t=Ee(t)),n&&(d=se(e,Le(n)));++c<f;)for(var g=0,w=t[c],x=n?n(w):w;(g=a(d,x,g,i))>-1;)d!==e&&fr.call(d,g,1),fr.call(e,g,1);return e}function Da(e,t){for(var n=e?t.length:0,i=n-1;n--;){var a=t[n];if(n==i||a!==c){var c=a;xt(a)?fr.call(e,a,1):Ui(e,a)}}return e}function Li(e,t){return e+hr(va()*(t-e+1))}function Ef(e,t,n,i){for(var a=-1,c=pe(dr((t-e)/(n||1)),0),f=y(c);c--;)f[i?c:++a]=e,e+=n;return f}function ki(e,t){var n="";if(!e||t<1||t>de)return n;do t%2&&(n+=e),t=hr(t/2),t&&(e+=e);while(t);return n}function q(e,t){return Xi(ho(e,t,Ce),e+"")}function Tf(e){return wa(dn(e))}function bf(e,t){var n=dn(e);return Rr(n,Jt(t,0,n.length))}function Dn(e,t,n,i){if(!ae(e))return e;t=Dt(t,e);for(var a=-1,c=t.length,f=c-1,d=e;d!=null&&++a<c;){var g=ft(t[a]),w=n;if(g==="__proto__"||g==="constructor"||g==="prototype")return e;if(a!=f){var x=d[g];w=i?i(x,g,d):r,w===r&&(w=ae(x)?x:xt(t[a+1])?[]:{})}Ln(d,g,w),d=d[g]}return e}var Wa=gr?function(e,t){return gr.set(e,t),e}:Ce,Cf=pr?function(e,t){return pr(e,"toString",{configurable:!0,enumerable:!1,value:os(t),writable:!0})}:Ce;function Pf(e){return Rr(dn(e))}function ze(e,t,n){var i=-1,a=e.length;t<0&&(t=-t>a?0:a+t),n=n>a?a:n,n<0&&(n+=a),a=t>n?0:n-t>>>0,t>>>=0;for(var c=y(a);++i<a;)c[i]=e[i+t];return c}function Rf(e,t){var n;return Nt(e,function(i,a,c){return n=t(i,a,c),!n}),!!n}function Sr(e,t,n){var i=0,a=e==null?i:e.length;if(typeof t=="number"&&t===t&&a<=Ol){for(;i<a;){var c=i+a>>>1,f=e[c];f!==null&&!Ne(f)&&(n?f<=t:f<t)?i=c+1:a=c}return a}return Ni(e,t,Ce,n)}function Ni(e,t,n,i){var a=0,c=e==null?0:e.length;if(c===0)return 0;t=n(t);for(var f=t!==t,d=t===null,g=Ne(t),w=t===r;a<c;){var x=hr((a+c)/2),S=n(e[x]),I=S!==r,T=S===null,R=S===S,j=Ne(S);if(f)var O=i||R;else w?O=R&&(i||I):d?O=R&&I&&(i||!T):g?O=R&&I&&!T&&(i||!j):T||j?O=!1:O=i?S<=t:S<t;O?a=x+1:c=x}return ye(c,_n)}function $a(e,t){for(var n=-1,i=e.length,a=0,c=[];++n<i;){var f=e[n],d=t?t(f):f;if(!n||!it(d,g)){var g=d;c[a++]=f===0?0:f}}return c}function Ma(e){return typeof e=="number"?e:Ne(e)?Re:+e}function ke(e){if(typeof e=="string")return e;if(D(e))return se(e,ke)+"";if(Ne(e))return ya?ya.call(e):"";var t=e+"";return t=="0"&&1/e==-B?"-0":t}function Ut(e,t,n){var i=-1,a=tr,c=e.length,f=!0,d=[],g=d;if(n)f=!1,a=ci;else if(c>=p){var w=t?null:jf(e);if(w)return rr(w);f=!1,a=Tn,g=new Gt}else g=t?[]:d;e:for(;++i<c;){var x=e[i],S=t?t(x):x;if(x=n||x!==0?x:0,f&&S===S){for(var I=g.length;I--;)if(g[I]===S)continue e;t&&g.push(S),d.push(x)}else a(g,S,n)||(g!==d&&g.push(S),d.push(x))}return d}function Ui(e,t){return t=Dt(t,e),e=go(e,t),e==null||delete e[ft(Ke(t))]}function Ba(e,t,n,i){return Dn(e,t,n(zt(e,t)),i)}function Ar(e,t,n,i){for(var a=e.length,c=i?a:-1;(i?c--:++c<a)&&t(e[c],c,e););return n?ze(e,i?0:c,i?c+1:a):ze(e,i?c+1:0,i?a:c)}function ja(e,t){var n=e;return n instanceof J&&(n=n.value()),fi(t,function(i,a){return a.func.apply(a.thisArg,Ot([i],a.args))},n)}function Di(e,t,n){var i=e.length;if(i<2)return i?Ut(e[0]):[];for(var a=-1,c=y(i);++a<i;)for(var f=e[a],d=-1;++d<i;)d!=a&&(c[a]=kn(c[a]||f,e[d],t,n));return Ut(me(c,1),t,n)}function qa(e,t,n){for(var i=-1,a=e.length,c=t.length,f={};++i<a;){var d=i<c?t[i]:r;n(f,e[i],d)}return f}function Wi(e){return ue(e)?e:[]}function $i(e){return typeof e=="function"?e:Ce}function Dt(e,t){return D(e)?e:Ki(e,t)?[e]:_o(Q(e))}var Of=q;function Wt(e,t,n){var i=e.length;return n=n===r?i:n,!t&&n>=i?e:ze(e,t,n)}var Ha=yc||function(e){return ge.clearTimeout(e)};function Ga(e,t){if(t)return e.slice();var n=e.length,i=pa?pa(n):new e.constructor(n);return e.copy(i),i}function Mi(e){var t=new e.constructor(e.byteLength);return new ur(t).set(new ur(e)),t}function Lf(e,t){var n=t?Mi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function kf(e){var t=new e.constructor(e.source,bs.exec(e));return t.lastIndex=e.lastIndex,t}function Nf(e){return On?te(On.call(e)):{}}function Ja(e,t){var n=t?Mi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function za(e,t){if(e!==t){var n=e!==r,i=e===null,a=e===e,c=Ne(e),f=t!==r,d=t===null,g=t===t,w=Ne(t);if(!d&&!w&&!c&&e>t||c&&f&&g&&!d&&!w||i&&f&&g||!n&&g||!a)return 1;if(!i&&!c&&!w&&e<t||w&&n&&a&&!i&&!c||d&&n&&a||!f&&a||!g)return-1}return 0}function Uf(e,t,n){for(var i=-1,a=e.criteria,c=t.criteria,f=a.length,d=n.length;++i<f;){var g=za(a[i],c[i]);if(g){if(i>=d)return g;var w=n[i];return g*(w=="desc"?-1:1)}}return e.index-t.index}function Ka(e,t,n,i){for(var a=-1,c=e.length,f=n.length,d=-1,g=t.length,w=pe(c-f,0),x=y(g+w),S=!i;++d<g;)x[d]=t[d];for(;++a<f;)(S||a<c)&&(x[n[a]]=e[a]);for(;w--;)x[d++]=e[a++];return x}function Va(e,t,n,i){for(var a=-1,c=e.length,f=-1,d=n.length,g=-1,w=t.length,x=pe(c-d,0),S=y(x+w),I=!i;++a<x;)S[a]=e[a];for(var T=a;++g<w;)S[T+g]=t[g];for(;++f<d;)(I||a<c)&&(S[T+n[f]]=e[a++]);return S}function Ee(e,t){var n=-1,i=e.length;for(t||(t=y(i));++n<i;)t[n]=e[n];return t}function ct(e,t,n,i){var a=!n;n||(n={});for(var c=-1,f=t.length;++c<f;){var d=t[c],g=i?i(n[d],e[d],d,n,e):r;g===r&&(g=e[d]),a?yt(n,d,g):Ln(n,d,g)}return n}function Df(e,t){return ct(e,zi(e),t)}function Wf(e,t){return ct(e,lo(e),t)}function Ir(e,t){return function(n,i){var a=D(n)?ju:af,c=t?t():{};return a(n,e,C(i,2),c)}}function un(e){return q(function(t,n){var i=-1,a=n.length,c=a>1?n[a-1]:r,f=a>2?n[2]:r;for(c=e.length>3&&typeof c=="function"?(a--,c):r,f&&Se(n[0],n[1],f)&&(c=a<3?r:c,a=1),t=te(t);++i<a;){var d=n[i];d&&e(t,d,i,c)}return t})}function Ya(e,t){return function(n,i){if(n==null)return n;if(!Te(n))return e(n,i);for(var a=n.length,c=t?a:-1,f=te(n);(t?c--:++c<a)&&i(f[c],c,f)!==!1;);return n}}function Xa(e){return function(t,n,i){for(var a=-1,c=te(t),f=i(t),d=f.length;d--;){var g=f[e?d:++a];if(n(c[g],g,c)===!1)break}return t}}function $f(e,t,n){var i=t&Fe,a=Wn(e);function c(){var f=this&&this!==ge&&this instanceof c?a:e;return f.apply(i?n:this,arguments)}return c}function Za(e){return function(t){t=Q(t);var n=tn(t)?nt(t):r,i=n?n[0]:t.charAt(0),a=n?Wt(n,1).join(""):t.slice(1);return i[e]()+a}}function cn(e){return function(t){return fi(Xo(Yo(t).replace(bu,"")),e,"")}}function Wn(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=ln(e.prototype),i=e.apply(n,t);return ae(i)?i:n}}function Mf(e,t,n){var i=Wn(e);function a(){for(var c=arguments.length,f=y(c),d=c,g=fn(a);d--;)f[d]=arguments[d];var w=c<3&&f[0]!==g&&f[c-1]!==g?[]:Lt(f,g);if(c-=w.length,c<n)return ro(e,t,Fr,a.placeholder,r,f,w,r,r,n-c);var x=this&&this!==ge&&this instanceof a?i:e;return Oe(x,this,f)}return a}function Qa(e){return function(t,n,i){var a=te(t);if(!Te(t)){var c=C(n,3);t=he(t),n=function(d){return c(a[d],d,a)}}var f=e(t,n,i);return f>-1?a[c?t[f]:f]:r}}function eo(e){return wt(function(t){var n=t.length,i=n,a=Ge.prototype.thru;for(e&&t.reverse();i--;){var c=t[i];if(typeof c!="function")throw new He(v);if(a&&!f&&Cr(c)=="wrapper")var f=new Ge([],!0)}for(i=f?i:n;++i<n;){c=t[i];var d=Cr(c),g=d=="wrapper"?Gi(c):r;g&&Vi(g[0])&&g[1]==(Be|$e|Me|Pt)&&!g[4].length&&g[9]==1?f=f[Cr(g[0])].apply(f,g[3]):f=c.length==1&&Vi(c)?f[d]():f.thru(c)}return function(){var w=arguments,x=w[0];if(f&&w.length==1&&D(x))return f.plant(x).value();for(var S=0,I=n?t[S].apply(this,w):x;++S<n;)I=t[S].call(this,I);return I}})}function Fr(e,t,n,i,a,c,f,d,g,w){var x=t&Be,S=t&Fe,I=t&dt,T=t&($e|bt),R=t&yn,j=I?r:Wn(e);function O(){for(var G=arguments.length,z=y(G),Ue=G;Ue--;)z[Ue]=arguments[Ue];if(T)var Ae=fn(O),De=Xu(z,Ae);if(i&&(z=Ka(z,i,a,T)),c&&(z=Va(z,c,f,T)),G-=De,T&&G<w){var ce=Lt(z,Ae);return ro(e,t,Fr,O.placeholder,n,z,ce,d,g,w-G)}var st=S?n:this,It=I?st[e]:e;return G=z.length,d?z=ap(z,d):R&&G>1&&z.reverse(),x&&g<G&&(z.length=g),this&&this!==ge&&this instanceof O&&(It=j||Wn(It)),It.apply(st,z)}return O}function to(e,t){return function(n,i){return hf(n,e,t(i),{})}}function Er(e,t){return function(n,i){var a;if(n===r&&i===r)return t;if(n!==r&&(a=n),i!==r){if(a===r)return i;typeof n=="string"||typeof i=="string"?(n=ke(n),i=ke(i)):(n=Ma(n),i=Ma(i)),a=e(n,i)}return a}}function Bi(e){return wt(function(t){return t=se(t,Le(C())),q(function(n){var i=this;return e(t,function(a){return Oe(a,i,n)})})})}function Tr(e,t){t=t===r?" ":ke(t);var n=t.length;if(n<2)return n?ki(t,e):t;var i=ki(t,dr(e/nn(t)));return tn(t)?Wt(nt(i),0,e).join(""):i.slice(0,e)}function Bf(e,t,n,i){var a=t&Fe,c=Wn(e);function f(){for(var d=-1,g=arguments.length,w=-1,x=i.length,S=y(x+g),I=this&&this!==ge&&this instanceof f?c:e;++w<x;)S[w]=i[w];for(;g--;)S[w++]=arguments[++d];return Oe(I,a?n:this,S)}return f}function no(e){return function(t,n,i){return i&&typeof i!="number"&&Se(t,n,i)&&(n=i=r),t=At(t),n===r?(n=t,t=0):n=At(n),i=i===r?t<n?1:-1:At(i),Ef(t,n,i,e)}}function br(e){return function(t,n){return typeof t=="string"&&typeof n=="string"||(t=Ve(t),n=Ve(n)),e(t,n)}}function ro(e,t,n,i,a,c,f,d,g,w){var x=t&$e,S=x?f:r,I=x?r:f,T=x?c:r,R=x?r:c;t|=x?Me:Ct,t&=~(x?Ct:Me),t&vn||(t&=-4);var j=[e,t,a,T,S,R,I,d,g,w],O=n.apply(r,j);return Vi(e)&&mo(O,j),O.placeholder=i,vo(O,e,t)}function ji(e){var t=fe[e];return function(n,i){if(n=Ve(n),i=i==null?0:ye(W(i),292),i&&ma(n)){var a=(Q(n)+"e").split("e"),c=t(a[0]+"e"+(+a[1]+i));return a=(Q(c)+"e").split("e"),+(a[0]+"e"+(+a[1]-i))}return t(n)}}var jf=an&&1/rr(new an([,-0]))[1]==B?function(e){return new an(e)}:cs;function io(e){return function(t){var n=_e(t);return n==et?yi(t):n==tt?ic(t):Yu(t,e(t))}}function _t(e,t,n,i,a,c,f,d){var g=t&dt;if(!g&&typeof e!="function")throw new He(v);var w=i?i.length:0;if(w||(t&=-97,i=a=r),f=f===r?f:pe(W(f),0),d=d===r?d:W(d),w-=a?a.length:0,t&Ct){var x=i,S=a;i=a=r}var I=g?r:Gi(e),T=[e,t,n,i,a,x,S,c,f,d];if(I&&rp(T,I),e=T[0],t=T[1],n=T[2],i=T[3],a=T[4],d=T[9]=T[9]===r?g?0:e.length:pe(T[9]-w,0),!d&&t&($e|bt)&&(t&=-25),!t||t==Fe)var R=$f(e,t,n);else t==$e||t==bt?R=Mf(e,t,d):(t==Me||t==(Fe|Me))&&!a.length?R=Bf(e,t,n,i):R=Fr.apply(r,T);var j=I?Wa:mo;return vo(j(R,T),e,t)}function so(e,t,n,i){return e===r||it(e,sn[n])&&!ee.call(i,n)?t:e}function ao(e,t,n,i,a,c){return ae(e)&&ae(t)&&(c.set(t,e),xr(e,t,r,ao,c),c.delete(t)),e}function qf(e){return Bn(e)?r:e}function oo(e,t,n,i,a,c){var f=n&ie,d=e.length,g=t.length;if(d!=g&&!(f&&g>d))return!1;var w=c.get(e),x=c.get(t);if(w&&x)return w==t&&x==e;var S=-1,I=!0,T=n&lt?new Gt:r;for(c.set(e,t),c.set(t,e);++S<d;){var R=e[S],j=t[S];if(i)var O=f?i(j,R,S,t,e,c):i(R,j,S,e,t,c);if(O!==r){if(O)continue;I=!1;break}if(T){if(!pi(t,function(G,z){if(!Tn(T,z)&&(R===G||a(R,G,n,i,c)))return T.push(z)})){I=!1;break}}else if(!(R===j||a(R,j,n,i,c))){I=!1;break}}return c.delete(e),c.delete(t),I}function Hf(e,t,n,i,a,c,f){switch(n){case Zt:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case En:return!(e.byteLength!=t.byteLength||!c(new ur(e),new ur(t)));case wn:case xn:case Sn:return it(+e,+t);case Vn:return e.name==t.name&&e.message==t.message;case An:case In:return e==t+"";case et:var d=yi;case tt:var g=i&ie;if(d||(d=rr),e.size!=t.size&&!g)return!1;var w=f.get(e);if(w)return w==t;i|=lt,f.set(e,t);var x=oo(d(e),d(t),i,a,c,f);return f.delete(e),x;case Xn:if(On)return On.call(e)==On.call(t)}return!1}function Gf(e,t,n,i,a,c){var f=n&ie,d=qi(e),g=d.length,w=qi(t),x=w.length;if(g!=x&&!f)return!1;for(var S=g;S--;){var I=d[S];if(!(f?I in t:ee.call(t,I)))return!1}var T=c.get(e),R=c.get(t);if(T&&R)return T==t&&R==e;var j=!0;c.set(e,t),c.set(t,e);for(var O=f;++S<g;){I=d[S];var G=e[I],z=t[I];if(i)var Ue=f?i(z,G,I,t,e,c):i(G,z,I,e,t,c);if(!(Ue===r?G===z||a(G,z,n,i,c):Ue)){j=!1;break}O||(O=I=="constructor")}if(j&&!O){var Ae=e.constructor,De=t.constructor;Ae!=De&&"constructor"in e&&"constructor"in t&&!(typeof Ae=="function"&&Ae instanceof Ae&&typeof De=="function"&&De instanceof De)&&(j=!1)}return c.delete(e),c.delete(t),j}function wt(e){return Xi(ho(e,r,Ao),e+"")}function qi(e){return Ta(e,he,zi)}function Hi(e){return Ta(e,be,lo)}var Gi=gr?function(e){return gr.get(e)}:cs;function Cr(e){for(var t=e.name+"",n=on[t],i=ee.call(on,t)?n.length:0;i--;){var a=n[i],c=a.func;if(c==null||c==e)return a.name}return t}function fn(e){var t=ee.call(u,"placeholder")?u:e;return t.placeholder}function C(){var e=u.iteratee||ls;return e=e===ls?Pa:e,arguments.length?e(arguments[0],arguments[1]):e}function Pr(e,t){var n=e.__data__;return Qf(t)?n[typeof t=="string"?"string":"hash"]:n.map}function Ji(e){for(var t=he(e),n=t.length;n--;){var i=t[n],a=e[i];t[n]=[i,a,fo(a)]}return t}function Kt(e,t){var n=tc(e,t);return Ca(n)?n:r}function Jf(e){var t=ee.call(e,qt),n=e[qt];try{e[qt]=r;var i=!0}catch{}var a=or.call(e);return i&&(t?e[qt]=n:delete e[qt]),a}var zi=wi?function(e){return e==null?[]:(e=te(e),Rt(wi(e),function(t){return ha.call(e,t)}))}:fs,lo=wi?function(e){for(var t=[];e;)Ot(t,zi(e)),e=cr(e);return t}:fs,_e=xe;(xi&&_e(new xi(new ArrayBuffer(1)))!=Zt||Cn&&_e(new Cn)!=et||Si&&_e(Si.resolve())!=Is||an&&_e(new an)!=tt||Pn&&_e(new Pn)!=Fn)&&(_e=function(e){var t=xe(e),n=t==gt?e.constructor:r,i=n?Vt(n):"";if(i)switch(i){case Tc:return Zt;case bc:return et;case Cc:return Is;case Pc:return tt;case Rc:return Fn}return t});function zf(e,t,n){for(var i=-1,a=n.length;++i<a;){var c=n[i],f=c.size;switch(c.type){case"drop":e+=f;break;case"dropRight":t-=f;break;case"take":t=ye(t,e+f);break;case"takeRight":e=pe(e,t-f);break}}return{start:e,end:t}}function Kf(e){var t=e.match(Ql);return t?t[1].split(eu):[]}function uo(e,t,n){t=Dt(t,e);for(var i=-1,a=t.length,c=!1;++i<a;){var f=ft(t[i]);if(!(c=e!=null&&n(e,f)))break;e=e[f]}return c||++i!=a?c:(a=e==null?0:e.length,!!a&&Dr(a)&&xt(f,a)&&(D(e)||Yt(e)))}function Vf(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]=="string"&&ee.call(e,"index")&&(n.index=e.index,n.input=e.input),n}function co(e){return typeof e.constructor=="function"&&!$n(e)?ln(cr(e)):{}}function Yf(e,t,n){var i=e.constructor;switch(t){case En:return Mi(e);case wn:case xn:return new i(+e);case Zt:return Lf(e,n);case Jr:case zr:case Kr:case Vr:case Yr:case Xr:case Zr:case Qr:case ei:return Ja(e,n);case et:return new i;case Sn:case In:return new i(e);case An:return kf(e);case tt:return new i;case Xn:return Nf(e)}}function Xf(e,t){var n=t.length;if(!n)return e;var i=n-1;return t[i]=(n>1?"& ":"")+t[i],t=t.join(n>2?", ":" "),e.replace(Zl,`{
736
+ */var $y=Hn.exports,fl;function Wy(){return fl||(fl=1,function(o,s){(function(){var r,l="4.17.21",f=200,m="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",v="Expected a function",E="Invalid `variable` option passed into `_.template`",b="__lodash_hash_undefined__",M=500,H="__lodash_placeholder__",X=1,U=2,V=4,ie=1,lt=2,Te=1,dt=2,vn=4,We=8,bt=16,Me=32,Ct=64,Be=128,Pt=256,yn=512,ws=30,xs="...",le=800,zn=16,Pe=1,Kn=2,As=3,B=1/0,de=9007199254740991,ht=17976931348623157e292,Re=NaN,ve=4294967295,_n=ve-1,Ll=ve>>>1,Nl=[["ary",Be],["bind",Te],["bindKey",dt],["curry",We],["curryRight",bt],["flip",yn],["partial",Me],["partialRight",Ct],["rearg",Pt]],Xt="[object Arguments]",Jn="[object Array]",Ul="[object AsyncFunction]",wn="[object Boolean]",xn="[object Date]",Dl="[object DOMException]",Vn="[object Error]",Yn="[object Function]",Ss="[object GeneratorFunction]",et="[object Map]",An="[object Number]",$l="[object Null]",gt="[object Object]",Is="[object Promise]",Wl="[object Proxy]",Sn="[object RegExp]",tt="[object Set]",In="[object String]",Xn="[object Symbol]",Ml="[object Undefined]",Tn="[object WeakMap]",Bl="[object WeakSet]",En="[object ArrayBuffer]",Zt="[object DataView]",zr="[object Float32Array]",Kr="[object Float64Array]",Jr="[object Int8Array]",Vr="[object Int16Array]",Yr="[object Int32Array]",Xr="[object Uint8Array]",Zr="[object Uint8ClampedArray]",Qr="[object Uint16Array]",ei="[object Uint32Array]",jl=/\b__p \+= '';/g,ql=/\b(__p \+=) '' \+/g,Hl=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ts=/&(?:amp|lt|gt|quot|#39);/g,Es=/[&<>"']/g,Gl=RegExp(Ts.source),zl=RegExp(Es.source),Kl=/<%-([\s\S]+?)%>/g,Jl=/<%([\s\S]+?)%>/g,Fs=/<%=([\s\S]+?)%>/g,Vl=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Yl=/^\w*$/,Xl=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ti=/[\\^$.*+?()[\]{}|]/g,Zl=RegExp(ti.source),ni=/^\s+/,Ql=/\s/,eu=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,tu=/\{\n\/\* \[wrapped with (.+)\] \*/,nu=/,? & /,ru=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,iu=/[()=,{}\[\]\/\s]/,su=/\\(\\)?/g,au=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,bs=/\w*$/,ou=/^[-+]0x[0-9a-f]+$/i,lu=/^0b[01]+$/i,uu=/^\[object .+?Constructor\]$/,cu=/^0o[0-7]+$/i,fu=/^(?:0|[1-9]\d*)$/,pu=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Zn=/($^)/,du=/['\n\r\u2028\u2029\\]/g,Qn="\\ud800-\\udfff",hu="\\u0300-\\u036f",gu="\\ufe20-\\ufe2f",mu="\\u20d0-\\u20ff",Cs=hu+gu+mu,Ps="\\u2700-\\u27bf",Rs="a-z\\xdf-\\xf6\\xf8-\\xff",vu="\\xac\\xb1\\xd7\\xf7",yu="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",_u="\\u2000-\\u206f",wu=" \\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",ks="A-Z\\xc0-\\xd6\\xd8-\\xde",Os="\\ufe0e\\ufe0f",Ls=vu+yu+_u+wu,ri="['’]",xu="["+Qn+"]",Ns="["+Ls+"]",er="["+Cs+"]",Us="\\d+",Au="["+Ps+"]",Ds="["+Rs+"]",$s="[^"+Qn+Ls+Us+Ps+Rs+ks+"]",ii="\\ud83c[\\udffb-\\udfff]",Su="(?:"+er+"|"+ii+")",Ws="[^"+Qn+"]",si="(?:\\ud83c[\\udde6-\\uddff]){2}",ai="[\\ud800-\\udbff][\\udc00-\\udfff]",Qt="["+ks+"]",Ms="\\u200d",Bs="(?:"+Ds+"|"+$s+")",Iu="(?:"+Qt+"|"+$s+")",js="(?:"+ri+"(?:d|ll|m|re|s|t|ve))?",qs="(?:"+ri+"(?:D|LL|M|RE|S|T|VE))?",Hs=Su+"?",Gs="["+Os+"]?",Tu="(?:"+Ms+"(?:"+[Ws,si,ai].join("|")+")"+Gs+Hs+")*",Eu="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Fu="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",zs=Gs+Hs+Tu,bu="(?:"+[Au,si,ai].join("|")+")"+zs,Cu="(?:"+[Ws+er+"?",er,si,ai,xu].join("|")+")",Pu=RegExp(ri,"g"),Ru=RegExp(er,"g"),oi=RegExp(ii+"(?="+ii+")|"+Cu+zs,"g"),ku=RegExp([Qt+"?"+Ds+"+"+js+"(?="+[Ns,Qt,"$"].join("|")+")",Iu+"+"+qs+"(?="+[Ns,Qt+Bs,"$"].join("|")+")",Qt+"?"+Bs+"+"+js,Qt+"+"+qs,Fu,Eu,Us,bu].join("|"),"g"),Ou=RegExp("["+Ms+Qn+Cs+Os+"]"),Lu=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Nu=["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"],Uu=-1,re={};re[zr]=re[Kr]=re[Jr]=re[Vr]=re[Yr]=re[Xr]=re[Zr]=re[Qr]=re[ei]=!0,re[Xt]=re[Jn]=re[En]=re[wn]=re[Zt]=re[xn]=re[Vn]=re[Yn]=re[et]=re[An]=re[gt]=re[Sn]=re[tt]=re[In]=re[Tn]=!1;var ne={};ne[Xt]=ne[Jn]=ne[En]=ne[Zt]=ne[wn]=ne[xn]=ne[zr]=ne[Kr]=ne[Jr]=ne[Vr]=ne[Yr]=ne[et]=ne[An]=ne[gt]=ne[Sn]=ne[tt]=ne[In]=ne[Xn]=ne[Xr]=ne[Zr]=ne[Qr]=ne[ei]=!0,ne[Vn]=ne[Yn]=ne[Tn]=!1;var Du={À:"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"},$u={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Wu={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Mu={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Bu=parseFloat,ju=parseInt,Ks=typeof Mr=="object"&&Mr&&Mr.Object===Object&&Mr,qu=typeof self=="object"&&self&&self.Object===Object&&self,ge=Ks||qu||Function("return this")(),li=s&&!s.nodeType&&s,jt=li&&!0&&o&&!o.nodeType&&o,Js=jt&&jt.exports===li,ui=Js&&Ks.process,je=function(){try{var h=jt&&jt.require&&jt.require("util").types;return h||ui&&ui.binding&&ui.binding("util")}catch{}}(),Vs=je&&je.isArrayBuffer,Ys=je&&je.isDate,Xs=je&&je.isMap,Zs=je&&je.isRegExp,Qs=je&&je.isSet,ea=je&&je.isTypedArray;function ke(h,_,y){switch(y.length){case 0:return h.call(_);case 1:return h.call(_,y[0]);case 2:return h.call(_,y[0],y[1]);case 3:return h.call(_,y[0],y[1],y[2])}return h.apply(_,y)}function Hu(h,_,y,T){for(var D=-1,Z=h==null?0:h.length;++D<Z;){var fe=h[D];_(T,fe,y(fe),h)}return T}function qe(h,_){for(var y=-1,T=h==null?0:h.length;++y<T&&_(h[y],y,h)!==!1;);return h}function Gu(h,_){for(var y=h==null?0:h.length;y--&&_(h[y],y,h)!==!1;);return h}function ta(h,_){for(var y=-1,T=h==null?0:h.length;++y<T;)if(!_(h[y],y,h))return!1;return!0}function Rt(h,_){for(var y=-1,T=h==null?0:h.length,D=0,Z=[];++y<T;){var fe=h[y];_(fe,y,h)&&(Z[D++]=fe)}return Z}function tr(h,_){var y=h==null?0:h.length;return!!y&&en(h,_,0)>-1}function ci(h,_,y){for(var T=-1,D=h==null?0:h.length;++T<D;)if(y(_,h[T]))return!0;return!1}function se(h,_){for(var y=-1,T=h==null?0:h.length,D=Array(T);++y<T;)D[y]=_(h[y],y,h);return D}function kt(h,_){for(var y=-1,T=_.length,D=h.length;++y<T;)h[D+y]=_[y];return h}function fi(h,_,y,T){var D=-1,Z=h==null?0:h.length;for(T&&Z&&(y=h[++D]);++D<Z;)y=_(y,h[D],D,h);return y}function zu(h,_,y,T){var D=h==null?0:h.length;for(T&&D&&(y=h[--D]);D--;)y=_(y,h[D],D,h);return y}function pi(h,_){for(var y=-1,T=h==null?0:h.length;++y<T;)if(_(h[y],y,h))return!0;return!1}var Ku=di("length");function Ju(h){return h.split("")}function Vu(h){return h.match(ru)||[]}function na(h,_,y){var T;return y(h,function(D,Z,fe){if(_(D,Z,fe))return T=Z,!1}),T}function nr(h,_,y,T){for(var D=h.length,Z=y+(T?1:-1);T?Z--:++Z<D;)if(_(h[Z],Z,h))return Z;return-1}function en(h,_,y){return _===_?oc(h,_,y):nr(h,ra,y)}function Yu(h,_,y,T){for(var D=y-1,Z=h.length;++D<Z;)if(T(h[D],_))return D;return-1}function ra(h){return h!==h}function ia(h,_){var y=h==null?0:h.length;return y?gi(h,_)/y:Re}function di(h){return function(_){return _==null?r:_[h]}}function hi(h){return function(_){return h==null?r:h[_]}}function sa(h,_,y,T,D){return D(h,function(Z,fe,te){y=T?(T=!1,Z):_(y,Z,fe,te)}),y}function Xu(h,_){var y=h.length;for(h.sort(_);y--;)h[y]=h[y].value;return h}function gi(h,_){for(var y,T=-1,D=h.length;++T<D;){var Z=_(h[T]);Z!==r&&(y=y===r?Z:y+Z)}return y}function mi(h,_){for(var y=-1,T=Array(h);++y<h;)T[y]=_(y);return T}function Zu(h,_){return se(_,function(y){return[y,h[y]]})}function aa(h){return h&&h.slice(0,ca(h)+1).replace(ni,"")}function Oe(h){return function(_){return h(_)}}function vi(h,_){return se(_,function(y){return h[y]})}function Fn(h,_){return h.has(_)}function oa(h,_){for(var y=-1,T=h.length;++y<T&&en(_,h[y],0)>-1;);return y}function la(h,_){for(var y=h.length;y--&&en(_,h[y],0)>-1;);return y}function Qu(h,_){for(var y=h.length,T=0;y--;)h[y]===_&&++T;return T}var ec=hi(Du),tc=hi($u);function nc(h){return"\\"+Mu[h]}function rc(h,_){return h==null?r:h[_]}function tn(h){return Ou.test(h)}function ic(h){return Lu.test(h)}function sc(h){for(var _,y=[];!(_=h.next()).done;)y.push(_.value);return y}function yi(h){var _=-1,y=Array(h.size);return h.forEach(function(T,D){y[++_]=[D,T]}),y}function ua(h,_){return function(y){return h(_(y))}}function Ot(h,_){for(var y=-1,T=h.length,D=0,Z=[];++y<T;){var fe=h[y];(fe===_||fe===H)&&(h[y]=H,Z[D++]=y)}return Z}function rr(h){var _=-1,y=Array(h.size);return h.forEach(function(T){y[++_]=T}),y}function ac(h){var _=-1,y=Array(h.size);return h.forEach(function(T){y[++_]=[T,T]}),y}function oc(h,_,y){for(var T=y-1,D=h.length;++T<D;)if(h[T]===_)return T;return-1}function lc(h,_,y){for(var T=y+1;T--;)if(h[T]===_)return T;return T}function nn(h){return tn(h)?cc(h):Ku(h)}function nt(h){return tn(h)?fc(h):Ju(h)}function ca(h){for(var _=h.length;_--&&Ql.test(h.charAt(_)););return _}var uc=hi(Wu);function cc(h){for(var _=oi.lastIndex=0;oi.test(h);)++_;return _}function fc(h){return h.match(oi)||[]}function pc(h){return h.match(ku)||[]}var dc=function h(_){_=_==null?ge:rn.defaults(ge.Object(),_,rn.pick(ge,Nu));var y=_.Array,T=_.Date,D=_.Error,Z=_.Function,fe=_.Math,te=_.Object,_i=_.RegExp,hc=_.String,He=_.TypeError,ir=y.prototype,gc=Z.prototype,sn=te.prototype,sr=_["__core-js_shared__"],ar=gc.toString,ee=sn.hasOwnProperty,mc=0,fa=function(){var e=/[^.]+$/.exec(sr&&sr.keys&&sr.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),or=sn.toString,vc=ar.call(te),yc=ge._,_c=_i("^"+ar.call(ee).replace(ti,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),lr=Js?_.Buffer:r,Lt=_.Symbol,ur=_.Uint8Array,pa=lr?lr.allocUnsafe:r,cr=ua(te.getPrototypeOf,te),da=te.create,ha=sn.propertyIsEnumerable,fr=ir.splice,ga=Lt?Lt.isConcatSpreadable:r,bn=Lt?Lt.iterator:r,qt=Lt?Lt.toStringTag:r,pr=function(){try{var e=Jt(te,"defineProperty");return e({},"",{}),e}catch{}}(),wc=_.clearTimeout!==ge.clearTimeout&&_.clearTimeout,xc=T&&T.now!==ge.Date.now&&T.now,Ac=_.setTimeout!==ge.setTimeout&&_.setTimeout,dr=fe.ceil,hr=fe.floor,wi=te.getOwnPropertySymbols,Sc=lr?lr.isBuffer:r,ma=_.isFinite,Ic=ir.join,Tc=ua(te.keys,te),pe=fe.max,ye=fe.min,Ec=T.now,Fc=_.parseInt,va=fe.random,bc=ir.reverse,xi=Jt(_,"DataView"),Cn=Jt(_,"Map"),Ai=Jt(_,"Promise"),an=Jt(_,"Set"),Pn=Jt(_,"WeakMap"),Rn=Jt(te,"create"),gr=Pn&&new Pn,on={},Cc=Vt(xi),Pc=Vt(Cn),Rc=Vt(Ai),kc=Vt(an),Oc=Vt(Pn),mr=Lt?Lt.prototype:r,kn=mr?mr.valueOf:r,ya=mr?mr.toString:r;function u(e){if(oe(e)&&!$(e)&&!(e instanceof z)){if(e instanceof Ge)return e;if(ee.call(e,"__wrapped__"))return wo(e)}return new Ge(e)}var ln=function(){function e(){}return function(t){if(!ae(t))return{};if(da)return da(t);e.prototype=t;var n=new e;return e.prototype=r,n}}();function vr(){}function Ge(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}u.templateSettings={escape:Kl,evaluate:Jl,interpolate:Fs,variable:"",imports:{_:u}},u.prototype=vr.prototype,u.prototype.constructor=u,Ge.prototype=ln(vr.prototype),Ge.prototype.constructor=Ge;function z(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ve,this.__views__=[]}function Lc(){var e=new z(this.__wrapped__);return e.__actions__=Ee(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ee(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ee(this.__views__),e}function Nc(){if(this.__filtered__){var e=new z(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Uc(){var e=this.__wrapped__.value(),t=this.__dir__,n=$(e),i=t<0,a=n?e.length:0,c=Vf(0,a,this.__views__),p=c.start,d=c.end,g=d-p,w=i?d:p-1,x=this.__iteratees__,A=x.length,I=0,F=ye(g,this.__takeCount__);if(!n||!i&&a==g&&F==g)return ja(e,this.__actions__);var O=[];e:for(;g--&&I<F;){w+=t;for(var j=-1,L=e[w];++j<A;){var G=x[j],K=G.iteratee,Ue=G.type,Se=K(L);if(Ue==Kn)L=Se;else if(!Se){if(Ue==Pe)continue e;break e}}O[I++]=L}return O}z.prototype=ln(vr.prototype),z.prototype.constructor=z;function Ht(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Dc(){this.__data__=Rn?Rn(null):{},this.size=0}function $c(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function Wc(e){var t=this.__data__;if(Rn){var n=t[e];return n===b?r:n}return ee.call(t,e)?t[e]:r}function Mc(e){var t=this.__data__;return Rn?t[e]!==r:ee.call(t,e)}function Bc(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Rn&&t===r?b:t,this}Ht.prototype.clear=Dc,Ht.prototype.delete=$c,Ht.prototype.get=Wc,Ht.prototype.has=Mc,Ht.prototype.set=Bc;function mt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function jc(){this.__data__=[],this.size=0}function qc(e){var t=this.__data__,n=yr(t,e);if(n<0)return!1;var i=t.length-1;return n==i?t.pop():fr.call(t,n,1),--this.size,!0}function Hc(e){var t=this.__data__,n=yr(t,e);return n<0?r:t[n][1]}function Gc(e){return yr(this.__data__,e)>-1}function zc(e,t){var n=this.__data__,i=yr(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this}mt.prototype.clear=jc,mt.prototype.delete=qc,mt.prototype.get=Hc,mt.prototype.has=Gc,mt.prototype.set=zc;function vt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Kc(){this.size=0,this.__data__={hash:new Ht,map:new(Cn||mt),string:new Ht}}function Jc(e){var t=Pr(this,e).delete(e);return this.size-=t?1:0,t}function Vc(e){return Pr(this,e).get(e)}function Yc(e){return Pr(this,e).has(e)}function Xc(e,t){var n=Pr(this,e),i=n.size;return n.set(e,t),this.size+=n.size==i?0:1,this}vt.prototype.clear=Kc,vt.prototype.delete=Jc,vt.prototype.get=Vc,vt.prototype.has=Yc,vt.prototype.set=Xc;function Gt(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new vt;++t<n;)this.add(e[t])}function Zc(e){return this.__data__.set(e,b),this}function Qc(e){return this.__data__.has(e)}Gt.prototype.add=Gt.prototype.push=Zc,Gt.prototype.has=Qc;function rt(e){var t=this.__data__=new mt(e);this.size=t.size}function ef(){this.__data__=new mt,this.size=0}function tf(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function nf(e){return this.__data__.get(e)}function rf(e){return this.__data__.has(e)}function sf(e,t){var n=this.__data__;if(n instanceof mt){var i=n.__data__;if(!Cn||i.length<f-1)return i.push([e,t]),this.size=++n.size,this;n=this.__data__=new vt(i)}return n.set(e,t),this.size=n.size,this}rt.prototype.clear=ef,rt.prototype.delete=tf,rt.prototype.get=nf,rt.prototype.has=rf,rt.prototype.set=sf;function _a(e,t){var n=$(e),i=!n&&Yt(e),a=!n&&!i&&Wt(e),c=!n&&!i&&!a&&pn(e),p=n||i||a||c,d=p?mi(e.length,hc):[],g=d.length;for(var w in e)(t||ee.call(e,w))&&!(p&&(w=="length"||a&&(w=="offset"||w=="parent")||c&&(w=="buffer"||w=="byteLength"||w=="byteOffset")||xt(w,g)))&&d.push(w);return d}function wa(e){var t=e.length;return t?e[Oi(0,t-1)]:r}function af(e,t){return Rr(Ee(e),zt(t,0,e.length))}function of(e){return Rr(Ee(e))}function Si(e,t,n){(n!==r&&!it(e[t],n)||n===r&&!(t in e))&&yt(e,t,n)}function On(e,t,n){var i=e[t];(!(ee.call(e,t)&&it(i,n))||n===r&&!(t in e))&&yt(e,t,n)}function yr(e,t){for(var n=e.length;n--;)if(it(e[n][0],t))return n;return-1}function lf(e,t,n,i){return Nt(e,function(a,c,p){t(i,a,n(a),p)}),i}function xa(e,t){return e&&ct(t,he(t),e)}function uf(e,t){return e&&ct(t,be(t),e)}function yt(e,t,n){t=="__proto__"&&pr?pr(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function Ii(e,t){for(var n=-1,i=t.length,a=y(i),c=e==null;++n<i;)a[n]=c?r:is(e,t[n]);return a}function zt(e,t,n){return e===e&&(n!==r&&(e=e<=n?e:n),t!==r&&(e=e>=t?e:t)),e}function ze(e,t,n,i,a,c){var p,d=t&X,g=t&U,w=t&V;if(n&&(p=a?n(e,i,a,c):n(e)),p!==r)return p;if(!ae(e))return e;var x=$(e);if(x){if(p=Xf(e),!d)return Ee(e,p)}else{var A=_e(e),I=A==Yn||A==Ss;if(Wt(e))return Ga(e,d);if(A==gt||A==Xt||I&&!a){if(p=g||I?{}:co(e),!d)return g?Mf(e,uf(p,e)):Wf(e,xa(p,e))}else{if(!ne[A])return a?e:{};p=Zf(e,A,d)}}c||(c=new rt);var F=c.get(e);if(F)return F;c.set(e,p),Mo(e)?e.forEach(function(L){p.add(ze(L,t,n,L,e,c))}):$o(e)&&e.forEach(function(L,G){p.set(G,ze(L,t,n,G,e,c))});var O=w?g?Hi:qi:g?be:he,j=x?r:O(e);return qe(j||e,function(L,G){j&&(G=L,L=e[G]),On(p,G,ze(L,t,n,G,e,c))}),p}function cf(e){var t=he(e);return function(n){return Aa(n,e,t)}}function Aa(e,t,n){var i=n.length;if(e==null)return!i;for(e=te(e);i--;){var a=n[i],c=t[a],p=e[a];if(p===r&&!(a in e)||!c(p))return!1}return!0}function Sa(e,t,n){if(typeof e!="function")throw new He(v);return Mn(function(){e.apply(r,n)},t)}function Ln(e,t,n,i){var a=-1,c=tr,p=!0,d=e.length,g=[],w=t.length;if(!d)return g;n&&(t=se(t,Oe(n))),i?(c=ci,p=!1):t.length>=f&&(c=Fn,p=!1,t=new Gt(t));e:for(;++a<d;){var x=e[a],A=n==null?x:n(x);if(x=i||x!==0?x:0,p&&A===A){for(var I=w;I--;)if(t[I]===A)continue e;g.push(x)}else c(t,A,i)||g.push(x)}return g}var Nt=Ya(ut),Ia=Ya(Ei,!0);function ff(e,t){var n=!0;return Nt(e,function(i,a,c){return n=!!t(i,a,c),n}),n}function _r(e,t,n){for(var i=-1,a=e.length;++i<a;){var c=e[i],p=t(c);if(p!=null&&(d===r?p===p&&!Ne(p):n(p,d)))var d=p,g=c}return g}function pf(e,t,n,i){var a=e.length;for(n=W(n),n<0&&(n=-n>a?0:a+n),i=i===r||i>a?a:W(i),i<0&&(i+=a),i=n>i?0:jo(i);n<i;)e[n++]=t;return e}function Ta(e,t){var n=[];return Nt(e,function(i,a,c){t(i,a,c)&&n.push(i)}),n}function me(e,t,n,i,a){var c=-1,p=e.length;for(n||(n=ep),a||(a=[]);++c<p;){var d=e[c];t>0&&n(d)?t>1?me(d,t-1,n,i,a):kt(a,d):i||(a[a.length]=d)}return a}var Ti=Xa(),Ea=Xa(!0);function ut(e,t){return e&&Ti(e,t,he)}function Ei(e,t){return e&&Ea(e,t,he)}function wr(e,t){return Rt(t,function(n){return At(e[n])})}function Kt(e,t){t=Dt(t,e);for(var n=0,i=t.length;e!=null&&n<i;)e=e[ft(t[n++])];return n&&n==i?e:r}function Fa(e,t,n){var i=t(e);return $(e)?i:kt(i,n(e))}function xe(e){return e==null?e===r?Ml:$l:qt&&qt in te(e)?Jf(e):op(e)}function Fi(e,t){return e>t}function df(e,t){return e!=null&&ee.call(e,t)}function hf(e,t){return e!=null&&t in te(e)}function gf(e,t,n){return e>=ye(t,n)&&e<pe(t,n)}function bi(e,t,n){for(var i=n?ci:tr,a=e[0].length,c=e.length,p=c,d=y(c),g=1/0,w=[];p--;){var x=e[p];p&&t&&(x=se(x,Oe(t))),g=ye(x.length,g),d[p]=!n&&(t||a>=120&&x.length>=120)?new Gt(p&&x):r}x=e[0];var A=-1,I=d[0];e:for(;++A<a&&w.length<g;){var F=x[A],O=t?t(F):F;if(F=n||F!==0?F:0,!(I?Fn(I,O):i(w,O,n))){for(p=c;--p;){var j=d[p];if(!(j?Fn(j,O):i(e[p],O,n)))continue e}I&&I.push(O),w.push(F)}}return w}function mf(e,t,n,i){return ut(e,function(a,c,p){t(i,n(a),c,p)}),i}function Nn(e,t,n){t=Dt(t,e),e=go(e,t);var i=e==null?e:e[ft(Je(t))];return i==null?r:ke(i,e,n)}function ba(e){return oe(e)&&xe(e)==Xt}function vf(e){return oe(e)&&xe(e)==En}function yf(e){return oe(e)&&xe(e)==xn}function Un(e,t,n,i,a){return e===t?!0:e==null||t==null||!oe(e)&&!oe(t)?e!==e&&t!==t:_f(e,t,n,i,Un,a)}function _f(e,t,n,i,a,c){var p=$(e),d=$(t),g=p?Jn:_e(e),w=d?Jn:_e(t);g=g==Xt?gt:g,w=w==Xt?gt:w;var x=g==gt,A=w==gt,I=g==w;if(I&&Wt(e)){if(!Wt(t))return!1;p=!0,x=!1}if(I&&!x)return c||(c=new rt),p||pn(e)?oo(e,t,n,i,a,c):zf(e,t,g,n,i,a,c);if(!(n&ie)){var F=x&&ee.call(e,"__wrapped__"),O=A&&ee.call(t,"__wrapped__");if(F||O){var j=F?e.value():e,L=O?t.value():t;return c||(c=new rt),a(j,L,n,i,c)}}return I?(c||(c=new rt),Kf(e,t,n,i,a,c)):!1}function wf(e){return oe(e)&&_e(e)==et}function Ci(e,t,n,i){var a=n.length,c=a,p=!i;if(e==null)return!c;for(e=te(e);a--;){var d=n[a];if(p&&d[2]?d[1]!==e[d[0]]:!(d[0]in e))return!1}for(;++a<c;){d=n[a];var g=d[0],w=e[g],x=d[1];if(p&&d[2]){if(w===r&&!(g in e))return!1}else{var A=new rt;if(i)var I=i(w,x,g,e,t,A);if(!(I===r?Un(x,w,ie|lt,i,A):I))return!1}}return!0}function Ca(e){if(!ae(e)||np(e))return!1;var t=At(e)?_c:uu;return t.test(Vt(e))}function xf(e){return oe(e)&&xe(e)==Sn}function Af(e){return oe(e)&&_e(e)==tt}function Sf(e){return oe(e)&&Dr(e.length)&&!!re[xe(e)]}function Pa(e){return typeof e=="function"?e:e==null?Ce:typeof e=="object"?$(e)?Oa(e[0],e[1]):ka(e):Qo(e)}function Pi(e){if(!Wn(e))return Tc(e);var t=[];for(var n in te(e))ee.call(e,n)&&n!="constructor"&&t.push(n);return t}function If(e){if(!ae(e))return ap(e);var t=Wn(e),n=[];for(var i in e)i=="constructor"&&(t||!ee.call(e,i))||n.push(i);return n}function Ri(e,t){return e<t}function Ra(e,t){var n=-1,i=Fe(e)?y(e.length):[];return Nt(e,function(a,c,p){i[++n]=t(a,c,p)}),i}function ka(e){var t=zi(e);return t.length==1&&t[0][2]?po(t[0][0],t[0][1]):function(n){return n===e||Ci(n,e,t)}}function Oa(e,t){return Ji(e)&&fo(t)?po(ft(e),t):function(n){var i=is(n,e);return i===r&&i===t?ss(n,e):Un(t,i,ie|lt)}}function xr(e,t,n,i,a){e!==t&&Ti(t,function(c,p){if(a||(a=new rt),ae(c))Tf(e,t,p,n,xr,i,a);else{var d=i?i(Yi(e,p),c,p+"",e,t,a):r;d===r&&(d=c),Si(e,p,d)}},be)}function Tf(e,t,n,i,a,c,p){var d=Yi(e,n),g=Yi(t,n),w=p.get(g);if(w){Si(e,n,w);return}var x=c?c(d,g,n+"",e,t,p):r,A=x===r;if(A){var I=$(g),F=!I&&Wt(g),O=!I&&!F&&pn(g);x=g,I||F||O?$(d)?x=d:ue(d)?x=Ee(d):F?(A=!1,x=Ga(g,!0)):O?(A=!1,x=za(g,!0)):x=[]:Bn(g)||Yt(g)?(x=d,Yt(d)?x=qo(d):(!ae(d)||At(d))&&(x=co(g))):A=!1}A&&(p.set(g,x),a(x,g,i,c,p),p.delete(g)),Si(e,n,x)}function La(e,t){var n=e.length;if(n)return t+=t<0?n:0,xt(t,n)?e[t]:r}function Na(e,t,n){t.length?t=se(t,function(c){return $(c)?function(p){return Kt(p,c.length===1?c[0]:c)}:c}):t=[Ce];var i=-1;t=se(t,Oe(P()));var a=Ra(e,function(c,p,d){var g=se(t,function(w){return w(c)});return{criteria:g,index:++i,value:c}});return Xu(a,function(c,p){return $f(c,p,n)})}function Ef(e,t){return Ua(e,t,function(n,i){return ss(e,i)})}function Ua(e,t,n){for(var i=-1,a=t.length,c={};++i<a;){var p=t[i],d=Kt(e,p);n(d,p)&&Dn(c,Dt(p,e),d)}return c}function Ff(e){return function(t){return Kt(t,e)}}function ki(e,t,n,i){var a=i?Yu:en,c=-1,p=t.length,d=e;for(e===t&&(t=Ee(t)),n&&(d=se(e,Oe(n)));++c<p;)for(var g=0,w=t[c],x=n?n(w):w;(g=a(d,x,g,i))>-1;)d!==e&&fr.call(d,g,1),fr.call(e,g,1);return e}function Da(e,t){for(var n=e?t.length:0,i=n-1;n--;){var a=t[n];if(n==i||a!==c){var c=a;xt(a)?fr.call(e,a,1):Ui(e,a)}}return e}function Oi(e,t){return e+hr(va()*(t-e+1))}function bf(e,t,n,i){for(var a=-1,c=pe(dr((t-e)/(n||1)),0),p=y(c);c--;)p[i?c:++a]=e,e+=n;return p}function Li(e,t){var n="";if(!e||t<1||t>de)return n;do t%2&&(n+=e),t=hr(t/2),t&&(e+=e);while(t);return n}function q(e,t){return Xi(ho(e,t,Ce),e+"")}function Cf(e){return wa(dn(e))}function Pf(e,t){var n=dn(e);return Rr(n,zt(t,0,n.length))}function Dn(e,t,n,i){if(!ae(e))return e;t=Dt(t,e);for(var a=-1,c=t.length,p=c-1,d=e;d!=null&&++a<c;){var g=ft(t[a]),w=n;if(g==="__proto__"||g==="constructor"||g==="prototype")return e;if(a!=p){var x=d[g];w=i?i(x,g,d):r,w===r&&(w=ae(x)?x:xt(t[a+1])?[]:{})}On(d,g,w),d=d[g]}return e}var $a=gr?function(e,t){return gr.set(e,t),e}:Ce,Rf=pr?function(e,t){return pr(e,"toString",{configurable:!0,enumerable:!1,value:os(t),writable:!0})}:Ce;function kf(e){return Rr(dn(e))}function Ke(e,t,n){var i=-1,a=e.length;t<0&&(t=-t>a?0:a+t),n=n>a?a:n,n<0&&(n+=a),a=t>n?0:n-t>>>0,t>>>=0;for(var c=y(a);++i<a;)c[i]=e[i+t];return c}function Of(e,t){var n;return Nt(e,function(i,a,c){return n=t(i,a,c),!n}),!!n}function Ar(e,t,n){var i=0,a=e==null?i:e.length;if(typeof t=="number"&&t===t&&a<=Ll){for(;i<a;){var c=i+a>>>1,p=e[c];p!==null&&!Ne(p)&&(n?p<=t:p<t)?i=c+1:a=c}return a}return Ni(e,t,Ce,n)}function Ni(e,t,n,i){var a=0,c=e==null?0:e.length;if(c===0)return 0;t=n(t);for(var p=t!==t,d=t===null,g=Ne(t),w=t===r;a<c;){var x=hr((a+c)/2),A=n(e[x]),I=A!==r,F=A===null,O=A===A,j=Ne(A);if(p)var L=i||O;else w?L=O&&(i||I):d?L=O&&I&&(i||!F):g?L=O&&I&&!F&&(i||!j):F||j?L=!1:L=i?A<=t:A<t;L?a=x+1:c=x}return ye(c,_n)}function Wa(e,t){for(var n=-1,i=e.length,a=0,c=[];++n<i;){var p=e[n],d=t?t(p):p;if(!n||!it(d,g)){var g=d;c[a++]=p===0?0:p}}return c}function Ma(e){return typeof e=="number"?e:Ne(e)?Re:+e}function Le(e){if(typeof e=="string")return e;if($(e))return se(e,Le)+"";if(Ne(e))return ya?ya.call(e):"";var t=e+"";return t=="0"&&1/e==-B?"-0":t}function Ut(e,t,n){var i=-1,a=tr,c=e.length,p=!0,d=[],g=d;if(n)p=!1,a=ci;else if(c>=f){var w=t?null:Hf(e);if(w)return rr(w);p=!1,a=Fn,g=new Gt}else g=t?[]:d;e:for(;++i<c;){var x=e[i],A=t?t(x):x;if(x=n||x!==0?x:0,p&&A===A){for(var I=g.length;I--;)if(g[I]===A)continue e;t&&g.push(A),d.push(x)}else a(g,A,n)||(g!==d&&g.push(A),d.push(x))}return d}function Ui(e,t){return t=Dt(t,e),e=go(e,t),e==null||delete e[ft(Je(t))]}function Ba(e,t,n,i){return Dn(e,t,n(Kt(e,t)),i)}function Sr(e,t,n,i){for(var a=e.length,c=i?a:-1;(i?c--:++c<a)&&t(e[c],c,e););return n?Ke(e,i?0:c,i?c+1:a):Ke(e,i?c+1:0,i?a:c)}function ja(e,t){var n=e;return n instanceof z&&(n=n.value()),fi(t,function(i,a){return a.func.apply(a.thisArg,kt([i],a.args))},n)}function Di(e,t,n){var i=e.length;if(i<2)return i?Ut(e[0]):[];for(var a=-1,c=y(i);++a<i;)for(var p=e[a],d=-1;++d<i;)d!=a&&(c[a]=Ln(c[a]||p,e[d],t,n));return Ut(me(c,1),t,n)}function qa(e,t,n){for(var i=-1,a=e.length,c=t.length,p={};++i<a;){var d=i<c?t[i]:r;n(p,e[i],d)}return p}function $i(e){return ue(e)?e:[]}function Wi(e){return typeof e=="function"?e:Ce}function Dt(e,t){return $(e)?e:Ji(e,t)?[e]:_o(Q(e))}var Lf=q;function $t(e,t,n){var i=e.length;return n=n===r?i:n,!t&&n>=i?e:Ke(e,t,n)}var Ha=wc||function(e){return ge.clearTimeout(e)};function Ga(e,t){if(t)return e.slice();var n=e.length,i=pa?pa(n):new e.constructor(n);return e.copy(i),i}function Mi(e){var t=new e.constructor(e.byteLength);return new ur(t).set(new ur(e)),t}function Nf(e,t){var n=t?Mi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function Uf(e){var t=new e.constructor(e.source,bs.exec(e));return t.lastIndex=e.lastIndex,t}function Df(e){return kn?te(kn.call(e)):{}}function za(e,t){var n=t?Mi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Ka(e,t){if(e!==t){var n=e!==r,i=e===null,a=e===e,c=Ne(e),p=t!==r,d=t===null,g=t===t,w=Ne(t);if(!d&&!w&&!c&&e>t||c&&p&&g&&!d&&!w||i&&p&&g||!n&&g||!a)return 1;if(!i&&!c&&!w&&e<t||w&&n&&a&&!i&&!c||d&&n&&a||!p&&a||!g)return-1}return 0}function $f(e,t,n){for(var i=-1,a=e.criteria,c=t.criteria,p=a.length,d=n.length;++i<p;){var g=Ka(a[i],c[i]);if(g){if(i>=d)return g;var w=n[i];return g*(w=="desc"?-1:1)}}return e.index-t.index}function Ja(e,t,n,i){for(var a=-1,c=e.length,p=n.length,d=-1,g=t.length,w=pe(c-p,0),x=y(g+w),A=!i;++d<g;)x[d]=t[d];for(;++a<p;)(A||a<c)&&(x[n[a]]=e[a]);for(;w--;)x[d++]=e[a++];return x}function Va(e,t,n,i){for(var a=-1,c=e.length,p=-1,d=n.length,g=-1,w=t.length,x=pe(c-d,0),A=y(x+w),I=!i;++a<x;)A[a]=e[a];for(var F=a;++g<w;)A[F+g]=t[g];for(;++p<d;)(I||a<c)&&(A[F+n[p]]=e[a++]);return A}function Ee(e,t){var n=-1,i=e.length;for(t||(t=y(i));++n<i;)t[n]=e[n];return t}function ct(e,t,n,i){var a=!n;n||(n={});for(var c=-1,p=t.length;++c<p;){var d=t[c],g=i?i(n[d],e[d],d,n,e):r;g===r&&(g=e[d]),a?yt(n,d,g):On(n,d,g)}return n}function Wf(e,t){return ct(e,Ki(e),t)}function Mf(e,t){return ct(e,lo(e),t)}function Ir(e,t){return function(n,i){var a=$(n)?Hu:lf,c=t?t():{};return a(n,e,P(i,2),c)}}function un(e){return q(function(t,n){var i=-1,a=n.length,c=a>1?n[a-1]:r,p=a>2?n[2]:r;for(c=e.length>3&&typeof c=="function"?(a--,c):r,p&&Ae(n[0],n[1],p)&&(c=a<3?r:c,a=1),t=te(t);++i<a;){var d=n[i];d&&e(t,d,i,c)}return t})}function Ya(e,t){return function(n,i){if(n==null)return n;if(!Fe(n))return e(n,i);for(var a=n.length,c=t?a:-1,p=te(n);(t?c--:++c<a)&&i(p[c],c,p)!==!1;);return n}}function Xa(e){return function(t,n,i){for(var a=-1,c=te(t),p=i(t),d=p.length;d--;){var g=p[e?d:++a];if(n(c[g],g,c)===!1)break}return t}}function Bf(e,t,n){var i=t&Te,a=$n(e);function c(){var p=this&&this!==ge&&this instanceof c?a:e;return p.apply(i?n:this,arguments)}return c}function Za(e){return function(t){t=Q(t);var n=tn(t)?nt(t):r,i=n?n[0]:t.charAt(0),a=n?$t(n,1).join(""):t.slice(1);return i[e]()+a}}function cn(e){return function(t){return fi(Xo(Yo(t).replace(Pu,"")),e,"")}}function $n(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=ln(e.prototype),i=e.apply(n,t);return ae(i)?i:n}}function jf(e,t,n){var i=$n(e);function a(){for(var c=arguments.length,p=y(c),d=c,g=fn(a);d--;)p[d]=arguments[d];var w=c<3&&p[0]!==g&&p[c-1]!==g?[]:Ot(p,g);if(c-=w.length,c<n)return ro(e,t,Tr,a.placeholder,r,p,w,r,r,n-c);var x=this&&this!==ge&&this instanceof a?i:e;return ke(x,this,p)}return a}function Qa(e){return function(t,n,i){var a=te(t);if(!Fe(t)){var c=P(n,3);t=he(t),n=function(d){return c(a[d],d,a)}}var p=e(t,n,i);return p>-1?a[c?t[p]:p]:r}}function eo(e){return wt(function(t){var n=t.length,i=n,a=Ge.prototype.thru;for(e&&t.reverse();i--;){var c=t[i];if(typeof c!="function")throw new He(v);if(a&&!p&&Cr(c)=="wrapper")var p=new Ge([],!0)}for(i=p?i:n;++i<n;){c=t[i];var d=Cr(c),g=d=="wrapper"?Gi(c):r;g&&Vi(g[0])&&g[1]==(Be|We|Me|Pt)&&!g[4].length&&g[9]==1?p=p[Cr(g[0])].apply(p,g[3]):p=c.length==1&&Vi(c)?p[d]():p.thru(c)}return function(){var w=arguments,x=w[0];if(p&&w.length==1&&$(x))return p.plant(x).value();for(var A=0,I=n?t[A].apply(this,w):x;++A<n;)I=t[A].call(this,I);return I}})}function Tr(e,t,n,i,a,c,p,d,g,w){var x=t&Be,A=t&Te,I=t&dt,F=t&(We|bt),O=t&yn,j=I?r:$n(e);function L(){for(var G=arguments.length,K=y(G),Ue=G;Ue--;)K[Ue]=arguments[Ue];if(F)var Se=fn(L),De=Qu(K,Se);if(i&&(K=Ja(K,i,a,F)),c&&(K=Va(K,c,p,F)),G-=De,F&&G<w){var ce=Ot(K,Se);return ro(e,t,Tr,L.placeholder,n,K,ce,d,g,w-G)}var st=A?n:this,It=I?st[e]:e;return G=K.length,d?K=lp(K,d):O&&G>1&&K.reverse(),x&&g<G&&(K.length=g),this&&this!==ge&&this instanceof L&&(It=j||$n(It)),It.apply(st,K)}return L}function to(e,t){return function(n,i){return mf(n,e,t(i),{})}}function Er(e,t){return function(n,i){var a;if(n===r&&i===r)return t;if(n!==r&&(a=n),i!==r){if(a===r)return i;typeof n=="string"||typeof i=="string"?(n=Le(n),i=Le(i)):(n=Ma(n),i=Ma(i)),a=e(n,i)}return a}}function Bi(e){return wt(function(t){return t=se(t,Oe(P())),q(function(n){var i=this;return e(t,function(a){return ke(a,i,n)})})})}function Fr(e,t){t=t===r?" ":Le(t);var n=t.length;if(n<2)return n?Li(t,e):t;var i=Li(t,dr(e/nn(t)));return tn(t)?$t(nt(i),0,e).join(""):i.slice(0,e)}function qf(e,t,n,i){var a=t&Te,c=$n(e);function p(){for(var d=-1,g=arguments.length,w=-1,x=i.length,A=y(x+g),I=this&&this!==ge&&this instanceof p?c:e;++w<x;)A[w]=i[w];for(;g--;)A[w++]=arguments[++d];return ke(I,a?n:this,A)}return p}function no(e){return function(t,n,i){return i&&typeof i!="number"&&Ae(t,n,i)&&(n=i=r),t=St(t),n===r?(n=t,t=0):n=St(n),i=i===r?t<n?1:-1:St(i),bf(t,n,i,e)}}function br(e){return function(t,n){return typeof t=="string"&&typeof n=="string"||(t=Ve(t),n=Ve(n)),e(t,n)}}function ro(e,t,n,i,a,c,p,d,g,w){var x=t&We,A=x?p:r,I=x?r:p,F=x?c:r,O=x?r:c;t|=x?Me:Ct,t&=~(x?Ct:Me),t&vn||(t&=-4);var j=[e,t,a,F,A,O,I,d,g,w],L=n.apply(r,j);return Vi(e)&&mo(L,j),L.placeholder=i,vo(L,e,t)}function ji(e){var t=fe[e];return function(n,i){if(n=Ve(n),i=i==null?0:ye(W(i),292),i&&ma(n)){var a=(Q(n)+"e").split("e"),c=t(a[0]+"e"+(+a[1]+i));return a=(Q(c)+"e").split("e"),+(a[0]+"e"+(+a[1]-i))}return t(n)}}var Hf=an&&1/rr(new an([,-0]))[1]==B?function(e){return new an(e)}:cs;function io(e){return function(t){var n=_e(t);return n==et?yi(t):n==tt?ac(t):Zu(t,e(t))}}function _t(e,t,n,i,a,c,p,d){var g=t&dt;if(!g&&typeof e!="function")throw new He(v);var w=i?i.length:0;if(w||(t&=-97,i=a=r),p=p===r?p:pe(W(p),0),d=d===r?d:W(d),w-=a?a.length:0,t&Ct){var x=i,A=a;i=a=r}var I=g?r:Gi(e),F=[e,t,n,i,a,x,A,c,p,d];if(I&&sp(F,I),e=F[0],t=F[1],n=F[2],i=F[3],a=F[4],d=F[9]=F[9]===r?g?0:e.length:pe(F[9]-w,0),!d&&t&(We|bt)&&(t&=-25),!t||t==Te)var O=Bf(e,t,n);else t==We||t==bt?O=jf(e,t,d):(t==Me||t==(Te|Me))&&!a.length?O=qf(e,t,n,i):O=Tr.apply(r,F);var j=I?$a:mo;return vo(j(O,F),e,t)}function so(e,t,n,i){return e===r||it(e,sn[n])&&!ee.call(i,n)?t:e}function ao(e,t,n,i,a,c){return ae(e)&&ae(t)&&(c.set(t,e),xr(e,t,r,ao,c),c.delete(t)),e}function Gf(e){return Bn(e)?r:e}function oo(e,t,n,i,a,c){var p=n&ie,d=e.length,g=t.length;if(d!=g&&!(p&&g>d))return!1;var w=c.get(e),x=c.get(t);if(w&&x)return w==t&&x==e;var A=-1,I=!0,F=n&lt?new Gt:r;for(c.set(e,t),c.set(t,e);++A<d;){var O=e[A],j=t[A];if(i)var L=p?i(j,O,A,t,e,c):i(O,j,A,e,t,c);if(L!==r){if(L)continue;I=!1;break}if(F){if(!pi(t,function(G,K){if(!Fn(F,K)&&(O===G||a(O,G,n,i,c)))return F.push(K)})){I=!1;break}}else if(!(O===j||a(O,j,n,i,c))){I=!1;break}}return c.delete(e),c.delete(t),I}function zf(e,t,n,i,a,c,p){switch(n){case Zt:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case En:return!(e.byteLength!=t.byteLength||!c(new ur(e),new ur(t)));case wn:case xn:case An:return it(+e,+t);case Vn:return e.name==t.name&&e.message==t.message;case Sn:case In:return e==t+"";case et:var d=yi;case tt:var g=i&ie;if(d||(d=rr),e.size!=t.size&&!g)return!1;var w=p.get(e);if(w)return w==t;i|=lt,p.set(e,t);var x=oo(d(e),d(t),i,a,c,p);return p.delete(e),x;case Xn:if(kn)return kn.call(e)==kn.call(t)}return!1}function Kf(e,t,n,i,a,c){var p=n&ie,d=qi(e),g=d.length,w=qi(t),x=w.length;if(g!=x&&!p)return!1;for(var A=g;A--;){var I=d[A];if(!(p?I in t:ee.call(t,I)))return!1}var F=c.get(e),O=c.get(t);if(F&&O)return F==t&&O==e;var j=!0;c.set(e,t),c.set(t,e);for(var L=p;++A<g;){I=d[A];var G=e[I],K=t[I];if(i)var Ue=p?i(K,G,I,t,e,c):i(G,K,I,e,t,c);if(!(Ue===r?G===K||a(G,K,n,i,c):Ue)){j=!1;break}L||(L=I=="constructor")}if(j&&!L){var Se=e.constructor,De=t.constructor;Se!=De&&"constructor"in e&&"constructor"in t&&!(typeof Se=="function"&&Se instanceof Se&&typeof De=="function"&&De instanceof De)&&(j=!1)}return c.delete(e),c.delete(t),j}function wt(e){return Xi(ho(e,r,So),e+"")}function qi(e){return Fa(e,he,Ki)}function Hi(e){return Fa(e,be,lo)}var Gi=gr?function(e){return gr.get(e)}:cs;function Cr(e){for(var t=e.name+"",n=on[t],i=ee.call(on,t)?n.length:0;i--;){var a=n[i],c=a.func;if(c==null||c==e)return a.name}return t}function fn(e){var t=ee.call(u,"placeholder")?u:e;return t.placeholder}function P(){var e=u.iteratee||ls;return e=e===ls?Pa:e,arguments.length?e(arguments[0],arguments[1]):e}function Pr(e,t){var n=e.__data__;return tp(t)?n[typeof t=="string"?"string":"hash"]:n.map}function zi(e){for(var t=he(e),n=t.length;n--;){var i=t[n],a=e[i];t[n]=[i,a,fo(a)]}return t}function Jt(e,t){var n=rc(e,t);return Ca(n)?n:r}function Jf(e){var t=ee.call(e,qt),n=e[qt];try{e[qt]=r;var i=!0}catch{}var a=or.call(e);return i&&(t?e[qt]=n:delete e[qt]),a}var Ki=wi?function(e){return e==null?[]:(e=te(e),Rt(wi(e),function(t){return ha.call(e,t)}))}:fs,lo=wi?function(e){for(var t=[];e;)kt(t,Ki(e)),e=cr(e);return t}:fs,_e=xe;(xi&&_e(new xi(new ArrayBuffer(1)))!=Zt||Cn&&_e(new Cn)!=et||Ai&&_e(Ai.resolve())!=Is||an&&_e(new an)!=tt||Pn&&_e(new Pn)!=Tn)&&(_e=function(e){var t=xe(e),n=t==gt?e.constructor:r,i=n?Vt(n):"";if(i)switch(i){case Cc:return Zt;case Pc:return et;case Rc:return Is;case kc:return tt;case Oc:return Tn}return t});function Vf(e,t,n){for(var i=-1,a=n.length;++i<a;){var c=n[i],p=c.size;switch(c.type){case"drop":e+=p;break;case"dropRight":t-=p;break;case"take":t=ye(t,e+p);break;case"takeRight":e=pe(e,t-p);break}}return{start:e,end:t}}function Yf(e){var t=e.match(tu);return t?t[1].split(nu):[]}function uo(e,t,n){t=Dt(t,e);for(var i=-1,a=t.length,c=!1;++i<a;){var p=ft(t[i]);if(!(c=e!=null&&n(e,p)))break;e=e[p]}return c||++i!=a?c:(a=e==null?0:e.length,!!a&&Dr(a)&&xt(p,a)&&($(e)||Yt(e)))}function Xf(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]=="string"&&ee.call(e,"index")&&(n.index=e.index,n.input=e.input),n}function co(e){return typeof e.constructor=="function"&&!Wn(e)?ln(cr(e)):{}}function Zf(e,t,n){var i=e.constructor;switch(t){case En:return Mi(e);case wn:case xn:return new i(+e);case Zt:return Nf(e,n);case zr:case Kr:case Jr:case Vr:case Yr:case Xr:case Zr:case Qr:case ei:return za(e,n);case et:return new i;case An:case In:return new i(e);case Sn:return Uf(e);case tt:return new i;case Xn:return Df(e)}}function Qf(e,t){var n=t.length;if(!n)return e;var i=n-1;return t[i]=(n>1?"& ":"")+t[i],t=t.join(n>2?", ":" "),e.replace(eu,`{
431
737
  /* [wrapped with `+t+`] */
432
- `)}function Zf(e){return D(e)||Yt(e)||!!(ga&&e&&e[ga])}function xt(e,t){var n=typeof e;return t=t??de,!!t&&(n=="number"||n!="symbol"&&uu.test(e))&&e>-1&&e%1==0&&e<t}function Se(e,t,n){if(!ae(n))return!1;var i=typeof t;return(i=="number"?Te(n)&&xt(t,n.length):i=="string"&&t in n)?it(n[t],e):!1}function Ki(e,t){if(D(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Ne(e)?!0:Kl.test(e)||!zl.test(e)||t!=null&&e in te(t)}function Qf(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Vi(e){var t=Cr(e),n=u[t];if(typeof n!="function"||!(t in J.prototype))return!1;if(e===n)return!0;var i=Gi(n);return!!i&&e===i[0]}function ep(e){return!!fa&&fa in e}var tp=sr?St:ps;function $n(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||sn;return e===n}function fo(e){return e===e&&!ae(e)}function po(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==r||e in te(n))}}function np(e){var t=Nr(e,function(i){return n.size===M&&n.clear(),i}),n=t.cache;return t}function rp(e,t){var n=e[1],i=t[1],a=n|i,c=a<(Fe|dt|Be),f=i==Be&&n==$e||i==Be&&n==Pt&&e[7].length<=t[8]||i==(Be|Pt)&&t[7].length<=t[8]&&n==$e;if(!(c||f))return e;i&Fe&&(e[2]=t[2],a|=n&Fe?0:vn);var d=t[3];if(d){var g=e[3];e[3]=g?Ka(g,d,t[4]):d,e[4]=g?Lt(e[3],H):t[4]}return d=t[5],d&&(g=e[5],e[5]=g?Va(g,d,t[6]):d,e[6]=g?Lt(e[5],H):t[6]),d=t[7],d&&(e[7]=d),i&Be&&(e[8]=e[8]==null?t[8]:ye(e[8],t[8])),e[9]==null&&(e[9]=t[9]),e[0]=t[0],e[1]=a,e}function ip(e){var t=[];if(e!=null)for(var n in te(e))t.push(n);return t}function sp(e){return or.call(e)}function ho(e,t,n){return t=pe(t===r?e.length-1:t,0),function(){for(var i=arguments,a=-1,c=pe(i.length-t,0),f=y(c);++a<c;)f[a]=i[t+a];a=-1;for(var d=y(t+1);++a<t;)d[a]=i[a];return d[t]=n(f),Oe(e,this,d)}}function go(e,t){return t.length<2?e:zt(e,ze(t,0,-1))}function ap(e,t){for(var n=e.length,i=ye(t.length,n),a=Ee(e);i--;){var c=t[i];e[i]=xt(c,n)?a[c]:r}return e}function Yi(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}var mo=yo(Wa),Mn=wc||function(e,t){return ge.setTimeout(e,t)},Xi=yo(Cf);function vo(e,t,n){var i=t+"";return Xi(e,Xf(i,op(Kf(i),n)))}function yo(e){var t=0,n=0;return function(){var i=Ic(),a=Jn-(i-n);if(n=i,a>0){if(++t>=le)return arguments[0]}else t=0;return e.apply(r,arguments)}}function Rr(e,t){var n=-1,i=e.length,a=i-1;for(t=t===r?i:t;++n<t;){var c=Li(n,a),f=e[c];e[c]=e[n],e[n]=f}return e.length=t,e}var _o=np(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Vl,function(n,i,a,c){t.push(a?c.replace(ru,"$1"):i||n)}),t});function ft(e){if(typeof e=="string"||Ne(e))return e;var t=e+"";return t=="0"&&1/e==-B?"-0":t}function Vt(e){if(e!=null){try{return ar.call(e)}catch{}try{return e+""}catch{}}return""}function op(e,t){return qe(Ll,function(n){var i="_."+n[0];t&n[1]&&!tr(e,i)&&e.push(i)}),e.sort()}function wo(e){if(e instanceof J)return e.clone();var t=new Ge(e.__wrapped__,e.__chain__);return t.__actions__=Ee(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}function lp(e,t,n){(n?Se(e,t,n):t===r)?t=1:t=pe(W(t),0);var i=e==null?0:e.length;if(!i||t<1)return[];for(var a=0,c=0,f=y(dr(i/t));a<i;)f[c++]=ze(e,a,a+=t);return f}function up(e){for(var t=-1,n=e==null?0:e.length,i=0,a=[];++t<n;){var c=e[t];c&&(a[i++]=c)}return a}function cp(){var e=arguments.length;if(!e)return[];for(var t=y(e-1),n=arguments[0],i=e;i--;)t[i-1]=arguments[i];return Ot(D(n)?Ee(n):[n],me(t,1))}var fp=q(function(e,t){return ue(e)?kn(e,me(t,1,ue,!0)):[]}),pp=q(function(e,t){var n=Ke(t);return ue(n)&&(n=r),ue(e)?kn(e,me(t,1,ue,!0),C(n,2)):[]}),dp=q(function(e,t){var n=Ke(t);return ue(n)&&(n=r),ue(e)?kn(e,me(t,1,ue,!0),r,n):[]});function hp(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:W(t),ze(e,t<0?0:t,i)):[]}function gp(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:W(t),t=i-t,ze(e,0,t<0?0:t)):[]}function mp(e,t){return e&&e.length?Ar(e,C(t,3),!0,!0):[]}function vp(e,t){return e&&e.length?Ar(e,C(t,3),!0):[]}function yp(e,t,n,i){var a=e==null?0:e.length;return a?(n&&typeof n!="number"&&Se(e,t,n)&&(n=0,i=a),cf(e,t,n,i)):[]}function xo(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=n==null?0:W(n);return a<0&&(a=pe(i+a,0)),nr(e,C(t,3),a)}function So(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=i-1;return n!==r&&(a=W(n),a=n<0?pe(i+a,0):ye(a,i-1)),nr(e,C(t,3),a,!0)}function Ao(e){var t=e==null?0:e.length;return t?me(e,1):[]}function _p(e){var t=e==null?0:e.length;return t?me(e,B):[]}function wp(e,t){var n=e==null?0:e.length;return n?(t=t===r?1:W(t),me(e,t)):[]}function xp(e){for(var t=-1,n=e==null?0:e.length,i={};++t<n;){var a=e[t];i[a[0]]=a[1]}return i}function Io(e){return e&&e.length?e[0]:r}function Sp(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=n==null?0:W(n);return a<0&&(a=pe(i+a,0)),en(e,t,a)}function Ap(e){var t=e==null?0:e.length;return t?ze(e,0,-1):[]}var Ip=q(function(e){var t=se(e,Wi);return t.length&&t[0]===e[0]?bi(t):[]}),Fp=q(function(e){var t=Ke(e),n=se(e,Wi);return t===Ke(n)?t=r:n.pop(),n.length&&n[0]===e[0]?bi(n,C(t,2)):[]}),Ep=q(function(e){var t=Ke(e),n=se(e,Wi);return t=typeof t=="function"?t:r,t&&n.pop(),n.length&&n[0]===e[0]?bi(n,r,t):[]});function Tp(e,t){return e==null?"":Sc.call(e,t)}function Ke(e){var t=e==null?0:e.length;return t?e[t-1]:r}function bp(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=i;return n!==r&&(a=W(n),a=a<0?pe(i+a,0):ye(a,i-1)),t===t?ac(e,t,a):nr(e,ra,a,!0)}function Cp(e,t){return e&&e.length?ka(e,W(t)):r}var Pp=q(Fo);function Fo(e,t){return e&&e.length&&t&&t.length?Oi(e,t):e}function Rp(e,t,n){return e&&e.length&&t&&t.length?Oi(e,t,C(n,2)):e}function Op(e,t,n){return e&&e.length&&t&&t.length?Oi(e,t,r,n):e}var Lp=wt(function(e,t){var n=e==null?0:e.length,i=Ii(e,t);return Da(e,se(t,function(a){return xt(a,n)?+a:a}).sort(za)),i});function kp(e,t){var n=[];if(!(e&&e.length))return n;var i=-1,a=[],c=e.length;for(t=C(t,3);++i<c;){var f=e[i];t(f,i,e)&&(n.push(f),a.push(i))}return Da(e,a),n}function Zi(e){return e==null?e:Ec.call(e)}function Np(e,t,n){var i=e==null?0:e.length;return i?(n&&typeof n!="number"&&Se(e,t,n)?(t=0,n=i):(t=t==null?0:W(t),n=n===r?i:W(n)),ze(e,t,n)):[]}function Up(e,t){return Sr(e,t)}function Dp(e,t,n){return Ni(e,t,C(n,2))}function Wp(e,t){var n=e==null?0:e.length;if(n){var i=Sr(e,t);if(i<n&&it(e[i],t))return i}return-1}function $p(e,t){return Sr(e,t,!0)}function Mp(e,t,n){return Ni(e,t,C(n,2),!0)}function Bp(e,t){var n=e==null?0:e.length;if(n){var i=Sr(e,t,!0)-1;if(it(e[i],t))return i}return-1}function jp(e){return e&&e.length?$a(e):[]}function qp(e,t){return e&&e.length?$a(e,C(t,2)):[]}function Hp(e){var t=e==null?0:e.length;return t?ze(e,1,t):[]}function Gp(e,t,n){return e&&e.length?(t=n||t===r?1:W(t),ze(e,0,t<0?0:t)):[]}function Jp(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:W(t),t=i-t,ze(e,t<0?0:t,i)):[]}function zp(e,t){return e&&e.length?Ar(e,C(t,3),!1,!0):[]}function Kp(e,t){return e&&e.length?Ar(e,C(t,3)):[]}var Vp=q(function(e){return Ut(me(e,1,ue,!0))}),Yp=q(function(e){var t=Ke(e);return ue(t)&&(t=r),Ut(me(e,1,ue,!0),C(t,2))}),Xp=q(function(e){var t=Ke(e);return t=typeof t=="function"?t:r,Ut(me(e,1,ue,!0),r,t)});function Zp(e){return e&&e.length?Ut(e):[]}function Qp(e,t){return e&&e.length?Ut(e,C(t,2)):[]}function ed(e,t){return t=typeof t=="function"?t:r,e&&e.length?Ut(e,r,t):[]}function Qi(e){if(!(e&&e.length))return[];var t=0;return e=Rt(e,function(n){if(ue(n))return t=pe(n.length,t),!0}),mi(t,function(n){return se(e,di(n))})}function Eo(e,t){if(!(e&&e.length))return[];var n=Qi(e);return t==null?n:se(n,function(i){return Oe(t,r,i)})}var td=q(function(e,t){return ue(e)?kn(e,t):[]}),nd=q(function(e){return Di(Rt(e,ue))}),rd=q(function(e){var t=Ke(e);return ue(t)&&(t=r),Di(Rt(e,ue),C(t,2))}),id=q(function(e){var t=Ke(e);return t=typeof t=="function"?t:r,Di(Rt(e,ue),r,t)}),sd=q(Qi);function ad(e,t){return qa(e||[],t||[],Ln)}function od(e,t){return qa(e||[],t||[],Dn)}var ld=q(function(e){var t=e.length,n=t>1?e[t-1]:r;return n=typeof n=="function"?(e.pop(),n):r,Eo(e,n)});function To(e){var t=u(e);return t.__chain__=!0,t}function ud(e,t){return t(e),e}function Or(e,t){return t(e)}var cd=wt(function(e){var t=e.length,n=t?e[0]:0,i=this.__wrapped__,a=function(c){return Ii(c,e)};return t>1||this.__actions__.length||!(i instanceof J)||!xt(n)?this.thru(a):(i=i.slice(n,+n+(t?1:0)),i.__actions__.push({func:Or,args:[a],thisArg:r}),new Ge(i,this.__chain__).thru(function(c){return t&&!c.length&&c.push(r),c}))});function fd(){return To(this)}function pd(){return new Ge(this.value(),this.__chain__)}function dd(){this.__values__===r&&(this.__values__=Bo(this.value()));var e=this.__index__>=this.__values__.length,t=e?r:this.__values__[this.__index__++];return{done:e,value:t}}function hd(){return this}function gd(e){for(var t,n=this;n instanceof vr;){var i=wo(n);i.__index__=0,i.__values__=r,t?a.__wrapped__=i:t=i;var a=i;n=n.__wrapped__}return a.__wrapped__=e,t}function md(){var e=this.__wrapped__;if(e instanceof J){var t=e;return this.__actions__.length&&(t=new J(this)),t=t.reverse(),t.__actions__.push({func:Or,args:[Zi],thisArg:r}),new Ge(t,this.__chain__)}return this.thru(Zi)}function vd(){return ja(this.__wrapped__,this.__actions__)}var yd=Ir(function(e,t,n){ee.call(e,n)?++e[n]:yt(e,n,1)});function _d(e,t,n){var i=D(e)?ta:uf;return n&&Se(e,t,n)&&(t=r),i(e,C(t,3))}function wd(e,t){var n=D(e)?Rt:Fa;return n(e,C(t,3))}var xd=Qa(xo),Sd=Qa(So);function Ad(e,t){return me(Lr(e,t),1)}function Id(e,t){return me(Lr(e,t),B)}function Fd(e,t,n){return n=n===r?1:W(n),me(Lr(e,t),n)}function bo(e,t){var n=D(e)?qe:Nt;return n(e,C(t,3))}function Co(e,t){var n=D(e)?qu:Ia;return n(e,C(t,3))}var Ed=Ir(function(e,t,n){ee.call(e,n)?e[n].push(t):yt(e,n,[t])});function Td(e,t,n,i){e=Te(e)?e:dn(e),n=n&&!i?W(n):0;var a=e.length;return n<0&&(n=pe(a+n,0)),Wr(e)?n<=a&&e.indexOf(t,n)>-1:!!a&&en(e,t,n)>-1}var bd=q(function(e,t,n){var i=-1,a=typeof t=="function",c=Te(e)?y(e.length):[];return Nt(e,function(f){c[++i]=a?Oe(t,f,n):Nn(f,t,n)}),c}),Cd=Ir(function(e,t,n){yt(e,n,t)});function Lr(e,t){var n=D(e)?se:Ra;return n(e,C(t,3))}function Pd(e,t,n,i){return e==null?[]:(D(t)||(t=t==null?[]:[t]),n=i?r:n,D(n)||(n=n==null?[]:[n]),Na(e,t,n))}var Rd=Ir(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]});function Od(e,t,n){var i=D(e)?fi:sa,a=arguments.length<3;return i(e,C(t,4),n,a,Nt)}function Ld(e,t,n){var i=D(e)?Hu:sa,a=arguments.length<3;return i(e,C(t,4),n,a,Ia)}function kd(e,t){var n=D(e)?Rt:Fa;return n(e,Ur(C(t,3)))}function Nd(e){var t=D(e)?wa:Tf;return t(e)}function Ud(e,t,n){(n?Se(e,t,n):t===r)?t=1:t=W(t);var i=D(e)?rf:bf;return i(e,t)}function Dd(e){var t=D(e)?sf:Pf;return t(e)}function Wd(e){if(e==null)return 0;if(Te(e))return Wr(e)?nn(e):e.length;var t=_e(e);return t==et||t==tt?e.size:Pi(e).length}function $d(e,t,n){var i=D(e)?pi:Rf;return n&&Se(e,t,n)&&(t=r),i(e,C(t,3))}var Md=q(function(e,t){if(e==null)return[];var n=t.length;return n>1&&Se(e,t[0],t[1])?t=[]:n>2&&Se(t[0],t[1],t[2])&&(t=[t[0]]),Na(e,me(t,1),[])}),kr=_c||function(){return ge.Date.now()};function Bd(e,t){if(typeof t!="function")throw new He(v);return e=W(e),function(){if(--e<1)return t.apply(this,arguments)}}function Po(e,t,n){return t=n?r:t,t=e&&t==null?e.length:t,_t(e,Be,r,r,r,r,t)}function Ro(e,t){var n;if(typeof t!="function")throw new He(v);return e=W(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=r),n}}var es=q(function(e,t,n){var i=Fe;if(n.length){var a=Lt(n,fn(es));i|=Me}return _t(e,i,t,n,a)}),Oo=q(function(e,t,n){var i=Fe|dt;if(n.length){var a=Lt(n,fn(Oo));i|=Me}return _t(t,i,e,n,a)});function Lo(e,t,n){t=n?r:t;var i=_t(e,$e,r,r,r,r,r,t);return i.placeholder=Lo.placeholder,i}function ko(e,t,n){t=n?r:t;var i=_t(e,bt,r,r,r,r,r,t);return i.placeholder=ko.placeholder,i}function No(e,t,n){var i,a,c,f,d,g,w=0,x=!1,S=!1,I=!0;if(typeof e!="function")throw new He(v);t=Ve(t)||0,ae(n)&&(x=!!n.leading,S="maxWait"in n,c=S?pe(Ve(n.maxWait)||0,t):c,I="trailing"in n?!!n.trailing:I);function T(ce){var st=i,It=a;return i=a=r,w=ce,f=e.apply(It,st),f}function R(ce){return w=ce,d=Mn(G,t),x?T(ce):f}function j(ce){var st=ce-g,It=ce-w,el=t-st;return S?ye(el,c-It):el}function O(ce){var st=ce-g,It=ce-w;return g===r||st>=t||st<0||S&&It>=c}function G(){var ce=kr();if(O(ce))return z(ce);d=Mn(G,j(ce))}function z(ce){return d=r,I&&i?T(ce):(i=a=r,f)}function Ue(){d!==r&&Ha(d),w=0,i=g=a=d=r}function Ae(){return d===r?f:z(kr())}function De(){var ce=kr(),st=O(ce);if(i=arguments,a=this,g=ce,st){if(d===r)return R(g);if(S)return Ha(d),d=Mn(G,t),T(g)}return d===r&&(d=Mn(G,t)),f}return De.cancel=Ue,De.flush=Ae,De}var jd=q(function(e,t){return Aa(e,1,t)}),qd=q(function(e,t,n){return Aa(e,Ve(t)||0,n)});function Hd(e){return _t(e,yn)}function Nr(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new He(v);var n=function(){var i=arguments,a=t?t.apply(this,i):i[0],c=n.cache;if(c.has(a))return c.get(a);var f=e.apply(this,i);return n.cache=c.set(a,f)||c,f};return n.cache=new(Nr.Cache||vt),n}Nr.Cache=vt;function Ur(e){if(typeof e!="function")throw new He(v);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 Gd(e){return Ro(2,e)}var Jd=Of(function(e,t){t=t.length==1&&D(t[0])?se(t[0],Le(C())):se(me(t,1),Le(C()));var n=t.length;return q(function(i){for(var a=-1,c=ye(i.length,n);++a<c;)i[a]=t[a].call(this,i[a]);return Oe(e,this,i)})}),ts=q(function(e,t){var n=Lt(t,fn(ts));return _t(e,Me,r,t,n)}),Uo=q(function(e,t){var n=Lt(t,fn(Uo));return _t(e,Ct,r,t,n)}),zd=wt(function(e,t){return _t(e,Pt,r,r,r,t)});function Kd(e,t){if(typeof e!="function")throw new He(v);return t=t===r?t:W(t),q(e,t)}function Vd(e,t){if(typeof e!="function")throw new He(v);return t=t==null?0:pe(W(t),0),q(function(n){var i=n[t],a=Wt(n,0,t);return i&&Ot(a,i),Oe(e,this,a)})}function Yd(e,t,n){var i=!0,a=!0;if(typeof e!="function")throw new He(v);return ae(n)&&(i="leading"in n?!!n.leading:i,a="trailing"in n?!!n.trailing:a),No(e,t,{leading:i,maxWait:t,trailing:a})}function Xd(e){return Po(e,1)}function Zd(e,t){return ts($i(t),e)}function Qd(){if(!arguments.length)return[];var e=arguments[0];return D(e)?e:[e]}function eh(e){return Je(e,V)}function th(e,t){return t=typeof t=="function"?t:r,Je(e,V,t)}function nh(e){return Je(e,X|V)}function rh(e,t){return t=typeof t=="function"?t:r,Je(e,X|V,t)}function ih(e,t){return t==null||Sa(e,t,he(t))}function it(e,t){return e===t||e!==e&&t!==t}var sh=br(Ti),ah=br(function(e,t){return e>=t}),Yt=ba(function(){return arguments}())?ba:function(e){return oe(e)&&ee.call(e,"callee")&&!ha.call(e,"callee")},D=y.isArray,oh=Vs?Le(Vs):gf;function Te(e){return e!=null&&Dr(e.length)&&!St(e)}function ue(e){return oe(e)&&Te(e)}function lh(e){return e===!0||e===!1||oe(e)&&xe(e)==wn}var $t=xc||ps,uh=Ys?Le(Ys):mf;function ch(e){return oe(e)&&e.nodeType===1&&!Bn(e)}function fh(e){if(e==null)return!0;if(Te(e)&&(D(e)||typeof e=="string"||typeof e.splice=="function"||$t(e)||pn(e)||Yt(e)))return!e.length;var t=_e(e);if(t==et||t==tt)return!e.size;if($n(e))return!Pi(e).length;for(var n in e)if(ee.call(e,n))return!1;return!0}function ph(e,t){return Un(e,t)}function dh(e,t,n){n=typeof n=="function"?n:r;var i=n?n(e,t):r;return i===r?Un(e,t,r,n):!!i}function ns(e){if(!oe(e))return!1;var t=xe(e);return t==Vn||t==Nl||typeof e.message=="string"&&typeof e.name=="string"&&!Bn(e)}function hh(e){return typeof e=="number"&&ma(e)}function St(e){if(!ae(e))return!1;var t=xe(e);return t==Yn||t==As||t==kl||t==Dl}function Do(e){return typeof e=="number"&&e==W(e)}function Dr(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=de}function ae(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function oe(e){return e!=null&&typeof e=="object"}var Wo=Xs?Le(Xs):yf;function gh(e,t){return e===t||Ci(e,t,Ji(t))}function mh(e,t,n){return n=typeof n=="function"?n:r,Ci(e,t,Ji(t),n)}function vh(e){return $o(e)&&e!=+e}function yh(e){if(tp(e))throw new U(m);return Ca(e)}function _h(e){return e===null}function wh(e){return e==null}function $o(e){return typeof e=="number"||oe(e)&&xe(e)==Sn}function Bn(e){if(!oe(e)||xe(e)!=gt)return!1;var t=cr(e);if(t===null)return!0;var n=ee.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&ar.call(n)==gc}var rs=Zs?Le(Zs):_f;function xh(e){return Do(e)&&e>=-de&&e<=de}var Mo=Qs?Le(Qs):wf;function Wr(e){return typeof e=="string"||!D(e)&&oe(e)&&xe(e)==In}function Ne(e){return typeof e=="symbol"||oe(e)&&xe(e)==Xn}var pn=ea?Le(ea):xf;function Sh(e){return e===r}function Ah(e){return oe(e)&&_e(e)==Fn}function Ih(e){return oe(e)&&xe(e)==$l}var Fh=br(Ri),Eh=br(function(e,t){return e<=t});function Bo(e){if(!e)return[];if(Te(e))return Wr(e)?nt(e):Ee(e);if(bn&&e[bn])return rc(e[bn]());var t=_e(e),n=t==et?yi:t==tt?rr:dn;return n(e)}function At(e){if(!e)return e===0?e:0;if(e=Ve(e),e===B||e===-B){var t=e<0?-1:1;return t*ht}return e===e?e:0}function W(e){var t=At(e),n=t%1;return t===t?n?t-n:t:0}function jo(e){return e?Jt(W(e),0,ve):0}function Ve(e){if(typeof e=="number")return e;if(Ne(e))return Re;if(ae(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=ae(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=aa(e);var n=au.test(e);return n||lu.test(e)?Mu(e.slice(2),n?2:8):su.test(e)?Re:+e}function qo(e){return ct(e,be(e))}function Th(e){return e?Jt(W(e),-de,de):e===0?e:0}function Q(e){return e==null?"":ke(e)}var bh=un(function(e,t){if($n(t)||Te(t)){ct(t,he(t),e);return}for(var n in t)ee.call(t,n)&&Ln(e,n,t[n])}),Ho=un(function(e,t){ct(t,be(t),e)}),$r=un(function(e,t,n,i){ct(t,be(t),e,i)}),Ch=un(function(e,t,n,i){ct(t,he(t),e,i)}),Ph=wt(Ii);function Rh(e,t){var n=ln(e);return t==null?n:xa(n,t)}var Oh=q(function(e,t){e=te(e);var n=-1,i=t.length,a=i>2?t[2]:r;for(a&&Se(t[0],t[1],a)&&(i=1);++n<i;)for(var c=t[n],f=be(c),d=-1,g=f.length;++d<g;){var w=f[d],x=e[w];(x===r||it(x,sn[w])&&!ee.call(e,w))&&(e[w]=c[w])}return e}),Lh=q(function(e){return e.push(r,ao),Oe(Go,r,e)});function kh(e,t){return na(e,C(t,3),ut)}function Nh(e,t){return na(e,C(t,3),Ei)}function Uh(e,t){return e==null?e:Fi(e,C(t,3),be)}function Dh(e,t){return e==null?e:Ea(e,C(t,3),be)}function Wh(e,t){return e&&ut(e,C(t,3))}function $h(e,t){return e&&Ei(e,C(t,3))}function Mh(e){return e==null?[]:wr(e,he(e))}function Bh(e){return e==null?[]:wr(e,be(e))}function is(e,t,n){var i=e==null?r:zt(e,t);return i===r?n:i}function jh(e,t){return e!=null&&uo(e,t,ff)}function ss(e,t){return e!=null&&uo(e,t,pf)}var qh=to(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=or.call(t)),e[t]=n},os(Ce)),Hh=to(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=or.call(t)),ee.call(e,t)?e[t].push(n):e[t]=[n]},C),Gh=q(Nn);function he(e){return Te(e)?_a(e):Pi(e)}function be(e){return Te(e)?_a(e,!0):Sf(e)}function Jh(e,t){var n={};return t=C(t,3),ut(e,function(i,a,c){yt(n,t(i,a,c),i)}),n}function zh(e,t){var n={};return t=C(t,3),ut(e,function(i,a,c){yt(n,a,t(i,a,c))}),n}var Kh=un(function(e,t,n){xr(e,t,n)}),Go=un(function(e,t,n,i){xr(e,t,n,i)}),Vh=wt(function(e,t){var n={};if(e==null)return n;var i=!1;t=se(t,function(c){return c=Dt(c,e),i||(i=c.length>1),c}),ct(e,Hi(e),n),i&&(n=Je(n,X|N|V,qf));for(var a=t.length;a--;)Ui(n,t[a]);return n});function Yh(e,t){return Jo(e,Ur(C(t)))}var Xh=wt(function(e,t){return e==null?{}:If(e,t)});function Jo(e,t){if(e==null)return{};var n=se(Hi(e),function(i){return[i]});return t=C(t),Ua(e,n,function(i,a){return t(i,a[0])})}function Zh(e,t,n){t=Dt(t,e);var i=-1,a=t.length;for(a||(a=1,e=r);++i<a;){var c=e==null?r:e[ft(t[i])];c===r&&(i=a,c=n),e=St(c)?c.call(e):c}return e}function Qh(e,t,n){return e==null?e:Dn(e,t,n)}function eg(e,t,n,i){return i=typeof i=="function"?i:r,e==null?e:Dn(e,t,n,i)}var zo=io(he),Ko=io(be);function tg(e,t,n){var i=D(e),a=i||$t(e)||pn(e);if(t=C(t,4),n==null){var c=e&&e.constructor;a?n=i?new c:[]:ae(e)?n=St(c)?ln(cr(e)):{}:n={}}return(a?qe:ut)(e,function(f,d,g){return t(n,f,d,g)}),n}function ng(e,t){return e==null?!0:Ui(e,t)}function rg(e,t,n){return e==null?e:Ba(e,t,$i(n))}function ig(e,t,n,i){return i=typeof i=="function"?i:r,e==null?e:Ba(e,t,$i(n),i)}function dn(e){return e==null?[]:vi(e,he(e))}function sg(e){return e==null?[]:vi(e,be(e))}function ag(e,t,n){return n===r&&(n=t,t=r),n!==r&&(n=Ve(n),n=n===n?n:0),t!==r&&(t=Ve(t),t=t===t?t:0),Jt(Ve(e),t,n)}function og(e,t,n){return t=At(t),n===r?(n=t,t=0):n=At(n),e=Ve(e),df(e,t,n)}function lg(e,t,n){if(n&&typeof n!="boolean"&&Se(e,t,n)&&(t=n=r),n===r&&(typeof t=="boolean"?(n=t,t=r):typeof e=="boolean"&&(n=e,e=r)),e===r&&t===r?(e=0,t=1):(e=At(e),t===r?(t=e,e=0):t=At(t)),e>t){var i=e;e=t,t=i}if(n||e%1||t%1){var a=va();return ye(e+a*(t-e+$u("1e-"+((a+"").length-1))),t)}return Li(e,t)}var ug=cn(function(e,t,n){return t=t.toLowerCase(),e+(n?Vo(t):t)});function Vo(e){return as(Q(e).toLowerCase())}function Yo(e){return e=Q(e),e&&e.replace(cu,Zu).replace(Cu,"")}function cg(e,t,n){e=Q(e),t=ke(t);var i=e.length;n=n===r?i:Jt(W(n),0,i);var a=n;return n-=t.length,n>=0&&e.slice(n,a)==t}function fg(e){return e=Q(e),e&&Hl.test(e)?e.replace(Es,Qu):e}function pg(e){return e=Q(e),e&&Yl.test(e)?e.replace(ti,"\\$&"):e}var dg=cn(function(e,t,n){return e+(n?"-":"")+t.toLowerCase()}),hg=cn(function(e,t,n){return e+(n?" ":"")+t.toLowerCase()}),gg=Za("toLowerCase");function mg(e,t,n){e=Q(e),t=W(t);var i=t?nn(e):0;if(!t||i>=t)return e;var a=(t-i)/2;return Tr(hr(a),n)+e+Tr(dr(a),n)}function vg(e,t,n){e=Q(e),t=W(t);var i=t?nn(e):0;return t&&i<t?e+Tr(t-i,n):e}function yg(e,t,n){e=Q(e),t=W(t);var i=t?nn(e):0;return t&&i<t?Tr(t-i,n)+e:e}function _g(e,t,n){return n||t==null?t=0:t&&(t=+t),Fc(Q(e).replace(ni,""),t||0)}function wg(e,t,n){return(n?Se(e,t,n):t===r)?t=1:t=W(t),ki(Q(e),t)}function xg(){var e=arguments,t=Q(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var Sg=cn(function(e,t,n){return e+(n?"_":"")+t.toLowerCase()});function Ag(e,t,n){return n&&typeof n!="number"&&Se(e,t,n)&&(t=n=r),n=n===r?ve:n>>>0,n?(e=Q(e),e&&(typeof t=="string"||t!=null&&!rs(t))&&(t=ke(t),!t&&tn(e))?Wt(nt(e),0,n):e.split(t,n)):[]}var Ig=cn(function(e,t,n){return e+(n?" ":"")+as(t)});function Fg(e,t,n){return e=Q(e),n=n==null?0:Jt(W(n),0,e.length),t=ke(t),e.slice(n,n+t.length)==t}function Eg(e,t,n){var i=u.templateSettings;n&&Se(e,t,n)&&(t=r),e=Q(e),t=$r({},t,i,so);var a=$r({},t.imports,i.imports,so),c=he(a),f=vi(a,c),d,g,w=0,x=t.interpolate||Zn,S="__p += '",I=_i((t.escape||Zn).source+"|"+x.source+"|"+(x===Ts?iu:Zn).source+"|"+(t.evaluate||Zn).source+"|$","g"),T="//# sourceURL="+(ee.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++ku+"]")+`
433
- `;e.replace(I,function(O,G,z,Ue,Ae,De){return z||(z=Ue),S+=e.slice(w,De).replace(fu,ec),G&&(d=!0,S+=`' +
738
+ `)}function ep(e){return $(e)||Yt(e)||!!(ga&&e&&e[ga])}function xt(e,t){var n=typeof e;return t=t??de,!!t&&(n=="number"||n!="symbol"&&fu.test(e))&&e>-1&&e%1==0&&e<t}function Ae(e,t,n){if(!ae(n))return!1;var i=typeof t;return(i=="number"?Fe(n)&&xt(t,n.length):i=="string"&&t in n)?it(n[t],e):!1}function Ji(e,t){if($(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Ne(e)?!0:Yl.test(e)||!Vl.test(e)||t!=null&&e in te(t)}function tp(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Vi(e){var t=Cr(e),n=u[t];if(typeof n!="function"||!(t in z.prototype))return!1;if(e===n)return!0;var i=Gi(n);return!!i&&e===i[0]}function np(e){return!!fa&&fa in e}var rp=sr?At:ps;function Wn(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||sn;return e===n}function fo(e){return e===e&&!ae(e)}function po(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==r||e in te(n))}}function ip(e){var t=Nr(e,function(i){return n.size===M&&n.clear(),i}),n=t.cache;return t}function sp(e,t){var n=e[1],i=t[1],a=n|i,c=a<(Te|dt|Be),p=i==Be&&n==We||i==Be&&n==Pt&&e[7].length<=t[8]||i==(Be|Pt)&&t[7].length<=t[8]&&n==We;if(!(c||p))return e;i&Te&&(e[2]=t[2],a|=n&Te?0:vn);var d=t[3];if(d){var g=e[3];e[3]=g?Ja(g,d,t[4]):d,e[4]=g?Ot(e[3],H):t[4]}return d=t[5],d&&(g=e[5],e[5]=g?Va(g,d,t[6]):d,e[6]=g?Ot(e[5],H):t[6]),d=t[7],d&&(e[7]=d),i&Be&&(e[8]=e[8]==null?t[8]:ye(e[8],t[8])),e[9]==null&&(e[9]=t[9]),e[0]=t[0],e[1]=a,e}function ap(e){var t=[];if(e!=null)for(var n in te(e))t.push(n);return t}function op(e){return or.call(e)}function ho(e,t,n){return t=pe(t===r?e.length-1:t,0),function(){for(var i=arguments,a=-1,c=pe(i.length-t,0),p=y(c);++a<c;)p[a]=i[t+a];a=-1;for(var d=y(t+1);++a<t;)d[a]=i[a];return d[t]=n(p),ke(e,this,d)}}function go(e,t){return t.length<2?e:Kt(e,Ke(t,0,-1))}function lp(e,t){for(var n=e.length,i=ye(t.length,n),a=Ee(e);i--;){var c=t[i];e[i]=xt(c,n)?a[c]:r}return e}function Yi(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}var mo=yo($a),Mn=Ac||function(e,t){return ge.setTimeout(e,t)},Xi=yo(Rf);function vo(e,t,n){var i=t+"";return Xi(e,Qf(i,up(Yf(i),n)))}function yo(e){var t=0,n=0;return function(){var i=Ec(),a=zn-(i-n);if(n=i,a>0){if(++t>=le)return arguments[0]}else t=0;return e.apply(r,arguments)}}function Rr(e,t){var n=-1,i=e.length,a=i-1;for(t=t===r?i:t;++n<t;){var c=Oi(n,a),p=e[c];e[c]=e[n],e[n]=p}return e.length=t,e}var _o=ip(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Xl,function(n,i,a,c){t.push(a?c.replace(su,"$1"):i||n)}),t});function ft(e){if(typeof e=="string"||Ne(e))return e;var t=e+"";return t=="0"&&1/e==-B?"-0":t}function Vt(e){if(e!=null){try{return ar.call(e)}catch{}try{return e+""}catch{}}return""}function up(e,t){return qe(Nl,function(n){var i="_."+n[0];t&n[1]&&!tr(e,i)&&e.push(i)}),e.sort()}function wo(e){if(e instanceof z)return e.clone();var t=new Ge(e.__wrapped__,e.__chain__);return t.__actions__=Ee(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}function cp(e,t,n){(n?Ae(e,t,n):t===r)?t=1:t=pe(W(t),0);var i=e==null?0:e.length;if(!i||t<1)return[];for(var a=0,c=0,p=y(dr(i/t));a<i;)p[c++]=Ke(e,a,a+=t);return p}function fp(e){for(var t=-1,n=e==null?0:e.length,i=0,a=[];++t<n;){var c=e[t];c&&(a[i++]=c)}return a}function pp(){var e=arguments.length;if(!e)return[];for(var t=y(e-1),n=arguments[0],i=e;i--;)t[i-1]=arguments[i];return kt($(n)?Ee(n):[n],me(t,1))}var dp=q(function(e,t){return ue(e)?Ln(e,me(t,1,ue,!0)):[]}),hp=q(function(e,t){var n=Je(t);return ue(n)&&(n=r),ue(e)?Ln(e,me(t,1,ue,!0),P(n,2)):[]}),gp=q(function(e,t){var n=Je(t);return ue(n)&&(n=r),ue(e)?Ln(e,me(t,1,ue,!0),r,n):[]});function mp(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:W(t),Ke(e,t<0?0:t,i)):[]}function vp(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:W(t),t=i-t,Ke(e,0,t<0?0:t)):[]}function yp(e,t){return e&&e.length?Sr(e,P(t,3),!0,!0):[]}function _p(e,t){return e&&e.length?Sr(e,P(t,3),!0):[]}function wp(e,t,n,i){var a=e==null?0:e.length;return a?(n&&typeof n!="number"&&Ae(e,t,n)&&(n=0,i=a),pf(e,t,n,i)):[]}function xo(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=n==null?0:W(n);return a<0&&(a=pe(i+a,0)),nr(e,P(t,3),a)}function Ao(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=i-1;return n!==r&&(a=W(n),a=n<0?pe(i+a,0):ye(a,i-1)),nr(e,P(t,3),a,!0)}function So(e){var t=e==null?0:e.length;return t?me(e,1):[]}function xp(e){var t=e==null?0:e.length;return t?me(e,B):[]}function Ap(e,t){var n=e==null?0:e.length;return n?(t=t===r?1:W(t),me(e,t)):[]}function Sp(e){for(var t=-1,n=e==null?0:e.length,i={};++t<n;){var a=e[t];i[a[0]]=a[1]}return i}function Io(e){return e&&e.length?e[0]:r}function Ip(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=n==null?0:W(n);return a<0&&(a=pe(i+a,0)),en(e,t,a)}function Tp(e){var t=e==null?0:e.length;return t?Ke(e,0,-1):[]}var Ep=q(function(e){var t=se(e,$i);return t.length&&t[0]===e[0]?bi(t):[]}),Fp=q(function(e){var t=Je(e),n=se(e,$i);return t===Je(n)?t=r:n.pop(),n.length&&n[0]===e[0]?bi(n,P(t,2)):[]}),bp=q(function(e){var t=Je(e),n=se(e,$i);return t=typeof t=="function"?t:r,t&&n.pop(),n.length&&n[0]===e[0]?bi(n,r,t):[]});function Cp(e,t){return e==null?"":Ic.call(e,t)}function Je(e){var t=e==null?0:e.length;return t?e[t-1]:r}function Pp(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=i;return n!==r&&(a=W(n),a=a<0?pe(i+a,0):ye(a,i-1)),t===t?lc(e,t,a):nr(e,ra,a,!0)}function Rp(e,t){return e&&e.length?La(e,W(t)):r}var kp=q(To);function To(e,t){return e&&e.length&&t&&t.length?ki(e,t):e}function Op(e,t,n){return e&&e.length&&t&&t.length?ki(e,t,P(n,2)):e}function Lp(e,t,n){return e&&e.length&&t&&t.length?ki(e,t,r,n):e}var Np=wt(function(e,t){var n=e==null?0:e.length,i=Ii(e,t);return Da(e,se(t,function(a){return xt(a,n)?+a:a}).sort(Ka)),i});function Up(e,t){var n=[];if(!(e&&e.length))return n;var i=-1,a=[],c=e.length;for(t=P(t,3);++i<c;){var p=e[i];t(p,i,e)&&(n.push(p),a.push(i))}return Da(e,a),n}function Zi(e){return e==null?e:bc.call(e)}function Dp(e,t,n){var i=e==null?0:e.length;return i?(n&&typeof n!="number"&&Ae(e,t,n)?(t=0,n=i):(t=t==null?0:W(t),n=n===r?i:W(n)),Ke(e,t,n)):[]}function $p(e,t){return Ar(e,t)}function Wp(e,t,n){return Ni(e,t,P(n,2))}function Mp(e,t){var n=e==null?0:e.length;if(n){var i=Ar(e,t);if(i<n&&it(e[i],t))return i}return-1}function Bp(e,t){return Ar(e,t,!0)}function jp(e,t,n){return Ni(e,t,P(n,2),!0)}function qp(e,t){var n=e==null?0:e.length;if(n){var i=Ar(e,t,!0)-1;if(it(e[i],t))return i}return-1}function Hp(e){return e&&e.length?Wa(e):[]}function Gp(e,t){return e&&e.length?Wa(e,P(t,2)):[]}function zp(e){var t=e==null?0:e.length;return t?Ke(e,1,t):[]}function Kp(e,t,n){return e&&e.length?(t=n||t===r?1:W(t),Ke(e,0,t<0?0:t)):[]}function Jp(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:W(t),t=i-t,Ke(e,t<0?0:t,i)):[]}function Vp(e,t){return e&&e.length?Sr(e,P(t,3),!1,!0):[]}function Yp(e,t){return e&&e.length?Sr(e,P(t,3)):[]}var Xp=q(function(e){return Ut(me(e,1,ue,!0))}),Zp=q(function(e){var t=Je(e);return ue(t)&&(t=r),Ut(me(e,1,ue,!0),P(t,2))}),Qp=q(function(e){var t=Je(e);return t=typeof t=="function"?t:r,Ut(me(e,1,ue,!0),r,t)});function ed(e){return e&&e.length?Ut(e):[]}function td(e,t){return e&&e.length?Ut(e,P(t,2)):[]}function nd(e,t){return t=typeof t=="function"?t:r,e&&e.length?Ut(e,r,t):[]}function Qi(e){if(!(e&&e.length))return[];var t=0;return e=Rt(e,function(n){if(ue(n))return t=pe(n.length,t),!0}),mi(t,function(n){return se(e,di(n))})}function Eo(e,t){if(!(e&&e.length))return[];var n=Qi(e);return t==null?n:se(n,function(i){return ke(t,r,i)})}var rd=q(function(e,t){return ue(e)?Ln(e,t):[]}),id=q(function(e){return Di(Rt(e,ue))}),sd=q(function(e){var t=Je(e);return ue(t)&&(t=r),Di(Rt(e,ue),P(t,2))}),ad=q(function(e){var t=Je(e);return t=typeof t=="function"?t:r,Di(Rt(e,ue),r,t)}),od=q(Qi);function ld(e,t){return qa(e||[],t||[],On)}function ud(e,t){return qa(e||[],t||[],Dn)}var cd=q(function(e){var t=e.length,n=t>1?e[t-1]:r;return n=typeof n=="function"?(e.pop(),n):r,Eo(e,n)});function Fo(e){var t=u(e);return t.__chain__=!0,t}function fd(e,t){return t(e),e}function kr(e,t){return t(e)}var pd=wt(function(e){var t=e.length,n=t?e[0]:0,i=this.__wrapped__,a=function(c){return Ii(c,e)};return t>1||this.__actions__.length||!(i instanceof z)||!xt(n)?this.thru(a):(i=i.slice(n,+n+(t?1:0)),i.__actions__.push({func:kr,args:[a],thisArg:r}),new Ge(i,this.__chain__).thru(function(c){return t&&!c.length&&c.push(r),c}))});function dd(){return Fo(this)}function hd(){return new Ge(this.value(),this.__chain__)}function gd(){this.__values__===r&&(this.__values__=Bo(this.value()));var e=this.__index__>=this.__values__.length,t=e?r:this.__values__[this.__index__++];return{done:e,value:t}}function md(){return this}function vd(e){for(var t,n=this;n instanceof vr;){var i=wo(n);i.__index__=0,i.__values__=r,t?a.__wrapped__=i:t=i;var a=i;n=n.__wrapped__}return a.__wrapped__=e,t}function yd(){var e=this.__wrapped__;if(e instanceof z){var t=e;return this.__actions__.length&&(t=new z(this)),t=t.reverse(),t.__actions__.push({func:kr,args:[Zi],thisArg:r}),new Ge(t,this.__chain__)}return this.thru(Zi)}function _d(){return ja(this.__wrapped__,this.__actions__)}var wd=Ir(function(e,t,n){ee.call(e,n)?++e[n]:yt(e,n,1)});function xd(e,t,n){var i=$(e)?ta:ff;return n&&Ae(e,t,n)&&(t=r),i(e,P(t,3))}function Ad(e,t){var n=$(e)?Rt:Ta;return n(e,P(t,3))}var Sd=Qa(xo),Id=Qa(Ao);function Td(e,t){return me(Or(e,t),1)}function Ed(e,t){return me(Or(e,t),B)}function Fd(e,t,n){return n=n===r?1:W(n),me(Or(e,t),n)}function bo(e,t){var n=$(e)?qe:Nt;return n(e,P(t,3))}function Co(e,t){var n=$(e)?Gu:Ia;return n(e,P(t,3))}var bd=Ir(function(e,t,n){ee.call(e,n)?e[n].push(t):yt(e,n,[t])});function Cd(e,t,n,i){e=Fe(e)?e:dn(e),n=n&&!i?W(n):0;var a=e.length;return n<0&&(n=pe(a+n,0)),$r(e)?n<=a&&e.indexOf(t,n)>-1:!!a&&en(e,t,n)>-1}var Pd=q(function(e,t,n){var i=-1,a=typeof t=="function",c=Fe(e)?y(e.length):[];return Nt(e,function(p){c[++i]=a?ke(t,p,n):Nn(p,t,n)}),c}),Rd=Ir(function(e,t,n){yt(e,n,t)});function Or(e,t){var n=$(e)?se:Ra;return n(e,P(t,3))}function kd(e,t,n,i){return e==null?[]:($(t)||(t=t==null?[]:[t]),n=i?r:n,$(n)||(n=n==null?[]:[n]),Na(e,t,n))}var Od=Ir(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]});function Ld(e,t,n){var i=$(e)?fi:sa,a=arguments.length<3;return i(e,P(t,4),n,a,Nt)}function Nd(e,t,n){var i=$(e)?zu:sa,a=arguments.length<3;return i(e,P(t,4),n,a,Ia)}function Ud(e,t){var n=$(e)?Rt:Ta;return n(e,Ur(P(t,3)))}function Dd(e){var t=$(e)?wa:Cf;return t(e)}function $d(e,t,n){(n?Ae(e,t,n):t===r)?t=1:t=W(t);var i=$(e)?af:Pf;return i(e,t)}function Wd(e){var t=$(e)?of:kf;return t(e)}function Md(e){if(e==null)return 0;if(Fe(e))return $r(e)?nn(e):e.length;var t=_e(e);return t==et||t==tt?e.size:Pi(e).length}function Bd(e,t,n){var i=$(e)?pi:Of;return n&&Ae(e,t,n)&&(t=r),i(e,P(t,3))}var jd=q(function(e,t){if(e==null)return[];var n=t.length;return n>1&&Ae(e,t[0],t[1])?t=[]:n>2&&Ae(t[0],t[1],t[2])&&(t=[t[0]]),Na(e,me(t,1),[])}),Lr=xc||function(){return ge.Date.now()};function qd(e,t){if(typeof t!="function")throw new He(v);return e=W(e),function(){if(--e<1)return t.apply(this,arguments)}}function Po(e,t,n){return t=n?r:t,t=e&&t==null?e.length:t,_t(e,Be,r,r,r,r,t)}function Ro(e,t){var n;if(typeof t!="function")throw new He(v);return e=W(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=r),n}}var es=q(function(e,t,n){var i=Te;if(n.length){var a=Ot(n,fn(es));i|=Me}return _t(e,i,t,n,a)}),ko=q(function(e,t,n){var i=Te|dt;if(n.length){var a=Ot(n,fn(ko));i|=Me}return _t(t,i,e,n,a)});function Oo(e,t,n){t=n?r:t;var i=_t(e,We,r,r,r,r,r,t);return i.placeholder=Oo.placeholder,i}function Lo(e,t,n){t=n?r:t;var i=_t(e,bt,r,r,r,r,r,t);return i.placeholder=Lo.placeholder,i}function No(e,t,n){var i,a,c,p,d,g,w=0,x=!1,A=!1,I=!0;if(typeof e!="function")throw new He(v);t=Ve(t)||0,ae(n)&&(x=!!n.leading,A="maxWait"in n,c=A?pe(Ve(n.maxWait)||0,t):c,I="trailing"in n?!!n.trailing:I);function F(ce){var st=i,It=a;return i=a=r,w=ce,p=e.apply(It,st),p}function O(ce){return w=ce,d=Mn(G,t),x?F(ce):p}function j(ce){var st=ce-g,It=ce-w,el=t-st;return A?ye(el,c-It):el}function L(ce){var st=ce-g,It=ce-w;return g===r||st>=t||st<0||A&&It>=c}function G(){var ce=Lr();if(L(ce))return K(ce);d=Mn(G,j(ce))}function K(ce){return d=r,I&&i?F(ce):(i=a=r,p)}function Ue(){d!==r&&Ha(d),w=0,i=g=a=d=r}function Se(){return d===r?p:K(Lr())}function De(){var ce=Lr(),st=L(ce);if(i=arguments,a=this,g=ce,st){if(d===r)return O(g);if(A)return Ha(d),d=Mn(G,t),F(g)}return d===r&&(d=Mn(G,t)),p}return De.cancel=Ue,De.flush=Se,De}var Hd=q(function(e,t){return Sa(e,1,t)}),Gd=q(function(e,t,n){return Sa(e,Ve(t)||0,n)});function zd(e){return _t(e,yn)}function Nr(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new He(v);var n=function(){var i=arguments,a=t?t.apply(this,i):i[0],c=n.cache;if(c.has(a))return c.get(a);var p=e.apply(this,i);return n.cache=c.set(a,p)||c,p};return n.cache=new(Nr.Cache||vt),n}Nr.Cache=vt;function Ur(e){if(typeof e!="function")throw new He(v);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 Kd(e){return Ro(2,e)}var Jd=Lf(function(e,t){t=t.length==1&&$(t[0])?se(t[0],Oe(P())):se(me(t,1),Oe(P()));var n=t.length;return q(function(i){for(var a=-1,c=ye(i.length,n);++a<c;)i[a]=t[a].call(this,i[a]);return ke(e,this,i)})}),ts=q(function(e,t){var n=Ot(t,fn(ts));return _t(e,Me,r,t,n)}),Uo=q(function(e,t){var n=Ot(t,fn(Uo));return _t(e,Ct,r,t,n)}),Vd=wt(function(e,t){return _t(e,Pt,r,r,r,t)});function Yd(e,t){if(typeof e!="function")throw new He(v);return t=t===r?t:W(t),q(e,t)}function Xd(e,t){if(typeof e!="function")throw new He(v);return t=t==null?0:pe(W(t),0),q(function(n){var i=n[t],a=$t(n,0,t);return i&&kt(a,i),ke(e,this,a)})}function Zd(e,t,n){var i=!0,a=!0;if(typeof e!="function")throw new He(v);return ae(n)&&(i="leading"in n?!!n.leading:i,a="trailing"in n?!!n.trailing:a),No(e,t,{leading:i,maxWait:t,trailing:a})}function Qd(e){return Po(e,1)}function eh(e,t){return ts(Wi(t),e)}function th(){if(!arguments.length)return[];var e=arguments[0];return $(e)?e:[e]}function nh(e){return ze(e,V)}function rh(e,t){return t=typeof t=="function"?t:r,ze(e,V,t)}function ih(e){return ze(e,X|V)}function sh(e,t){return t=typeof t=="function"?t:r,ze(e,X|V,t)}function ah(e,t){return t==null||Aa(e,t,he(t))}function it(e,t){return e===t||e!==e&&t!==t}var oh=br(Fi),lh=br(function(e,t){return e>=t}),Yt=ba(function(){return arguments}())?ba:function(e){return oe(e)&&ee.call(e,"callee")&&!ha.call(e,"callee")},$=y.isArray,uh=Vs?Oe(Vs):vf;function Fe(e){return e!=null&&Dr(e.length)&&!At(e)}function ue(e){return oe(e)&&Fe(e)}function ch(e){return e===!0||e===!1||oe(e)&&xe(e)==wn}var Wt=Sc||ps,fh=Ys?Oe(Ys):yf;function ph(e){return oe(e)&&e.nodeType===1&&!Bn(e)}function dh(e){if(e==null)return!0;if(Fe(e)&&($(e)||typeof e=="string"||typeof e.splice=="function"||Wt(e)||pn(e)||Yt(e)))return!e.length;var t=_e(e);if(t==et||t==tt)return!e.size;if(Wn(e))return!Pi(e).length;for(var n in e)if(ee.call(e,n))return!1;return!0}function hh(e,t){return Un(e,t)}function gh(e,t,n){n=typeof n=="function"?n:r;var i=n?n(e,t):r;return i===r?Un(e,t,r,n):!!i}function ns(e){if(!oe(e))return!1;var t=xe(e);return t==Vn||t==Dl||typeof e.message=="string"&&typeof e.name=="string"&&!Bn(e)}function mh(e){return typeof e=="number"&&ma(e)}function At(e){if(!ae(e))return!1;var t=xe(e);return t==Yn||t==Ss||t==Ul||t==Wl}function Do(e){return typeof e=="number"&&e==W(e)}function Dr(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=de}function ae(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function oe(e){return e!=null&&typeof e=="object"}var $o=Xs?Oe(Xs):wf;function vh(e,t){return e===t||Ci(e,t,zi(t))}function yh(e,t,n){return n=typeof n=="function"?n:r,Ci(e,t,zi(t),n)}function _h(e){return Wo(e)&&e!=+e}function wh(e){if(rp(e))throw new D(m);return Ca(e)}function xh(e){return e===null}function Ah(e){return e==null}function Wo(e){return typeof e=="number"||oe(e)&&xe(e)==An}function Bn(e){if(!oe(e)||xe(e)!=gt)return!1;var t=cr(e);if(t===null)return!0;var n=ee.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&ar.call(n)==vc}var rs=Zs?Oe(Zs):xf;function Sh(e){return Do(e)&&e>=-de&&e<=de}var Mo=Qs?Oe(Qs):Af;function $r(e){return typeof e=="string"||!$(e)&&oe(e)&&xe(e)==In}function Ne(e){return typeof e=="symbol"||oe(e)&&xe(e)==Xn}var pn=ea?Oe(ea):Sf;function Ih(e){return e===r}function Th(e){return oe(e)&&_e(e)==Tn}function Eh(e){return oe(e)&&xe(e)==Bl}var Fh=br(Ri),bh=br(function(e,t){return e<=t});function Bo(e){if(!e)return[];if(Fe(e))return $r(e)?nt(e):Ee(e);if(bn&&e[bn])return sc(e[bn]());var t=_e(e),n=t==et?yi:t==tt?rr:dn;return n(e)}function St(e){if(!e)return e===0?e:0;if(e=Ve(e),e===B||e===-B){var t=e<0?-1:1;return t*ht}return e===e?e:0}function W(e){var t=St(e),n=t%1;return t===t?n?t-n:t:0}function jo(e){return e?zt(W(e),0,ve):0}function Ve(e){if(typeof e=="number")return e;if(Ne(e))return Re;if(ae(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=ae(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=aa(e);var n=lu.test(e);return n||cu.test(e)?ju(e.slice(2),n?2:8):ou.test(e)?Re:+e}function qo(e){return ct(e,be(e))}function Ch(e){return e?zt(W(e),-de,de):e===0?e:0}function Q(e){return e==null?"":Le(e)}var Ph=un(function(e,t){if(Wn(t)||Fe(t)){ct(t,he(t),e);return}for(var n in t)ee.call(t,n)&&On(e,n,t[n])}),Ho=un(function(e,t){ct(t,be(t),e)}),Wr=un(function(e,t,n,i){ct(t,be(t),e,i)}),Rh=un(function(e,t,n,i){ct(t,he(t),e,i)}),kh=wt(Ii);function Oh(e,t){var n=ln(e);return t==null?n:xa(n,t)}var Lh=q(function(e,t){e=te(e);var n=-1,i=t.length,a=i>2?t[2]:r;for(a&&Ae(t[0],t[1],a)&&(i=1);++n<i;)for(var c=t[n],p=be(c),d=-1,g=p.length;++d<g;){var w=p[d],x=e[w];(x===r||it(x,sn[w])&&!ee.call(e,w))&&(e[w]=c[w])}return e}),Nh=q(function(e){return e.push(r,ao),ke(Go,r,e)});function Uh(e,t){return na(e,P(t,3),ut)}function Dh(e,t){return na(e,P(t,3),Ei)}function $h(e,t){return e==null?e:Ti(e,P(t,3),be)}function Wh(e,t){return e==null?e:Ea(e,P(t,3),be)}function Mh(e,t){return e&&ut(e,P(t,3))}function Bh(e,t){return e&&Ei(e,P(t,3))}function jh(e){return e==null?[]:wr(e,he(e))}function qh(e){return e==null?[]:wr(e,be(e))}function is(e,t,n){var i=e==null?r:Kt(e,t);return i===r?n:i}function Hh(e,t){return e!=null&&uo(e,t,df)}function ss(e,t){return e!=null&&uo(e,t,hf)}var Gh=to(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=or.call(t)),e[t]=n},os(Ce)),zh=to(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=or.call(t)),ee.call(e,t)?e[t].push(n):e[t]=[n]},P),Kh=q(Nn);function he(e){return Fe(e)?_a(e):Pi(e)}function be(e){return Fe(e)?_a(e,!0):If(e)}function Jh(e,t){var n={};return t=P(t,3),ut(e,function(i,a,c){yt(n,t(i,a,c),i)}),n}function Vh(e,t){var n={};return t=P(t,3),ut(e,function(i,a,c){yt(n,a,t(i,a,c))}),n}var Yh=un(function(e,t,n){xr(e,t,n)}),Go=un(function(e,t,n,i){xr(e,t,n,i)}),Xh=wt(function(e,t){var n={};if(e==null)return n;var i=!1;t=se(t,function(c){return c=Dt(c,e),i||(i=c.length>1),c}),ct(e,Hi(e),n),i&&(n=ze(n,X|U|V,Gf));for(var a=t.length;a--;)Ui(n,t[a]);return n});function Zh(e,t){return zo(e,Ur(P(t)))}var Qh=wt(function(e,t){return e==null?{}:Ef(e,t)});function zo(e,t){if(e==null)return{};var n=se(Hi(e),function(i){return[i]});return t=P(t),Ua(e,n,function(i,a){return t(i,a[0])})}function eg(e,t,n){t=Dt(t,e);var i=-1,a=t.length;for(a||(a=1,e=r);++i<a;){var c=e==null?r:e[ft(t[i])];c===r&&(i=a,c=n),e=At(c)?c.call(e):c}return e}function tg(e,t,n){return e==null?e:Dn(e,t,n)}function ng(e,t,n,i){return i=typeof i=="function"?i:r,e==null?e:Dn(e,t,n,i)}var Ko=io(he),Jo=io(be);function rg(e,t,n){var i=$(e),a=i||Wt(e)||pn(e);if(t=P(t,4),n==null){var c=e&&e.constructor;a?n=i?new c:[]:ae(e)?n=At(c)?ln(cr(e)):{}:n={}}return(a?qe:ut)(e,function(p,d,g){return t(n,p,d,g)}),n}function ig(e,t){return e==null?!0:Ui(e,t)}function sg(e,t,n){return e==null?e:Ba(e,t,Wi(n))}function ag(e,t,n,i){return i=typeof i=="function"?i:r,e==null?e:Ba(e,t,Wi(n),i)}function dn(e){return e==null?[]:vi(e,he(e))}function og(e){return e==null?[]:vi(e,be(e))}function lg(e,t,n){return n===r&&(n=t,t=r),n!==r&&(n=Ve(n),n=n===n?n:0),t!==r&&(t=Ve(t),t=t===t?t:0),zt(Ve(e),t,n)}function ug(e,t,n){return t=St(t),n===r?(n=t,t=0):n=St(n),e=Ve(e),gf(e,t,n)}function cg(e,t,n){if(n&&typeof n!="boolean"&&Ae(e,t,n)&&(t=n=r),n===r&&(typeof t=="boolean"?(n=t,t=r):typeof e=="boolean"&&(n=e,e=r)),e===r&&t===r?(e=0,t=1):(e=St(e),t===r?(t=e,e=0):t=St(t)),e>t){var i=e;e=t,t=i}if(n||e%1||t%1){var a=va();return ye(e+a*(t-e+Bu("1e-"+((a+"").length-1))),t)}return Oi(e,t)}var fg=cn(function(e,t,n){return t=t.toLowerCase(),e+(n?Vo(t):t)});function Vo(e){return as(Q(e).toLowerCase())}function Yo(e){return e=Q(e),e&&e.replace(pu,ec).replace(Ru,"")}function pg(e,t,n){e=Q(e),t=Le(t);var i=e.length;n=n===r?i:zt(W(n),0,i);var a=n;return n-=t.length,n>=0&&e.slice(n,a)==t}function dg(e){return e=Q(e),e&&zl.test(e)?e.replace(Es,tc):e}function hg(e){return e=Q(e),e&&Zl.test(e)?e.replace(ti,"\\$&"):e}var gg=cn(function(e,t,n){return e+(n?"-":"")+t.toLowerCase()}),mg=cn(function(e,t,n){return e+(n?" ":"")+t.toLowerCase()}),vg=Za("toLowerCase");function yg(e,t,n){e=Q(e),t=W(t);var i=t?nn(e):0;if(!t||i>=t)return e;var a=(t-i)/2;return Fr(hr(a),n)+e+Fr(dr(a),n)}function _g(e,t,n){e=Q(e),t=W(t);var i=t?nn(e):0;return t&&i<t?e+Fr(t-i,n):e}function wg(e,t,n){e=Q(e),t=W(t);var i=t?nn(e):0;return t&&i<t?Fr(t-i,n)+e:e}function xg(e,t,n){return n||t==null?t=0:t&&(t=+t),Fc(Q(e).replace(ni,""),t||0)}function Ag(e,t,n){return(n?Ae(e,t,n):t===r)?t=1:t=W(t),Li(Q(e),t)}function Sg(){var e=arguments,t=Q(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var Ig=cn(function(e,t,n){return e+(n?"_":"")+t.toLowerCase()});function Tg(e,t,n){return n&&typeof n!="number"&&Ae(e,t,n)&&(t=n=r),n=n===r?ve:n>>>0,n?(e=Q(e),e&&(typeof t=="string"||t!=null&&!rs(t))&&(t=Le(t),!t&&tn(e))?$t(nt(e),0,n):e.split(t,n)):[]}var Eg=cn(function(e,t,n){return e+(n?" ":"")+as(t)});function Fg(e,t,n){return e=Q(e),n=n==null?0:zt(W(n),0,e.length),t=Le(t),e.slice(n,n+t.length)==t}function bg(e,t,n){var i=u.templateSettings;n&&Ae(e,t,n)&&(t=r),e=Q(e),t=Wr({},t,i,so);var a=Wr({},t.imports,i.imports,so),c=he(a),p=vi(a,c),d,g,w=0,x=t.interpolate||Zn,A="__p += '",I=_i((t.escape||Zn).source+"|"+x.source+"|"+(x===Fs?au:Zn).source+"|"+(t.evaluate||Zn).source+"|$","g"),F="//# sourceURL="+(ee.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Uu+"]")+`
739
+ `;e.replace(I,function(L,G,K,Ue,Se,De){return K||(K=Ue),A+=e.slice(w,De).replace(du,nc),G&&(d=!0,A+=`' +
434
740
  __e(`+G+`) +
435
- '`),Ae&&(g=!0,S+=`';
436
- `+Ae+`;
437
- __p += '`),z&&(S+=`' +
438
- ((__t = (`+z+`)) == null ? '' : __t) +
439
- '`),w=De+O.length,O}),S+=`';
440
- `;var R=ee.call(t,"variable")&&t.variable;if(!R)S=`with (obj) {
441
- `+S+`
741
+ '`),Se&&(g=!0,A+=`';
742
+ `+Se+`;
743
+ __p += '`),K&&(A+=`' +
744
+ ((__t = (`+K+`)) == null ? '' : __t) +
745
+ '`),w=De+L.length,L}),A+=`';
746
+ `;var O=ee.call(t,"variable")&&t.variable;if(!O)A=`with (obj) {
747
+ `+A+`
442
748
  }
443
- `;else if(nu.test(R))throw new U(E);S=(g?S.replace(Ml,""):S).replace(Bl,"$1").replace(jl,"$1;"),S="function("+(R||"obj")+`) {
444
- `+(R?"":`obj || (obj = {});
749
+ `;else if(iu.test(O))throw new D(E);A=(g?A.replace(jl,""):A).replace(ql,"$1").replace(Hl,"$1;"),A="function("+(O||"obj")+`) {
750
+ `+(O?"":`obj || (obj = {});
445
751
  `)+"var __t, __p = ''"+(d?", __e = _.escape":"")+(g?`, __j = Array.prototype.join;
446
752
  function print() { __p += __j.call(arguments, '') }
447
753
  `:`;
448
- `)+S+`return __p
449
- }`;var j=Zo(function(){return Z(c,T+"return "+S).apply(r,f)});if(j.source=S,ns(j))throw j;return j}function Tg(e){return Q(e).toLowerCase()}function bg(e){return Q(e).toUpperCase()}function Cg(e,t,n){if(e=Q(e),e&&(n||t===r))return aa(e);if(!e||!(t=ke(t)))return e;var i=nt(e),a=nt(t),c=oa(i,a),f=la(i,a)+1;return Wt(i,c,f).join("")}function Pg(e,t,n){if(e=Q(e),e&&(n||t===r))return e.slice(0,ca(e)+1);if(!e||!(t=ke(t)))return e;var i=nt(e),a=la(i,nt(t))+1;return Wt(i,0,a).join("")}function Rg(e,t,n){if(e=Q(e),e&&(n||t===r))return e.replace(ni,"");if(!e||!(t=ke(t)))return e;var i=nt(e),a=oa(i,nt(t));return Wt(i,a).join("")}function Og(e,t){var n=ws,i=xs;if(ae(t)){var a="separator"in t?t.separator:a;n="length"in t?W(t.length):n,i="omission"in t?ke(t.omission):i}e=Q(e);var c=e.length;if(tn(e)){var f=nt(e);c=f.length}if(n>=c)return e;var d=n-nn(i);if(d<1)return i;var g=f?Wt(f,0,d).join(""):e.slice(0,d);if(a===r)return g+i;if(f&&(d+=g.length-d),rs(a)){if(e.slice(d).search(a)){var w,x=g;for(a.global||(a=_i(a.source,Q(bs.exec(a))+"g")),a.lastIndex=0;w=a.exec(x);)var S=w.index;g=g.slice(0,S===r?d:S)}}else if(e.indexOf(ke(a),d)!=d){var I=g.lastIndexOf(a);I>-1&&(g=g.slice(0,I))}return g+i}function Lg(e){return e=Q(e),e&&ql.test(e)?e.replace(Fs,oc):e}var kg=cn(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),as=Za("toUpperCase");function Xo(e,t,n){return e=Q(e),t=n?r:t,t===r?nc(e)?cc(e):zu(e):e.match(t)||[]}var Zo=q(function(e,t){try{return Oe(e,r,t)}catch(n){return ns(n)?n:new U(n)}}),Ng=wt(function(e,t){return qe(t,function(n){n=ft(n),yt(e,n,es(e[n],e))}),e});function Ug(e){var t=e==null?0:e.length,n=C();return e=t?se(e,function(i){if(typeof i[1]!="function")throw new He(v);return[n(i[0]),i[1]]}):[],q(function(i){for(var a=-1;++a<t;){var c=e[a];if(Oe(c[0],this,i))return Oe(c[1],this,i)}})}function Dg(e){return lf(Je(e,X))}function os(e){return function(){return e}}function Wg(e,t){return e==null||e!==e?t:e}var $g=eo(),Mg=eo(!0);function Ce(e){return e}function ls(e){return Pa(typeof e=="function"?e:Je(e,X))}function Bg(e){return Oa(Je(e,X))}function jg(e,t){return La(e,Je(t,X))}var qg=q(function(e,t){return function(n){return Nn(n,e,t)}}),Hg=q(function(e,t){return function(n){return Nn(e,n,t)}});function us(e,t,n){var i=he(t),a=wr(t,i);n==null&&!(ae(t)&&(a.length||!i.length))&&(n=t,t=e,e=this,a=wr(t,he(t)));var c=!(ae(n)&&"chain"in n)||!!n.chain,f=St(e);return qe(a,function(d){var g=t[d];e[d]=g,f&&(e.prototype[d]=function(){var w=this.__chain__;if(c||w){var x=e(this.__wrapped__),S=x.__actions__=Ee(this.__actions__);return S.push({func:g,args:arguments,thisArg:e}),x.__chain__=w,x}return g.apply(e,Ot([this.value()],arguments))})}),e}function Gg(){return ge._===this&&(ge._=mc),this}function cs(){}function Jg(e){return e=W(e),q(function(t){return ka(t,e)})}var zg=Bi(se),Kg=Bi(ta),Vg=Bi(pi);function Qo(e){return Ki(e)?di(ft(e)):Ff(e)}function Yg(e){return function(t){return e==null?r:zt(e,t)}}var Xg=no(),Zg=no(!0);function fs(){return[]}function ps(){return!1}function Qg(){return{}}function em(){return""}function tm(){return!0}function nm(e,t){if(e=W(e),e<1||e>de)return[];var n=ve,i=ye(e,ve);t=C(t),e-=ve;for(var a=mi(i,t);++n<e;)t(n);return a}function rm(e){return D(e)?se(e,ft):Ne(e)?[e]:Ee(_o(Q(e)))}function im(e){var t=++hc;return Q(e)+t}var sm=Er(function(e,t){return e+t},0),am=ji("ceil"),om=Er(function(e,t){return e/t},1),lm=ji("floor");function um(e){return e&&e.length?_r(e,Ce,Ti):r}function cm(e,t){return e&&e.length?_r(e,C(t,2),Ti):r}function fm(e){return ia(e,Ce)}function pm(e,t){return ia(e,C(t,2))}function dm(e){return e&&e.length?_r(e,Ce,Ri):r}function hm(e,t){return e&&e.length?_r(e,C(t,2),Ri):r}var gm=Er(function(e,t){return e*t},1),mm=ji("round"),vm=Er(function(e,t){return e-t},0);function ym(e){return e&&e.length?gi(e,Ce):0}function _m(e,t){return e&&e.length?gi(e,C(t,2)):0}return u.after=Bd,u.ary=Po,u.assign=bh,u.assignIn=Ho,u.assignInWith=$r,u.assignWith=Ch,u.at=Ph,u.before=Ro,u.bind=es,u.bindAll=Ng,u.bindKey=Oo,u.castArray=Qd,u.chain=To,u.chunk=lp,u.compact=up,u.concat=cp,u.cond=Ug,u.conforms=Dg,u.constant=os,u.countBy=yd,u.create=Rh,u.curry=Lo,u.curryRight=ko,u.debounce=No,u.defaults=Oh,u.defaultsDeep=Lh,u.defer=jd,u.delay=qd,u.difference=fp,u.differenceBy=pp,u.differenceWith=dp,u.drop=hp,u.dropRight=gp,u.dropRightWhile=mp,u.dropWhile=vp,u.fill=yp,u.filter=wd,u.flatMap=Ad,u.flatMapDeep=Id,u.flatMapDepth=Fd,u.flatten=Ao,u.flattenDeep=_p,u.flattenDepth=wp,u.flip=Hd,u.flow=$g,u.flowRight=Mg,u.fromPairs=xp,u.functions=Mh,u.functionsIn=Bh,u.groupBy=Ed,u.initial=Ap,u.intersection=Ip,u.intersectionBy=Fp,u.intersectionWith=Ep,u.invert=qh,u.invertBy=Hh,u.invokeMap=bd,u.iteratee=ls,u.keyBy=Cd,u.keys=he,u.keysIn=be,u.map=Lr,u.mapKeys=Jh,u.mapValues=zh,u.matches=Bg,u.matchesProperty=jg,u.memoize=Nr,u.merge=Kh,u.mergeWith=Go,u.method=qg,u.methodOf=Hg,u.mixin=us,u.negate=Ur,u.nthArg=Jg,u.omit=Vh,u.omitBy=Yh,u.once=Gd,u.orderBy=Pd,u.over=zg,u.overArgs=Jd,u.overEvery=Kg,u.overSome=Vg,u.partial=ts,u.partialRight=Uo,u.partition=Rd,u.pick=Xh,u.pickBy=Jo,u.property=Qo,u.propertyOf=Yg,u.pull=Pp,u.pullAll=Fo,u.pullAllBy=Rp,u.pullAllWith=Op,u.pullAt=Lp,u.range=Xg,u.rangeRight=Zg,u.rearg=zd,u.reject=kd,u.remove=kp,u.rest=Kd,u.reverse=Zi,u.sampleSize=Ud,u.set=Qh,u.setWith=eg,u.shuffle=Dd,u.slice=Np,u.sortBy=Md,u.sortedUniq=jp,u.sortedUniqBy=qp,u.split=Ag,u.spread=Vd,u.tail=Hp,u.take=Gp,u.takeRight=Jp,u.takeRightWhile=zp,u.takeWhile=Kp,u.tap=ud,u.throttle=Yd,u.thru=Or,u.toArray=Bo,u.toPairs=zo,u.toPairsIn=Ko,u.toPath=rm,u.toPlainObject=qo,u.transform=tg,u.unary=Xd,u.union=Vp,u.unionBy=Yp,u.unionWith=Xp,u.uniq=Zp,u.uniqBy=Qp,u.uniqWith=ed,u.unset=ng,u.unzip=Qi,u.unzipWith=Eo,u.update=rg,u.updateWith=ig,u.values=dn,u.valuesIn=sg,u.without=td,u.words=Xo,u.wrap=Zd,u.xor=nd,u.xorBy=rd,u.xorWith=id,u.zip=sd,u.zipObject=ad,u.zipObjectDeep=od,u.zipWith=ld,u.entries=zo,u.entriesIn=Ko,u.extend=Ho,u.extendWith=$r,us(u,u),u.add=sm,u.attempt=Zo,u.camelCase=ug,u.capitalize=Vo,u.ceil=am,u.clamp=ag,u.clone=eh,u.cloneDeep=nh,u.cloneDeepWith=rh,u.cloneWith=th,u.conformsTo=ih,u.deburr=Yo,u.defaultTo=Wg,u.divide=om,u.endsWith=cg,u.eq=it,u.escape=fg,u.escapeRegExp=pg,u.every=_d,u.find=xd,u.findIndex=xo,u.findKey=kh,u.findLast=Sd,u.findLastIndex=So,u.findLastKey=Nh,u.floor=lm,u.forEach=bo,u.forEachRight=Co,u.forIn=Uh,u.forInRight=Dh,u.forOwn=Wh,u.forOwnRight=$h,u.get=is,u.gt=sh,u.gte=ah,u.has=jh,u.hasIn=ss,u.head=Io,u.identity=Ce,u.includes=Td,u.indexOf=Sp,u.inRange=og,u.invoke=Gh,u.isArguments=Yt,u.isArray=D,u.isArrayBuffer=oh,u.isArrayLike=Te,u.isArrayLikeObject=ue,u.isBoolean=lh,u.isBuffer=$t,u.isDate=uh,u.isElement=ch,u.isEmpty=fh,u.isEqual=ph,u.isEqualWith=dh,u.isError=ns,u.isFinite=hh,u.isFunction=St,u.isInteger=Do,u.isLength=Dr,u.isMap=Wo,u.isMatch=gh,u.isMatchWith=mh,u.isNaN=vh,u.isNative=yh,u.isNil=wh,u.isNull=_h,u.isNumber=$o,u.isObject=ae,u.isObjectLike=oe,u.isPlainObject=Bn,u.isRegExp=rs,u.isSafeInteger=xh,u.isSet=Mo,u.isString=Wr,u.isSymbol=Ne,u.isTypedArray=pn,u.isUndefined=Sh,u.isWeakMap=Ah,u.isWeakSet=Ih,u.join=Tp,u.kebabCase=dg,u.last=Ke,u.lastIndexOf=bp,u.lowerCase=hg,u.lowerFirst=gg,u.lt=Fh,u.lte=Eh,u.max=um,u.maxBy=cm,u.mean=fm,u.meanBy=pm,u.min=dm,u.minBy=hm,u.stubArray=fs,u.stubFalse=ps,u.stubObject=Qg,u.stubString=em,u.stubTrue=tm,u.multiply=gm,u.nth=Cp,u.noConflict=Gg,u.noop=cs,u.now=kr,u.pad=mg,u.padEnd=vg,u.padStart=yg,u.parseInt=_g,u.random=lg,u.reduce=Od,u.reduceRight=Ld,u.repeat=wg,u.replace=xg,u.result=Zh,u.round=mm,u.runInContext=h,u.sample=Nd,u.size=Wd,u.snakeCase=Sg,u.some=$d,u.sortedIndex=Up,u.sortedIndexBy=Dp,u.sortedIndexOf=Wp,u.sortedLastIndex=$p,u.sortedLastIndexBy=Mp,u.sortedLastIndexOf=Bp,u.startCase=Ig,u.startsWith=Fg,u.subtract=vm,u.sum=ym,u.sumBy=_m,u.template=Eg,u.times=nm,u.toFinite=At,u.toInteger=W,u.toLength=jo,u.toLower=Tg,u.toNumber=Ve,u.toSafeInteger=Th,u.toString=Q,u.toUpper=bg,u.trim=Cg,u.trimEnd=Pg,u.trimStart=Rg,u.truncate=Og,u.unescape=Lg,u.uniqueId=im,u.upperCase=kg,u.upperFirst=as,u.each=bo,u.eachRight=Co,u.first=Io,us(u,function(){var e={};return ut(u,function(t,n){ee.call(u.prototype,n)||(e[n]=t)}),e}(),{chain:!1}),u.VERSION=l,qe(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){u[e].placeholder=u}),qe(["drop","take"],function(e,t){J.prototype[e]=function(n){n=n===r?1:pe(W(n),0);var i=this.__filtered__&&!t?new J(this):this.clone();return i.__filtered__?i.__takeCount__=ye(n,i.__takeCount__):i.__views__.push({size:ye(n,ve),type:e+(i.__dir__<0?"Right":"")}),i},J.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),qe(["filter","map","takeWhile"],function(e,t){var n=t+1,i=n==Pe||n==Ss;J.prototype[e]=function(a){var c=this.clone();return c.__iteratees__.push({iteratee:C(a,3),type:n}),c.__filtered__=c.__filtered__||i,c}}),qe(["head","last"],function(e,t){var n="take"+(t?"Right":"");J.prototype[e]=function(){return this[n](1).value()[0]}}),qe(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");J.prototype[e]=function(){return this.__filtered__?new J(this):this[n](1)}}),J.prototype.compact=function(){return this.filter(Ce)},J.prototype.find=function(e){return this.filter(e).head()},J.prototype.findLast=function(e){return this.reverse().find(e)},J.prototype.invokeMap=q(function(e,t){return typeof e=="function"?new J(this):this.map(function(n){return Nn(n,e,t)})}),J.prototype.reject=function(e){return this.filter(Ur(C(e)))},J.prototype.slice=function(e,t){e=W(e);var n=this;return n.__filtered__&&(e>0||t<0)?new J(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(t=W(t),n=t<0?n.dropRight(-t):n.take(t-e)),n)},J.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},J.prototype.toArray=function(){return this.take(ve)},ut(J.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),a=u[i?"take"+(t=="last"?"Right":""):t],c=i||/^find/.test(t);a&&(u.prototype[t]=function(){var f=this.__wrapped__,d=i?[1]:arguments,g=f instanceof J,w=d[0],x=g||D(f),S=function(G){var z=a.apply(u,Ot([G],d));return i&&I?z[0]:z};x&&n&&typeof w=="function"&&w.length!=1&&(g=x=!1);var I=this.__chain__,T=!!this.__actions__.length,R=c&&!I,j=g&&!T;if(!c&&x){f=j?f:new J(this);var O=e.apply(f,d);return O.__actions__.push({func:Or,args:[S],thisArg:r}),new Ge(O,I)}return R&&j?e.apply(this,d):(O=this.thru(S),R?i?O.value()[0]:O.value():O)})}),qe(["pop","push","shift","sort","splice","unshift"],function(e){var t=ir[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);u.prototype[e]=function(){var a=arguments;if(i&&!this.__chain__){var c=this.value();return t.apply(D(c)?c:[],a)}return this[n](function(f){return t.apply(D(f)?f:[],a)})}}),ut(J.prototype,function(e,t){var n=u[t];if(n){var i=n.name+"";ee.call(on,i)||(on[i]=[]),on[i].push({name:t,func:n})}}),on[Fr(r,dt).name]=[{name:"wrapper",func:r}],J.prototype.clone=Oc,J.prototype.reverse=Lc,J.prototype.value=kc,u.prototype.at=cd,u.prototype.chain=fd,u.prototype.commit=pd,u.prototype.next=dd,u.prototype.plant=gd,u.prototype.reverse=md,u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=vd,u.prototype.first=u.prototype.head,bn&&(u.prototype[bn]=hd),u},rn=fc();jt?((jt.exports=rn)._=rn,li._=rn):ge._=rn}).call(Uy)}(Hn,Hn.exports)),Hn.exports}var Wy=Dy();const hs=o=>{const s=Wy.startCase(o).toLowerCase();return s.charAt(0).toUpperCase()+s.slice(1)},$y=({data:o,universalIdentifier:s=We.v4()})=>`import { defineObject } from 'twenty-sdk';
754
+ `)+A+`return __p
755
+ }`;var j=Zo(function(){return Z(c,F+"return "+A).apply(r,p)});if(j.source=A,ns(j))throw j;return j}function Cg(e){return Q(e).toLowerCase()}function Pg(e){return Q(e).toUpperCase()}function Rg(e,t,n){if(e=Q(e),e&&(n||t===r))return aa(e);if(!e||!(t=Le(t)))return e;var i=nt(e),a=nt(t),c=oa(i,a),p=la(i,a)+1;return $t(i,c,p).join("")}function kg(e,t,n){if(e=Q(e),e&&(n||t===r))return e.slice(0,ca(e)+1);if(!e||!(t=Le(t)))return e;var i=nt(e),a=la(i,nt(t))+1;return $t(i,0,a).join("")}function Og(e,t,n){if(e=Q(e),e&&(n||t===r))return e.replace(ni,"");if(!e||!(t=Le(t)))return e;var i=nt(e),a=oa(i,nt(t));return $t(i,a).join("")}function Lg(e,t){var n=ws,i=xs;if(ae(t)){var a="separator"in t?t.separator:a;n="length"in t?W(t.length):n,i="omission"in t?Le(t.omission):i}e=Q(e);var c=e.length;if(tn(e)){var p=nt(e);c=p.length}if(n>=c)return e;var d=n-nn(i);if(d<1)return i;var g=p?$t(p,0,d).join(""):e.slice(0,d);if(a===r)return g+i;if(p&&(d+=g.length-d),rs(a)){if(e.slice(d).search(a)){var w,x=g;for(a.global||(a=_i(a.source,Q(bs.exec(a))+"g")),a.lastIndex=0;w=a.exec(x);)var A=w.index;g=g.slice(0,A===r?d:A)}}else if(e.indexOf(Le(a),d)!=d){var I=g.lastIndexOf(a);I>-1&&(g=g.slice(0,I))}return g+i}function Ng(e){return e=Q(e),e&&Gl.test(e)?e.replace(Ts,uc):e}var Ug=cn(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),as=Za("toUpperCase");function Xo(e,t,n){return e=Q(e),t=n?r:t,t===r?ic(e)?pc(e):Vu(e):e.match(t)||[]}var Zo=q(function(e,t){try{return ke(e,r,t)}catch(n){return ns(n)?n:new D(n)}}),Dg=wt(function(e,t){return qe(t,function(n){n=ft(n),yt(e,n,es(e[n],e))}),e});function $g(e){var t=e==null?0:e.length,n=P();return e=t?se(e,function(i){if(typeof i[1]!="function")throw new He(v);return[n(i[0]),i[1]]}):[],q(function(i){for(var a=-1;++a<t;){var c=e[a];if(ke(c[0],this,i))return ke(c[1],this,i)}})}function Wg(e){return cf(ze(e,X))}function os(e){return function(){return e}}function Mg(e,t){return e==null||e!==e?t:e}var Bg=eo(),jg=eo(!0);function Ce(e){return e}function ls(e){return Pa(typeof e=="function"?e:ze(e,X))}function qg(e){return ka(ze(e,X))}function Hg(e,t){return Oa(e,ze(t,X))}var Gg=q(function(e,t){return function(n){return Nn(n,e,t)}}),zg=q(function(e,t){return function(n){return Nn(e,n,t)}});function us(e,t,n){var i=he(t),a=wr(t,i);n==null&&!(ae(t)&&(a.length||!i.length))&&(n=t,t=e,e=this,a=wr(t,he(t)));var c=!(ae(n)&&"chain"in n)||!!n.chain,p=At(e);return qe(a,function(d){var g=t[d];e[d]=g,p&&(e.prototype[d]=function(){var w=this.__chain__;if(c||w){var x=e(this.__wrapped__),A=x.__actions__=Ee(this.__actions__);return A.push({func:g,args:arguments,thisArg:e}),x.__chain__=w,x}return g.apply(e,kt([this.value()],arguments))})}),e}function Kg(){return ge._===this&&(ge._=yc),this}function cs(){}function Jg(e){return e=W(e),q(function(t){return La(t,e)})}var Vg=Bi(se),Yg=Bi(ta),Xg=Bi(pi);function Qo(e){return Ji(e)?di(ft(e)):Ff(e)}function Zg(e){return function(t){return e==null?r:Kt(e,t)}}var Qg=no(),em=no(!0);function fs(){return[]}function ps(){return!1}function tm(){return{}}function nm(){return""}function rm(){return!0}function im(e,t){if(e=W(e),e<1||e>de)return[];var n=ve,i=ye(e,ve);t=P(t),e-=ve;for(var a=mi(i,t);++n<e;)t(n);return a}function sm(e){return $(e)?se(e,ft):Ne(e)?[e]:Ee(_o(Q(e)))}function am(e){var t=++mc;return Q(e)+t}var om=Er(function(e,t){return e+t},0),lm=ji("ceil"),um=Er(function(e,t){return e/t},1),cm=ji("floor");function fm(e){return e&&e.length?_r(e,Ce,Fi):r}function pm(e,t){return e&&e.length?_r(e,P(t,2),Fi):r}function dm(e){return ia(e,Ce)}function hm(e,t){return ia(e,P(t,2))}function gm(e){return e&&e.length?_r(e,Ce,Ri):r}function mm(e,t){return e&&e.length?_r(e,P(t,2),Ri):r}var vm=Er(function(e,t){return e*t},1),ym=ji("round"),_m=Er(function(e,t){return e-t},0);function wm(e){return e&&e.length?gi(e,Ce):0}function xm(e,t){return e&&e.length?gi(e,P(t,2)):0}return u.after=qd,u.ary=Po,u.assign=Ph,u.assignIn=Ho,u.assignInWith=Wr,u.assignWith=Rh,u.at=kh,u.before=Ro,u.bind=es,u.bindAll=Dg,u.bindKey=ko,u.castArray=th,u.chain=Fo,u.chunk=cp,u.compact=fp,u.concat=pp,u.cond=$g,u.conforms=Wg,u.constant=os,u.countBy=wd,u.create=Oh,u.curry=Oo,u.curryRight=Lo,u.debounce=No,u.defaults=Lh,u.defaultsDeep=Nh,u.defer=Hd,u.delay=Gd,u.difference=dp,u.differenceBy=hp,u.differenceWith=gp,u.drop=mp,u.dropRight=vp,u.dropRightWhile=yp,u.dropWhile=_p,u.fill=wp,u.filter=Ad,u.flatMap=Td,u.flatMapDeep=Ed,u.flatMapDepth=Fd,u.flatten=So,u.flattenDeep=xp,u.flattenDepth=Ap,u.flip=zd,u.flow=Bg,u.flowRight=jg,u.fromPairs=Sp,u.functions=jh,u.functionsIn=qh,u.groupBy=bd,u.initial=Tp,u.intersection=Ep,u.intersectionBy=Fp,u.intersectionWith=bp,u.invert=Gh,u.invertBy=zh,u.invokeMap=Pd,u.iteratee=ls,u.keyBy=Rd,u.keys=he,u.keysIn=be,u.map=Or,u.mapKeys=Jh,u.mapValues=Vh,u.matches=qg,u.matchesProperty=Hg,u.memoize=Nr,u.merge=Yh,u.mergeWith=Go,u.method=Gg,u.methodOf=zg,u.mixin=us,u.negate=Ur,u.nthArg=Jg,u.omit=Xh,u.omitBy=Zh,u.once=Kd,u.orderBy=kd,u.over=Vg,u.overArgs=Jd,u.overEvery=Yg,u.overSome=Xg,u.partial=ts,u.partialRight=Uo,u.partition=Od,u.pick=Qh,u.pickBy=zo,u.property=Qo,u.propertyOf=Zg,u.pull=kp,u.pullAll=To,u.pullAllBy=Op,u.pullAllWith=Lp,u.pullAt=Np,u.range=Qg,u.rangeRight=em,u.rearg=Vd,u.reject=Ud,u.remove=Up,u.rest=Yd,u.reverse=Zi,u.sampleSize=$d,u.set=tg,u.setWith=ng,u.shuffle=Wd,u.slice=Dp,u.sortBy=jd,u.sortedUniq=Hp,u.sortedUniqBy=Gp,u.split=Tg,u.spread=Xd,u.tail=zp,u.take=Kp,u.takeRight=Jp,u.takeRightWhile=Vp,u.takeWhile=Yp,u.tap=fd,u.throttle=Zd,u.thru=kr,u.toArray=Bo,u.toPairs=Ko,u.toPairsIn=Jo,u.toPath=sm,u.toPlainObject=qo,u.transform=rg,u.unary=Qd,u.union=Xp,u.unionBy=Zp,u.unionWith=Qp,u.uniq=ed,u.uniqBy=td,u.uniqWith=nd,u.unset=ig,u.unzip=Qi,u.unzipWith=Eo,u.update=sg,u.updateWith=ag,u.values=dn,u.valuesIn=og,u.without=rd,u.words=Xo,u.wrap=eh,u.xor=id,u.xorBy=sd,u.xorWith=ad,u.zip=od,u.zipObject=ld,u.zipObjectDeep=ud,u.zipWith=cd,u.entries=Ko,u.entriesIn=Jo,u.extend=Ho,u.extendWith=Wr,us(u,u),u.add=om,u.attempt=Zo,u.camelCase=fg,u.capitalize=Vo,u.ceil=lm,u.clamp=lg,u.clone=nh,u.cloneDeep=ih,u.cloneDeepWith=sh,u.cloneWith=rh,u.conformsTo=ah,u.deburr=Yo,u.defaultTo=Mg,u.divide=um,u.endsWith=pg,u.eq=it,u.escape=dg,u.escapeRegExp=hg,u.every=xd,u.find=Sd,u.findIndex=xo,u.findKey=Uh,u.findLast=Id,u.findLastIndex=Ao,u.findLastKey=Dh,u.floor=cm,u.forEach=bo,u.forEachRight=Co,u.forIn=$h,u.forInRight=Wh,u.forOwn=Mh,u.forOwnRight=Bh,u.get=is,u.gt=oh,u.gte=lh,u.has=Hh,u.hasIn=ss,u.head=Io,u.identity=Ce,u.includes=Cd,u.indexOf=Ip,u.inRange=ug,u.invoke=Kh,u.isArguments=Yt,u.isArray=$,u.isArrayBuffer=uh,u.isArrayLike=Fe,u.isArrayLikeObject=ue,u.isBoolean=ch,u.isBuffer=Wt,u.isDate=fh,u.isElement=ph,u.isEmpty=dh,u.isEqual=hh,u.isEqualWith=gh,u.isError=ns,u.isFinite=mh,u.isFunction=At,u.isInteger=Do,u.isLength=Dr,u.isMap=$o,u.isMatch=vh,u.isMatchWith=yh,u.isNaN=_h,u.isNative=wh,u.isNil=Ah,u.isNull=xh,u.isNumber=Wo,u.isObject=ae,u.isObjectLike=oe,u.isPlainObject=Bn,u.isRegExp=rs,u.isSafeInteger=Sh,u.isSet=Mo,u.isString=$r,u.isSymbol=Ne,u.isTypedArray=pn,u.isUndefined=Ih,u.isWeakMap=Th,u.isWeakSet=Eh,u.join=Cp,u.kebabCase=gg,u.last=Je,u.lastIndexOf=Pp,u.lowerCase=mg,u.lowerFirst=vg,u.lt=Fh,u.lte=bh,u.max=fm,u.maxBy=pm,u.mean=dm,u.meanBy=hm,u.min=gm,u.minBy=mm,u.stubArray=fs,u.stubFalse=ps,u.stubObject=tm,u.stubString=nm,u.stubTrue=rm,u.multiply=vm,u.nth=Rp,u.noConflict=Kg,u.noop=cs,u.now=Lr,u.pad=yg,u.padEnd=_g,u.padStart=wg,u.parseInt=xg,u.random=cg,u.reduce=Ld,u.reduceRight=Nd,u.repeat=Ag,u.replace=Sg,u.result=eg,u.round=ym,u.runInContext=h,u.sample=Dd,u.size=Md,u.snakeCase=Ig,u.some=Bd,u.sortedIndex=$p,u.sortedIndexBy=Wp,u.sortedIndexOf=Mp,u.sortedLastIndex=Bp,u.sortedLastIndexBy=jp,u.sortedLastIndexOf=qp,u.startCase=Eg,u.startsWith=Fg,u.subtract=_m,u.sum=wm,u.sumBy=xm,u.template=bg,u.times=im,u.toFinite=St,u.toInteger=W,u.toLength=jo,u.toLower=Cg,u.toNumber=Ve,u.toSafeInteger=Ch,u.toString=Q,u.toUpper=Pg,u.trim=Rg,u.trimEnd=kg,u.trimStart=Og,u.truncate=Lg,u.unescape=Ng,u.uniqueId=am,u.upperCase=Ug,u.upperFirst=as,u.each=bo,u.eachRight=Co,u.first=Io,us(u,function(){var e={};return ut(u,function(t,n){ee.call(u.prototype,n)||(e[n]=t)}),e}(),{chain:!1}),u.VERSION=l,qe(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){u[e].placeholder=u}),qe(["drop","take"],function(e,t){z.prototype[e]=function(n){n=n===r?1:pe(W(n),0);var i=this.__filtered__&&!t?new z(this):this.clone();return i.__filtered__?i.__takeCount__=ye(n,i.__takeCount__):i.__views__.push({size:ye(n,ve),type:e+(i.__dir__<0?"Right":"")}),i},z.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),qe(["filter","map","takeWhile"],function(e,t){var n=t+1,i=n==Pe||n==As;z.prototype[e]=function(a){var c=this.clone();return c.__iteratees__.push({iteratee:P(a,3),type:n}),c.__filtered__=c.__filtered__||i,c}}),qe(["head","last"],function(e,t){var n="take"+(t?"Right":"");z.prototype[e]=function(){return this[n](1).value()[0]}}),qe(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");z.prototype[e]=function(){return this.__filtered__?new z(this):this[n](1)}}),z.prototype.compact=function(){return this.filter(Ce)},z.prototype.find=function(e){return this.filter(e).head()},z.prototype.findLast=function(e){return this.reverse().find(e)},z.prototype.invokeMap=q(function(e,t){return typeof e=="function"?new z(this):this.map(function(n){return Nn(n,e,t)})}),z.prototype.reject=function(e){return this.filter(Ur(P(e)))},z.prototype.slice=function(e,t){e=W(e);var n=this;return n.__filtered__&&(e>0||t<0)?new z(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(t=W(t),n=t<0?n.dropRight(-t):n.take(t-e)),n)},z.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},z.prototype.toArray=function(){return this.take(ve)},ut(z.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),a=u[i?"take"+(t=="last"?"Right":""):t],c=i||/^find/.test(t);a&&(u.prototype[t]=function(){var p=this.__wrapped__,d=i?[1]:arguments,g=p instanceof z,w=d[0],x=g||$(p),A=function(G){var K=a.apply(u,kt([G],d));return i&&I?K[0]:K};x&&n&&typeof w=="function"&&w.length!=1&&(g=x=!1);var I=this.__chain__,F=!!this.__actions__.length,O=c&&!I,j=g&&!F;if(!c&&x){p=j?p:new z(this);var L=e.apply(p,d);return L.__actions__.push({func:kr,args:[A],thisArg:r}),new Ge(L,I)}return O&&j?e.apply(this,d):(L=this.thru(A),O?i?L.value()[0]:L.value():L)})}),qe(["pop","push","shift","sort","splice","unshift"],function(e){var t=ir[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);u.prototype[e]=function(){var a=arguments;if(i&&!this.__chain__){var c=this.value();return t.apply($(c)?c:[],a)}return this[n](function(p){return t.apply($(p)?p:[],a)})}}),ut(z.prototype,function(e,t){var n=u[t];if(n){var i=n.name+"";ee.call(on,i)||(on[i]=[]),on[i].push({name:t,func:n})}}),on[Tr(r,dt).name]=[{name:"wrapper",func:r}],z.prototype.clone=Lc,z.prototype.reverse=Nc,z.prototype.value=Uc,u.prototype.at=pd,u.prototype.chain=dd,u.prototype.commit=hd,u.prototype.next=gd,u.prototype.plant=vd,u.prototype.reverse=yd,u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=_d,u.prototype.first=u.prototype.head,bn&&(u.prototype[bn]=md),u},rn=dc();jt?((jt.exports=rn)._=rn,li._=rn):ge._=rn}).call($y)}(Hn,Hn.exports)),Hn.exports}var My=Wy();const hs=o=>{const s=My.startCase(o).toLowerCase();return s.charAt(0).toUpperCase()+s.slice(1)},By=({data:o,universalIdentifier:s=$e.v4()})=>`import { defineObject } from 'twenty-sdk';
450
756
 
451
757
  export default defineObject({
452
758
  universalIdentifier: '${s}',
@@ -466,20 +772,20 @@ export default defineObject({
466
772
  // },
467
773
  ],
468
774
  });
469
- `,My=({name:o})=>`import { definePageLayout } from 'twenty-sdk';
775
+ `,jy=({name:o})=>`import { definePageLayout } from 'twenty-sdk';
470
776
 
471
777
  export default definePageLayout({
472
- universalIdentifier: '${We.v4()}',
778
+ universalIdentifier: '${$e.v4()}',
473
779
  name: '${o}',
474
780
  tabs: [
475
781
  {
476
- universalIdentifier: '${We.v4()}',
782
+ universalIdentifier: '${$e.v4()}',
477
783
  title: 'Overview',
478
784
  widgets: [],
479
785
  },
480
786
  ],
481
787
  });
482
- `,By=({name:o,universalIdentifier:s=We.v4()})=>{const r=Ze.default(o);return`import { defineRole } from 'twenty-sdk';
788
+ `,qy=({name:o,universalIdentifier:s=$e.v4()})=>{const r=Ze.default(o);return`import { defineRole } from 'twenty-sdk';
483
789
 
484
790
  export const ${r.toUpperCase().replace(/-/g,"_")}_ROLE_UNIVERSAL_IDENTIFIER =
485
791
  '${s}';
@@ -493,7 +799,7 @@ export default defineRole({
493
799
  canSoftDeleteAllObjectRecords: true,
494
800
  canDestroyAllObjectRecords: false,
495
801
  });
496
- `},jy=({name:o,universalIdentifier:s=We.v4()})=>{const r=Ze.default(o);return`import { defineSkill } from 'twenty-sdk';
802
+ `},Hy=({name:o,universalIdentifier:s=$e.v4()})=>{const r=Ze.default(o);return`import { defineSkill } from 'twenty-sdk';
497
803
 
498
804
  export const ${r.toUpperCase().replace(/-/g,"_")}_SKILL_UNIVERSAL_IDENTIFIER =
499
805
  '${s}';
@@ -505,7 +811,7 @@ export default defineSkill({
505
811
  description: 'Add a description for your skill',
506
812
  content: 'Add the skill content here',
507
813
  });
508
- `},cl=({name:o,universalIdentifier:s=We.v4(),objectUniversalIdentifier:r="fill-later"})=>{const l=Ze.default(o);return`import { defineView } from 'twenty-sdk';
814
+ `},pl=({name:o,universalIdentifier:s=$e.v4(),objectUniversalIdentifier:r="fill-later"})=>{const l=Ze.default(o);return`import { defineView } from 'twenty-sdk';
509
815
 
510
816
  export default defineView({
511
817
  universalIdentifier: '${s}',
@@ -530,7 +836,7 @@ export default defineView({
530
836
  // },
531
837
  // ],
532
838
  });
533
- `},qy=({data:o})=>{const s=We.v4(),r=o.description?`
839
+ `},Gy=({data:o})=>{const s=$e.v4(),r=o.description?`
534
840
  description: '${o.description}',`:"";return`import { defineField, FieldType } from 'twenty-sdk';
535
841
 
536
842
  export default defineField({
@@ -540,4 +846,4 @@ export default defineField({
540
846
  type: FieldMetadataType.${o.type},
541
847
  objectUniversalIdentifier: '${o.objectUniversalIdentifier}',${r}
542
848
  });
543
- `},gs="src";class Hy{async execute(s,r){try{const l=s??await this.getEntity(),p=this.getFolderName(l),m=r?$.join(Ie,r):$.join(Ie,gs,p);await k.ensureDir(m);const{name:v,file:E}=await this.getEntityData(l),b=$.join(m,this.getFileName(v,l));if(await k.pathExists(b)){const{overwrite:M}=await this.handleFileExist();if(!M)return}await k.writeFile(b,E),console.log(A.default.green(`✓ Created ${p}:`),A.default.cyan($.relative(Ie,b))),l===K.Object&&await this.promptAndCreateViewAndNavigationMenuItem(v,r)}catch(l){console.error(A.default.red("Add new entity failed:"),l instanceof Error?l.message:l),process.exit(1)}}async getEntityData(s){switch(s){case K.Object:{const r=await this.getObjectData(),l=r.nameSingular,p=We.v4();this.lastObjectUniversalIdentifier=p;const m=$y({data:r,universalIdentifier:p});return{name:l,file:m}}case K.Field:{const r=await this.getFieldData(),l=r.name,p=qy({data:r});return{name:l,file:p}}case K.LogicFunction:{const r=await this.getEntityName(s),l=Ny({name:r});return{name:r,file:l}}case K.FrontComponent:{const r=await this.getEntityName(s),l=ky({name:r});return{name:r,file:l}}case K.Role:{const r=await this.getEntityName(s),l=By({name:r});return{name:r,file:l}}case K.Skill:{const r=await this.getEntityName(s),l=jy({name:r});return{name:r,file:l}}case K.View:{const l=(await this.getViewData()).name,p=cl({name:l});return{name:l,file:p}}case K.NavigationMenuItem:{const r=await this.getEntityName(s),l=ll({name:r});return{name:r,file:l}}case K.PageLayout:{const r=await this.getEntityName(s),l=My({name:r});return{name:r,file:l}}default:P.dt()}}async promptAndCreateViewAndNavigationMenuItem(s,r){const{createViewAndNavItem:l}=await ot.default.prompt([{type:"confirm",name:"createViewAndNavItem",message:"Also create a view and navigation menu item for this object? (recommended)",default:!0}]);if(!l||!this.lastObjectUniversalIdentifier)return;const p=We.v4(),m=cl({name:`all-${Ze.default(s)}`,universalIdentifier:p,objectUniversalIdentifier:this.lastObjectUniversalIdentifier}),v=r?$.join(Ie,r):$.join(Ie,gs,this.getFolderName(K.View));await k.ensureDir(v);const E=`all-${Ze.default(s)}.ts`,b=$.join(v,E);if(await k.pathExists(b)){const{overwrite:V}=await this.handleFileExist();if(!V)return}await k.writeFile(b,m),console.log(A.default.green("✓ Created view:"),A.default.cyan($.relative(Ie,b)));const M=ll({name:s,viewUniversalIdentifier:p}),H=r?$.join(Ie,r):$.join(Ie,gs,this.getFolderName(K.NavigationMenuItem));await k.ensureDir(H);const X=`${Ze.default(s)}.ts`,N=$.join(H,X);if(await k.pathExists(N)){const{overwrite:V}=await this.handleFileExist();if(!V)return}await k.writeFile(N,M),console.log(A.default.green("✓ Created navigation menu item:"),A.default.cyan($.relative(Ie,N)))}async getEntity(){const{entity:s}=await ot.default.prompt([{type:"select",name:"entity",message:"What entity do you want to create?",default:"",choices:Object.values(K)}]);return s}async handleFileExist(){return await ot.default.prompt([{type:"confirm",name:"overwrite",message:"File already exists. Do you want to overwrite it?",default:!1}])}async getEntityName(s){const{name:r}=await ot.default.prompt([{type:"input",name:"name",message:`Enter a name for your new ${s}:`,default:"",validate:l=>l.length===0?`${s} name is required`:!0}]);return r}async getFieldData(){return ot.default.prompt([{type:"input",name:"name",message:"Enter a name for your field:",default:"",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"label",message:"Enter a label for your field:",default:s=>hs(s.name),validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"select",name:"type",message:"Select the field type:",choices:Object.values(P.R),default:P.R.TEXT},{type:"input",name:"objectUniversalIdentifier",message:"Enter the universalIdentifier of the object this field belongs to:",default:"fill-later",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"description",message:"Enter a description for your field (optional):",default:""}])}async getObjectData(){return ot.default.prompt([{type:"input",name:"nameSingular",message:"Enter a name singular for your object (eg: company):",default:"",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"namePlural",message:"Enter a name plural for your object (eg: companies):",default:"",validate:(s,r)=>s.trim()===r?.nameSingular.trim()?"Name plural must be different from name singular":!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"labelSingular",message:"Enter a label singular for your object:",default:s=>hs(s.nameSingular),validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"labelPlural",message:"Enter a label plural for your object:",default:s=>hs(s.namePlural),validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0}])}async getViewData(){return ot.default.prompt([{type:"input",name:"name",message:"Enter a name for your view:",default:"",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"objectUniversalIdentifier",message:"Enter the universalIdentifier of the object this view belongs to:",default:"fill-later",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0}])}getFolderName(s){return`${Ze.default(s)}s`}getFileName(s,r){switch(r){case K.FrontComponent:return`${Ze.default(s)}.tsx`;default:return`${Ze.default(s)}.ts`}}}const Gy=o=>{const s=new Ty,r=new by,l=new Cy,p=new Py,m=new Ly;o.command("auth:login").description("Authenticate with Twenty").option("--api-key <key>","API key for authentication").option("--api-url <url>","Twenty API URL").action(async N=>{await r.execute(N)}),o.command("auth:logout").description("Remove authentication credentials").action(async()=>{await l.execute()}),o.command("auth:status").description("Check authentication status").action(async()=>{await p.execute()}),o.command("auth:switch [workspace]").description("Switch the default workspace for authentication").action(async N=>{await m.execute({workspace:N})}),o.command("auth:list").description("List all configured workspaces").action(async()=>{await s.execute()});const v=new Ay,E=new Fy,b=new Ey,M=new Hy,H=new Oy,X=new Ry;o.command("app:dev [appPath]").description("Watch and sync local application changes").action(async N=>{await v.execute({appPath:jn(N)})}),o.command("app:typecheck [appPath]").description("Run TypeScript type checking on the application").action(async N=>{await E.execute({appPath:jn(N)})}),o.command("app:uninstall [appPath]").description("Uninstall application from Twenty").option("-y, --yes","Skip confirmation prompt").action(async(N,V)=>{try{const ie=await b.execute({appPath:jn(N),askForConfirmation:!V?.yes});process.exit(ie.success?0:1)}catch{process.exit(1)}}),o.command("entity:add [entityType]").option("--path <path>","Path in which the entity should be created.").description(`Add a new entity to your application (${Object.values(K).join("|")})`).action(async(N,V)=>{await M.execute(N,V?.path)}),o.command("function:logs [appPath]").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").description("Watch application function logs").action(async(N,V)=>{await H.execute({...V,appPath:jn(N)})}),o.command("function:execute [appPath]").option("--postInstall","Execute post-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").description("Execute a logic function with a JSON payload").action(async(N,V)=>{!V?.postInstall&&!V?.functionUniversalIdentifier&&!V?.functionName&&(console.error(A.default.red("Error: Either --postInstall or --functionName (-n) or --functionUniversalIdentifier (-u) is required.")),process.exit(1)),await X.execute({...V,payload:V?.payload??"{}",appPath:jn(N)})})},Jy="0.6.0",zy={version:Jy};qm.inspect.defaultOptions.depth=10;const mn=new hl.Command;mn.name("twenty").description("CLI for Twenty application development").version(zy.version);mn.option("--workspace <name>","Use a specific workspace configuration (overrides the default set by auth:switch)");mn.hook("preAction",async o=>{let r=(o.optsWithGlobals?o.optsWithGlobals():o.opts()).workspace;r||(r=await new we().getDefaultWorkspace()),we.setActiveWorkspace(r),console.log(A.default.gray(`👩‍💻 Workspace - ${we.getActiveWorkspace()}`))});Gy(mn);mn.exitOverride();try{mn.parse()}catch(o){o instanceof hl.CommanderError&&process.exit(o.exitCode),o instanceof Error&&(console.error(A.default.red("Error:"),o.message),process.exit(1))}
849
+ `},gs="src";class zy{async execute(s,r){try{const l=s??await this.getEntity(),f=this.getFolderName(l),m=r?R.join(Ie,r):R.join(Ie,gs,f);await C.ensureDir(m);const{name:v,file:E}=await this.getEntityData(l),b=R.join(m,this.getFileName(v,l));if(await C.pathExists(b)){const{overwrite:M}=await this.handleFileExist();if(!M)return}await C.writeFile(b,E),console.log(S.default.green(`✓ Created ${f}:`),S.default.cyan(R.relative(Ie,b))),l===J.Object&&await this.promptAndCreateViewAndNavigationMenuItem(v,r)}catch(l){console.error(S.default.red("Add new entity failed:"),l instanceof Error?l.message:l),process.exit(1)}}async getEntityData(s){switch(s){case J.Object:{const r=await this.getObjectData(),l=r.nameSingular,f=$e.v4();this.lastObjectUniversalIdentifier=f;const m=By({data:r,universalIdentifier:f});return{name:l,file:m}}case J.Field:{const r=await this.getFieldData(),l=r.name,f=Gy({data:r});return{name:l,file:f}}case J.LogicFunction:{const r=await this.getEntityName(s),l=Dy({name:r});return{name:r,file:l}}case J.FrontComponent:{const r=await this.getEntityName(s),l=Uy({name:r});return{name:r,file:l}}case J.Role:{const r=await this.getEntityName(s),l=qy({name:r});return{name:r,file:l}}case J.Skill:{const r=await this.getEntityName(s),l=Hy({name:r});return{name:r,file:l}}case J.View:{const l=(await this.getViewData()).name,f=pl({name:l});return{name:l,file:f}}case J.NavigationMenuItem:{const r=await this.getEntityName(s),l=cl({name:r});return{name:r,file:l}}case J.PageLayout:{const r=await this.getEntityName(s),l=jy({name:r});return{name:r,file:l}}default:k.dt()}}async promptAndCreateViewAndNavigationMenuItem(s,r){const{createViewAndNavItem:l}=await ot.default.prompt([{type:"confirm",name:"createViewAndNavItem",message:"Also create a view and navigation menu item for this object? (recommended)",default:!0}]);if(!l||!this.lastObjectUniversalIdentifier)return;const f=$e.v4(),m=pl({name:`all-${Ze.default(s)}`,universalIdentifier:f,objectUniversalIdentifier:this.lastObjectUniversalIdentifier}),v=r?R.join(Ie,r):R.join(Ie,gs,this.getFolderName(J.View));await C.ensureDir(v);const E=`all-${Ze.default(s)}.ts`,b=R.join(v,E);if(await C.pathExists(b)){const{overwrite:V}=await this.handleFileExist();if(!V)return}await C.writeFile(b,m),console.log(S.default.green("✓ Created view:"),S.default.cyan(R.relative(Ie,b)));const M=cl({name:s,viewUniversalIdentifier:f}),H=r?R.join(Ie,r):R.join(Ie,gs,this.getFolderName(J.NavigationMenuItem));await C.ensureDir(H);const X=`${Ze.default(s)}.ts`,U=R.join(H,X);if(await C.pathExists(U)){const{overwrite:V}=await this.handleFileExist();if(!V)return}await C.writeFile(U,M),console.log(S.default.green("✓ Created navigation menu item:"),S.default.cyan(R.relative(Ie,U)))}async getEntity(){const{entity:s}=await ot.default.prompt([{type:"select",name:"entity",message:"What entity do you want to create?",default:"",choices:Object.values(J)}]);return s}async handleFileExist(){return await ot.default.prompt([{type:"confirm",name:"overwrite",message:"File already exists. Do you want to overwrite it?",default:!1}])}async getEntityName(s){const{name:r}=await ot.default.prompt([{type:"input",name:"name",message:`Enter a name for your new ${s}:`,default:"",validate:l=>l.length===0?`${s} name is required`:!0}]);return r}async getFieldData(){return ot.default.prompt([{type:"input",name:"name",message:"Enter a name for your field:",default:"",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"label",message:"Enter a label for your field:",default:s=>hs(s.name),validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"select",name:"type",message:"Select the field type:",choices:Object.values(k.R),default:k.R.TEXT},{type:"input",name:"objectUniversalIdentifier",message:"Enter the universalIdentifier of the object this field belongs to:",default:"fill-later",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"description",message:"Enter a description for your field (optional):",default:""}])}async getObjectData(){return ot.default.prompt([{type:"input",name:"nameSingular",message:"Enter a name singular for your object (eg: company):",default:"",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"namePlural",message:"Enter a name plural for your object (eg: companies):",default:"",validate:(s,r)=>s.trim()===r?.nameSingular.trim()?"Name plural must be different from name singular":!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"labelSingular",message:"Enter a label singular for your object:",default:s=>hs(s.nameSingular),validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"labelPlural",message:"Enter a label plural for your object:",default:s=>hs(s.namePlural),validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0}])}async getViewData(){return ot.default.prompt([{type:"input",name:"name",message:"Enter a name for your view:",default:"",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"objectUniversalIdentifier",message:"Enter the universalIdentifier of the object this view belongs to:",default:"fill-later",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0}])}getFolderName(s){return`${Ze.default(s)}s`}getFileName(s,r){switch(r){case J.FrontComponent:return`${Ze.default(s)}.tsx`;default:return`${Ze.default(s)}.ts`}}}const Ky=o=>{const s=new Cy,r=new Py,l=new Ry,f=new ky,m=new Ny;o.command("auth:login").description("Authenticate with Twenty").option("--api-key <key>","API key for authentication").option("--api-url <url>","Twenty API URL").action(async U=>{await r.execute(U)}),o.command("auth:logout").description("Remove authentication credentials").action(async()=>{await l.execute()}),o.command("auth:status").description("Check authentication status").action(async()=>{await f.execute()}),o.command("auth:switch [workspace]").description("Switch the default workspace for authentication").action(async U=>{await m.execute({workspace:U})}),o.command("auth:list").description("List all configured workspaces").action(async()=>{await s.execute()});const v=new Ty,E=new Fy,b=new by,M=new zy,H=new Ly,X=new Oy;o.command("app:dev [appPath]").description("Watch and sync local application changes").action(async U=>{await v.execute({appPath:jn(U)})}),o.command("app:typecheck [appPath]").description("Run TypeScript type checking on the application").action(async U=>{await E.execute({appPath:jn(U)})}),o.command("app:uninstall [appPath]").description("Uninstall application from Twenty").option("-y, --yes","Skip confirmation prompt").action(async(U,V)=>{try{const ie=await b.execute({appPath:jn(U),askForConfirmation:!V?.yes});process.exit(ie.success?0:1)}catch{process.exit(1)}}),o.command("entity:add [entityType]").option("--path <path>","Path in which the entity should be created.").description(`Add a new entity to your application (${Object.values(J).join("|")})`).action(async(U,V)=>{await M.execute(U,V?.path)}),o.command("function:logs [appPath]").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").description("Watch application function logs").action(async(U,V)=>{await H.execute({...V,appPath:jn(U)})}),o.command("function:execute [appPath]").option("--postInstall","Execute post-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").description("Execute a logic function with a JSON payload").action(async(U,V)=>{!V?.postInstall&&!V?.functionUniversalIdentifier&&!V?.functionName&&(console.error(S.default.red("Error: Either --postInstall or --functionName (-n) or --functionUniversalIdentifier (-u) is required.")),process.exit(1)),await X.execute({...V,payload:V?.payload??"{}",appPath:jn(U)})})},Jy="0.6.1",Vy={version:Jy};Hm.inspect.defaultOptions.depth=10;const mn=new ml.Command;mn.name("twenty").description("CLI for Twenty application development").version(Vy.version);mn.option("--workspace <name>","Use a specific workspace configuration (overrides the default set by auth:switch)");mn.hook("preAction",async o=>{let r=(o.optsWithGlobals?o.optsWithGlobals():o.opts()).workspace;r||(r=await new we().getDefaultWorkspace()),we.setActiveWorkspace(r),console.log(S.default.gray(`👩‍💻 Workspace - ${we.getActiveWorkspace()}`))});Ky(mn);mn.exitOverride();try{mn.parse()}catch(o){o instanceof ml.CommanderError&&process.exit(o.exitCode),o instanceof Error&&(console.error(S.default.red("Error:"),o.message),process.exit(1))}