botmux 3.18.4 → 3.18.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/.runtime-build-id +1 -1
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +98 -5
  4. package/dist/cli.js.map +1 -1
  5. package/dist/core/binary-install-shape.d.ts +77 -0
  6. package/dist/core/binary-install-shape.d.ts.map +1 -0
  7. package/dist/core/binary-install-shape.js +117 -0
  8. package/dist/core/binary-install-shape.js.map +1 -0
  9. package/dist/core/binary-self-update.d.ts +82 -0
  10. package/dist/core/binary-self-update.d.ts.map +1 -0
  11. package/dist/core/binary-self-update.js +239 -0
  12. package/dist/core/binary-self-update.js.map +1 -0
  13. package/dist/core/maintenance.d.ts +88 -1
  14. package/dist/core/maintenance.d.ts.map +1 -1
  15. package/dist/core/maintenance.js +149 -8
  16. package/dist/core/maintenance.js.map +1 -1
  17. package/dist/core/release-download.d.ts +13 -0
  18. package/dist/core/release-download.d.ts.map +1 -0
  19. package/dist/core/release-download.js +130 -0
  20. package/dist/core/release-download.js.map +1 -0
  21. package/dist/dashboard/hd2d-assets.d.ts +2 -3
  22. package/dist/dashboard/hd2d-assets.d.ts.map +1 -1
  23. package/dist/dashboard/hd2d-assets.js +7 -109
  24. package/dist/dashboard/hd2d-assets.js.map +1 -1
  25. package/dist/dashboard/web/app.d.ts.map +1 -1
  26. package/dist/dashboard/web/app.js +7 -1
  27. package/dist/dashboard/web/app.js.map +1 -1
  28. package/dist/dashboard/web/settings-page.d.ts.map +1 -1
  29. package/dist/dashboard/web/settings-page.js.map +1 -1
  30. package/dist/dashboard-web/app.js +1 -1
  31. package/dist/dashboard.js +120 -13
  32. package/dist/dashboard.js.map +1 -1
  33. package/dist/utils/file-lock.d.ts +25 -0
  34. package/dist/utils/file-lock.d.ts.map +1 -1
  35. package/dist/utils/file-lock.js +34 -4
  36. package/dist/utils/file-lock.js.map +1 -1
  37. package/dist/utils/global-install.d.ts +19 -0
  38. package/dist/utils/global-install.d.ts.map +1 -1
  39. package/dist/utils/global-install.js +28 -1
  40. package/dist/utils/global-install.js.map +1 -1
  41. package/dist/utils/install-info.d.ts +37 -1
  42. package/dist/utils/install-info.d.ts.map +1 -1
  43. package/dist/utils/install-info.js +45 -3
  44. package/dist/utils/install-info.js.map +1 -1
  45. package/package.json +7 -7
