botmux 3.14.0 → 3.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/dist/.runtime-build-id +1 -1
  2. package/dist/adapters/backend/tmux-pipe-backend.d.ts +30 -0
  3. package/dist/adapters/backend/tmux-pipe-backend.d.ts.map +1 -1
  4. package/dist/adapters/backend/tmux-pipe-backend.js +60 -0
  5. package/dist/adapters/backend/tmux-pipe-backend.js.map +1 -1
  6. package/dist/adapters/backend/types.d.ts +7 -0
  7. package/dist/adapters/backend/types.d.ts.map +1 -1
  8. package/dist/adapters/backend/types.js.map +1 -1
  9. package/dist/adapters/cli/cursor.d.ts.map +1 -1
  10. package/dist/adapters/cli/cursor.js +13 -1
  11. package/dist/adapters/cli/cursor.js.map +1 -1
  12. package/dist/adapters/cli/dsh.d.ts.map +1 -1
  13. package/dist/adapters/cli/dsh.js +5 -1
  14. package/dist/adapters/cli/dsh.js.map +1 -1
  15. package/dist/adapters/cli/pi.d.ts +14 -1
  16. package/dist/adapters/cli/pi.d.ts.map +1 -1
  17. package/dist/adapters/cli/pi.js +21 -1
  18. package/dist/adapters/cli/pi.js.map +1 -1
  19. package/dist/adapters/cli/shared-hints.d.ts.map +1 -1
  20. package/dist/adapters/cli/shared-hints.js +29 -24
  21. package/dist/adapters/cli/shared-hints.js.map +1 -1
  22. package/dist/adapters/cli/types.d.ts +4 -0
  23. package/dist/adapters/cli/types.d.ts.map +1 -1
  24. package/dist/bot-registry.d.ts +22 -0
  25. package/dist/bot-registry.d.ts.map +1 -1
  26. package/dist/bot-registry.js +24 -0
  27. package/dist/bot-registry.js.map +1 -1
  28. package/dist/cli.d.ts.map +1 -1
  29. package/dist/cli.js +8 -3
  30. package/dist/cli.js.map +1 -1
  31. package/dist/core/command-discovery.d.ts.map +1 -1
  32. package/dist/core/command-discovery.js +4 -1
  33. package/dist/core/command-discovery.js.map +1 -1
  34. package/dist/core/dashboard-ipc-server.d.ts.map +1 -1
  35. package/dist/core/dashboard-ipc-server.js +42 -1
  36. package/dist/core/dashboard-ipc-server.js.map +1 -1
  37. package/dist/core/skills/frontmatter.d.ts.map +1 -1
  38. package/dist/core/skills/frontmatter.js +6 -1
  39. package/dist/core/skills/frontmatter.js.map +1 -1
  40. package/dist/core/worker-pool.d.ts.map +1 -1
  41. package/dist/core/worker-pool.js +21 -8
  42. package/dist/core/worker-pool.js.map +1 -1
  43. package/dist/daemon.d.ts.map +1 -1
  44. package/dist/daemon.js +4 -10
  45. package/dist/daemon.js.map +1 -1
  46. package/dist/dashboard/bot-payload.d.ts +4 -0
  47. package/dist/dashboard/bot-payload.d.ts.map +1 -1
  48. package/dist/dashboard/bot-payload.js +1 -0
  49. package/dist/dashboard/bot-payload.js.map +1 -1
  50. package/dist/dashboard/web/bot-defaults-page.d.ts +7 -0
  51. package/dist/dashboard/web/bot-defaults-page.d.ts.map +1 -1
  52. package/dist/dashboard/web/bot-defaults-page.js +96 -1
  53. package/dist/dashboard/web/bot-defaults-page.js.map +1 -1
  54. package/dist/dashboard/web/bot-defaults.d.ts +2 -0
  55. package/dist/dashboard/web/bot-defaults.d.ts.map +1 -1
  56. package/dist/dashboard/web/bot-defaults.js.map +1 -1
  57. package/dist/dashboard/web/i18n.d.ts.map +1 -1
  58. package/dist/dashboard/web/i18n.js +8 -0
  59. package/dist/dashboard/web/i18n.js.map +1 -1
  60. package/dist/dashboard/web/skills-page.d.ts.map +1 -1
  61. package/dist/dashboard/web/skills-page.js +4 -2
  62. package/dist/dashboard/web/skills-page.js.map +1 -1
  63. package/dist/dashboard-web/app.js +1 -1
  64. package/dist/dashboard-web/chunks/bot-defaults-page-65SMZ4QY.js +10 -0
  65. package/dist/dashboard-web/chunks/{chunk-2WQDS65D.js → chunk-IKN6WURK.js} +1 -1
  66. package/dist/dashboard-web/chunks/{chunk-Q2MT4VWH.js → chunk-VMWNR3SV.js} +4 -4
  67. package/dist/dashboard-web/chunks/{chunk-6O7KXFD2.js → chunk-Z7B3E3US.js} +1 -1
  68. package/dist/dashboard-web/chunks/{chunk-U3ZFSO7E.js → chunk-Z7DO42GJ.js} +1 -1
  69. package/dist/dashboard-web/chunks/{connectors-page-2KZO5KSJ.js → connectors-page-CPH6VVFY.js} +1 -1
  70. package/dist/dashboard-web/chunks/{feedback-page-CLVTOLLO.js → feedback-page-J2FKQ3LK.js} +1 -1
  71. package/dist/dashboard-web/chunks/{groups-page-HLASRTSY.js → groups-page-VDOOLS4M.js} +1 -1
  72. package/dist/dashboard-web/chunks/{insights-page-4RPU2CRU.js → insights-page-A2LWTKJD.js} +1 -1
  73. package/dist/dashboard-web/chunks/{monitor-room-OTKQ2CXK.js → monitor-room-2YR752E3.js} +1 -1
  74. package/dist/dashboard-web/chunks/{monitoring-page-IJPUB6JT.js → monitoring-page-BGYSKZGM.js} +1 -1
  75. package/dist/dashboard-web/chunks/{office-page-QSR3J44Y.js → office-page-ZZHTEAE4.js} +1 -1
  76. package/dist/dashboard-web/chunks/{overview-page-6OK63V4V.js → overview-page-7NYPKQSB.js} +1 -1
  77. package/dist/dashboard-web/chunks/{roles-page-6NWJMOB5.js → roles-page-YUC4YLJG.js} +1 -1
  78. package/dist/dashboard-web/chunks/{schedules-page-6I3LNXD4.js → schedules-page-2L2NKTDJ.js} +1 -1
  79. package/dist/dashboard-web/chunks/{sessions-page-B2TXGJDO.js → sessions-page-DYZZMKFL.js} +1 -1
  80. package/dist/dashboard-web/chunks/{settings-page-6KJADSC6.js → settings-page-LIULUSMH.js} +1 -1
  81. package/dist/dashboard-web/chunks/{skills-page-M2Q6L5CB.js → skills-page-DQPBBI3T.js} +2 -2
  82. package/dist/dashboard-web/chunks/{team-federation-page-7I7FDE3B.js → team-federation-page-LQKLDV4K.js} +1 -1
  83. package/dist/dashboard-web/chunks/{v3-page-HQXRL65L.js → v3-page-RVKQIMAP.js} +1 -1
  84. package/dist/dashboard-web/chunks/{whiteboards-page-LQKC4TAZ.js → whiteboards-page-S5K55HRZ.js} +1 -1
  85. package/dist/dashboard.js +11 -1
  86. package/dist/dashboard.js.map +1 -1
  87. package/dist/dsh-runner.js +8 -1
  88. package/dist/dsh-runner.js.map +1 -1
  89. package/dist/i18n/en.d.ts.map +1 -1
  90. package/dist/i18n/en.js +15 -26
  91. package/dist/i18n/en.js.map +1 -1
  92. package/dist/i18n/zh.d.ts.map +1 -1
  93. package/dist/i18n/zh.js +15 -26
  94. package/dist/i18n/zh.js.map +1 -1
  95. package/dist/im/lark/event-dispatcher.d.ts.map +1 -1
  96. package/dist/im/lark/event-dispatcher.js +5 -19
  97. package/dist/im/lark/event-dispatcher.js.map +1 -1
  98. package/dist/services/bridge-fallback-gate.d.ts +15 -7
  99. package/dist/services/bridge-fallback-gate.d.ts.map +1 -1
  100. package/dist/services/bridge-fallback-gate.js +43 -16
  101. package/dist/services/bridge-fallback-gate.js.map +1 -1
  102. package/dist/services/peer-cross-ref-store.d.ts +8 -0
  103. package/dist/services/peer-cross-ref-store.d.ts.map +1 -0
  104. package/dist/services/peer-cross-ref-store.js +95 -0
  105. package/dist/services/peer-cross-ref-store.js.map +1 -0
  106. package/dist/services/pi-transcript.d.ts.map +1 -1
  107. package/dist/services/pi-transcript.js +10 -6
  108. package/dist/services/pi-transcript.js.map +1 -1
  109. package/dist/services/structured-bridge-clis.d.ts +13 -4
  110. package/dist/services/structured-bridge-clis.d.ts.map +1 -1
  111. package/dist/services/structured-bridge-clis.js +13 -3
  112. package/dist/services/structured-bridge-clis.js.map +1 -1
  113. package/dist/types.d.ts +1 -0
  114. package/dist/types.d.ts.map +1 -1
  115. package/dist/utils/bot-routing.d.ts +1 -1
  116. package/dist/utils/bot-routing.d.ts.map +1 -1
  117. package/dist/utils/bot-routing.js.map +1 -1
  118. package/dist/worker.js +233 -11
  119. package/dist/worker.js.map +1 -1
  120. package/package.json +5 -1
  121. package/dist/dashboard-web/chunks/bot-defaults-page-4RENHE7J.js +0 -10