@@ -1 +1 @@
1
- import{a as kt,b as _e,d as xt}from"./chunks/chunk-2PVRDXEL.js";import{a as Et,b as Mt}from"./chunks/chunk-Z67OSM5P.js";import{b as $e}from"./chunks/chunk-SZOB6VK2.js";import{a as bt}from"./chunks/chunk-BD3PZGH2.js";import{b as Ue}from"./chunks/chunk-G5ZS2YUS.js";import{b as Be}from"./chunks/chunk-OXSVWLER.js";import{a as me,b as wt,c as yt}from"./chunks/chunk-NJCJR3U2.js";import"./chunks/chunk-KTQ7B6ZR.js";import{c as Ie}from"./chunks/chunk-CEUCNZFJ.js";import{i as gt,j as vt}from"./chunks/chunk-NYY66DNC.js";import"./chunks/chunk-ECFC7UG2.js";import{a as ue,b as lt}from"./chunks/chunk-QITAMHW6.js";import{G as pt,I as ht,L as mt,M as he,c as pe,u as He,v as ct,w as f,x as s,y as dt,z as ut}from"./chunks/chunk-BU3Q6XC6.js";import{a as yn,b as kn}from"./chunks/chunk-ARROO6TE.js";import{c as Y,d as wn,e as ft}from"./chunks/chunk-3YZFAHNK.js";var nn=Y(yn(),1),on=Y(kn(),1),l=Y(wn(),1);var ze="botmux:close-theme-menu",xn={palette:'<circle cx="13.5" cy="6.5" r=".5" fill="currentColor"/><circle cx="17.5" cy="10.5" r=".5" fill="currentColor"/><circle cx="8.5" cy="7.5" r=".5" fill="currentColor"/><circle cx="6.5" cy="12.5" r=".5" fill="currentColor"/><path d="M12 2a10 10 0 0 0 0 20h1.7a2.3 2.3 0 0 0 1.6-4c-.5-.5-.2-1.3.5-1.3H17a5 5 0 0 0 5-5 9.7 9.7 0 0 0-10-9.7z"/>',monitor:'<rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/>',sun:'<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>',moon:'<path d="M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"/>',cpu:'<path d="M12 20v2"/><path d="M12 2v2"/><path d="M17 20v2"/><path d="M17 2v2"/><path d="M2 12h2"/><path d="M2 17h2"/><path d="M2 7h2"/><path d="M20 12h2"/><path d="M20 17h2"/><path d="M20 7h2"/><path d="M7 20v2"/><path d="M7 2v2"/><rect x="4" y="4" width="16" height="16" rx="2"/><rect x="8" y="8" width="8" height="8" rx="1"/>',zap:'<path d="M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"/>',chevron:'<path d="m6 9 6 6 6-6"/>'},Nt=[{labelKey:"theme.base",options:[{value:"system",labelKey:"status.system",icon:"monitor"},{value:"light",labelKey:"status.light",icon:"sun"},{value:"dark",labelKey:"status.dark",icon:"moon"}]},{labelKey:"theme.skins",options:[{value:"cyber",labelKey:"skin.cyber",icon:"cpu"},{value:"fallout",labelKey:"skin.fallout",icon:"zap"}]}],Rt=Nt.flatMap(e=>e.options),L=!1,Z=null,Q=null,En=70,Mn=120;function Ke(e){return`<svg class="tm-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${xn[e]??""}</svg>`}function Rn(e){return e.replace(/[&<>"]/g,n=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[n])}function Lt(){let e=document.getElementById("theme-menu"),n=document.getElementById("theme-menu-btn"),o=document.getElementById("theme-menu-pop");if(!e||!n||!o||e.dataset.themeMenuInit==="1")return;e.dataset.themeMenuInit="1",o.innerHTML=Nt.map(u=>`<div class="tm-group" data-label-key="${u.labelKey}"></div>`+u.options.map(m=>`<button type="button" class="tm-item" role="option" data-value="${m.value}"><span class="tm-ic">${Ke(m.icon)}</span><span class="tm-label" data-label-key="${m.labelKey}"></span></button>`).join("")).join("");let a=()=>{if(!L)return;let u=n.getBoundingClientRect(),m=12,k=Math.min(Math.max(o.offsetWidth||216,216),Math.max(0,window.innerWidth-m*2)),w=m+k/2,g=window.innerWidth-m-k/2,x=u.left+u.width/2,y=Math.min(Math.max(x,w),Math.max(w,g)),O=Math.max(180,window.innerHeight-u.bottom-20);o.style.setProperty("--theme-menu-pop-left",`${Math.round(y)}px`),o.style.setProperty("--theme-menu-pop-top",`${Math.round(u.bottom+8)}px`),o.style.setProperty("--theme-menu-pop-max-height",`${Math.round(O)}px`)},r=u=>{Z!=null&&(window.clearTimeout(Z),Z=null),Q!=null&&(window.clearTimeout(Q),Q=null),L=u,n.setAttribute("aria-expanded",String(L)),document.body.classList.toggle("theme-menu-open",L),L?(o.hidden=!1,a(),window.requestAnimationFrame(()=>e.classList.add("open"))):(e.classList.remove("open"),Q=window.setTimeout(()=>{Q=null,L||(o.hidden=!0)},Mn))},d=()=>r(!0),p=()=>{Z==null&&(Z=window.setTimeout(()=>r(!1),En))},h=u=>{u.pointerType!=="touch"&&d()},c=u=>{u.pointerType!=="touch"&&p()};e.addEventListener("pointerenter",h),e.addEventListener("pointerleave",c),o.addEventListener("pointerenter",h),o.addEventListener("pointerleave",c),n.addEventListener("click",u=>{u.stopPropagation(),r(!L)}),n.addEventListener("focus",()=>{n.matches(":focus-visible")&&d()}),e.addEventListener("focusout",u=>{let m=u.relatedTarget;(!(m instanceof Node)||!e.contains(m))&&p()}),o.addEventListener("click",u=>{let m=u.target.closest(".tm-item");m&&(f.setTheme(m.dataset.value??"system"),r(!1))}),document.addEventListener("click",u=>{L&&!e.contains(u.target)&&r(!1)}),document.addEventListener("pointermove",u=>{if(!L||u.pointerType==="touch")return;let m=u.target;m instanceof Node&&e.contains(m)||p()}),document.addEventListener("keydown",u=>{u.key==="Escape"&&L&&r(!1)}),window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),window.addEventListener(ze,()=>{L&&r(!1)}),Fe()}function Fe(){let e=document.getElementById("theme-menu-btn");if(!e)return;let n=Rt.find(o=>o.value===f.theme)??Rt[0];e.innerHTML=`<span class="tm-ic">${Ke("palette")}</span><span class="tm-current">${Rn(s(n.labelKey))}</span><span class="tm-chev">${Ke("chevron")}</span>`,document.querySelectorAll("#theme-menu-pop [data-label-key]").forEach(o=>{o.textContent=s(o.dataset.labelKey??"")}),document.querySelectorAll("#theme-menu-pop .tm-item").forEach(o=>{o.classList.toggle("active",o.dataset.value===f.theme)})}function v(e,n,o,a,r=!1){return{id:e,routePrefix:n,rerenderOnUiChange:r,load:async()=>(await o())[a]}}var Nn=[v("agent-workbench-dock","#/agent-workbench-dock",()=>import("./chunks/agent-workbench-dock-page-XHJUYFGN.js"),"renderAgentWorkbenchDockPage"),v("agent-workbench","#/agent-workbench",()=>import("./chunks/agent-workbench-page-FLKTLIRM.js"),"renderAgentWorkbenchPage"),{id:"plugins",routePrefix:"#/plugins",rerenderOnUiChange:!1,load:async()=>{let e=await import("./chunks/plugin-page-AKQZFAC4.js");return n=>e.renderPluginPage(n)}},v("workflows","#/workflows",()=>import("./chunks/v3-page-766CBD7H.js"),"renderV3RunsPage"),v("groups","#/groups",()=>import("./chunks/groups-page-L4ZJNWVR.js"),"renderGroupsPage"),v("settings","#/settings",()=>import("./chunks/settings-page-2IRIS3FP.js"),"renderSettingsPage"),v("bot-defaults","#/bot-defaults",()=>import("./chunks/bot-defaults-page-XMGLZZ2E.js"),"renderBotDefaultsPage"),v("skills","#/skills",()=>import("./chunks/skills-page-5RZPM6HJ.js"),"renderSkillsPage"),v("customization","#/customization",()=>import("./chunks/customization-page-VQJAEDZY.js"),"renderCustomizationPage"),v("connectors-logs","#/connectors/logs",()=>import("./chunks/connectors-page-WDM4CEAU.js"),"renderConnectorsLogsPage"),v("webhook-logs","#/webhook-logs",()=>import("./chunks/connectors-page-WDM4CEAU.js"),"renderConnectorsLogsPage"),v("connectors","#/connectors",()=>import("./chunks/connectors-page-WDM4CEAU.js"),"renderConnectorsPage"),v("team-manage","#/team/manage",()=>import("./chunks/team-federation-page-KERG6LKC.js"),"renderTeamManagePage"),v("team","#/team",()=>import("./chunks/team-federation-page-KERG6LKC.js"),"renderTeamFederationPage"),v("roles-profile","#/roles/profile",()=>import("./chunks/roles-page-QO3YCA7D.js"),"renderRoleProfilesPage"),v("roles","#/roles",()=>import("./chunks/roles-page-QO3YCA7D.js"),"renderRolesPage"),v("schedules","#/schedules",()=>import("./chunks/schedules-page-YNGSKDQW.js"),"renderSchedulesPage"),v("whiteboards","#/whiteboards",()=>import("./chunks/whiteboards-page-2M6XZD5C.js"),"renderWhiteboardsPage"),v("monitoring","#/monitoring",()=>import("./chunks/monitoring-page-AUSXMPYO.js"),"renderMonitoringPage"),v("sessions","#/sessions",()=>import("./chunks/sessions-page-BWR4UB6X.js"),"renderSessionsPage"),v("monitor-room","#/monitor-room",()=>import("./chunks/monitor-room-7LZUJQPF.js"),"renderMonitorRoomPage",!0),v("office","#/office",()=>import("./chunks/office-page-6ZU6MAZN.js"),"renderOfficePage"),v("insights","#/insights",()=>import("./chunks/insights-page-7LUJU2CX.js"),"renderInsightsPage"),v("feedback","#/feedback",()=>import("./chunks/feedback-page-GMJ4FLJ4.js"),"renderFeedbackPage")];function Tt(e){return Nn.find(n=>n.exact?e===n.routePrefix:e.startsWith(n.routePrefix))}async function St(){let e=await import("./chunks/overview-page-QBC5CIYH.js");return n=>e.renderOverviewPage(n)}function Pt(){return{seq:0,pageDispose:null,rerenderOnUiChange:!0}}function Ot(e){let n=++e.seq;return e.pageDispose&&(e.pageDispose(),e.pageDispose=null),n}function Ct(e,n){return n===e.seq}async function At(e,n,o,a,r={}){let d=await a();if(!Ct(e,n))return!1;let p=d(o);return Ct(e,n)?(e.pageDispose=typeof p=="function"?p:null,e.rerenderOnUiChange=r.rerenderOnUiChange??!0,!0):(typeof p=="function"&&p(),!1)}var Ln="botmux.dashboard.stale-chunk-reload.v1:",Tn=/Failed to fetch dynamically imported module|Importing a module script failed|error loading dynamically imported module|dynamically imported module/i,Sn=/\b(?:https?:\/\/|\/assets\/)\S+?\.js\b/;function Dt(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}function Ht(e){return Tn.test(Dt(e))}function Cn(e,n){let r=Dt(e).match(Sn)?.[0]||`${n.href}|${n.hash}`;return`${Ln}${r.slice(-240)}`}function Pn(e,n){if(!Ht(e))return!1;let o=Cn(e,n);try{if(n.sessionStorage.getItem(o)==="1")return!1;n.sessionStorage.setItem(o,"1")}catch{return!1}return n.reload(),!0}function It(e,n){if(!Ht(e))return!1;let o;try{o=n.getSessionStorage()}catch{return!1}return Pn(e,{...n,sessionStorage:o})}var On=new Set(["auto","scroll","overlay"]),fe=28,P=3,K=6,Bt=!1,zt=null,Ut=new WeakMap,A=new Map,$t=null,_t=null,We=0,Ve=0,ee=null;function An(e){return e.closest("dialog[open]")??document.body}function Dn(e){let n=Ut.get(e);if(n?.isConnected)return n;let o=document.createElement("div");return o.className="floating-scrollbar-layer",o.setAttribute("aria-hidden","true"),e.appendChild(o),Ut.set(e,o),o}function Hn(e){return On.has(e)}function qe(e,n){let o=getComputedStyle(e),a=n==="y"?o.overflowY:o.overflowX;return Hn(a)?n==="y"?e.scrollHeight-e.clientHeight>1:e.scrollWidth-e.clientWidth>1:!1}function In(e){if(!e.isConnected||e.closest("[hidden]"))return!1;let n=e.getBoundingClientRect();return n.width>0&&n.height>0&&n.bottom>0&&n.right>0&&n.top<window.innerHeight&&n.left<window.innerWidth}function Bn(e){return[e,...Array.from(e.querySelectorAll("*"))].filter(o=>In(o)&&(qe(o,"x")||qe(o,"y")))}function be(e){e.hideTimer!==void 0&&window.clearTimeout(e.hideTimer),e.track.remove()}function Un(e,n){let o=A.get(e);o||(o={},A.set(e,o));let a=o[n],r=An(e),d=Dn(r);if(a?.track.parentElement===d)return a;a&&be(a);let p=document.createElement("div"),h=document.createElement("div");p.className=`floating-scrollbar floating-scrollbar-${n}`,h.className="floating-scrollbar-thumb",p.appendChild(h),d.appendChild(p);let c={target:e,axis:n,track:p,thumb:h,hideTimer:void 0};return o[n]=c,c}function je(e,n=!1){e.track.classList.add("is-visible"),e.hideTimer!==void 0&&window.clearTimeout(e.hideTimer),e.hideTimer=n?void 0:window.setTimeout(()=>{e.track.classList.remove("is-visible","is-active"),e.hideTimer=void 0},900)}function $n(e){let{target:n,axis:o,track:a,thumb:r}=e,d=n.getBoundingClientRect();if(o==="y"){let w=Math.max(0,d.top+P),g=Math.min(window.innerHeight,d.bottom-P),x=Math.max(0,g-w);if(x<fe||n.scrollHeight<=n.clientHeight){a.hidden=!0;return}let y=Math.max(fe,Math.round(x*n.clientHeight/n.scrollHeight)),O=Math.max(1,n.scrollHeight-n.clientHeight),B=Math.round((x-y)*n.scrollTop/O);a.hidden=!1,a.style.left=`${Math.min(window.innerWidth-K-P,Math.max(P,d.right-K-P))}px`,a.style.top=`${w}px`,a.style.width=`${K}px`,a.style.height=`${x}px`,r.style.width="100%",r.style.height=`${y}px`,r.style.transform=`translate3d(0, ${B}px, 0)`;return}let p=Math.max(0,d.left+P),h=Math.min(window.innerWidth,d.right-P),c=Math.max(0,h-p);if(c<fe||n.scrollWidth<=n.clientWidth){a.hidden=!0;return}let u=Math.max(fe,Math.round(c*n.clientWidth/n.scrollWidth)),m=Math.max(1,n.scrollWidth-n.clientWidth),k=Math.round((c-u)*n.scrollLeft/m);a.hidden=!1,a.style.left=`${p}px`,a.style.top=`${Math.min(window.innerHeight-K-P,Math.max(P,d.bottom-K-P))}px`,a.style.width=`${c}px`,a.style.height=`${K}px`,r.style.width=`${u}px`,r.style.height="100%",r.style.transform=`translate3d(${k}px, 0, 0)`}function z(){We||(We=window.requestAnimationFrame(()=>{We=0,Kn()}))}function _n(){Ve||(Ve=window.setTimeout(()=>{Ve=0,z()},120))}function Kn(){let e=zt;if(!e)return;let n=new Set(Bn(e));for(let[o,a]of A)n.has(o)||(a.x&&be(a.x),a.y&&be(a.y),A.delete(o));for(let o of n){let a=o===ee;for(let r of["x","y"]){let d=A.get(o);if(!qe(o,r)){let h=d?.[r];h&&(be(h),delete d?.[r]);continue}let p=Un(o,r);$n(p),a&&je(p,!0)}}}function zn(e){if(!(e instanceof HTMLElement))return;let n=A.get(e);if(n)for(let o of Object.values(n))o&&(o.track.classList.add("is-active"),je(o))}function Fn(e){for(let n=e;n;n=n.parentElement)if(n instanceof HTMLElement&&A.has(n))return n;return null}function Kt(e){if(ee===e)return;let n=ee?A.get(ee):void 0;if(ee=e,n)for(let a of Object.values(n))a?.track.classList.remove("is-visible");let o=e?A.get(e):void 0;if(o)for(let a of Object.values(o))a&&je(a,!0)}function Ft(e){Bt||(Bt=!0,zt=e,document.documentElement.classList.add("floating-scrollbars-on"),$t=typeof ResizeObserver>"u"?null:new ResizeObserver(z),$t?.observe(e),_t=new MutationObserver(n=>{for(let o of n){let a=o.target;if(!(a instanceof Element&&a.closest(".floating-scrollbar-layer"))){_n();return}}}),_t.observe(e,{attributes:!0,attributeFilter:["class","style","hidden","open"],childList:!0,subtree:!0}),document.addEventListener("scroll",n=>{zn(n.target),z()},!0),window.addEventListener("resize",z),window.addEventListener("hashchange",z),document.addEventListener("pointermove",n=>{Kt(Fn(document.elementFromPoint(n.clientX,n.clientY)))}),document.addEventListener("pointerleave",()=>Kt(null)),z())}var Wt=!1,F=null,ge=null,W=null;function qt(){if(F)return F;let e=document.createElement("div");return e.className="icon-tip",e.setAttribute("role","tooltip"),e.style.display="none",document.body.appendChild(e),F=e,e}function Wn(e){let n=qt(),o=gt(e,document.body);return n.parentNode!==o&&o.appendChild(n),n}function Vn(e){let n=qt(),o=e.getBoundingClientRect(),a=n.offsetWidth,r=n.offsetHeight,d=8,p=o.top<r+d+4,h=o.left+o.width/2-a/2;h=Math.min(Math.max(h,6),window.innerWidth-a-6);let c=p?o.bottom+d:o.top-r-d;n.style.left=`${Math.round(h)}px`,n.style.top=`${Math.round(c)}px`,n.dataset.placement=p?"bottom":"top"}function te(){W&&(clearTimeout(W),W=null),ge=null,F&&(F.style.display="none",F.classList.remove("show"))}function Vt(e){let n=e.getAttribute("data-tip");if(!n)return;ge=e;let o=Wn(e);o.textContent=n,o.style.display="block",o.classList.remove("show"),Vn(e),requestAnimationFrame(()=>{ge===e&&o.classList.add("show")})}function Ge(e){return e instanceof Element?e.closest("[data-tip]"):null}function jt(){Wt||typeof document>"u"||(Wt=!0,document.addEventListener("pointerover",e=>{let n=Ge(e.target);!n||n===ge||(W&&clearTimeout(W),W=setTimeout(()=>Vt(n),120))}),document.addEventListener("pointerout",e=>{let n=Ge(e.target);if(!n)return;let o=e.relatedTarget instanceof Element?e.relatedTarget:null;o&&(o===n||n.contains(o))||te()}),document.addEventListener("focusin",e=>{let n=Ge(e.target);n&&Vt(n)}),document.addEventListener("focusout",te),document.addEventListener("click",te,!0),window.addEventListener("scroll",te,!0),window.addEventListener("resize",te))}function ve(e,n){if(e)try{let o=new URL(e);if(!["http:","https:"].includes(o.protocol)||o.username||o.password)return;let a=n.startsWith("#/")&&n.length<=4096&&!/[\u0000-\u001f\u007f]/.test(n)?n:"#/";return o.searchParams.set("next",`/${a}`),o.toString()}catch{return}}var t=Y(ft(),1),qn=["roles","role-profiles","bot-defaults","skills","customization","plugins","team","connectors","insights","feedback","whiteboards"],Gt=[{id:"overview",href:"#/",labelKey:"nav.overview",icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("rect",{x:"1.5",y:"1.5",width:"5.4",height:"5.4",rx:"1.5"}),(0,t.jsx)("rect",{x:"9.1",y:"1.5",width:"5.4",height:"5.4",rx:"1.5"}),(0,t.jsx)("rect",{x:"1.5",y:"9.1",width:"5.4",height:"5.4",rx:"1.5"}),(0,t.jsx)("rect",{x:"9.1",y:"9.1",width:"5.4",height:"5.4",rx:"1.5"})]})},{id:"sessions",href:"#/sessions",labelKey:"nav.sessions",icon:(0,t.jsx)("path",{d:"M2 3.5h12v7H6l-3 3v-3H2z"})},{id:"agent-workbench",href:"#/agent-workbench",labelKey:"nav.workbench",icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),(0,t.jsx)("path",{d:"M4.5 6.5l2 1.5-2 1.5M8 10h3"})]})},{id:"groups",href:"#/groups",labelKey:"nav.groups",icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("circle",{cx:"5.6",cy:"5.8",r:"2.4"}),(0,t.jsx)("circle",{cx:"11",cy:"6.8",r:"1.9"}),(0,t.jsx)("path",{d:"M1.8 13.2c.5-2.4 2-3.6 3.8-3.6s3.3 1.2 3.8 3.6M9.8 12.6c.4-1.7 1.5-2.6 2.8-2.6 1 0 1.9.5 2.4 1.6"})]})},{id:"roles",href:"#/roles",labelKey:"nav.roles",manage:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M8 1.8l5.2 2v3.4c0 3.4-2.2 5.9-5.2 7-3-1.1-5.2-3.6-5.2-7V3.8z"}),(0,t.jsx)("path",{d:"M5.8 8l1.6 1.6 2.8-3"})]})},{id:"monitoring",href:"#/monitoring",labelKey:"nav.monitoring",icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M2 9.2h2.3l1.3-4.8 2.5 8.4 1.8-5.1h4.1"}),(0,t.jsx)("path",{d:"M2 2.5h12v11H2z"})]})},{id:"insights",href:"#/insights",labelKey:"nav.insights",manage:!0,icon:(0,t.jsx)(t.Fragment,{children:(0,t.jsx)("path",{d:"M2 2v12h12M5 11V7M8.5 11V4.5M12 11V8.5"})})},{id:"feedback",href:"#/feedback",labelKey:"nav.feedback",manage:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M2.2 3.2h11.6v8H8l-3.2 2.6v-2.6H2.2z"}),(0,t.jsx)("path",{d:"M5 6.2h6M5 8.3h4"})]})},{id:"workflows",href:"#/workflows",labelKey:"nav.workflows",icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("circle",{cx:"3.4",cy:"3.6",r:"1.9"}),(0,t.jsx)("circle",{cx:"3.4",cy:"12.4",r:"1.9"}),(0,t.jsx)("circle",{cx:"12.6",cy:"8",r:"1.9"}),(0,t.jsx)("path",{d:"M5.2 4.4l5.6 2.8M5.2 11.6l5.6-2.8"})]})},{id:"schedules",href:"#/schedules",labelKey:"nav.schedules",icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("circle",{cx:"8",cy:"8",r:"6.2"}),(0,t.jsx)("path",{d:"M8 4.5V8l2.4 1.6"})]})},{id:"whiteboards",href:"#/whiteboards",labelKey:"nav.whiteboards",manage:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("rect",{x:"2.2",y:"2.2",width:"11.6",height:"11.6",rx:"2"}),(0,t.jsx)("path",{d:"M4.8 5.2h6.4M4.8 8h6.4M4.8 10.8h4"})]})},{id:"office",href:"#/office",labelKey:"nav.office",icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("rect",{x:"3",y:"4",width:"10",height:"7",rx:"2"}),(0,t.jsx)("circle",{cx:"6",cy:"7.5",r:"1"}),(0,t.jsx)("circle",{cx:"10",cy:"7.5",r:"1"}),(0,t.jsx)("path",{d:"M8 4V2M4.5 11v2M11.5 11v2"})]})},{id:"bot-defaults",href:"#/bot-defaults",labelKey:"nav.botDefaults",manage:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("rect",{x:"2.5",y:"5",width:"11",height:"8",rx:"2"}),(0,t.jsx)("circle",{cx:"5.8",cy:"9",r:"1"}),(0,t.jsx)("circle",{cx:"10.2",cy:"9",r:"1"}),(0,t.jsx)("path",{d:"M8 5V2.5M5.5 13v1.2M10.5 13v1.2"})]})},{id:"skills",href:"#/skills",labelKey:"nav.skills",manage:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M3 2.5h10v3H3zM3 7h10v6.5H3z"}),(0,t.jsx)("path",{d:"M5.4 9.2h5.2M5.4 11.2h3.8"})]})},{id:"customization",href:"#/customization",labelKey:"nav.customization",manage:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M11.5 2.5l2 2-7 7-2.6.6.6-2.6z"}),(0,t.jsx)("path",{d:"M2.5 13.5h5"})]})},{id:"plugins",href:"#/plugins",label:"\u63D2\u4EF6",manage:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M6.4 1.8h3.2v3h2.8v3.2H9.6v2.8H6.4V8H3.6V4.8h2.8z"}),(0,t.jsx)("path",{d:"M2.2 11.8h11.6v2.4H2.2z"})]})},{id:"team",href:"#/team",labelKey:"nav.team",manage:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("circle",{cx:"8",cy:"8",r:"6.2"}),(0,t.jsx)("path",{d:"M1.8 8h12.4M8 1.8c-2 1.8-2 10.6 0 12.4 2-1.8 2-10.6 0-12.4z"})]})},{id:"connectors",href:"#/connectors",labelKey:"nav.connectors",manage:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M5.5 6.5v-3a2.5 2.5 0 0 1 5 0v3"}),(0,t.jsx)("rect",{x:"3.5",y:"6.5",width:"9",height:"7",rx:"2"})]})},{id:"settings",href:"#/settings",labelKey:"nav.settings",icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M8 1.75 9.35 2.05 10 3.28l1.38.3 1.04-.96.96.96-.96 1.04.3 1.38 1.23.65L14.25 8l-.3 1.35-1.23.65-.3 1.38.96 1.04-.96.96-1.04-.96-1.38.3-.65 1.23L8 14.25l-1.35-.3L6 12.72l-1.38-.3-1.04.96-.96-.96.96-1.04-.3-1.38-1.23-.65L1.75 8l.3-1.35 1.23-.65.3-1.38-.96-1.04.96-.96 1.04.96 1.38-.3.65-1.23z"}),(0,t.jsx)("circle",{cx:"8",cy:"8",r:"2"})]})}],jn=[{id:"overview",labelKey:"nav.group.overview",items:["overview"]},{id:"collab",labelKey:"nav.group.collab",items:["sessions","agent-workbench","groups","schedules","workflows","office"]},{id:"workforce",labelKey:"nav.group.workforce",items:["roles","skills","customization","bot-defaults"]},{id:"analytics",labelKey:"nav.group.analytics",items:["monitoring","insights","feedback"]},{id:"manage",labelKey:"nav.group.manage",items:["connectors","team","plugins","whiteboards","settings"]}],oe=[],T=!0,ye=!1,Ee=location.hash||"#/",V=null,ae=!1,re=null,ke=null,an=null,xe=null,rn=null,I=Pt(),sn="botmux.ownerAvatar.v1",Gn=new Set(["working","analyzing","active","starting"]),Qe="botmux:auth-expired",Me;function ne(e){return(0,t.jsx)("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e})}function Xt(e){return e.labelKey?s(e.labelKey):e.label??""}function Xn(e,n){let o=n||"#/";return e.id==="plugins"&&oe.some(a=>a.href===o||o.startsWith(`${a.href}?`)||o.startsWith(`${a.href}/`))?!1:e.id==="sessions"&&(o==="#/monitor-room"||o.startsWith("#/monitor-room?")||o.startsWith("#/monitor-room/"))||e.id==="connectors"&&(o==="#/webhook-logs"||o.startsWith("#/webhook-logs?")||o.startsWith("#/webhook-logs/"))?!0:e.href===o||e.href!=="#/"&&(o.startsWith(`${e.href}?`)||o.startsWith(`${e.href}/`))}function Jn(){let e=_e()?Gt.filter(o=>o.id!=="workflows"):Gt;if(oe.length===0)return e;let n=e.findIndex(o=>o.id==="plugins");return n<0?[...e,...oe]:[...e.slice(0,n+1),...oe,...e.slice(n+1)]}function Yn(e){let n=[];return Xn(e,Ee)&&n.push("active"),e.id==="settings"&&ae&&n.push("nav-has-update"),n.length?n.join(" "):void 0}function Zn(e){return(0,t.jsxs)("a",{href:e.href,"data-route":e.id,className:[Yn(e),e.plugin?"sidebar-plugin-item":""].filter(Boolean).join(" ")||void 0,title:e.plugin?Xt(e):void 0,children:[ne(e.icon),(0,t.jsx)("span",{className:"sidebar-nav-label",children:Xt(e)}),e.id==="settings"&&ae?(0,t.jsx)(vt,{className:"nav-update-tip",label:Yt(),trigger:(0,t.jsx)("span",{className:"nav-update-dot","aria-hidden":"true"}),preventClick:!1,focusable:!1,children:Yt()}):null]})}function ln(){let e=pe(new URLSearchParams(location.search).get("locale"));if(e)return e;let n=location.hash.indexOf("?");return n<0?null:pe(new URLSearchParams(location.hash.slice(n+1)).get("locale"))}function Jt(){let e=ln();return!e||e===f.locale?!1:(f.setLocale(e),!0)}function Qn(){let e=location.hash.indexOf("?");return e<0?null:{path:location.hash.slice(0,e)||"#/",params:new URLSearchParams(location.hash.slice(e+1))}}function eo(){let e=Qn(),n=e?.params.get("open");if(!e||!n||n!=="bot-onboarding"&&n!=="create-session")return!1;e.params.delete("open");let o=e.params.toString();return history.replaceState(null,"",o?`${e.path}?${o}`:e.path),n==="bot-onboarding"?window.dispatchEvent(new Event(me)):$e(),!0}function Yt(){let e=re?`v${re}`:"";return ke==="runtime"?s("update.navRuntimeBadgeTitle",{version:e}):s("update.navBadgeTitle",{version:e})}function Zt(e){xe=e}function Xe(){if(xe)return xe;let e=document.getElementById("root");if(!e)throw new Error("dashboard root is not mounted");return xe=e,e}function to(){return(0,l.useEffect)(()=>{Lt()},[]),(0,l.useEffect)(()=>{Fe()}),(0,t.jsxs)("div",{className:"theme-menu",id:"theme-menu",children:[(0,t.jsx)("button",{type:"button",className:"theme-menu-btn",id:"theme-menu-btn","aria-haspopup":"listbox","aria-expanded":"false","aria-label":"Theme",children:(0,t.jsx)("span",{className:"tm-ic",children:(0,t.jsxs)("svg",{className:"tm-svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,t.jsx)("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),(0,t.jsx)("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),(0,t.jsx)("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"}),(0,t.jsx)("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),(0,t.jsx)("path",{d:"M12 2a10 10 0 0 0 0 20h1.7a2.3 2.3 0 0 0 1.6-4c-.5-.5-.2-1.3.5-1.3H17a5 5 0 0 0 5-5 9.7 9.7 0 0 0-10-9.7z"})]})})}),(0,t.jsx)("div",{className:"theme-menu-pop",id:"theme-menu-pop",role:"listbox",hidden:!0})]})}function no(){let e=[...ue.sessions.values()],n=e.filter(c=>c.status!=="closed"),o=n.map(c=>({s:c,reason:mt(c)})).filter(c=>!!c.reason).sort((c,u)=>he(c.s)-he(u.s)),a=new Set(o.map(c=>String(c.s.sessionId??""))),r=n.filter(c=>Gn.has(String(c.status))&&!a.has(String(c.sessionId??""))).length,d=o[0]??null,p=Mt(e).filter(c=>c.online||c.active.length>0).length,h=Math.max(0,n.length-o.length-r);return{working:r,attention:o.length,idle:h,onlineBots:p,attentionNotice:d?{count:o.length,time:ut(he(d.s)),bot:ht(d.s),reason:d.reason}:null}}function we(e){return(0,t.jsxs)("div",{className:`topbar-status-row${e.hot?" topbar-status-row-hot":""}`,children:[(0,t.jsx)("span",{children:e.label}),(0,t.jsx)("b",{className:e.value>0?"status-count-on":void 0,children:e.value})]})}function oo(e){let{attention:n,idle:o,working:a}=e.summary,r=a+n+o,d=r===0?"conic-gradient(var(--border) 0 360deg)":(()=>{let p=a/r*360,h=p+n/r*360;return`conic-gradient(var(--accent) 0 ${p}deg, var(--warning) ${p}deg ${h}deg, var(--success) ${h}deg 360deg)`})();return(0,t.jsxs)("div",{className:"topbar-status-donut-wrap","aria-hidden":"true",children:[(0,t.jsx)("div",{className:"topbar-status-donut",style:{background:d}}),(0,t.jsxs)("div",{className:"topbar-status-donut-center",children:[(0,t.jsx)("b",{children:r}),(0,t.jsx)("span",{children:s("overview.openSessions")})]})]})}function Je(){window.dispatchEvent(new Event(ze))}function ao(e){let{autoOpen:n=!1,summary:o}=e,[a,r]=(0,l.useState)(!1),[d,p]=(0,l.useState)(!1),[h,c]=(0,l.useState)(!1),u=(0,l.useRef)(null),m=n&&!d,k=a||m;return(0,l.useEffect)(()=>{n||p(!1)},[n]),(0,l.useEffect)(()=>{if(!k)return;let g=x=>{let y=x.target;y instanceof Node&&u.current?.contains(y)||(r(!1),p(!0))};return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[k]),(0,t.jsxs)("div",{ref:u,className:`topbar-status-menu${m?" topbar-status-auto-open":""}${a?" is-open":""}${h?" suppress-hover":""}`,onPointerEnter:Je,onPointerLeave:()=>c(!1),onFocusCapture:Je,onBlur:g=>{let x=g.relatedTarget;(!(x instanceof Node)||!g.currentTarget.contains(x))&&r(!1)},onKeyDown:g=>{g.key==="Escape"&&(r(!1),p(!0),c(!0),g.currentTarget.querySelector("#status")?.focus())},children:[(0,t.jsx)("button",{type:"button",id:"status",className:"connection-status","aria-haspopup":"true","aria-expanded":k,onClick:()=>{if(Je(),k){r(!1),p(!0),c(!0);return}c(!1),r(!0)},children:s("overview.sessionOverview")}),(0,t.jsxs)("div",{className:"topbar-status-pop",children:[o.attentionNotice?(0,t.jsxs)("a",{className:"topbar-attention-notice",href:"#/sessions",children:[(0,t.jsx)("span",{className:"topbar-attention-dot","aria-hidden":"true"}),(0,t.jsxs)("span",{className:"topbar-attention-copy",children:[(0,t.jsx)("b",{children:s("strip.pending",{count:o.attentionNotice.count})}),(0,t.jsx)("small",{children:s("strip.longestCompact",{time:o.attentionNotice.time,bot:o.attentionNotice.bot,reason:o.attentionNotice.reason})})]}),(0,t.jsx)("span",{className:"topbar-attention-action",children:s("strip.handle")})]}):null,(0,t.jsxs)("div",{className:"topbar-status-list",children:[(0,t.jsx)(we,{label:s("overview.workingSessions"),value:o.working}),(0,t.jsx)(we,{label:s("overview.idleSessions"),value:o.idle}),(0,t.jsx)(we,{label:s("overview.attention"),value:o.attention,hot:o.attention>0}),(0,t.jsx)(we,{label:s("overview.onlineBots"),value:o.onlineBots})]}),(0,t.jsx)(oo,{summary:o})]})]})}function Qt(e){if(!e.open)return null;let n=!!e.loginUrl;return(0,t.jsx)("div",{id:"auth-expired-overlay",className:"auth-expired-overlay",role:"presentation",onClick:o=>{o.target===o.currentTarget&&e.onClose()},children:(0,t.jsxs)("div",{className:"auth-expired-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"auth-expired-title",children:[(0,t.jsx)("h2",{id:"auth-expired-title",children:n?"\u767B\u5F55 Dashboard":"\u8BBF\u95EE\u94FE\u63A5\u5DF2\u5931\u6548"}),(0,t.jsx)("p",{children:n?"\u5F53\u524D\u6D4F\u89C8\u5668\u5C1A\u672A\u767B\u5F55\u3002\u70B9\u51FB\u540E\u5C06\u901A\u8FC7 Botmux \u5E73\u53F0\u6821\u9A8C\u673A\u5668 owner \u6743\u9650\uFF0C\u5E76\u8FD4\u56DE\u5F53\u524D\u9875\u9762\uFF1B\u65E0\u6743\u9650\u8D26\u53F7\u4ECD\u4F1A\u88AB\u62D2\u7EDD\u3002":"\u5F53\u524D\u94FE\u63A5/\u8BBF\u95EE\u5DF2\u5931\u6548\uFF0C\u8BF7\u4F7F\u7528\u6700\u65B0\u6388\u6743\u94FE\u63A5\u91CD\u65B0\u8FDB\u5165\uFF08\u8FD0\u884C botmux dashboard \u83B7\u53D6\uFF09\u3002"}),(0,t.jsxs)("div",{className:"auth-expired-actions",children:[e.loginUrl?(0,t.jsx)("a",{id:"dashboard-one-click-login",className:"auth-login-link primary",href:e.loginUrl,target:"_top",rel:"noopener",children:"\u4E00\u952E\u767B\u5F55"}):null,(0,t.jsx)("button",{id:"auth-expired-dismiss",type:"button",className:n?"secondary":"primary",onClick:e.onClose,children:n?"\u6682\u4E0D\u767B\u5F55":"\u77E5\u9053\u4E86"})]})]})})}function ro(e){let n=new Date(e);if(Number.isNaN(n.getTime()))return e.slice(0,10);try{return new Intl.DateTimeFormat(f.locale==="zh"?"zh-CN":"en-US",{year:"numeric",month:"numeric",day:"numeric"}).format(n)}catch{return e.slice(0,10)}}async function en(){let e=await fetch("/__selfcheck",{cache:"no-store"}),n=await e.text();if(!e.ok||!n)throw new Error(s("update.healthCheckFailed"));return n}function so(e){let{status:n}=e,[o,a]=(0,l.useState)(!1),[r,d]=(0,l.useState)("idle"),[p,h]=(0,l.useState)(0),[c,u]=(0,l.useState)(!1),[m,k]=(0,l.useState)(!1),[w,g]=(0,l.useState)(""),[x,y]=(0,l.useState)(!1),[O,B]=(0,l.useState)(!1),[E,Re]=(0,l.useState)(!1),[q,ie]=(0,l.useState)(!1),[j,nt]=(0,l.useState)([]),[M,Ne]=(0,l.useState)(null),[D,Le]=(0,l.useState)(null),S=(0,l.useRef)(!1),G=(0,l.useRef)(null),le=(0,l.useRef)(null),ot=(0,l.useRef)(null),Te=(0,l.useRef)(null),Se=(0,l.useRef)(null),[X,at]=(0,l.useState)(null),dn=()=>{G.current!==null&&(window.clearTimeout(G.current),G.current=null)},Ce=()=>{le.current!==null&&(window.clearInterval(le.current),le.current=null)};if((0,l.useEffect)(()=>{S.current=!1,d("idle"),h(0),u(!1),k(!1),g(""),y(!1),B(!1),Re(!1),ie(!1),nt([]),Ne(null),Le(null)},[n?.current,n?.latest]),(0,l.useEffect)(()=>{if(Ce(),r==="idle"||r==="error"){h(0);return}let i=r==="updating"?50:95;return r==="restarting"&&h(b=>Math.max(b,50)),le.current=window.setInterval(()=>{h(b=>b>=i?i:b+Math.max(.5,(i-b)*.08))},400),()=>Ce()},[r]),(0,l.useEffect)(()=>{n&&k(n.versionLookupOk===!1)},[n]),(0,l.useEffect)(()=>{o||y(!1)},[o]),(0,l.useEffect)(()=>{if(!o||!X)return;let i=window.requestAnimationFrame(()=>{Se.current?.querySelector('button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')?.focus()});return()=>window.cancelAnimationFrame(i)},[o,X!==null]),(0,l.useEffect)(()=>{if(!o){at(null);return}let i=()=>{let b=Te.current;if(!b)return;let R=b.getBoundingClientRect(),C=Math.min(340,Math.max(0,window.innerWidth-32)),$=Math.max(16,Math.min(R.left,window.innerWidth-C-16));at({top:R.bottom+8,left:$})};return i(),window.addEventListener("resize",i),document.addEventListener("scroll",i,!0),()=>{window.removeEventListener("resize",i),document.removeEventListener("scroll",i,!0)}},[o]),(0,l.useEffect)(()=>()=>{dn(),Ce()},[]),(0,l.useEffect)(()=>{if(!o)return;let i=R=>{let C=R.target;ot.current?.contains(C)||Se.current?.contains(C)||a(!1)},b=R=>{R.key==="Escape"&&(a(!1),Te.current?.focus())};return document.addEventListener("pointerdown",i),document.addEventListener("keydown",b),()=>{document.removeEventListener("pointerdown",i),document.removeEventListener("keydown",b)}},[o]),!n)return null;let U=n.behind&&!!n.latest,Pe=!n.latest,Oe=U&&n.updateSupported&&!n.localDevInstall&&n.node.ok,rt=n.updateSupported&&!n.localDevInstall&&n.node.ok,H=r==="updating"||r==="restarting",st=2*Math.PI*20,un=st*(1-Math.max(2,Math.round(p))/100),pn=n.updateCommand??"botmux update",Ae=`v${n.current}`,hn=n.latest?`v${n.latest}`:"",mn=n.localDevInstall?s("update.localDev"):n.updateSupported?n.node.ok?"":s("update.nodeWarn",{version:n.node.version,required:n.node.required}):s("update.unsupportedInstall"),it=i=>{let b=Date.now(),R=async()=>{try{let C=await fetch("/__selfcheck",{cache:"no-store"}),$=await C.text();if(C.ok&&$&&$!==i){location.reload();return}}catch{}if(Date.now()-b>9e4){S.current=!1,d("error"),g(s("update.restartSlow"));return}G.current=window.setTimeout(()=>{R()},2e3)};G.current=window.setTimeout(()=>{R()},3e3)},fn=async()=>{if(U){if(!Oe){a(!1),location.hash="#/settings";return}if(!S.current){S.current=!0,Le(null),k(!1),g("");try{let i=await en(),b=await Ue(fetch,d);if(b.bootstrapRequired){S.current=!1,d("error"),g(s("update.bootstrapRequired"));return}if(!b.restarted){S.current=!1,d("error"),g(s("update.restartFailed",{detail:b.restartError??"unknown"}));return}it(i)}catch(i){S.current=!1,d("error"),g(i instanceof Error?i.message:String(i))}}}},De=async(i=!1)=>{if(E)return!q;Re(!0),ie(!1);try{let b=await fetch(`/api/update/versions${i?"?refresh=1":""}`,{cache:"no-store"}),R=await b.json().catch(()=>null);if(!R||!Array.isArray(R.versions))throw new Error("Invalid rollback versions response");let C=R.versions.filter(_=>{if(!_||typeof _!="object")return!1;let J=_;return typeof J.version=="string"&&(typeof J.publishedAt=="string"||J.publishedAt===null)}).slice(0,3);nt(C),Ne(_=>C.some(J=>J.version===_)?_:null),B(!0);let $=b.ok&&R.ok===!0;return ie(!$),$}catch{return B(!0),ie(!0),!1}finally{Re(!1)}},bn=async()=>{if(!(!M||!rt||E||S.current)){S.current=!0,Le(M),k(!1),g("");try{let i=await en();await Ue(fetch,d,M),it(i)}catch(i){S.current=!1,d("error"),g(i instanceof Error?i.message:String(i))}}},gn=async()=>{if(!(c||H)){u(!0),k(!1);try{let i=await e.onRefresh();x&&await De(!0),k(!i)}finally{u(!1)}}},ce=r==="updating"?D?s("update.rollbackInstalling",{version:D}):s("update.updating",{command:pn}):r==="restarting"?D?s("update.rollbackRestarting",{version:D}):s("update.restarting"):r==="error"?D?s("update.rollbackFailed",{detail:w}):s("update.updateFailed",{detail:w}):m?s("update.topbarRefreshFailed"):U?Oe?s("update.versionUpgradePrompt",{version:hn}):mn:n.latest?s("update.upToDate"):s("update.checkUnavailable"),vn=Oe?r==="error"?s("update.topbarRetry"):r==="idle"?s("update.topbarAction"):s("update.topbarWorking"):s("update.topbarReview"),de=r==="error"||m&&Pe?{className:"is-error",symbol:"!"}:U?{className:"has-update",symbol:"\u2191"}:Pe?{className:"is-unknown",symbol:"?"}:{className:"is-current",symbol:"\u2713"};return(0,t.jsxs)("div",{ref:ot,className:`dashboard-version-control${o?" is-open":""}`,children:[(0,t.jsxs)("button",{ref:Te,type:"button",className:`dashboard-version-chip${U?" has-update":""}${Pe?" is-unknown":""}${r==="error"?" is-error":""}`,"aria-haspopup":"dialog","aria-expanded":o,"aria-label":`${Ae}. ${ce}`,title:ce,onClick:()=>a(i=>!i),children:[(0,t.jsx)("span",{children:Ae}),(0,t.jsx)("span",{className:`dashboard-version-state ${de.className}`,"aria-hidden":"true",children:de.symbol})]}),o&&X&&typeof document<"u"?(0,nn.createPortal)((0,t.jsxs)("section",{ref:Se,className:"dashboard-version-popover",role:"dialog","aria-modal":"false","aria-labelledby":"dashboard-version-title",style:{top:X.top,left:X.left},children:[(0,t.jsxs)("header",{className:"dashboard-version-popover-head",children:[(0,t.jsx)("strong",{id:"dashboard-version-title",children:s("update.current")}),(0,t.jsxs)("div",{className:"dashboard-version-head-actions",children:[(0,t.jsx)("button",{type:"button",className:`dashboard-version-refresh${c?" is-refreshing":""}`,"aria-label":s(c?"update.topbarRefreshing":"update.topbarRefresh"),title:s(c?"update.topbarRefreshing":"update.topbarRefresh"),disabled:c||E||H,onClick:()=>{gn()},children:(0,t.jsxs)("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[(0,t.jsx)("path",{d:"M13.2 5.7A5.8 5.8 0 1 0 13 10.8"}),(0,t.jsx)("path",{d:"M13.2 2.8v2.9h-2.9"})]})}),(0,t.jsx)("button",{type:"button",className:"dashboard-version-close","aria-label":s("update.topbarClose"),onClick:()=>a(!1),children:"\xD7"})]})]}),(0,t.jsxs)("div",{className:"dashboard-version-popover-body",children:[(0,t.jsxs)("div",{className:"dashboard-version-current",children:[(0,t.jsx)("strong",{children:Ae}),H?(0,t.jsxs)("span",{className:"dashboard-version-ring",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(p),"aria-label":ce,children:[(0,t.jsxs)("svg",{viewBox:"0 0 44 44",width:"44",height:"44","aria-hidden":"true",children:[(0,t.jsx)("defs",{children:(0,t.jsxs)("linearGradient",{id:"dvr-grad",x1:"0%",y1:"100%",x2:"100%",y2:"0%",children:[(0,t.jsx)("stop",{offset:"0%",stopColor:"var(--brand-accent-cyan)"}),(0,t.jsx)("stop",{offset:"55%",stopColor:"var(--accent)"}),(0,t.jsx)("stop",{offset:"100%",stopColor:"var(--brand-accent-pink)"})]})}),(0,t.jsx)("circle",{className:"dvr-track",cx:"22",cy:"22",r:"20"}),(0,t.jsx)("circle",{className:"dvr-arc",cx:"22",cy:"22",r:"20",style:{strokeDasharray:st,strokeDashoffset:un}})]}),(0,t.jsxs)("span",{className:"dvr-pct",children:[Math.round(p),"%"]})]}):(0,t.jsx)("span",{className:de.className,"aria-hidden":"true",children:de.symbol})]}),(0,t.jsx)("p",{className:`dashboard-version-message${r==="error"||m?" is-error":""}`,role:r==="error"||m?"alert":"status","aria-live":"polite",children:ce}),(0,t.jsxs)("a",{className:"dashboard-version-release-link",href:"https://github.com/deepcoldy/botmux/releases",target:"_blank",rel:"noopener noreferrer",children:[(0,t.jsx)("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M8 1.5a6.5 6.5 0 0 0-2.1 12.65c.33.06.45-.14.45-.32v-1.26c-1.84.4-2.23-.78-2.23-.78-.3-.76-.73-.96-.73-.96-.6-.41.05-.4.05-.4.66.05 1 .68 1 .68.59 1 1.54.72 1.92.55.06-.42.23-.72.42-.88-1.47-.17-3.02-.74-3.02-3.28 0-.72.26-1.32.68-1.78-.07-.17-.3-.84.07-1.75 0 0 .56-.18 1.79.68A6.2 6.2 0 0 1 8 4.63a6.2 6.2 0 0 1 1.71.22c1.23-.86 1.79-.68 1.79-.68.37.91.14 1.58.07 1.75.42.46.68 1.06.68 1.78 0 2.55-1.55 3.11-3.03 3.28.24.21.45.61.45 1.23v1.62c0 .18.12.38.46.32A6.5 6.5 0 0 0 8 1.5Z"})}),(0,t.jsx)("span",{children:s("update.changelogViewOnGitHub")})]}),(U||x)&&n.installs.multiple?(0,t.jsxs)("details",{className:"dashboard-version-installs",children:[(0,t.jsx)("summary",{children:s("update.multiInstallWarn")}),(0,t.jsx)("ul",{children:n.installs.entries.map(i=>(0,t.jsx)("li",{children:i.binPath},i.binPath))})]}):null,rt?(0,t.jsxs)("details",{className:"dashboard-version-rollback",open:x,"aria-busy":E,onToggle:i=>{let b=i.currentTarget.open;y(b),b&&!O&&!E&&De()},children:[(0,t.jsxs)("summary",{children:[(0,t.jsxs)("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[(0,t.jsx)("circle",{cx:"8",cy:"8",r:"5.5"}),(0,t.jsx)("path",{d:"M8 4.8V8l2.2 1.3"})]}),(0,t.jsx)("span",{children:s("update.rollbackTitle")}),(0,t.jsx)("span",{className:"dashboard-version-rollback-chevron","aria-hidden":"true",children:"\u2304"})]}),(0,t.jsxs)("div",{className:"dashboard-version-rollback-body",children:[E&&j.length===0?(0,t.jsxs)("p",{className:"dashboard-version-rollback-status",role:"status","aria-live":"polite",children:[(0,t.jsx)("span",{className:"dashboard-update-spinner","aria-hidden":"true"}),s("update.rollbackLoading")]}):null,q?(0,t.jsxs)("p",{className:"dashboard-version-rollback-load-error",role:"alert",children:[(0,t.jsx)("span",{children:s("update.rollbackLoadFailed")}),(0,t.jsx)("button",{type:"button",disabled:E,onClick:()=>{De(!0)},children:s("update.rollbackRetry")})]}):null,O&&!E&&!q&&j.length===0?(0,t.jsx)("p",{className:"dashboard-version-rollback-status",children:s("update.rollbackEmpty")}):null,j.length>0?(0,t.jsxs)("fieldset",{disabled:H||E||q,children:[(0,t.jsx)("legend",{children:s("update.rollbackHint")}),(0,t.jsx)("div",{className:"dashboard-version-rollback-options",children:j.map(i=>(0,t.jsxs)("label",{className:M===i.version?"is-selected":"",children:[(0,t.jsx)("input",{type:"radio",name:"dashboard-rollback-version",value:i.version,checked:M===i.version,onChange:()=>Ne(i.version)}),(0,t.jsxs)("strong",{children:["v",i.version]}),i.publishedAt?(0,t.jsx)("time",{dateTime:i.publishedAt,children:ro(i.publishedAt)}):null]},i.version))})]}):null,M?(0,t.jsxs)("p",{id:"dashboard-version-rollback-risk",className:"dashboard-version-rollback-risk",role:"note",children:[(0,t.jsxs)("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[(0,t.jsx)("path",{d:"M7.1 2.3 1.8 12a1 1 0 0 0 .9 1.5h10.6a1 1 0 0 0 .9-1.5L8.9 2.3a1 1 0 0 0-1.8 0Z"}),(0,t.jsx)("path",{d:"M8 5.5v3.6M8 11.6h.01"})]}),(0,t.jsxs)("span",{children:[s("update.rollbackRisk",{version:M})," ",(0,t.jsx)("a",{href:`https://github.com/deepcoldy/botmux/releases/tag/v${encodeURIComponent(M)}`,target:"_blank",rel:"noopener noreferrer","aria-label":s("update.rollbackReleaseNotesA11y",{version:M}),children:s("update.rollbackReleaseNotes",{version:M})})]})]}):null,j.length>0?(0,t.jsxs)("button",{type:"button",className:"dashboard-version-rollback-action",disabled:!M||E||q||H,"aria-describedby":M?"dashboard-version-rollback-risk":void 0,onClick:()=>{bn()},children:[H&&D?(0,t.jsx)("span",{className:"dashboard-update-spinner","aria-hidden":"true"}):null,M?r==="error"&&D===M?s("update.rollbackRetry"):s("update.rollbackAction",{version:M}):s("update.rollbackSelect")]}):null]})]}):null]}),U&&!x&&!D?(0,t.jsxs)("footer",{className:"dashboard-version-popover-actions",children:[(0,t.jsx)("button",{type:"button",className:"dashboard-version-secondary",onClick:()=>a(!1),children:H?s("update.topbarClose"):s("update.topbarLater")}),(0,t.jsx)("button",{type:"button",className:"dashboard-version-primary",disabled:H,onClick:()=>{fn()},children:vn})]}):null]}),document.body):null]})}function io(){let e=no(),[n,o]=(0,l.useState)(!1),[a,r]=(0,l.useState)(!1),[d,p]=(0,l.useState)(!1),h=(0,l.useRef)(e.attention),c=(0,l.useRef)(null),u=()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)};(0,l.useEffect)(()=>{let w=()=>o(!0);return window.addEventListener(me,w),()=>window.removeEventListener(me,w)},[]),(0,l.useEffect)(()=>{let w=()=>r(!0);return window.addEventListener(Qe,w),se&&r(!0),()=>window.removeEventListener(Qe,w)},[]),(0,l.useEffect)(()=>()=>u(),[]),(0,l.useEffect)(()=>{let w=h.current;if(h.current=e.attention,e.attention===0){u(),p(!1);return}w!==0||document.body.classList.contains("theme-menu-open")||(p(!0),u(),c.current=window.setTimeout(()=>{c.current=null,p(!1)},4e3))},[e.attention]);let m=()=>{se=!1,r(!1)},k=_e()?Ee.startsWith("#/agent-workbench-dock")?"dock":Ee.startsWith("#/agent-workbench")?"appCenter":null:null;return k?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"workbench-route-host","data-workbench-surface":k,children:(0,t.jsx)("main",{id:"root",ref:Zt})}),(0,t.jsx)(Qt,{open:a,loginUrl:ve(Me,location.hash),onClose:m}),(0,t.jsx)(Be,{}),(0,t.jsx)(Ie,{})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"aurora","aria-hidden":"true",children:[(0,t.jsx)("i",{className:"a1"}),(0,t.jsx)("i",{className:"a2"}),(0,t.jsx)("i",{className:"a3"})]}),(0,t.jsxs)("div",{className:"app-shell",children:[(0,t.jsxs)("header",{className:"topbar",children:[(0,t.jsx)("div",{className:"topbar-left",children:(0,t.jsxs)("div",{className:"topbar-brand-block",children:[(0,t.jsxs)("a",{className:"brand",href:"#/",children:[(0,t.jsx)("span",{className:"brand-mark","aria-hidden":"true",children:(0,t.jsx)("img",{className:"brand-logo-img",src:"/assets/brand-logo.png",alt:"",decoding:"sync",loading:"eager",fetchPriority:"high"})}),(0,t.jsx)("strong",{className:"brand-wordmark",children:"Botmux"}),(0,t.jsx)("span",{className:"brand-product",children:"Dashboard"})]}),(0,t.jsx)(so,{status:an,onRefresh:()=>et(!0)})]})}),(0,t.jsxs)("div",{className:"topbar-actions",children:[(0,t.jsx)(ao,{summary:e,autoOpen:d}),(0,t.jsxs)("div",{className:"topbar-tool-group",children:[(0,t.jsx)("button",{type:"button",className:"topbar-locale-toggle","aria-label":f.locale==="zh"?"Switch to English":"\u5207\u6362\u5230\u4E2D\u6587",title:f.locale==="zh"?"Switch to English":"\u5207\u6362\u5230\u4E2D\u6587",onClick:()=>lo(f.locale==="zh"?"en":"zh"),children:f.locale==="zh"?"CN":"EN"}),(0,t.jsx)(to,{}),(0,t.jsxs)("a",{className:"topbar-docs-link",href:"https://deepcoldy.github.io/botmux/",target:"_blank",rel:"noopener noreferrer",title:s("nav.docs"),"aria-label":s("nav.docs"),children:[ne((0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("rect",{x:"2.2",y:"2.2",width:"11.6",height:"11.6",rx:"2"}),(0,t.jsx)("path",{d:"M4.8 5.2h6.4M4.8 8h6.4M4.8 10.8h4"})]})),(0,t.jsx)("span",{children:s("nav.docs")})]})]}),(0,t.jsxs)("span",{className:"topbar-owner",title:V?.name,"aria-label":V?.name??"Owner",children:[(0,t.jsx)("span",{className:"topbar-owner-placeholder","aria-hidden":"true",children:ne((0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("circle",{cx:"8",cy:"6",r:"2.4"}),(0,t.jsx)("path",{d:"M3.7 13c.7-2.5 2.2-3.7 4.3-3.7s3.6 1.2 4.3 3.7"})]}))}),V?.avatarUrl?(0,t.jsx)("img",{className:"topbar-owner-img",src:V.avatarUrl,alt:"",decoding:"async",referrerPolicy:"no-referrer",onError:w=>{w.currentTarget.remove()}}):null]})]})]}),(0,t.jsxs)("div",{className:"chrome-body",children:[(0,t.jsxs)("aside",{className:"sidebar",children:[T?(0,t.jsxs)("div",{className:"sidebar-create-actions",children:[(0,t.jsxs)("button",{type:"button",className:"sidebar-create-btn",onClick:()=>$e(),children:[ne((0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M2 3.5h12v7H6l-3 3v-3H2z"}),(0,t.jsx)("path",{d:"M8 4.9v4.2M5.9 7h4.2"})]})),(0,t.jsx)("span",{className:"sidebar-nav-label",children:s("nav.createSession")})]}),(0,t.jsxs)("button",{type:"button",className:"sidebar-create-btn",onClick:()=>{wt()},children:[ne((0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("rect",{x:"2.5",y:"6",width:"11",height:"7.5",rx:"2"}),(0,t.jsx)("circle",{cx:"5.8",cy:"9.75",r:"1"}),(0,t.jsx)("circle",{cx:"10.2",cy:"9.75",r:"1"}),(0,t.jsx)("path",{d:"M8 6V3.8M6.3 1.9h3.4"})]})),(0,t.jsx)("span",{className:"sidebar-nav-label",children:s("nav.createBot")})]})]}):null,(0,t.jsx)("nav",{className:"sidebar-nav","aria-label":"Dashboard",children:(()=>{let w=Jn().filter(y=>T||!y.manage),g=new Map(w.map(y=>[y.id,y])),x=w.filter(y=>y.plugin);return jn.map(y=>{let O=y.items.flatMap(B=>{let E=g.get(B);return E?E.id==="plugins"?[E,...x]:[E]:[]});return O.length===0?null:(0,t.jsxs)("div",{className:"nav-group",children:[(0,t.jsx)("div",{className:"nav-group-title",children:s(y.labelKey)}),O.map(Zn)]},y.id)})})()})]}),(0,t.jsxs)("div",{className:"workspace",children:[(0,t.jsx)("dialog",{id:"create-session-modal",className:"create-session-modal"}),(0,t.jsx)(yt,{open:n,onClose:()=>o(!1)}),(0,t.jsx)("main",{id:"root",ref:Zt})]})]})]}),(0,t.jsx)(Qt,{open:a,loginUrl:ve(Me,location.hash),onClose:m}),(0,t.jsx)(Be,{}),(0,t.jsx)(Ie,{})]})}function N(){rn?.render((0,t.jsx)(io,{}))}function lo(e){f.setLocale(e),ho(e)}var se=!1;function cn(e){let n=!!ve(e,location.hash),o=n&&Me!==e;n&&(Me=e),se&&o&&N(),!se&&(se=!0,window.dispatchEvent(new Event(Qe)))}var Ye;function co(){let e=document.getElementById("readonly-toast");e||(e=document.createElement("div"),e.id="readonly-toast",e.style.cssText="position:fixed;left:50%;bottom:28px;transform:translateX(-50%);z-index:9999;background:var(--fg,#1f2329);color:var(--bg,#fff);padding:10px 18px;border-radius:var(--radius-lg);font-size:13px;box-shadow:0 8px 24px rgba(0,0,0,.25)",document.body.appendChild(e)),e.textContent="\u5F53\u524D\u662F\u53EA\u8BFB\u8BBF\u95EE\uFF0C\u6B64\u64CD\u4F5C\u9700\u8981\u6388\u6743\u94FE\u63A5\uFF08\u8FD0\u884C botmux dashboard \u83B7\u53D6\uFF09",e.style.display="block",Ye&&window.clearTimeout(Ye),Ye=window.setTimeout(()=>{e.style.display="none"},4e3)}var tt=window.fetch.bind(window);window.fetch=async function(...n){let o=await tt(...n);if(o.status===401){if(o.headers.get("x-botmux-auth-scope")==="workbench")return o;let a=o.headers.get("x-botmux-login-url")??void 0,r=(n[1]?.method??"GET").toUpperCase();a||(r==="GET"||r==="HEAD")&&!ye?cn(a):co()}return o};async function uo(){try{let e=await tt("/api/workbench/capabilities",{cache:"no-store"});f.workbenchCapabilities=e.ok?ct(await e.json()):He}catch{f.workbenchCapabilities=He}}async function po(){let e=uo();try{let n=await tt("/api/settings");if(n.ok){let o=await n.json();T=!!o.authed,f.authed=T,f.workbenchAuthed=T,ye=!!(o.settings&&o.settings.publicReadOnly),f.publicReadOnly=ye;let a=ln()??pe(o.lang);a&&f.setLocale(a)}else if(n.status===401&&n.headers.get("x-botmux-auth-scope")==="workbench")T=!1,f.authed=!1,f.workbenchAuthed=!0,ye=!1,f.publicReadOnly=!1;else if(n.status===401){T=!1,f.authed=!1,f.workbenchAuthed=!1;let o=n.headers.get("x-botmux-login-url")??void 0;cn(o)}}catch{}await e}async function tn(){try{let e=await fetch("/api/plugins/dashboard");if(!e.ok)return;let n=await e.json();oe=(Array.isArray(n?.plugins)?n.plugins:[]).filter(a=>a.pinned===!0&&typeof a.route=="string").map(a=>({id:`plugin:${a.pluginId}:${a.id}`,href:a.route,label:a.displayName||a.pluginId,manage:!0,plugin:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M5.2 2.2h5.6v3.1l1.7 1.7-1.4 1.4-1-1v6.4H5.9V7.4l-1 1L3.5 7l1.7-1.7z"}),(0,t.jsx)("path",{d:"M8 13.8v1"})]})})),N()}catch{}}async function ho(e){if(T)try{await fetch("/api/settings",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({lang:e})})}catch{}}async function et(e=!1){if(!T)return!1;try{let n=await fetch(`/api/update/status${e?"?refresh=1":""}`,{cache:"no-store"});if(!n.ok)return!1;let o=await n.json();an=o;let a=Array.isArray(o.cliUpdates)?o.cliUpdates.find(r=>r?.updateAvailable===!0&&r?.latest):null;return o.behind===!0&&o.latest?(ae=!0,ke="botmux",re=String(o.latest)):a?(ae=!0,ke="runtime",re=String(a.latest)):(ae=!1,ke=null,re=null),N(),o.versionLookupOk!==!1}catch{return!1}}function mo(e){e.innerHTML='<section class="auth-required" style="max-width:520px;margin:64px auto;text-align:center;background:var(--surface);color:var(--fg);border:1px solid var(--border);border-radius:var(--radius-lg);padding:40px 36px;box-shadow:0 8px 28px rgba(0,0,0,.12)"><h2 style="margin:0 0 12px;font-size:20px;color:var(--fg)">\u6B64\u9875\u9700\u8981\u6388\u6743\u94FE\u63A5</h2><p style="margin:0 0 24px;line-height:1.7;color:var(--muted);font-size:14px">\u4F60\u5F53\u524D\u662F\u53EA\u8BFB\u8BBF\u95EE\uFF0C\u7BA1\u7406\u9875\uFF08\u7FA4\u89D2\u8272 / Profiles / Bot \u914D\u7F6E / \u56E2\u961F / Webhook\uFF09\u9700\u8981\u6388\u6743\u94FE\u63A5\u3002\u8FD0\u884C <code>botmux dashboard</code> \u83B7\u53D6\u6700\u65B0\u94FE\u63A5\u540E\u5373\u53EF\u7BA1\u7406\u3002</p><a href="#/" style="display:inline-block;padding:8px 22px;background:var(--accent);color:var(--on-accent);border-radius:var(--radius-lg);text-decoration:none;font-size:14px">\u8FD4\u56DE\u603B\u89C8</a></section>'}async function Ze(){let e=Ot(I),n=location.hash||"#/";Ee=n,N();let o=xt(n);if(o){window.location.replace(o);return}if(!T&&qn.some(a=>n.startsWith("#/"+a))){mo(Xe()),I.rerenderOnUiChange=!0;return}if(n.startsWith("#/v3")){window.location.replace(`#/workflows${n.slice(4)}`);return}else if(n.startsWith("#/legacy-workflow")){window.location.replace("#/workflows");return}else if(/^#\/workflows(?:\/|-)catalog(?:[/?].*)?$/.test(n)){window.location.replace("#/workflows");return}if(n.startsWith("#/role-profiles")){window.location.replace(`#/roles/profile${n.slice(15)}`);return}try{let a=Tt(n);await At(I,e,Xe(),a?a.load:St,{rerenderOnUiChange:a?a.rerenderOnUiChange:!1}),e===I.seq&&T&&eo()}catch(a){if(e!==I.seq||It(a,{href:window.location.href,hash:n,getSessionStorage:()=>window.sessionStorage,reload:()=>window.location.reload()}))return;Xe().innerHTML=`<section class="page"><div class="empty">Dashboard route failed: ${dt(String(a))}</div></section>`,I.pageDispose=null,I.rerenderOnUiChange=!0}}function fo(){try{let e=JSON.parse(window.localStorage.getItem(sn)??"null");if(e?.avatarUrl)return{avatarUrl:String(e.avatarUrl),name:e.name?String(e.name):void 0}}catch{}return null}function bo(){V=fo(),N(),fetch("/api/owner-profile").then(e=>e.ok?e.json():null).then(e=>{if(!(!e?.ok||!e.avatarUrl)){V={avatarUrl:String(e.avatarUrl),name:e.name?String(e.name):void 0};try{window.localStorage.setItem(sn,JSON.stringify({avatarUrl:e.avatarUrl,name:e.name??""}))}catch{}N()}}).catch(()=>{})}(async()=>{let e=kt(window.location.href);e&&window.history.replaceState(window.history.state,"",e),f.init(),Jt();let n=document.getElementById("app-root");if(!n)throw new Error("missing dashboard app root");Ft(n),jt(),rn=(0,on.createRoot)(n),N(),f.on(()=>{N(),I.rerenderOnUiChange&&Ze()}),ue.on(()=>{N()}),await po(),N(),window.addEventListener(bt,()=>{tn()}),tn(),et(),window.setInterval(()=>{document.hidden||et()},30*6e4),bo();try{await lt({canReadSchedules:()=>f.authed||f.publicReadOnly})}catch(o){console.error("botmux dashboard bootstrap failed",o),ue.setOnline(!1)}pt().then(N),Et().then(N),window.addEventListener("hashchange",()=>{Jt()||Ze()}),Ze()})();export{cn as showAuthExpiredOverlay,co as showReadOnlyToast};
1
+ import{a as kt,b as _e,d as xt}from"./chunks/chunk-2PVRDXEL.js";import{a as Et,b as Mt}from"./chunks/chunk-Z67OSM5P.js";import{b as $e}from"./chunks/chunk-SZOB6VK2.js";import{a as bt}from"./chunks/chunk-BD3PZGH2.js";import{b as Ue}from"./chunks/chunk-G5ZS2YUS.js";import{b as Be}from"./chunks/chunk-OXSVWLER.js";import{a as me,b as wt,c as yt}from"./chunks/chunk-NJCJR3U2.js";import"./chunks/chunk-KTQ7B6ZR.js";import{c as Ie}from"./chunks/chunk-CEUCNZFJ.js";import{i as gt,j as vt}from"./chunks/chunk-NYY66DNC.js";import"./chunks/chunk-ECFC7UG2.js";import{a as ue,b as lt}from"./chunks/chunk-QITAMHW6.js";import{G as pt,I as ht,L as mt,M as he,c as pe,u as He,v as ct,w as f,x as s,y as dt,z as ut}from"./chunks/chunk-BU3Q6XC6.js";import{a as yn,b as kn}from"./chunks/chunk-ARROO6TE.js";import{c as Y,d as wn,e as ft}from"./chunks/chunk-3YZFAHNK.js";var nn=Y(yn(),1),on=Y(kn(),1),l=Y(wn(),1);var ze="botmux:close-theme-menu",xn={palette:'<circle cx="13.5" cy="6.5" r=".5" fill="currentColor"/><circle cx="17.5" cy="10.5" r=".5" fill="currentColor"/><circle cx="8.5" cy="7.5" r=".5" fill="currentColor"/><circle cx="6.5" cy="12.5" r=".5" fill="currentColor"/><path d="M12 2a10 10 0 0 0 0 20h1.7a2.3 2.3 0 0 0 1.6-4c-.5-.5-.2-1.3.5-1.3H17a5 5 0 0 0 5-5 9.7 9.7 0 0 0-10-9.7z"/>',monitor:'<rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/>',sun:'<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>',moon:'<path d="M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"/>',cpu:'<path d="M12 20v2"/><path d="M12 2v2"/><path d="M17 20v2"/><path d="M17 2v2"/><path d="M2 12h2"/><path d="M2 17h2"/><path d="M2 7h2"/><path d="M20 12h2"/><path d="M20 17h2"/><path d="M20 7h2"/><path d="M7 20v2"/><path d="M7 2v2"/><rect x="4" y="4" width="16" height="16" rx="2"/><rect x="8" y="8" width="8" height="8" rx="1"/>',zap:'<path d="M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"/>',chevron:'<path d="m6 9 6 6 6-6"/>'},Nt=[{labelKey:"theme.base",options:[{value:"system",labelKey:"status.system",icon:"monitor"},{value:"light",labelKey:"status.light",icon:"sun"},{value:"dark",labelKey:"status.dark",icon:"moon"}]},{labelKey:"theme.skins",options:[{value:"cyber",labelKey:"skin.cyber",icon:"cpu"},{value:"fallout",labelKey:"skin.fallout",icon:"zap"}]}],Rt=Nt.flatMap(e=>e.options),L=!1,Z=null,Q=null,En=70,Mn=120;function Ke(e){return`<svg class="tm-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${xn[e]??""}</svg>`}function Rn(e){return e.replace(/[&<>"]/g,n=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[n])}function Lt(){let e=document.getElementById("theme-menu"),n=document.getElementById("theme-menu-btn"),o=document.getElementById("theme-menu-pop");if(!e||!n||!o||e.dataset.themeMenuInit==="1")return;e.dataset.themeMenuInit="1",o.innerHTML=Nt.map(u=>`<div class="tm-group" data-label-key="${u.labelKey}"></div>`+u.options.map(m=>`<button type="button" class="tm-item" role="option" data-value="${m.value}"><span class="tm-ic">${Ke(m.icon)}</span><span class="tm-label" data-label-key="${m.labelKey}"></span></button>`).join("")).join("");let a=()=>{if(!L)return;let u=n.getBoundingClientRect(),m=12,k=Math.min(Math.max(o.offsetWidth||216,216),Math.max(0,window.innerWidth-m*2)),w=m+k/2,g=window.innerWidth-m-k/2,x=u.left+u.width/2,y=Math.min(Math.max(x,w),Math.max(w,g)),O=Math.max(180,window.innerHeight-u.bottom-20);o.style.setProperty("--theme-menu-pop-left",`${Math.round(y)}px`),o.style.setProperty("--theme-menu-pop-top",`${Math.round(u.bottom+8)}px`),o.style.setProperty("--theme-menu-pop-max-height",`${Math.round(O)}px`)},r=u=>{Z!=null&&(window.clearTimeout(Z),Z=null),Q!=null&&(window.clearTimeout(Q),Q=null),L=u,n.setAttribute("aria-expanded",String(L)),document.body.classList.toggle("theme-menu-open",L),L?(o.hidden=!1,a(),window.requestAnimationFrame(()=>e.classList.add("open"))):(e.classList.remove("open"),Q=window.setTimeout(()=>{Q=null,L||(o.hidden=!0)},Mn))},d=()=>r(!0),p=()=>{Z==null&&(Z=window.setTimeout(()=>r(!1),En))},h=u=>{u.pointerType!=="touch"&&d()},c=u=>{u.pointerType!=="touch"&&p()};e.addEventListener("pointerenter",h),e.addEventListener("pointerleave",c),o.addEventListener("pointerenter",h),o.addEventListener("pointerleave",c),n.addEventListener("click",u=>{u.stopPropagation(),r(!L)}),n.addEventListener("focus",()=>{n.matches(":focus-visible")&&d()}),e.addEventListener("focusout",u=>{let m=u.relatedTarget;(!(m instanceof Node)||!e.contains(m))&&p()}),o.addEventListener("click",u=>{let m=u.target.closest(".tm-item");m&&(f.setTheme(m.dataset.value??"system"),r(!1))}),document.addEventListener("click",u=>{L&&!e.contains(u.target)&&r(!1)}),document.addEventListener("pointermove",u=>{if(!L||u.pointerType==="touch")return;let m=u.target;m instanceof Node&&e.contains(m)||p()}),document.addEventListener("keydown",u=>{u.key==="Escape"&&L&&r(!1)}),window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),window.addEventListener(ze,()=>{L&&r(!1)}),Fe()}function Fe(){let e=document.getElementById("theme-menu-btn");if(!e)return;let n=Rt.find(o=>o.value===f.theme)??Rt[0];e.innerHTML=`<span class="tm-ic">${Ke("palette")}</span><span class="tm-current">${Rn(s(n.labelKey))}</span><span class="tm-chev">${Ke("chevron")}</span>`,document.querySelectorAll("#theme-menu-pop [data-label-key]").forEach(o=>{o.textContent=s(o.dataset.labelKey??"")}),document.querySelectorAll("#theme-menu-pop .tm-item").forEach(o=>{o.classList.toggle("active",o.dataset.value===f.theme)})}function v(e,n,o,a,r=!1){return{id:e,routePrefix:n,rerenderOnUiChange:r,load:async()=>(await o())[a]}}var Nn=[v("agent-workbench-dock","#/agent-workbench-dock",()=>import("./chunks/agent-workbench-dock-page-XHJUYFGN.js"),"renderAgentWorkbenchDockPage"),v("agent-workbench","#/agent-workbench",()=>import("./chunks/agent-workbench-page-FLKTLIRM.js"),"renderAgentWorkbenchPage"),{id:"plugins",routePrefix:"#/plugins",rerenderOnUiChange:!1,load:async()=>{let e=await import("./chunks/plugin-page-AKQZFAC4.js");return n=>e.renderPluginPage(n)}},v("workflows","#/workflows",()=>import("./chunks/v3-page-766CBD7H.js"),"renderV3RunsPage"),v("groups","#/groups",()=>import("./chunks/groups-page-L4ZJNWVR.js"),"renderGroupsPage"),v("settings","#/settings",()=>import("./chunks/settings-page-2IRIS3FP.js"),"renderSettingsPage"),v("bot-defaults","#/bot-defaults",()=>import("./chunks/bot-defaults-page-XMGLZZ2E.js"),"renderBotDefaultsPage"),v("skills","#/skills",()=>import("./chunks/skills-page-5RZPM6HJ.js"),"renderSkillsPage"),v("customization","#/customization",()=>import("./chunks/customization-page-VQJAEDZY.js"),"renderCustomizationPage"),v("connectors-logs","#/connectors/logs",()=>import("./chunks/connectors-page-WDM4CEAU.js"),"renderConnectorsLogsPage"),v("webhook-logs","#/webhook-logs",()=>import("./chunks/connectors-page-WDM4CEAU.js"),"renderConnectorsLogsPage"),v("connectors","#/connectors",()=>import("./chunks/connectors-page-WDM4CEAU.js"),"renderConnectorsPage"),v("team-manage","#/team/manage",()=>import("./chunks/team-federation-page-KERG6LKC.js"),"renderTeamManagePage"),v("team","#/team",()=>import("./chunks/team-federation-page-KERG6LKC.js"),"renderTeamFederationPage"),v("roles-profile","#/roles/profile",()=>import("./chunks/roles-page-QO3YCA7D.js"),"renderRoleProfilesPage"),v("roles","#/roles",()=>import("./chunks/roles-page-QO3YCA7D.js"),"renderRolesPage"),v("schedules","#/schedules",()=>import("./chunks/schedules-page-YNGSKDQW.js"),"renderSchedulesPage"),v("whiteboards","#/whiteboards",()=>import("./chunks/whiteboards-page-2M6XZD5C.js"),"renderWhiteboardsPage"),v("monitoring","#/monitoring",()=>import("./chunks/monitoring-page-AUSXMPYO.js"),"renderMonitoringPage"),v("sessions","#/sessions",()=>import("./chunks/sessions-page-BWR4UB6X.js"),"renderSessionsPage"),v("monitor-room","#/monitor-room",()=>import("./chunks/monitor-room-7LZUJQPF.js"),"renderMonitorRoomPage",!0),v("office","#/office",()=>import("./chunks/office-page-6ZU6MAZN.js"),"renderOfficePage"),v("insights","#/insights",()=>import("./chunks/insights-page-7LUJU2CX.js"),"renderInsightsPage"),v("feedback","#/feedback",()=>import("./chunks/feedback-page-GMJ4FLJ4.js"),"renderFeedbackPage")];function Tt(e){return Nn.find(n=>n.exact?e===n.routePrefix:e.startsWith(n.routePrefix))}async function St(){let e=await import("./chunks/overview-page-QBC5CIYH.js");return n=>e.renderOverviewPage(n)}function Pt(){return{seq:0,pageDispose:null,rerenderOnUiChange:!0}}function Ot(e){let n=++e.seq;return e.pageDispose&&(e.pageDispose(),e.pageDispose=null),n}function Ct(e,n){return n===e.seq}async function At(e,n,o,a,r={}){let d=await a();if(!Ct(e,n))return!1;let p=d(o);return Ct(e,n)?(e.pageDispose=typeof p=="function"?p:null,e.rerenderOnUiChange=r.rerenderOnUiChange??!0,!0):(typeof p=="function"&&p(),!1)}var Ln="botmux.dashboard.stale-chunk-reload.v1:",Tn=/Failed to fetch dynamically imported module|Importing a module script failed|error loading dynamically imported module|dynamically imported module/i,Sn=/\b(?:https?:\/\/|\/assets\/)\S+?\.js\b/;function Dt(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}function Ht(e){return Tn.test(Dt(e))}function Cn(e,n){let r=Dt(e).match(Sn)?.[0]||`${n.href}|${n.hash}`;return`${Ln}${r.slice(-240)}`}function Pn(e,n){if(!Ht(e))return!1;let o=Cn(e,n);try{if(n.sessionStorage.getItem(o)==="1")return!1;n.sessionStorage.setItem(o,"1")}catch{return!1}return n.reload(),!0}function It(e,n){if(!Ht(e))return!1;let o;try{o=n.getSessionStorage()}catch{return!1}return Pn(e,{...n,sessionStorage:o})}var On=new Set(["auto","scroll","overlay"]),fe=28,P=3,K=6,Bt=!1,zt=null,Ut=new WeakMap,A=new Map,$t=null,_t=null,We=0,Ve=0,ee=null;function An(e){return e.closest("dialog[open]")??document.body}function Dn(e){let n=Ut.get(e);if(n?.isConnected)return n;let o=document.createElement("div");return o.className="floating-scrollbar-layer",o.setAttribute("aria-hidden","true"),e.appendChild(o),Ut.set(e,o),o}function Hn(e){return On.has(e)}function qe(e,n){let o=getComputedStyle(e),a=n==="y"?o.overflowY:o.overflowX;return Hn(a)?n==="y"?e.scrollHeight-e.clientHeight>1:e.scrollWidth-e.clientWidth>1:!1}function In(e){if(!e.isConnected||e.closest("[hidden]"))return!1;let n=e.getBoundingClientRect();return n.width>0&&n.height>0&&n.bottom>0&&n.right>0&&n.top<window.innerHeight&&n.left<window.innerWidth}function Bn(e){return[e,...Array.from(e.querySelectorAll("*"))].filter(o=>In(o)&&(qe(o,"x")||qe(o,"y")))}function be(e){e.hideTimer!==void 0&&window.clearTimeout(e.hideTimer),e.track.remove()}function Un(e,n){let o=A.get(e);o||(o={},A.set(e,o));let a=o[n],r=An(e),d=Dn(r);if(a?.track.parentElement===d)return a;a&&be(a);let p=document.createElement("div"),h=document.createElement("div");p.className=`floating-scrollbar floating-scrollbar-${n}`,h.className="floating-scrollbar-thumb",p.appendChild(h),d.appendChild(p);let c={target:e,axis:n,track:p,thumb:h,hideTimer:void 0};return o[n]=c,c}function je(e,n=!1){e.track.classList.add("is-visible"),e.hideTimer!==void 0&&window.clearTimeout(e.hideTimer),e.hideTimer=n?void 0:window.setTimeout(()=>{e.track.classList.remove("is-visible","is-active"),e.hideTimer=void 0},900)}function $n(e){let{target:n,axis:o,track:a,thumb:r}=e,d=n.getBoundingClientRect();if(o==="y"){let w=Math.max(0,d.top+P),g=Math.min(window.innerHeight,d.bottom-P),x=Math.max(0,g-w);if(x<fe||n.scrollHeight<=n.clientHeight){a.hidden=!0;return}let y=Math.max(fe,Math.round(x*n.clientHeight/n.scrollHeight)),O=Math.max(1,n.scrollHeight-n.clientHeight),B=Math.round((x-y)*n.scrollTop/O);a.hidden=!1,a.style.left=`${Math.min(window.innerWidth-K-P,Math.max(P,d.right-K-P))}px`,a.style.top=`${w}px`,a.style.width=`${K}px`,a.style.height=`${x}px`,r.style.width="100%",r.style.height=`${y}px`,r.style.transform=`translate3d(0, ${B}px, 0)`;return}let p=Math.max(0,d.left+P),h=Math.min(window.innerWidth,d.right-P),c=Math.max(0,h-p);if(c<fe||n.scrollWidth<=n.clientWidth){a.hidden=!0;return}let u=Math.max(fe,Math.round(c*n.clientWidth/n.scrollWidth)),m=Math.max(1,n.scrollWidth-n.clientWidth),k=Math.round((c-u)*n.scrollLeft/m);a.hidden=!1,a.style.left=`${p}px`,a.style.top=`${Math.min(window.innerHeight-K-P,Math.max(P,d.bottom-K-P))}px`,a.style.width=`${c}px`,a.style.height=`${K}px`,r.style.width=`${u}px`,r.style.height="100%",r.style.transform=`translate3d(${k}px, 0, 0)`}function z(){We||(We=window.requestAnimationFrame(()=>{We=0,Kn()}))}function _n(){Ve||(Ve=window.setTimeout(()=>{Ve=0,z()},120))}function Kn(){let e=zt;if(!e)return;let n=new Set(Bn(e));for(let[o,a]of A)n.has(o)||(a.x&&be(a.x),a.y&&be(a.y),A.delete(o));for(let o of n){let a=o===ee;for(let r of["x","y"]){let d=A.get(o);if(!qe(o,r)){let h=d?.[r];h&&(be(h),delete d?.[r]);continue}let p=Un(o,r);$n(p),a&&je(p,!0)}}}function zn(e){if(!(e instanceof HTMLElement))return;let n=A.get(e);if(n)for(let o of Object.values(n))o&&(o.track.classList.add("is-active"),je(o))}function Fn(e){for(let n=e;n;n=n.parentElement)if(n instanceof HTMLElement&&A.has(n))return n;return null}function Kt(e){if(ee===e)return;let n=ee?A.get(ee):void 0;if(ee=e,n)for(let a of Object.values(n))a?.track.classList.remove("is-visible");let o=e?A.get(e):void 0;if(o)for(let a of Object.values(o))a&&je(a,!0)}function Ft(e){Bt||(Bt=!0,zt=e,document.documentElement.classList.add("floating-scrollbars-on"),$t=typeof ResizeObserver>"u"?null:new ResizeObserver(z),$t?.observe(e),_t=new MutationObserver(n=>{for(let o of n){let a=o.target;if(!(a instanceof Element&&a.closest(".floating-scrollbar-layer"))){_n();return}}}),_t.observe(e,{attributes:!0,attributeFilter:["class","style","hidden","open"],childList:!0,subtree:!0}),document.addEventListener("scroll",n=>{zn(n.target),z()},!0),window.addEventListener("resize",z),window.addEventListener("hashchange",z),document.addEventListener("pointermove",n=>{Kt(Fn(document.elementFromPoint(n.clientX,n.clientY)))}),document.addEventListener("pointerleave",()=>Kt(null)),z())}var Wt=!1,F=null,ge=null,W=null;function qt(){if(F)return F;let e=document.createElement("div");return e.className="icon-tip",e.setAttribute("role","tooltip"),e.style.display="none",document.body.appendChild(e),F=e,e}function Wn(e){let n=qt(),o=gt(e,document.body);return n.parentNode!==o&&o.appendChild(n),n}function Vn(e){let n=qt(),o=e.getBoundingClientRect(),a=n.offsetWidth,r=n.offsetHeight,d=8,p=o.top<r+d+4,h=o.left+o.width/2-a/2;h=Math.min(Math.max(h,6),window.innerWidth-a-6);let c=p?o.bottom+d:o.top-r-d;n.style.left=`${Math.round(h)}px`,n.style.top=`${Math.round(c)}px`,n.dataset.placement=p?"bottom":"top"}function te(){W&&(clearTimeout(W),W=null),ge=null,F&&(F.style.display="none",F.classList.remove("show"))}function Vt(e){let n=e.getAttribute("data-tip");if(!n)return;ge=e;let o=Wn(e);o.textContent=n,o.style.display="block",o.classList.remove("show"),Vn(e),requestAnimationFrame(()=>{ge===e&&o.classList.add("show")})}function Ge(e){return e instanceof Element?e.closest("[data-tip]"):null}function jt(){Wt||typeof document>"u"||(Wt=!0,document.addEventListener("pointerover",e=>{let n=Ge(e.target);!n||n===ge||(W&&clearTimeout(W),W=setTimeout(()=>Vt(n),120))}),document.addEventListener("pointerout",e=>{let n=Ge(e.target);if(!n)return;let o=e.relatedTarget instanceof Element?e.relatedTarget:null;o&&(o===n||n.contains(o))||te()}),document.addEventListener("focusin",e=>{let n=Ge(e.target);n&&Vt(n)}),document.addEventListener("focusout",te),document.addEventListener("click",te,!0),window.addEventListener("scroll",te,!0),window.addEventListener("resize",te))}function ve(e,n){if(e)try{let o=new URL(e);if(!["http:","https:"].includes(o.protocol)||o.username||o.password)return;let a=n.startsWith("#/")&&n.length<=4096&&!/[\u0000-\u001f\u007f]/.test(n)?n:"#/";return o.searchParams.set("next",`/${a}`),o.toString()}catch{return}}var t=Y(ft(),1),qn=["roles","role-profiles","bot-defaults","skills","customization","plugins","team","connectors","insights","feedback","whiteboards"],Gt=[{id:"overview",href:"#/",labelKey:"nav.overview",icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("rect",{x:"1.5",y:"1.5",width:"5.4",height:"5.4",rx:"1.5"}),(0,t.jsx)("rect",{x:"9.1",y:"1.5",width:"5.4",height:"5.4",rx:"1.5"}),(0,t.jsx)("rect",{x:"1.5",y:"9.1",width:"5.4",height:"5.4",rx:"1.5"}),(0,t.jsx)("rect",{x:"9.1",y:"9.1",width:"5.4",height:"5.4",rx:"1.5"})]})},{id:"sessions",href:"#/sessions",labelKey:"nav.sessions",icon:(0,t.jsx)("path",{d:"M2 3.5h12v7H6l-3 3v-3H2z"})},{id:"agent-workbench",href:"#/agent-workbench",labelKey:"nav.workbench",icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),(0,t.jsx)("path",{d:"M4.5 6.5l2 1.5-2 1.5M8 10h3"})]})},{id:"groups",href:"#/groups",labelKey:"nav.groups",icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("circle",{cx:"5.6",cy:"5.8",r:"2.4"}),(0,t.jsx)("circle",{cx:"11",cy:"6.8",r:"1.9"}),(0,t.jsx)("path",{d:"M1.8 13.2c.5-2.4 2-3.6 3.8-3.6s3.3 1.2 3.8 3.6M9.8 12.6c.4-1.7 1.5-2.6 2.8-2.6 1 0 1.9.5 2.4 1.6"})]})},{id:"roles",href:"#/roles",labelKey:"nav.roles",manage:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M8 1.8l5.2 2v3.4c0 3.4-2.2 5.9-5.2 7-3-1.1-5.2-3.6-5.2-7V3.8z"}),(0,t.jsx)("path",{d:"M5.8 8l1.6 1.6 2.8-3"})]})},{id:"monitoring",href:"#/monitoring",labelKey:"nav.monitoring",icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M2 9.2h2.3l1.3-4.8 2.5 8.4 1.8-5.1h4.1"}),(0,t.jsx)("path",{d:"M2 2.5h12v11H2z"})]})},{id:"insights",href:"#/insights",labelKey:"nav.insights",manage:!0,icon:(0,t.jsx)(t.Fragment,{children:(0,t.jsx)("path",{d:"M2 2v12h12M5 11V7M8.5 11V4.5M12 11V8.5"})})},{id:"feedback",href:"#/feedback",labelKey:"nav.feedback",manage:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M2.2 3.2h11.6v8H8l-3.2 2.6v-2.6H2.2z"}),(0,t.jsx)("path",{d:"M5 6.2h6M5 8.3h4"})]})},{id:"workflows",href:"#/workflows",labelKey:"nav.workflows",icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("circle",{cx:"3.4",cy:"3.6",r:"1.9"}),(0,t.jsx)("circle",{cx:"3.4",cy:"12.4",r:"1.9"}),(0,t.jsx)("circle",{cx:"12.6",cy:"8",r:"1.9"}),(0,t.jsx)("path",{d:"M5.2 4.4l5.6 2.8M5.2 11.6l5.6-2.8"})]})},{id:"schedules",href:"#/schedules",labelKey:"nav.schedules",icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("circle",{cx:"8",cy:"8",r:"6.2"}),(0,t.jsx)("path",{d:"M8 4.5V8l2.4 1.6"})]})},{id:"whiteboards",href:"#/whiteboards",labelKey:"nav.whiteboards",manage:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("rect",{x:"2.2",y:"2.2",width:"11.6",height:"11.6",rx:"2"}),(0,t.jsx)("path",{d:"M4.8 5.2h6.4M4.8 8h6.4M4.8 10.8h4"})]})},{id:"office",href:"#/office",labelKey:"nav.office",icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("rect",{x:"3",y:"4",width:"10",height:"7",rx:"2"}),(0,t.jsx)("circle",{cx:"6",cy:"7.5",r:"1"}),(0,t.jsx)("circle",{cx:"10",cy:"7.5",r:"1"}),(0,t.jsx)("path",{d:"M8 4V2M4.5 11v2M11.5 11v2"})]})},{id:"bot-defaults",href:"#/bot-defaults",labelKey:"nav.botDefaults",manage:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("rect",{x:"2.5",y:"5",width:"11",height:"8",rx:"2"}),(0,t.jsx)("circle",{cx:"5.8",cy:"9",r:"1"}),(0,t.jsx)("circle",{cx:"10.2",cy:"9",r:"1"}),(0,t.jsx)("path",{d:"M8 5V2.5M5.5 13v1.2M10.5 13v1.2"})]})},{id:"skills",href:"#/skills",labelKey:"nav.skills",manage:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M3 2.5h10v3H3zM3 7h10v6.5H3z"}),(0,t.jsx)("path",{d:"M5.4 9.2h5.2M5.4 11.2h3.8"})]})},{id:"customization",href:"#/customization",labelKey:"nav.customization",manage:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M11.5 2.5l2 2-7 7-2.6.6.6-2.6z"}),(0,t.jsx)("path",{d:"M2.5 13.5h5"})]})},{id:"plugins",href:"#/plugins",label:"\u63D2\u4EF6",manage:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M6.4 1.8h3.2v3h2.8v3.2H9.6v2.8H6.4V8H3.6V4.8h2.8z"}),(0,t.jsx)("path",{d:"M2.2 11.8h11.6v2.4H2.2z"})]})},{id:"team",href:"#/team",labelKey:"nav.team",manage:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("circle",{cx:"8",cy:"8",r:"6.2"}),(0,t.jsx)("path",{d:"M1.8 8h12.4M8 1.8c-2 1.8-2 10.6 0 12.4 2-1.8 2-10.6 0-12.4z"})]})},{id:"connectors",href:"#/connectors",labelKey:"nav.connectors",manage:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M5.5 6.5v-3a2.5 2.5 0 0 1 5 0v3"}),(0,t.jsx)("rect",{x:"3.5",y:"6.5",width:"9",height:"7",rx:"2"})]})},{id:"settings",href:"#/settings",labelKey:"nav.settings",icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M8 1.75 9.35 2.05 10 3.28l1.38.3 1.04-.96.96.96-.96 1.04.3 1.38 1.23.65L14.25 8l-.3 1.35-1.23.65-.3 1.38.96 1.04-.96.96-1.04-.96-1.38.3-.65 1.23L8 14.25l-1.35-.3L6 12.72l-1.38-.3-1.04.96-.96-.96.96-1.04-.3-1.38-1.23-.65L1.75 8l.3-1.35 1.23-.65.3-1.38-.96-1.04.96-.96 1.04.96 1.38-.3.65-1.23z"}),(0,t.jsx)("circle",{cx:"8",cy:"8",r:"2"})]})}],jn=[{id:"overview",labelKey:"nav.group.overview",items:["overview"]},{id:"collab",labelKey:"nav.group.collab",items:["sessions","agent-workbench","groups","schedules","workflows","office"]},{id:"workforce",labelKey:"nav.group.workforce",items:["roles","skills","customization","bot-defaults"]},{id:"analytics",labelKey:"nav.group.analytics",items:["monitoring","insights","feedback"]},{id:"manage",labelKey:"nav.group.manage",items:["connectors","team","plugins","whiteboards","settings"]}],oe=[],T=!0,ye=!1,Ee=location.hash||"#/",V=null,ae=!1,re=null,ke=null,an=null,xe=null,rn=null,I=Pt(),sn="botmux.ownerAvatar.v1",Gn=new Set(["working","analyzing","active","starting"]),Qe="botmux:auth-expired",Me;function ne(e){return(0,t.jsx)("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e})}function Xt(e){return e.labelKey?s(e.labelKey):e.label??""}function Xn(e,n){let o=n||"#/";return e.id==="plugins"&&oe.some(a=>a.href===o||o.startsWith(`${a.href}?`)||o.startsWith(`${a.href}/`))?!1:e.id==="sessions"&&(o==="#/monitor-room"||o.startsWith("#/monitor-room?")||o.startsWith("#/monitor-room/"))||e.id==="connectors"&&(o==="#/webhook-logs"||o.startsWith("#/webhook-logs?")||o.startsWith("#/webhook-logs/"))?!0:e.href===o||e.href!=="#/"&&(o.startsWith(`${e.href}?`)||o.startsWith(`${e.href}/`))}function Jn(){let e=_e()?Gt.filter(o=>o.id!=="workflows"):Gt;if(oe.length===0)return e;let n=e.findIndex(o=>o.id==="plugins");return n<0?[...e,...oe]:[...e.slice(0,n+1),...oe,...e.slice(n+1)]}function Yn(e){let n=[];return Xn(e,Ee)&&n.push("active"),e.id==="settings"&&ae&&n.push("nav-has-update"),n.length?n.join(" "):void 0}function Zn(e){return(0,t.jsxs)("a",{href:e.href,"data-route":e.id,className:[Yn(e),e.plugin?"sidebar-plugin-item":""].filter(Boolean).join(" ")||void 0,title:e.plugin?Xt(e):void 0,children:[ne(e.icon),(0,t.jsx)("span",{className:"sidebar-nav-label",children:Xt(e)}),e.id==="settings"&&ae?(0,t.jsx)(vt,{className:"nav-update-tip",label:Yt(),trigger:(0,t.jsx)("span",{className:"nav-update-dot","aria-hidden":"true"}),preventClick:!1,focusable:!1,children:Yt()}):null]})}function ln(){let e=pe(new URLSearchParams(location.search).get("locale"));if(e)return e;let n=location.hash.indexOf("?");return n<0?null:pe(new URLSearchParams(location.hash.slice(n+1)).get("locale"))}function Jt(){let e=ln();return!e||e===f.locale?!1:(f.setLocale(e),!0)}function Qn(){let e=location.hash.indexOf("?");return e<0?null:{path:location.hash.slice(0,e)||"#/",params:new URLSearchParams(location.hash.slice(e+1))}}function eo(){let e=Qn(),n=e?.params.get("open");if(!e||!n||n!=="bot-onboarding"&&n!=="create-session")return!1;e.params.delete("open");let o=e.params.toString();return history.replaceState(null,"",o?`${e.path}?${o}`:e.path),n==="bot-onboarding"?window.dispatchEvent(new Event(me)):$e(),!0}function Yt(){let e=re?`v${re}`:"";return ke==="runtime"?s("update.navRuntimeBadgeTitle",{version:e}):s("update.navBadgeTitle",{version:e})}function Zt(e){xe=e}function Xe(){if(xe)return xe;let e=document.getElementById("root");if(!e)throw new Error("dashboard root is not mounted");return xe=e,e}function to(){return(0,l.useEffect)(()=>{Lt()},[]),(0,l.useEffect)(()=>{Fe()}),(0,t.jsxs)("div",{className:"theme-menu",id:"theme-menu",children:[(0,t.jsx)("button",{type:"button",className:"theme-menu-btn",id:"theme-menu-btn","aria-haspopup":"listbox","aria-expanded":"false","aria-label":"Theme",children:(0,t.jsx)("span",{className:"tm-ic",children:(0,t.jsxs)("svg",{className:"tm-svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,t.jsx)("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),(0,t.jsx)("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),(0,t.jsx)("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"}),(0,t.jsx)("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),(0,t.jsx)("path",{d:"M12 2a10 10 0 0 0 0 20h1.7a2.3 2.3 0 0 0 1.6-4c-.5-.5-.2-1.3.5-1.3H17a5 5 0 0 0 5-5 9.7 9.7 0 0 0-10-9.7z"})]})})}),(0,t.jsx)("div",{className:"theme-menu-pop",id:"theme-menu-pop",role:"listbox",hidden:!0})]})}function no(){let e=[...ue.sessions.values()],n=e.filter(c=>c.status!=="closed"),o=n.map(c=>({s:c,reason:mt(c)})).filter(c=>!!c.reason).sort((c,u)=>he(c.s)-he(u.s)),a=new Set(o.map(c=>String(c.s.sessionId??""))),r=n.filter(c=>Gn.has(String(c.status))&&!a.has(String(c.sessionId??""))).length,d=o[0]??null,p=Mt(e).filter(c=>c.online||c.active.length>0).length,h=Math.max(0,n.length-o.length-r);return{working:r,attention:o.length,idle:h,onlineBots:p,attentionNotice:d?{count:o.length,time:ut(he(d.s)),bot:ht(d.s),reason:d.reason}:null}}function we(e){return(0,t.jsxs)("div",{className:`topbar-status-row${e.hot?" topbar-status-row-hot":""}`,children:[(0,t.jsx)("span",{children:e.label}),(0,t.jsx)("b",{className:e.value>0?"status-count-on":void 0,children:e.value})]})}function oo(e){let{attention:n,idle:o,working:a}=e.summary,r=a+n+o,d=r===0?"conic-gradient(var(--border) 0 360deg)":(()=>{let p=a/r*360,h=p+n/r*360;return`conic-gradient(var(--accent) 0 ${p}deg, var(--warning) ${p}deg ${h}deg, var(--success) ${h}deg 360deg)`})();return(0,t.jsxs)("div",{className:"topbar-status-donut-wrap","aria-hidden":"true",children:[(0,t.jsx)("div",{className:"topbar-status-donut",style:{background:d}}),(0,t.jsxs)("div",{className:"topbar-status-donut-center",children:[(0,t.jsx)("b",{children:r}),(0,t.jsx)("span",{children:s("overview.openSessions")})]})]})}function Je(){window.dispatchEvent(new Event(ze))}function ao(e){let{autoOpen:n=!1,summary:o}=e,[a,r]=(0,l.useState)(!1),[d,p]=(0,l.useState)(!1),[h,c]=(0,l.useState)(!1),u=(0,l.useRef)(null),m=n&&!d,k=a||m;return(0,l.useEffect)(()=>{n||p(!1)},[n]),(0,l.useEffect)(()=>{if(!k)return;let g=x=>{let y=x.target;y instanceof Node&&u.current?.contains(y)||(r(!1),p(!0))};return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[k]),(0,t.jsxs)("div",{ref:u,className:`topbar-status-menu${m?" topbar-status-auto-open":""}${a?" is-open":""}${h?" suppress-hover":""}`,onPointerEnter:Je,onPointerLeave:()=>c(!1),onFocusCapture:Je,onBlur:g=>{let x=g.relatedTarget;(!(x instanceof Node)||!g.currentTarget.contains(x))&&r(!1)},onKeyDown:g=>{g.key==="Escape"&&(r(!1),p(!0),c(!0),g.currentTarget.querySelector("#status")?.focus())},children:[(0,t.jsx)("button",{type:"button",id:"status",className:"connection-status","aria-haspopup":"true","aria-expanded":k,onClick:()=>{if(Je(),k){r(!1),p(!0),c(!0);return}c(!1),r(!0)},children:s("overview.sessionOverview")}),(0,t.jsxs)("div",{className:"topbar-status-pop",children:[o.attentionNotice?(0,t.jsxs)("a",{className:"topbar-attention-notice",href:"#/sessions",children:[(0,t.jsx)("span",{className:"topbar-attention-dot","aria-hidden":"true"}),(0,t.jsxs)("span",{className:"topbar-attention-copy",children:[(0,t.jsx)("b",{children:s("strip.pending",{count:o.attentionNotice.count})}),(0,t.jsx)("small",{children:s("strip.longestCompact",{time:o.attentionNotice.time,bot:o.attentionNotice.bot,reason:o.attentionNotice.reason})})]}),(0,t.jsx)("span",{className:"topbar-attention-action",children:s("strip.handle")})]}):null,(0,t.jsxs)("div",{className:"topbar-status-list",children:[(0,t.jsx)(we,{label:s("overview.workingSessions"),value:o.working}),(0,t.jsx)(we,{label:s("overview.idleSessions"),value:o.idle}),(0,t.jsx)(we,{label:s("overview.attention"),value:o.attention,hot:o.attention>0}),(0,t.jsx)(we,{label:s("overview.onlineBots"),value:o.onlineBots})]}),(0,t.jsx)(oo,{summary:o})]})]})}function Qt(e){if(!e.open)return null;let n=!!e.loginUrl;return(0,t.jsx)("div",{id:"auth-expired-overlay",className:"auth-expired-overlay",role:"presentation",onClick:o=>{o.target===o.currentTarget&&e.onClose()},children:(0,t.jsxs)("div",{className:"auth-expired-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"auth-expired-title",children:[(0,t.jsx)("h2",{id:"auth-expired-title",children:n?"\u767B\u5F55 Dashboard":"\u8BBF\u95EE\u94FE\u63A5\u5DF2\u5931\u6548"}),(0,t.jsx)("p",{children:n?"\u5F53\u524D\u6D4F\u89C8\u5668\u5C1A\u672A\u767B\u5F55\u3002\u70B9\u51FB\u540E\u5C06\u901A\u8FC7 Botmux \u5E73\u53F0\u6821\u9A8C\u673A\u5668 owner \u6743\u9650\uFF0C\u5E76\u8FD4\u56DE\u5F53\u524D\u9875\u9762\uFF1B\u65E0\u6743\u9650\u8D26\u53F7\u4ECD\u4F1A\u88AB\u62D2\u7EDD\u3002":"\u5F53\u524D\u94FE\u63A5/\u8BBF\u95EE\u5DF2\u5931\u6548\uFF0C\u8BF7\u4F7F\u7528\u6700\u65B0\u6388\u6743\u94FE\u63A5\u91CD\u65B0\u8FDB\u5165\uFF08\u8FD0\u884C botmux dashboard \u83B7\u53D6\uFF09\u3002"}),(0,t.jsxs)("div",{className:"auth-expired-actions",children:[e.loginUrl?(0,t.jsx)("a",{id:"dashboard-one-click-login",className:"auth-login-link primary",href:e.loginUrl,target:"_top",rel:"noopener",children:"\u4E00\u952E\u767B\u5F55"}):null,(0,t.jsx)("button",{id:"auth-expired-dismiss",type:"button",className:n?"secondary":"primary",onClick:e.onClose,children:n?"\u6682\u4E0D\u767B\u5F55":"\u77E5\u9053\u4E86"})]})]})})}function ro(e){let n=new Date(e);if(Number.isNaN(n.getTime()))return e.slice(0,10);try{return new Intl.DateTimeFormat(f.locale==="zh"?"zh-CN":"en-US",{year:"numeric",month:"numeric",day:"numeric"}).format(n)}catch{return e.slice(0,10)}}async function en(){let e=await fetch("/__selfcheck",{cache:"no-store"}),n=await e.text();if(!e.ok||!n)throw new Error(s("update.healthCheckFailed"));return n}function so(e){let{status:n}=e,[o,a]=(0,l.useState)(!1),[r,d]=(0,l.useState)("idle"),[p,h]=(0,l.useState)(0),[c,u]=(0,l.useState)(!1),[m,k]=(0,l.useState)(!1),[w,g]=(0,l.useState)(""),[x,y]=(0,l.useState)(!1),[O,B]=(0,l.useState)(!1),[E,Re]=(0,l.useState)(!1),[q,ie]=(0,l.useState)(!1),[j,nt]=(0,l.useState)([]),[M,Ne]=(0,l.useState)(null),[D,Le]=(0,l.useState)(null),S=(0,l.useRef)(!1),G=(0,l.useRef)(null),le=(0,l.useRef)(null),ot=(0,l.useRef)(null),Te=(0,l.useRef)(null),Se=(0,l.useRef)(null),[X,at]=(0,l.useState)(null),dn=()=>{G.current!==null&&(window.clearTimeout(G.current),G.current=null)},Ce=()=>{le.current!==null&&(window.clearInterval(le.current),le.current=null)};if((0,l.useEffect)(()=>{S.current=!1,d("idle"),h(0),u(!1),k(!1),g(""),y(!1),B(!1),Re(!1),ie(!1),nt([]),Ne(null),Le(null)},[n?.current,n?.latest]),(0,l.useEffect)(()=>{if(Ce(),r==="idle"||r==="error"){h(0);return}let i=r==="updating"?50:95;return r==="restarting"&&h(b=>Math.max(b,50)),le.current=window.setInterval(()=>{h(b=>b>=i?i:b+Math.max(.5,(i-b)*.08))},400),()=>Ce()},[r]),(0,l.useEffect)(()=>{n&&k(n.versionLookupOk===!1)},[n]),(0,l.useEffect)(()=>{o||y(!1)},[o]),(0,l.useEffect)(()=>{if(!o||!X)return;let i=window.requestAnimationFrame(()=>{Se.current?.querySelector('button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')?.focus()});return()=>window.cancelAnimationFrame(i)},[o,X!==null]),(0,l.useEffect)(()=>{if(!o){at(null);return}let i=()=>{let b=Te.current;if(!b)return;let R=b.getBoundingClientRect(),C=Math.min(340,Math.max(0,window.innerWidth-32)),$=Math.max(16,Math.min(R.left,window.innerWidth-C-16));at({top:R.bottom+8,left:$})};return i(),window.addEventListener("resize",i),document.addEventListener("scroll",i,!0),()=>{window.removeEventListener("resize",i),document.removeEventListener("scroll",i,!0)}},[o]),(0,l.useEffect)(()=>()=>{dn(),Ce()},[]),(0,l.useEffect)(()=>{if(!o)return;let i=R=>{let C=R.target;ot.current?.contains(C)||Se.current?.contains(C)||a(!1)},b=R=>{R.key==="Escape"&&(a(!1),Te.current?.focus())};return document.addEventListener("pointerdown",i),document.addEventListener("keydown",b),()=>{document.removeEventListener("pointerdown",i),document.removeEventListener("keydown",b)}},[o]),!n)return null;let U=n.behind&&!!n.latest,Pe=!n.latest,Oe=U&&n.updateSupported&&!n.localDevInstall&&n.node.ok,rt=(n.rollbackSupported??n.updateSupported)&&!n.localDevInstall&&n.node.ok,H=r==="updating"||r==="restarting",st=2*Math.PI*20,un=st*(1-Math.max(2,Math.round(p))/100),pn=n.updateCommand??"botmux update",Ae=`v${n.current}`,hn=n.latest?`v${n.latest}`:"",mn=n.localDevInstall?s("update.localDev"):n.updateSupported?n.node.ok?"":s("update.nodeWarn",{version:n.node.version,required:n.node.required}):s("update.unsupportedInstall"),it=i=>{let b=Date.now(),R=async()=>{try{let C=await fetch("/__selfcheck",{cache:"no-store"}),$=await C.text();if(C.ok&&$&&$!==i){location.reload();return}}catch{}if(Date.now()-b>9e4){S.current=!1,d("error"),g(s("update.restartSlow"));return}G.current=window.setTimeout(()=>{R()},2e3)};G.current=window.setTimeout(()=>{R()},3e3)},fn=async()=>{if(U){if(!Oe){a(!1),location.hash="#/settings";return}if(!S.current){S.current=!0,Le(null),k(!1),g("");try{let i=await en(),b=await Ue(fetch,d);if(b.bootstrapRequired){S.current=!1,d("error"),g(s("update.bootstrapRequired"));return}if(!b.restarted){S.current=!1,d("error"),g(s("update.restartFailed",{detail:b.restartError??"unknown"}));return}it(i)}catch(i){S.current=!1,d("error"),g(i instanceof Error?i.message:String(i))}}}},De=async(i=!1)=>{if(E)return!q;Re(!0),ie(!1);try{let b=await fetch(`/api/update/versions${i?"?refresh=1":""}`,{cache:"no-store"}),R=await b.json().catch(()=>null);if(!R||!Array.isArray(R.versions))throw new Error("Invalid rollback versions response");let C=R.versions.filter(_=>{if(!_||typeof _!="object")return!1;let J=_;return typeof J.version=="string"&&(typeof J.publishedAt=="string"||J.publishedAt===null)}).slice(0,3);nt(C),Ne(_=>C.some(J=>J.version===_)?_:null),B(!0);let $=b.ok&&R.ok===!0;return ie(!$),$}catch{return B(!0),ie(!0),!1}finally{Re(!1)}},bn=async()=>{if(!(!M||!rt||E||S.current)){S.current=!0,Le(M),k(!1),g("");try{let i=await en();await Ue(fetch,d,M),it(i)}catch(i){S.current=!1,d("error"),g(i instanceof Error?i.message:String(i))}}},gn=async()=>{if(!(c||H)){u(!0),k(!1);try{let i=await e.onRefresh();x&&await De(!0),k(!i)}finally{u(!1)}}},ce=r==="updating"?D?s("update.rollbackInstalling",{version:D}):s("update.updating",{command:pn}):r==="restarting"?D?s("update.rollbackRestarting",{version:D}):s("update.restarting"):r==="error"?D?s("update.rollbackFailed",{detail:w}):s("update.updateFailed",{detail:w}):m?s("update.topbarRefreshFailed"):U?Oe?s("update.versionUpgradePrompt",{version:hn}):mn:n.latest?s("update.upToDate"):s("update.checkUnavailable"),vn=Oe?r==="error"?s("update.topbarRetry"):r==="idle"?s("update.topbarAction"):s("update.topbarWorking"):s("update.topbarReview"),de=r==="error"||m&&Pe?{className:"is-error",symbol:"!"}:U?{className:"has-update",symbol:"\u2191"}:Pe?{className:"is-unknown",symbol:"?"}:{className:"is-current",symbol:"\u2713"};return(0,t.jsxs)("div",{ref:ot,className:`dashboard-version-control${o?" is-open":""}`,children:[(0,t.jsxs)("button",{ref:Te,type:"button",className:`dashboard-version-chip${U?" has-update":""}${Pe?" is-unknown":""}${r==="error"?" is-error":""}`,"aria-haspopup":"dialog","aria-expanded":o,"aria-label":`${Ae}. ${ce}`,title:ce,onClick:()=>a(i=>!i),children:[(0,t.jsx)("span",{children:Ae}),(0,t.jsx)("span",{className:`dashboard-version-state ${de.className}`,"aria-hidden":"true",children:de.symbol})]}),o&&X&&typeof document<"u"?(0,nn.createPortal)((0,t.jsxs)("section",{ref:Se,className:"dashboard-version-popover",role:"dialog","aria-modal":"false","aria-labelledby":"dashboard-version-title",style:{top:X.top,left:X.left},children:[(0,t.jsxs)("header",{className:"dashboard-version-popover-head",children:[(0,t.jsx)("strong",{id:"dashboard-version-title",children:s("update.current")}),(0,t.jsxs)("div",{className:"dashboard-version-head-actions",children:[(0,t.jsx)("button",{type:"button",className:`dashboard-version-refresh${c?" is-refreshing":""}`,"aria-label":s(c?"update.topbarRefreshing":"update.topbarRefresh"),title:s(c?"update.topbarRefreshing":"update.topbarRefresh"),disabled:c||E||H,onClick:()=>{gn()},children:(0,t.jsxs)("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[(0,t.jsx)("path",{d:"M13.2 5.7A5.8 5.8 0 1 0 13 10.8"}),(0,t.jsx)("path",{d:"M13.2 2.8v2.9h-2.9"})]})}),(0,t.jsx)("button",{type:"button",className:"dashboard-version-close","aria-label":s("update.topbarClose"),onClick:()=>a(!1),children:"\xD7"})]})]}),(0,t.jsxs)("div",{className:"dashboard-version-popover-body",children:[(0,t.jsxs)("div",{className:"dashboard-version-current",children:[(0,t.jsx)("strong",{children:Ae}),H?(0,t.jsxs)("span",{className:"dashboard-version-ring",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(p),"aria-label":ce,children:[(0,t.jsxs)("svg",{viewBox:"0 0 44 44",width:"44",height:"44","aria-hidden":"true",children:[(0,t.jsx)("defs",{children:(0,t.jsxs)("linearGradient",{id:"dvr-grad",x1:"0%",y1:"100%",x2:"100%",y2:"0%",children:[(0,t.jsx)("stop",{offset:"0%",stopColor:"var(--brand-accent-cyan)"}),(0,t.jsx)("stop",{offset:"55%",stopColor:"var(--accent)"}),(0,t.jsx)("stop",{offset:"100%",stopColor:"var(--brand-accent-pink)"})]})}),(0,t.jsx)("circle",{className:"dvr-track",cx:"22",cy:"22",r:"20"}),(0,t.jsx)("circle",{className:"dvr-arc",cx:"22",cy:"22",r:"20",style:{strokeDasharray:st,strokeDashoffset:un}})]}),(0,t.jsxs)("span",{className:"dvr-pct",children:[Math.round(p),"%"]})]}):(0,t.jsx)("span",{className:de.className,"aria-hidden":"true",children:de.symbol})]}),(0,t.jsx)("p",{className:`dashboard-version-message${r==="error"||m?" is-error":""}`,role:r==="error"||m?"alert":"status","aria-live":"polite",children:ce}),(0,t.jsxs)("a",{className:"dashboard-version-release-link",href:"https://github.com/deepcoldy/botmux/releases",target:"_blank",rel:"noopener noreferrer",children:[(0,t.jsx)("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M8 1.5a6.5 6.5 0 0 0-2.1 12.65c.33.06.45-.14.45-.32v-1.26c-1.84.4-2.23-.78-2.23-.78-.3-.76-.73-.96-.73-.96-.6-.41.05-.4.05-.4.66.05 1 .68 1 .68.59 1 1.54.72 1.92.55.06-.42.23-.72.42-.88-1.47-.17-3.02-.74-3.02-3.28 0-.72.26-1.32.68-1.78-.07-.17-.3-.84.07-1.75 0 0 .56-.18 1.79.68A6.2 6.2 0 0 1 8 4.63a6.2 6.2 0 0 1 1.71.22c1.23-.86 1.79-.68 1.79-.68.37.91.14 1.58.07 1.75.42.46.68 1.06.68 1.78 0 2.55-1.55 3.11-3.03 3.28.24.21.45.61.45 1.23v1.62c0 .18.12.38.46.32A6.5 6.5 0 0 0 8 1.5Z"})}),(0,t.jsx)("span",{children:s("update.changelogViewOnGitHub")})]}),(U||x)&&n.installs.multiple?(0,t.jsxs)("details",{className:"dashboard-version-installs",children:[(0,t.jsx)("summary",{children:s("update.multiInstallWarn")}),(0,t.jsx)("ul",{children:n.installs.entries.map(i=>(0,t.jsx)("li",{children:i.binPath},i.binPath))})]}):null,rt?(0,t.jsxs)("details",{className:"dashboard-version-rollback",open:x,"aria-busy":E,onToggle:i=>{let b=i.currentTarget.open;y(b),b&&!O&&!E&&De()},children:[(0,t.jsxs)("summary",{children:[(0,t.jsxs)("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[(0,t.jsx)("circle",{cx:"8",cy:"8",r:"5.5"}),(0,t.jsx)("path",{d:"M8 4.8V8l2.2 1.3"})]}),(0,t.jsx)("span",{children:s("update.rollbackTitle")}),(0,t.jsx)("span",{className:"dashboard-version-rollback-chevron","aria-hidden":"true",children:"\u2304"})]}),(0,t.jsxs)("div",{className:"dashboard-version-rollback-body",children:[E&&j.length===0?(0,t.jsxs)("p",{className:"dashboard-version-rollback-status",role:"status","aria-live":"polite",children:[(0,t.jsx)("span",{className:"dashboard-update-spinner","aria-hidden":"true"}),s("update.rollbackLoading")]}):null,q?(0,t.jsxs)("p",{className:"dashboard-version-rollback-load-error",role:"alert",children:[(0,t.jsx)("span",{children:s("update.rollbackLoadFailed")}),(0,t.jsx)("button",{type:"button",disabled:E,onClick:()=>{De(!0)},children:s("update.rollbackRetry")})]}):null,O&&!E&&!q&&j.length===0?(0,t.jsx)("p",{className:"dashboard-version-rollback-status",children:s("update.rollbackEmpty")}):null,j.length>0?(0,t.jsxs)("fieldset",{disabled:H||E||q,children:[(0,t.jsx)("legend",{children:s("update.rollbackHint")}),(0,t.jsx)("div",{className:"dashboard-version-rollback-options",children:j.map(i=>(0,t.jsxs)("label",{className:M===i.version?"is-selected":"",children:[(0,t.jsx)("input",{type:"radio",name:"dashboard-rollback-version",value:i.version,checked:M===i.version,onChange:()=>Ne(i.version)}),(0,t.jsxs)("strong",{children:["v",i.version]}),i.publishedAt?(0,t.jsx)("time",{dateTime:i.publishedAt,children:ro(i.publishedAt)}):null]},i.version))})]}):null,M?(0,t.jsxs)("p",{id:"dashboard-version-rollback-risk",className:"dashboard-version-rollback-risk",role:"note",children:[(0,t.jsxs)("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[(0,t.jsx)("path",{d:"M7.1 2.3 1.8 12a1 1 0 0 0 .9 1.5h10.6a1 1 0 0 0 .9-1.5L8.9 2.3a1 1 0 0 0-1.8 0Z"}),(0,t.jsx)("path",{d:"M8 5.5v3.6M8 11.6h.01"})]}),(0,t.jsxs)("span",{children:[s("update.rollbackRisk",{version:M})," ",(0,t.jsx)("a",{href:`https://github.com/deepcoldy/botmux/releases/tag/v${encodeURIComponent(M)}`,target:"_blank",rel:"noopener noreferrer","aria-label":s("update.rollbackReleaseNotesA11y",{version:M}),children:s("update.rollbackReleaseNotes",{version:M})})]})]}):null,j.length>0?(0,t.jsxs)("button",{type:"button",className:"dashboard-version-rollback-action",disabled:!M||E||q||H,"aria-describedby":M?"dashboard-version-rollback-risk":void 0,onClick:()=>{bn()},children:[H&&D?(0,t.jsx)("span",{className:"dashboard-update-spinner","aria-hidden":"true"}):null,M?r==="error"&&D===M?s("update.rollbackRetry"):s("update.rollbackAction",{version:M}):s("update.rollbackSelect")]}):null]})]}):null]}),U&&!x&&!D?(0,t.jsxs)("footer",{className:"dashboard-version-popover-actions",children:[(0,t.jsx)("button",{type:"button",className:"dashboard-version-secondary",onClick:()=>a(!1),children:H?s("update.topbarClose"):s("update.topbarLater")}),(0,t.jsx)("button",{type:"button",className:"dashboard-version-primary",disabled:H,onClick:()=>{fn()},children:vn})]}):null]}),document.body):null]})}function io(){let e=no(),[n,o]=(0,l.useState)(!1),[a,r]=(0,l.useState)(!1),[d,p]=(0,l.useState)(!1),h=(0,l.useRef)(e.attention),c=(0,l.useRef)(null),u=()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)};(0,l.useEffect)(()=>{let w=()=>o(!0);return window.addEventListener(me,w),()=>window.removeEventListener(me,w)},[]),(0,l.useEffect)(()=>{let w=()=>r(!0);return window.addEventListener(Qe,w),se&&r(!0),()=>window.removeEventListener(Qe,w)},[]),(0,l.useEffect)(()=>()=>u(),[]),(0,l.useEffect)(()=>{let w=h.current;if(h.current=e.attention,e.attention===0){u(),p(!1);return}w!==0||document.body.classList.contains("theme-menu-open")||(p(!0),u(),c.current=window.setTimeout(()=>{c.current=null,p(!1)},4e3))},[e.attention]);let m=()=>{se=!1,r(!1)},k=_e()?Ee.startsWith("#/agent-workbench-dock")?"dock":Ee.startsWith("#/agent-workbench")?"appCenter":null:null;return k?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"workbench-route-host","data-workbench-surface":k,children:(0,t.jsx)("main",{id:"root",ref:Zt})}),(0,t.jsx)(Qt,{open:a,loginUrl:ve(Me,location.hash),onClose:m}),(0,t.jsx)(Be,{}),(0,t.jsx)(Ie,{})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"aurora","aria-hidden":"true",children:[(0,t.jsx)("i",{className:"a1"}),(0,t.jsx)("i",{className:"a2"}),(0,t.jsx)("i",{className:"a3"})]}),(0,t.jsxs)("div",{className:"app-shell",children:[(0,t.jsxs)("header",{className:"topbar",children:[(0,t.jsx)("div",{className:"topbar-left",children:(0,t.jsxs)("div",{className:"topbar-brand-block",children:[(0,t.jsxs)("a",{className:"brand",href:"#/",children:[(0,t.jsx)("span",{className:"brand-mark","aria-hidden":"true",children:(0,t.jsx)("img",{className:"brand-logo-img",src:"/assets/brand-logo.png",alt:"",decoding:"sync",loading:"eager",fetchPriority:"high"})}),(0,t.jsx)("strong",{className:"brand-wordmark",children:"Botmux"}),(0,t.jsx)("span",{className:"brand-product",children:"Dashboard"})]}),(0,t.jsx)(so,{status:an,onRefresh:()=>et(!0)})]})}),(0,t.jsxs)("div",{className:"topbar-actions",children:[(0,t.jsx)(ao,{summary:e,autoOpen:d}),(0,t.jsxs)("div",{className:"topbar-tool-group",children:[(0,t.jsx)("button",{type:"button",className:"topbar-locale-toggle","aria-label":f.locale==="zh"?"Switch to English":"\u5207\u6362\u5230\u4E2D\u6587",title:f.locale==="zh"?"Switch to English":"\u5207\u6362\u5230\u4E2D\u6587",onClick:()=>lo(f.locale==="zh"?"en":"zh"),children:f.locale==="zh"?"CN":"EN"}),(0,t.jsx)(to,{}),(0,t.jsxs)("a",{className:"topbar-docs-link",href:"https://deepcoldy.github.io/botmux/",target:"_blank",rel:"noopener noreferrer",title:s("nav.docs"),"aria-label":s("nav.docs"),children:[ne((0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("rect",{x:"2.2",y:"2.2",width:"11.6",height:"11.6",rx:"2"}),(0,t.jsx)("path",{d:"M4.8 5.2h6.4M4.8 8h6.4M4.8 10.8h4"})]})),(0,t.jsx)("span",{children:s("nav.docs")})]})]}),(0,t.jsxs)("span",{className:"topbar-owner",title:V?.name,"aria-label":V?.name??"Owner",children:[(0,t.jsx)("span",{className:"topbar-owner-placeholder","aria-hidden":"true",children:ne((0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("circle",{cx:"8",cy:"6",r:"2.4"}),(0,t.jsx)("path",{d:"M3.7 13c.7-2.5 2.2-3.7 4.3-3.7s3.6 1.2 4.3 3.7"})]}))}),V?.avatarUrl?(0,t.jsx)("img",{className:"topbar-owner-img",src:V.avatarUrl,alt:"",decoding:"async",referrerPolicy:"no-referrer",onError:w=>{w.currentTarget.remove()}}):null]})]})]}),(0,t.jsxs)("div",{className:"chrome-body",children:[(0,t.jsxs)("aside",{className:"sidebar",children:[T?(0,t.jsxs)("div",{className:"sidebar-create-actions",children:[(0,t.jsxs)("button",{type:"button",className:"sidebar-create-btn",onClick:()=>$e(),children:[ne((0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M2 3.5h12v7H6l-3 3v-3H2z"}),(0,t.jsx)("path",{d:"M8 4.9v4.2M5.9 7h4.2"})]})),(0,t.jsx)("span",{className:"sidebar-nav-label",children:s("nav.createSession")})]}),(0,t.jsxs)("button",{type:"button",className:"sidebar-create-btn",onClick:()=>{wt()},children:[ne((0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("rect",{x:"2.5",y:"6",width:"11",height:"7.5",rx:"2"}),(0,t.jsx)("circle",{cx:"5.8",cy:"9.75",r:"1"}),(0,t.jsx)("circle",{cx:"10.2",cy:"9.75",r:"1"}),(0,t.jsx)("path",{d:"M8 6V3.8M6.3 1.9h3.4"})]})),(0,t.jsx)("span",{className:"sidebar-nav-label",children:s("nav.createBot")})]})]}):null,(0,t.jsx)("nav",{className:"sidebar-nav","aria-label":"Dashboard",children:(()=>{let w=Jn().filter(y=>T||!y.manage),g=new Map(w.map(y=>[y.id,y])),x=w.filter(y=>y.plugin);return jn.map(y=>{let O=y.items.flatMap(B=>{let E=g.get(B);return E?E.id==="plugins"?[E,...x]:[E]:[]});return O.length===0?null:(0,t.jsxs)("div",{className:"nav-group",children:[(0,t.jsx)("div",{className:"nav-group-title",children:s(y.labelKey)}),O.map(Zn)]},y.id)})})()})]}),(0,t.jsxs)("div",{className:"workspace",children:[(0,t.jsx)("dialog",{id:"create-session-modal",className:"create-session-modal"}),(0,t.jsx)(yt,{open:n,onClose:()=>o(!1)}),(0,t.jsx)("main",{id:"root",ref:Zt})]})]})]}),(0,t.jsx)(Qt,{open:a,loginUrl:ve(Me,location.hash),onClose:m}),(0,t.jsx)(Be,{}),(0,t.jsx)(Ie,{})]})}function N(){rn?.render((0,t.jsx)(io,{}))}function lo(e){f.setLocale(e),ho(e)}var se=!1;function cn(e){let n=!!ve(e,location.hash),o=n&&Me!==e;n&&(Me=e),se&&o&&N(),!se&&(se=!0,window.dispatchEvent(new Event(Qe)))}var Ye;function co(){let e=document.getElementById("readonly-toast");e||(e=document.createElement("div"),e.id="readonly-toast",e.style.cssText="position:fixed;left:50%;bottom:28px;transform:translateX(-50%);z-index:9999;background:var(--fg,#1f2329);color:var(--bg,#fff);padding:10px 18px;border-radius:var(--radius-lg);font-size:13px;box-shadow:0 8px 24px rgba(0,0,0,.25)",document.body.appendChild(e)),e.textContent="\u5F53\u524D\u662F\u53EA\u8BFB\u8BBF\u95EE\uFF0C\u6B64\u64CD\u4F5C\u9700\u8981\u6388\u6743\u94FE\u63A5\uFF08\u8FD0\u884C botmux dashboard \u83B7\u53D6\uFF09",e.style.display="block",Ye&&window.clearTimeout(Ye),Ye=window.setTimeout(()=>{e.style.display="none"},4e3)}var tt=window.fetch.bind(window);window.fetch=async function(...n){let o=await tt(...n);if(o.status===401){if(o.headers.get("x-botmux-auth-scope")==="workbench")return o;let a=o.headers.get("x-botmux-login-url")??void 0,r=(n[1]?.method??"GET").toUpperCase();a||(r==="GET"||r==="HEAD")&&!ye?cn(a):co()}return o};async function uo(){try{let e=await tt("/api/workbench/capabilities",{cache:"no-store"});f.workbenchCapabilities=e.ok?ct(await e.json()):He}catch{f.workbenchCapabilities=He}}async function po(){let e=uo();try{let n=await tt("/api/settings");if(n.ok){let o=await n.json();T=!!o.authed,f.authed=T,f.workbenchAuthed=T,ye=!!(o.settings&&o.settings.publicReadOnly),f.publicReadOnly=ye;let a=ln()??pe(o.lang);a&&f.setLocale(a)}else if(n.status===401&&n.headers.get("x-botmux-auth-scope")==="workbench")T=!1,f.authed=!1,f.workbenchAuthed=!0,ye=!1,f.publicReadOnly=!1;else if(n.status===401){T=!1,f.authed=!1,f.workbenchAuthed=!1;let o=n.headers.get("x-botmux-login-url")??void 0;cn(o)}}catch{}await e}async function tn(){try{let e=await fetch("/api/plugins/dashboard");if(!e.ok)return;let n=await e.json();oe=(Array.isArray(n?.plugins)?n.plugins:[]).filter(a=>a.pinned===!0&&typeof a.route=="string").map(a=>({id:`plugin:${a.pluginId}:${a.id}`,href:a.route,label:a.displayName||a.pluginId,manage:!0,plugin:!0,icon:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:"M5.2 2.2h5.6v3.1l1.7 1.7-1.4 1.4-1-1v6.4H5.9V7.4l-1 1L3.5 7l1.7-1.7z"}),(0,t.jsx)("path",{d:"M8 13.8v1"})]})})),N()}catch{}}async function ho(e){if(T)try{await fetch("/api/settings",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({lang:e})})}catch{}}async function et(e=!1){if(!T)return!1;try{let n=await fetch(`/api/update/status${e?"?refresh=1":""}`,{cache:"no-store"});if(!n.ok)return!1;let o=await n.json();an=o;let a=Array.isArray(o.cliUpdates)?o.cliUpdates.find(r=>r?.updateAvailable===!0&&r?.latest):null;return o.behind===!0&&o.latest?(ae=!0,ke="botmux",re=String(o.latest)):a?(ae=!0,ke="runtime",re=String(a.latest)):(ae=!1,ke=null,re=null),N(),o.versionLookupOk!==!1}catch{return!1}}function mo(e){e.innerHTML='<section class="auth-required" style="max-width:520px;margin:64px auto;text-align:center;background:var(--surface);color:var(--fg);border:1px solid var(--border);border-radius:var(--radius-lg);padding:40px 36px;box-shadow:0 8px 28px rgba(0,0,0,.12)"><h2 style="margin:0 0 12px;font-size:20px;color:var(--fg)">\u6B64\u9875\u9700\u8981\u6388\u6743\u94FE\u63A5</h2><p style="margin:0 0 24px;line-height:1.7;color:var(--muted);font-size:14px">\u4F60\u5F53\u524D\u662F\u53EA\u8BFB\u8BBF\u95EE\uFF0C\u7BA1\u7406\u9875\uFF08\u7FA4\u89D2\u8272 / Profiles / Bot \u914D\u7F6E / \u56E2\u961F / Webhook\uFF09\u9700\u8981\u6388\u6743\u94FE\u63A5\u3002\u8FD0\u884C <code>botmux dashboard</code> \u83B7\u53D6\u6700\u65B0\u94FE\u63A5\u540E\u5373\u53EF\u7BA1\u7406\u3002</p><a href="#/" style="display:inline-block;padding:8px 22px;background:var(--accent);color:var(--on-accent);border-radius:var(--radius-lg);text-decoration:none;font-size:14px">\u8FD4\u56DE\u603B\u89C8</a></section>'}async function Ze(){let e=Ot(I),n=location.hash||"#/";Ee=n,N();let o=xt(n);if(o){window.location.replace(o);return}if(!T&&qn.some(a=>n.startsWith("#/"+a))){mo(Xe()),I.rerenderOnUiChange=!0;return}if(n.startsWith("#/v3")){window.location.replace(`#/workflows${n.slice(4)}`);return}else if(n.startsWith("#/legacy-workflow")){window.location.replace("#/workflows");return}else if(/^#\/workflows(?:\/|-)catalog(?:[/?].*)?$/.test(n)){window.location.replace("#/workflows");return}if(n.startsWith("#/role-profiles")){window.location.replace(`#/roles/profile${n.slice(15)}`);return}try{let a=Tt(n);await At(I,e,Xe(),a?a.load:St,{rerenderOnUiChange:a?a.rerenderOnUiChange:!1}),e===I.seq&&T&&eo()}catch(a){if(e!==I.seq||It(a,{href:window.location.href,hash:n,getSessionStorage:()=>window.sessionStorage,reload:()=>window.location.reload()}))return;Xe().innerHTML=`<section class="page"><div class="empty">Dashboard route failed: ${dt(String(a))}</div></section>`,I.pageDispose=null,I.rerenderOnUiChange=!0}}function fo(){try{let e=JSON.parse(window.localStorage.getItem(sn)??"null");if(e?.avatarUrl)return{avatarUrl:String(e.avatarUrl),name:e.name?String(e.name):void 0}}catch{}return null}function bo(){V=fo(),N(),fetch("/api/owner-profile").then(e=>e.ok?e.json():null).then(e=>{if(!(!e?.ok||!e.avatarUrl)){V={avatarUrl:String(e.avatarUrl),name:e.name?String(e.name):void 0};try{window.localStorage.setItem(sn,JSON.stringify({avatarUrl:e.avatarUrl,name:e.name??""}))}catch{}N()}}).catch(()=>{})}(async()=>{let e=kt(window.location.href);e&&window.history.replaceState(window.history.state,"",e),f.init(),Jt();let n=document.getElementById("app-root");if(!n)throw new Error("missing dashboard app root");Ft(n),jt(),rn=(0,on.createRoot)(n),N(),f.on(()=>{N(),I.rerenderOnUiChange&&Ze()}),ue.on(()=>{N()}),await po(),N(),window.addEventListener(bt,()=>{tn()}),tn(),et(),window.setInterval(()=>{document.hidden||et()},30*6e4),bo();try{await lt({canReadSchedules:()=>f.authed||f.publicReadOnly})}catch(o){console.error("botmux dashboard bootstrap failed",o),ue.setOnline(!1)}pt().then(N),Et().then(N),window.addEventListener("hashchange",()=>{Jt()||Ze()}),Ze()})();export{cn as showAuthExpiredOverlay,co as showReadOnlyToast};
package/dist/dashboard.js CHANGED
@@ -9,6 +9,7 @@ import { fileURLToPath } from 'node:url';
9
9
  import { createHmac, randomBytes } from 'node:crypto';
10
10
  import { logger } from './utils/logger.js';
11
11
  import { isStandaloneBinary } from './core/self-spawn.js';
12
+ import { currentUpdateStrategy, replaceStandaloneBinary } from './core/binary-self-update.js';
12
13
  import { gracefulProcessExitCode } from './pm2-graceful-exit.js';
13
14
  import { config, isWildcardBindHost } from './config.js';
14
15
  import { listenWithProbe } from './utils/listen-with-probe.js';
@@ -70,14 +71,14 @@ import { parseCloseResidual } from './core/close-residual.js';
70
71
  import { dashboardSecretPath } from './core/dashboard-secret.js';
71
72
  import { getGitRepoInfo } from './core/session-row-enrichment.js';
72
73
  import { deleteWhiteboard, listWhiteboards, readWhiteboard, whiteboardEnabled } from './services/whiteboard-store.js';
73
- import { isLocalDevInstall, botmuxVersionAt, botmuxCliEntryAt, botmuxInstallRoot, bakedBinaryVersion } from './utils/install-info.js';
74
+ import { isLocalDevInstall, botmuxVersionAt, diskVersionAt, botmuxCliEntryAt, botmuxInstallRoot, bakedBinaryVersion } from './utils/install-info.js';
74
75
  import { checkNode, detectBotmuxInstalls, resolveCurrentVersion, resolveCurrentVersionAt } from './utils/install-diagnostics.js';
75
76
  import { fetchLatestVersion, fetchReleasesSince, fetchRollbackVersions, compareVersions, isCanonicalStableVersion, isNewerVersion, } from './core/update-check.js';
76
77
  import { GITHUB_REPO } from './core/restart-report.js';
77
78
  import { DEFAULT_OVERLOAD_THRESHOLDS } from './core/host-overload-alert.js';
78
79
  import { spawnDetachedRestart, globalInstallUpdateLockTarget } from './core/maintenance.js';
79
80
  import { resolveLocalDevCheckoutDir, resolveLocalDevRestartTarget, isGitWorktree, gitPorcelainStatus, gitHeadSha, localDevUpdateSteps, } from './utils/local-dev-update.js';
80
- import { detectGlobalInstallManager, formatGlobalInstallCommand, resolveGlobalInstallPlan, tryResolveGlobalInstallPlan, withGlobalInstallRegistry, UnsupportedGlobalInstallError, } from './utils/global-install.js';
81
+ import { detectGlobalInstallManager, formatGlobalInstallCommand, resolveGlobalInstallPlan, tryResolveGlobalInstallPlan, isAutoUpdateSupportedInstall, withGlobalInstallRegistry, UnsupportedGlobalInstallError, } from './utils/global-install.js';
81
82
  import { filterCliRuntimeUpdateEntriesForTargets, listCliRuntimeUpdateEntries, selectCodexRuntimeUpdateTargets, } from './core/cli-runtime-update.js';
82
83
  import { claimRestartLease, clearRestartIntent, clearRestartLease, hasActiveRestartLease, writeManualIntentIfAbsent, writeRestartIntent, } from './services/restart-intent-store.js';
83
84
  import { withFileLock } from './utils/file-lock.js';
@@ -1189,7 +1190,11 @@ function resolveDashboardSettings() {
1189
1190
  repoPickerMode: global.repoPickerMode ?? 'all',
1190
1191
  maintenance: global.maintenance ?? {},
1191
1192
  localDevInstall: isLocalDevInstall(),
1192
- autoUpdateSupported: lastSuccessfulUpdatePlan !== undefined || tryResolveGlobalInstallPlan() !== null,
1193
+ // Same predicate the save-time validation uses (resolveAutoUpdateSupport), so
1194
+ // the UI can never render the toggle disabled while the backend would accept
1195
+ // it — or the reverse. A plain `tryResolveGlobalInstallPlan()` here reported
1196
+ // false for every compiled binary, because its package root is "/".
1197
+ autoUpdateSupported: lastSuccessfulUpdatePlan !== undefined || isAutoUpdateSupportedInstall(),
1193
1198
  whiteboard: { enabled: global.whiteboard?.enabled === true },
1194
1199
  workflow: { enabled: global.workflow?.enabled === true }, // default OFF
1195
1200
  remoteAccess: global.remoteAccess === true,
@@ -3726,9 +3731,24 @@ const server = createServer(async (req, res) => {
3726
3731
  // `authed` guards on the two mutations are defense-in-depth for host actions.
3727
3732
  if (req.method === 'GET' && url.pathname === '/api/update/status') {
3728
3733
  const current = currentInstalledVersion();
3729
- const packageRoot = lastSuccessfulUpdatePlan?.activePackageRoot ?? botmuxInstallRoot();
3730
- const installManager = detectGlobalInstallManager(packageRoot);
3731
- const installPlan = tryResolveGlobalInstallPlan(packageRoot);
3734
+ // Display/classification only deliberately NOT a plan root. It feeds
3735
+ // `currentUpdateStrategy` (which handles the compiled binary's "/" correctly)
3736
+ // and the manager label shown when nothing else resolves. Named distinctly from
3737
+ // the `packageRoot` variables that DO reach resolveGlobalInstallPlan, so the two
3738
+ // uses cannot be confused (and so the source guard in
3739
+ // test/binary-self-update.test.ts can tell them apart).
3740
+ const classifyRoot = lastSuccessfulUpdatePlan?.activePackageRoot ?? botmuxInstallRoot();
3741
+ const installManager = detectGlobalInstallManager(classifyRoot);
3742
+ // A compiled binary has no package.json, so `classifyRoot` is "/" and the
3743
+ // plan resolution always fails — which used to grey out the update button
3744
+ // and tell an npm user their install method is unsupported. Resolve the
3745
+ // strategy by BINARY LOCATION first; only fall back to the package-root
3746
+ // classification for the Node path (unchanged there).
3747
+ const updateStrategy = currentUpdateStrategy(classifyRoot);
3748
+ const installPlan = updateStrategy.kind === 'package-manager'
3749
+ ? tryResolveGlobalInstallPlan(updateStrategy.packageRoot)
3750
+ : null;
3751
+ const selfReplace = updateStrategy.kind === 'self-replace';
3732
3752
  // Compare against the npm `latest` dist-tag (always stable; the update
3733
3753
  // button installs `@latest`). isNewerVersion uses semver precedence, so a
3734
3754
  // canary running AHEAD of the latest stable (e.g. 2.87.0-canary.0 vs
@@ -3770,9 +3790,19 @@ const server = createServer(async (req, res) => {
3770
3790
  // the wrapper points at is a real git worktree; otherwise the button
3771
3791
  // stays disabled (there is nothing to pull).
3772
3792
  localDevUpdatable: localDev && isGitWorktree(resolveLocalDevCheckoutDir()),
3773
- updateSupported: installPlan !== null,
3774
- updateManager: installPlan?.manager ?? installManager,
3775
- updateCommand: installPlan ? formatGlobalInstallCommand(installPlan) : null,
3793
+ updateSupported: installPlan !== null || selfReplace,
3794
+ // Rollback is a SEPARATE capability from update. The web UI used to derive
3795
+ // it from `updateSupported`, which now includes the self-replacing binary —
3796
+ // but /api/update/rollback only knows how to drive a package manager, so a
3797
+ // curl-installed binary would be offered a button that always fails.
3798
+ // Report it explicitly instead of letting the UI infer it.
3799
+ rollbackSupported: installPlan !== null,
3800
+ // The standalone binary is not owned by a package manager; report it as
3801
+ // its own kind rather than letting the UI claim "npm/pnpm/Bun only".
3802
+ updateManager: selfReplace ? 'binary' : (installPlan?.manager ?? installManager),
3803
+ updateCommand: selfReplace
3804
+ ? `botmux update(下载并替换 ${updateStrategy.target})`
3805
+ : installPlan ? formatGlobalInstallCommand(installPlan) : null,
3776
3806
  node: checkNode(),
3777
3807
  installs: detectBotmuxInstalls(),
3778
3808
  });
@@ -3860,9 +3890,66 @@ const server = createServer(async (req, res) => {
3860
3890
  localDev: true,
3861
3891
  });
3862
3892
  }
3893
+ // 编译版独立二进制(install.sh 形态):没有包管理器拥有这个文件,改为下载
3894
+ // 对应平台的 release 资产、校验 SHA-256 后原子替换自身。npm 子包形态不走
3895
+ // 这里 —— 那棵树归 npm 所有,交回 npm 更新(见 binary-self-update.ts 头部)。
3896
+ const runStrategy = currentUpdateStrategy(botmuxInstallRoot());
3897
+ if (runStrategy.kind === 'self-replace') {
3898
+ if (updateInFlight)
3899
+ return jsonRes(res, 409, { ok: false, error: 'update_in_flight' });
3900
+ updateInFlight = true;
3901
+ let acquired = false;
3902
+ let blockedByRestart = false;
3903
+ let oldVersion = '';
3904
+ let newVersion = '';
3905
+ try {
3906
+ const latest = await cachedLatestVersion(false);
3907
+ if (!latest.value) {
3908
+ return jsonRes(res, 503, { ok: false, error: 'version_lookup_failed' });
3909
+ }
3910
+ oldVersion = currentInstalledVersion();
3911
+ newVersion = latest.value;
3912
+ await withFileLock(globalInstallUpdateLockTarget(), async () => {
3913
+ acquired = true;
3914
+ if (hasActiveRestartLease()) {
3915
+ blockedByRestart = true;
3916
+ return;
3917
+ }
3918
+ await replaceStandaloneBinary(newVersion, runStrategy.target);
3919
+ }, { maxWaitMs: 2_000 });
3920
+ }
3921
+ catch (e) {
3922
+ if (!acquired)
3923
+ return jsonRes(res, 409, { ok: false, error: 'update_in_flight' });
3924
+ return jsonRes(res, 500, { ok: false, error: 'install_failed', detail: e instanceof Error ? e.message : String(e) });
3925
+ }
3926
+ finally {
3927
+ updateInFlight = false;
3928
+ }
3929
+ if (blockedByRestart)
3930
+ return jsonRes(res, 409, { ok: false, error: 'restart_in_flight' });
3931
+ return jsonRes(res, 200, {
3932
+ ok: true,
3933
+ oldVersion,
3934
+ newVersion,
3935
+ // The swapped binary is on disk but THIS process still runs (and reports)
3936
+ // the old baked version, so `changed` cannot be derived by re-reading —
3937
+ // it is the version comparison that decided to update at all.
3938
+ changed: newVersion !== oldVersion,
3939
+ restartRequired: true,
3940
+ manager: 'binary',
3941
+ });
3942
+ }
3863
3943
  let installPlan;
3864
3944
  try {
3865
- const packageRoot = lastSuccessfulUpdatePlan?.activePackageRoot ?? botmuxInstallRoot();
3945
+ // ⚠️ NOT `botmuxInstallRoot()`: for a compiled binary that is "/" and the
3946
+ // resolve below throws, which is the very defect this PR fixes. The
3947
+ // strategy resolved above already carries the right root (the sibling main
3948
+ // package for an npm/pnpm/Bun subpackage; the running install root under
3949
+ // Node). `lastSuccessfulUpdatePlan` still wins so a pnpm update keeps using
3950
+ // the stable symlink it resolved last time.
3951
+ const packageRoot = lastSuccessfulUpdatePlan?.activePackageRoot
3952
+ ?? (runStrategy.kind === 'package-manager' ? runStrategy.packageRoot : botmuxInstallRoot());
3866
3953
  installPlan = resolveGlobalInstallPlan(packageRoot);
3867
3954
  }
3868
3955
  catch (error) {
@@ -3910,7 +3997,11 @@ const server = createServer(async (req, res) => {
3910
3997
  }
3911
3998
  if (blockedByRestart)
3912
3999
  return jsonRes(res, 409, { ok: false, error: 'restart_in_flight' });
3913
- const newVersion = botmuxVersionAt(installPlan.activePackageRoot);
4000
+ // Read the DISK, not `botmuxVersionAt`: for a compiled binary the baked
4001
+ // version takes priority and would report this process's OLD version even
4002
+ // though npm just rewrote package.json (measured) — making `changed` always
4003
+ // false and the "restart to apply" prompt never appear.
4004
+ const newVersion = diskVersionAt(installPlan.activePackageRoot);
3914
4005
  lastSuccessfulUpdatePlan = installPlan;
3915
4006
  return jsonRes(res, 200, {
3916
4007
  ok: true,
@@ -3946,9 +4037,22 @@ const server = createServer(async (req, res) => {
3946
4037
  if (!rollback.versions.some(entry => entry.version === targetVersion)) {
3947
4038
  return jsonRes(res, 400, { ok: false, error: 'not_rollback_target' });
3948
4039
  }
4040
+ // Rollback only knows how to drive a package manager. Resolve the strategy
4041
+ // first so a compiled binary uses its MAPPED root: on a fresh process there
4042
+ // is no `lastSuccessfulUpdatePlan` yet and `botmuxInstallRoot()` is "/", which
4043
+ // made the very first rollback throw `unsupported_install_method` even though
4044
+ // /api/update/status had just reported `rollbackSupported: true`.
4045
+ const rollbackStrategy = currentUpdateStrategy(botmuxInstallRoot());
4046
+ if (rollbackStrategy.kind !== 'package-manager') {
4047
+ return jsonRes(res, 400, {
4048
+ ok: false,
4049
+ error: 'unsupported_install_method',
4050
+ manager: rollbackStrategy.kind === 'self-replace' ? 'binary' : 'unknown',
4051
+ });
4052
+ }
3949
4053
  let installPlan;
3950
4054
  try {
3951
- const packageRoot = lastSuccessfulUpdatePlan?.activePackageRoot ?? botmuxInstallRoot();
4055
+ const packageRoot = lastSuccessfulUpdatePlan?.activePackageRoot ?? rollbackStrategy.packageRoot;
3952
4056
  installPlan = withGlobalInstallRegistry(resolveGlobalInstallPlan(packageRoot, process.platform, `botmux@${targetVersion}`));
3953
4057
  }
3954
4058
  catch (error) {
@@ -3987,7 +4091,10 @@ const server = createServer(async (req, res) => {
3987
4091
  return;
3988
4092
  }
3989
4093
  await runGlobalInstall(installPlan);
3990
- const newVersion = botmuxVersionAt(installPlan.activePackageRoot);
4094
+ // diskVersionAt, not botmuxVersionAt: the baked version of a compiled
4095
+ // binary would never equal the rollback target, so this verification
4096
+ // would report a spurious `installed_version_mismatch` on every rollback.
4097
+ const newVersion = diskVersionAt(installPlan.activePackageRoot);
3991
4098
  lastSuccessfulUpdatePlan = installPlan;
3992
4099
  if (newVersion !== targetVersion) {
3993
4100
  installedVersionMismatch = newVersion;