@@ -1 +1 @@
1
- import{a as gt,b as vt}from"./chunks/chunk-U3ZFSO7E.js";import{b as Ce,d as mt,e as ft,g as bt}from"./chunks/chunk-AGCPF6MT.js";import{a as lt}from"./chunks/chunk-BD3PZGH2.js";import{a as me,b as pt,c as ht}from"./chunks/chunk-6O7KXFD2.js";import{i as dt,j as ut}from"./chunks/chunk-5CJMHTT4.js";import{a as ue,b as nt}from"./chunks/chunk-G5XGBCM6.js";import{B as at,D as st,G as it,H as he,c as pe,r as y,s,t as rt,u as ot}from"./chunks/chunk-Q2MT4VWH.js";import{a as hn,b as mn,c as fn,d as ct}from"./chunks/chunk-5THX4DI2.js";import{c as Y}from"./chunks/chunk-7SZRL6FY.js";var Xt=Y(mn(),1),Yt=Y(fn(),1),c=Y(hn(),1);var De="botmux:close-theme-menu",bn={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"/>'},wt=[{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"}]}],yt=wt.flatMap(e=>e.options),M=!1,Z=null,Q=null,gn=70,vn=120;function Oe(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">${bn[e]??""}</svg>`}function yn(e){return e.replace(/[&<>"]/g,n=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[n])}function xt(){let e=document.getElementById("theme-menu"),n=document.getElementById("theme-menu-btn"),r=document.getElementById("theme-menu-pop");if(!e||!n||!r||e.dataset.themeMenuInit==="1")return;e.dataset.themeMenuInit="1",r.innerHTML=wt.map(p=>`<div class="tm-group" data-label-key="${p.labelKey}"></div>`+p.options.map(f=>`<button type="button" class="tm-item" role="option" data-value="${f.value}"><span class="tm-ic">${Oe(f.icon)}</span><span class="tm-label" data-label-key="${f.labelKey}"></span></button>`).join("")).join("");let o=()=>{if(!M)return;let p=n.getBoundingClientRect(),f=12,h=Math.min(Math.max(r.offsetWidth||216,216),Math.max(0,window.innerWidth-f*2)),P=f+h/2,g=window.innerWidth-f-h/2,w=p.left+p.width/2,R=Math.min(Math.max(w,P),Math.max(P,g)),U=Math.max(180,window.innerHeight-p.bottom-20);r.style.setProperty("--theme-menu-pop-left",`${Math.round(R)}px`),r.style.setProperty("--theme-menu-pop-top",`${Math.round(p.bottom+8)}px`),r.style.setProperty("--theme-menu-pop-max-height",`${Math.round(U)}px`)},a=p=>{Z!=null&&(window.clearTimeout(Z),Z=null),Q!=null&&(window.clearTimeout(Q),Q=null),M=p,n.setAttribute("aria-expanded",String(M)),document.body.classList.toggle("theme-menu-open",M),M?(r.hidden=!1,o(),window.requestAnimationFrame(()=>e.classList.add("open"))):(e.classList.remove("open"),Q=window.setTimeout(()=>{Q=null,M||(r.hidden=!0)},vn))},i=()=>a(!0),u=()=>{Z==null&&(Z=window.setTimeout(()=>a(!1),gn))},m=p=>{p.pointerType!=="touch"&&i()},d=p=>{p.pointerType!=="touch"&&u()};e.addEventListener("pointerenter",m),e.addEventListener("pointerleave",d),r.addEventListener("pointerenter",m),r.addEventListener("pointerleave",d),n.addEventListener("click",p=>{p.stopPropagation(),a(!M)}),n.addEventListener("focus",()=>{n.matches(":focus-visible")&&i()}),e.addEventListener("focusout",p=>{let f=p.relatedTarget;(!(f instanceof Node)||!e.contains(f))&&u()}),r.addEventListener("click",p=>{let f=p.target.closest(".tm-item");f&&(y.setTheme(f.dataset.value??"system"),a(!1))}),document.addEventListener("click",p=>{M&&!e.contains(p.target)&&a(!1)}),document.addEventListener("pointermove",p=>{if(!M||p.pointerType==="touch")return;let f=p.target;f instanceof Node&&e.contains(f)||u()}),document.addEventListener("keydown",p=>{p.key==="Escape"&&M&&a(!1)}),window.addEventListener("resize",o),window.addEventListener("scroll",o,!0),window.addEventListener(De,()=>{M&&a(!1)}),He()}function He(){let e=document.getElementById("theme-menu-btn");if(!e)return;let n=yt.find(r=>r.value===y.theme)??yt[0];e.innerHTML=`<span class="tm-ic">${Oe("palette")}</span><span class="tm-current">${yn(s(n.labelKey))}</span><span class="tm-chev">${Oe("chevron")}</span>`,document.querySelectorAll("#theme-menu-pop [data-label-key]").forEach(r=>{r.textContent=s(r.dataset.labelKey??"")}),document.querySelectorAll("#theme-menu-pop .tm-item").forEach(r=>{r.classList.toggle("active",r.dataset.value===y.theme)})}function v(e,n,r,o,a=!1){return{id:e,routePrefix:n,rerenderOnUiChange:a,load:async()=>(await r())[o]}}var wn=[{id:"plugins",routePrefix:"#/plugins",rerenderOnUiChange:!1,load:async()=>{let e=await import("./chunks/plugin-page-VEGTCEAS.js");return n=>e.renderPluginPage(n)}},v("workflows","#/workflows",()=>import("./chunks/v3-page-HQXRL65L.js"),"renderV3RunsPage"),v("groups","#/groups",()=>import("./chunks/groups-page-HLASRTSY.js"),"renderGroupsPage"),v("settings","#/settings",()=>import("./chunks/settings-page-6KJADSC6.js"),"renderSettingsPage"),v("bot-defaults","#/bot-defaults",()=>import("./chunks/bot-defaults-page-4RENHE7J.js"),"renderBotDefaultsPage"),v("skills","#/skills",()=>import("./chunks/skills-page-M2Q6L5CB.js"),"renderSkillsPage"),v("connectors-logs","#/connectors/logs",()=>import("./chunks/connectors-page-2KZO5KSJ.js"),"renderConnectorsLogsPage"),v("webhook-logs","#/webhook-logs",()=>import("./chunks/connectors-page-2KZO5KSJ.js"),"renderConnectorsLogsPage"),v("connectors","#/connectors",()=>import("./chunks/connectors-page-2KZO5KSJ.js"),"renderConnectorsPage"),v("team-manage","#/team/manage",()=>import("./chunks/team-federation-page-7I7FDE3B.js"),"renderTeamManagePage"),v("team","#/team",()=>import("./chunks/team-federation-page-7I7FDE3B.js"),"renderTeamFederationPage"),v("roles-profile","#/roles/profile",()=>import("./chunks/roles-page-6NWJMOB5.js"),"renderRoleProfilesPage"),v("roles","#/roles",()=>import("./chunks/roles-page-6NWJMOB5.js"),"renderRolesPage"),v("schedules","#/schedules",()=>import("./chunks/schedules-page-6I3LNXD4.js"),"renderSchedulesPage"),v("whiteboards","#/whiteboards",()=>import("./chunks/whiteboards-page-LQKC4TAZ.js"),"renderWhiteboardsPage"),v("monitoring","#/monitoring",()=>import("./chunks/monitoring-page-IJPUB6JT.js"),"renderMonitoringPage"),v("sessions","#/sessions",()=>import("./chunks/sessions-page-B2TXGJDO.js"),"renderSessionsPage"),v("monitor-room","#/monitor-room",()=>import("./chunks/monitor-room-OTKQ2CXK.js"),"renderMonitorRoomPage",!0),v("office","#/office",()=>import("./chunks/office-page-QSR3J44Y.js"),"renderOfficePage"),v("insights","#/insights",()=>import("./chunks/insights-page-4RPU2CRU.js"),"renderInsightsPage"),v("feedback","#/feedback",()=>import("./chunks/feedback-page-CLVTOLLO.js"),"renderFeedbackPage")];function kt(e){return wn.find(n=>n.exact?e===n.routePrefix:e.startsWith(n.routePrefix))}async function Et(){let e=await import("./chunks/overview-page-6OK63V4V.js");return n=>e.renderOverviewPage(n)}function Mt(){return{seq:0,pageDispose:null,rerenderOnUiChange:!0}}function Tt(e){let n=++e.seq;return e.pageDispose&&(e.pageDispose(),e.pageDispose=null),n}function Rt(e,n){return n===e.seq}async function Lt(e,n,r,o,a={}){let i=await o();if(!Rt(e,n))return!1;let u=i(r);return Rt(e,n)?(e.pageDispose=typeof u=="function"?u:null,e.rerenderOnUiChange=a.rerenderOnUiChange??!0,!0):(typeof u=="function"&&u(),!1)}var xn="botmux.dashboard.stale-chunk-reload.v1:",kn=/Failed to fetch dynamically imported module|Importing a module script failed|error loading dynamically imported module|dynamically imported module/i,En=/\b(?:https?:\/\/|\/assets\/)\S+?\.js\b/;function Nt(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}function St(e){return kn.test(Nt(e))}function Rn(e,n){let a=Nt(e).match(En)?.[0]||`${n.href}|${n.hash}`;return`${xn}${a.slice(-240)}`}function Mn(e,n){if(!St(e))return!1;let r=Rn(e,n);try{if(n.sessionStorage.getItem(r)==="1")return!1;n.sessionStorage.setItem(r,"1")}catch{return!1}return n.reload(),!0}function Pt(e,n){if(!St(e))return!1;let r;try{r=n.getSessionStorage()}catch{return!1}return Mn(e,{...n,sessionStorage:r})}var Tn=new Set(["auto","scroll","overlay"]),fe=28,S=3,_=6,Ct=!1,It=null,Ot=new WeakMap,C=new Map,Dt=null,Ht=null,Ae=0,Ie=0,ee=null;function Ln(e){return e.closest("dialog[open]")??document.body}function Nn(e){let n=Ot.get(e);if(n?.isConnected)return n;let r=document.createElement("div");return r.className="floating-scrollbar-layer",r.setAttribute("aria-hidden","true"),e.appendChild(r),Ot.set(e,r),r}function Sn(e){return Tn.has(e)}function Be(e,n){let r=getComputedStyle(e),o=n==="y"?r.overflowY:r.overflowX;return Sn(o)?n==="y"?e.scrollHeight-e.clientHeight>1:e.scrollWidth-e.clientWidth>1:!1}function Pn(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 Cn(e){return[e,...Array.from(e.querySelectorAll("*"))].filter(r=>Pn(r)&&(Be(r,"x")||Be(r,"y")))}function be(e){e.hideTimer!==void 0&&window.clearTimeout(e.hideTimer),e.track.remove()}function On(e,n){let r=C.get(e);r||(r={},C.set(e,r));let o=r[n],a=Ln(e),i=Nn(a);if(o?.track.parentElement===i)return o;o&&be(o);let u=document.createElement("div"),m=document.createElement("div");u.className=`floating-scrollbar floating-scrollbar-${n}`,m.className="floating-scrollbar-thumb",u.appendChild(m),i.appendChild(u);let d={target:e,axis:n,track:u,thumb:m,hideTimer:void 0};return r[n]=d,d}function Ue(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 Dn(e){let{target:n,axis:r,track:o,thumb:a}=e,i=n.getBoundingClientRect();if(r==="y"){let P=Math.max(0,i.top+S),g=Math.min(window.innerHeight,i.bottom-S),w=Math.max(0,g-P);if(w<fe||n.scrollHeight<=n.clientHeight){o.hidden=!0;return}let R=Math.max(fe,Math.round(w*n.clientHeight/n.scrollHeight)),U=Math.max(1,n.scrollHeight-n.clientHeight),V=Math.round((w-R)*n.scrollTop/U);o.hidden=!1,o.style.left=`${Math.min(window.innerWidth-_-S,Math.max(S,i.right-_-S))}px`,o.style.top=`${P}px`,o.style.width=`${_}px`,o.style.height=`${w}px`,a.style.width="100%",a.style.height=`${R}px`,a.style.transform=`translate3d(0, ${V}px, 0)`;return}let u=Math.max(0,i.left+S),m=Math.min(window.innerWidth,i.right-S),d=Math.max(0,m-u);if(d<fe||n.scrollWidth<=n.clientWidth){o.hidden=!0;return}let p=Math.max(fe,Math.round(d*n.clientWidth/n.scrollWidth)),f=Math.max(1,n.scrollWidth-n.clientWidth),h=Math.round((d-p)*n.scrollLeft/f);o.hidden=!1,o.style.left=`${u}px`,o.style.top=`${Math.min(window.innerHeight-_-S,Math.max(S,i.bottom-_-S))}px`,o.style.width=`${d}px`,o.style.height=`${_}px`,a.style.width=`${p}px`,a.style.height="100%",a.style.transform=`translate3d(${h}px, 0, 0)`}function F(){Ae||(Ae=window.requestAnimationFrame(()=>{Ae=0,An()}))}function Hn(){Ie||(Ie=window.setTimeout(()=>{Ie=0,F()},120))}function An(){let e=It;if(!e)return;let n=new Set(Cn(e));for(let[r,o]of C)n.has(r)||(o.x&&be(o.x),o.y&&be(o.y),C.delete(r));for(let r of n){let o=r===ee;for(let a of["x","y"]){let i=C.get(r);if(!Be(r,a)){let m=i?.[a];m&&(be(m),delete i?.[a]);continue}let u=On(r,a);Dn(u),o&&Ue(u,!0)}}}function In(e){if(!(e instanceof HTMLElement))return;let n=C.get(e);if(n)for(let r of Object.values(n))r&&(r.track.classList.add("is-active"),Ue(r))}function Bn(e){for(let n=e;n;n=n.parentElement)if(n instanceof HTMLElement&&C.has(n))return n;return null}function At(e){if(ee===e)return;let n=ee?C.get(ee):void 0;if(ee=e,n)for(let o of Object.values(n))o?.track.classList.remove("is-visible");let r=e?C.get(e):void 0;if(r)for(let o of Object.values(r))o&&Ue(o,!0)}function Bt(e){Ct||(Ct=!0,It=e,document.documentElement.classList.add("floating-scrollbars-on"),Dt=typeof ResizeObserver>"u"?null:new ResizeObserver(F),Dt?.observe(e),Ht=new MutationObserver(n=>{for(let r of n){let o=r.target;if(!(o instanceof Element&&o.closest(".floating-scrollbar-layer"))){Hn();return}}}),Ht.observe(e,{attributes:!0,attributeFilter:["class","style","hidden","open"],childList:!0,subtree:!0}),document.addEventListener("scroll",n=>{In(n.target),F()},!0),window.addEventListener("resize",F),window.addEventListener("hashchange",F),document.addEventListener("pointermove",n=>{At(Bn(document.elementFromPoint(n.clientX,n.clientY)))}),document.addEventListener("pointerleave",()=>At(null)),F())}var Ut=!1,K=null,ge=null,W=null;function _t(){if(K)return K;let e=document.createElement("div");return e.className="icon-tip",e.setAttribute("role","tooltip"),e.style.display="none",document.body.appendChild(e),K=e,e}function Un(e){let n=_t(),r=dt(e,document.body);return n.parentNode!==r&&r.appendChild(n),n}function $n(e){let n=_t(),r=e.getBoundingClientRect(),o=n.offsetWidth,a=n.offsetHeight,i=8,u=r.top<a+i+4,m=r.left+r.width/2-o/2;m=Math.min(Math.max(m,6),window.innerWidth-o-6);let d=u?r.bottom+i:r.top-a-i;n.style.left=`${Math.round(m)}px`,n.style.top=`${Math.round(d)}px`,n.dataset.placement=u?"bottom":"top"}function te(){W&&(clearTimeout(W),W=null),ge=null,K&&(K.style.display="none",K.classList.remove("show"))}function $t(e){let n=e.getAttribute("data-tip");if(!n)return;ge=e;let r=Un(e);r.textContent=n,r.style.display="block",r.classList.remove("show"),$n(e),requestAnimationFrame(()=>{ge===e&&r.classList.add("show")})}function $e(e){return e instanceof Element?e.closest("[data-tip]"):null}function Ft(){Ut||typeof document>"u"||(Ut=!0,document.addEventListener("pointerover",e=>{let n=$e(e.target);!n||n===ge||(W&&clearTimeout(W),W=setTimeout(()=>$t(n),120))}),document.addEventListener("pointerout",e=>{let n=$e(e.target);if(!n)return;let r=e.relatedTarget instanceof Element?e.relatedTarget:null;r&&(r===n||n.contains(r))||te()}),document.addEventListener("focusin",e=>{let n=$e(e.target);n&&$t(n)}),document.addEventListener("focusout",te),document.addEventListener("click",te,!0),window.addEventListener("scroll",te,!0),window.addEventListener("resize",te))}async function Kt(e){let n=await e.json().catch(()=>null);return n&&typeof n=="object"?n:{}}function Wt(e,n){let r=n.detail??n.error;return new Error(typeof r=="string"?r:`HTTP ${e.status}`)}async function _e(e,n=()=>{},r){n("updating");let o=await e(r?"/api/update/rollback":"/api/update/run",r?{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:r})}:{method:"POST"}),a=await Kt(o);if(!o.ok||a.ok===!1)throw Wt(o,a);if(a.ok!==!0||typeof a.oldVersion!="string"||typeof a.newVersion!="string"||typeof a.changed!="boolean")throw new Error("Invalid update response");if(r&&(a.newVersion!==r||a.changed!==!0))throw new Error("Invalid rollback response");let i={oldVersion:a.oldVersion,newVersion:a.newVersion,changed:a.changed,restarted:!1};if(n("restarting"),r)return{...i,restarted:!0};let u=await e("/api/update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({update:{oldVersion:i.oldVersion,newVersion:i.newVersion}})}),m=await Kt(u);if(m.error==="bootstrap_shutdown_protocol_required"){let p=Array.isArray(m.unsafeDaemons)?m.unsafeDaemons.filter(f=>typeof f=="string"):[];return{...i,restarted:!1,bootstrapRequired:!0,unsafeDaemons:p}}if(!u.ok||m.ok===!1)return{...i,restarted:!1,restartError:Wt(u,m).message};if(m.ok!==!0)throw new Error("Invalid restart response");return m.alreadyScheduled===!0?{...i,restarted:!0,alreadyScheduled:!0}:{...i,restarted:!0}}function Fe(e,n){if(e)try{let r=new URL(e);if(!["http:","https:"].includes(r.protocol)||r.username||r.password)return;let o=n.startsWith("#/")&&n.length<=4096&&!/[\u0000-\u001f\u007f]/.test(n)?n:"#/";return r.searchParams.set("next",`/${o}`),r.toString()}catch{return}}var t=Y(ct(),1),_n=["roles","role-profiles","bot-defaults","skills","plugins","team","connectors","insights","feedback","whiteboards"],zt=[{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:"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:"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"})]})}],re=[],A=!0,qe=!1,Zt=location.hash||"#/",z=null,oe=!1,ae=null,ye=null,Qt=null,we=null,en=null,H=Mt(),tn="botmux.ownerAvatar.v1",Fn=new Set(["working","analyzing","active","starting"]),je="botmux:auth-expired",Ge;function ne(e){return(0,t.jsx)("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e})}function Vt(e){return e.labelKey?s(e.labelKey):e.label??""}function Kn(e,n){let r=n||"#/";return e.id==="plugins"&&re.some(o=>o.href===r||r.startsWith(`${o.href}?`)||r.startsWith(`${o.href}/`))?!1:e.id==="sessions"&&(r==="#/monitor-room"||r.startsWith("#/monitor-room?")||r.startsWith("#/monitor-room/"))||e.id==="connectors"&&(r==="#/webhook-logs"||r.startsWith("#/webhook-logs?")||r.startsWith("#/webhook-logs/"))?!0:e.href===r||e.href!=="#/"&&(r.startsWith(`${e.href}?`)||r.startsWith(`${e.href}/`))}function Wn(){let e=ft()?zt.filter(r=>r.id!=="workflows"):zt;if(re.length===0)return e;let n=e.findIndex(r=>r.id==="plugins");return n<0?[...e,...re]:[...e.slice(0,n+1),...re,...e.slice(n+1)]}function zn(e){let n=[];return Kn(e,Zt)&&n.push("active"),e.id==="settings"&&oe&&n.push("nav-has-update"),n.length?n.join(" "):void 0}function nn(){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 qt(){let e=nn();return!e||e===y.locale?!1:(y.setLocale(e),!0)}function Vn(){let e=location.hash.indexOf("?");return e<0?null:{path:location.hash.slice(0,e)||"#/",params:new URLSearchParams(location.hash.slice(e+1))}}function qn(){let e=Vn(),n=e?.params.get("open");if(!e||!n||n!=="bot-onboarding"&&n!=="create-session")return!1;e.params.delete("open");let r=e.params.toString();return history.replaceState(null,"",r?`${e.path}?${r}`:e.path),n==="bot-onboarding"?window.dispatchEvent(new Event(me)):Ce(),!0}function jt(){let e=ae?`v${ae}`:"";return ye==="runtime"?s("update.navRuntimeBadgeTitle",{version:e}):s("update.navBadgeTitle",{version:e})}function jn(e){we=e}function Ke(){if(we)return we;let e=document.getElementById("root");if(!e)throw new Error("dashboard root is not mounted");return we=e,e}function Gn(){return(0,c.useEffect)(()=>{xt()},[]),(0,c.useEffect)(()=>{He()}),(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 Jn(){let e=[...ue.sessions.values()],n=e.filter(d=>d.status!=="closed"),r=n.map(d=>({s:d,reason:it(d)})).filter(d=>!!d.reason).sort((d,p)=>he(d.s)-he(p.s)),o=new Set(r.map(d=>String(d.s.sessionId??""))),a=n.filter(d=>Fn.has(String(d.status))&&!o.has(String(d.sessionId??""))).length,i=r[0]??null,u=vt(e).filter(d=>d.online||d.active.length>0).length,m=Math.max(0,n.length-r.length-a);return{working:a,attention:r.length,idle:m,onlineBots:u,attentionNotice:i?{count:r.length,time:ot(he(i.s)),bot:st(i.s),reason:i.reason}:null}}function ve(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 Xn(e){let{attention:n,idle:r,working:o}=e.summary,a=o+n+r,i=a===0?"conic-gradient(var(--border) 0 360deg)":(()=>{let u=o/a*360,m=u+n/a*360;return`conic-gradient(var(--accent) 0 ${u}deg, var(--warning) ${u}deg ${m}deg, var(--success) ${m}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:i}}),(0,t.jsxs)("div",{className:"topbar-status-donut-center",children:[(0,t.jsx)("b",{children:a}),(0,t.jsx)("span",{children:s("overview.openSessions")})]})]})}function We(){window.dispatchEvent(new Event(De))}function Yn(e){let{autoOpen:n=!1,summary:r}=e,[o,a]=(0,c.useState)(!1),[i,u]=(0,c.useState)(!1),[m,d]=(0,c.useState)(!1),p=(0,c.useRef)(null),f=n&&!i,h=o||f;return(0,c.useEffect)(()=>{n||u(!1)},[n]),(0,c.useEffect)(()=>{if(!h)return;let g=w=>{let R=w.target;R instanceof Node&&p.current?.contains(R)||(a(!1),u(!0))};return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[h]),(0,t.jsxs)("div",{ref:p,className:`topbar-status-menu${f?" topbar-status-auto-open":""}${o?" is-open":""}${m?" suppress-hover":""}`,onPointerEnter:We,onPointerLeave:()=>d(!1),onFocusCapture:We,onBlur:g=>{let w=g.relatedTarget;(!(w instanceof Node)||!g.currentTarget.contains(w))&&a(!1)},onKeyDown:g=>{g.key==="Escape"&&(a(!1),u(!0),d(!0),g.currentTarget.querySelector("#status")?.focus())},children:[(0,t.jsx)("button",{type:"button",id:"status",className:"connection-status","aria-haspopup":"true","aria-expanded":h,onClick:()=>{if(We(),h){a(!1),u(!0),d(!0);return}d(!1),a(!0)},children:s("overview.sessionOverview")}),(0,t.jsxs)("div",{className:"topbar-status-pop",children:[r.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:r.attentionNotice.count})}),(0,t.jsx)("small",{children:s("strip.longestCompact",{time:r.attentionNotice.time,bot:r.attentionNotice.bot,reason:r.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)(ve,{label:s("overview.workingSessions"),value:r.working}),(0,t.jsx)(ve,{label:s("overview.idleSessions"),value:r.idle}),(0,t.jsx)(ve,{label:s("overview.attention"),value:r.attention,hot:r.attention>0}),(0,t.jsx)(ve,{label:s("overview.onlineBots"),value:r.onlineBots})]}),(0,t.jsx)(Xn,{summary:r})]})]})}function Zn(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:r=>{r.target===r.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 Qn(e){let n=new Date(e);if(Number.isNaN(n.getTime()))return e.slice(0,10);try{return new Intl.DateTimeFormat(y.locale==="zh"?"zh-CN":"en-US",{year:"numeric",month:"numeric",day:"numeric"}).format(n)}catch{return e.slice(0,10)}}async function Gt(){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 er(e){let{status:n}=e,[r,o]=(0,c.useState)(!1),[a,i]=(0,c.useState)("idle"),[u,m]=(0,c.useState)(0),[d,p]=(0,c.useState)(!1),[f,h]=(0,c.useState)(!1),[P,g]=(0,c.useState)(""),[w,R]=(0,c.useState)(!1),[U,V]=(0,c.useState)(!1),[T,xe]=(0,c.useState)(!1),[q,ie]=(0,c.useState)(!1),[j,Xe]=(0,c.useState)([]),[x,ke]=(0,c.useState)(null),[O,Ee]=(0,c.useState)(null),L=(0,c.useRef)(!1),G=(0,c.useRef)(null),le=(0,c.useRef)(null),Ye=(0,c.useRef)(null),Re=(0,c.useRef)(null),Me=(0,c.useRef)(null),[J,Ze]=(0,c.useState)(null),rn=()=>{G.current!==null&&(window.clearTimeout(G.current),G.current=null)},Te=()=>{le.current!==null&&(window.clearInterval(le.current),le.current=null)};if((0,c.useEffect)(()=>{L.current=!1,i("idle"),m(0),p(!1),h(!1),g(""),R(!1),V(!1),xe(!1),ie(!1),Xe([]),ke(null),Ee(null)},[n?.current,n?.latest]),(0,c.useEffect)(()=>{if(Te(),a==="idle"||a==="error"){m(0);return}let l=a==="updating"?50:95;return a==="restarting"&&m(b=>Math.max(b,50)),le.current=window.setInterval(()=>{m(b=>b>=l?l:b+Math.max(.5,(l-b)*.08))},400),()=>Te()},[a]),(0,c.useEffect)(()=>{n&&h(n.versionLookupOk===!1)},[n]),(0,c.useEffect)(()=>{r||R(!1)},[r]),(0,c.useEffect)(()=>{if(!r||!J)return;let l=window.requestAnimationFrame(()=>{Me.current?.querySelector('button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')?.focus()});return()=>window.cancelAnimationFrame(l)},[r,J!==null]),(0,c.useEffect)(()=>{if(!r){Ze(null);return}let l=()=>{let b=Re.current;if(!b)return;let k=b.getBoundingClientRect(),N=Math.min(340,Math.max(0,window.innerWidth-32)),B=Math.max(16,Math.min(k.left,window.innerWidth-N-16));Ze({top:k.bottom+8,left:B})};return l(),window.addEventListener("resize",l),document.addEventListener("scroll",l,!0),()=>{window.removeEventListener("resize",l),document.removeEventListener("scroll",l,!0)}},[r]),(0,c.useEffect)(()=>()=>{rn(),Te()},[]),(0,c.useEffect)(()=>{if(!r)return;let l=k=>{let N=k.target;Ye.current?.contains(N)||Me.current?.contains(N)||o(!1)},b=k=>{k.key==="Escape"&&(o(!1),Re.current?.focus())};return document.addEventListener("pointerdown",l),document.addEventListener("keydown",b),()=>{document.removeEventListener("pointerdown",l),document.removeEventListener("keydown",b)}},[r]),!n)return null;let I=n.behind&&!!n.latest,Le=!n.latest,Ne=I&&n.updateSupported&&!n.localDevInstall&&n.node.ok,Qe=n.updateSupported&&!n.localDevInstall&&n.node.ok,D=a==="updating"||a==="restarting",et=2*Math.PI*20,on=et*(1-Math.max(2,Math.round(u))/100),an=n.updateCommand??"botmux update",Se=`v${n.current}`,sn=n.latest?`v${n.latest}`:"",ln=n.localDevInstall?s("update.localDev"):n.updateSupported?n.node.ok?"":s("update.nodeWarn",{version:n.node.version,required:n.node.required}):s("update.unsupportedInstall"),tt=l=>{let b=Date.now(),k=async()=>{try{let N=await fetch("/__selfcheck",{cache:"no-store"}),B=await N.text();if(N.ok&&B&&B!==l){location.reload();return}}catch{}if(Date.now()-b>9e4){L.current=!1,i("error"),g(s("update.restartSlow"));return}G.current=window.setTimeout(()=>{k()},2e3)};G.current=window.setTimeout(()=>{k()},3e3)},cn=async()=>{if(I){if(!Ne){o(!1),location.hash="#/settings";return}if(!L.current){L.current=!0,Ee(null),h(!1),g("");try{let l=await Gt(),b=await _e(fetch,i);if(b.bootstrapRequired){L.current=!1,i("error"),g(s("update.bootstrapRequired"));return}if(!b.restarted){L.current=!1,i("error"),g(s("update.restartFailed",{detail:b.restartError??"unknown"}));return}tt(l)}catch(l){L.current=!1,i("error"),g(l instanceof Error?l.message:String(l))}}}},Pe=async(l=!1)=>{if(T)return!q;xe(!0),ie(!1);try{let b=await fetch(`/api/update/versions${l?"?refresh=1":""}`,{cache:"no-store"}),k=await b.json().catch(()=>null);if(!k||!Array.isArray(k.versions))throw new Error("Invalid rollback versions response");let N=k.versions.filter($=>{if(!$||typeof $!="object")return!1;let X=$;return typeof X.version=="string"&&(typeof X.publishedAt=="string"||X.publishedAt===null)}).slice(0,3);Xe(N),ke($=>N.some(X=>X.version===$)?$:null),V(!0);let B=b.ok&&k.ok===!0;return ie(!B),B}catch{return V(!0),ie(!0),!1}finally{xe(!1)}},dn=async()=>{if(!(!x||!Qe||T||L.current)){L.current=!0,Ee(x),h(!1),g("");try{let l=await Gt();await _e(fetch,i,x),tt(l)}catch(l){L.current=!1,i("error"),g(l instanceof Error?l.message:String(l))}}},un=async()=>{if(!(d||D)){p(!0),h(!1);try{let l=await e.onRefresh();w&&await Pe(!0),h(!l)}finally{p(!1)}}},ce=a==="updating"?O?s("update.rollbackInstalling",{version:O}):s("update.updating",{command:an}):a==="restarting"?O?s("update.rollbackRestarting",{version:O}):s("update.restarting"):a==="error"?O?s("update.rollbackFailed",{detail:P}):s("update.updateFailed",{detail:P}):f?s("update.topbarRefreshFailed"):I?Ne?s("update.versionUpgradePrompt",{version:sn}):ln:n.latest?s("update.upToDate"):s("update.checkUnavailable"),pn=Ne?a==="error"?s("update.topbarRetry"):a==="idle"?s("update.topbarAction"):s("update.topbarWorking"):s("update.topbarReview"),de=a==="error"||f&&Le?{className:"is-error",symbol:"!"}:I?{className:"has-update",symbol:"\u2191"}:Le?{className:"is-unknown",symbol:"?"}:{className:"is-current",symbol:"\u2713"};return(0,t.jsxs)("div",{ref:Ye,className:`dashboard-version-control${r?" is-open":""}`,children:[(0,t.jsxs)("button",{ref:Re,type:"button",className:`dashboard-version-chip${I?" has-update":""}${Le?" is-unknown":""}${a==="error"?" is-error":""}`,"aria-haspopup":"dialog","aria-expanded":r,"aria-label":`${Se}. ${ce}`,title:ce,onClick:()=>o(l=>!l),children:[(0,t.jsx)("span",{children:Se}),(0,t.jsx)("span",{className:`dashboard-version-state ${de.className}`,"aria-hidden":"true",children:de.symbol})]}),r&&J&&typeof document<"u"?(0,Xt.createPortal)((0,t.jsxs)("section",{ref:Me,className:"dashboard-version-popover",role:"dialog","aria-modal":"false","aria-labelledby":"dashboard-version-title",style:{top:J.top,left:J.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${d?" is-refreshing":""}`,"aria-label":s(d?"update.topbarRefreshing":"update.topbarRefresh"),title:s(d?"update.topbarRefreshing":"update.topbarRefresh"),disabled:d||T||D,onClick:()=>{un()},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:()=>o(!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:Se}),D?(0,t.jsxs)("span",{className:"dashboard-version-ring",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(u),"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:et,strokeDashoffset:on}})]}),(0,t.jsxs)("span",{className:"dvr-pct",children:[Math.round(u),"%"]})]}):(0,t.jsx)("span",{className:de.className,"aria-hidden":"true",children:de.symbol})]}),(0,t.jsx)("p",{className:`dashboard-version-message${a==="error"||f?" is-error":""}`,role:a==="error"||f?"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")})]}),(I||w)&&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(l=>(0,t.jsx)("li",{children:l.binPath},l.binPath))})]}):null,Qe?(0,t.jsxs)("details",{className:"dashboard-version-rollback",open:w,"aria-busy":T,onToggle:l=>{let b=l.currentTarget.open;R(b),b&&!U&&!T&&Pe()},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:[T&&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:T,onClick:()=>{Pe(!0)},children:s("update.rollbackRetry")})]}):null,U&&!T&&!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:D||T||q,children:[(0,t.jsx)("legend",{children:s("update.rollbackHint")}),(0,t.jsx)("div",{className:"dashboard-version-rollback-options",children:j.map(l=>(0,t.jsxs)("label",{className:x===l.version?"is-selected":"",children:[(0,t.jsx)("input",{type:"radio",name:"dashboard-rollback-version",value:l.version,checked:x===l.version,onChange:()=>ke(l.version)}),(0,t.jsxs)("strong",{children:["v",l.version]}),l.publishedAt?(0,t.jsx)("time",{dateTime:l.publishedAt,children:Qn(l.publishedAt)}):null]},l.version))})]}):null,x?(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:x})," ",(0,t.jsx)("a",{href:`https://github.com/deepcoldy/botmux/releases/tag/v${encodeURIComponent(x)}`,target:"_blank",rel:"noopener noreferrer","aria-label":s("update.rollbackReleaseNotesA11y",{version:x}),children:s("update.rollbackReleaseNotes",{version:x})})]})]}):null,j.length>0?(0,t.jsxs)("button",{type:"button",className:"dashboard-version-rollback-action",disabled:!x||T||q||D,"aria-describedby":x?"dashboard-version-rollback-risk":void 0,onClick:()=>{dn()},children:[D&&O?(0,t.jsx)("span",{className:"dashboard-update-spinner","aria-hidden":"true"}):null,x?a==="error"&&O===x?s("update.rollbackRetry"):s("update.rollbackAction",{version:x}):s("update.rollbackSelect")]}):null]})]}):null]}),I&&!w&&!O?(0,t.jsxs)("footer",{className:"dashboard-version-popover-actions",children:[(0,t.jsx)("button",{type:"button",className:"dashboard-version-secondary",onClick:()=>o(!1),children:D?s("update.topbarClose"):s("update.topbarLater")}),(0,t.jsx)("button",{type:"button",className:"dashboard-version-primary",disabled:D,onClick:()=>{cn()},children:pn})]}):null]}),document.body):null]})}function tr(){let e=Jn(),[n,r]=(0,c.useState)(!1),[o,a]=(0,c.useState)(!1),[i,u]=(0,c.useState)(!1),m=(0,c.useRef)(e.attention),d=(0,c.useRef)(null),p=()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)};(0,c.useEffect)(()=>{let h=()=>r(!0);return window.addEventListener(me,h),()=>window.removeEventListener(me,h)},[]),(0,c.useEffect)(()=>{let h=()=>a(!0);return window.addEventListener(je,h),se&&a(!0),()=>window.removeEventListener(je,h)},[]),(0,c.useEffect)(()=>()=>p(),[]),(0,c.useEffect)(()=>{let h=m.current;if(m.current=e.attention,e.attention===0){p(),u(!1);return}h!==0||document.body.classList.contains("theme-menu-open")||(u(!0),p(),d.current=window.setTimeout(()=>{d.current=null,u(!1)},4e3))},[e.attention]);let f=()=>{se=!1,a(!1)};return(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)(er,{status:Qt,onRefresh:()=>Je(!0)})]})}),(0,t.jsxs)("div",{className:"topbar-actions",children:[(0,t.jsx)(Yn,{summary:e,autoOpen:i}),(0,t.jsxs)("div",{className:"topbar-tool-group",children:[(0,t.jsx)("button",{type:"button",className:"topbar-locale-toggle","aria-label":y.locale==="zh"?"Switch to English":"\u5207\u6362\u5230\u4E2D\u6587",title:y.locale==="zh"?"Switch to English":"\u5207\u6362\u5230\u4E2D\u6587",onClick:()=>nr(y.locale==="zh"?"en":"zh"),children:y.locale==="zh"?"CN":"EN"}),(0,t.jsx)(Gn,{}),(0,t.jsxs)("a",{className:"topbar-docs-link",href:"https://bytedance.aiforce.cloud/app/app_4k9smq6rdxher/",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:z?.name,"aria-label":z?.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"})]}))}),z?.avatarUrl?(0,t.jsx)("img",{className:"topbar-owner-img",src:z.avatarUrl,alt:"",decoding:"async",referrerPolicy:"no-referrer",onError:h=>{h.currentTarget.remove()}}):null]})]})]}),(0,t.jsxs)("div",{className:"chrome-body",children:[(0,t.jsxs)("aside",{className:"sidebar",children:[A?(0,t.jsxs)("div",{className:"sidebar-create-actions",children:[(0,t.jsxs)("button",{type:"button",className:"sidebar-create-btn",onClick:()=>Ce(),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:()=>{pt()},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:Wn().filter(h=>A||!h.manage).map(h=>(0,t.jsxs)("a",{href:h.href,"data-route":h.id,className:[zn(h),h.plugin?"sidebar-plugin-item":""].filter(Boolean).join(" ")||void 0,title:h.plugin?Vt(h):void 0,children:[ne(h.icon),(0,t.jsx)("span",{className:"sidebar-nav-label",children:Vt(h)}),h.id==="settings"&&oe?(0,t.jsx)(ut,{className:"nav-update-tip",label:jt(),trigger:(0,t.jsx)("span",{className:"nav-update-dot","aria-hidden":"true"}),preventClick:!1,focusable:!1,children:jt()}):null]},h.id))})]}),(0,t.jsxs)("div",{className:"workspace",children:[(0,t.jsx)("dialog",{id:"create-session-modal",className:"create-session-modal"}),(0,t.jsx)(ht,{open:n,onClose:()=>r(!1)}),(0,t.jsx)("main",{id:"root",ref:jn})]})]})]}),(0,t.jsx)(Zn,{open:o,loginUrl:Fe(Ge,location.hash),onClose:f})]})}function E(){en?.render((0,t.jsx)(tr,{}))}function nr(e){y.setLocale(e),ir(e)}var se=!1;function rr(e){let n=!!Fe(e,location.hash),r=n&&Ge!==e;n&&(Ge=e),se&&r&&E(),!se&&(se=!0,window.dispatchEvent(new Event(je)))}var ze;function or(){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",ze&&window.clearTimeout(ze),ze=window.setTimeout(()=>{e.style.display="none"},4e3)}var ar=window.fetch.bind(window);window.fetch=async function(...n){let r=await ar(...n);if(r.status===401){let o=r.headers.get("x-botmux-login-url")??void 0,a=(n[1]?.method??"GET").toUpperCase();o||(a==="GET"||a==="HEAD")&&!qe?rr(o):or()}return r};async function sr(){try{let e=await fetch("/api/settings");if(e.ok){let n=await e.json();A=!!n.authed,y.authed=A,qe=!!(n.settings&&n.settings.publicReadOnly),y.publicReadOnly=qe;let r=nn()??pe(n.lang);r&&y.setLocale(r)}}catch{}}async function Jt(){try{let e=await fetch("/api/plugins/dashboard");if(!e.ok)return;let n=await e.json();re=(Array.isArray(n?.plugins)?n.plugins:[]).filter(o=>o.pinned===!0&&typeof o.route=="string").map(o=>({id:`plugin:${o.pluginId}:${o.id}`,href:o.route,label:o.displayName||o.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"})]})})),E()}catch{}}async function ir(e){if(A)try{await fetch("/api/settings",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({lang:e})})}catch{}}async function Je(e=!1){if(!A)return!1;try{let n=await fetch(`/api/update/status${e?"?refresh=1":""}`,{cache:"no-store"});if(!n.ok)return!1;let r=await n.json();Qt=r;let o=Array.isArray(r.cliUpdates)?r.cliUpdates.find(a=>a?.updateAvailable===!0&&a?.latest):null;return r.behind===!0&&r.latest?(oe=!0,ye="botmux",ae=String(r.latest)):o?(oe=!0,ye="runtime",ae=String(o.latest)):(oe=!1,ye=null,ae=null),E(),r.versionLookupOk!==!1}catch{return!1}}function lr(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 Ve(){let e=Tt(H),n=location.hash||"#/";Zt=n,E();let r=bt(n);if(r){window.location.replace(r);return}if(!A&&_n.some(o=>n.startsWith("#/"+o))){lr(Ke()),H.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 o=kt(n);await Lt(H,e,Ke(),o?o.load:Et,{rerenderOnUiChange:o?o.rerenderOnUiChange:!1}),e===H.seq&&A&&qn()}catch(o){if(e!==H.seq||Pt(o,{href:window.location.href,hash:n,getSessionStorage:()=>window.sessionStorage,reload:()=>window.location.reload()}))return;Ke().innerHTML=`<section class="page"><div class="empty">Dashboard route failed: ${rt(String(o))}</div></section>`,H.pageDispose=null,H.rerenderOnUiChange=!0}}function cr(){try{let e=JSON.parse(window.localStorage.getItem(tn)??"null");if(e?.avatarUrl)return{avatarUrl:String(e.avatarUrl),name:e.name?String(e.name):void 0}}catch{}return null}function dr(){z=cr(),E(),fetch("/api/owner-profile").then(e=>e.ok?e.json():null).then(e=>{if(!(!e?.ok||!e.avatarUrl)){z={avatarUrl:String(e.avatarUrl),name:e.name?String(e.name):void 0};try{window.localStorage.setItem(tn,JSON.stringify({avatarUrl:e.avatarUrl,name:e.name??""}))}catch{}E()}}).catch(()=>{})}(async()=>{let e=mt(window.location.href);e&&window.history.replaceState(window.history.state,"",e),y.init(),qt();let n=document.getElementById("app-root");if(!n)throw new Error("missing dashboard app root");Bt(n),Ft(),en=(0,Yt.createRoot)(n),E(),y.on(()=>{E(),H.rerenderOnUiChange&&Ve()}),ue.on(()=>{E()}),await sr(),E(),window.addEventListener(lt,()=>{Jt()}),Jt(),Je(),window.setInterval(()=>{document.hidden||Je()},30*6e4),dr();try{await nt()}catch(r){console.error("botmux dashboard bootstrap failed",r),ue.setOnline(!1)}at().then(E),gt().then(E),window.addEventListener("hashchange",()=>{qt()||Ve()}),Ve()})();export{rr as showAuthExpiredOverlay,or as showReadOnlyToast};
1
+ import{a as gt,b as vt}from"./chunks/chunk-Z7DO42GJ.js";import{b as Ce,d as mt,e as ft,g as bt}from"./chunks/chunk-AGCPF6MT.js";import{a as lt}from"./chunks/chunk-BD3PZGH2.js";import{a as me,b as pt,c as ht}from"./chunks/chunk-Z7B3E3US.js";import{i as dt,j as ut}from"./chunks/chunk-5CJMHTT4.js";import{a as ue,b as nt}from"./chunks/chunk-G5XGBCM6.js";import{B as at,D as st,G as it,H as he,c as pe,r as y,s,t as rt,u as ot}from"./chunks/chunk-VMWNR3SV.js";import{a as hn,b as mn,c as fn,d as ct}from"./chunks/chunk-5THX4DI2.js";import{c as Y}from"./chunks/chunk-7SZRL6FY.js";var Xt=Y(mn(),1),Yt=Y(fn(),1),c=Y(hn(),1);var De="botmux:close-theme-menu",bn={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"/>'},wt=[{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"}]}],yt=wt.flatMap(e=>e.options),M=!1,Z=null,Q=null,gn=70,vn=120;function Oe(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">${bn[e]??""}</svg>`}function yn(e){return e.replace(/[&<>"]/g,n=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[n])}function xt(){let e=document.getElementById("theme-menu"),n=document.getElementById("theme-menu-btn"),r=document.getElementById("theme-menu-pop");if(!e||!n||!r||e.dataset.themeMenuInit==="1")return;e.dataset.themeMenuInit="1",r.innerHTML=wt.map(p=>`<div class="tm-group" data-label-key="${p.labelKey}"></div>`+p.options.map(f=>`<button type="button" class="tm-item" role="option" data-value="${f.value}"><span class="tm-ic">${Oe(f.icon)}</span><span class="tm-label" data-label-key="${f.labelKey}"></span></button>`).join("")).join("");let o=()=>{if(!M)return;let p=n.getBoundingClientRect(),f=12,h=Math.min(Math.max(r.offsetWidth||216,216),Math.max(0,window.innerWidth-f*2)),P=f+h/2,g=window.innerWidth-f-h/2,w=p.left+p.width/2,R=Math.min(Math.max(w,P),Math.max(P,g)),U=Math.max(180,window.innerHeight-p.bottom-20);r.style.setProperty("--theme-menu-pop-left",`${Math.round(R)}px`),r.style.setProperty("--theme-menu-pop-top",`${Math.round(p.bottom+8)}px`),r.style.setProperty("--theme-menu-pop-max-height",`${Math.round(U)}px`)},a=p=>{Z!=null&&(window.clearTimeout(Z),Z=null),Q!=null&&(window.clearTimeout(Q),Q=null),M=p,n.setAttribute("aria-expanded",String(M)),document.body.classList.toggle("theme-menu-open",M),M?(r.hidden=!1,o(),window.requestAnimationFrame(()=>e.classList.add("open"))):(e.classList.remove("open"),Q=window.setTimeout(()=>{Q=null,M||(r.hidden=!0)},vn))},i=()=>a(!0),u=()=>{Z==null&&(Z=window.setTimeout(()=>a(!1),gn))},m=p=>{p.pointerType!=="touch"&&i()},d=p=>{p.pointerType!=="touch"&&u()};e.addEventListener("pointerenter",m),e.addEventListener("pointerleave",d),r.addEventListener("pointerenter",m),r.addEventListener("pointerleave",d),n.addEventListener("click",p=>{p.stopPropagation(),a(!M)}),n.addEventListener("focus",()=>{n.matches(":focus-visible")&&i()}),e.addEventListener("focusout",p=>{let f=p.relatedTarget;(!(f instanceof Node)||!e.contains(f))&&u()}),r.addEventListener("click",p=>{let f=p.target.closest(".tm-item");f&&(y.setTheme(f.dataset.value??"system"),a(!1))}),document.addEventListener("click",p=>{M&&!e.contains(p.target)&&a(!1)}),document.addEventListener("pointermove",p=>{if(!M||p.pointerType==="touch")return;let f=p.target;f instanceof Node&&e.contains(f)||u()}),document.addEventListener("keydown",p=>{p.key==="Escape"&&M&&a(!1)}),window.addEventListener("resize",o),window.addEventListener("scroll",o,!0),window.addEventListener(De,()=>{M&&a(!1)}),He()}function He(){let e=document.getElementById("theme-menu-btn");if(!e)return;let n=yt.find(r=>r.value===y.theme)??yt[0];e.innerHTML=`<span class="tm-ic">${Oe("palette")}</span><span class="tm-current">${yn(s(n.labelKey))}</span><span class="tm-chev">${Oe("chevron")}</span>`,document.querySelectorAll("#theme-menu-pop [data-label-key]").forEach(r=>{r.textContent=s(r.dataset.labelKey??"")}),document.querySelectorAll("#theme-menu-pop .tm-item").forEach(r=>{r.classList.toggle("active",r.dataset.value===y.theme)})}function v(e,n,r,o,a=!1){return{id:e,routePrefix:n,rerenderOnUiChange:a,load:async()=>(await r())[o]}}var wn=[{id:"plugins",routePrefix:"#/plugins",rerenderOnUiChange:!1,load:async()=>{let e=await import("./chunks/plugin-page-VEGTCEAS.js");return n=>e.renderPluginPage(n)}},v("workflows","#/workflows",()=>import("./chunks/v3-page-RVKQIMAP.js"),"renderV3RunsPage"),v("groups","#/groups",()=>import("./chunks/groups-page-VDOOLS4M.js"),"renderGroupsPage"),v("settings","#/settings",()=>import("./chunks/settings-page-LIULUSMH.js"),"renderSettingsPage"),v("bot-defaults","#/bot-defaults",()=>import("./chunks/bot-defaults-page-65SMZ4QY.js"),"renderBotDefaultsPage"),v("skills","#/skills",()=>import("./chunks/skills-page-DQPBBI3T.js"),"renderSkillsPage"),v("connectors-logs","#/connectors/logs",()=>import("./chunks/connectors-page-CPH6VVFY.js"),"renderConnectorsLogsPage"),v("webhook-logs","#/webhook-logs",()=>import("./chunks/connectors-page-CPH6VVFY.js"),"renderConnectorsLogsPage"),v("connectors","#/connectors",()=>import("./chunks/connectors-page-CPH6VVFY.js"),"renderConnectorsPage"),v("team-manage","#/team/manage",()=>import("./chunks/team-federation-page-LQKLDV4K.js"),"renderTeamManagePage"),v("team","#/team",()=>import("./chunks/team-federation-page-LQKLDV4K.js"),"renderTeamFederationPage"),v("roles-profile","#/roles/profile",()=>import("./chunks/roles-page-YUC4YLJG.js"),"renderRoleProfilesPage"),v("roles","#/roles",()=>import("./chunks/roles-page-YUC4YLJG.js"),"renderRolesPage"),v("schedules","#/schedules",()=>import("./chunks/schedules-page-2L2NKTDJ.js"),"renderSchedulesPage"),v("whiteboards","#/whiteboards",()=>import("./chunks/whiteboards-page-S5K55HRZ.js"),"renderWhiteboardsPage"),v("monitoring","#/monitoring",()=>import("./chunks/monitoring-page-BGYSKZGM.js"),"renderMonitoringPage"),v("sessions","#/sessions",()=>import("./chunks/sessions-page-DYZZMKFL.js"),"renderSessionsPage"),v("monitor-room","#/monitor-room",()=>import("./chunks/monitor-room-2YR752E3.js"),"renderMonitorRoomPage",!0),v("office","#/office",()=>import("./chunks/office-page-ZZHTEAE4.js"),"renderOfficePage"),v("insights","#/insights",()=>import("./chunks/insights-page-A2LWTKJD.js"),"renderInsightsPage"),v("feedback","#/feedback",()=>import("./chunks/feedback-page-J2FKQ3LK.js"),"renderFeedbackPage")];function kt(e){return wn.find(n=>n.exact?e===n.routePrefix:e.startsWith(n.routePrefix))}async function Et(){let e=await import("./chunks/overview-page-7NYPKQSB.js");return n=>e.renderOverviewPage(n)}function Mt(){return{seq:0,pageDispose:null,rerenderOnUiChange:!0}}function Tt(e){let n=++e.seq;return e.pageDispose&&(e.pageDispose(),e.pageDispose=null),n}function Rt(e,n){return n===e.seq}async function Lt(e,n,r,o,a={}){let i=await o();if(!Rt(e,n))return!1;let u=i(r);return Rt(e,n)?(e.pageDispose=typeof u=="function"?u:null,e.rerenderOnUiChange=a.rerenderOnUiChange??!0,!0):(typeof u=="function"&&u(),!1)}var xn="botmux.dashboard.stale-chunk-reload.v1:",kn=/Failed to fetch dynamically imported module|Importing a module script failed|error loading dynamically imported module|dynamically imported module/i,En=/\b(?:https?:\/\/|\/assets\/)\S+?\.js\b/;function Nt(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}function St(e){return kn.test(Nt(e))}function Rn(e,n){let a=Nt(e).match(En)?.[0]||`${n.href}|${n.hash}`;return`${xn}${a.slice(-240)}`}function Mn(e,n){if(!St(e))return!1;let r=Rn(e,n);try{if(n.sessionStorage.getItem(r)==="1")return!1;n.sessionStorage.setItem(r,"1")}catch{return!1}return n.reload(),!0}function Pt(e,n){if(!St(e))return!1;let r;try{r=n.getSessionStorage()}catch{return!1}return Mn(e,{...n,sessionStorage:r})}var Tn=new Set(["auto","scroll","overlay"]),fe=28,S=3,_=6,Ct=!1,It=null,Ot=new WeakMap,C=new Map,Dt=null,Ht=null,Ae=0,Ie=0,ee=null;function Ln(e){return e.closest("dialog[open]")??document.body}function Nn(e){let n=Ot.get(e);if(n?.isConnected)return n;let r=document.createElement("div");return r.className="floating-scrollbar-layer",r.setAttribute("aria-hidden","true"),e.appendChild(r),Ot.set(e,r),r}function Sn(e){return Tn.has(e)}function Be(e,n){let r=getComputedStyle(e),o=n==="y"?r.overflowY:r.overflowX;return Sn(o)?n==="y"?e.scrollHeight-e.clientHeight>1:e.scrollWidth-e.clientWidth>1:!1}function Pn(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 Cn(e){return[e,...Array.from(e.querySelectorAll("*"))].filter(r=>Pn(r)&&(Be(r,"x")||Be(r,"y")))}function be(e){e.hideTimer!==void 0&&window.clearTimeout(e.hideTimer),e.track.remove()}function On(e,n){let r=C.get(e);r||(r={},C.set(e,r));let o=r[n],a=Ln(e),i=Nn(a);if(o?.track.parentElement===i)return o;o&&be(o);let u=document.createElement("div"),m=document.createElement("div");u.className=`floating-scrollbar floating-scrollbar-${n}`,m.className="floating-scrollbar-thumb",u.appendChild(m),i.appendChild(u);let d={target:e,axis:n,track:u,thumb:m,hideTimer:void 0};return r[n]=d,d}function Ue(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 Dn(e){let{target:n,axis:r,track:o,thumb:a}=e,i=n.getBoundingClientRect();if(r==="y"){let P=Math.max(0,i.top+S),g=Math.min(window.innerHeight,i.bottom-S),w=Math.max(0,g-P);if(w<fe||n.scrollHeight<=n.clientHeight){o.hidden=!0;return}let R=Math.max(fe,Math.round(w*n.clientHeight/n.scrollHeight)),U=Math.max(1,n.scrollHeight-n.clientHeight),V=Math.round((w-R)*n.scrollTop/U);o.hidden=!1,o.style.left=`${Math.min(window.innerWidth-_-S,Math.max(S,i.right-_-S))}px`,o.style.top=`${P}px`,o.style.width=`${_}px`,o.style.height=`${w}px`,a.style.width="100%",a.style.height=`${R}px`,a.style.transform=`translate3d(0, ${V}px, 0)`;return}let u=Math.max(0,i.left+S),m=Math.min(window.innerWidth,i.right-S),d=Math.max(0,m-u);if(d<fe||n.scrollWidth<=n.clientWidth){o.hidden=!0;return}let p=Math.max(fe,Math.round(d*n.clientWidth/n.scrollWidth)),f=Math.max(1,n.scrollWidth-n.clientWidth),h=Math.round((d-p)*n.scrollLeft/f);o.hidden=!1,o.style.left=`${u}px`,o.style.top=`${Math.min(window.innerHeight-_-S,Math.max(S,i.bottom-_-S))}px`,o.style.width=`${d}px`,o.style.height=`${_}px`,a.style.width=`${p}px`,a.style.height="100%",a.style.transform=`translate3d(${h}px, 0, 0)`}function F(){Ae||(Ae=window.requestAnimationFrame(()=>{Ae=0,An()}))}function Hn(){Ie||(Ie=window.setTimeout(()=>{Ie=0,F()},120))}function An(){let e=It;if(!e)return;let n=new Set(Cn(e));for(let[r,o]of C)n.has(r)||(o.x&&be(o.x),o.y&&be(o.y),C.delete(r));for(let r of n){let o=r===ee;for(let a of["x","y"]){let i=C.get(r);if(!Be(r,a)){let m=i?.[a];m&&(be(m),delete i?.[a]);continue}let u=On(r,a);Dn(u),o&&Ue(u,!0)}}}function In(e){if(!(e instanceof HTMLElement))return;let n=C.get(e);if(n)for(let r of Object.values(n))r&&(r.track.classList.add("is-active"),Ue(r))}function Bn(e){for(let n=e;n;n=n.parentElement)if(n instanceof HTMLElement&&C.has(n))return n;return null}function At(e){if(ee===e)return;let n=ee?C.get(ee):void 0;if(ee=e,n)for(let o of Object.values(n))o?.track.classList.remove("is-visible");let r=e?C.get(e):void 0;if(r)for(let o of Object.values(r))o&&Ue(o,!0)}function Bt(e){Ct||(Ct=!0,It=e,document.documentElement.classList.add("floating-scrollbars-on"),Dt=typeof ResizeObserver>"u"?null:new ResizeObserver(F),Dt?.observe(e),Ht=new MutationObserver(n=>{for(let r of n){let o=r.target;if(!(o instanceof Element&&o.closest(".floating-scrollbar-layer"))){Hn();return}}}),Ht.observe(e,{attributes:!0,attributeFilter:["class","style","hidden","open"],childList:!0,subtree:!0}),document.addEventListener("scroll",n=>{In(n.target),F()},!0),window.addEventListener("resize",F),window.addEventListener("hashchange",F),document.addEventListener("pointermove",n=>{At(Bn(document.elementFromPoint(n.clientX,n.clientY)))}),document.addEventListener("pointerleave",()=>At(null)),F())}var Ut=!1,K=null,ge=null,W=null;function _t(){if(K)return K;let e=document.createElement("div");return e.className="icon-tip",e.setAttribute("role","tooltip"),e.style.display="none",document.body.appendChild(e),K=e,e}function Un(e){let n=_t(),r=dt(e,document.body);return n.parentNode!==r&&r.appendChild(n),n}function $n(e){let n=_t(),r=e.getBoundingClientRect(),o=n.offsetWidth,a=n.offsetHeight,i=8,u=r.top<a+i+4,m=r.left+r.width/2-o/2;m=Math.min(Math.max(m,6),window.innerWidth-o-6);let d=u?r.bottom+i:r.top-a-i;n.style.left=`${Math.round(m)}px`,n.style.top=`${Math.round(d)}px`,n.dataset.placement=u?"bottom":"top"}function te(){W&&(clearTimeout(W),W=null),ge=null,K&&(K.style.display="none",K.classList.remove("show"))}function $t(e){let n=e.getAttribute("data-tip");if(!n)return;ge=e;let r=Un(e);r.textContent=n,r.style.display="block",r.classList.remove("show"),$n(e),requestAnimationFrame(()=>{ge===e&&r.classList.add("show")})}function $e(e){return e instanceof Element?e.closest("[data-tip]"):null}function Ft(){Ut||typeof document>"u"||(Ut=!0,document.addEventListener("pointerover",e=>{let n=$e(e.target);!n||n===ge||(W&&clearTimeout(W),W=setTimeout(()=>$t(n),120))}),document.addEventListener("pointerout",e=>{let n=$e(e.target);if(!n)return;let r=e.relatedTarget instanceof Element?e.relatedTarget:null;r&&(r===n||n.contains(r))||te()}),document.addEventListener("focusin",e=>{let n=$e(e.target);n&&$t(n)}),document.addEventListener("focusout",te),document.addEventListener("click",te,!0),window.addEventListener("scroll",te,!0),window.addEventListener("resize",te))}async function Kt(e){let n=await e.json().catch(()=>null);return n&&typeof n=="object"?n:{}}function Wt(e,n){let r=n.detail??n.error;return new Error(typeof r=="string"?r:`HTTP ${e.status}`)}async function _e(e,n=()=>{},r){n("updating");let o=await e(r?"/api/update/rollback":"/api/update/run",r?{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:r})}:{method:"POST"}),a=await Kt(o);if(!o.ok||a.ok===!1)throw Wt(o,a);if(a.ok!==!0||typeof a.oldVersion!="string"||typeof a.newVersion!="string"||typeof a.changed!="boolean")throw new Error("Invalid update response");if(r&&(a.newVersion!==r||a.changed!==!0))throw new Error("Invalid rollback response");let i={oldVersion:a.oldVersion,newVersion:a.newVersion,changed:a.changed,restarted:!1};if(n("restarting"),r)return{...i,restarted:!0};let u=await e("/api/update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({update:{oldVersion:i.oldVersion,newVersion:i.newVersion}})}),m=await Kt(u);if(m.error==="bootstrap_shutdown_protocol_required"){let p=Array.isArray(m.unsafeDaemons)?m.unsafeDaemons.filter(f=>typeof f=="string"):[];return{...i,restarted:!1,bootstrapRequired:!0,unsafeDaemons:p}}if(!u.ok||m.ok===!1)return{...i,restarted:!1,restartError:Wt(u,m).message};if(m.ok!==!0)throw new Error("Invalid restart response");return m.alreadyScheduled===!0?{...i,restarted:!0,alreadyScheduled:!0}:{...i,restarted:!0}}function Fe(e,n){if(e)try{let r=new URL(e);if(!["http:","https:"].includes(r.protocol)||r.username||r.password)return;let o=n.startsWith("#/")&&n.length<=4096&&!/[\u0000-\u001f\u007f]/.test(n)?n:"#/";return r.searchParams.set("next",`/${o}`),r.toString()}catch{return}}var t=Y(ct(),1),_n=["roles","role-profiles","bot-defaults","skills","plugins","team","connectors","insights","feedback","whiteboards"],zt=[{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:"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:"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"})]})}],re=[],A=!0,qe=!1,Zt=location.hash||"#/",z=null,oe=!1,ae=null,ye=null,Qt=null,we=null,en=null,H=Mt(),tn="botmux.ownerAvatar.v1",Fn=new Set(["working","analyzing","active","starting"]),je="botmux:auth-expired",Ge;function ne(e){return(0,t.jsx)("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e})}function Vt(e){return e.labelKey?s(e.labelKey):e.label??""}function Kn(e,n){let r=n||"#/";return e.id==="plugins"&&re.some(o=>o.href===r||r.startsWith(`${o.href}?`)||r.startsWith(`${o.href}/`))?!1:e.id==="sessions"&&(r==="#/monitor-room"||r.startsWith("#/monitor-room?")||r.startsWith("#/monitor-room/"))||e.id==="connectors"&&(r==="#/webhook-logs"||r.startsWith("#/webhook-logs?")||r.startsWith("#/webhook-logs/"))?!0:e.href===r||e.href!=="#/"&&(r.startsWith(`${e.href}?`)||r.startsWith(`${e.href}/`))}function Wn(){let e=ft()?zt.filter(r=>r.id!=="workflows"):zt;if(re.length===0)return e;let n=e.findIndex(r=>r.id==="plugins");return n<0?[...e,...re]:[...e.slice(0,n+1),...re,...e.slice(n+1)]}function zn(e){let n=[];return Kn(e,Zt)&&n.push("active"),e.id==="settings"&&oe&&n.push("nav-has-update"),n.length?n.join(" "):void 0}function nn(){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 qt(){let e=nn();return!e||e===y.locale?!1:(y.setLocale(e),!0)}function Vn(){let e=location.hash.indexOf("?");return e<0?null:{path:location.hash.slice(0,e)||"#/",params:new URLSearchParams(location.hash.slice(e+1))}}function qn(){let e=Vn(),n=e?.params.get("open");if(!e||!n||n!=="bot-onboarding"&&n!=="create-session")return!1;e.params.delete("open");let r=e.params.toString();return history.replaceState(null,"",r?`${e.path}?${r}`:e.path),n==="bot-onboarding"?window.dispatchEvent(new Event(me)):Ce(),!0}function jt(){let e=ae?`v${ae}`:"";return ye==="runtime"?s("update.navRuntimeBadgeTitle",{version:e}):s("update.navBadgeTitle",{version:e})}function jn(e){we=e}function Ke(){if(we)return we;let e=document.getElementById("root");if(!e)throw new Error("dashboard root is not mounted");return we=e,e}function Gn(){return(0,c.useEffect)(()=>{xt()},[]),(0,c.useEffect)(()=>{He()}),(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 Jn(){let e=[...ue.sessions.values()],n=e.filter(d=>d.status!=="closed"),r=n.map(d=>({s:d,reason:it(d)})).filter(d=>!!d.reason).sort((d,p)=>he(d.s)-he(p.s)),o=new Set(r.map(d=>String(d.s.sessionId??""))),a=n.filter(d=>Fn.has(String(d.status))&&!o.has(String(d.sessionId??""))).length,i=r[0]??null,u=vt(e).filter(d=>d.online||d.active.length>0).length,m=Math.max(0,n.length-r.length-a);return{working:a,attention:r.length,idle:m,onlineBots:u,attentionNotice:i?{count:r.length,time:ot(he(i.s)),bot:st(i.s),reason:i.reason}:null}}function ve(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 Xn(e){let{attention:n,idle:r,working:o}=e.summary,a=o+n+r,i=a===0?"conic-gradient(var(--border) 0 360deg)":(()=>{let u=o/a*360,m=u+n/a*360;return`conic-gradient(var(--accent) 0 ${u}deg, var(--warning) ${u}deg ${m}deg, var(--success) ${m}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:i}}),(0,t.jsxs)("div",{className:"topbar-status-donut-center",children:[(0,t.jsx)("b",{children:a}),(0,t.jsx)("span",{children:s("overview.openSessions")})]})]})}function We(){window.dispatchEvent(new Event(De))}function Yn(e){let{autoOpen:n=!1,summary:r}=e,[o,a]=(0,c.useState)(!1),[i,u]=(0,c.useState)(!1),[m,d]=(0,c.useState)(!1),p=(0,c.useRef)(null),f=n&&!i,h=o||f;return(0,c.useEffect)(()=>{n||u(!1)},[n]),(0,c.useEffect)(()=>{if(!h)return;let g=w=>{let R=w.target;R instanceof Node&&p.current?.contains(R)||(a(!1),u(!0))};return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[h]),(0,t.jsxs)("div",{ref:p,className:`topbar-status-menu${f?" topbar-status-auto-open":""}${o?" is-open":""}${m?" suppress-hover":""}`,onPointerEnter:We,onPointerLeave:()=>d(!1),onFocusCapture:We,onBlur:g=>{let w=g.relatedTarget;(!(w instanceof Node)||!g.currentTarget.contains(w))&&a(!1)},onKeyDown:g=>{g.key==="Escape"&&(a(!1),u(!0),d(!0),g.currentTarget.querySelector("#status")?.focus())},children:[(0,t.jsx)("button",{type:"button",id:"status",className:"connection-status","aria-haspopup":"true","aria-expanded":h,onClick:()=>{if(We(),h){a(!1),u(!0),d(!0);return}d(!1),a(!0)},children:s("overview.sessionOverview")}),(0,t.jsxs)("div",{className:"topbar-status-pop",children:[r.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:r.attentionNotice.count})}),(0,t.jsx)("small",{children:s("strip.longestCompact",{time:r.attentionNotice.time,bot:r.attentionNotice.bot,reason:r.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)(ve,{label:s("overview.workingSessions"),value:r.working}),(0,t.jsx)(ve,{label:s("overview.idleSessions"),value:r.idle}),(0,t.jsx)(ve,{label:s("overview.attention"),value:r.attention,hot:r.attention>0}),(0,t.jsx)(ve,{label:s("overview.onlineBots"),value:r.onlineBots})]}),(0,t.jsx)(Xn,{summary:r})]})]})}function Zn(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:r=>{r.target===r.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 Qn(e){let n=new Date(e);if(Number.isNaN(n.getTime()))return e.slice(0,10);try{return new Intl.DateTimeFormat(y.locale==="zh"?"zh-CN":"en-US",{year:"numeric",month:"numeric",day:"numeric"}).format(n)}catch{return e.slice(0,10)}}async function Gt(){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 er(e){let{status:n}=e,[r,o]=(0,c.useState)(!1),[a,i]=(0,c.useState)("idle"),[u,m]=(0,c.useState)(0),[d,p]=(0,c.useState)(!1),[f,h]=(0,c.useState)(!1),[P,g]=(0,c.useState)(""),[w,R]=(0,c.useState)(!1),[U,V]=(0,c.useState)(!1),[T,xe]=(0,c.useState)(!1),[q,ie]=(0,c.useState)(!1),[j,Xe]=(0,c.useState)([]),[x,ke]=(0,c.useState)(null),[O,Ee]=(0,c.useState)(null),L=(0,c.useRef)(!1),G=(0,c.useRef)(null),le=(0,c.useRef)(null),Ye=(0,c.useRef)(null),Re=(0,c.useRef)(null),Me=(0,c.useRef)(null),[J,Ze]=(0,c.useState)(null),rn=()=>{G.current!==null&&(window.clearTimeout(G.current),G.current=null)},Te=()=>{le.current!==null&&(window.clearInterval(le.current),le.current=null)};if((0,c.useEffect)(()=>{L.current=!1,i("idle"),m(0),p(!1),h(!1),g(""),R(!1),V(!1),xe(!1),ie(!1),Xe([]),ke(null),Ee(null)},[n?.current,n?.latest]),(0,c.useEffect)(()=>{if(Te(),a==="idle"||a==="error"){m(0);return}let l=a==="updating"?50:95;return a==="restarting"&&m(b=>Math.max(b,50)),le.current=window.setInterval(()=>{m(b=>b>=l?l:b+Math.max(.5,(l-b)*.08))},400),()=>Te()},[a]),(0,c.useEffect)(()=>{n&&h(n.versionLookupOk===!1)},[n]),(0,c.useEffect)(()=>{r||R(!1)},[r]),(0,c.useEffect)(()=>{if(!r||!J)return;let l=window.requestAnimationFrame(()=>{Me.current?.querySelector('button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')?.focus()});return()=>window.cancelAnimationFrame(l)},[r,J!==null]),(0,c.useEffect)(()=>{if(!r){Ze(null);return}let l=()=>{let b=Re.current;if(!b)return;let k=b.getBoundingClientRect(),N=Math.min(340,Math.max(0,window.innerWidth-32)),B=Math.max(16,Math.min(k.left,window.innerWidth-N-16));Ze({top:k.bottom+8,left:B})};return l(),window.addEventListener("resize",l),document.addEventListener("scroll",l,!0),()=>{window.removeEventListener("resize",l),document.removeEventListener("scroll",l,!0)}},[r]),(0,c.useEffect)(()=>()=>{rn(),Te()},[]),(0,c.useEffect)(()=>{if(!r)return;let l=k=>{let N=k.target;Ye.current?.contains(N)||Me.current?.contains(N)||o(!1)},b=k=>{k.key==="Escape"&&(o(!1),Re.current?.focus())};return document.addEventListener("pointerdown",l),document.addEventListener("keydown",b),()=>{document.removeEventListener("pointerdown",l),document.removeEventListener("keydown",b)}},[r]),!n)return null;let I=n.behind&&!!n.latest,Le=!n.latest,Ne=I&&n.updateSupported&&!n.localDevInstall&&n.node.ok,Qe=n.updateSupported&&!n.localDevInstall&&n.node.ok,D=a==="updating"||a==="restarting",et=2*Math.PI*20,on=et*(1-Math.max(2,Math.round(u))/100),an=n.updateCommand??"botmux update",Se=`v${n.current}`,sn=n.latest?`v${n.latest}`:"",ln=n.localDevInstall?s("update.localDev"):n.updateSupported?n.node.ok?"":s("update.nodeWarn",{version:n.node.version,required:n.node.required}):s("update.unsupportedInstall"),tt=l=>{let b=Date.now(),k=async()=>{try{let N=await fetch("/__selfcheck",{cache:"no-store"}),B=await N.text();if(N.ok&&B&&B!==l){location.reload();return}}catch{}if(Date.now()-b>9e4){L.current=!1,i("error"),g(s("update.restartSlow"));return}G.current=window.setTimeout(()=>{k()},2e3)};G.current=window.setTimeout(()=>{k()},3e3)},cn=async()=>{if(I){if(!Ne){o(!1),location.hash="#/settings";return}if(!L.current){L.current=!0,Ee(null),h(!1),g("");try{let l=await Gt(),b=await _e(fetch,i);if(b.bootstrapRequired){L.current=!1,i("error"),g(s("update.bootstrapRequired"));return}if(!b.restarted){L.current=!1,i("error"),g(s("update.restartFailed",{detail:b.restartError??"unknown"}));return}tt(l)}catch(l){L.current=!1,i("error"),g(l instanceof Error?l.message:String(l))}}}},Pe=async(l=!1)=>{if(T)return!q;xe(!0),ie(!1);try{let b=await fetch(`/api/update/versions${l?"?refresh=1":""}`,{cache:"no-store"}),k=await b.json().catch(()=>null);if(!k||!Array.isArray(k.versions))throw new Error("Invalid rollback versions response");let N=k.versions.filter($=>{if(!$||typeof $!="object")return!1;let X=$;return typeof X.version=="string"&&(typeof X.publishedAt=="string"||X.publishedAt===null)}).slice(0,3);Xe(N),ke($=>N.some(X=>X.version===$)?$:null),V(!0);let B=b.ok&&k.ok===!0;return ie(!B),B}catch{return V(!0),ie(!0),!1}finally{xe(!1)}},dn=async()=>{if(!(!x||!Qe||T||L.current)){L.current=!0,Ee(x),h(!1),g("");try{let l=await Gt();await _e(fetch,i,x),tt(l)}catch(l){L.current=!1,i("error"),g(l instanceof Error?l.message:String(l))}}},un=async()=>{if(!(d||D)){p(!0),h(!1);try{let l=await e.onRefresh();w&&await Pe(!0),h(!l)}finally{p(!1)}}},ce=a==="updating"?O?s("update.rollbackInstalling",{version:O}):s("update.updating",{command:an}):a==="restarting"?O?s("update.rollbackRestarting",{version:O}):s("update.restarting"):a==="error"?O?s("update.rollbackFailed",{detail:P}):s("update.updateFailed",{detail:P}):f?s("update.topbarRefreshFailed"):I?Ne?s("update.versionUpgradePrompt",{version:sn}):ln:n.latest?s("update.upToDate"):s("update.checkUnavailable"),pn=Ne?a==="error"?s("update.topbarRetry"):a==="idle"?s("update.topbarAction"):s("update.topbarWorking"):s("update.topbarReview"),de=a==="error"||f&&Le?{className:"is-error",symbol:"!"}:I?{className:"has-update",symbol:"\u2191"}:Le?{className:"is-unknown",symbol:"?"}:{className:"is-current",symbol:"\u2713"};return(0,t.jsxs)("div",{ref:Ye,className:`dashboard-version-control${r?" is-open":""}`,children:[(0,t.jsxs)("button",{ref:Re,type:"button",className:`dashboard-version-chip${I?" has-update":""}${Le?" is-unknown":""}${a==="error"?" is-error":""}`,"aria-haspopup":"dialog","aria-expanded":r,"aria-label":`${Se}. ${ce}`,title:ce,onClick:()=>o(l=>!l),children:[(0,t.jsx)("span",{children:Se}),(0,t.jsx)("span",{className:`dashboard-version-state ${de.className}`,"aria-hidden":"true",children:de.symbol})]}),r&&J&&typeof document<"u"?(0,Xt.createPortal)((0,t.jsxs)("section",{ref:Me,className:"dashboard-version-popover",role:"dialog","aria-modal":"false","aria-labelledby":"dashboard-version-title",style:{top:J.top,left:J.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${d?" is-refreshing":""}`,"aria-label":s(d?"update.topbarRefreshing":"update.topbarRefresh"),title:s(d?"update.topbarRefreshing":"update.topbarRefresh"),disabled:d||T||D,onClick:()=>{un()},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:()=>o(!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:Se}),D?(0,t.jsxs)("span",{className:"dashboard-version-ring",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(u),"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:et,strokeDashoffset:on}})]}),(0,t.jsxs)("span",{className:"dvr-pct",children:[Math.round(u),"%"]})]}):(0,t.jsx)("span",{className:de.className,"aria-hidden":"true",children:de.symbol})]}),(0,t.jsx)("p",{className:`dashboard-version-message${a==="error"||f?" is-error":""}`,role:a==="error"||f?"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")})]}),(I||w)&&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(l=>(0,t.jsx)("li",{children:l.binPath},l.binPath))})]}):null,Qe?(0,t.jsxs)("details",{className:"dashboard-version-rollback",open:w,"aria-busy":T,onToggle:l=>{let b=l.currentTarget.open;R(b),b&&!U&&!T&&Pe()},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:[T&&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:T,onClick:()=>{Pe(!0)},children:s("update.rollbackRetry")})]}):null,U&&!T&&!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:D||T||q,children:[(0,t.jsx)("legend",{children:s("update.rollbackHint")}),(0,t.jsx)("div",{className:"dashboard-version-rollback-options",children:j.map(l=>(0,t.jsxs)("label",{className:x===l.version?"is-selected":"",children:[(0,t.jsx)("input",{type:"radio",name:"dashboard-rollback-version",value:l.version,checked:x===l.version,onChange:()=>ke(l.version)}),(0,t.jsxs)("strong",{children:["v",l.version]}),l.publishedAt?(0,t.jsx)("time",{dateTime:l.publishedAt,children:Qn(l.publishedAt)}):null]},l.version))})]}):null,x?(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:x})," ",(0,t.jsx)("a",{href:`https://github.com/deepcoldy/botmux/releases/tag/v${encodeURIComponent(x)}`,target:"_blank",rel:"noopener noreferrer","aria-label":s("update.rollbackReleaseNotesA11y",{version:x}),children:s("update.rollbackReleaseNotes",{version:x})})]})]}):null,j.length>0?(0,t.jsxs)("button",{type:"button",className:"dashboard-version-rollback-action",disabled:!x||T||q||D,"aria-describedby":x?"dashboard-version-rollback-risk":void 0,onClick:()=>{dn()},children:[D&&O?(0,t.jsx)("span",{className:"dashboard-update-spinner","aria-hidden":"true"}):null,x?a==="error"&&O===x?s("update.rollbackRetry"):s("update.rollbackAction",{version:x}):s("update.rollbackSelect")]}):null]})]}):null]}),I&&!w&&!O?(0,t.jsxs)("footer",{className:"dashboard-version-popover-actions",children:[(0,t.jsx)("button",{type:"button",className:"dashboard-version-secondary",onClick:()=>o(!1),children:D?s("update.topbarClose"):s("update.topbarLater")}),(0,t.jsx)("button",{type:"button",className:"dashboard-version-primary",disabled:D,onClick:()=>{cn()},children:pn})]}):null]}),document.body):null]})}function tr(){let e=Jn(),[n,r]=(0,c.useState)(!1),[o,a]=(0,c.useState)(!1),[i,u]=(0,c.useState)(!1),m=(0,c.useRef)(e.attention),d=(0,c.useRef)(null),p=()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)};(0,c.useEffect)(()=>{let h=()=>r(!0);return window.addEventListener(me,h),()=>window.removeEventListener(me,h)},[]),(0,c.useEffect)(()=>{let h=()=>a(!0);return window.addEventListener(je,h),se&&a(!0),()=>window.removeEventListener(je,h)},[]),(0,c.useEffect)(()=>()=>p(),[]),(0,c.useEffect)(()=>{let h=m.current;if(m.current=e.attention,e.attention===0){p(),u(!1);return}h!==0||document.body.classList.contains("theme-menu-open")||(u(!0),p(),d.current=window.setTimeout(()=>{d.current=null,u(!1)},4e3))},[e.attention]);let f=()=>{se=!1,a(!1)};return(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)(er,{status:Qt,onRefresh:()=>Je(!0)})]})}),(0,t.jsxs)("div",{className:"topbar-actions",children:[(0,t.jsx)(Yn,{summary:e,autoOpen:i}),(0,t.jsxs)("div",{className:"topbar-tool-group",children:[(0,t.jsx)("button",{type:"button",className:"topbar-locale-toggle","aria-label":y.locale==="zh"?"Switch to English":"\u5207\u6362\u5230\u4E2D\u6587",title:y.locale==="zh"?"Switch to English":"\u5207\u6362\u5230\u4E2D\u6587",onClick:()=>nr(y.locale==="zh"?"en":"zh"),children:y.locale==="zh"?"CN":"EN"}),(0,t.jsx)(Gn,{}),(0,t.jsxs)("a",{className:"topbar-docs-link",href:"https://bytedance.aiforce.cloud/app/app_4k9smq6rdxher/",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:z?.name,"aria-label":z?.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"})]}))}),z?.avatarUrl?(0,t.jsx)("img",{className:"topbar-owner-img",src:z.avatarUrl,alt:"",decoding:"async",referrerPolicy:"no-referrer",onError:h=>{h.currentTarget.remove()}}):null]})]})]}),(0,t.jsxs)("div",{className:"chrome-body",children:[(0,t.jsxs)("aside",{className:"sidebar",children:[A?(0,t.jsxs)("div",{className:"sidebar-create-actions",children:[(0,t.jsxs)("button",{type:"button",className:"sidebar-create-btn",onClick:()=>Ce(),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:()=>{pt()},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:Wn().filter(h=>A||!h.manage).map(h=>(0,t.jsxs)("a",{href:h.href,"data-route":h.id,className:[zn(h),h.plugin?"sidebar-plugin-item":""].filter(Boolean).join(" ")||void 0,title:h.plugin?Vt(h):void 0,children:[ne(h.icon),(0,t.jsx)("span",{className:"sidebar-nav-label",children:Vt(h)}),h.id==="settings"&&oe?(0,t.jsx)(ut,{className:"nav-update-tip",label:jt(),trigger:(0,t.jsx)("span",{className:"nav-update-dot","aria-hidden":"true"}),preventClick:!1,focusable:!1,children:jt()}):null]},h.id))})]}),(0,t.jsxs)("div",{className:"workspace",children:[(0,t.jsx)("dialog",{id:"create-session-modal",className:"create-session-modal"}),(0,t.jsx)(ht,{open:n,onClose:()=>r(!1)}),(0,t.jsx)("main",{id:"root",ref:jn})]})]})]}),(0,t.jsx)(Zn,{open:o,loginUrl:Fe(Ge,location.hash),onClose:f})]})}function E(){en?.render((0,t.jsx)(tr,{}))}function nr(e){y.setLocale(e),ir(e)}var se=!1;function rr(e){let n=!!Fe(e,location.hash),r=n&&Ge!==e;n&&(Ge=e),se&&r&&E(),!se&&(se=!0,window.dispatchEvent(new Event(je)))}var ze;function or(){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",ze&&window.clearTimeout(ze),ze=window.setTimeout(()=>{e.style.display="none"},4e3)}var ar=window.fetch.bind(window);window.fetch=async function(...n){let r=await ar(...n);if(r.status===401){let o=r.headers.get("x-botmux-login-url")??void 0,a=(n[1]?.method??"GET").toUpperCase();o||(a==="GET"||a==="HEAD")&&!qe?rr(o):or()}return r};async function sr(){try{let e=await fetch("/api/settings");if(e.ok){let n=await e.json();A=!!n.authed,y.authed=A,qe=!!(n.settings&&n.settings.publicReadOnly),y.publicReadOnly=qe;let r=nn()??pe(n.lang);r&&y.setLocale(r)}}catch{}}async function Jt(){try{let e=await fetch("/api/plugins/dashboard");if(!e.ok)return;let n=await e.json();re=(Array.isArray(n?.plugins)?n.plugins:[]).filter(o=>o.pinned===!0&&typeof o.route=="string").map(o=>({id:`plugin:${o.pluginId}:${o.id}`,href:o.route,label:o.displayName||o.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"})]})})),E()}catch{}}async function ir(e){if(A)try{await fetch("/api/settings",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({lang:e})})}catch{}}async function Je(e=!1){if(!A)return!1;try{let n=await fetch(`/api/update/status${e?"?refresh=1":""}`,{cache:"no-store"});if(!n.ok)return!1;let r=await n.json();Qt=r;let o=Array.isArray(r.cliUpdates)?r.cliUpdates.find(a=>a?.updateAvailable===!0&&a?.latest):null;return r.behind===!0&&r.latest?(oe=!0,ye="botmux",ae=String(r.latest)):o?(oe=!0,ye="runtime",ae=String(o.latest)):(oe=!1,ye=null,ae=null),E(),r.versionLookupOk!==!1}catch{return!1}}function lr(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 Ve(){let e=Tt(H),n=location.hash||"#/";Zt=n,E();let r=bt(n);if(r){window.location.replace(r);return}if(!A&&_n.some(o=>n.startsWith("#/"+o))){lr(Ke()),H.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 o=kt(n);await Lt(H,e,Ke(),o?o.load:Et,{rerenderOnUiChange:o?o.rerenderOnUiChange:!1}),e===H.seq&&A&&qn()}catch(o){if(e!==H.seq||Pt(o,{href:window.location.href,hash:n,getSessionStorage:()=>window.sessionStorage,reload:()=>window.location.reload()}))return;Ke().innerHTML=`<section class="page"><div class="empty">Dashboard route failed: ${rt(String(o))}</div></section>`,H.pageDispose=null,H.rerenderOnUiChange=!0}}function cr(){try{let e=JSON.parse(window.localStorage.getItem(tn)??"null");if(e?.avatarUrl)return{avatarUrl:String(e.avatarUrl),name:e.name?String(e.name):void 0}}catch{}return null}function dr(){z=cr(),E(),fetch("/api/owner-profile").then(e=>e.ok?e.json():null).then(e=>{if(!(!e?.ok||!e.avatarUrl)){z={avatarUrl:String(e.avatarUrl),name:e.name?String(e.name):void 0};try{window.localStorage.setItem(tn,JSON.stringify({avatarUrl:e.avatarUrl,name:e.name??""}))}catch{}E()}}).catch(()=>{})}(async()=>{let e=mt(window.location.href);e&&window.history.replaceState(window.history.state,"",e),y.init(),qt();let n=document.getElementById("app-root");if(!n)throw new Error("missing dashboard app root");Bt(n),Ft(),en=(0,Yt.createRoot)(n),E(),y.on(()=>{E(),H.rerenderOnUiChange&&Ve()}),ue.on(()=>{E()}),await sr(),E(),window.addEventListener(lt,()=>{Jt()}),Jt(),Je(),window.setInterval(()=>{document.hidden||Je()},30*6e4),dr();try{await nt()}catch(r){console.error("botmux dashboard bootstrap failed",r),ue.setOnline(!1)}at().then(E),gt().then(E),window.addEventListener("hashchange",()=>{qt()||Ve()}),Ve()})();export{rr as showAuthExpiredOverlay,or as showReadOnlyToast};