openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
388 lines • 235 kB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./session-placement-recovery-migration.runtime-D-Ocs6wH.js","./control-ui-boot-shared-CXVvK2AW.js","./rolldown-runtime-DkW27tQK.js","./control-ui-foundation-Cydpkyqa.js","./control-ui-core-Rwzhj6nO.js","./lit-runtime-CV_MH99K.js","./control-ui-core-vvcQQV2m.js","./gateway-runtime-Bqqcp9-I.js","./control-ui-core-ClxHIvNM.css","./control-ui-boot-shared-BYq7Cchl.js","./control-ui-boot-shared-Deak_Sjt.js","./control-ui-boot-shared-gfE6fZcA.js","./markdown-runtime-Bn6OdBVq.js","./control-ui-boot-shared-DfZ39Yj9.js","./control-ui-boot-shared-3juXI2I2.js","./control-ui-boot-shared-BVNXvWX-.js","./control-ui-boot-shared-KspYIvAF.css","./gateway-scope-upgrade.runtime-COKPg-Cs.js","./command-palette-DutMicI_.js","./transcript-search-BNkA0vxn.js","./debug-overlay-BHWfz6ox.js","./lane-table-CREVCF-J.js","./lane-table-BIZTCoDw.css","./keyboard-shortcuts-dialog-FN4z-F-7.js","./macos-titlebar-controls.runtime-DzBe0DU9.js","./sidebar-attention-DwR-r9JL.js","./terminal-panel-registration-K_mKS-nt.js","./control-ui-boot-chat-_QSl8fbH.js","./control-ui-boot-chat-Cgwe4GEM.js","./config-runtime-D-5ybyEi.js","./dock-layout-controller-DJtLlZ8p.js","./scrollbar-styles-Cosje8h4.js","./panel-tab-strip-P1EsXfgP.js","./dock-destination-controls-B0dNLHXR.js","./theme-color-BwHgSJo3.js","./browser-panel-DGRO2wFN.js","./desktop-panel-C0q8O3Dk.js","./control-ui-boot-chat-Bia0O-uD.js","./control-ui-boot-chat-CMe3QBDk.js","./control-ui-boot-chat-CazDfK3O.js","./control-ui-boot-chat-BhPddYSI.js","./control-ui-boot-chat-C2G5RI6S.css","./control-ui-boot-chat-D85X0PFX.js","./desktop-focus-window-CY5JuBq7.js","./board-document-B_hi1f-Z.js","./board-view-MrEmUNnS.js","./control-ui-disabled-2SNbmzuV.js","./near-viewport-observer-BfnpDHlZ.js","./widget-sandbox-host-BBp_TNUu.js","./board-view-Dy3yHmZ7.css","./board-document-B0Y4zGJq.css","./assistant-panel-Ph0p7Cpg.js","./custodian-surface-B8--KKtk.js","./custodian-alert-store-C8M3qKFB.js","./wizard-step-controls-BcNiLuAR.js","./channel-picker-Bws61IbA.js","./presentation-B7nRIH3E.js","./select-picker-BNhpItgu.js","./select-picker-CvHp-4fg.css","./channel-picker-Dr_cIA_m.css","./wizard-step-controls-CUvrnOcR.css","./custodian-surface-BlvV8Huo.css","./assistant-panel-Vf7BSqc6.css","./approval-page-registration-CZQUFKna.js","./approval-result-validators-CU-g8vLR.js","./approval-Dpr9VMH2.js","./approval-COwc0-bg.css","./question-page-registration-D8fm_YUt.js","./exec-approval-Bp0d8ZwT.js","./login-gate-B4HKZ0Kk.js","./control-ui-boot-new-Bj2SAUyl.js","./control-ui-boot-new-DTUE5TUM.css","./control-ui-environment-presentation.runtime-BcIofN7_.js","./sw-refresh.runtime-CfiqJg48.js","./canvas-surface-lease.runtime-D9IH9B8w.js","./session-placement-startup.runtime-Bow8I4wF.js","./update-triage.runtime-C-ASlPWe.js","./en-update-actions-BD3m-_AA.js","./en-settings-D_ebb5Hk.js","./web-push.runtime-D1HzC7es.js","./browser-bootstrap.runtime-yU444ZS1.js","./native-notifications-D_lyz80n.js","./native-device-settings-CcSm3s9I.js","./session-progress-hovercard-registration-DF9iuIbl.js","./route-loader-CBX3uHIe.js","./nav-drawer-swipe.runtime-BJvyGdY6.js","./critical-observer-notice.runtime-CRMUtUuZ.js","./update-confirmation.runtime-CS0ySheH.js","./update-run-view-DVwiT6Fy.js","./update-run-projection-lALEhkx7.js","./stream-auto-follow-controller-DQpG-yCd.js","./update-run-view-BC2Uw3Fp.css","./app-sidebar-DxM9SlaJ.js","./settings-sidebar-UFxCOjch.js","./config-form.tiers-DFD3a4dS.js","./setup-schema-BzY-uJ6H.js","./slots-CTN3PGFH.js","./settings-targets-BmloFKW8.js","./view-pairing.runtime-lXzSgb_-.js","./onboarding-memory-import-CFKfZGFP.js","./onboarding-memory-import-DuWLEvoz.css","./outbox-store-projection-BFrl_eSc.js","./sidebar-update-card-C9_fyhkz.js","./sidebar-update-card-CE6rs-4H.js","./sidebar-update-card-BF-_KMrW.css","./composer-draft-retirement.runtime-vhT3sNK4.js"])))=>i.map(i=>d[i]);
import{n as e}from"./rolldown-runtime-DkW27tQK.js";import{$t as t,B as n,Bi as r,Bt as i,C as a,Ci as o,Cn as s,D as c,Di as l,Dt as u,E as d,Et as f,Fi as p,Ft as m,G as h,Hi as g,I as _,Ii as v,It as y,Kn as b,Kt as x,L as S,Ln as C,Nt as w,Oi as T,Ot as E,Pt as ee,Qi as D,Qt as O,Rt as k,S as A,T as j,Tt as M,Un as N,Ut as te,V as ne,Vn as P,Vt as re,X as ie,Xt as ae,Yi as oe,Yt as se,Z as ce,Zt as le,_i as ue,a as F,ai as de,an as fe,bn as pe,ci as me,ct as he,di as ge,en as _e,fi as ve,fn as ye,gi as be,ht as xe,i as Se,ia as Ce,ii as I,in as we,ji as Te,ki as Ee,li as De,lt as Oe,mi as ke,mt as Ae,n as je,nn as Me,oa as Ne,oi as Pe,pi as Fe,pt as Ie,qi as Le,qt as L,r as Re,ri as R,si as ze,sn as Be,st as Ve,ta as z,ui as He,un as Ue,v as We,vi as Ge,w as Ke,wi as qe,wr as B,wt as Je,x as Ye,xi as Xe,zt as Ze}from"./control-ui-foundation-Cydpkyqa.js";import{$n as Qe,$o as $e,$t as et,Ac as tt,As as nt,At as rt,B as it,Bi as at,Bn as ot,Br as st,Bt as ct,Cc as lt,Ci as ut,Cn as dt,Ct as ft,Dc as pt,Di as mt,Do as ht,Ec as gt,Ei as _t,Eo as vt,F as yt,Fa as bt,Fo as xt,Fr as St,G as Ct,Ga as wt,Gi as Tt,Go as Et,Gs as Dt,Hn as Ot,Hr as kt,Ht as At,I as jt,In as Mt,Io as Nt,It as Pt,J as Ft,Ja as It,Jn as Lt,Jo as Rt,Jt as zt,K as Bt,Ki as Vt,Ko as Ht,L as Ut,Ln as Wt,Lo as Gt,Lr as Kt,Ls as qt,Lt as Jt,M as Yt,Mi as Xt,Mo as Zt,Mr as Qt,N as $t,Ni as en,No as tn,Nr as nn,Ns as rn,Nt as an,Oi as on,Oo as sn,P as cn,Pn as ln,Po as un,Pr as dn,Q as fn,Qa as pn,Qo as mn,Qt as hn,R as gn,Rn as _n,Ro as vn,Rr as yn,Sc as bn,Si as xn,Ti as Sn,To as Cn,Ts as wn,U as Tn,Ui as En,Ur as Dn,Us as On,V as kn,Vi as An,Vn as jn,Vr as Mn,Vs as Nn,Vt as Pn,W as Fn,Wa as In,Wi as Ln,Wn as Rn,Wo as zn,Wr as Bn,X as Vn,Xa as Hn,Xo as Un,Xt as Wn,Y as V,Yo as Gn,Zo as Kn,Zt as qn,_ as Jn,_c as Yn,_i as Xn,a as Zn,ai as Qn,ar as $n,bc as er,bi as tr,c as nr,cc as rr,ci as ir,cn as ar,cs as or,d as sr,di as cr,do as lr,dt as ur,ea as dr,en as fr,er as pr,es as mr,et as hr,fc as gr,fi as _r,fo as vr,fr as yr,gc as br,gi as xr,gn as Sr,gt as Cr,hc as wr,hi as Tr,hr as Er,ht as Dr,i as Or,ii as kr,in as Ar,ir as jr,it as Mr,jo as Nr,k as Pr,kc as Fr,ki as Ir,l as Lr,lc as Rr,li as zr,mc as Br,mi as Vr,mr as Hr,mt as Ur,n as Wr,ni as Gr,nn as Kr,no as qr,nr as Jr,oa as Yr,on as Xr,or as Zr,os as Qr,ot as $r,pc as ei,pi as ti,pr as ni,qn as ri,qo as ii,qs as ai,qt as oi,ri as si,rn as ci,rr as li,sa as ui,si as di,sn as fi,ta as pi,tr as mi,ts as hi,u as gi,ui as _i,vc as vi,vi as yi,vn as bi,wc as xi,wi as Si,wn as Ci,ws as wi,xi as Ti,xt as Ei,ya as Di,yi as Oi,z as ki,za as Ai,zi as ji,zn as Mi,zr as Ni,zs as Pi}from"./control-ui-core-Rwzhj6nO.js";import{$ as Fi,K as Ii,X as H,at as U,nt as Li,q as W,st as Ri}from"./lit-runtime-CV_MH99K.js";import{A as zi,At as Bi,Ct as Vi,Dt as Hi,Et as Ui,F as Wi,Ft as Gi,Gt as Ki,H as qi,Ht as Ji,I as Yi,It as Xi,L as Zi,M as Qi,N as $i,Nt as ea,Ot as ta,P as na,Pt as ra,Qt as ia,Rt as aa,S as oa,St as sa,T as ca,Tt as la,U as ua,V as da,Vt as fa,W as pa,Wt as ma,Yt as G,_ as ha,b as ga,ct as _a,d as va,en as K,et as ya,f as ba,g as xa,h as Sa,i as Ca,jt as wa,kt as Ta,l as Ea,lt as Da,m as Oa,n as ka,o as Aa,p as ja,r as Ma,rn as Na,s as Pa,t as Fa,tt as Ia,u as La,ut as Ra,v as za,x as Ba,xt as Va,y as Ha,z as Ua,zt as Wa}from"./control-ui-core-vvcQQV2m.js";import{a as Ga,n as Ka,r as qa}from"./gateway-runtime-Bqqcp9-I.js";function Ja(){let e=window.webkit?.messageHandlers?.openclawWindowDrag;return e?.postMessage.bind(e)}function Ya(e){if(e.button!==0||e.defaultPrevented)return;for(let t of e.composedPath())if(t instanceof Element&&t.matches(Za))return;let t=Ja();if(t){try{t({type:`window-drag`})}catch{return}e.preventDefault()}}function Xa(e){if(e.target!==e.currentTarget||!(e.currentTarget instanceof HTMLElement))return;let t=Number.parseFloat(getComputedStyle(e.currentTarget).paddingTop);!Number.isFinite(t)||e.offsetY>t||Ya(e)}var Za;function Qa(){return(Qa=e((()=>{Za=`a, button, input, select, textarea, [role='button'], [contenteditable]`})))()}function $a(e){return Object.hasOwn(ko,e)}function eo(e){return{id:e,...ko[e]}}function to(e,t=``){return`${ue(t)}${ko[e].path}`}function no(e,t,n){let r=Ge(e),i=to(t,n);if(r===i)return``;let a=`${i}/`;return r.startsWith(a)&&r.slice(a.length)||null}function ro(e){return e.length===36&&Xe.test(e)}function io(e,t=``,n,r=12){let i=ro(e),a=pt(g(n),48).replace(/-+$/u,``),o=i?`${a?`${a}-`:``}${e.replaceAll(`-`,``).slice(0,r).toLowerCase()}`:e,s=encodeURIComponent(ro(o)?`person-${o}`:o).replaceAll(`.`,`%2E`);i||(s=s.replace(/-(?=[0-9a-f]{8,32}$)/u,`%2D`));let c=`${to(`activity`,t)}/${s}`;return{pathname:c,search:``,href:c}}function ao(e,t=``){let n=no(e,`activity`,t);if(!n||n.includes(`/`))return null;try{let e=decodeURIComponent(n);return!e.trim()||e===`.`||e===`..`?null:ro(e)?e:n.match(Po)?.[1]??e}catch{return null}}function oo(e,t=``){if(!Fe(e))throw Error(`Invalid Workboard board id.`);let n=encodeURIComponent(e).replaceAll(`.`,`%2E`);return`${to(`workboard`,t)}/${n}`}function so(e,t=null,n=``){if(!e||e.includes(`/`)||e===`.`||e===`..`)throw Error(`Invalid agent id for a route path.`);let r=encodeURIComponent(e).replaceAll(`.`,`%2E`),i=`${to(`agents`,n)}/${r}`;return t?`${i}/${t}`:i}function co(e,t=``){let n=no(e,`agents`,t);if(!n)return null;let r=n.split(`/`);if(r.length>2||!r[0])return null;let i;try{i=decodeURIComponent(r[0])}catch{return null}if(!i||i.includes(`/`)||i===`.`||i===`..`)return null;let a=r[1]??null,o=a&&tt(a)?a:null;return{agentId:i,panel:o??`files`,panelSegment:o,invalidPanel:a!==null&&o===null}}function lo(e,t=``){let n=to(`memory`,t);return e===`overview`?n:`${n}/${e}`}function uo(e,t=``){let n=no(e,`memory`,t);return n===``?`overview`:n===`memories`||n===`dreams`||n===`settings`?n:null}function fo(e,t=``){let n=to(`plugins`,t);return e===`installed`?n:`${n}/discover`}function po(e,t=``){let n=no(e,`plugins`,t);return n===``?`installed`:n===`discover`?`discover`:null}function mo(e){return e===`chat`||e===`dashboard`}function ho(e,t=``){let n=Ge(e),r=ue(t);if(r&&n!==r&&!n.startsWith(`${r}/`))return null;let i=n.slice(r.length);return i.startsWith(`/chat/`)?`chat`:i.startsWith(`/dashboard/`)?`dashboard`:l({pathname:n,basePath:r})?`chat`:null}function go(e,t=``){let n=no(e,`workboard`,t);if(!n||n.includes(`/`))return null;try{let e=decodeURIComponent(n);return Fe(e)?e:null}catch{return null}}function _o(e,t=``){return co(e,t)?`agents`:ao(e,t)?`activity`:go(e,t)?`workboard`:uo(e,t)?`memory`:po(e,t)?`plugins`:ho(e,t)}function vo(e,t=``){let n=Ge(e),r=ue(t);if(!(!r||n===r||n.startsWith(`${r}/`)))return null;let i=r?n.slice(r.length)||`/`:n;return Mo.get(i.toLowerCase())??_o(n,r)}function yo(e){if(jo.includes(e))return!0;let t=e.split(`/`).filter(Boolean);for(let e=1;e<=t.length;e+=1){let n=`/${t.slice(0,e).join(`/`)}`;if(jo.some(e=>e.startsWith(`${n}/`)))return!0}return!1}function bo(e){let t=Ee(e);if(t!==null)return t;let n=e.trim().endsWith(`/`),r=Ge(e);if(r.toLowerCase().endsWith(`/index.html`))return ue(r.slice(0,-11));if(r===`/`)return``;let i=r.split(`/`).filter(Boolean);for(let e=0;e<i.length;e+=1){let t=`/${i.slice(e).join(`/`)}`,n=Mo.has(t)?t:void 0,r=Object.values(Oo).find(e=>t===e||t.startsWith(`${e}/`)),a=_o(t);if(!n&&!r&&!a)continue;let o=i[e-1],s=r??(a?ko[a].path:null),c=(n??s??``).split(`/`)[1];if(e===0||o===c)return``;let l=`/${i.slice(0,e).join(`/`)}`;return yo(l)?``:l}if(!n||i.length===0)return``;let a=`/${i.join(`/`)}`;return yo(a)?``:a}function xo(e,t){return{pathname:to(e,t),search:``,hash:``}}var So,Co,wo,To,Eo,Do,Oo,ko,Ao,jo,Mo,No,Po;function q(){return(q=e((()=>{r(),qe(),be(),ve(),Fr(),gt(),So=`__openclawAgentPath`,Co=`__openclawActivityPath`,wo=`__openclawSessionPath`,To=`__openclawMemoryPath`,Eo=`__openclawPluginsPath`,Do=`__openclawWorkboardPath`,Oo={approval:`/approve`,question:`/ask`},ko={chat:{path:`/chat`},dashboard:{path:`/dashboard`},dashboards:{path:`/dashboards`},custodian:{path:`/custodian`},"new-session":{path:`/new`},activity:{path:`/activity`},meetings:{path:`/meetings`},apps:{path:`/apps`},portals:{path:`/portals`},agents:{path:`/settings/agents`,aliases:[`/agents`]},channels:{path:`/settings/channels`,aliases:[`/channels`]},connection:{path:`/settings/connection`},config:{path:`/settings/general`,aliases:[`/config`]},profile:{path:`/settings/profile`,aliases:[`/profile`]},communications:{path:`/settings/communications`,aliases:[`/communications`]},appearance:{path:`/settings/appearance`,aliases:[`/appearance`]},lobsterdex:{path:`/settings/lobsterdex`,aliases:[`/lobsterdex`]},device:{path:`/settings/device`},"device-permissions":{path:`/settings/device/permissions`},notifications:{path:`/settings/notifications`},security:{path:`/settings/security`},secrets:{path:`/settings/secrets`},advanced:{path:`/settings/advanced`},approvals:{path:`/settings/approvals`},automation:{path:`/settings/automation`,aliases:[`/automation`]},mcp:{path:`/settings/mcp`,aliases:[`/mcp`]},memory:{path:`/settings/memory`},talk:{path:`/settings/talk`},infrastructure:{path:`/settings/infrastructure`,aliases:[`/infrastructure`]},labs:{path:`/settings/labs`},updates:{path:`/settings/updates`},about:{path:`/settings/about`},"ai-agents":{path:`/settings/ai-agents`,aliases:[`/ai-agents`]},"model-setup":{path:`/settings/model-setup`,aliases:[`/model-setup`]},"model-providers":{path:`/settings/model-providers`,aliases:[`/model-providers`]},"memory-import":{path:`/memory-import`,aliases:[`/settings/memory-import`]},workboard:{path:`/workboard`},worktrees:{path:`/worktrees`,aliases:[`/settings/worktrees`]},sessions:{path:`/sessions`,aliases:[`/settings/sessions`]},usage:{path:`/usage`},debug:{path:`/debug`},logs:{path:`/logs`},"skill-workshop":{path:`/skills/workshop`},skills:{path:`/skills`},plugins:{path:`/settings/plugins`},cron:{path:`/automations`,aliases:[`/cron`]},tasks:{path:`/tasks`},devices:{path:`/settings/devices`,aliases:[`/nodes`]},"cloud-workers":{path:`/settings/cloud-workers`},plugin:{path:`/plugin`}},Ao=Object.keys(ko),jo=[],Mo=new Map;for(let e of Ao){let t=ko[e],n=`aliases`in t?[t.path,...t.aliases]:[t.path];for(let t of n){let n=Ge(t);jo.push(n),Mo.has(n)||Mo.set(n,e)}}No=`person`,Po=/(?:^|-)([0-9a-f]{8,32})$/u})))()}function Fo(){let e=typeof window>`u`?void 0:window.__OPENCLAW_CONTROL_UI_BASE_PATH__,t=typeof e==`string`?e:typeof document>`u`?null:document.documentElement.getAttribute(de);return t===null?null:ue(t)}function Io(e){let t=Fo(),n=t||bo(e);return[n,t??n]}function Lo(){return{pathname:window.location.pathname,search:window.location.search,hash:window.location.hash}}function Ro(e){return`${e.pathname}${e.search}${e.hash}`}function zo(){let e=new Set,t,n=()=>{if(t)return;let n=()=>{let t=Lo();for(let n of e)n(t)};window.addEventListener(`popstate`,n),t=()=>window.removeEventListener(`popstate`,n)},r=()=>{e.size===0&&(t?.(),t=void 0)};return{location:Lo,push:e=>window.history.pushState({},``,Ro(e)),replace:e=>window.history.replaceState({},``,Ro(e)),listen:t=>(e.add(t),n(),()=>{e.delete(t),r()})}}function Bo(){return(Bo=e((()=>{ge(),q()})))()}function Vo(e,t){let n=e!==`sw.js`&&typeof document<`u`?document.documentElement.getAttribute(Ce):null,r=n?`?v=${encodeURIComponent(n)}`:``;return`${ue(t??``)}/${e}${r}`}function Ho(e,t){return Vo(e,t?.resourceBasePath??(t?.pathname===void 0?Io(Uo())[1]:bo(t.pathname)))}function Uo(){return typeof window>`u`?`/`:window.location.pathname}function Wo(){return(Wo=e((()=>{Ne(),q(),Bo()})))()}function Go(e){return fs.has(e)}function Ko(e){return ps.has(e)}function qo(e){return ds.includes(e)}function Jo(e){if(typeof e!=`string`)return null;if(e.startsWith(`route:`)){let t=e.slice(6);return t===`workboard`?{type:`plugin`,key:`workboard/workboard`}:qo(t)?{type:`route`,route:t}:null}if(e.startsWith(`session:`)){let t=e.slice(8).trim();return t?{type:`session`,key:t}:null}if(e.startsWith(`workboard:`)){let t=e.slice(10).trim();return Fe(t)?{type:`plugin`,key:`workboard/board-${t}`}:null}if(e.startsWith(`plugin:`)){let t=e.slice(7);return/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}\/[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(t)?{type:`plugin`,key:t}:null}return null}function Yo(e){return e.type===`route`?`route:${e.route}`:e.type===`plugin`?`plugin:${e.key}`:`session:${e.key}`}function Xo(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){let e=Jo(n);if(!e)continue;let r=Yo(e);t.includes(r)||t.push(r)}return t}function Zo(e){let t=new Set(e.flatMap(e=>{let t=Jo(e);return t?.type===`route`?[t.route]:[]}));return ds.filter(e=>!t.has(e))}function Qo(e,t){let n=ia.getLocale();if(hs!==n&&(hs=n,gs=typeof Intl<`u`&&`Segmenter`in Intl?new Intl.Segmenter(n,{granularity:`word`}):null),!gs)return e.split(/[^\p{L}\p{N}]+/u).some(e=>e.startsWith(t));for(let n of gs.segment(e))if(n.isWordLike!==!1&&n.segment.startsWith(t))return!0;return!1}function $o(e,t){let n=D(e).normalize(`NFC`),r=D(t).normalize(`NFC`);return r?r.length>2?n.includes(r):Qo(n,r):!1}function es(e,t,n=null){return e===`device`||e===`device-permissions`?n!==null:e===`updates`?t||n!==null:t||vs.some(t=>t.routes.some(t=>t===e))}function ts(e,t=null){return(e?_s:vs).map(n=>({labelKey:n.labelKey===`nav.settingsGroupDevice`&&t?.snapshot?.device.platform!==`macos`?`nav.settingsGroupThisDevice`:n.labelKey,routes:n.routes.filter(n=>es(n,e,t))})).filter(e=>e.routes.length>0)}function ns(e){return Ss.has(e)}function rs(e){return xs[e]??e}function is(e){return Cs[e]?.[0]??`folder`}function as(e,t,n,r,i=!1,a=!1){if(i||!r)return;let o=n.currentTarget;if(!o)return;let s=()=>{e.delete(o);try{Promise.resolve(r(t)).catch(()=>void 0)}catch{}};if(a){os(e,n),s();return}e.has(o)||e.set(o,globalThis.setTimeout(s,50))}function os(e,t){let n=t.currentTarget;if(!n)return;let r=e.get(n);r!==void 0&&(globalThis.clearTimeout(r),e.delete(n))}function ss(e){let[,t]=Cs[e];return K(t)}function cs(e){let t=e.context.endsWith(`OpenClaw`)?e.context:`${e.context} — OpenClaw`;if(e.gatewayDisconnected){let n=e.queuedCount&&e.queuedCount>0?` · ${K(`connection.queuedCount`,{count:String(e.queuedCount)})}`:``;return`(${K(`connection.disconnectedTitle`)}${n}) ${t}`}return e.attentionCount&&e.attentionCount>0?`(${e.attentionCount}) ${t}`:t}function ls(e){return e===`custodian`?K(`nav.askOpenClaw`):ss(e)}function us(e){let t=Cs[e][2];return K(t)}var ds,fs,ps,ms,hs,gs,_s,vs,ys,bs,xs,Ss,Cs;function ws(){return(ws=e((()=>{ve(),G(),ds=[`dashboards`,`usage`,`cron`,`tasks`,`sessions`,`activity`,`meetings`,`plugins`,`apps`,`portals`],fs=new Set([`plugins`,`skills`,`skill-workshop`]),ps=new Set([`sessions`,`worktrees`]),ms=[`dashboards`,`cron`,`plugins`].map(e=>Yo({type:`route`,route:e})),hs=``,gs=null,_s=[{labelKey:null,routes:[`custodian`,`profile`,`appearance`,`notifications`]},{labelKey:`nav.settingsGroupDevice`,routes:[`device`,`device-permissions`]},{labelKey:`nav.settingsGroupConnections`,routes:[`connection`,`channels`,`communications`,`talk`,`devices`,`cloud-workers`]},{labelKey:`nav.settingsGroupAgents`,routes:[`agents`,`labs`,`model-providers`,`mcp`,`memory`,`automation`]},{labelKey:`nav.settingsGroupSecurity`,routes:[`security`,`secrets`,`approvals`]},{labelKey:`nav.settingsGroupSystem`,routes:[`infrastructure`,`advanced`,`debug`,`logs`,`updates`,`about`]}],vs=[{labelKey:null,routes:[`profile`,`appearance`,`notifications`]},{labelKey:`nav.settingsGroupDevice`,routes:[`device`,`device-permissions`]},{labelKey:`nav.settingsGroupConnections`,routes:[`connection`,`channels`,`talk`,`devices`]},{labelKey:`nav.settingsGroupAgents`,routes:[`agents`,`model-providers`,`memory`]},{labelKey:`nav.settingsGroupSecurity`,routes:[`approvals`]},{labelKey:`nav.settingsGroupSystem`,routes:[`advanced`,`debug`,`logs`,`updates`,`about`]}],ys=[`ai-agents`,`model-setup`,`lobsterdex`],bs=[`ai-agents`],xs={"ai-agents":`agents`,"model-setup":`model-providers`},Ss=new Set([..._s.flatMap(e=>e.routes),...ys]),Cs={agents:[`bot`,`tabs.agents`,`subtitles.agents`],activity:[`activity`,`tabs.activity`,`subtitles.activity`],meetings:[`book`,`tabs.meetings`,`subtitles.meetings`],apps:[`layoutGrid`,`tabs.apps`,`subtitles.apps`],portals:[`monitor`,`tabs.portals`,`subtitles.portals`],approvals:[`badgeCheck`,`tabs.approvals`,`subtitles.approvals`],workboard:[`kanban`,`tabs.workboard`,`subtitles.workboard`],worktrees:[`folder`,`tabs.worktrees`,`subtitles.worktrees`],channels:[`link`,`tabs.channels`,`subtitles.channels`],connection:[`radio`,`tabs.connection`,`subtitles.connection`],sessions:[`fileText`,`tabs.sessions`,`subtitles.sessions`],usage:[`coins`,`tabs.usage`,`subtitles.usage`],cron:[`calendarClock`,`tabs.cron`,`subtitles.cron`],tasks:[`listChecks`,`tabs.tasks`,`subtitles.tasks`],skills:[`zap`,`tabs.skills`,`subtitles.skills`],plugins:[`puzzle`,`tabs.plugins`,`subtitles.plugins`],"skill-workshop":[`wrench`,`tabs.skillWorkshop`,`subtitles.skillWorkshop`],device:[`monitor`,`tabs.device`,`subtitles.device`],"device-permissions":[`shieldCheck`,`tabs.devicePermissions`,`subtitles.devicePermissions`],devices:[`monitorSmartphone`,`tabs.devices`,`subtitles.devices`],"cloud-workers":[`server`,`tabs.cloudWorkers`,`subtitles.cloudWorkers`],chat:[`messageSquare`,`tabs.chat`,`subtitles.chat`],dashboard:[`layoutDashboard`,`tabs.chat`,`subtitles.chat`],dashboards:[`layoutDashboard`,`tabs.dashboards`,`subtitles.dashboards`],custodian:[`lobster`,`tabs.custodian`,`subtitles.custodian`],config:[`settings`,`nav.settings`,`subtitles.config`],profile:[`circleUser`,`tabs.profile`,`subtitles.profile`],communications:[`send`,`tabs.communications`,`subtitles.communications`],appearance:[`palette`,`tabs.appearance`,`subtitles.appearance`],lobsterdex:[`bug`,`tabs.lobsterdex`,`subtitles.lobsterdex`],automation:[`terminal`,`tabs.automation`,`subtitles.automation`],mcp:[`wrench`,`tabs.mcp`,`subtitles.mcp`],memory:[`book`,`tabs.memory`,`subtitles.memory`],talk:[`mic`,`tabs.talk`,`subtitles.talk`],infrastructure:[`globe`,`tabs.infrastructure`,`subtitles.infrastructure`],labs:[`flaskConical`,`tabs.labs`,`subtitles.labs`],updates:[`download`,`tabs.updates`,`subtitles.updates`],about:[`fileText`,`tabs.about`,`subtitles.about`],"ai-agents":[`brain`,`tabs.aiAgents`,`subtitles.aiAgents`],"model-setup":[`spark`,`tabs.modelSetup`,`subtitles.modelSetup`],"model-providers":[`box`,`routeTitles.modelProviders`,`subtitles.modelProviders`],"memory-import":[`download`,`tabs.memoryImport`,`subtitles.memoryImport`],notifications:[`bell`,`routeTitles.notifications`,`subtitles.notifications`],security:[`shieldCheck`,`tabs.security`,`subtitles.security`],secrets:[`key`,`tabs.secrets`,`secretsStore.hint`],advanced:[`fileCode`,`routeTitles.advanced`,`subtitles.advanced`],debug:[`bug`,`tabs.debug`,`subtitles.debug`],logs:[`scrollText`,`tabs.logs`,`subtitles.logs`],plugin:[`puzzle`,`tabs.plugin`,`subtitles.plugin`],"new-session":[`plus`,`newSession.title`,`newSession.hint`]}})))()}function Ts(e){let t=new URLSearchParams(e).get(`onboarding`);return t!==null&&/^(?:1|true|yes|on)$/iu.test(t.trim())}function Es(){return(Es=e((()=>{})))()}function Ds(e,t){let n=new WebSocket(e),r=!0,i,a,o=()=>{r=!1,a!==void 0&&(clearTimeout(a),a=void 0)};return n.addEventListener(`open`,()=>{o(),t.open()}),n.addEventListener(`message`,e=>t.message(String(e.data??``))),n.addEventListener(`close`,e=>{o(),t.close(e.code,e.reason||i||``)}),n.addEventListener(`error`,()=>{o(),i||t.error(Error(`websocket error`))}),a=setTimeout(()=>{if(a=void 0,r){r=!1,i=`gateway websocket opening timed out after ${k}ms`;try{t.error(Error(i))}finally{n.close()}}},k),{isOpen:()=>n.readyState===WebSocket.OPEN,send:e=>n.send(e),close:(e,t)=>{o(),n.close(e===1008?4008:e,t)}}}function Os(){return(Os=e((()=>{Ze()})))()}async function ks(e){let{deviceIdentity:t}=e;if(!t)return;if(e.connectChallengeTs===null)throw Error(`gateway connect challenge timestamp invalid`);let n=e.connectChallengeTs??Date.now(),r=e.connectNonce??``,i=ye({deviceId:t.deviceId,clientId:e.client.id,clientMode:e.client.mode,role:e.role,scopes:e.scopes,signedAtMs:n,token:e.authToken??null,nonce:r}),a=await lr(t.privateKey,i);return{id:t.deviceId,publicKey:t.publicKey,signature:a,signedAt:n,nonce:r}}function As(){return(As=e((()=>{Hn()})))()}function js(e,t){return fe(t)===_e.PROTOCOL_MISMATCH||!e?.toLowerCase().includes(`protocol mismatch`)?t:{code:_e.PROTOCOL_MISMATCH,clientMinProtocol:4,clientMaxProtocol:4,...t&&typeof t==`object`&&!Array.isArray(t)?t:{}}}function Ms(e){return fe(e?.details)}function Ns(){return(Ns=e((()=>{we()})))()}function Ps(){return(typeof window<`u`?window:void 0)?.isSecureContext===!0}function Fs(e){try{let t=new URL(e,window.location.href);return Cn(t.hostname)||t.host===new URL(window.location.href).host}catch{return!1}}function Is(e){let{gatewayCode:t,message:n,details:r,retryable:i,retryAfterMs:a}=e;return{code:t,message:n,details:r,retryable:i,retryAfterMs:a}}function Ls(e){let t=e&&typeof e==`object`&&`name`in e?e.name:void 0;return typeof t==`string`&&t.trim()?t:void 0}function Rs(e){let t=Ls(e)?.toLowerCase(),n=vt(e).toLowerCase();return t===`securityerror`||n.includes(`security error`)||n.includes(`mixed content`)||n.includes(`insecure websocket`)}function zs(e,t){let n=Rs(e),r=vt(e),i=t.trim().toLowerCase().startsWith(`ws://`),a={code:n?Js:qs,browserErrorName:Ls(e),browserMessage:r};return n?{code:Js,message:`Browser refused the Gateway WebSocket for security reasons.`+(i?` Use wss:// when the Control UI is served over HTTPS/Tailscale Serve, or open the loopback dashboard at http://127.0.0.1:18789.`:` Check the Gateway WebSocket URL and browser security policy.`),details:a}:{code:qs,message:`Could not create the Gateway WebSocket: ${r}`,details:a}}async function Bs(e){if(!e||typeof crypto>`u`||!crypto.subtle)return``;try{let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e));return Array.from(new Uint8Array(t),e=>e.toString(16).padStart(2,`0`)).join(``)}catch{return``}}var Vs,Hs,Us,Ws,Gs,Ks,qs,Js,Ys,Xs,Zs,Qs;function $s(){return($s=e((()=>{ae(),we(),f(),y(),te(),Ie(),Ze(),w(),ge(),Oe(),sn(),Hn(),wt(),Os(),As(),Ns(),I(),Vs=class extends re{constructor(e){let t=js(e.message,e.details);super({...e,details:t,message:Me({message:e.message,details:t})}),this.name=`GatewayRequestError`}},Hs=`operator`,Us=[`operator.admin`,`operator.read`,`operator.write`,`operator.approvals`,`operator.questions`,`operator.pairing`],Ws=4008,Gs=4013,Ks=1006,qs=`BROWSER_WEBSOCKET_CONSTRUCTOR_ERROR`,Js=`BROWSER_WEBSOCKET_SECURITY_ERROR`,Ys=3e4,Xs=1e3,Zs=class{constructor(e){this.opts=e,this.scopeUpgradeRuntime=null,this.inboundActivitySeq=0,this.lastInboundActivityAtMs=null,this.maxInboundSilenceMs=null,this.tickWatchTimer=null,this.pendingDeviceTokenRetry=!1,this.deviceTokenRetryBudgetUsed=!1,this.recovery={value:``,resolved:!1,generation:0},this.scopeUpgradeBinding=null,this.client=new m({createSocket:e=>{this.maxPayloadBytes=void 0;let t=Ds(this.opts.url,e);return{...t,send:e=>{if(this.maxPayloadBytes!==void 0&&new TextEncoder().encode(e).byteLength>this.maxPayloadBytes)throw new Qs;t.send(e)}}},createRequestId:In,createRequestError:e=>new Vs({code:e.code??`UNAVAILABLE`,message:e.message??`request failed`,details:e.details,retryable:e.retryable,retryAfterMs:e.retryAfterMs}),buildConnectPlan:({nonce:e,challengeTs:t,generation:n})=>this.buildConnectPlan(e,t,n),buildConnectParams:e=>e.params,onConnectHello:(e,t)=>this.handleConnectHello(e,t.plan),onHello:e=>this.opts.onHello?.(e),onConnectFailure:(e,t)=>(this.client.recordTiming(`failed`,t.generation,t.plan,{errorCode:e.code}),this.handleConnectFailure(e,t.plan)),resolveClose:e=>this.resolveClose(e),onClose:(e,t)=>{this.recovery={...this.recovery,generation:e.generation+1,resolved:!1},this.stopTickWatch(),this.scopeUpgradeBinding=null;let n=e.connectFailure?.error;this.client.recordTiming(`failed`,e.generation,void 0,{errorCode:n instanceof Vs?n.code:`SOCKET_CLOSED`}),t.notify&&this.opts.onClose?.({code:e.code,reason:e.reason,error:n instanceof Vs?Is(n):void 0,willRetry:t.retry})},onSocketFactoryError:e=>this.handleSocketFactoryError(e),onEvent:e=>this.opts.onEvent?.(e),onGap:e=>this.opts.onGap?.(e),onActivity:()=>{this.inboundActivitySeq+=1,this.lastInboundActivityAtMs=Date.now()},onTiming:({plan:e,detail:t,...n})=>{this.opts.onConnectTiming?.({...n,...e?this.connectPlanTimingPayload(e):{},...t&&typeof t==`object`?t:{}})},onRequestTiming:e=>this.opts.onRequestTiming?.(e),onCallbackError:(e,t)=>console.error(`[gateway] ${e} handler error:`,t),handshake:{mode:`fallback`,timeoutMs:750},reconnect:{initialMs:800,multiplier:1.7,maxMs:15e3},nowMs:()=>typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now()})}get instanceId(){return this.opts.instanceId}get gatewayUrl(){return this.opts.url}start(){this.client.start()}stop(){this.stopTickWatch(),this.recovery={...this.recovery,generation:this.recovery.generation+1,resolved:!1},this.client.stop(),this.cancelScopeUpgrade(),this.scopeUpgradeBinding=null,this.pendingDeviceTokenRetry=!1,this.deviceTokenRetryBudgetUsed=!1}get connected(){return this.client.connected}get needsWakeReconnect(){return!this.client.connected||this.lastInboundActivityAtMs!==null&&this.maxInboundSilenceMs!==null&&Date.now()-this.lastInboundActivityAtMs>this.maxInboundSilenceMs}get recoveryScope(){return this.recovery.value}get recoveryScopeReady(){return this.recovery.resolved}get scopeUpgradeReady(){return this.connected&&this.scopeUpgradeBinding!==null}connectPlanTimingPayload(e){return{secureContext:Ps(),hasDeviceIdentity:!!e.deviceIdentity,hasDevice:!!e.params.device,hasAuthToken:!!e.selectedAuth.authToken,hasBootstrapToken:!!e.selectedAuth.authBootstrapToken,hasDeviceToken:!!(e.selectedAuth.authDeviceToken??e.selectedAuth.resolvedDeviceToken),hasPassword:!!e.selectedAuth.authPassword}}async buildConnectPlan(e,t,n){this.recovery={...this.recovery,generation:n,resolved:!1};let r=Hs,i=Intl.DateTimeFormat().resolvedOptions().timeZone||void 0,a={id:this.opts.clientName??M.CONTROL_UI,version:this.opts.clientVersion??`control-ui`,buildId:this.opts.clientBuildId,platform:this.opts.platform??navigator.platform??`web`,deviceFamily:this.opts.deviceFamily,mode:this.opts.mode??Je.WEBCHAT,instanceId:this.opts.instanceId,...i?{timeZone:i}:{}},o=this.opts.token?.trim()||void 0,s={authToken:o,authPassword:this.opts.password?.trim()||void 0},c=await qr().catch(()=>null);this.client.recordTiming(`device-identity-ready`,n,void 0,{secureContext:Ps(),hasDeviceIdentity:c!==null}),c&&(s=this.selectConnectAuth({role:r,deviceId:c.deviceId}));let l=le({requestedScopes:s.authBootstrapToken?this.opts.bootstrapProfile===`owner`?[...he]:[...Ve]:this.opts.scopes,usingStoredDeviceToken:s.usingStoredDeviceToken,storedScopes:s.storedScopes,defaultScopes:Us}),u={generation:n,params:{minProtocol:4,maxProtocol:4,client:a,role:r,scopes:l,device:await ks({deviceIdentity:c,client:a,role:r,scopes:l,authToken:s.signatureToken,connectNonce:e,connectChallengeTs:t}),caps:[`agent-kind`,`approvals`,`task-suggestions`,`terminal-offset-seq`,`terminal-session-metadata`,`tool-events`,`inline-widgets`,`ui-commands`,`usage-refreshing`],auth:se(s),userAgent:navigator.userAgent,locale:navigator.language},explicitGatewayToken:o,selectedAuth:s,deviceIdentity:c};return this.pendingDeviceTokenRetry&&u.selectedAuth.authDeviceToken&&(this.pendingDeviceTokenRetry=!1),u}handleConnectHello(e,t){if(this.maxPayloadBytes=e.policy?.maxPayload,this.startTickWatch(e),this.pendingDeviceTokenRetry=!1,this.deviceTokenRetryBudgetUsed=!1,this.opts.bootstrapToken=void 0,this.opts.bootstrapProfile=void 0,this.scopeUpgradeBinding=t.deviceIdentity&&{clientId:t.params.client.id,deviceId:t.deviceIdentity.deviceId,role:t.params.role??Hs},e?.auth?.deviceToken&&t.deviceIdentity){let n=e.auth.role??t.params.role??Hs,r=n===t.params.role&&e.auth.deviceToken===t.selectedAuth.storedToken?t.selectedAuth.storedScopes??e.auth.scopes??[]:e.auth.scopes??[];vr({deviceId:t.deviceIdentity.deviceId,gatewayUrl:this.opts.url,role:n,token:e.auth.deviceToken,scopes:r})}this.resolveRecoveryScope(e,t)}async resolveRecoveryScope(e,t){let n=e.auth?.recoveryScope,r=await Bs(e.auth?.deviceToken??t.selectedAuth.authDeviceToken??t.selectedAuth.resolvedDeviceToken??t.selectedAuth.authToken),i=n&&e.auth?.recoveryMigrationAllowed===!0&&r?(await R(async()=>{let{default:e}=await import(`./session-placement-recovery-migration.runtime-D-Ocs6wH.js`);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),import.meta.url)).default:void 0;t.generation!==this.recovery.generation||!this.client.connected||(i?.(this.opts.url,r,n),this.recovery.value=n??r,this.recovery.resolved=!0,this.opts.onRecoveryScopeChange?.())}startTickWatch(e){this.stopTickWatch();let t=e.policy?.tickIntervalMs,n=i(typeof t==`number`&&Number.isFinite(t)&&t>0?t:Ys,{minMs:Xs});this.maxInboundSilenceMs=n*2,this.lastInboundActivityAtMs=Date.now(),this.tickWatchTimer=setInterval(()=>{this.needsWakeReconnect&&this.forceReconnect(`tick timeout`)},n)}stopTickWatch(){this.tickWatchTimer!==null&&(clearInterval(this.tickWatchTimer),this.tickWatchTimer=null),this.lastInboundActivityAtMs=null,this.maxInboundSilenceMs=null}handleConnectFailure(e,n){let r=e instanceof Vs?Ms(e):null;t({retryBudgetUsed:this.deviceTokenRetryBudgetUsed,currentDeviceToken:n.selectedAuth.authDeviceToken,explicitToken:n.explicitGatewayToken,storedToken:n.selectedAuth.storedToken,trustedEndpoint:!!n.deviceIdentity&&Fs(this.opts.url),errorDetails:e instanceof Vs?e.details:void 0})&&(this.pendingDeviceTokenRetry=!0,this.deviceTokenRetryBudgetUsed=!0),n.selectedAuth.storedToken&&(n.selectedAuth.resolvedDeviceToken===n.selectedAuth.storedToken||n.selectedAuth.authDeviceToken===n.selectedAuth.storedToken)&&n.deviceIdentity&&r===_e.AUTH_DEVICE_TOKEN_MISMATCH&&It({deviceId:n.deviceIdentity.deviceId,gatewayUrl:this.opts.url,role:n.params.role??Hs});let i=xe(e);return Ae(e)?{closeCode:Gs,closeReason:`gateway starting`,reconnectDelayMs:i??void 0}:{closeCode:Ws,closeReason:`connect failed`}}selectConnectAuth(e){let t=pn({deviceId:e.deviceId,gatewayUrl:this.opts.url,role:e.role}),n=t?.scopes??[],r=e.role!==Hs||n.includes(`operator.read`)||n.includes(`operator.write`)||n.includes(`operator.admin`);return O({token:this.opts.token,bootstrapToken:this.opts.bootstrapToken,password:this.opts.password,storedToken:r?t?.token:void 0,storedScopes:t?.scopes,pendingDeviceTokenRetry:this.pendingDeviceTokenRetry,trustedDeviceTokenRetry:Fs(this.opts.url),preferBootstrapToken:!0})}async request(e,t,n){return await this.client.request(e,t,n)}async requestScopeUpgrade(e={}){let t=this.scopeUpgradeBinding;if(!this.connected||!t)throw Error(`scope upgrade requires a connected browser device`);return(await this.loadScopeUpgradeRuntime()).requestScopeUpgrade({binding:t,scopes:Us,onPending:e.onPending})}cancelScopeUpgrade(){this.scopeUpgradeRuntime?.then(e=>e.cancelScopeUpgrade()).catch(()=>void 0)}loadScopeUpgradeRuntime(){return this.scopeUpgradeRuntime??=R(async()=>{let{createGatewayScopeUpgradeRuntime:e}=await import(`./gateway-scope-upgrade.runtime-COKPg-Cs.js`);return{createGatewayScopeUpgradeRuntime:e}},__vite__mapDeps([17,2,4,3,5,6,7,8]),import.meta.url).then(({createGatewayScopeUpgradeRuntime:e})=>e({gatewayUrl:this.opts.url,request:(e,t,n)=>this.request(e,t,n),reconnect:()=>this.forceReconnect(`scope upgrade approved`)})).catch(e=>{throw this.scopeUpgradeRuntime=null,e})}addEventListener(e){return this.client.addEventListener(e)}forceReconnect(e){this.client.closeSocket(4e3,e)}resolveClose(e){let t=e.connectFailure?.error,n=e.connectFailure?.reconnectDelayMs;if(n!==void 0)return{retry:!0,notify:!0,reconnectDelayMs:n,pendingError:t};let r=t instanceof Vs?Is(t):void 0;return{retry:Ms(r)===_e.AUTH_TOKEN_MISMATCH?this.pendingDeviceTokenRetry:!ee({details:r?.details,protocolMismatchIsTerminal:!0}),notify:!0,pendingError:t}}handleSocketFactoryError(e){let t=zs(e,this.opts.url);this.pendingDeviceTokenRetry=!1;try{this.opts.onClose?.({code:Ks,reason:t.code===Js?`security error`:`websocket error`,error:t,willRetry:!1})}catch(e){console.error(`[gateway] close handler error:`,e)}}},Qs=class extends Error{constructor(){super(`Request exceeds the Gateway payload limit. Shorten the message or remove one or more attachments and retry.`),this.name=`GatewayPayloadLimitError`}}})))()}function ec(e,t,n,r=``,i={}){return o({namespace:e,sessionKey:n,fallbackAgentId:t,basePath:r,displayName:i.displayName??void 0,exactKey:i.exactKey,mainKey:i.mainKey??void 0,shortIdLength:i.shortIdLength})}function tc(){return(tc=e((()=>{qe()})))()}function nc(e,t,n){return e?!e.scopes||ce({role:e.role??`operator`,requestedScopes:[t],allowedScopes:e.scopes}):n}function J(e){let t=e?.hello?.auth??null;return{canWrite:rc(t),canAdmin:ac(t),canPair:oc(t),canReviewApprovals:!t||sc(t),canGrantApprovals:sc(t)}}function rc(e){return nc(e,`operator.write`,!0)}function ic(e){return nc(e,`operator.read`,!0)}function ac(e){return nc(e,`operator.admin`,!0)}function oc(e){return nc(e,`operator.pairing`,!1)}function sc(e){return nc(e,`operator.approvals`,!1)}function cc(){return(cc=e((()=>{ie()})))()}function lc(e,t,n){let r=vo(t.pathname,n),i=r?e.getRoute(r):null;i&&Promise.resolve(i.component()).catch(()=>void 0)}function uc(e,t,n){return e===`workboard`?jr(t,n).canonicalLocation??t:t}function dc(){let e=ke({routes:vc});return{...e,navigate:(t,n,r,i)=>e.navigate(t,n,r,i?uc(t,i,n.basePath):void 0),routeIdFromPath:vo}}function fc(e,t){if(ao(e,t))return[`activity`,Co,e];if(co(e,t))return[`agents`,So,e];if(go(e,t))return[`workboard`,Do,e];let n=uo(e,t);if(n&&n!==`overview`)return[`memory`,To,e];if(po(e,t)===`discover`)return[`plugins`,Eo,e];let r=ho(e,t);return r?[r,wo,e]:null}function pc(e,t){let n=fc(e.pathname,t);if(!n)return e;let[r,i,a]=n,o=new URLSearchParams(e.search);return o.set(i,a),{...e,pathname:to(r,t),search:`?${o.toString()}`}}function mc(e,t){return e.pathname===t.pathname&&e.search===t.search&&e.hash===t.hash}function hc(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`notFound`}async function gc(e){try{await e}catch(e){if(!hc(e))throw e}}async function _c(e,t,n,r){let i=t.location(),a=uc(vo(i.pathname,n),i,n);mc(i,a)||(t.replace(a),i=t.location());let o=co(i.pathname,n);o?.invalidPanel&&(t.replace({...i,pathname:so(o.agentId,null,n)}),i=t.location()),vo(i.pathname,n)===null&&(t.replace({...i,pathname:e.pathForRoute(`chat`,n)}),i=t.location());let s=fc(i.pathname,n);await gc(e.start({location:()=>pc(t.location(),n),push:e=>t.push(e),replace:e=>t.replace(e),listen:i=>t.listen(a=>{let o=uc(vo(a.pathname,n),a,n);mc(a,o)||t.replace(o);let s=fc(o.pathname,n);if(s){e.navigate(s[0],r,{history:`none`},o).catch(e=>{console.error(`[openclaw] Dynamic route navigation failed`,e)});return}i(o)})},n,r)),s&&mc(t.location(),i)&&await gc(e.navigate(s[0],r,{history:`none`},i))}var vc;function yc(){return(yc=e((()=>{be(),q(),Yn(),wr(),mr(),mn(),Un(),Rt(),Ht(),zn(),Gt(),xt(),tn(),Nr(),Xt(),on(),Sn(),ut(),Ti(),Oi(),Xn(),Tr(),ti(),cr(),zr(),di(),Gr(),Dn(),Mn(),Ni(),Kt(),dn(),Qt(),Hr(),yr(),$n(),li(),mi(),Qe(),vc=[...ii,Zt,ir,br,xr,en,Kn,kt,hi,$e,Gn,Et,Nt,xn,vi,tr,...vn,_i,_r,Vr,st,Jr,pr,St,yn,Zr,Ir,yi,nn,Er,Bn,un,ni,_t,mt,Si,si]})))()}function bc(e,t){return t?.status===`pending`&&t.module===void 0&&t.error===void 0&&e?e:t??e}function xc(e){return{status:e.status,active:e.matches[0],pending:e.pendingMatches[0]}}function Sc(){return{status:`idle`,active:void 0,pending:void 0,settled:void 0,showPending:!1}}var Cc,wc;function Tc(){return(Tc=e((()=>{Cc=1e3,wc=class{constructor(e,t={}){this.invalidate=e,this.connected=!1,this.selection=Sc(),this.snapshotValue=Sc(),this.showPending=!1,this.notFoundActive=!1,this.notFoundDeclined=!1,this.notFoundQueued=!1,this.notFoundGeneration=0,this.notFoundRecoveryReady=!0,this.pendingDelayMs=t.pendingDelayMs??Cc}get snapshot(){return this.snapshotValue}setInputs(e){this.onNotFound=e.onNotFound;let t=e.notFoundRecoveryReady??!0,n=!this.notFoundRecoveryReady&&t&&this.notFoundDeclined;if(this.notFoundRecoveryReady=t,this.router===e.router){n&&this.selection.status===`notFound`&&(this.cancelNotFoundEffect(),this.updateNotFoundEffect(this.selection.status));return}if(this.detachSource(),this.router=e.router,this.settled=void 0,this.connected){this.attachSource();return}let r=e.router?xc(e.router.getState()):Sc();this.applySelection(r)}connect(){this.connected||(this.connected=!0,this.attachSource(!1),this.invalidate())}disconnect(){this.connected&&(this.connected=!1,this.detachSource())}attachSource(e=!0){let t=this.router;if(!this.unsubscribe){if(!t){this.applySelection(Sc(),e);return}this.applySelection(xc(t.getState()),e),this.unsubscribe=t.subscribe(()=>this.applySelection(xc(t.getState())))}}detachSource(){this.unsubscribe?.(),this.unsubscribe=void 0,this.clearPendingTimer(),this.pendingMatchId=void 0,this.showPending=!1,this.cancelNotFoundEffect()}applySelection(e,t=!0){if(this.selection=e,e.status===`idle`)this.settled=void 0;else{let t=bc(e.active,e.pending);t?.status===`success`&&(this.settled=t)}let n=e.pending;n?.status===`pending`&&n.module===void 0&&n.error===void 0&&!e.active?this.pendingMatchId===n.id?this.connected&&!this.showPending&&this.pendingTimer===void 0&&this.schedulePendingFallback(n.id):(this.clearPendingTimer(),this.pendingMatchId=n.id,this.showPending=!1,this.schedulePendingFallback(n.id)):(this.clearPendingTimer(),this.pendingMatchId=void 0,this.showPending=!1),this.publish({...e,settled:this.settled,showPending:this.showPending},t),this.updateNotFoundEffect(e.status)}schedulePendingFallback(e){this.connected&&(this.pendingTimer=globalThis.setTimeout(()=>{this.pendingTimer=void 0;let t=this.selection.pending,n=t?.id===e&&t.status===`pending`&&t.module===void 0&&t.error===void 0&&!this.selection.active;!this.connected||this.pendingMatchId!==e||!n||(this.showPending=!0,this.publish({...this.selection,settled:this.settled,showPending:!0}))},this.pendingDelayMs))}updateNotFoundEffect(e){if(e!==`notFound`){(this.notFoundActive||this.notFoundQueued)&&this.cancelNotFoundEffect();return}if(!this.connected||this.notFoundActive)return;this.notFoundActive=!0,this.notFoundQueued=!0;let t=++this.notFoundGeneration;queueMicrotask(()=>{!this.connected||t!==this.notFoundGeneration||this.selection.status!==`notFound`||(this.notFoundQueued=!1,this.onNotFound?.()===!1&&(this.notFoundDeclined=!0))})}cancelNotFoundEffect(){this.notFoundGeneration+=1,this.notFoundActive=!1,this.notFoundDeclined=!1,this.notFoundQueued=!1}publish(e,t=!0){let n=this.snapshotValue;(n.status!==e.status||n.active!==e.active||n.pending!==e.pending||n.settled!==e.settled||n.showPending!==e.showPending)&&(this.snapshotValue=e,t&&this.connected&&this.invalidate())}clearPendingTimer(){this.pendingTimer!==void 0&&(globalThis.clearTimeout(this.pendingTimer),this.pendingTimer=void 0)}}})))()}function Ec(e,t){let n={canReload:e,onBlocked:t};return Oc.add(n),()=>void Oc.delete(n)}function Dc(e=!1){let t=[...Oc].find(e=>!e.canReload());return t&&e&&t.onBlocked(),!t}var Oc;function kc(){return(kc=e((()=>{Oc=new Set})))()}function Ac(e){return e instanceof Error&&Hc.test(e.message)}function jc(){let e=new URL(window.location.href);e.searchParams.set(`openclaw_mount_recovery`,String(Date.now())),window.location.replace(e.href)}function Mc(e){if(Gc)return Gc.promise;let t=(async()=>{let e=new AbortController,t=setTimeout(()=>e.abort(),Vc);try{return(await fetch(window.location.href,{method:`HEAD`,cache:`no-store`,signal:e.signal})).ok}catch{return!1}finally{clearTimeout(t)}})().finally(()=>{Gc?.promise===t&&(Gc=null)});return Gc={buildId:e,promise:t},t}function Nc(e,t){if(!e)return!1;try{return e.setItem(zc,t),!0}catch{return!1}}async function Pc(e={}){if(!Dc())return!1;let t=e.storage===void 0?xi():e.storage,n=e.buildId??sa.buildId;try{if(t?.getItem(zc)===n)return!1}catch{}let r=e.now?.()??Date.now(),i=t??Wc,a=Uc.get(i)??[new Map,n],o=a[0];for(let[e,t]of o)r-t>=Bc&&o.delete(e);if(o.has(n))return!1;o.set(n,r),a[1]=n,Uc.set(i,a);let s=!!(Gc&&Gc.buildId!==n);if(!await Mc(n)&&(!s||!await Mc(n)))return!1;let c=e.reload??jc;return!Dc()||a[1]!==n||!Nc(t,n)?!1:(a[1]=null,c(),!0)}async function Fc(e,t){let n,r=new Promise(e=>{n=setTimeout(()=>e(!1),t)});try{return await Promise.race([e(),r])}finally{clearTimeout(n)}}async function Ic(e={}){if(e.canReload?.()===!1||!Dc(!0))return!1;let t=e.now??Date.now,n=e.probe??Mc,r=e.wait??(e=>new Promise(t=>{setTimeout(t,e)})),i=e.intervalMs??qc,a=t()+(e.timeoutMs??Kc);for(let o=0;;o+=1){let s=a-t();if(o>0&&s<=0)return!1;if(s>0?await Fc(n,s):await n()){if(e.canReload?.()===!1||!Dc(!0))return!1;let t=e.storage===void 0?xi():e.storage,n=t??Wc,r=e.reload??jc,i=Uc.get(n)??[new Map,sa.buildId];Uc.set(n,i);let a=i[1];return a!==null&&(i[1]=null,Nc(t,a),r(),!0)}if(t()>=a)return!1;await r(i)}}function Lc(e=Pc){let t=t=>{let n=t.payload;Ac(n)&&e()};return window.addEventListener(`vite:preloadError`,t),()=>window.removeEventListener(`vite:preloadError`,t)}function Rc(e={}){let t=e.isCssApplied??(()=>getComputedStyle(document.documentElement).getPropertyValue(`--openclaw-css-ok`).trim()===`1`),n=e.schedule??Pc,r=e.retry??(()=>Ic({timeoutMs:0})),i=!1,a=!1,o=null,s=()=>{window.removeEventListener(`load`,u),window.removeEventListener(`error`,d,!0)},c=()=>{if(a||o)return;o=document.createElement(`div`),o.role=`alert`,o.style.cssText=`position:fixed;inset:0 0 auto;z-index:2147483647;padding:12px;text-align:center;background:#1f2937;color:#fff;font:14px system-ui`;let e=document.createElement(`button`);e.textContent=K(`common.reload`),e.addEventListener(`click`,()=>void r()),o.append(K(`lazyView.stylesFailed`),` `,e),document.body.append(o)},l=async()=>{i||a||(i=!0,s(),await n()||c())};function u(){if(t()){s();return}l()}function d(e){let t=e.target;!(t instanceof HTMLLinkElement)||!t.relList.contains(`stylesheet`)||l()}return window.addEventListener(`error`,d,!0),document.readyState===`complete`?u():window.addEventListener(`load`,u,{once:!0}),()=>{a=!0,s(),o?.remove(),o=null}}var zc,Bc,Vc,Hc,Uc,Wc,Gc,Kc,qc;function Jc(){return(Jc=e((()=>{la(),G(),kc(),zc=`openclaw.controlUi.staleChunkReloadBuildId`,Bc=5e3,Vc=3e3,Hc=/importing a module script failed|failed to fetch dynamically imported module|error loading dynamically imported module|unable to preload css/i,Uc=new WeakMap,Wc={},Gc=null,Kc=3e4,qc=1e3})))()}function Yc(e){return typeof e==`object`&&!!e&&`render`in e&&typeof e.render==`function`}function Xc(e,t){let n=globalThis.performance?.now()??0,r=t(),i=Math.round((globalThis.performance?.now()??n)-n);return i>=16&&console.debug(`[openclaw] routed render`,{routeId:e,durationMs:i}),r}function Zc(e){if(!e)return()=>{};let t=e.textContent;return e.disabled=!0,e.textContent=K(`lazyView.reloading`),()=>{e.disabled=!1,e.textContent=t}}function Qc(e,t,n,r,i){let a=Ac(n);a&&Pc();let o=()=>{t!==void 0&&e.revalidate(t,r).catch(()=>void 0)};return wa({error:n,onRetry:e=>{if(!a){o();return}let t=Zc(e.currentTarget instanceof HTMLButtonElement?e.currentTarget:null);Ic().then(e=>{e||(t(),o())})},render:i,stale:a})}function $c(e,t,n,r={}){if(n?.status===`notFound`||n?.status===`redirected`||!n)return W;let i=n.routeId;if(!n?.module)return n.error?Qc(e,r.retryContext,n.error,i):t.showPending?ra():W;let a=n.module;if(!Yc(a))return n.error?Qc(e,r.retryContext,n.error,i):null;let o=()=>Xc(i,()=>a.render(n.data,n.isFetching===`loader`));return n.error?Qc(e,r.retryContext,n.error,i,o):o()}var el,tl;function nl(){return(nl=e((()=>{Ii(),Fi(),ta(),ea(),Hi(),G(),bn(),Tc(),Jc(),el=class{constructor(e,t){this.inputs=t,this.controller=new wc(()=>e.requestUpdate()),e.addController(this)}get snapshot(){return this.controller.snapshot}hostConnected(){this.controller.setInputs(this.inputs()),this.controller.connect()}hostUpdate(){this.controller.setInputs(this.inputs())}hostDisconnected(){this.controller.disconnect()}},tl=class extends er{constructor(...e){super(...e),this.outlet=new el(this,()=>({router:this.router,onNotFound:this.onNotFound,notFoundRecoveryReady:this.notFoundRecoveryReady})),this.mcpAppUnmountGate=new Ui(this)}render(){let e=this.router;if(!e)return W;let t=this.outlet.snapshot,n=bc(t.active,t.pending),r=n?`${n.routeId}:${n.status}`:`empty`,i=n?.module,a=n&&Yc(i)?i.renderOwnerKey?.(n,t.settled):void 0,o=n?.error===void 0?a:void 0,s=o!==void 0&&n?.status===`pending`&&n.data===void 0;return this.mcpAppUnmountGate.render(o??r,()=>$c(e,t,n,{retryContext:this.retryContext}),()=>[this],{retainRenderedValue:s})}},B([Ri({attribute:!1})],tl.prototype,`router`,void 0),B([Ri({attribute:!1})],tl.prototype,`retryContext`,void 0),B([Ri({attribute:!1})],tl.prototype,`onNotFound`,void 0),B([Ri({attribute:!1})],tl.prototype,`notFoundRecoveryReady`,void 0),customElements.get(`openclaw-router-outlet`)||customElements.define(`openclaw-router-outlet`,tl)})))()}function rl(e,t){if(!mo(e)||!t||typeof t!=`object`)return;let n=t;return n.kind===`session`&&typeof n.sessionKey==`string`&&n.sessionKey.trim()||void 0}function il(e){let t=bc(e.matches[0],e.pendingMatches[0]),n=e.matches[0],r=n?rl(n.routeId,n.data):void 0;return{...t?{routeId:t.routeId,location:t.location,routeFailed:t.status===`error`||t.status===`notFound`}:{},...n?{committedRouteId:n.routeId,committedLocation:n.location}:{},...r?{committedSessionKey:r}:{}}}function al(){return(al=e((()=>{q(),nl()})))()}function ol(e,t){if(customElements.get(e))return Promise.resolve();let n=sl.get(e);if(n)return n;let r=Promise.resolve().then(t).then(()=>{if(!customElements.get(e))throw Error(`Custom element module did not define ${e}`)}).finally(()=>{sl.delete(e)});return sl.set(e,r),r}function Y(e){return customElements.get(e.tagName)!==void 0}var sl,cl,ll,ul,dl,fl,pl,ml,hl,gl,_l,vl,yl,bl,xl,Sl,Cl,wl,Tl,El,Dl;function Ol(){return(Ol=e((()=>{G(),Jc(),I(),sl=new Map,cl=class{constructor(e,t,n=e=>Ic({canReload:e})){this.host=e,this.onClose=t,this.retryStale=n,this.preloads=new Set,this.activeDismissed=!1}get visibleState(){return this.current}preload(e,t){Y(e)||this.preloads.has(e.tagName)||(this.preloads.add(e.tagName),ol(e.tagName,e.loadModule).then(()=>this.host.requestUpdate(),n=>{t?.reportError&&!this.current&&(this.current={element:e,error:n,stale:Ac(n),status:`error`},this.host.requestUpdate())}).finally(()=>this.preloads.delete(e.tagName)))}request(e,t){let n={action:t,element:e,status:`loading`};this.current=n,this.host.requestUpdate(),this.load(n)}requestWhileActive(e,t){t?this.active!==e&&(this.active=e,this.activeDismissed=!1):this.active===e&&(this.active=void 0,this.activeDismissed=!1),!t&&this.current?.element===e?this.abandon():this.pumpActive()}retry(){let e=this.current;if(e?.status!==`error`)return;let t={action:e.action,element:e.element,status:`loading`};this.current=t,this.host.requestUpdate(),(e.stale?this.retryStale(()=>this.current===t):Promise.resolve(!1)).then(e=>{!e&&this.current===t&&this.load(t)})}close(){this.current&&(this.current.element===this.active&&(this.activeDismissed=!0),this.onClose?.(),this.abandon())}abandon(){this.current&&(this.current=void 0,this.host.requestUpdate(),this.pumpActive())}pumpActive(){this.active&&!this.activeDismissed&&!this.current&&!Y(this.active)&&this.request(this.active)}load(e){ol(e.element.tagName,e.element.loadModule).then(async()=>{this.current===e&&(this.host.requestUpdate(),await this.host.updateComplete,this.current===e&&((!this.host.queryRenderedElement||this.host.queryRenderedElement(e.element.tagName)!==null)&&e.action?.(),this.current===e&&this.abandon()))},t=>{this.current===e&&(this.current={action:e.action,element:e.element,error:t,stale:Ac(t),status:`error`},this.host.requestUpdate())})}},ll={tagName:`openclaw-command-palette`,label:`command palette`,loadModule:()=>R(()=>import(`./command-palette-DutMicI_.js`),__vite__mapDeps([18,2,3,4,5,6,7,8,19,1,9,10,11,12,13,14,15,16]),import.meta.url)},ul=`openclaw-debug-overlay`,dl={tagName:ul,label:ul,loadModule:()=>R(()=>import(`./debug-overlay-BHWfz6ox.js`),__vite__mapDeps([20,2,3,4,5,6,7,8,1,9,10,11,12,13,14,15,16,21,22]),import.meta.url)},fl=`openclaw-keyboard-shortcuts-dialog`,pl={tagName:fl,label:fl,loadModule:()=>R(()=>import(`./keyboard-shortcuts-dialog-FN4z-F-7.js`),__vite__mapDeps([23,2,3,4,5,6,7,8,1,9,10,11,12,13,14,15,16]),import.meta.url)},ml=`openclaw-macos-titlebar-controls`,hl={tagName:ml,label:ml,loadModule:()=>R(()=>import(`./macos-titlebar-controls.runtime-DzBe0DU9.js`),__vite__mapDeps([24,2,3,4,5,6,7,8]),import.meta.url)},gl={tagName:`openclaw-sidebar-attention`,label:K(`attention.issues`),loadModule:()=>R(()=>import(`./sidebar-attention-DwR-r9JL.js`),__vite__mapDeps([25,6,2,3,4,5,7,8,13,9,10,11,12,1,14,15,16]),import.meta.url)},_l={tagName:`openclaw-terminal-panel`,label:`terminal panel`,loadModule:()=>R(()=>import(`./terminal-panel-registration-K_mKS-nt.js`),__vite__mapDeps([26,2,3,4,5,6,7,8,9,10,11,12,27,13,1,14,15,16,28,29,30,31,32,33,34]),import.meta.url)},vl={tagName:`openclaw-browser-panel`,label:`browser panel`,loadModule:()=>R(()=>import(`./browser-panel-DGRO2wFN.js`),__vite__mapDeps([35,2,3,4,5,6,7,8,13,9,10,11,12,1,14,15,16,27,28,29,30,31,32,33]),import.meta.url)},yl={tagName:`openclaw-desktop-panel`,label:`desktop panel`,loadModule:()=>R(()=>import(`./desktop-panel-C0q8O3Dk.js`),__vite__mapDeps([36,2,3,4,5,6,7,8,27,9,10,11,12,13,1,14,15,16,28,29,37,38,39,40,41,42,30,31,43]),import.meta.url)},bl={tagName:`openclaw-board-document`,label:`dashboard document`,loadModule:()=>R(()=>import(`./board-document-B_hi1f-Z.js`),__vite__mapDeps([44,2,3,4,5,6,7,8,9,10,11,12,27,13,1,14,15,16,28,29,45,39,46,47,48,49,50]),import.meta.url)},xl={tagName:`openclaw-assistant-panel`,get label(){return K(`assistantPanel.title`)},loadModule:()=>R(()=>import(`./assistant-panel-Ph0p7Cpg.js`),__vite__mapDeps([51,2,3,4,5,6,7,8,13,9,10,11,12,1,14,15,16,27,28,29,52,53,37,38,39,40,41,42,54,55,56,57,58,59,60,61,30,62]),import.meta.url)},Sl={tagName:`openclaw-approval-page`,label:`approval page`,loadModule:()=>R(()=>import(`./approval-page-registration-CZQUFKna.js`),__vite__mapDeps([63,2,3,4,5,6,7,8,64,28,9,10,11,12,29,65,66]),import.meta.url)},Cl=`openclaw-question-page`,wl={tagName:Cl,label:Cl,loadModule:()=>R(()=>import(`./question-page-registration-D8fm_YUt.js`),__vite__mapDeps([67,2,3,4,5,6,7,8,13,9,10,11,12,1,14,15,16,37,27,28,29,38,39,40,41,42,65,66]),import.meta.url)},Tl=`openclaw-exec-approval`,El={tagName:Tl,label:Tl,loadModule:()=>R(()=>import(`./exec-approval-Bp0d8ZwT.js`),__vite__mapDeps([68,2,3,4,5,6,7,8,27,9,10,11,12,13,1,14,15,16,28,29]),import.meta.url)},Dl={tagName:`openclaw-login-gate`,label:K(`login.subtitle`),loadModule:()=>R(()=>import(`./login-gate-B4HKZ0Kk.js`),__vite__mapDeps([69,4,2,3,5,6,7,8,70,9,10,11,12,13,1,14,15,16,71]),import.meta.url)}})))()}function kl(e){let t=e.indexOf(`#`),n=t===-1?e:e.slice(0,t),r=t===-1?``:e.slice(t),i=n.indexOf(`?`);return i!==-1&&new URLSearchParams(n.slice(i+1)).has(jl.name)?e:`${n}${i===-1?`?`:`&`}${jl.name}=${jl.value}${r}`}function Al(e,t=``,n){return S(e,t,n)}var jl;function Ml(){return(Ml=e((()=>{_(),jl={name:`nav`,value:`collapsed`}})))()}function Nl(e){let t=e.agentId?.trim()||qt(e.sessionKey)?.agentId;t&&e.selection.set(v(t)),e.gateway.setSessionKey(e.sessionKey)}function Pl(e,t,n){let r=e=>{let n=e?.trim()?v(e):null,r=t.state.agentsList;if(!r||r.agents.length===0)return n;let i=v(r.defaultId);return!n||!r.agents.some(e=>v(e.id)===n)?i:n},i=e=>{let n=e?.trim()?v(e):null;return t.state.agentsList?.agents.some(e=>e.kind===`system`&&v(e.id)===n)?null:n},a=e.connection.gatewayUrl,o=n?.load(a)?.trim(),s=r(o?v(o):e.snapshot.assistantAgentId?v(e.snapshot.assistantAgentId):null),c={selectedId:s,scopeId:i(s)},l=e.snapshot.assistantAgentId?v(e.snapshot.assistantAgentId):null,u=!o||s!==v(o);o&&u&&n?.save(a,null);let d=new Set,f=e=>{let t=r(e.selectedId),n=t===e.selectedId?e.scopeId:t,a={selectedId:t,scopeId:i(n)};if(c.selectedId!==a.selectedId||c.scopeId!==a.scopeId){c=a;for(let e of d)e(c)}};return e.subscribe(t=>{let r=t.assistantAgentId?v(t.assistantAgentId):null,i=r!==l;l=r;let o=e.connection.gatewayUrl;if(o!==a){a=o;let e=n?.load(a)?.trim();u=!e;let t=e?v(e):r;f({selectedId:t,scopeId:t});return}i&&u&&r&&f({selectedId:r,scopeId:r})}),t.subscribe(()=>{!u&&r(c.selectedId)!==c.selectedId&&(u=!0,n?.save(a,null)),f(u&&l?{selectedId:l,scopeId:c.selectedId===l?c.scopeId:l}:c)}),{get state(){return c},set(e){let t=e?.trim()?v(e):null;u=!t||r(t)!==t,n?.save(a,u?null:t),f({selectedId:t,scopeId:t})},setScope(e){let t=e?.trim()?v(e):null;f({...c,scopeId:t})},subscribe(e){return d.add(e),()=>d.delete(e)}}}function Fl(){return(Fl=e((()=>{nt()})))()}function Il(e,t,n){let r=`${ue(t)}${n}`;if(e===r||e===`${r}/`)return null;let i=`${r}/`;if(!e.startsWith(i))return;let a=e.slice(i.length);if(!a||a.includes(`/`))return null;try{let e=decodeURIComponent(a);return e&&e!==`.`&&e!==`..`?e:null}catch{return null}}function Ll(e,t){let n=Il(e,t,Oo.approval);return n===void 0?null:{kind:`approval`,approvalId:n}}function Rl(e,t){let n=Il(e,t,Oo.question);return n===void 0?null:{kind:`question`,questionId:n}}function zl(e,t){return Ll(e,t)??Rl(e,t)}function Bl(){return(Bl=e((()=>{q()})))()}function Vl(e){return e.reason instanceof Error?e.reason:new DOMException(`Gateway wait aborted`,`AbortError`)}function Hl(e,t){let n=e.snapshot.client;return t.aborted?Promise.reject(Vl(t)):n&&e.snapshot.phase===`connected`?Promise.resolve(n):new Promise((n,r)=>{let i=()=>void 0,a=!1,o=()=>{i(),t.removeEventListener(`abort`,s)},s=()=>{o(),r(Vl(t))};t.addEventListener(`abort`,s,{once:!0}),i=e.subscribe(e=>{e.phase===`connected`&&e.client&&(a=!0,o(),n(e.client))}),(a||t.aborted)&&i()})}function Ul(){return(Ul=e((()=>{})))()}function Wl(e,t){return!new URLSearchParams(e.search+`&`+e.hash.slice(1)).has(`session`)&&(vo(e.pathname,t)===null||/^\/chat\/?$/u.test(e.pathname.slice(t.length)))}function Gl(e,t){let n=e?.trim();if(!n||!t)return null;let r=v(n);return t.agents.some(e=>v(e.id)===r)?r:null}function Kl(e,t){let n=new URLSearchParams(e.search);if(!n.has(`session`))return null;let r=to(`chat`,t),i=to(`dashboard`,t),a=e.pathname===r||e.pathname===`${r}/`?`chat`:e.pathname===i||e.pathname===`${i}/`?`dashboard`:null;return a?{face:n.get(`face`)===`dashboard`?`dashboard`:a,sessionKey:n.get(`session`)?.trim()??``}:null}async function ql(e){let t=Kl(e.location,e.basePath);if(!t)return null;let n=!!(e.agentsList()?.mainKey?.trim()||e.gateway.snapshot.phase===`connected`&&e.gateway.snapshot.hello),r=qt(t.sessionKey);t.sessionKey&&!n&&await Hl(e.gateway,e.signal);let i={agentsList:e.agentsList(),hello:e.gateway.snapshot.hello},a=r?.agentId??(Gl(e.selectedAgentId,i.agentsList)||On(i)),o=Nn(i),s=t.sessionKey?ec(t.face,a,t.sessionKey,e.basePath,{mainKey:o}):null,c=new URLSearchParams(e.location.search);c.delete(`session`),c.delete(`face`);let l=c.toString();return{...e.location,pathname:s??to(t.face,e.basePath),search:l?`?${l}`:``}}function Jl(e,t,n,r,i){if(!Wl(e,t)||!n.trim())return e;let a=qt(n)?.agentId??r.trim();if(!a)return e;let o=ec(`chat`,a,n,t,{mainKey:i});return o?{...e,pathname:o}:e}async function Yl(e){let t=await ql(e);if(t)return t;if(!Wl(e.location,e.basePath))return e.location;qt(e.sessionKey)||await Hl(e.gateway,e.signal);let n={agentsList:e.agentsList(),hello:e.gateway.snapshot.hello};return Jl(e.location,e.basePath,e.sessionKey.trim()||e.gateway.snapshot.sessionKey,Gl(e.selectedAgentId,n.agentsList)||On(n),Nn(n))}function Xl(){return(Xl=e((()=>{q(),yc(),tc(),nt()})))()}function Zl(e){let t=e.trim().replace(/^#/,``);if(!/^[0-9a-fA-F]{6}$/.test(t))return`#ffffff`;let n=e=>{let n=Number.parseInt(t.slice(e,e+2),16)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4};return .2126*n(0)+.7152*n(2)+.0722*n(4)>.179?`#000000`:`#ffffff`}function Ql(){return(Ql=e((()=>{})))()}function $l(){if(typeof document>`u`)return;let e=document.documentElement,t=getComputedStyle(e),n=t.getPropertyValue(`--bg`).trim(),r=globalThis.matchMedia?.(`(max-width: 768px), (max-width: 932px) and (max-height: 500px) and (orientation: landscape)`).matches&&document.querySelector(`.shell--chat`)&&t.getPropertyValue(`--bg-content`).trim()||n;if(r){e.style.setProperty(`--control-ui-system-chrome-background`,r);for(let e of document.querySelectorAll(`meta[name="theme-color"]`))e.content=r,e.removeAttribute(`media`)}}function eu(e){iu=e;let t=document.documentElement,n=(iu??ru)?.trim().replace(/^#/,``),r=n&&/^[0-9a-fA-F]{6}$/.test(n)?`#${n}`:null;if(!r){for(let e of nu)t.style.removeProperty(e);return}let i=Zl(r),a=(e,t)=>`color-mix(in srgb, var(${e}) ${t}%, transparent)`;for(let e of[`--ring`,`--accent`,`--accent-muted`,`--primary`])t.style.setProperty(e,r);for(let e of[`--accent-foreground`,`--primary-foreground`])t.style.setProperty(e,i);t.style.setProperty(`--accent-hover`,`color-mix(in srgb, var(--accent) 82%, white 18%)`),t.style.setProperty(`--primary-hover`,`color-mix(in srgb, var(--primary) 82%, white 18%)`),t.style.setProperty(`--accent-subtle`,a(`--accent`,16)),t.style.setProperty(`--accent-glow`,a(`--accent`,30)),t.style.setProperty(`--focus`,a(`--ring`,22)),t.style.setProperty(`--focus-ring`,`0 0 0 2px var(--bg), 0 0 0 3px ${a(`--ring`,80)}`),t.style.setProperty(`--focus-glow`,`0 0 0 2px var(--bg), 0 0 0 3px var(--ring), 0 0 16px var(--accent-glow)`)}function tu(e){ru=e,eu(iu)}var nu,ru,iu;function au(){return(au=e((()=>{nu=[`--ring`,`--accent`,`--accent-foreground`,`--accent-hover`,`--accent-muted`,`--accent-subtle`,`--accent-glow`,`--primary`,`--primary-hover`,`--primary-foreground`,`--focus`,`--focus-ring`,`--focus-glow`]})))()}function ou(e){if(!gu.test(e))throw Error(`Unsupported tweakcn link. Expected a theme share URL.`)}function su(e,t){let n=z(e);if(!n||n.length>vu)throw Error(`Unsupported tweakcn token: ${t}`);let r=n.toLowerCase();if(yu.some(e=>r.includes(e))||n.includes(`/*`)||n.includes(`*/`)||n.includes(`\\`))throw Error(`Unsupported tweakcn token: ${t}`);for(let e of n){let n=e.charCodeAt(0);if(n<32||n===127||e===`{`||e===`}`||e===`;`||e===`<`||e===`>`||e==="`")throw Error(`Unsupported tweakcn token: ${t}`)}return n}function cu(e){let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||e===` `||bu.has(e)}function lu(e,t){let n=su(e,t);if(n.includes(`(`)||n.includes(`)`)||!Array.from(n).every(cu))throw Error(`Unsupported tweakcn token: ${t}`);return n}function uu(e){return Object.fromEntries(e)}function du(e){if(!e||typeof e!=`object`)return null;let t=[];for(let n of xu){let r=n===`font-body`||n===`font-display`||n===`mono`?lu(e[n],n):su(e[n],n);t.push([n,r])}return uu(t)}function fu(e){let t=z(e);return t?s(t,80):`Custom`}function pu(e){let t=P(e);if(!t)return null;let{sourceUrl:n,themeId:r,label:i,importedAt:a}=t;if(typeof n!=`string`||typeof r!=`string`||typeof i!=`string`||typeof a!=`string`)return null;try{ou(r);let e=du(P(t.light)??void 0),o=du(P(t.dark)??void 0);return!e||!o?null:{sourceUrl:n,themeId:r,label:fu(i),importedAt:a,light:e,dark:o}}catch{return null}}function mu(e){let t=du(e.light),n=du(e.dark);if(!t||!n)throw Error(`Stored custom theme is missing required tokens.`);let r=e=>xu.map(t=>` --${t}: ${e[t]};`).join(`
`);return[`:root[data-theme="custom"] {`,r(n),`}`,`:root[data-theme="custom-light"] {`,r(t),`}`].join(`
`)}function hu(e){if(typeof document>`u`)return;let t=document.getElementById(_u);if(!e){t?.remove();return}let n;try{n=mu(e)}catch{t?.remove();return}if(!n){t?.remove();return}t||(t=document.createElement(`style`),t.id=_u,document.head.appendChild(t)),t.textContent=n}var gu,_u,vu,yu,bu,xu;function Su(){return(Su=e((()=>{gu=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/,_u=`openclaw-custom-theme`,vu=240,yu=[`url(`,`image(`,`image-set(`,`-webkit-image-set(`,`cross-fade(`,`element(`,`-moz-element(`,`paint(`,`@import`,`expression(`],bu=new Set([`,`,`'`,`"`,`.`,`_`,`-`]),xu=`bg.bg-accent.bg-elevated.bg-hover.bg-muted.bg-content.card.card-foreground.card-highlight.popover.popover-foreground.panel.panel-strong.panel-hover.chrome.chrome-strong.text.text-strong.chat-text.muted.muted-strong.muted-foreground.border.border-strong.border-hover.input.ring.accent.accent-hover.accent-muted.accent-subtle.accent-foreground.accent-glow.primary.primary-foreground.secondary.secondary-foreground.accent-2.accent-2-muted.accent-2-subtle.destructive.destructive-foreground.danger.danger-muted.danger-subtle.focus.focus-ring.focus-glow.font-body.font-display.mono.grid-line`.split(`.`)})))()}function Cu(){return typeof globalThis.matchMedia==`function`&&globalThis.matchMedia(`(prefers-color-scheme: light)`).matches}function wu(e,t){let n=typeof e==`string`?e:``,r=typeof t==`string`?t:``;return{theme:Ou.has(n)?n:`claw`,mode:ku.has(r)?r:`system`}}function Tu(e){return e===`system`?Cu()?`light`:`dark`:e}function Eu(e,t){let n=Tu(t);if(e===`claw`)return n===`light`?`light`:`dark`;let r=e===`knot`?`openknot`:e;return n===`light`?`${r}-light`:r}function Du(e,t){if(typeof document>`u`||e===`claw`||e===`custom`){t();return}let n=`openclaw-theme-palette-${e}`,r=document.getElementById(n);if(r instanceof HTMLLinkElement&&r.sheet){t();return}let i=r instanceof HTMLLinkElement?r:document.createElement(`link`),a=e=>{i.removeEventListener(`load`,a),i.removeEventListener(`error`,a),e.type===`error`&&(console.error(`Theme palette failed to load; reload to retry: ${i.href}`),i.remove()),t()};i.addEventListener(`load`,a),i.addEventListener(`error`,a),r||(i.id=n,i.rel=`stylesheet`,i.href=Ho(`themes/${e}.css`),document.head.append(i))}var Ou,ku;function Au(){return(Au=e((()=>{Wo(),Ou=new Set([`claw`,`knot`,`dash`,`absolutely`,`tide`,`beacon`,`phosphor`,`crt`,`manuscript`,`rose`,`miami`,`custom`]),ku=new Set([`system`,`light`,`dark`])})))()}function ju(e){return j.find(t=>t===e)}function Mu(e,t,n){let r=Vu[e];return{ui:t??r.ui,chat:n??r.chat}}function Nu(e){let t=`openclaw-typeface-${e}`,n=Bu[e].asset;if(!n||document.getElementById(t))return;let r=document.createElement(`link`);r.id=t,r.rel=`stylesheet`,r.href=Ho(n),document.head.append(r)}function Pu(e){typeof document>`u`||(Nu(e.ui),Nu(e.chat),Nu(`jetbrains-mono`))}function Fu(){j.forEach(Nu)}function Iu(e,t){for(let[n,r]of[[`--font-body`,e],[`--font-chat`,t]])r?document.documentElement.style.setProperty(n,Bu[r].stack):document.documentElement.style.removeProperty(n)}function Lu(e){zu[e].kind===`serif`?document.documentElement.style.setProperty(`--chat-font-smoothing`,`auto`):document.documentElement.style.removeProperty(`--chat-font-smoothing`)}var Ru,zu,Bu,Vu;function Hu(){return(Hu=e((()=>{d(),Wo(),Ru={sans:`-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,serif:`Georgia, "Times New Roman", serif`,mono:`ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace`},zu={"instrument-sans":{label:`Instrument Sans`,kind:`sans`},geist:{label:`Geist`,kind:`sans`},"dm-sans":{label:`DM Sans`,kind:`sans`},"ibm-plex-sans":{label:`IBM Plex Sans`,kind:`sans`},"space-grotesk":{label:`Space Grotesk`,kind:`sans`},"atkinson-hyperlegible":{label:`Atkinson Hyperlegible`,family:`Atkinson Hyperlegible Next`,kind:`sans`},fraunces:{label:`Fraunces`,kind:`serif`},lora:{label:`Lora`,kind:`serif`},"jetbrains-mono":{label:`JetBrains Mono`,kind:`mono`},system:{label:`System`,kind:`sans`}},Bu=Object.fromEntries(j.map(e=>{let{label:t,family:n=t,kind:r}=zu[e];return[e,{label:t,stack:e===`system`?Ru.sans:`"${n}", ${Ru[r]}`,asset:e===`system`?void 0:`fonts/${e}.css`}]})),Vu={claw:{ui:`instrument-sans`,chat:`instrument-sans`},knot:{ui:`geist`,chat:`geist`},dash:{ui:`dm-sans`,chat:`fraunces`},absolutely:{ui:`space-grotesk`,chat:`lora`},tide:{ui:`ibm-plex-sans`,chat:`ibm-plex-sans`},beacon:{ui:`atkinson-hyperlegible`,chat:`atkinson-hyperlegible`},phosphor:{ui:`jetbrains-mono`,chat:`jetbrains-mono`},crt:{ui:`jetbrains-mono`,chat:`jetbrains-mono`},manuscript:{ui:`lora`,chat:`lora`},rose:{ui:`dm-sans`,chat:`dm-sans`},miami:{ui:`space-grotesk`,chat:`space-grotesk`},custom:{ui:`system`,chat:`system`}}})))()}function Uu(e){let t=z(e);return t?Rr(t)?t.length<=Xu?t:null:/[\r\n]/.test(t)?null:t.length<=Yu?t:null:null}function Wu(e){let t=z(e?.name);return{name:t?s(t,Ju):null,avatar:Uu(e?.avatar)}}function Gu(e,t=`You`){return Wu(e).name??t}function Ku(e){let t=Wu(e);return gr(t.avatar,{identity:{avatar:t.avatar??void 0}})}function qu(e){let t=Wu(e),n=z(t.avatar);return n?Ku(t)?null:n:null}var Ju,Yu,Xu;function Zu(){return(Zu=e((()=>{rr(),Ju=50,Yu=16,Xu=2e6})))()}function Qu(e){return`${kd}${L(e)}`}function $u(e){return`${Md}${L(e)}`}function ed(e){let t=0;for(let n of e)if(n===`(`)t++;else if(n===`)`&&(t--,t<0))return!1;return t===0}function td(e){for(let t of e.matchAll(Vd)){let e=t[0].toLowerCase();if(!Rd.has(e)&&!Ld.has(e)&&!zd.has(e))return!1}return!0}function nd(e){if(typeof e!=`string`)return;let t=e.trim().replace(/\s+/g,` `);if(t.length!==0&&!(t.length>Ud)){if(Ld.has(t.toLowerCase())||Hd.test(t))return t;if(!(!Bd.test(t)||!ed(t)||!td(t)))return/^(?:calc|clamp|fit-content|max|min)\(.+\)$/i.test(t)?t:void 0}}function rd(e,t){return n=>e.includes(n)?n:t}function id(e){return Kd.includes(e)?e:void 0}function ad(e){return typeof e==`string`&&/^#[0-9a-f]{6}$/i.test(e)?e.toLowerCase():void 0}function od(e,t=100){if(typeof e!=`number`||!Number.isFinite(e))return t;let n=Id[0],r=Math.abs(e-n);for(let t of Id){let i=Math.abs(e-t);i<r&&(n=t,r=i)}return n}function sd(){return typeof document>`u`?!1:!!document.querySelector(`script[src*="/@vite/client"]`)}function cd(e,t){return`${e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e}:${t}`}function ld(){let e=location.protocol===`https:`?`wss`:`ws`,t=Io(location.pathname)[0],n=`${e}://${location.host}${t}`;return sd()?{pageUrl:n,effectiveUrl:`${e}://${cd(location.hostname,`18789`)}`}:{pageUrl:n,effectiveUrl:n}}function ud(e){let{effectiveUrl:t}=ld();if(L(e.gatewayUrl)===L(t))return e;let n=_d(t);return{...e,gatewayUrl:t,token:yd(e.gatewayUrl,t,{token:e.token,password:``}).token,sessionKey:n.sessionKey,lastActiveSessionKey:n.lastActiveSessionKey}}function dd(){return xi()}function fd(e){return e?C(e)??null:null}function pd(e,t){let n=z(e.gatewayUrl);return n?L(n)===L(t):!1}function md(e,t){let n=fd(e?.getItem(Qu(t))??null);return n&&(!z(n.gatewayUrl)||pd(n,t))?{gatewayUrl:z(n.gatewayUrl)??t,parsed:n}:null}function hd(e){return`${Fd}${L(e)}`}function gd(e,t,n){let r=L(e),i=t.sessionsByGateway?.[r],a=z(i?.sessionKey),o=z(i?.lastActiveSessionKey),s=z(i?.selectedAgentId);if(a&&o)return{sessionKey:a,lastActiveSessionKey:o,...s?{selectedAgentId:v(s)}:{}};let c=z(t.sessionKey)??n.sessionKey;return{sessionKey:c,lastActiveSessionKey:z(t.lastActiveSessionKey)??c??n.lastActiveSessionKey}}function _d(e){let t={sessionKey:`main`,lastActiveSessionKey:`main`};try{let n=md(lt(),e);return n?gd(e,n.parsed,t):t}catch{return t}}function vd(e){try{let t=dd();if(!t)return``;t.removeItem(Pd);let n=t.getItem(hd(e));return z(n)??``}catch{return``}}function yd(e,t,n){let r=L(e)===L(t),i=x(e)===x(t);return{token:r?n.token:vd(t),password:i?n.password:``}}function bd(e,t){try{let n=dd();if(!n)return;n.removeItem(Pd);let r=hd(e),i=z(t)??``;if(i){n.setItem(r,i);return}n.removeItem(r)}catch{}}function xd(e){return $d=e,()=>{$d===e&&($d=null)}}function Sd(e=$d?.gatewayUrl()){let t=Cd(e);return{...t,token:vd(t.gatewayUrl)}}function Cd(e){let t=Qd;if(t&&(!e||L(t.gatewayUrl)===L(e)))return e?{...t,gatewayUrl:e}:t;let{pageUrl:n,effectiveUrl:r}=ld(),i=lt(),a={gatewayUrl:e??r,sessionKey:`main`,lastActiveSessionKey:`main`,theme:X.theme,themeMode:X.themeMode,chatShowThinking:!0,chatShowToolCalls:!0,chatPersistCommentary:!0,chatCollapseTaskProgress:X.chatCollapseTaskProgress,chatSendShortcut:X.chatSendShortcut,catalogOpenTarget:X.catalogOpenTarget,navCollapsed:!1,navWidth:jd,sidebarEntries:[...ms],sidebarLiveActivity:X.sidebarLiveActivity,showAdvancedSettings:!1,pinnedAgentIds:[],composerHoldToRecord:X.composerHoldToRecord};try{let t=e??z(i?.getItem($u(n))),o=(t?md(i,t):null)??(e?null:md(i,r));if(!o)return a;let s=o.parsed,c=o.gatewayUrl,l=e??(c===n?r:c),u=gd(l,s,a),d=pu(s.customTheme),{theme:f,mode:p}=wu(s.theme,s.themeMode),m=N(s)??{},h=Object.hasOwn(m,`sidebarEntries`)?null:Array.isArray(m.sidebarPinnedRoutes)?Xo(m.sidebarPinnedRoutes.map(e=>typeof e==`string`?`route:${e}`:e)):null,g={gatewayUrl:l,sessionKey:u.sessionKey,lastActiveSessionKey:u.lastActiveSessionKey,selectedAgentId:u.selectedAgentId,theme:f===`custom`&&!d?`claw`:f,themeMode:p,accent:ad(s.accent),fontUi:ju(s.fontUi),fontChat:ju(s.fontChat),chatShowThinking:typeof s.chatShowThinking==`boolean`?s.chatShowThinking:a.chatShowThinking,chatShowToolCalls:typeof s.chatShowToolCalls==`boolean`?s.chatShowToolCalls:a.chatShowToolCalls,chatPersistCommentary:typeof s.chatPersistCommentary==`boolean`?s.chatPersistCommentary:a.chatPersistCommentary,chatCollapseTaskProgress:typeof s.chatCollapseTaskProgress==`boolean`?s.chatCollapseTaskProgress:a.chatCollapseTaskProgress,chatSendShortcut:Gd(s.chatSendShortcut),chatFollowUpMode:id(s.chatFollowUpMode),catalogOpenTarget:Yd(s.catalogOpenTarget),realtimeTalkInputDeviceId:z(s.realtimeTalkInputDeviceId),realtimeTalkVideoDeviceId:z(s.realtimeTalkVideoDeviceId),composerHoldToRecord:typeof s.composerHoldToRecord==`boolean`?s.composerHoldToRecord:a.composerHoldToRecord,talkCameraAutoEnable:typeof s.talkCameraAutoEnable==`boolean`?s.talkCameraAutoEnable:void 0,chatSplitLayout:Jt(s.chatSplitLayout),chatWorkspaceDock:Zd(s.chatWorkspaceDock),boardSessionViews:zt(s.boardSessionViews),sidebarSessionLayouts:At(s.sidebarSessionLayouts),sidebarSessionActivePanels:Pn(s.sidebarSessionActivePanels),navCollapsed:a.navCollapsed,navWidth:typeof s.navWidth==`number`&&s.navWidth>=240&&s.navWidth<=400?s.navWidth:a.navWidth,sidebarEntries:Xo(m.sidebarEntries)??h??a.sidebarEntries,sidebarLiveActivity:typeof s.sidebarLiveActivity==`boolean`?s.sidebarLiveActivity:a.sidebarLiveActivity,chatMessageMaxWidth:nd(s.chatMessageMaxWidth),showAdvancedSettings:typeof s.showAdvancedSettings==`boolean`?s.showAdvancedSettings:a.showAdvancedSettings,pinnedAgentIds:Le(s.pinnedAgentIds),textScale:typeof s.textScale==`number`&&od(s.textScale)!==X.textScale?od(s.textScale):void 0,customTheme:d??void 0,locale:Na(s.locale)?s.locale:void 0,...s.lobsterPetVisits===!1?{lobsterPetVisits:!1}:{},...s.lobsterPetSounds===!0?{lobsterPetSounds:!0}:{},...s.sessionDeleteConfirm===!1?{sessionDeleteConfirm:!1}:{},...s.openLinksInControlUiBrowser===!0?{openLinksInControlUiBrowser:!0}:{}};return(`token`in s||h!==null)&&Od({...g,token:vd(l)},{selectGateway:!e}),g}catch{return a}}function wd(e){Od(e)}function Td(e){ef=e}function Ed(e,t={}){let n=Sd(e.gatewayUrl),r={...n,...e};return Od(r,{selectGateway:t.selectGateway??e.gatewayUrl!==void 0}),ef?.(n,r),r}function Dd(){let e=lt();try{let t=e?.getItem(Nd);return t?Wu(JSON.parse(t)):Wu()}catch{return Wu()}}function Od(e,t={}){bd(e.gatewayUrl,e.token);let n=lt(),r=L(e.gatewayUrl),i=Qu(e.gatewayUrl),a=ad(e.accent),o=ju(e.fontUi),s=ju(e.fontChat),c=id(e.chatFollowUpMode),l={};try{let t=md(n,e.gatewayUrl);if(t){let e=t.parsed;e.sessionsByGateway&&typeof e.sessionsByGateway==`object`&&(l=e.sessionsByGateway)}}catch{}let u=Object.fromEntries([...Object.entries(l).filter(([e])=>e!==r),[r,{sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,...z(e.selectedAgentId)?{selectedAgentId:v(e.selectedAgentId)}:{}}]].slice(-10)),d={gatewayUrl:e.gatewayUrl,theme:e.theme,themeMode:e.themeMode,...a?{accent:a}:{},...o?{fontUi:o}:{},...s?{fontChat:s}:{},chatShowThinking:e.chatShowThinking,chatShowToolCalls:e.chatShowToolCalls,chatPersistCommentary:e.chatPersistCommentary??!0,...e.chatCollapseTaskProgress===!0?{chatCollapseTaskProgress:!0}:{},...Gd(e.chatSendShortcut)===`modifier-enter`?{chatSendShortcut:`modifier-enter`}:{},...c?{chatFollowUpMode:c}:{},...Yd(e.catalogOpenTarget)===`terminal`?{catalogOpenTarget:`terminal`}:{},...z(e.realtimeTalkInputDeviceId)?{realtimeTalkInputDeviceId:z(e.realtimeTalkInputDeviceId)}:{},...z(e.realtimeTalkVideoDeviceId)?{realtimeTalkVideoDeviceId:z(e.realtimeTalkVideoDeviceId)}:{},...e.composerHoldToRecord===!1?{composerHoldToRecord:!1}:{},...typeof e.talkCameraAutoEnable==`boolean`?{talkCameraAutoEnable:e.talkCameraAutoEnable}:{},...e.chatSplitLayout?{chatSplitLayout:e.chatSplitLayout}:{},...e.chatWorkspaceDock===`bottom`?{chatWorkspaceDock:`bottom`}:{},...e.boardSessionViews&&Object.keys(e.boardSessionViews).length>0?{boardSessionViews:zt(e.boardSessionViews)}:{},...e.sidebarSessionLayouts&&Object.keys(e.sidebarSessionLayouts).length>0?{sidebarSessionLayouts:At(e.sidebarSessionLayouts)}:{},...e.sidebarSessionActivePanels&&Object.keys(e.sidebarSessionActivePanels).length>0?{sidebarSessionActivePanels:Pn(e.sidebarSessionActivePanels)}:{},navWidth:e.navWidth,sidebarEntries:e.sidebarEntries,...e.sidebarLiveActivity===!1?{sidebarLiveActivity:!1}:{},...nd(e.chatMessageMaxWidth)?{chatMessageMaxWidth:nd(e.chatMessageMaxWidth)}:{},...e.showAdvancedSettings===!0?{showAdvancedSettings:!0}:{},...e.pinnedAgentIds&&e.pinnedAgentIds.length>0?{pinnedAgentIds:e.pinnedAgentIds}:{},...e.textScale===void 0?{}:{textScale:od(e.textScale)},...e.customTheme?{customTheme:e.customTheme}:{},sessionsByGateway:u,...e.locale?{locale:e.locale}:{},...e.lobsterPetVisits===!1?{lobsterPetVisits:!1}:{},...e.lobsterPetSounds===!0?{lobsterPetSounds:!0}:{},...e.sessionDeleteConfirm===!1?{sessionDeleteConfirm:!1}:{},...e.openLinksInControlUiBrowser===!0?{openLinksInControlUiBrowser:!0}:{}},f=JSON.stringify(d),{token:p,...m}=e;Qd=m;try{let{pageUrl:r}=ld(),a=$u(r);n?.setItem(i,f),(t.selectGateway||n?.getItem(a)==null)&&n?.setItem(a,e.gatewayUrl),n?.removeItem(Ad),n&&(Qd=null)}catch{}let h=$d;h&&L(h.gatewayUrl())===r&&h.refresh()}var kd,Ad,jd,Md,Nd,Pd,Fd,Id,Ld,Rd,zd,Bd,Vd,Hd,Ud,Wd,Gd,Kd,qd,Jd,Yd,Xd,Zd,X,Qd,$d,ef;function tf(){return(tf=e((()=>{pe(),p(),r(),ws(),G(),oi(),ct(),Pt(),Bo(),Su(),Au(),Hu(),Zu(),kd=`openclaw.control.settings.v1:`,Ad=`openclaw.control.settings.v1`,jd=258,Md=`openclaw.control.currentGateway.v1:`,Nd=`openclaw.control.user.v1`,Pd=`openclaw.control.token.v1`,Fd=`openclaw.control.token.v1:`,Id=[90,100,110,125,140],Ld=new Set([`none`,`min-content`,`max-content`]),Rd=new Set([`calc`,`clamp`,`fit-content`,`max`,`min`]),zd=new Set([`ch`,`em`,`rem`,`vh`,`vmax`,`vmin`,`vw`,`px`]),Bd=/^[0-9A-Za-z.%+\-*/(),\s]+$/,Vd=/[A-Za-z][A-Za-z0-9-]*/g,Hd=/^(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem|em|ch|vw|vh|vmin|vmax|%)$/i,Ud=96,Wd=[`enter`,`modifier-enter`],Gd=rd(Wd,`enter`),Kd=[`queue`,`steer`],qd=rd(Kd,`steer`),Jd=[`viewer`,`terminal`],Yd=rd(Jd,`viewer`),Xd=[`right`,`bottom`],Zd=rd(Xd,`right`),X={theme:`claw`,themeMode:`system`,textScale:100,sidebarLiveActivity:!0,chatMessageMaxWidth:`48rem`,chatCollapseTaskProgress:!1,chatSendShortcut:`enter`,catalogOpenTarget:`viewer`,composerHoldToRecord:!0,lobsterPetVisits:!0,lobsterPetSounds:!1,sessionDeleteConfirm:!0},Qd=null,$d=null,ef=null})))()}var nf,rf;function af(){return(af=e((()=>{nf=e=>{e.classList.remove(`theme-transition`),e.style.removeProperty(`--theme-switch-x`),e.style.removeProperty(`--theme-switch-y`)},rf=({nextTheme:e,applyTheme:t,currentTheme:n})=>{if(n===e){t();return}let r=globalThis.document??null;if(!r){t();return}let i=r.documentElement;t(),nf(i)}})))()}function of(e){if(typeof document>`u`)return;let t=document.documentElement,n=Eu(e.theme,e.themeMode);t.dataset.theme=n,t.dataset.themeMode=n.endsWith(`light`)?`light`:`dark`,t.dataset.themeResolved=t.dataset.themeMode,t.classList.toggle(`wa-light`,t.dataset.themeMode===`light`),t.classList.toggle(`wa-dark`,t.dataset.themeMode===`dark`),t.style.colorScheme=t.dataset.themeMode,t.style.setProperty(`--control-ui-text-scale`,`${(e.textScale??100)/100}`);let r=Mu(e.theme,e.fontUi,e.fontChat);Pu(r),Iu(e.fontUi,e.fontChat),Lu(r.chat),hu(e.customTheme),eu(e.accent),$l()}function sf(e,t){let{token:n,...r}=e,i=r,a=null,o,s,c=new Set,l=0,u=()=>{let e=++l;Du(i.theme,()=>{e===l&&of(i)});for(let e of c)e()},d=()=>{o?.(),o=void 0},f=()=>{if(d(),i.themeMode!==`system`||typeof globalThis.matchMedia!=`function`)return;let e=globalThis.matchMedia(`(prefers-color-scheme: light)`),t=()=>{i.themeMode===`system`&&u()};typeof e.addEventListener==`function`?(e.addEventListener(`change`,t),o=()=>e.removeEventListener(`change`,t)):typeof e.addListener==`function`&&(e.addListener(t),o=()=>e.removeListener(t))};if(typeof globalThis.matchMedia==`function`){let e=globalThis.matchMedia(`(max-width: 768px), (max-width: 932px) and (max-height: 500px) and (orientation: landscape)`),t=()=>$l();typeof e.addEventListener==`function`?(e.addEventListener(`change`,t),s=()=>e.removeEventListener(`change`,t)):typeof e.addListener==`function`&&(e.addListener(t),s=()=>e.removeListener(t))}let p=()=>{let e=Cd(t.connection.gatewayUrl);JSON.stringify(e)!==JSON.stringify(i)&&(i=e,u(),f())},m=xd({gatewayUrl:()=>t.connection.gatewayUrl,refresh:p}),h=e=>{(e.key===null||e.key===Qu(t.connection.gatewayUrl))&&p()};globalThis.addEventListener?.(`storage`,h);let g=t.subscribe(()=>{i.gatewayUrl!==t.connection.gatewayUrl&&p()});return f(),u(),{get settings(){return i},get mode(){return i.themeMode},get resolvedMode(){return Eu(i.theme,i.themeMode).endsWith(`light`)?`light`:`dark`},get serverSelection(){return a},recordServerSelection(e,t){a={revision:(a?.revision??0)+1,scope:t,theme:e},u()},setMode(e,t){let n=i,r={...n,themeMode:e},a=Eu(n.theme,n.themeMode),o=Eu(r.theme,r.themeMode);rf({nextTheme:o,currentTheme:a,context:{element:t},applyTheme:()=>{Ed({themeMode:e})}})},refresh:p,subscribe(e){return c.add(e),()=>c.delete(e)},dispose(){m(),globalThis.removeEventListener?.(`storage`,h),g(),l+=1,d(),s?.(),c.clear()}}}function cf(){return(cf=e((()=>{au(),Su(),tf(),af(),Au(),Hu()})))()}function lf(){let e=new Map,t=!1,n=(e=[])=>an(e),r=e=>{let t=new Map(e.attachments.map(e=>[e.id,e]));for(let n of Object.values(e.fallbacks))for(let e of n.attachments)t.set(e.id,e);return[...t.values()]},i=(e,t=new Set)=>{e&&n(r(e).filter(e=>!t.has(e.id)))},a=(e,t)=>JSON.stringify([e,t]),o=t=>{let n=e.get(t);return n&&e.delete(t),n};return{prepare:({owner:r,paneId:s,scopeKey:c,attachments:l,fallbacks:u,message:d=``,mentions:f})=>{let p=a(s,c),m=o(p),h=Object.entries(u);if(!d&&l.length===0&&h.length===0){i(m);return}let g=new Set(l.map(e=>e.id));for(let e of Object.values(u))for(let t of e.attachments)g.add(t.id);if(i(m,g),!r||t){n(l);for(let e of Object.values(u))n(e.attachments);return}e.set(p,{owner:r,preparedAt:Date.now(),paneId:s,scopeKey:c,attachments:[...l],message:d,...f?.length?{mentions:f.map(e=>({...e}))}:{},fallbacks:Object.fromEntries(h.map(([e,t])=>[e,{...t,attachments:[...t.attachments]}]))});for(let t of e.keys()){if(e.size<=uf)break;i(o(t))}},consume:({owner:e,paneId:t,scopeKey:n})=>{let r=o(a(t,n));return r?.owner===e?{attachments:r.attachments,fallbacks:r.fallbacks,...r.message?{message:r.message}:{},...r.mentions?{mentions:r.mentions}:{}}:(i(r),null)},retireScope:(t,n)=>{for(let[r,a]of e)a.scopeKey===t&&a.preparedAt<n&&i(o(r))},clearPane:t=>{for(let[n,r]of e)r.paneId===t&&i(o(n))},dispose:()=>{t=!0;for(let t of e.values())i(t);e.clear()}}}var uf;function df(){return(df=e((()=>{rt(),uf=32})))()}function ff(){let e=new Map,t=new WeakMap,n=t=>[...e.keys()].find(e=>wi(e,t));return{retain:r=>{if(!r)return;let i=r.kind===`initial`?e:t.get(r.owner)??new Map,a=r.kind===`initial`?n(r.sessionKey)??r.sessionKey:r.deliveryKey;r.kind===`delivered`&&t.set(r.owner,i);let o={...r,pending:!0};i.delete(a),i.set(a,o);let s=r.kind===`initial`?32:64;return i.size>s&&i.delete(i.keys().next().value),o},readInitial:(t,r)=>{let i=e.get(n(t)??``);return i?.owner===r?i:null},readDelivered:(e,n)=>t.get(n)?.get(e),clearInitial:t=>{let r=n(t);r&&e.delete(r)},clear:()=>{e.clear(),t=new WeakMap}}}function pf(){return(pf=e((()=>{nt()})))()}function mf(e){return Le([e.hello?.auth?.deviceToken,e.settings?.token,e.password]).filter(e=>!/[\r\n]/.test(e))}function hf(e){return mf(e)[0]??null}function gf(e){let t=hf(e);return t?`Bearer ${t}`:null}function _f(){return(_f=e((()=>{r()})))()}function vf(){if(typeof document>`u`)return null;let e=document.documentElement.getAttribute(He);return e===`true`||e!==`false`&&null}function yf(e,t,n){let r=document.documentElement;(e||t||r.hasAttribute(`data-openclaw-environment`)||r.style.getPropertyValue(`--ring`))&&R(async()=>{let{applyControlUiPresentation:e}=await import(`./control-ui-environment-presentation.runtime-BcIofN7_.js`);return{applyControlUiPresentation:e}},__vite__mapDeps([72,2,3,4,5,6,7,8]),import.meta.url).then(({applyControlUiPresentation:r})=>{n()&&r({environment:e,seamColor:t})})}function bf(e){return{assistantIdentity:Br({agentId:e.assistantAgentId,name:e.assistantName,avatar:e.assistantAvatar,avatarSource:e.assistantAvatarSource,avatarStatus:e.assistantAvatarStatus,avatarReason:e.assistantAvatarReason}),serverVersion:e.serverVersion??null,serverBuildId:e.serverBuildId??null,devGitBranch:e.devGitBranch?.trim()||null,environment:e.environment??null,localMediaPreviewRoots:e.localMediaPreviewRoots??[],embedSandboxMode:e.embedSandbox??`scripts`,allowExternalEmbedUrls:!!e.allowExternalEmbedUrls,automaticallyFetchFavicons:!!e.automaticallyFetchFavicons,communityInvite:e.communityInvite===!0,terminalEnabled:!!e.terminalEnabled,cliAgentsEnabled:!!e.cliAgentsEnabled,pluginAssetsRequireAuth:e.pluginAssetsRequireAuth!==!1,pluginFrameGrants:(e.pluginFrameGrants??[]).filter(e=>typeof e?.pluginId==`string`&&typeof e.path==`string`&&(e.match===`exact`||e.match===`prefix`))}}async function xf(e){if(typeof window>`u`||typeof fetch!=`function`)return null;try{let t=null;for(let n of e.authCandidates.length?e.authCandidates:[``]){let r={Accept:`application/json`};if(n&&(r.Authorization=`Bearer ${n}`),t=await fetch(e.url,{method:`GET`,headers:r,credentials:`same-origin`,signal:e.signal}),t.ok)break;if(t.status!==401&&t.status!==403)return null}if(!t?.ok)return null;let n=await t.json();return{config:bf(n),seamColor:n.seamColor}}catch{return null}}function Sf(e){let t=Cf,n=0,r=0,i=0,a=document.documentElement.getAttribute(me);a&&(t={...t,environment:JSON.parse(a)},yf(t.environment,void 0,()=>i===0));let o=`${ue(e.resourceBasePath)}${Pe}`,s=new URL(o,window.location.origin).origin===window.location.origin,c=()=>s?mf(e.getAuth?.()??{}):[],l=[],u,d=new Set;return{get current(){return t},async refresh(e){let a=c();if((a.length!==l.length||a.some((e,t)=>e!==l[t]))&&(l=a,n++,u=void 0),e?.skipWithoutAuthCandidate&&s&&!a.length)return null;if(u&&u.signal===e?.signal)return u.promise;let f=++r,p=n,m=e?.signal,h=()=>{let e=c();return p===n&&!m?.aborted&&a.length===e.length&&a.every((t,n)=>t===e[n])},g=xf({url:o,authCandidates:a,signal:m}).then(e=>{if(!e||!h())return null;let n=e.config;if(f<i)return n;i=f,yf(n.environment,e.seamColor,()=>h()&&f===i);let r=vf();if(r!==null&&n.terminalEnabled!==r)return Dc()&&window.location.reload(),n;t=n;for(let e of d)e(t);return n});u={promise:g,signal:m};try{return await g}finally{u?.promise===g&&(u=void 0)}},subscribe(e){return d.add(e),()=>d.delete(e)}}}var Cf;function wf(){return(wf=e((()=>{be(),ge(),ei(),_f(),kc(),I(),Cf={assistantIdentity:Br(),serverVersion:null,serverBuildId:null,devGitBranch:null,environment:null,localMediaPreviewRoots:[],embedSandboxMode:`strict`,allowExternalEmbedUrls:!1,automaticallyFetchFavicons:!1,communityInvite:!1,terminalEnabled:vf()??!1,cliAgentsEnabled:!1,pluginAssetsRequireAuth:!0,pluginFrameGrants:[]}})))()}function Tf(){let e=null,t=0,n=0,r=[],i=new Map,a=()=>{for(;n<Ef;){let o=r.shift();if(!o)return;if(o.generation!==t){o.resolve();continue}if(!e){r.unshift(o);return}n++;let s=()=>{o.generation===t&&i.delete(o.key),o.resolve()};o.run().then(s,s).finally(()=>{n--,a()})}},o=()=>{t+=1,e=null,r.splice(0).forEach(e=>e.resolve()),i.clear()};return{reset:o,synchronize(t){let n=t.connected?t.client:null;if(n===e){!n&&r.length&&o();return}if(!n){o();return}e&&o(),e=n,a()},run(e,n){let o=i.get(e);if(o)return o;let s,c=new Promise(e=>{s=e});return i.set(e,c),r.push({generation:t,key:e,resolve:s,run:n}),a(),c}}}var Ef;function Df(){return(Df=e((()=>{Ef=2})))()}function Of(e){let t=e.hello?.auth;return e.phase!==`connected`||t?.scopes===void 0||ac(t)?{phase:`hidden`}:Ga(e,`device.scopes.requestUpgrade`)===!0&&Ga(e,`device.scopes.waitUpgrade`)===!0&&e.client?.scopeUpgradeReady===!0?{phase:`available`}:{phase:`guidance`}}function kf(){return(kf=e((()=>{qa(),cc()})))()}function Af(e){let t=new Set,n=e.snapshot,r=null,i=Of(n),a=e=>{if(JSON.stringify(i)!==JSON.stringify(e)){i=e;for(let e of t)e()}},o=()=>{r&&a(r.state)},s=e.subscribe(e=>{n=e,r?.sync(n),a(r?.state??Of(n))});return{get state(){return i},activate(e){r??=new e(n,o),r.sync(n),a(r.state)},request:()=>r?.request(),retry:()=>r?.retry(),cancel:()=>r?.cancel(),subscribe(e){return t.add(e),()=>t.delete(e)},dispose(){s(),r?.dispose(),r=null,t.clear()}}}function jf(){return(jf=e((()=>{kf()})))()}function Mf(e,t,n){let r=!1,i=!1,a=!1,o=t.visibilityState===`hidden`,s=n=>{t.visibilityState!==`hidden`&&(a||=n,!i&&(i=!0,queueMicrotask(()=>{i=!1;let n=a;if(a=!1,r||t.visibilityState===`hidden`)return;let o=e.snapshot.client;o&&(n||o.needsWakeReconnect)&&e.connect(),R(async()=>{let{refreshControlUiServiceWorker:e}=await import(`./sw-refresh.runtime-CfiqJg48.js`);return{refreshControlUiServiceWorker:e}},__vite__mapDeps([73,2,6,3,4,5,7,8]),import.meta.url).then(({refreshControlUiServiceWorker:e})=>e()).catch(e=>{console.warn(`OpenClaw service worker refresh failed after page activation.`,e)})})))},c=()=>{if(t.visibilityState===`hidden`){o=!0;return}o&&(o=!1,s(!1))},l=e=>{e.persisted&&s(!0)},u=()=>s(!1);return t.addEventListener(`visibilitychange`,c),n.addEventListener(`pageshow`,l),n.addEventListener(`online`,u),()=>{r=!0,t.removeEventListener(`visibilitychange`,c),n.removeEventListener(`pageshow`,l),n.removeEventListener(`online`,u)}}function Nf(){return(Nf=e((()=>{I()})))()}function Pf(e){if(!e||typeof e!=`object`)return;let t=e.presence;return Array.isArray(t)?t:void 0}function Ff(e,t){if(!t)return null;let n=e.find(e=>e.instanceId===t&&e.reason!==`disconnect`);return n?.user?.id?n.user:null}function If({snapshotUser:e,presenceEntries:t,presenceInstanceId:n}){return e??Ff(t??[],n)}function Lf(){return(Lf=e((()=>{})))()}function Rf(e){let t=N(e)?.phase;return t===`accepting`||t===`preparing`||t===`draining`||t===`prepared`?t:void 0}function zf(e,t,n,r){for(let i of Array.from(e)){if(r&&!r(t))return;try{i(t)}catch(e){console.error(`[gateway] ${n} handler error:`,e)}}}function Bf(e,t){return e?.id===t?.id&&e?.identity?.id===t?.identity?.id&&e?.email===t?.email&&e?.name===t?.name&&e?.avatarUrl===t?.avatarUrl}function Vf(e,t=``,n=``,r=Wf,a={}){let o=e,s=a.persistDefaultConnectionSettings!==!1,c={gatewayUrl:o.gatewayUrl,token:o.token,bootstrapToken:n,...a.bootstrapProfile?{bootstrapProfile:a.bootstrapProfile}:{},password:t},l=0,u={client:null,phase:`stopped`,offlineStable:!1,hello:null,canvasPluginSurfaceUrl:null,assistantAgentId:null,sessionKey:o.sessionKey,lastError:null,lastErrorCode:null,lastErrorAuthReason:null,selfUser:null},d=null,f=null,p=null,m=null,h=!1,g=0,_=!1,v=!0,y=e=>!v&&d===e,b=null,S=null,C=new Set,w=new Set,T=new Set,E=[],ee=()=>{b!==null&&(globalThis.clearTimeout(b),b=null)},D=()=>{S!==null&&(globalThis.clearTimeout(S),S=null)},O=e=>{D(),S=globalThis.setTimeout(()=>{S=null,v||j({...u,restartPending:!1})},i((e??0)*3,{minMs:15e3}))},k=()=>{v||u.phase===`connected`||u.offlineStable||b!==null||(b=globalThis.setTimeout(()=>{b=null,!v&&u.phase!==`connected`&&j({...u,offlineStable:!0})},Gf))},j=e=>{e.phase===`connected`?(ee(),u=e.offlineStable?{...e,offlineStable:!1}:e):(u={...e,suspensionPhase:void 0},k()),zf(C,u,`snapshot`,e=>e===u)},M=()=>{if(f)return Promise.resolve(f);if(p)return p;let e=R(async()=>{let{createCanvasSurfaceLease:e}=await import(`./canvas-surface-lease.runtime-D9IH9B8w.js`);return{createCanvasSurfaceLease:e}},__vite__mapDeps([74,13,2,3,4,5,6,7,8,9,10,11,12,1,14,15,16]),import.meta.url).then(({createCanvasSurfaceLease:e})=>{let t=e({request:(e,t)=>{let n=m;return!n||d!==n?Promise.reject(Error(`canvas surface lease has no current gateway client`)):n.request(e,t)},onChange:e=>{!m||d!==m||j({...u,canvasPluginSurfaceUrl:e})}});return f=t,t});return p=e,e.catch(()=>{p===e&&(p=null)}),e},te=e=>(m=null,f?.stop(),g+=1,h=!0,m=e,Ei(),g),ne=(e,t,n)=>{M().then(r=>{h&&g===t&&m===e&&d===e&&r.start(n)}).catch(()=>{})},P=()=>{if(!h){m=null;return}g+=1,h=!1,m=null,f?.stop(),Ei()},re=(e,t=!1)=>{let n={...o,...e};if(!s&&!t){o=n,(e.gatewayUrl!==void 0||e.token!==void 0)&&bd(n.gatewayUrl,n.token);return}s=!0,o=Ed(e,{selectGateway:t})},ie=e=>{let t=d;if(e.event===`gateway.suspension`){let n=Rf(e.payload);if(n&&(j({...u,suspensionPhase:n}),!y(t)))return}else if(e.event===`shutdown`){let n=e.payload,r=n&&typeof n==`object`&&`restartExpectedMs`in n?n.restartExpectedMs:void 0;if(typeof r==`number`&&(O(r),j({...u,restartPending:!0}),!y(t)))return}else if(e.event===`presence`){let n=Pf(e.payload);if(n){let e=Ff(n,d?.instanceId);if(e&&!Bf(u.selfUser,e)&&(j({...u,selfUser:e}),!y(t)))return}}E=[{ts:Date.now(),event:e.event,payload:e.payload},...E].slice(0,250),zf(T,E,`event`,e=>e===E&&y(t))},ae=(e={})=>{v=!1;let{sessionKey:t,...n}=e,i=n.gatewayUrl??c.gatewayUrl,f=x(i)!==x(c.gatewayUrl),p=yd(c.gatewayUrl,i,c),m={...c,...n,...f&&n.token===void 0?{token:p.token}:{},...f&&n.password===void 0?{password:p.password}:{},...f&&n.bootstrapToken===void 0?{bootstrapToken:``,bootstrapProfile:void 0}:{},...n.bootstrapToken!==void 0&&n.bootstrapProfile===void 0?{bootstrapProfile:void 0}:{}};(m.gatewayUrl!==c.gatewayUrl||m.token!==c.token||m.password!==c.password||m.bootstrapToken!==c.bootstrapToken||m.bootstrapProfile!==c.bootstrapProfile)&&(l+=1,Mr());let h=n.gatewayUrl!==void 0&&n.gatewayUrl!==c.gatewayUrl,g=h?_d(m.gatewayUrl):null,b=t!==void 0,S=b?t.trim():g?.sessionKey??u.sessionKey;h&&(_=!1),c=m;let C=e=>{Ur(m.gatewayUrl,mf({hello:e,settings:m,password:m.password}),a.resourceBasePath)};C(),re({gatewayUrl:m.gatewayUrl,token:m.token,...b?{sessionKey:S,lastActiveSessionKey:S}:g??{},...g?{selectedAgentId:g.selectedAgentId}:{}},s||h),P(),d?.stop();let T=r({url:m.gatewayUrl,token:m.token.trim()?m.token:void 0,bootstrapToken:m.bootstrapToken.trim()?m.bootstrapToken:void 0,bootstrapProfile:m.bootstrapProfile,password:m.password.trim()?m.password:void 0,clientName:a.clientOptions?.clientName??`openclaw-control-ui`,clientVersion:sa.version??`dev`,clientBuildId:sa.buildId,platform:a.clientOptions?.platform,deviceFamily:a.clientOptions?.deviceFamily,mode:a.clientOptions?.mode??`webchat`,instanceId:a.clientOptions?.instanceId??In(),scopes:a.clientOptions?.scopes,onHello:e=>{if(d!==T)return;let t=!!e.server?.buildId?.trim();if(Hf(m.gatewayUrl)&&(t||_)&&Vi({version:e.server?.version,buildId:e.server?.buildId,controlUiBuildSource:e.server?.controlUiBuildSource})){j({...u,client:T,phase:`reconnecting`,hello:e,canvasPluginSurfaceUrl:null,selfUser:null,lastError:null,lastErrorCode:null,lastErrorAuthReason:null});let t=e.server?.buildId?.trim()||e.server?.version?.trim();t&&Pc({buildId:t});return}C(e),c={...c,bootstrapToken:``,bootstrapProfile:void 0},s&&(o=Sd());let n=Pi({hello:e}),r=Di(u.sessionKey,e),i=Di(o.lastActiveSessionKey,e);(r!==o.sessionKey||i!==o.lastActiveSessionKey)&&re({sessionKey:r,lastActiveSessionKey:i}),_=!0;let a=Uf(e.pluginSurfaceUrls?.canvas),l=te(T);D(),j({...u,client:T,phase:`connected`,restartPending:!1,suspensionPhase:Rf(N(e.snapshot)?.suspension),hello:e,canvasPluginSurfaceUrl:a,assistantAgentId:n?.defaultAgentId?.trim()||null,sessionKey:r,lastError:null,lastErrorCode:null,lastErrorAuthReason:null,selfUser:Ff(Pf(e.snapshot)??[],T.instanceId)}),ne(T,l,a??void 0)},onRecoveryScopeChange:()=>{d===T&&u.phase===`connected`&&j({...u})},onClose:({code:e,reason:t,error:n,willRetry:r})=>{if(d!==T)return;P();let i=Be(n?.details);i&&Pc({buildId:i});let a=i===null&&!_&&r&&Ae(n);if(a&&u.phase===`starting`)return;let o=Ms(n)??n?.code??null,s=A(n);s&&O(),j({...u,client:T,phase:i===null?a?`starting`:_?r?`reconnecting`:`offline`:r?`connecting`:`stopped`:`reload-required`,hello:null,canvasPluginSurfaceUrl:null,selfUser:null,restartPending:s||u.restartPending===!0,lastError:a?null:n?.message?vt(n.message):`disconnected (${e}): ${ht(t,K(`common.unknown`))}`,lastErrorCode:a?null:o,lastErrorAuthReason:a?null:Cr(n?.details)})},onGap:({expected:e,received:t})=>{y(T)&&(j({...u,lastError:`event gap detected (expected seq ${e}, got ${t}); reconnecting`,lastErrorCode:null,lastErrorAuthReason:null}),y(T)&&ae())},onEvent:e=>{if(d===T){try{ie(e)}catch(e){console.error(`[gateway] event handler error:`,e)}zf(w,e,`event listener`,()=>y(T))}}});d=T,j({...u,client:T,phase:_?`reconnecting`:`connecting`,hello:null,canvasPluginSurfaceUrl:null,assistantAgentId:null,selfUser:null,sessionKey:S,lastError:null,lastErrorCode:null,lastErrorAuthReason:null}),y(T)&&T.start()};return{get snapshot(){return u},get connection(){return c},get connectionRevision(){return l},get eventLog(){return E},connect:ae,setSessionKey:e=>{let t=e.trim();!t||t===u.sessionKey||(re({sessionKey:t,lastActiveSessionKey:t}),j({...u,sessionKey:t}))},start:()=>ae(),stop:()=>{v=!0,ee(),D(),P(),d?.stop(),d=null,_=!1,j({...u,client:null,phase:`stopped`,offlineStable:!1,restartPending:!1,hello:null,canvasPluginSurfaceUrl:null,assistantAgentId:null,selfUser:null,lastError:null,lastErrorCode:null,lastErrorAuthReason:null})},subscribe:e=>(C.add(e),()=>C.delete(e)),subscribeEventLog:e=>(T.add(e),()=>T.delete(e)),subscribeEvents:e=>(w.add(e),()=>w.delete(e)),updateSelfUser:e=>{u.selfUser&&j({...u,selfUser:{...u.selfUser,...e}})}}}function Hf(e){try{return new URL(e.replace(/^ws/u,`http`)).origin===globalThis.location?.origin}catch{return!1}}function Uf(e){return e?.trim()||null}var Wf,Gf;function Kf(){return(Kf=e((()=>{Ie(),we(),Ze(),Ye(),$s(),la(),G(),ft(),Dr(),sn(),ur(),Vt(),nt(),wt(),$r(),_f(),tf(),Jc(),I(),Wf=e=>new Zs(e),Gf=2e3})))()}function qf(){return window.chrome?.webview}function Jf(e){qf()?.postMessage(e)}function Yf(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.type!=`string`)return null;if(t.type===`draft-text`){let e=t.payload&&typeof t.payload==`object`?t.payload.text:void 0;if(typeof e==`string`)return e}return null}function Xf(){let e=qf();if(!e)return{subscribe:()=>()=>{},dispose:()=>{}};let t=null,n=new Set,r=e=>{let r=Yf(e.data);if(r!==null){if(n.size===0){t=r;return}for(let e of n)e(r)}};return e.addEventListener(`message`,r),Jf({type:`ready`}),{subscribe(e){if(n.add(e),t!==null){let n=t;t=null,e(n)}return()=>n.delete(e)},dispose(){n.clear(),t=null,e.removeEventListener(`message`,r)}}}function Zf(){let e=window.webkit?.messageHandlers?.openclawLink;return e?.postMessage.bind(e)}function Qf(){return window.webkit?.messageHandlers?.openclawUpdate}function $f(){return Qf()!==void 0}function ep(){let e=Qf();return e?(e.postMessage.bind(e)({type:`start-update`}),window.dispatchEvent(new CustomEvent(cp)),!0):!1}function tp(e){if(!e.isTrusted)return null;let t=Ct(e);if(!t||t.hasAttribute(`download`)||t.hasAttribute(`data-file-path`))return null;try{let e=new URL(t.href,window.location.href);return e.protocol===`mailto:`||e.protocol===`tel:`?{anchor:t,url:e}:null}catch{return null}}function np(e){let t=e.composedPath(),n=t.find(e=>e instanceof HTMLElement&&e.localName===`openclaw-modal-dialog`);if(n instanceof HTMLElement)return n;for(let e of t)if(e instanceof HTMLDialogElement&&e.open&&e.getRootNode()===document)return e;return document.body}function rp(e,t,n){try{return e({type:`open-link`,url:t.href,target:n}),!0}catch{return!1}}function ip(e){return!e.defaultPrevented&&!e.shiftKey&&!e.altKey&&(e.type===`click`&&e.button===0||e.type===`auxclick`&&e.button===1)}function ap(e={}){if(typeof window>`u`||typeof document>`u`)return{dispose(){}};let t=Zf();if(!t&&!e.shouldOpenInControlUiBrowser&&!e.onNativeUpdateDeclined)return{dispose(){}};let n=null,r=!1,i=()=>{r=!0},a=()=>{r&&(r=!1,e.onNativeUpdateDeclined?.())},o=e=>{e&&n!==e||(n?.remove(),n=null)},s=(e,t,r,i,a,s)=>{o();let c=document.createElement(`openclaw-native-link-menu`);c.x=i,c.y=a,c.trigger=t,c.onClose=()=>o(c),c.onAction=t=>{if(t===`copy`){ar(r.href);return}rp(e,r,t)},n=c,s.append(c),Ia(c)},c=n=>{let r=Bt(n);if(r&&ip(n)&&e.shouldOpenInControlUiBrowser?.()){window.dispatchEvent(new CustomEvent(Qi,{detail:{open:!0,url:r.url.href}})),o(),n.preventDefault();return}if(!t||!Ft(n))return;let i=tp(n),a=i??r,s=i?`external`:`inline`;!a||!rp(t,a.url,s)||(o(),n.preventDefault())},l=e=>{if(!t||e.defaultPrevented)return;let n=Bt(e);n&&(e.preventDefault(),e.stopPropagation(),s(t,n.anchor,n.url,e.clientX,e.clientY,np(e)))};return window.addEventListener(`click`,c),window.addEventListener(`auxclick`,c),window.addEventListener(cp,i),window.addEventListener(op,a),t&&document.addEventListener(`contextmenu`,l,!0),{dispose(){window.removeEventListener(`click`,c),window.removeEventListener(`auxclick`,c),window.removeEventListener(cp,i),window.removeEventListener(op,a),document.removeEventListener(`contextmenu`,l,!0),o()}}}var op,sp,cp;function lp(){return(lp=e((()=>{ya(),pa(),da(),op=`openclaw:native-update-declined`,sp=`openclaw:native-update-availability-changed`,cp=`openclaw:native-update-posted`})))()}function up(e,t){if(!Array.isArray(e))return;let n=e.filter(e=>{if(!b(e))return!1;let{startIndex:n,endIndex:r}=e;return Number.isSafeInteger(n)&&Number.isSafeInteger(r)&&typeof n==`number`&&typeof r==`number`&&n>=0&&r>n&&r<=t});return n.length>0?n:void 0}function dp(e){if(!Array.isArray(e))return;let t=e.filter(e=>e===`allow-once`||e===`allow-always`||e===`deny`);return t.length>0?t:void 0}function fp(e){if(!b(e))return null;switch(e.kind){case`standing-grant`:return typeof e.automation==`string`&&typeof e.command==`string`?{kind:`standing-grant`,automation:e.automation,command:e.command,...typeof e.expiresInDays==`number`?{expiresInDays:e.expiresInDays}:{}}:null;case`message-send`:return typeof e.target==`string`&&typeof e.recipientCount==`number`?{kind:`message-send`,target:e.target,recipientCount:e.recipientCount,...Array.isArray(e.recipients)&&e.recipients.every(e=>typeof e==`string`)?{recipients:e.recipients}:{},...e.audience===`internal`||e.audience===`external`?{audience:e.audience}:{}}:null;case`payment`:return typeof e.amount==`string`&&typeof e.currency==`string`&&typeof e.target==`string`?{kind:`payment`,amount:e.amount,currency:e.currency,target:e.target}:null;case`external-post`:return typeof e.target==`string`&&(e.visibility===`public`||e.visibility===`restricted`)?{kind:`external-post`,target:e.target,visibility:e.visibility}:null;default:return null}}function pp(e){if(!b(e))return null;let t=z(e.id)??``,n=e.request;if(!t||!b(n))return null;let r=typeof n.command==`string`?n.command:``;if(r.trim().length===0)return null;let i=typeof e.createdAtMs==`number`?e.createdAtMs:0,a=typeof e.expiresAtMs==`number`?e.expiresAtMs:0;return!i||!a?null:{id:t,kind:`exec`,request:{command:r,cwd:typeof n.cwd==`string`?n.cwd:null,host:typeof n.host==`string`?n.host:null,security:typeof n.security==`string`?n.security:null,ask:typeof n.ask==`string`?n.ask:null,agentId:typeof n.agentId==`string`?n.agentId:null,resolvedPath:typeof n.resolvedPath==`string`?n.resolvedPath:null,sessionKey:typeof n.sessionKey==`string`?n.sessionKey:null,runId:typeof n.runId==`string`?n.runId:null,commandSpans:up(n.commandSpans,r.length),allowedDecisions:dp(n.allowedDecisions),scope:fp(n.scope)},createdAtMs:i,expiresAtMs:a}}function mp(e,t){if(e!==`exec.approval.resolved`&&e!==`plugin.approval.resolved`&&e!==`openclaw.approval.resolved`||!b(t))return null;let n=z(t.id)??``;return n?{id:n,decision:typeof t.decision==`string`?t.decision:null,resolvedBy:typeof t.resolvedBy==`string`?t.resolvedBy:null,ts:typeof t.ts==`number`?t.ts:null}:null}function hp(e){if(!b(e))return null;let t=z(e.id)??``;if(!t)return null;let n=typeof e.createdAtMs==`number`?e.createdAtMs:0,r=typeof e.expiresAtMs==`number`?e.expiresAtMs:0;if(!n||!r)return null;let i=b(e.request)?e.request:{},a=z(i.title)??``;if(!a)return null;let o=typeof i.description==`string`?i.description:null,s=typeof i.severity==`string`?i.severity:null,c=typeof i.pluginId==`string`?i.pluginId:null;return{id:t,kind:`plugin`,request:{command:a,agentId:typeof i.agentId==`string`?i.agentId:null,sessionKey:typeof i.sessionKey==`string`?i.sessionKey:null,allowedDecisions:dp(i.allowedDecisions)},pluginTitle:a,pluginDescription:o,pluginSeverity:s,pluginId:c,createdAtMs:n,expiresAtMs:r}}function gp(e){if(!b(e))return null;let t=z(e.id)??``,n=b(e.request)?e.request:{},r=z(n.title)??``,i=z(n.description),a=z(n.command),o=z(n.proposalHash),s=typeof e.createdAtMs==`number`?e.createdAtMs:0,c=typeof e.expiresAtMs==`number`?e.expiresAtMs:0;return!t||!r||!i||!a||!o||!s||!c?null:{id:t,kind:`system-agent`,request:{command:a,agentId:typeof n.agentId==`string`?n.agentId:null,sessionKey:typeof n.sessionKey==`string`?n.sessionKey:null,allowedDecisions:[`allow-once`,`deny`]},pluginTitle:r,pluginDescription:i,proposalHash:o,createdAtMs:s,expiresAtMs:c}}function _p(e,t){return e===`exec.approval.requested`?pp(t):e===`plugin.approval.requested`?hp(t):e===`openclaw.approval.requested`?gp(t):null}async function vp(e,t,n){if(t.kind===`system-agent`){await e.request(`approval.resolve`,{id:t.id,kind:`system-agent`,decision:n});return}let r=t.kind===`plugin`?`plugin.approval.resolve`:`exec.approval.resolve`;await e.request(r,{id:t.id,decision:n})}function yp(e){let t=Date.now();return e.filter(e=>e.expiresAtMs>t)}function bp(e,t){let n=yp(e).filter(e=>e.id!==t.id);return n.push(t),Ep(n)}function xp(e,t){return yp(e).filter(e=>e.id!==t)}function Sp(e){return b(e)?z(e.gatewayCode)??null:null}function Cp(e){if(!b(e))return null;let{details:t}=e;return b(t)?z(t.reason)??null:null}function wp(e){if(!(e instanceof Error))return!1;let t=Sp(e),n=Cp(e);return n===Lp||n===Rp||t===Rp||/unknown or expired approval id/i.test(e.message)}function Tp(e,t){return Array.isArray(e)?e.flatMap(e=>{let n=t(e);return n?[n]:[]}):null}function Ep(e){return e.toSorted((e,t)=>e.createdAtMs-t.createdAtMs||e.id.localeCompare(t.id))}function Dp(e,t){return yp(e).filter(e=>e.kind===t)}function Op(e,t,n,r){let i=new Set(t.map(e=>e.id)),a=yp(n),o=new Set(a.map(e=>e.id)),s=yp(e).filter(e=>!r.has(e.id)&&(!i.has(e.id)||o.has(e.id))),c=new Set(s.map(e=>e.id)),l=a.filter(e=>!i.has(e.id)&&!c.has(e.id));return Ep([...s,...l])}function kp(e,t){let n=e.execApprovalExpiryTimers?.get(t);n!==void 0&&(globalThis.clearTimeout(n),e.execApprovalExpiryTimers?.delete(t))}function Ap(e,t){kp(e,t.id);let n=globalThis.setTimeout(()=>{let r=e.execApprovalExpiryTimers?.get(t.id);if(r!==void 0&&r!==n)return;e.execApprovalExpiryTimers?.delete(t.id);let i=e.execApprovalQueue.some(e=>e.id===t.id);jp(e,t.id),i&&e.execApprovalChanged?.()},Math.max(0,t.expiresAtMs-Date.now()+500));e.execApprovalExpiryTimers?.set(t.id,n)}function jp(e,t){kp(e,t),e.execApprovalQueue=xp(e.execApprovalQueue,t),e.execApprovalErrors.delete(t)}function Mp(e){let t=new Set(e.execApprovalQueue.map(e=>e.id));for(let n of e.execApprovalErrors.keys())t.has(n)||e.execApprovalErrors.delete(n)}function Np(e){for(let t of e.execApprovalExpiryTimers?.values()??[])globalThis.clearTimeout(t);e.execApprovalExpiryTimers?.clear()}function Pp(e,t){e.execApprovalQueue=bp(e.execApprovalQueue,t),Ap(e,t)}async function Fp(e,t){let n=e.client;if(!n||t?.isCurrentClient&&!t.isCurrentClient(n))return!1;let r={removedIds:new Set},i=e.execApprovalRefreshes??=new Set;i.add(r);let a=yp(e.execApprovalQueue);try{let[i,o,s]=await Promise.allSettled([n.request(`exec.approval.list`,{}),n.request(`plugin.approval.list`,{}),n.request(`openclaw.approval.list`,{})]),c=i.status===`fulfilled`?Tp(i.value,pp)??[]:Dp(e.execApprovalQueue,`exec`),l=o.status===`fulfilled`?Tp(o.value,hp)??[]:Dp(e.execApprovalQueue,`plugin`),u=s.status===`fulfilled`?Tp(s.value,gp)??[]:Dp(e.execApprovalQueue,`system-agent`),d=Op(Ep([...c,...l,...u]),a,e.execApprovalQueue,r.removedIds);if(t?.isCurrentClient&&!t.isCurrentClient(n))return!1;e.execApprovalQueue=d,Mp(e);let f=new Set(d.map(e=>e.id));for(let t of e.execApprovalExpiryTimers?.keys()??[])f.has(t)||kp(e,t);for(let t of d)Ap(e,t);return!0}finally{i.delete(r),i.size===0&&(e.execApprovalRefreshes=void 0)}}function Ip(e,t){jp(e,t);for(let n of e.execApprovalRefreshes??[])n.removedIds.add(t)}var Lp,Rp;function zp(){return(zp=e((()=>{Lp=`APPROVAL_ALREADY_RESOLVED`,Rp=`APPROVAL_NOT_FOUND`})))()}function Bp(e){let t=J(e);return t.canAdmin||t.canPair}function Vp(e,t){let n=J(t);return{access:n,reviewChanged:e.canReviewApprovals!==n.canReviewApprovals,grantChanged:e.canGrantApprovals!==n.canGrantApprovals,grantRevoked:e.canGrantApprovals&&!n.canGrantApprovals,adminRevoked:e.canAdmin&&!n.canAdmin,pairingChanged:e.canPair!==n.canPair,pairingSetupRevoked:(e.canAdmin||e.canPair)&&!(n.canAdmin||n.canPair)}}function Hp(e){let t=0;return{invalidate(n={}){t+=1,n.clear&&(e.state.pendingCount=0)},async refresh(){let n=e.gateway.snapshot.client;if(!n||e.gateway.snapshot.phase!==`connected`||e.isDisposed()||!e.state.devicePairSetupOpen||!Bp(e.gateway.snapshot))return;let r=++t,i;try{i=await n.request(`device.pair.list`,{})}catch{return}e.isDisposed()||r!==t||e.gateway.snapshot.client!==n||e.gateway.snapshot.phase!==`connected`||!e.state.devicePairSetupOpen||!Bp(e.gateway.snapshot)||(e.state.pendingCount=Array.isArray(i.pending)?i.pending.length:0,e.publish())}}}function Up(e){return async(t,n=e.getConnectedEpoch(),r=e.getReviewGeneration())=>{!e.canReview()||r!==e.getReviewGeneration()||!J(e.gateway.snapshot).canReviewApprovals||await Fp(e.state,{isCurrentClient:i=>i===t&&n===e.getConnectedEpoch()&&r===e.getReviewGeneration()&&e.canReview()&&J(e.gateway.snapshot).canReviewApprovals&&e.isCurrentClient(t)})&&!e.isDisposed()&&e.publish()}}function Wp(){return(Wp=e((()=>{zp(),cc()})))()}function Gp(e,t){return Number.isInteger(e)&&e>=t}function Kp(e){let t=e?.snapshot;if(!b(t))return null;let n=t.updateAvailable;return qp(n)}function qp(e){if(!b(e)||!Ue(e.currentVersion)||!Ue(e.latestVersion)||!Ue(e.channel))return null;let t=e.commits,n=Array.isArray(t)?t.filter(e=>b(e)&&Ue(e.sha)&&typeof e.subject==`string`).map(e=>({sha:e.sha,subject:e.subject})).slice(0,em):void 0;return{currentVersion:e.currentVersion,latestVersion:e.latestVersion,channel:e.channel,...Ue(e.currentSha)?{currentSha:e.currentSha}:{},...Ue(e.upstreamRef)?{upstreamRef:e.upstreamRef}:{},...Ue(e.upstreamSha)?{upstreamSha:e.upstreamSha}:{},...Gp(e.commitsBehind,0)?{commitsBehind:e.commitsBehind}:{},...n?.length?{commits:n}:{}}}function Jp(e){return b(e)?e.kind===`package`?Ue(e.version)?{kind:`package`,version:e.version}:null:e.kind===`git`&&Ue(e.upstreamRef)&&Ue(e.upstreamSha)&&Gp(e.commitsBehind,0)?{kind:`git`,upstreamRef:e.upstreamRef,upstreamSha:e.upstreamSha,commitsBehind:e.commitsBehind}:null:null}function Yp(e){return{...Ue(e.currentSha)?{currentSha:e.currentSha}:{},...Gp(e.commitAtMs,0)?{commitAtMs:e.commitAtMs}:{},...Gp(e.installedAtMs,0)?{installedAtMs:e.installedAtMs}:{}}}function Xp(e){if(!b(e))return null;let t=Yp(e);return e.status===`current`?{...t,status:`current`}:e.status===`behind`&&Gp(e.commitsBehind,1)?{...t,status:`behind`,commitsBehind:e.commitsBehind}:e.status===`ahead`&&Gp(e.commitsAhead,1)?{...t,status:`ahead`,commitsAhead:e.commitsAhead}:e.status===`diverged`&&Gp(e.commitsAhead,1)&&Gp(e.commitsBehind,1)?{...t,status:`diverged`,commitsAhead:e.commitsAhead,commitsBehind:e.commitsBehind}:e.status===`unavailable`&&(e.reason===`fetch-failed`||e.reason===`no-upstream`||e.reason===`no-upstream-sha`||e.reason===`comparison-failed`||e.reason===`git-unavailable`)?{...t,status:`unavailable`,reason:e.reason}:null}function Zp(e){return!b(e)||!Ue(e.id)||e.state!==`waiting-for-idle`&&e.state!==`countdown`&&e.state!==`applying`||!Gp(e.announcedAtMs,0)||!Gp(e.forceAtMs,0)||!Gp(e.updatedAtMs,0)?null:{id:e.id,state:e.state,announcedAtMs:e.announcedAtMs,...Gp(e.applyAtMs,0)?{applyAtMs:e.applyAtMs}:{},...Gp(e.holdUntilMs,0)?{holdUntilMs:e.holdUntilMs}:{},forceAtMs:e.forceAtMs,updatedAtMs:e.updatedAtMs}}function Qp(e){if(!b(e)||!Ue(e.channel)||typeof e.autoEnabled!=`boolean`)return null;let t=b(e.install)?e.install:null,n=t?.kind,r=n===`package`||n===`git`||n===`unknown`?n:void 0;if(e.install!==void 0&&r===void 0)return null;let i=t?.git===void 0?void 0:Xp(t.git);if(t?.git!==void 0&&!i)return null;let a=e.target===void 0?void 0:Jp(e.target),o=e.campaign===void 0?void 0:Zp(e.campaign);return e.target!==void 0&&!a||e.campaign!==void 0&&!o?null:{channel:e.channel,autoEnabled:e.autoEnabled,...r?{install:{kind:r,...i?{git:i}:{}}}:{},...a?{target:a}:{},...o?{campaign:o}:{}}}function $p(e){let t=e?.snapshot;return b(t)?Qp(t.updateSchedule):null}var em;function tm(){return(tm=e((()=>{em=5})))()}function nm(e){let t=e?.stats?.handoffId?.trim();return t&&t.length<=256?t:null}function rm(e,t){if(e?.kind!==`update`||!e.status)return null;let n=e.stats,r=je({status:e.status,reason:n?.reason??void 0}),i=r!==`succeeded`&&r!==`pending`,a=i?am(e):null,o=i&&typeof e.ts==`number`?{timestampMs:e.ts,status:e.status,reason:n?.reason?.trim()||`unexpected-error`,installKind:n?.mode?.trim()||null,beforeVersion:n?.before?.version?.trim()||null,beforeSha:n?.before?.sha?.trim()||null,afterVersion:n?.after?.version?.trim()||null,afterSha:n?.after?.sha?.trim()||null,failure:a}:null,s=i?um({status:e.status,reason:n?.reason??void 0,cause:a}):null;s&&r===`failed`&&(s.text+=` ${K(`updates.triage.hostHint`)}`);let c={id:nm(e)??(typeof e.ts==`number`?`recorded:${e.ts}`:null),timestampMs:e.ts??null},l=c.id??t,u=r===`failed`&&l&&s?{id:l,outcome:r,attempt:o,banner:s}:null;return u&&(c.id!==null||c.timestampMs!==null)&&(u.reconciledRecord=c),{outcome:r,record:c,attempt:o,banner:s,failure:u}}function im(e){let t=ht(e).split(`
`).map(e=>e.trim()).filter(Boolean).at(-1);return t?t.slice(0,pm):null}function am(e){let t=e?.stats?.steps,n=Array.isArray(t)?t.findLast(e=>typeof e?.log?.exitCode==`number`&&e.log.exitCode!==0):void 0,r=im(n?.log?.stderrTail)??im(n?.log?.stdoutTail),i=n?.name?.trim();return i&&r?{step:i,detail:r}:null}async function om(e,t,n={},r){try{return await e.request(`update.status`,n,{timeoutMs:t})}catch(e){return r?.(e),null}}function sm(e){let t=0,n=null;return async(r=`manual`)=>{let i=e.getClient(),a=e.getEpoch();if(!i||!e.canRefresh()||!e.isCurrent(i,a)||r===`background`&&n?.())return;let o=r===`manual`,s=++t,c=e.getRevision(),l=()=>s===t&&e.isCurrent(i,a),u=()=>l()&&e.canRefresh()&&c===e.getRevision();o&&(n=u,e.onRefreshing(!0));try{let t=await om(i,5e3,o?{refreshCheckout:!0}:{},t=>{r!==`background`&&u()&&e.onError(t)});t&&u()&&e.onStatus(t)}finally{l()&&(n=null,e.onRefreshing(!1))}}}function cm(e,t){let n=rm(e.sentinel),r=Object.hasOwn(e,`schedule`)?Qp(e.schedule):void 0;return{failure:n?.failure??null,updateStatusBanner:n?n.banner:t.updateStatusBanner,recordedUpdateAttempt:n?n.attempt:t.recordedUpdateAttempt,...Object.hasOwn(e,`updateAvailable`)?{updateAvailable:qp(e.updateAvailable)}:{},...r===void 0?{}:{updateSchedule:r,heldUpdateCampaignId:r?.campaign?.holdUntilMs===void 0?t.heldUpdateCampaignId:r.campaign.id}}}function lm(e){if(e.status!==`failed`&&e.status!==`rolled-back`)return null;let t=e.steps.findLast(e=>e.status===`failed`);return{id:e.runId,reconciledRecord:{id:e.runId,timestampMs:e.finishedAtMs??e.updatedAtMs},outcome:`failed`,banner:{tone:`danger`,text:F(e).markdown},attempt:{timestampMs:e.finishedAtMs??e.updatedAtMs,status:e.status,reason:e.reason??`unexpected-error`,installKind:e.target.kind??null,beforeVersion:e.before.version??null,beforeSha:e.before.sha??null,afterVersion:e.after.version??null,afterSha:e.after.sha??null,failure:t?{step:t.step,detail:t.detail??``}:null}}}function um(e){let t=(e.status??`error`).trim()||`error`,n=(e.reason??`unexpected-error`).trim()||`unexpected-error`,r=K(fm[n]??`updates.failureReasons.default`),i=e.cause;return{tone:t===`skipped`?`warn`:`danger`,text:i?`${K(`updates.failedAtStep`,{step:i.step,cause:i.detail})} ${r}`:K(`updates.status`,{status:t,reason:n,guidance:r})}}function dm(){return{tone:`danger`,text:K(`updates.outcomeUnknown`)}}var fm,pm;function mm(){return(mm=e((()=>{Se(),Re(),G(),sn(),tm(),fm={dirty:`updates.failureReasons.dirty`,"no-upstream":`updates.failureReasons.noUpstream`,"not-git-install":`updates.failureReasons.notGitInstall`,"not-openclaw-root":`updates.failureReasons.notOpenclawRoot`,"deps-install-failed":`updates.failureReasons.depsInstallFailed`,"build-failed":`updates.failureReasons.buildFailed`,"build-dirty":`updates.failureReasons.buildDirty`,"ui-build-failed":`updates.failureReasons.uiBuildFailed`,"global-install-failed":`updates.failureReasons.globalInstallFailed`,"restart-disabled":`updates.failureReasons.restartDisabled`,"restart-unavailable":`updates.failureReasons.restartUnavailable`,"restart-unhealthy":`updates.failureReasons.restartUnhealthy`,"restart-revision-mismatch":`updates.failureReasons.restartRevisionMismatch`,"restart-revision-unavailable":`updates.failureReasons.restartRevisionUnavailable`,"already-current":`updates.failureReasons.alreadyCurrent`,"managed-service-handoff-already-running":`updates.failureReasons.managedServiceHandoffAlreadyRunning`,"managed-service-handoff-unavailable":`updates.failureReasons.managedServiceHandoffUnavailable`,"doctor-failed":`updates.failureReasons.doctorFailed`,"managed-service-handoff-failed":`updates.failureReasons.managedServiceHandoffFailed`,"managed-service-handoff-spawn-failed":`updates.failureReasons.managedServiceHandoffSpawnFailed`,"managed-service-handoff-helper-failed":`updates.failureReasons.managedServiceHandoffFailed`,"managed-service-handoff-parent-timeout":`updates.failureReasons.managedServiceHandoffParentTimeout`},pm=180})))()}function hm(){let e=lt(),t=xi(),n=(e,t)=>{try{let n=e?.getItem(t);if(n==null)return[];let r=n.length<32768?JSON.parse(n):null;return Array.isArray(r)&&r.every(e=>typeof e==`string`)?r.slice(-32):null}catch{return null}},r=e=>`openclaw:control-ui:update-${e}:v1`,i=(e,t,n)=>JSON.stringify([e,t,n]),a=(e,t,i)=>{try{if(!e)return!1;let a=n(e,r(t));return a?(e.setItem(r(t),JSON.stringify([...new Set([...a,i])].slice(-32))),!0):!1}catch{return!1}};return{acknowledged:(t,a,o)=>(n(e,r(`acknowledged`))??[]).includes(i(t,a,o)),acknowledge:(t,n,r)=>a(e,`acknowledged`,i(t,n,r)),triaged:(e,a,o)=>(n(t,r(`triaged`))??[]).includes(i(e,a,o)),recordTriage:(e,n,r)=>a(t,`triaged`,i(e,n,r))}}function gm(){return(gm=e((()=>{})))()}function _m(e,t,n){let r=e?.campaign,i=t?.campaign;return!i||n&&r?.id===i.id&&r.updatedAtMs===i.updatedAtMs}function vm(e,t){return e?.campaign?.holdUntilMs===void 0?t:e.campaign.id}function ym(e,t){let n=$p(t);return{updateAvailable:Kp(t),updateSchedule:n,heldUpdateCampaignId:vm(n,e.heldUpdateCampaignId),updateCampaignStatusHydrated:_m(e.updateSchedule,n,e.updateCampaignStatusHydrated)}}function bm(e,t){let n=t&&Object.hasOwn(t,`schedule`)?Qp(t.schedule):void 0;return{updateAvailable:qp(t?.updateAvailable),...n===void 0?{}:{updateSchedule:n,heldUpdateCampaignId:vm(n,e.heldUpdateCampaignId),updateCampaignStatusHydrated:_m(e.updateSchedule,n,e.updateCampaignStatusHydrated)}}}function xm(e,t=Date.now()){let n=e?.campaign;return n?n.state===`applying`?K(`updates.campaign.applying`):n.holdUntilMs!==void 0&&n.holdUntilMs>t?K(`updates.campaign.held`,{time:Jn(n.holdUntilMs,t)}):n.state===`waiting-for-idle`?K(`updates.campaign.waitingForIdle`,{time:Jn(n.forceAtMs,t)}):K(`updates.campaign.countdown`,{time:Jn(n.applyAtMs??n.forceAtMs,t)}):null}function Sm(e,t){let n=e?.target,r=n?.kind===`git`?n.commitsBehind:t?.commitsBehind;if(r!==void 0)return K(r===1?`updates.target.commitBehind`:`updates.target.commitsBehind`,{count:String(r)});let i=n?.kind===`package`?n.version:t?.latestVersion;return i?K(`updates.target.version`,{version:i}):null}function Cm(e,t,n){let r=t?.target;return!!(n||t?.campaign||e&&e.latestVersion!==e.currentVersion||e?.commitsBehind!==void 0&&e.commitsBehind>0||r?.kind===`git`&&r.commitsBehind>0)}function wm(){return(wm=e((()=>{G(),Pr(),tm()})))()}function Tm(e){let t=null,n=0,r=()=>{n+=1,t!==null&&(globalThis.clearTimeout(t),t=null)},i=async()=>{t=null;let r=n;e.canPoll()&&await e.refresh(),r===n&&a()},a=()=>{if(!e.canPoll()){r();return}t===null&&(t=globalThis.setTimeout(()=>void i(),5e3))};return{stop:r,sync:a}}function Em(e,t,n={}){let r={updateAvailable:null,updateSchedule:null,heldUpdateCampaignId:null,updateRunning:!1,updateStatusRefreshing:!1,updateCampaignStatusHydrated:!0,updateReconciliationPending:!1,updateStatusBanner:null,recordedUpdateAttempt:null,updateRun:null,updateRunAcknowledged:!1,controlUiRefreshRequired:!1},i=!1,a=e.snapshot.client,o=e.snapshot.hello,s=null,c=0,l=J(e.snapshot),u=x(e.connection.gatewayUrl),d=e.snapshot.selfUser?.id??null,f=hm(),p=!1,m=0,h=0,g=0,_=!1,v=null,y=null,S=null,C=t=>!i&&a===t&&e.snapshot.client===t&&e.snapshot.phase===`connected`&&J(e.snapshot).canAdmin;function w(){let t=y,a=u,o=d;if(!t||t===S||r.updateRunning||r.updateReconciliationPending)return;let s=()=>!i&&y===t&&x(e.connection.gatewayUrl)===a&&(e.snapshot.selfUser?.id??null)===o&&J(e.snapshot).canAdmin;!s()||f.triaged(a,o,t.id)||(S=t,n.onUpdateFailure?.(t,{isCurrent:s,admit:()=>s()&&e.snapshot.phase===`connected`&&!r.updateRunning&&!r.updateReconciliationPending&&!f.triaged(a,o,t.id)&&f.recordTriage(a,o,t.id)}))}function T(){let e=r.updateSchedule?.campaign,n=e?.state===`applying`&&r.updateRun?.origin.campaignId!==e.id;r={...r,updateRunning:p||r.updateRun?.status===`running`||n,updateReconciliationPending:v!==null&&(!r.updateRun||r.updateRun.status===`running`)},n&&(y=null),t(),w()}let E=e=>{r={...r,updateStatusBanner:{tone:`danger`,text:K(`updates.error`,{error:vt(e)})}},T()},ee=e=>{let t=r.updateRun;if(t?.runId===e.runId&&t.updatedAtMs>e.updatedAtMs)return;v=e.runId;let n=lm(e);(y?.id!==n?.id||JSON.stringify(y)!==JSON.stringify(n))&&(y=n),r={...r,updateRun:e,updateRunAcknowledged:f.acknowledged(u,d,e.runId),recordedUpdateAttempt:n?.attempt??null,updateStatusBanner:n?.banner??null},T()},D=async()=>{let e=a,t=v;if(!e||!t||!C(e))return;let n=++g,i=c,o=()=>n===g&&i===c&&t===v&&C(e);try{let n=await e.request(`update.runs.get`,{runId:t});if(!o())return;n.run?(ee(n.run),n.run.status!==`running`&&O()):(v=null,r={...r,updateRun:null,updateStatusBanner:dm()},T())}catch(e){o()&&E(e)}},O=sm({getClient:()=>a,getEpoch:()=>c,getRevision:()=>m,canRefresh:()=>!i&&l.canAdmin,isCurrent:(e,t)=>t===c&&C(e),onRefreshing:e=>{r={...r,updateStatusRefreshing:e},T()},onStatus:e=>{let{failure:t,...n}=cm(e,r);r={...r,...n,updateCampaignStatusHydrated:!0};let i=e.activeRun??e.lastRun;if(i&&(!r.updateRun||i.runId===r.updateRun.runId||i.createdAtMs>=r.updateRun.createdAtMs))ee(i);else if(!r.updateRun)y=t,T();else{let e=lm(r.updateRun);r={...r,updateStatusBanner:e?.banner??null,recordedUpdateAttempt:e?.attempt??null},T()}},onError:E}),k=Tm({canPoll:()=>!!(a&&C(a)&&r.updateSchedule?.campaign),refresh:()=>O(`background`)}),A=(e,t)=>n.connectionBootstrap?.run(e,t)??t();return{get snapshot(){return r},synchronizeGateway:t=>{let n=x(e.connection.gatewayUrl),i=t.selfUser?.id??null,f=J(t),_=!l.canAdmin&&f.canAdmin,b=t.phase===`connected`,S=n!==u||b&&i!==d||!!t.hello?.auth&&!f.canAdmin;S&&(h++,g++,m++,v=null,p=!1,y=null,r={...r,updateRun:null,updateRunAcknowledged:!1,updateStatusRefreshing:!1,updateStatusBanner:null,recordedUpdateAttempt:null,heldUpdateCampaignId:null}),u=n,b&&(d=i);let C=b?t.client:null,w=s!==C,E=o!==t.hello;if(l=f,a=t.client,o=t.hello,s=C,w&&(c++,g++,m++,h++,p=!1),!b||!t.client){r={...r,updateAvailable:null,updateSchedule:null,updateStatusRefreshing:!1,updateCampaignStatusHydrated:!0},k.stop(),t.phase===`reload-required`?r={...r,controlUiRefreshRequired:!0}:t.client?t.hello&&(r={...r,controlUiRefreshRequired:!0}):(c=0,r={...r,controlUiRefreshRequired:!1}),T();return}let ee={version:t.hello?.server?.version,buildId:t.hello?.server?.buildId,controlUiBuildSource:t.hello?.server?.controlUiBuildSource};r={...r,...w||E?ym(r,t.hello):{},controlUiRefreshRequired:w?(!!ee.buildId?.trim()||c>1)&&Vi(ee):r.controlUiRefreshRequired},T(),k.sync(),(w||S||_)&&l.canAdmin&&A(`update-run`,()=>v?D():O(`background`))},handleUpdateRunChanged(e){if(!b(e)||typeof e.runId!=`string`||typeof e.updatedAtMs!=`number`||!a||!C(a))return;let t=r.updateRun;t?.runId===e.runId&&e.updatedAtMs<=t.updatedAtMs||(m++,v&&v!==e.runId?O(`completion`):(v=e.runId,D()))},handleUpdateAvailable(e){if(i)return;let t=r.updateSchedule?.campaign;m++,r={...r,...bm(r,e)},T(),k.sync(),t?.state===`applying`&&r.updateSchedule?.campaign?.state!==`applying`&&O(`completion`)},refreshUpdateStatus:O,acknowledgeUpdateRun(){let e=r.updateRun;e&&e.status!==`running`&&(f.acknowledge(u,d,e.runId),r={...r,updateRunAcknowledged:!0},T())},async runUpdate(e){let t=a;if(!t||!C(t)||r.updateRunning||r.updateReconciliationPending)return;let i=++h,o=e?.sessionKey??n.getActiveSessionKey?.();m++,g++,v=null,p=!0,y=null,r={...r,updateRun:null,updateRunAcknowledged:!1,updateStatusBanner:null,recordedUpdateAttempt:null},T();let s=()=>i===h&&C(t);try{if(await n.drainConfigWrites?.(),!s()||r.updateSchedule?.campaign?.state===`applying`)return;let e=await t.request(`update.run`,o?{sessionKey:o}:{});if(!s())return;if(e.runId)v=e.runId,await D();else{let t=rm(e.sentinel?.payload);y=t?.failure??null,r={...r,recordedUpdateAttempt:t?.attempt??null,updateStatusBanner:t?.banner??um({status:e.result?.status??`error`,reason:e.result?.reason})}}}catch(e){s()&&(E(e),await O(`completion`))}finally{s()&&(p=!1,T())}},async holdUpdate(){let t=e.snapshot.client,n=r.updateSchedule?.campaign,a=_||r.updateRunning||r.updateReconciliationPending;if(!t||e.snapshot.phase!==`connected`||i||a||!n||n.state===`applying`||r.heldUpdateCampaignId===n.id||!J(e.snapshot).canAdmin)return!1;let o=h,s=m,c=()=>o===h&&C(t)&&J(e.snapshot).canAdmin;_=!0;try{let e=await t.request(`update.hold`,{});if(!c())return!1;let i=e.schedule&&Qp(e.schedule);return s===m&&(i!==void 0||e.ok)&&(m+=1,r={...r,...i===void 0?{}:{updateSchedule:i},heldUpdateCampaignId:e.ok?n.id:vm(i??r.updateSchedule,r.heldUpdateCampaignId)},T()),e.ok}catch(e){if(c()&&s===m){let t=vt(e);E(t)}return!1}finally{_=!1}},dispose(){i=!0,h++,g++,k.stop()}}}function Dm(){return(Dm=e((()=>{la(),G(),sn(),cc(),mm(),gm(),tm(),wm()})))()}function Om(e){return!!(e&&typeof e==`object`&&`event`in e)}function km(e,t={}){let n=Em(e,g,t),r=(e,n)=>t.connectionBootstrap?.run(e,n)??n(),i={...n.snapshot,approvalQueue:[],approvalBusy:!1,approvalCanGrant:!1,approvalErrors:new Map,devicePairSetupOpen:!1,devicePairSetupLifecycle:{phase:`selection`,access:`full`},devicePairPendingCount:0},a=new Set,o=!1,s=e.snapshot.client,c=null,l=0,u=J(e.snapshot),d=0,f=0,p=null,m=cn({client:e.snapshot.client,connected:e.snapshot.phase===`connected`,onChange:()=>g()}),h={client:s,execApprovalQueue:[],execApprovalBusy:!1,execApprovalErrors:new Map,execApprovalExpiryTimers:new Map};function g(){i={...i,...n.snapshot,approvalQueue:h.execApprovalQueue,approvalBusy:h.execApprovalBusy,approvalCanGrant:J(e.snapshot).canGrantApprovals,approvalErrors:new Map(h.execApprovalErrors),...it(m)};for(let e of a)e(i)}h.execApprovalChanged=g;let _=Hp({gateway:e,state:m,isDisposed:()=>o,publish:g}),v=async e=>{g(),await e,o||(Fn(m,g),g())},y=t=>!o&&s===t&&e.snapshot.client===t&&e.snapshot.phase===`connected`,b=Up({gateway:e,state:h,getConnectedEpoch:()=>l,getReviewGeneration:()=>d,canReview:()=>u.canReviewApprovals,isCurrentClient:y,isDisposed:()=>o,publish:g}),x=e=>{let t=s,i=e.phase===`connected`,a=i?e.client:null,o=c!==a,g=Vp(u,e);if(u=g.access,g.reviewChanged&&(d+=1),g.grantChanged&&(f+=1),g.grantRevoked){let e=p;e&&h.execApprovalQueue.some(t=>t.id===e.id)&&h.execApprovalErrors.set(e.id,K(`execApproval.reviewOnly`)),p=null,h.execApprovalBusy=!1}if((g.adminRevoked||g.pairingSetupRevoked)&&(Yt(m),_.invalidate({clear:!0})),g.pairingChanged&&_.invalidate({clear:!(u.canAdmin||u.canPair)}),s=e.client,c=a,h.client=e.client,m.client=e.client,m.connected=i,(t!==e.client||!i)&&(p=null,_.invalidate({clear:!0}),Yt(m)),i&&!u.canReviewApprovals&&(p=null,h.execApprovalQueue=[],h.execApprovalBusy=!1,h.execApprovalErrors.clear(),Np(h)),!i||!e.client){h.execApprovalQueue=[],h.execApprovalBusy=!1,h.execApprovalErrors.clear(),e.phase!==`reload-required`&&!e.client&&(l=0),Np(h),n.synchronizeGateway(e);return}let v=e.client;n.synchronizeGateway(e),g.pairingChanged&&m.devicePairSetupOpen&&(u.canAdmin||u.canPair)&&r(`pairing-pending-count`,()=>_.refresh()).catch(()=>void 0),o?(l+=1,u.canReviewApprovals&&r(`approvals`,()=>b(v,l,d)).catch(()=>void 0)):g.reviewChanged&&u.canReviewApprovals&&r(`approvals`,()=>b(v,l,d)).catch(()=>void 0)},S=e.subscribe(x),C=e.subscribeEvents(t=>{if(o||!Om(t))return;if(t.event===`device.pair.setup.completed`){let e=gn(t.payload);e&&$t(m,e);return}if(t.event===`device.pair.setup.deliveryUncertain`){let e=ki(t.payload);e&&jt(m,e);return}if(t.event===`device.pair.requested`||t.event===`device.pair.resolved`){_.refresh();return}if(t.event===`update.available`){n.handleUpdateAvailable(t.payload);return}if(t.event===`update.run.changed`){n.handleUpdateRunChanged(t.payload);return}if(!u.canReviewApprovals||!J(e.snapshot).canReviewApprovals)return;let r=_p(t.event,t.payload);if(r){Pp(h,r),g();return}let i=mp(t.event,t.payload);i&&(Ip(h,i.id),g())});return x(e.snapshot),{get snapshot(){return i},subscribe(e){return a.add(e),()=>a.delete(e)},refreshUpdateStatus:n.refreshUpdateStatus,acknowledgeUpdateRun:n.acknowledgeUpdateRun,runUpdate:n.runUpdate,holdUpdate:n.holdUpdate,async decideApproval(t,n,r){let i=n?h.execApprovalQueue.find(e=>e.id===n)??(r?.id===n?r:void 0):h.execApprovalQueue[0],a=e.snapshot.client;if(!i||h.execApprovalBusy||o)return;let c=i===r;if(!a||e.snapshot.phase!==`connected`){h.execApprovalErrors.set(i.id,K(`sessionsView.actionRequiresConnection`)),g();return}if(!J(e.snapshot).canGrantApprovals){h.execApprovalErrors.set(i.id,K(`execApproval.reviewOnly`)),g();return}h.execApprovalBusy=!0,h.execApprovalErrors.delete(i.id);let u={client:a,epoch:l,accessGeneration:d,grantGeneration:f,id:i.id};p=u;let m=()=>p===u&&u.epoch===l&&u.accessGeneration===d&&u.grantGeneration===f&&J(e.snapshot).canGrantApprovals&&y(u.client);g();try{if(await vp(a,i,t),!m())return;Ip(h,i.id)}catch(e){if(wp(e)){if(!m())return;Ip(h,i.id);let e=s,t=l;e&&m()&&await b(e,t);return}m()&&(c||h.execApprovalQueue.some(e=>e.id===i.id))&&h.execApprovalErrors.set(i.id,`Approval failed: ${vt(e)}`)}finally{p===u&&(p=null,h.execApprovalBusy=!1,g())}},async openDevicePairSetup(){let t=J(e.snapshot);if(o||!t.canAdmin&&!t.canPair)return!1;m.pendingCount=0;let n=Ut(m);return _.refresh(),await v(n),m.devicePairSetupOpen},async refreshDevicePairSetup(){o||!J(e.snapshot).canAdmin||await v(kn(m))},async setDevicePairSetupAccess(t){o||!J(e.snapshot).canAdmin||await v(Tn(m,t))},closeDevicePairSetup(){_.invalidate({clear:!0}),Yt(m),g()},dispose(){o=!0,p=null,n.dispose(),_.invalidate(),Yt(m),S(),C(),Np(h),h.execApprovalErrors.clear(),a.clear()}}}function Am(){return(Am=e((()=>{We(),G(),yt(),sn(),zp(),cc(),Wp(),Dm()})))()}function jm(e,t){return e.phase===`connected`&&ac(e.hello?.auth??null)&&Ga(e,t)===!0}function Mm(e){return jm(e,`browser.request`)}function Nm(e){return jm(e,`desktop.observe`)}function Pm(e){if(!e)return!1;let t=e.snapshot,n=e.connection.gatewayUrl;if(t.phase===`connected`){let r=Ka(t,`chat.history`,`operator.read`)&&Ka(t,`chat.send`,`operator.write`);return Fm.set(e,{gatewayUrl:n,allowed:r}),r}let r=Fm.get(e);return r?.gatewayUrl!==n||t.phase===`reload-required`?(Fm.delete(e),!1):r.allowed}var Fm;function Im(){return(Im=e((()=>{qa(),cc(),Fm=new WeakMap})))()}function Lm(e,{gatewayUrl:t,recoveryScope:n}){let r=e.connectionRevision;return()=>{let i=e.snapshot.client;return e.connectionRevision===r&&e.connection.gatewayUrl===t&&(!i?.recoveryScopeReady||i.recoveryScope===n)}}function Rm(e,t=()=>R(()=>import(`./session-placement-startup.runtime-Bow8I4wF.js`),__vite__mapDeps([75,13,2,3,4,5,6,7,8,9,10,11,12,1,14,15,16]),import.meta.url)){let n=new Map,{gateway:r}=e,i=!1,a,o,s=new Set,c,l,u=()=>s.forEach(e=>e()),d=()=>{let{client:e,phase:t}=r.snapshot;return t===`connected`&&e?.recoveryScopeReady?e:null},f=()=>[...n.values()].map(e=>e()).filter(e=>e!==void 0),p=()=>f().every(e=>e.persisted),m=()=>{let e=f(),t=e[0];if(!t)return;let n=o,a=Lm(r,t.input.recovery);return()=>{let t=f();i||o!==n||!a()||e.length!==t.length||e.some((e,n)=>e!==t[n])||jc()}},h=Ec(p,()=>ui({message:K(`newSession.placementReloadBlocked`),actionLabel:K(`newSession.discardUnsavedAndReload`),onAction:m()})),g=(s,f=!1)=>{let p=s?.input;if(i)return;if(c??=r.subscribe(()=>g()),(p||f)&&o?.error&&(o=void 0,p||u()),p){if(a){a.start(p);return}let e=p.recovery.sessionKey;n.delete(e);let t=Lm(r,p.recovery);n.set(e,()=>t()?s:void 0),n.size>32&&n.delete(n.keys().next().value),u()}let m=d();if(a){if(m)for(let[e,t]of n){let r=t()?.input;n.delete(e),r&&a.start(r)}a?.resumeRecovery(),m&&l&&(l=void 0,u());return}if(m&&!p){if(!l?.current()){let e={gatewayUrl:r.connection.gatewayUrl,recoveryScope:m.recoveryScope},t=Lm(r,e),n=[],i={startedAt:Date.now()};l={current:t,refresh:()=>{n=gi(e.gatewayUrl,e.recoveryScope)},read:r=>t()&&n.includes(sr(e.gatewayUrl,e.recoveryScope,r))?i:void 0}}l.refresh()}if(o)return;let h={};o=h,t().then(({default:t})=>{i||(a=t(e),a.subscribe(u),g())},e=>{h.error=Error(vt(e)),u()})};return{get(e){let t=n.get(e)?.()?.input,r=t?{targetKind:t.recovery.target.kind,startedAt:t.createdAt}:l?.read(e);if(!r)return a?.get(e)??null;let i=o?.error,s=Ac(i)&&!p();return d()?{sessionKey:e,...r,phase:i?`failed`:`pending`,error:s?K(`newSession.placementReloadBlocked`):i?.message,retryable:!!i&&!s,...s?{discardAndReload:m()}:{}}:null},hasPendingTurn(e){return!!(n.get(e)?.()||a?.hasPendingTurn(e)||l?.read(e))},start:e=>g({input:e,persisted:e.persistRecovery}),pause(e,t,o){let s=d();if(i||!s)return;if(a){a.pause(e,t,o);return}let c=n.get(e)?.()?.input,l=c?.recovery??o.readSessionPlacementRecovery(r.connection.gatewayUrl,s.recoveryScope,e);if(!l)return;let{recovery:u,persisted:f}=o.pauseSessionPlacementRecovery(l,t,c?.persistRecovery??!0);g({input:{recovery:u,persistRecovery:c?.persistRecovery??!0,recovering:!0,createdAt:c?.createdAt??Date.now()},persisted:f})},retry(e){let t=n.get(e)?.();if(t||l?.read(e)){let n=o,r=n?.error;if(Ac(r)){g();let t=l;if(!t?.read(e))return;Ic({canReload:()=>(t.refresh(),!i&&o===n&&l===t&&!!t.read(e)&&p())});return}return g(t,!0)}a?.retry(e)},resumeRecovery:g,subscribe(e){return s.add(e),()=>s.delete(e)},dispose(){c?.(),h(),i=!0,a?.dispose(),a=void 0,n.clear(),l=void 0,s.clear()}}}function zm(){return(zm=e((()=>{G(),sn(),Lr(),Yr(),kc(),Jc(),I()})))()}function Bm(e){let t=new Set,n=null,r=()=>{for(let e of t)e()},i=()=>{let t=e.gateway.snapshot,r=t.hello?.auth?.scopes;t.phase===`connected`&&r&&!zi({scopes:r,state:e.scopeUpgrade.state})&&oa(e.gateway.connection.gatewayUrl,`scopeUpgrade`),n?.syncDismissals()},a=e.gateway.subscribe(i),o=e.scopeUpgrade.subscribe(i);return i(),{get entries(){return n?.entries??[]},activate(t){return n??=new t(e,r),n.mentions},dismiss(e){n?.dismiss(e)},subscribe(e){return t.add(e),()=>t.delete(e)},dispose(){a(),o(),n?.dispose(),n=null,t.clear()}}}function Vm(){return(Vm=e((()=>{ca()})))()}function Hm(){let e=new AbortController,t=new Set,n=n=>{if(e.signal.aborted){n();return}t.add(n)};return{signal:e.signal,addDisposer:n,async run(t){for(let r of t){if(e.signal.aborted)return;let t=await r();t&&n(t)}},trackDisposer(t,r){t.then(n).catch(t=>{e.signal.aborted||r(t)})},stop(){e.abort();for(let e of[...t].toReversed())e();t.clear()}}}function Um(e,t){let n=t?`${t}/`:`/`;if(e.pathname!==n)return e;let r=new URLSearchParams(e.search);if(r.get(`view`)!==`terminal`)return e;r.delete(`view`);let i=r.toString();return{pathname:T({kind:`terminal`},t),search:i?`?${i}`:``,hash:e.hash}}function Wm(e,t){let n=e,r=!1,i=null,a=null,o=null,s=null,c=null,l=!1,d=null,f=e=>{Object.entries(e).every(([e,t])=>n[e]===t)||(n={...n,...e},r=!0)},p=typeof window>`u`?void 0:window.__OPENCLAW_NATIVE_CONTROL_AUTH__;if(p){try{delete window.__OPENCLAW_NATIVE_CONTROL_AUTH__}catch{window.__OPENCLAW_NATIVE_CONTROL_AUTH__=void 0}let e=z(p.gatewayUrl),t=z(p.token),r=z(p.password),a=e?yd(n.gatewayUrl,e,{token:n.token,password:``}):null,o=p.client,s=u(z(o?.id)),c=E(z(o?.mode)),l=z(o?.platform),m=z(o?.deviceFamily),h=z(o?.instanceId),g=Array.isArray(o?.scopes)?oe(o.scopes.flatMap(e=>z(e)??[])):[];s&&c&&l&&m&&g.length>0&&(d={clientName:s,mode:c,platform:l,deviceFamily:m,...h?{instanceId:h}:{},scopes:g}),f({...e?{gatewayUrl:e}:{},...p.token===null||t?{token:t??``}:a?{token:a.token}:{}}),r&&(i=r)}if(!t.search&&!t.hash)return{settings:n,password:i,pendingGatewayUrl:a,pendingGatewayToken:o,pendingBootstrapToken:s,pendingBootstrapProfile:c,queryTokenUsed:l,nativeClient:d,location:t,changed:r};let m=new URL(`${t.pathname}${t.search}${t.hash}`,`http://openclaw.local`),h=new URLSearchParams(m.search),g=new URLSearchParams(m.hash.startsWith(`#`)?m.hash.slice(1):m.hash),_=h.get(`gatewayUrl`)??g.get(`gatewayUrl`),v=z(_)??``,y=!!(v&&v!==n.gatewayUrl),b=h.get(`token`),x=g.get(`token`),S=x!=null||b!=null,C=z(x??b),w=g.has(`bootstrapToken`),T=z(g.get(`bootstrapToken`)),ee=g.has(ze),D=z(g.get(ze)),O=ho(t.pathname,bo(t.pathname)),k=!!(C&&!O&&!y),A=!1;if(h.has(`token`)&&(h.delete(`token`),A=!0),S&&(b!=null&&(l=!0,console.warn(`[openclaw] Auth token passed as query parameter (?token=). Use URL fragment instead: #token=<token>. Query parameters may appear in server logs.`)),C&&y?o=C:C&&f({token:C}),g.delete(`token`),A=!0),w&&(s=T??null,c=T&&D===`owner`?De:null,g.delete(`bootstrapToken`),A=!0),ee&&(g.delete(ze),A=!0),k&&f({sessionKey:`main`,lastActiveSessionKey:`main`}),(h.has(`password`)||g.has(`password`))&&(h.delete(`password`),g.delete(`password`),A=!0),_!=null&&(a=y?v:null,y?s&&(o=null):o=null,h.delete(`gatewayUrl`),g.delete(`gatewayUrl`),A=!0),A){m.search=h.toString();let e=g.toString();m.hash=e?`#${e}`:``}return{settings:n,password:i,pendingGatewayUrl:a,pendingGatewayToken:o,pendingBootstrapToken:s,pendingBootstrapProfile:c,queryTokenUsed:l,nativeClient:d,location:A?{pathname:m.pathname,search:m.search,hash:m.hash}:t,changed:r}}function Gm(){return(Gm=e((()=>{f(),r(),qe(),ge(),q(),tf()})))()}async function Km(e,t,n){try{let{presentUpdateFailureTriage:r}=await R(async()=>{let{presentUpdateFailureTriage:e}=await import(`./update-triage.runtime-C-ASlPWe.js`);return{presentUpdateFailureTriage:e}},__vite__mapDeps([76,2,4,3,5,6,7,8,77,78,53]),import.meta.url);r(e,t,n)}catch{n.isCurrent()&&e.navigate(`updates`)}}function qm(){return(qm=e((()=>{I()})))()}function Jm(e,t={}){let n=globalThis.navigator,r=!(/iPad|iPhone|iPod/u.test(n.userAgent)||n.platform===`MacIntel`&&n.maxTouchPoints>1)||n.standalone===!0,i=r&&`serviceWorker`in n&&`PushManager`in globalThis&&`Notification`in globalThis,a={supported:i,permission:r?i?Notification.permission:`unsupported`:`install-required`,subscription:`unknown`,loading:!1},o=new Set,s=e=>{Object.assign(a,e);for(let e of o)e()},c=a.supported?R(async()=>{let{createWebPushCapabilityRuntime:e}=await import(`./web-push.runtime-D1HzC7es.js`);return{createWebPushCapabilityRuntime:e}},__vite__mapDeps([79,13,2,3,4,5,6,7,8,9,10,11,12,1,14,15,16]),import.meta.url).then(({createWebPushCapabilityRuntime:n})=>n({gateway:e,publish:s,connectionBootstrap:t.connectionBootstrap})).catch(e=>(s({supported:!1,permission:`unsupported`,subscription:`unknown`,preferences:null,error:vt(e)}),null)):null;return{snapshot:a,subscribe(e){return o.add(e),()=>o.delete(e)},run:e=>c?c.then(t=>t?.run(e)):Promise.resolve(),dispose(){c?.then(e=>e?.dispose()),o.clear()}}}function Ym(){return(Ym=e((()=>{sn(),I()})))()}function Xm(e,t){let n={navCollapsed:t,navWidth:e.navWidth,sidebarEntries:e.sidebarEntries,pinnedAgentIds:e.pinnedAgentIds??[]},r=new Set;return{get snapshot(){return n},update(e){let t={...n,...e},i=t.navWidth!==n.navWidth||t.sidebarEntries!==n.sidebarEntries||t.pinnedAgentIds!==n.pinnedAgentIds;if(!(!i&&t.navCollapsed===n.navCollapsed)){i&&Ed({navWidth:t.navWidth,sidebarEntries:[...t.sidebarEntries],pinnedAgentIds:[...t.pinnedAgentIds]}),n=t;for(let e of r)e(n)}},subscribe(e){return r.add(e),()=>r.delete(e)}}}function Zm(){let e=zo(),t=e.location(),[n,r]=Io(t.pathname||globalThis.location?.pathname||`/`),i=zl(t.pathname,n),a=Sd(),o=i?ud(a):a,s=Wm(o,t),c=L(s.settings.gatewayUrl)===L(o.gatewayUrl)?null:_d(s.settings.gatewayUrl),l=c?{...s.settings,...c,selectedAgentId:c.selectedAgentId}:s.settings;(s.location.pathname!==t.pathname||s.location.search!==t.search||s.location.hash!==t.hash)&&e.replace(s.location),s.changed&&(i?bd(l.gatewayUrl,l.token):wd(l));let u=Um(s.location,n),d=new URLSearchParams(u.search),f=d.get(jl.name)===jl.value;if(f){d.delete(jl.name);let e=d.toString();u={...u,search:e?`?${e}`:``}}u!==s.location&&e.replace(u);let p=Te(u,n),m=i===null&&p===null,h=m&&et(u,n,vo),g=s.pendingGatewayUrl!==null,_=Vf(l,s.password??``,g?``:s.pendingBootstrapToken??``,void 0,{persistDefaultConnectionSettings:i===null,resourceBasePath:r,...!g&&s.pendingBootstrapProfile?{bootstrapProfile:s.pendingBootstrapProfile}:{},...s.nativeClient?{clientOptions:s.nativeClient}:{}}),v=Tf(),y=dt(_),b=Hm(),x=h&&!qt(l.sessionKey),S=null,C=x?new Promise(e=>{S=e}):null,w=(i||p?Promise.resolve(u):Yl({location:u,basePath:n,sessionKey:l.sessionKey,gateway:_,agentsList:()=>y.state.agentsList,selectedAgentId:l.selectedAgentId,signal:b.signal})).catch(e=>{if(b.signal.aborted)return u;throw e}),T=ln(_),E=Pl(_,y,m?{load:e=>_d(e).selectedAgentId??null,save:(e,t)=>{_.connection.gatewayUrl===e&&Ed({selectedAgentId:t??void 0})}}:void 0),ee=Sr(_),D=Af(_),O=Sf({resourceBasePath:r,getAuth:()=>({hello:_.snapshot.hello,settings:{token:_.connection.token},password:_.connection.password})}),k=Tt(_,E),A=Xr(_),j=km(_,{connectionBootstrap:v,getActiveSessionKey:()=>_.snapshot.sessionKey||void 0,drainConfigWrites:()=>A.waitForPendingWrites(),onUpdateFailure:(e,t)=>void Km(Ee,e,t)}),M=Bm({gateway:_,agentSelection:E,agents:y,overlays:j,scopeUpgrade:D,connectionBootstrap:v}),N=()=>{let e=j.snapshot;A.setWritesSuspended(e.updateRunning||e.updateReconciliationPending)},te=j.subscribe(N);N();let ne=Xm(l,f&&Al(u.pathname,n)?.namespace===`chat`),P=sf(l,_),re=Xf(),ie=ap({onNativeUpdateDeclined:()=>{let e=j.snapshot,t=e.updateSchedule?.campaign,n=e.updateRunning||e.updateReconciliationPending||t?.state===`applying`;(e.updateAvailable||t)&&!n&&!e.controlUiRefreshRequired&&j.runUpdate()},shouldOpenInControlUiBrowser:()=>Sd().openLinksInControlUiBrowser===!0&&Mm(_.snapshot)&&document.querySelector(`openclaw-app-shell`)?.isConnected===!0}),ae=null,oe=null,se=Jm(_,{connectionBootstrap:v}),ce=ff(),le=Rm({gateway:_,sessions:k,chatSubmissions:ce}),ue=lf(),F=dc(),de=!1,fe=null,pe=s.pendingGatewayUrl===null?null:{gatewayUrl:s.pendingGatewayUrl,token:s.pendingGatewayToken,bootstrapToken:s.pendingBootstrapToken??``,...s.pendingBootstrapProfile?{bootstrapProfile:s.pendingBootstrapProfile}:{}},me=null,he=null,ge=!!(g||s.nativeClient||s.pendingBootstrapToken),ve=_.connectionRevision,ye=_.subscribe(e=>{if(v.synchronize({client:e.client,connected:e.phase===`connected`}),e.phase===`connected`&&(ge=!0),!ge&&e.phase===`stopped`&&(e.lastErrorCode===_e.AUTH_TOKEN_MISSING||e.lastErrorCode===_e.AUTH_PASSWORD_MISSING)&&(ge=!0,b.trackDisposer(R(async()=>{let{startBrowserBootstrapRecovery:e}=await import(`./browser-bootstrap.runtime-yU444ZS1.js`);return{startBrowserBootstrapRecovery:e}},__vite__mapDeps([80,2,3,4,5,6,7,8,27,9,10,11,12,13,1,14,15,16,28,29]),import.meta.url).then(({startBrowserBootstrapRecovery:t})=>_.snapshot.client===e.client&&_.connectionRevision===ve&&!b.signal.aborted?t(_,n):()=>{}),()=>{})),e.phase!==`connected`||!e.client){me=null,he=null;return}let t=e.client;me!==t&&(me=t,v.run(`config`,()=>O.refresh()),v.run(`session-observer`,()=>Kr(t,Ar()!==`off`))),!(!t.recoveryScopeReady||he===t)&&(he=t,le.resumeRecovery())}),be=(e,t)=>{let r=xo(e,n),i=F.getState().matches[0],a=i?.routeId===e&&e===`workboard`?i.location.pathname:null;return t?.pathname!==void 0||t?.search!==void 0||t?.hash!==void 0?{...r,pathname:t?.pathname??a??r.pathname,search:t?.search??``,hash:t?.hash??``}:r},xe=()=>{let e=pe;if(!e)return;pe=null;let t=yd(_.connection.gatewayUrl,e.gatewayUrl,_.connection);_.connect({gatewayUrl:e.gatewayUrl,token:e.bootstrapToken?``:e.token??t.token,password:t.password,bootstrapToken:e.bootstrapToken,bootstrapProfile:e.bootstrapProfile})},Se=()=>{pe=null},Ce=(t,n,r)=>{let i=be(t,n);de||(fe={routeId:t,location:i,mode:r});let a=de&&mc(e.location(),i)?`replace`:r,o=F.navigate(t,Ee,{history:a},i);return o.catch(e=>{console.error(`[openclaw] route navigation failed`,e)}),o},I=(e,t)=>Ce(e,t,`push`),we=new Wn(()=>Ee),Ee={basePath:n,resourceBasePath:r,lifecycleAbortSignal:b.signal,router:F,gateway:_,connectionBootstrap:v,agents:y,agentIdentity:T,agentSelection:E,channels:ee,config:O,scopeUpgrade:D,sidebarAttention:M,runtimeConfig:A,sessions:k,placementStartup:le,plugins:we,overlays:j,navigation:ne,theme:P,nativeChatDrafts:re,get nativeDeviceSettings(){return ae},get nativeNotifications(){return oe},webPush:se,chatSubmissions:ce,chatAttachmentHandoff:ue,navigate:(e,t)=>{I(e,t)},navigateAndWait:I,replace:(e,t)=>{Ce(e,t,`replace`)},revalidate:e=>F.revalidate(Ee,e),preload:e=>F.preloadLocation(xo(e,n),Ee)};return{context:Ee,router:F,documentMode:i,focusLocation:p,get pendingGatewayConnection(){return pe},confirmPendingGatewayConnection:xe,cancelPendingGatewayConnection:Se,start:()=>{let t=()=>F.stop();m&&b.addDisposer(t);let r=[()=>(_.start(),()=>_.stop()),()=>Mf(_,document,window),()=>(we.start(),()=>we.dispose())];m&&!h&&r.unshift(()=>lc(F,u,n));let i=window;return typeof i.webkit?.messageHandlers?.openclawNotifications?.postMessage==`function`&&r.unshift(async()=>{let{createNativeNotificationsCapability:e}=await R(async()=>{let{createNativeNotificationsCapability:e}=await import(`./native-notifications-D_lyz80n.js`);return{createNativeNotificationsCapability:e}},__vite__mapDeps([81,2]),import.meta.url);if(!b.signal.aborted)return oe=e(),()=>oe?.dispose()}),typeof i.webkit?.messageHandlers?.openclawDeviceSettings?.postMessage==`function`&&r.unshift(async()=>{let{createNativeDeviceSettingsCapability:e}=await R(async()=>{let{createNativeDeviceSettingsCapability:e}=await import(`./native-device-settings-CcSm3s9I.js`);return{createNativeDeviceSettingsCapability:e}},__vite__mapDeps([82,2,3,4,5,6,7,8]),import.meta.url);if(!b.signal.aborted)return ae=e(),()=>ae?.dispose()}),r.push(()=>fr({context:Ee,enabled:h,history:e,initialLocationReady:x?Promise.resolve(u):w,...x?{redirect:()=>e.replace({...xo(`model-setup`,n),search:`?firstRun=1`}),onInitialDecision:()=>S?.()}:{}})),r.push(()=>{O.refresh({skipWithoutAuthCandidate:!0})}),m&&(C&&r.push(()=>C),r.push(async()=>{let r=fe;return fe=null,de=!0,r&&e[r.mode](r.location),await _c(F,e,n,Ee),t})),x&&r.push(()=>{b.trackDisposer(fr({context:Ee,enabled:!1,history:e,initialLocationReady:w,installLocation:async t=>{let r=vo(t.pathname,n);r?await F.navigate(r,Ee,{history:`replace`},t):e.replace(t)},shouldInstallLocation:()=>et(e.location(),n,vo)}),e=>{console.error(`[openclaw] initial session location failed`,e)})}),b.run(r)},stop:()=>{b.stop(),ye(),v.reset(),y.dispose(),ee.dispose(),D.dispose(),M.dispose(),le.dispose(),k.dispose(),te(),A.dispose(),j.dispose(),P.dispose(),re.dispose(),ie.dispose(),se.dispose(),ce.clear(),ue.dispose()}}}function Qm(){return(Qm=e((()=>{qe(),we(),yc(),Ml(),Mt(),Ci(),bi(),fi(),Vt(),nt(),ci(),hn(),qn(),Fl(),Bl(),Xl(),cf(),Bo(),df(),pf(),wf(),Df(),jf(),Nf(),Kf(),lp(),Am(),Im(),zm(),tf(),Vm(),Gm(),qm(),Ym(),I()})))()}var $m;function eh(){return(eh=e((()=>{$m=h(`openclaw.application`)})))()}function th(){return window.__OPENCLAW_NATIVE_WEB_CHROME__===!0}function nh(){let e=window.__OPENCLAW_NATIVE_HISTORY__;return e&&typeof e.canGoBack==`boolean`&&typeof e.canGoForward==`boolean`?e:{canGoBack:!1,canGoForward:!1}}var rh;function ih(){return(ih=e((()=>{rh=`openclaw:native-history-state`})))()}function ah(e){return`${e.pathname}${e.search}${e.hash}`}function oh(e){return`type`in e&&e.type===`notFound`}function sh(e){return H`
<main
class="connect-splash"
role="status"
aria-live="polite"
aria-label=${e??K(`common.loading`)}
>
<openclaw-mascot mood="thinking" .size=${120}></openclaw-mascot>
${e?H`<span class="connect-splash__status">${e}</span>`:W}
</main>
`}var ch;function lh(){return(lh=e((()=>{ne(),qe(),Ii(),Fi(),Va(),Ra(),Gi(),ta(),_a(),G(),sn(),nt(),Wt(),bn(),ot(),Qm(),eh(),Ol(),ih(),Im(),tf(),I(),ch=class extends er{get context(){return this.runtime?.context}get focusTarget(){let e=this.runtime?.focusLocation;return e?.status===`valid`?e.target:null}get terminalOnly(){return this.focusTarget?.kind===`terminal`}constructor(){super(),this.loginGatePinned=!1,this.loginGatewayUrl=``,this.loginToken=``,this.loginPassword=``,this.loginShowGatewayToken=!1,this.loginShowGatewayPassword=!1,this.pendingGatewayUrl=null,this.onboarding=Ts(globalThis.location?.search??``),this.focusDashboardRoute={kind:`loading`},this.contextProvider=new n(this,{context:$m}),this.subscriptions=new Mi(this),this.loginGatewaySource=null,this.loginConnectionClient=null,this.focusDashboardAbort=null,this.loginGateLoader=new cl(this),this.lazyCustomElements=new cl(this,()=>this.closeDocument(this.context?.basePath??``)),this.subscriptions.watch(()=>this.context?.gateway,(e,t)=>e.subscribe(t),e=>this.synchronizeGateway(e)).watch(()=>this.terminalOnly?this.context?.config:void 0,(e,t)=>e.subscribe(t)).watch(()=>this.context?.agentSelection,(e,t)=>e.subscribe(t)).watch(()=>this.terminalOnly?this.context?.theme:void 0,(e,t)=>e.subscribe(t)).effect(()=>this.ownerDocument,Da)}connectedCallback(){super.connectedCallback(),R(()=>import(`./session-progress-hovercard-registration-DF9iuIbl.js`),__vite__mapDeps([83,13,2,3,4,5,6,7,8,9,10,11,12,1,14,15,16]),import.meta.url),this.resetLoginSensitivePresentation(),this.runtime=Zm();let e=this.focusTarget;e?.kind===`terminal`&&this.requestLazyDocument(_l),e?.kind===`desktop`&&this.requestLazyDocument(yl),e?.kind===`dashboard`&&this.requestLazyDocument(bl),this.runtime.documentMode?.kind===`approval`&&this.requestLazyDocument(Sl),this.runtime.documentMode?.kind===`question`&&this.requestLazyDocument(wl);let t=this.runtime.context;this.pendingGatewayUrl=this.runtime.pendingGatewayConnection?.gatewayUrl??null,this.contextProvider.setValue(t),this.syncLoginConnection(),this.requestUpdate(),this.runtime.start().then(()=>this.resolveFocusDashboard()).catch(e=>{console.error(`[openclaw] application start failed`,e)})}disconnectedCallback(){this.subscriptions.clear(),this.focusDashboardAbort?.abort(),this.focusDashboardAbort=null,this.lazyCustomElements.abandon(),this.loginGateLoader.abandon(),this.runtime?.stop(),this.runtime=void 0,this.loginGatewaySource=null,this.loginConnectionClient=null,this.pendingGatewayUrl=null,this.resetLoginSensitivePresentation(),super.disconnectedCallback()}firstUpdated(){this.runtime&&globalThis.dispatchEvent(new Event(`openclaw-control-ui-rendered`))}synchronizeGateway(e){let t=e!==this.loginGatewaySource;t&&(this.loginGatewaySource=e,this.loginConnectionClient=null,this.resetLoginSensitivePresentation());let n=e.snapshot,r=n.client!==this.loginConnectionClient;r&&(this.loginConnectionClient=n.client,this.resetLoginSensitivePresentation()),(t||r)&&this.syncLoginConnection(e),n.phase===`connected`&&(this.loginGatePinned=!1)}syncLoginConnection(e=this.context?.gateway){let t=e?.connection;t&&(this.loginGatewayUrl=t.gatewayUrl,this.loginToken=t.token,this.loginPassword=t.password)}resetLoginSensitivePresentation(){this.loginShowGatewayToken=!1,this.loginShowGatewayPassword=!1}updateLoginGatewayUrl(e){let t=yd(this.loginGatewayUrl,e,{token:this.loginToken,password:this.loginPassword});this.loginGatewayUrl=e,this.loginToken=t.token,this.loginPassword=t.password}closeDocument(e){globalThis.history.length>1?globalThis.history.back():globalThis.location.assign(e||`/`)}renderFocusEscape(e){return th()?W:H`<button
class="btn btn--ghost"
type="button"
@click=${()=>this.closeDocument(this.context?.basePath??``)}
>
${e}
</button>`}requestLazyDocument(e){Y(e)||this.lazyCustomElements.request(e)}renderLazyDocumentState(e){let t=this.lazyCustomElements.visibleState;return!t||t.element!==e?W:H`<main class="connect-splash">
${Bi(t,()=>this.lazyCustomElements.retry(),()=>this.lazyCustomElements.close())}
</main>`}renderApprovalDocument(e){if(this.lazyCustomElements.visibleState?.element===Sl)return this.renderLazyDocumentState(Sl);let t=e.documentMode?.kind===`approval`?e.documentMode.approvalId:``;return H`<openclaw-approval-page .approvalId=${t??``}></openclaw-approval-page>`}renderQuestionDocument(e){if(this.lazyCustomElements.visibleState?.element===wl)return this.renderLazyDocumentState(wl);let t=e.documentMode?.kind===`question`?e.documentMode.questionId:``;return H`<openclaw-question-page .questionId=${t??``}></openclaw-question-page>`}replaceFocusDashboardLocation(e,t){let n=this.context?.basePath??``,r=T({kind:`dashboard`,path:ah(t)},n),i=T({kind:`dashboard`,path:ah(e)},n),a=`${globalThis.location.pathname}${globalThis.location.search}${globalThis.location.hash}`;!r||!i||a!==r||i===a||globalThis.history.replaceState(globalThis.history.state,``,i)}async resolveFocusDashboard(){let e=this.focusTarget,t=this.context;if(e?.kind!==`dashboard`||!t)return;this.focusDashboardAbort?.abort();let n=new AbortController;this.focusDashboardAbort=n,this.focusDashboardRoute={kind:`loading`};let r=e.route;try{let{loadChatRoute:e}=await R(async()=>{let{loadChatRoute:e}=await import(`./route-loader-CBX3uHIe.js`);return{loadChatRoute:e}},__vite__mapDeps([84,38,2,3,4,5,6,7,8,9,10,11,12,13,1,14,15,16,29,28,37,27,39,40,41,42]),import.meta.url),i=await e(t,r,`dashboard`,n.signal);if(n.signal.aborted||this.focusDashboardAbort!==n)return;if(oh(i)||i.kind===`missing-session`){this.focusDashboardRoute={kind:`not-found`};return}if(i.kind===`route-error`){this.focusDashboardRoute={kind:`error`,message:i.message};return}if(i.kind===`ambiguous`){this.focusDashboardRoute={kind:`ambiguous`,data:{...i,candidates:i.candidates.map(e=>({...e,href:T({kind:`dashboard`,path:e.href},t.basePath)??e.href}))}};return}this.focusDashboardRoute={kind:`session`,data:i},i.canonicalLocation&&i.canonicalLocationSource&&this.replaceFocusDashboardLocation(i.canonicalLocation,i.canonicalLocationSource);let a=i.canonicalLocationSource;i.canonicalLocationReady&&a&&i.canonicalLocationReady.then(e=>{e&&!n.signal.aborted&&this.focusDashboardAbort===n&&this.replaceFocusDashboardLocation(e,a)})}catch(e){!n.signal.aborted&&this.focusDashboardAbort===n&&(this.focusDashboardRoute={kind:`error`,message:vt(e)})}}renderFocusDashboard(e,t,n){let r=this.focusDashboardRoute;return r.kind===`loading`?sh(n):r.kind===`not-found`?H`<main class="board-document">
<section class="board-document__state stack" role="status">
<span>${K(`dashboardDocument.notFound`)}</span>
${this.renderFocusEscape(K(`dashboardDocument.close`))}
</section>
</main>`:r.kind===`error`?H`<main class="board-document">
<section class="board-document__state board-document__state--error stack" role="alert">
<span>${K(`dashboardDocument.loadFailed`,{error:r.message})}</span>
${this.renderFocusEscape(K(`dashboardDocument.close`))}
</section>
</main>`:r.kind===`ambiguous`?H`<main class="board-document">
<section class="card board-document__state">
<h2>${K(`chat.sessionRoute.chooseTitle`)}</h2>
<p>
${r.data.candidates.length>1?K(`chat.sessionRoute.multipleMatches`,{shortId:r.data.shortId}):K(`chat.sessionRoute.additionalMatches`)}
</p>
${r.data.candidates.map(e=>H`<p>
<a href=${e.href}>${e.displayName}</a><br />
<small>${e.agentId} · ${e.idPrefix}</small>
</p>`)}
${r.data.truncated?H`<p><small>${K(`chat.sessionRoute.additionalMatches`)}</small></p>`:W}
${this.renderFocusEscape(K(`dashboardDocument.close`))}
</section>
</main>`:H`
<openclaw-board-document
.gatewaySnapshot=${e}
.sessionKey=${r.data.sessionKey}
.onDocumentClose=${th()?null:()=>this.closeDocument(this.context?.basePath??``)}
></openclaw-board-document>
${!t&&e.lastError===null?sh(n):W}
${t?this.renderLazyDocumentState(bl):W}
`}render(){let e=this.context,t=this.runtime;if(!e||!t)return H`<main class="app-shell app-shell--booting" aria-busy="true"></main>`;let n=e.gateway.snapshot,r=n.phase===`connected`,i=n.phase===`starting`?K(`common.gatewayStarting`):void 0,a=this.pendingGatewayUrl?H`
<openclaw-gateway-url-confirmation
.props=${{pendingGatewayUrl:this.pendingGatewayUrl,onConfirm:()=>{t.confirmPendingGatewayConnection(),this.pendingGatewayUrl=null},onCancel:()=>{t.cancelPendingGatewayConnection(),this.pendingGatewayUrl=null}}}
></openclaw-gateway-url-confirmation>
`:W;if(t.focusLocation?.status===`unsupported`)return H`<main class="connect-splash" role="alert">
<div class="stack">
<span class="connect-splash__status">${K(`focus.unsupported`)}</span>
${this.renderFocusEscape(K(`common.back`))}
</div>
</main>`;let o=this.focusTarget;if(o?.kind===`terminal`){let t=_n(n,e.config.current.terminalEnabled??!1),a=e.agentSelection.state.selectedId??n.assistantAgentId,o=a?v(a):null;return H`
<openclaw-terminal-panel
.client=${r?n.client:null}
.available=${t}
.agentId=${o}
.themeMode=${e.theme.resolvedMode}
fullscreen
></openclaw-terminal-panel>
${!r&&n.lastError===null?sh(i):W}
${t?this.renderLazyDocumentState(_l):W}
${!t&&(r||n.lastError)?H`<div class="terminal-view-unavailable">
<div class="stack">
<span>${K(`terminal.unavailable`)}</span>
${this.renderFocusEscape(K(`common.back`))}
</div>
</div>`:W}
`}if(o?.kind===`desktop`){let t=Nm(n),a=o.selector?.kind===`source`?o.selector.value:null,s=o.selector?.kind===`session`?o.selector.value:null;return H`
<openclaw-desktop-panel
.client=${r?n.client:null}
.available=${t}
.documentMode=${!0}
.requestedSource=${a}
.sessionKey=${s}
.documentControl=${o.control}
.onDocumentClose=${()=>this.closeDocument(e.basePath)}
></openclaw-desktop-panel>
${!r&&n.lastError===null?sh(i):W}
${t?this.renderLazyDocumentState(yl):W}
${!t&&(r||n.lastError)?H`<div class="desktop-view-unavailable">
<div class="stack">
<span>${K(`desktop.unavailable`)}</span>
${this.renderFocusEscape(K(`common.back`))}
</div>
</div>`:W}
`}if(o?.kind===`dashboard`)return this.renderFocusDashboard(n,r,i);if(t.documentMode===null&&n.lastError===null&&(n.phase===`starting`||n.phase===`connecting`&&!this.loginGatePinned))return H`
<openclaw-tooltip-provider>
${sh(i)} ${a}
</openclaw-tooltip-provider>
`;let s=n.phase===`reconnecting`||n.phase===`reload-required`,c=!r&&!s;if(c&&!Y(Dl)){let e=this.loginGateLoader.visibleState;return e||this.loginGateLoader.preload(Dl,{reportError:!0}),H`<openclaw-tooltip-provider>
${e?.status===`error`?wa({error:e.error,stale:e.stale,onRetry:()=>this.loginGateLoader.retry()}):sh()}
${a}
</openclaw-tooltip-provider>`}return c?H`
<openclaw-tooltip-provider>
<openclaw-login-gate
.props=${{resourceBasePath:e.resourceBasePath,connected:r,lastError:n.lastError,lastErrorCode:n.lastErrorCode,lastErrorAuthReason:n.lastErrorAuthReason,hasToken:!!this.loginToken.trim(),hasPassword:!!this.loginPassword.trim(),gatewayUrl:this.loginGatewayUrl,token:this.loginToken,password:this.loginPassword,showGatewayToken:this.loginShowGatewayToken,showGatewayPassword:this.loginShowGatewayPassword,onGatewayUrlChange:e=>{this.updateLoginGatewayUrl(e)},onTokenChange:e=>{this.loginToken=e},onPasswordChange:e=>{this.loginPassword=e},onToggleGatewayToken:()=>{this.loginShowGatewayToken=!this.loginShowGatewayToken},onToggleGatewayPassword:()=>{this.loginShowGatewayPassword=!this.loginShowGatewayPassword},onConnect:()=>{this.loginGatePinned=!0,e.gateway.connect({gatewayUrl:this.loginGatewayUrl,token:this.loginToken,password:this.loginPassword})}}}
></openclaw-login-gate>
${a}
</openclaw-tooltip-provider>
`:t.documentMode?.kind===`approval`?H`
<openclaw-tooltip-provider>
${this.pendingGatewayUrl?a:this.renderApprovalDocument(t)}
</openclaw-tooltip-provider>
`:t.documentMode?.kind===`question`?H`
<openclaw-tooltip-provider>
${a} ${this.renderQuestionDocument(t)}
</openclaw-tooltip-provider>
`:H`
<openclaw-tooltip-provider>
<openclaw-github-link-hovercard-provider
.client=${n.client}
.agentId=${e.agentSelection.state.selectedId??n.assistantAgentId??void 0}
>
<openclaw-session-progress-hovercard-provider
.client=${n.client}
.context=${e}
.gateway=${e.gateway}
>
${a}
<openclaw-app-shell
.runtime=${t}
.onboarding=${this.onboarding}
></openclaw-app-shell>
</openclaw-session-progress-hovercard-provider>
</openclaw-github-link-hovercard-provider>
</openclaw-tooltip-provider>
`}},B([U()],ch.prototype,`loginGatePinned`,void 0),B([U()],ch.prototype,`loginGatewayUrl`,void 0),B([U()],ch.prototype,`loginToken`,void 0),B([U()],ch.prototype,`loginPassword`,void 0),B([U()],ch.prototype,`loginShowGatewayToken`,void 0),B([U()],ch.prototype,`loginShowGatewayPassword`,void 0),B([U()],ch.prototype,`pendingGatewayUrl`,void 0),B([U()],ch.prototype,`onboarding`,void 0),B([U()],ch.prototype,`focusDashboardRoute`,void 0)})))()}function uh(e,t){let n=t instanceof CustomEvent?t.detail:null;return typeof n==`object`&&n&&!Array.isArray(n)?{eventType:e,detail:n}:{eventType:e}}function dh(){try{let e=xi()?.getItem(mh),t=e?JSON.parse(e):null;if(typeof t!=`object`||!t||Array.isArray(t))return ph(),null;let n=Object.entries(t),r=n.find(([e])=>e===`eventType`)?.[1],i=gh.find(e=>e===r);if(i&&n.length===1)return{eventType:i};let a=n.find(([e])=>e===`detail`)?.[1];if(i&&n.length===2&&typeof a==`object`&&a&&!Array.isArray(a))return{eventType:i,detail:a}}catch{}return ph(),null}function fh(e){try{let t=xi();return t?(t.setItem(mh,JSON.stringify(e)),!0):!1}catch{}return ph(),!1}function ph(){try{xi()?.removeItem(mh)}catch{}}var mh,hh,gh;function _h(){return(_h=e((()=>{Ha(),da(),mh=`openclaw:lazy-event`,hh=`openclaw:approvals-open`,gh=[Sa,na,Zi,Ua,Qi,Wi,$i,Yi,hh]})))()}var vh;function yh(){return(yh=e((()=>{q(),La(),ja(),da(),Aa(),qa(),Wt(),Ol(),_h(),Im(),vh=class{constructor(e,t){this.host=e,this.requestLazyElement=t,this.restoredPanels=new Set,this.handleDeferredTerminalToggle=e=>{let t=this.host;if(this.isSessionRoute()){Pa(`terminal`,e);return}if(Y(t.terminalPanelElement))return;let n=t.context,r=n?.gateway?.snapshot;if(!r||!_n(r,n.config.current.terminalEnabled??!1)){e.preventDefault();return}this.requestLazyElement(t.terminalPanelElement,uh(Ua,e))},this.handleDeferredBrowserToggle=e=>{let t=this.host;if(this.isSessionRoute()){Pa(`browser`,e);return}if(Y(t.browserPanelElement))return;let n=t.context?.gateway?.snapshot;n&&Mm(n)?this.requestLazyElement(t.browserPanelElement,uh(Qi,e)):e.preventDefault()},this.handleDeferredDesktopToggle=e=>{let t=this.host;if(this.isSessionRoute()){Pa(`desktop`,e);return}let n=t.context;if(!n||!Nm(n.gateway.snapshot)){e.preventDefault(),e.stopImmediatePropagation();return}Y(t.desktopPanelElement)||this.requestLazyElement(t.desktopPanelElement,uh(Wi,e))},this.handleDeferredAssistantToggle=e=>{let t=this.host;if(Y(t.assistantPanelElement))return;let n=t.context?.gateway?.snapshot,r=e.type===Yi;(r?Pm(t.context?.gateway):Ka(n,`openclaw.chat`,`operator.admin`))?this.requestLazyElement(t.assistantPanelElement,uh(r?Yi:$i,e)):e.preventDefault()}}reset(){this.restoredPanels.clear()}restore(){let e=this.host,t=e.context,n=t?.gateway?.snapshot;if(!n)return;let r=Nm(n),i=Ka(n,`openclaw.chat`,`operator.admin`),a=mo(e.routeState.routeId),o=_n(n,t.config.current.terminalEnabled??!1),s=!a&&Mm(n),c=i||Pm(t.gateway);for(let[t,n,i]of[[e.terminalPanelElement,Oa,o],[e.browserPanelElement,ba,s],[e.desktopPanelElement,Ea,!a&&r],[e.assistantPanelElement,va,c]]){if(!i)continue;let r=!this.restoredPanels.has(t)&&n.load().open;this.restoredPanels.add(t),(t===e.assistantPanelElement&&e.custodianMinimizeRequestId>0||r)&&e.lazyCustomElements.preload(t,{reportError:!0})}}isSessionRoute(){return mo(vo(globalThis.location?.pathname??``,this.host.context?.basePath??``)??this.host.routeState.routeId)}}})))()}function bh(){return`(max-width: ${th()?Eh:Th}px)`}function xh(){return globalThis.matchMedia?.(bh()).matches??!1}function Sh(){return Dh.some(e=>document.documentElement.classList.contains(e))}function Ch(e){return e.mobileNavLayout&&mo(e.routeId)&&!e.onboarding&&!Sh()}function wh(e,t){return Ch({mobileNavLayout:e,routeId:`chat`,onboarding:t})}var Th,Eh,Dh;function Oh(){return(Oh=e((()=>{q(),ih(),Th=1100,Eh=600,Dh=[`openclaw-native-macos`,`openclaw-native-nav`,`openclaw-native-web-chrome`]})))()}var kh;function Ah(){return(Ah=e((()=>{I(),kh=class{constructor(e,t){this.host=e,this.requestOpen=t,this.pending=!1}load(){this.owner||this.pending||(this.pending=!0,R(async()=>{let{NavDrawerSwipeOwner:e}=await import(`./nav-drawer-swipe.runtime-BJvyGdY6.js`);return{NavDrawerSwipeOwner:e}},__vite__mapDeps([85,2]),import.meta.url).then(({NavDrawerSwipeOwner:e})=>{this.owner=new e(this.host,this.requestOpen),this.pending=!1,this.host.isConnected&&this.owner.connect()},()=>this.pending=!1))}connect(){this.owner?.connect()}disconnect(){this.owner?.disconnect()}opened(){return this.owner?.opened(),!!this.owner}closed(){this.owner?.closed()}}})))()}function jh(e){let t=[...e.querySelectorAll(`openclaw-sidebar-attention:defined`)].map(e=>e.dismissPanel()).some(e=>e);return e.querySelector(`openclaw-app-sidebar:defined`)?.dismissTransientMenus()===!0||t}function Mh(e,t){let n=e.querySelector(`.shell-nav`);if(!n||t.composedPath().some(e=>e instanceof Element&&e!==n&&e.matches(`dialog, [role='dialog']`)))return;let r=[...n.querySelectorAll(Bh)].filter(e=>e.checkVisibility()),i=t.shiftKey?r.at(-1):r[0],a=t.shiftKey?r[0]:r.at(-1);(!n.contains(document.activeElement)||document.activeElement===a||t.shiftKey&&document.activeElement===n)&&(t.preventDefault(),(i??n).focus({preventScroll:!0}))}function Nh(e,t){t.defaultPrevented||hr(V.escape,t)||(hr(V.toggleSidebar,t)?(t.preventDefault(),e.closeNavDrawer({restoreFocus:!0})):t.key===`Tab`?Mh(e,t):(ga(t)||ua(t)||hr(V.workspaceFiles,t)||hr(V.sideChat,t))&&(t.preventDefault(),t.stopImmediatePropagation()))}function Ph(e){let t=e.querySelector(`.shell-nav`),n=e.querySelector(`openclaw-toast-host`);t&&n&&n.parentElement!==t&&t.moveBefore(n,null)}function Fh(e){let t=e.querySelector(`.shell`),n=e.querySelector(`openclaw-toast-host`);t&&n?.parentElement?.classList.contains(`shell-nav`)&&t.moveBefore(n,null)}function Ih(e){return[...e.querySelectorAll(`.topbar-nav-toggle, .chat-pane__nav-toggle`)].find(e=>e.checkVisibility())}function Lh(e){return e.onboarding||(e.mobileNavLayout?!e.navDrawerOpen:e.navCollapsed)}function Rh(e){return e.navigationSurfaceHidden&&!e.mobileNavLayout&&!e.onboarding&&!e.compact}function zh(e){let t=Rh(e),n=!e.compact&&e.refreshRequired;return!t&&!n?W:H`${t?H`<openclaw-sidebar-attention
class="sidebar-attention--floating"
.onNavigate=${e.onNavigate}
.onOpenApprovals=${e.onOpenApprovals}
></openclaw-sidebar-attention>`:W}${n?H`<openclaw-sidebar-update-card
class="sidebar-update-card--floating"
.updateAvailable=${e.updateAvailable}
.updateSchedule=${e.updateSchedule??null}
.heldUpdateCampaignId=${e.heldUpdateCampaignId??null}
.updateBusy=${e.updateBusy}
.updateRun=${e.updateRun??null}
.updateRunAcknowledged=${e.updateRunAcknowledged??!1}
.connected=${e.connected??!1}
.onAcknowledge=${e.onAcknowledge}
.onCheckStatus=${e.onCheckStatus}
.statusBanner=${e.statusBanner??null}
.watchUpdateProgress=${e.watchUpdateProgress}
.canUpdate=${e.canUpdate??!1}
.canHoldUpdate=${e.canHoldUpdate??!1}
.onUpdate=${e.onUpdate}
.refreshRequired=${e.refreshRequired}
.onRefresh=${e.onRefresh}
.onHoldUpdate=${e.onHoldUpdate??(async()=>!1)}
.onReviewUpdate=${e.onReviewUpdate??(()=>void 0)}
></openclaw-sidebar-update-card>`:W}`}var Bh;function Vh(){return(Vh=e((()=>{Ii(),Ha(),da(),fn(),Bh=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex='-1'])`})))()}function Hh(e){return e!==void 0&&ns(e)}var Uh,Wh;function Gh(){return(Gh=e((()=>{ws(),q(),Ha(),da(),Ji(),fn(),dr(),Wt(),yh(),Ol(),_h(),Oh(),ih(),Ah(),Vh(),Im(),tf(),Jc(),Wh=class{constructor(e){this.host=e,this.pendingLazyAction=dh(),this.toggleNavigationSurface=e=>{let t=this.host,n=t.context;if(!n||t.onboardingMode||Hh(t.routeState.routeId)&&!xh())return;if(xh()){if(this.navDrawerSwipe.load(),t.navDrawerOpen){t.closeNavDrawer({restoreFocus:!0});return}t.navDrawerTrigger=e??Ih(t)??null,t.navDrawerOpen=!0,Ph(t),this.navDrawerSwipe.opened()||t.updateComplete.then(()=>{t.isConnected&&t.navDrawerOpen&&t.querySelector(`.shell-nav`)?.focus({preventScroll:!0})});return}let r=t.navDrawerOpen||!(n.navigation.snapshot.navCollapsed&&!t.desktopNavigationExpanded);t.desktopNavigationExpanded=!1,r&&this.dismissSidebarTransientMenus(),t.closeNavDrawer(),n.navigation.update({navCollapsed:r}),r&&t.updateComplete.then(()=>{this.restoreFocusTo(t.querySelector(`.shell-chrome-controls__nav-toggle`))})},this.restoreFocusTo=e=>fa(e?.isConnected&&e.checkVisibility()?e:this.host.querySelector(`.content`)),this.closeNavDrawer=(e={})=>{let t=this.host;t.navDrawerOpen&&(this.dismissSidebarTransientMenus(),this.navDrawerSwipe.closed()),Fh(t);let n=e.restoreFocus?t.navDrawerTrigger:null;t.navDrawerOpen=!1,t.navDrawerTrigger=null,e.restoreFocus&&requestAnimationFrame(()=>this.restoreFocusTo(n))},this.resizeNavigation=e=>{let t=this.host,n=t.querySelector(`.shell`),r=t.context;if(!n||!r)return;let i=Math.round(Math.min(400,Math.max(240,e*n.clientWidth)));r.navigation.update({navWidth:i})},this.handleNativeToggleSidebar=()=>this.toggleNavigationSurface(),this.handleNativeOpenSearch=()=>this.openPalette(),this.handleNativeToggleSearch=e=>{e.preventDefault(),this.togglePalette()},this.handleNativeNewSession=()=>{let e=this.host,t=e.context;if(!e.onboardingMode){if(!t){e.pendingNativeNewSession=!0;return}pi(t.gateway.snapshot,{method:`sessions.create`,params:{}}).allowed&&e.openNewSession(t.agentSelection.state.selectedId??``)}},this.handleNativeNavigate=e=>{let t=e.detail,n=t?.path,r=typeof n==`string`?n.slice(1):``;if(typeof n!=`string`||!n.startsWith(`/`)||n.startsWith(`//`)||/^[a-z][a-z\d+.-]*:/i.test(r))return;let i=vo(n),a=this.host.context;if(!i||!a)return;e.preventDefault();let o={pathname:`${a.basePath}${n}`},s=t?.search;typeof s==`string`&&s.startsWith(`?`)&&!s.includes(`#`)&&(o.search=s),this.host.navigate(i,o)},this.handleNativeHistoryState=e=>{let t=e.detail;typeof t?.canGoBack==`boolean`&&typeof t.canGoForward==`boolean`&&(this.host.nativeHistoryState=t)},this.handleWindowResize=()=>{let e=this.host,t=xh(),n=t&&!e.navDrawerOpen&&this.dismissSidebarTransientMenus();t?(this.navDrawerSwipe.load(),e.desktopNavigationExpanded=!1):e.navDrawerOpen&&(e.closeNavDrawer({restoreFocus:!1}),e.desktopNavigationExpanded=e.context?.navigation.snapshot.navCollapsed??!1),e.requestUpdate(),e.updateComplete.then(()=>{xh()&&!e.navDrawerOpen&&n&&requestAnimationFrame(()=>{this.restoreFocusTo(Ih(e))})})},this.handleUnhandledFileDrag=e=>{let t=e.composedPath().some(e=>e instanceof HTMLInputElement&&e.type===`file`&&!e.disabled);e.defaultPrevented||t||!Array.from(e.dataTransfer?.types??[]).includes(`Files`)||(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`none`))},this.dismissSidebarTransientMenus=()=>jh(this.host),this.handleDocumentKeydownBubble=e=>{let t=this.host;e.defaultPrevented||!hr(V.escape,e)||(t.navDrawerOpen&&xh()&&!document.openClawModalLayers?.size?(e.preventDefault(),t.closeNavDrawer({restoreFocus:!0})):Hh(t.routeState.routeId)&&!this.shouldIgnoreSettingsEscape(e)&&(e.preventDefault(),t.exitSettings()))},this.handleDocumentKeydown=e=>{let t=this.host;if(!document.openClawModalLayers?.size){if(t.navDrawerOpen&&xh()){Nh(t,e);return}if(!t.commandPalette&&ga(e)){e.preventDefault(),this.togglePalette();return}if(ua(e)&&!mo(t.routeState.routeId)&&!e.defaultPrevented&&!t.onboardingMode&&!Hh(t.routeState.routeId)&&t.context&&_n(t.context.gateway.snapshot,t.context.config.current.terminalEnabled??!1)){e.preventDefault(),window.dispatchEvent(new CustomEvent(Ua));return}if(qi(e)&&Pm(t.context?.gateway)){e.preventDefault(),window.dispatchEvent(new CustomEvent(Yi));return}if(!e.defaultPrevented){if(hr(V.keyboardShortcuts,e)){e.preventDefault(),window.dispatchEvent(new CustomEvent(Zi));return}if(hr(V.debugOverlay,e)){let t=e.target;if(t instanceof Element&&t.closest(`input, textarea, [contenteditable]:not([contenteditable='false'])`))return;e.preventDefault(),window.dispatchEvent(new CustomEvent(na));return}if(hr(V.escape,e)&&Hh(t.routeState.routeId)){if(t.navDrawerOpen){e.preventDefault(),t.closeNavDrawer({restoreFocus:!0});return}if(e.eventPhase===Event.CAPTURING_PHASE||this.shouldIgnoreSettingsEscape(e))return;e.preventDefault(),t.exitSettings();return}if(hr(V.appearanceSettings,e)){e.preventDefault(),t.navigate(`appearance`);return}hr(V.toggleSidebar,e)&&(e.preventDefault(),this.toggleNavigationSurface())}}},this.handleDebugOverlayRequest=e=>{let t=this.host;t.navDrawerOpen&&xh()&&t.closeNavDrawer({restoreFocus:!1});let n=uh(na,e);if(Y(dl)){t.querySelector(dl.tagName)?.toggle(),this.clearPendingLazyAction(n);return}this.requestLazyElement(dl,n)},this.handleKeyboardShortcutsRequest=e=>{let t=uh(Zi,e);if(Y(pl)){this.host.querySelector(pl.tagName)?.toggle(),this.clearPendingLazyAction(t);return}this.requestLazyElement(pl,t)},this.handleCommandPaletteOpen=(e,t)=>{let n=this.host,r=n.commandPalette,i=uh(Sa,e);if(r){r.openPalette(),this.clearPendingLazyAction(i);return}this.requestLazyElement(n.commandPaletteElement,i,t)},this.openPalette=()=>this.handleCommandPaletteOpen(new CustomEvent(Sa),this.openPalette),this.handleShellNavDrawerToggle=e=>{this.toggleNavigationSurface(Ba(e))},this.togglePalette=()=>{let e=this.host.commandPalette;e?e.togglePalette():this.openPalette()},this.openApprovals=()=>void window.dispatchEvent(new CustomEvent(hh)),this.handleApprovalsOpen=e=>{let t=this.host,n=uh(hh,e);if(Y(t.execApprovalElement)){t.approvalOverlay?.show(),this.clearPendingLazyAction(n);return}this.requestLazyElement(t.execApprovalElement,n)},this.restorePendingLazyAction=()=>{let e=this.pendingLazyAction;if(!e||this.host.lazyCustomElements.visibleState)return;let t=this.lazyElementForShellEvent(e.eventType);Y(t)&&!this.host.querySelector(t.tagName)||this.dispatchLazyShellEvent(e)&&!this.host.lazyCustomElements.visibleState&&this.clearPendingLazyAction(e)},this.handleCommandPaletteSlashCommand=e=>{let t=this.host,n=t.commandPaletteTarget?.owner.isConnected?t.commandPaletteTarget.onSlashCommand:null;if(n){n(e);return}let r=t.chatNavigationOptions(`chat`),i=new URLSearchParams(r?.search??``);i.set(`draft`,e.endsWith(` `)?e:`${e} `),t.navigate(`chat`,{...r,search:`?${i.toString()}`})},this.handleCommandPaletteTarget=e=>za(this.host,e),this.nativeNavCollapsed=()=>{let e=this.host,t=xh();return e.onboardingMode||t||Hh(e.routeState.routeId)&&!t||!e.navDrawerOpen&&!e.desktopNavigationExpanded&&(e.context?.navigation.snapshot.navCollapsed??!1)},this.panels=new vh(e,(e,t)=>this.requestLazyElement(e,t)),this.navDrawerSwipe=new kh(e,()=>this.toggleNavigationSurface())}connect(){this.disconnect(),this.listeners=new AbortController;let e={signal:this.listeners.signal},t=this.host;t.nativeHistoryState=nh(),t.addEventListener(xa,this.handleCommandPaletteTarget,e),document.addEventListener(`keydown`,this.handleDocumentKeydown,{capture:!0,signal:this.listeners.signal}),document.addEventListener(`keydown`,this.handleDocumentKeydownBubble,e),window.addEventListener(`dragover`,this.handleUnhandledFileDrag,e),window.addEventListener(`drop`,this.handleUnhandledFileDrag,e);for(let[t,n]of[[Sa,this.handleCommandPaletteOpen],[ha,this.handleShellNavDrawerToggle],[na,this.handleDebugOverlayRequest],[Zi,this.handleKeyboardShortcutsRequest],[`resize`,this.handleWindowResize],[rh,this.handleNativeHistoryState],[`openclaw:native-toggle-sidebar`,this.handleNativeToggleSidebar],[`openclaw:native-open-search`,this.handleNativeOpenSearch],[`openclaw:native-toggle-search`,this.handleNativeToggleSearch],[`openclaw:native-new-session`,this.handleNativeNewSession],[`openclaw:native-navigate`,this.handleNativeNavigate],[Ua,this.panels.handleDeferredTerminalToggle],[Qi,this.panels.handleDeferredBrowserToggle],[Wi,this.panels.handleDeferredDesktopToggle],[$i,this.panels.handleDeferredAssistantToggle],[Yi,this.panels.handleDeferredAssistantToggle],[hh,this.handleApprovalsOpen]])window.addEventListener(t,n,e);this.navDrawerSwipe.connect(),xh()&&this.navDrawerSwipe.load(),Uh=this.listeners,Object.assign(window,{__OPENCLAW_NATIVE_COMMANDS_READY__:!0}),window.dispatchEvent(new Event(`openclaw:native-commands-state`))}disconnect(){let e=this.listeners;this.listeners?.abort(),this.listeners=void 0,this.navDrawerSwipe.disconnect(),e&&Uh===e&&(Uh=void 0,Object.assign(window,{__OPENCLAW_NATIVE_COMMANDS_READY__:!1}),window.dispatchEvent(new Event(`openclaw:native-commands-state`)))}shouldIgnoreSettingsEscape(e){let t=this.host,n=t.context?.overlays.snapshot;if(t.commandPalette?.isOpen||t.querySelector(pl.tagName)?.isOpen||n?.devicePairSetupOpen||t.approvalOverlay?.dialogOpen===!0||document.openClawModalLayers?.size)return!0;let r=e.target;return r instanceof Element&&r.closest(`input, textarea, select, wa-select[open], [contenteditable], dialog, [role='dialog'], [role='menu'], [role='listbox']`)!==null}lazyElementForShellEvent(e){let t=this.host;return{[Sa]:t.commandPaletteElement,[na]:dl,[Zi]:pl,[Ua]:t.terminalPanelElement,[Qi]:t.browserPanelElement,[Wi]:t.desktopPanelElement,[$i]:t.assistantPanelElement,[Yi]:t.assistantPanelElement,[hh]:t.execApprovalElement}[e]}requestLazyElement(e,t,n=()=>this.dispatchLazyShellEvent(t)){this.pendingLazyAction=t,fh(t),this.host.lazyCustomElements.request(e,()=>{n(),this.clearPendingLazyAction(t)})}retryPendingLazyAction(e){let t=this.pendingLazyAction;return Ic({canReload:()=>e()&&this.pendingLazyAction===t&&(!t||fh(t))})}dispatchLazyShellEvent({eventType:e,detail:t}){return window.dispatchEvent(new CustomEvent(e,{cancelable:!0,detail:t}))}clearPendingLazyAction(e){JSON.stringify(this.pendingLazyAction)===JSON.stringify(e)&&(ph(),this.pendingLazyAction=null)}cancelPendingLazyAction(){let e=this.pendingLazyAction;e&&this.clearPendingLazyAction(e)}abandonPendingLazyActionForContext(){this.panels.reset(),this.pendingLazyAction=null,ph(),this.host.lazyCustomElements.abandon()}preservePendingLazyActionForReload(){this.panels.reset(),this.host.lazyCustomElements.abandon()}}})))()}function Kh(e){return e===`theme`||e===`themeMode`||e===`accent`||e===`fontUi`||e===`fontChat`}function qh(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,n)=>e===t[n]):e===t}function Jh(e,t,n){let r=(n,r)=>{qh(t[n],r)||(e[n]=r)};for(let e of Object.keys(n))r(e,n[e])}function Yh(e){let t=P(P(P(e)?.ui)?.prefs);if(!t)return{};let n={};for(let e of rg){if(ng[e].configSync===!1)continue;let r=ng[e].extract(t[e]);r!==void 0&&(n[e]=r)}return n}function Xh(e,t,n,r,i,a){let o=ng[t],s=o.local(r),c=o.reset?.(r),l=c?o.local({...r,...c}):void 0,u=e=>{let t=!qh(s,e);return{overridden:t,provenance:t||o.configSync===!1&&i===!1?`device-local`:`default`,resetValue:e,value:s}},d=P(P(P(e)?.ui)?.prefs),f=o.configSync!==!1&&d&&Object.hasOwn(d,t)?o.extract(d[t]):void 0,p=a?.[t]??void 0,m=p??f,h=p!==void 0,g=a!=null&&Kh(t)?f??l:l,_=m!==void 0&&(!o.canApply||o.canApply(m,r)),v=_?m:l;if(n&&t in n){if(i===!1)return{...u(v),provenance:`device-local`};let e=n[t];return e===null?{...u(g),provenance:`pending`}:{overridden:!0,provenance:`pending`,resetValue:g,value:e}}return(!d||!Object.hasOwn(d,t))&&!h||m===void 0?u(l):_?qh(s,m)?{overridden:!0,provenance:h?`profile`:`synced`,resetValue:g,value:m}:u(m):i===!1?u(l):{overridden:!0,provenance:h?`profile`:`synced`,resetValue:g,value:s}}function Zh(e,t){let n={};for(let r of rg){let i=ng[r],a=e[r];if(a!==void 0){if(a===null){let e=i.clearable?i.reset?.(t):void 0;e&&Jh(n,t,e);continue}qh(a,i.local(t))||i.canApply&&!i.canApply(a,t)||(n[r]=a)}}return Object.keys(n).length>0?n:null}var Qh,$h,eg,tg,ng,rg;function ig(){return(ig=e((()=>{d(),ws(),G(),tf(),Hu(),Qh=new Set([...Ke,`custom`]),$h=new Set([`light`,`dark`,`system`]),eg=e=>e,tg=e=>eg({configSync:!1,extract:ju,local:t=>ju(t[e]),write:t=>({[e]:t}),clearable:!0,reset:()=>({[e]:void 0})}),ng={theme:eg({extract:e=>Qh.has(e)?e:void 0,local:e=>e.theme,write:e=>({theme:e??X.theme}),clearable:!0,reset:()=>({theme:X.theme}),canApply:(e,t)=>e!==`custom`||!!t.customTheme}),themeMode:eg({extract:e=>$h.has(e)?e:void 0,local:e=>e.themeMode,write:e=>({themeMode:e??X.themeMode}),clearable:!0,reset:()=>({themeMode:X.themeMode})}),accent:eg({extract:ad,local:e=>ad(e.accent),write:e=>({accent:e}),clearable:!0,reset:()=>({accent:void 0})}),fontUi:tg(`fontUi`),fontChat:tg(`fontChat`),locale:eg({extract:e=>typeof e==`string`&&Na(e)?e:void 0,local:e=>e.locale,write:e=>({locale:e}),clearable:!0,reset:()=>({locale:void 0})}),chatShowThinking:eg({extract:e=>typeof e==`boolean`?e:void 0,local:e=>e.chatShowThinking}),chatShowToolCalls:eg({extract:e=>typeof e==`boolean`?e:void 0,local:e=>e.chatShowToolCalls}),chatPersistCommentary:eg({extract:e=>typeof e==`boolean`?e:void 0,local:e=>e.chatPersistCommentary!==!1}),chatSendShortcut:eg({extract:e=>e===`enter`||e===`modifier-enter`?Gd(e):void 0,local:e=>Gd(e.chatSendShortcut),write:e=>({chatSendShortcut:e}),clearable:!0,reset:()=>({chatSendShortcut:void 0})}),chatFollowUpMode:eg({extract:e=>id(e),local:e=>id(e.chatFollowUpMode),write:e=>({chatFollowUpMode:e}),clearable:!0,reset:()=>({chatFollowUpMode:void 0})}),sidebarEntries:eg({extract:e=>Xo(e)??void 0,local:e=>e.sidebarEntries})},rg=Object.keys(ng)})))()}function ag(e,t){return t?`${e}:profile:${t}`:e}function og(e,t){return t&&dg?.profileId===t&&dg.scope===e?dg.prefs:null}function sg(e){return dg?.scope===e?dg.profileId:null}function cg(){dg=null,fg+=1}async function lg(e,t,n){let r=++fg,i=await e.request(`users.prefs.get`,{keys:Object.values(a)});if(r!==fg||i.status!==`ok`)return!1;let o={};for(let[e,t]of Object.entries(a)){if(!Kh(e))continue;let n=c(t,i.entries[t]);n!==void 0&&Object.assign(o,{[e]:n})}return dg={profileId:t,scope:n,prefs:o},!0}async function ug(e,t,n){if(!e||!n)return{ok:!1,reason:`unavailable`,error:`Profile preferences are unavailable.`};let r=Object.fromEntries(Object.entries(t).flatMap(([e,t])=>Kh(e)?[[a[e],t]]:[]));try{let t=await e.request(`users.prefs.set`,{entries:r});return t.status===`ok`?{ok:!0,value:t,refresh:{ok:!0}}:{ok:!1,reason:`rejected`,error:`Profile preferences are unavailable.`}}catch(e){return{ok:!1,reason:e instanceof Vs&&(e.gatewayCode===`INVALID_REQUEST`||e.gatewayCode===`FORBIDDEN`)?`rejected`:`error`,error:e instanceof Error?e.message:String(e)}}}var dg,fg;function pg(){return(pg=e((()=>{d(),$s(),ig(),dg=null,fg=0})))()}function mg(e,t){try{let n=globalThis.localStorage;return n?{available:!0,value:n.getItem(`${e}:${t}`)}:{available:!1,value:null}}catch{return{available:!1,value:null}}}function hg(e,t){return mg(e,t).value}function gg(e,t,n){try{let r=globalThis.localStorage;if(!r)return!1;let i=`${e}:${t}`;return n===null?r.removeItem(i):r.setItem(i,n),!0}catch{return!1}}function _g(e){try{let t=P(JSON.parse(e??`null`));return t&&Object.keys(t).length?t:null}catch{return null}}function vg(e,t){let n=mg(e,t);return{available:n.available,prefs:_g(n.value)}}function yg(e){let t=_g(hg(Cg,e));if(!t)return new Set;let n=Object.keys(t).filter(e=>Object.hasOwn(ng,e));return new Set(n)}function bg(e,t){gg(Cg,e,t.size?JSON.stringify(Object.fromEntries([...t].map(e=>[e,!0]))):null)}var xg,Sg,Cg;function wg(){return(wg=e((()=>{ig(),xg=`openclaw.control.serverPrefs.v1`,Sg=`openclaw.control.serverPrefs.pending.v1`,Cg=`openclaw.control.serverPrefs.retained-local.v1`})))()}function Tg(e,t,n=``,r=Sd(n||void 0),i={}){let a=ag(n,i.profileId);return Xh(e,t,a===Z?Q:_g(hg(Sg,a)),r,i.canSync,og(n,i.profileId))}function Eg(e,t){let n={};for(let r of rg){if(Zg.delete(r))continue;if(Xg.delete(r)){n[r]=null;continue}let i=ng[r],a=i.local(e),o=i.local(t);if(!qh(a,o)){if(o===void 0){i.clearable&&(n[r]=null);continue}n[r]=o}}return Object.keys(n).length>0?n:null}function Dg(){c_!==null&&(clearTimeout(c_),c_=null),l_=0}function Og(e,t,n){let r=yg(e);for(let e of t)n?r.add(e):r.delete(e);bg(e,r),n&&e===u_&&(d_=null)}function kg(e,t=!1){if(!t&&e===Z)return;Z=e;let n=vg(Sg,e);Q=n.prefs,$g=new Set(n.available&&n.prefs?Object.keys(n.prefs):[])}function Ag(e){gg(`openclaw.control.serverPrefs.pending.v1`,Z,e?JSON.stringify(e):null)?$g=new Set(Q?Object.keys(Q):[]):$g.clear()}function jg(e,t){e===Z&&Pg();let n=e===Z?Q:null,r={..._g(hg(Sg,e)),...n};for(let e of t)delete r[e];let i=Object.keys(r).length?r:null;if(e===Z){Q=i,Ag(i);return}gg(Sg,e,i?JSON.stringify(i):null)}function Mg(){let e={..._g(hg(`openclaw.control.serverPrefs.pending.v1`,Z))??{},...Q};Ag(Object.keys(e).length?e:null)}function Ng(e){let t={..._g(hg(Sg,Z))};for(let n of Object.keys(e))qh(t[n],e[n])&&delete t[n];let n={...t,...Q};Ag(Object.keys(n).length?n:null)}function Pg(){if(!Q||$g.size===0)return;let e=vg(Sg,Z);if(!e.available)return;let t=e.prefs??{};for(let e of $g){if(!Object.hasOwn(t,e)){delete Q[e],$g.delete(e);continue}let n=t[e];qh(Q[e],n)||(Q[e]=n)}Object.keys(Q).length||(Q=null)}function Fg(e){let t=Q;return!!(t&&Object.keys(e).every(n=>Object.hasOwn(t,n)&&qh(t[n],e[n])))}function Ig(){Dg(),Qg=a_=o_=!1,Z=``,Q=e_=null,$g.clear(),t_=``,n_=null,r_=!1,u_=``,d_=null,cg(),Xg.clear(),Zg.clear()}function Lg(e,t,n=Z){let r=ng[e],i=Kh(e)?sg(n):null,a=ag(n,i),o=r.reset;if(!o)throw Error(`Server UI preference is not resettable: ${e}`);if(t?.provenance===`device-local`){let n=r.write;if(!n)throw Error(`Server UI preference cannot restore a retained local value: ${e}`);return jg(a,[e]),Og(a,[e],!1),Zg.add(e),Ed(n(t.resetValue))}if(Xg.add(e),i&&t){let e=r.write;if(e)return Ed(e(t.resetValue))}return Ed(o(Sd()))}function Rg(e,t){let n=t.scope??``,r=ag(n,t.profileId);if(r===u_&&e===d_)return!1;let i=u_!==``&&r!==u_,a=()=>{u_=r,d_=e},o=r===Z?Q:_g(hg(Sg,r)),s=yg(r),c={...Yh(e),...og(n,t.profileId)},l=JSON.stringify(c),u=hg(xg,r);if(!i&&l===u)return s.size&&Og(r,[...s],!1),a(),!1;let d=_g(u)??{},f={};for(let e of Object.keys(c))!(o&&e in o)&&!s.has(e)&&(i||u===null||!qh(c[e],d[e]))&&(f[e]=c[e]);for(let e of Object.keys(d))!(e in c)&&!(o&&e in o)&&!s.has(e)&&ng[e]?.clearable&&(f[e]=null);if(i)for(let e of rg)Kh(e)&&!(e in c)&&!(o&&e in o)&&!s.has(e)&&ng[e].clearable&&(f[e]=null);gg(xg,r,l),s.size&&Og(r,[...s],!1),a(),Object.hasOwn(f,`theme`)&&t.onThemeChanged?.(f.theme??null);let p=Zh(f,Sd(n||void 0));if(!p)return!1;Qg=!0;try{Ed(p)}finally{Qg=!1}return t.onApplied(p),!0}async function zg(e){let t=e.scope??e.client.gatewayUrl;return await lg(e.client,e.profileId,t)?(d_=null,Rg(e.configObject,{...e,scope:t})):!1}function Bg(){return Qg}function Vg(e,t){let n=t.profileId??t.profile?.selfUser?.id??null,r=ag(e.state.client?.gatewayUrl??``,n);if(r_=t.canWrite??rc(t.profile?.hello?.auth??null),e_===e&&t_===r&&n_===n)return;Pg();let i=Z===``?{..._g(hg(Sg,``)),...Q}:null;Dg(),s_+=1,e_=e,t_=r,n_=n,a_=!1,kg(r,!0),r&&i&&Object.keys(i).length&&(Q={...Q,...i},Mg(),gg(Sg,``,null))}function Hg(e){if(Q){for(let t of Object.keys(e))qh(Q[t],e[t])&&(delete Q[t],$g.delete(t));Object.keys(Q).length||(Q=null)}}function Ug(e,t){c_!==null||l_>=Yg||(l_+=1,c_=setTimeout(()=>{c_=null,e_===e&&s_===t&&Q&&Gg(e)},Jg))}async function Wg(e,t){for(;Q;){if(e_!==e||s_!==t||(Pg(),!Q))return;let n=rg.filter(e=>Q?.[e]!==void 0&&ng[e].configSync===!1&&!(n_&&r_));if(n.length){if(!e.state.connected)return;jg(Z,n),Og(Z,n,!0),i_?.({needsRefresh:!1,retainedLocal:!0});continue}if(n_&&Q.theme===`custom`){jg(Z,[`theme`]),Og(Z,[`theme`],!0);continue}let r={};if(n_&&r_)for(let e of rg)Kh(e)&&Object.hasOwn(Q,e)&&Object.assign(r,{[e]:Q[e]});let i=!!(r&&Object.keys(r).length),a=i?r:{...Q},o=i_;for(let n=0;n<2;n+=1){if(e_!==e||s_!==t)return;let r=i?await ug(e.state.client,a,e.state.connected&&r_&&Fg(a)):await e.runExternalMutation(e=>e.request(`config.patch`,{raw:JSON.stringify({ui:{prefs:a}}),...a.sidebarEntries===void 0?{}:{replacePaths:[`ui.prefs.sidebarEntries`]},note:`control-ui prefs sync`}),{waitForWritesResumed:!0,canDispatch:()=>e.canPatch!==!1&&(Pg(),Fg(a)?!0:(o_=!!Q,!1)),dispatchError:`Access changed before preferences could sync.`});if(e_!==e||s_!==t)return;if(r.ok){Hg(a);let n={..._g(hg(`openclaw.control.serverPrefs.v1`,Z))??{},...a},s=og(e.state.client?.gatewayUrl??``,n_);if(i&&s){let t=Yh(e.state.configSnapshot?.config);for(let e of rg)Object.hasOwn(a,e)&&(a[e]===null?(delete s[e],t[e]===void 0?delete n[e]:Object.assign(n,{[e]:t[e]})):Object.assign(s,{[e]:a[e]}));d_=null}if(gg(xg,Z,JSON.stringify(n)),Ng(a),Dg(),e_!==e||s_!==t||(r.refresh.ok&&o&&u_===Z&&(d_=null),o?.({needsRefresh:!r.refresh.ok}),e_!==e||s_!==t))return;break}if(r.reason===`conflict`&&n===0){await new Promise(e=>{setTimeout(e,250)});continue}if(r.reason===`conflict`){Ug(e,t);return}if(r.reason===`error`||r.reason===`unavailable`||r.reason===`suspended`)return;Hg(a),Ng(a),o?.({needsRefresh:!1,retainedLocal:!0});return}}}function Gg(e){if(a_){o_=!0;return}if(!Q||e.state.connected&&e.canPatch===!1&&!(n_&&r_&&Object.keys(Q).some(Kh)))return;a_=!0;let t=s_;Wg(e,t).catch(()=>void 0).finally(()=>{e_===e&&s_===t&&(a_=!1,o_&&(o_=!1,Gg(e)))})}function Kg(e,t,n={}){Vg(e,n),Dg(),i_=n.afterCommit;let r=rg.filter(e=>Object.hasOwn(t,e)),i=e.state.connected?r.filter(n=>ng[n].configSync===!1&&!n_?!0:n_&&Kh(n)?!r_||n===`theme`&&t.theme===`custom`:e.canPatch===!1):[];if(i.length&&(jg(Z,i),Og(Z,i,!0),n.afterCommit?.({needsRefresh:!1,retainedLocal:!0}),i.length===r.length))return;let a=i.length?Object.fromEntries(Object.entries(t).filter(([e])=>!i.some(t=>t===e))):t;Pg(),Q={...Q,...a},Mg(),Gg(e)}function qg(e,t={}){Vg(e,t),Dg(),s_+=1,a_=o_=!1,i_=t.afterCommit,Gg(e)}var Jg,Yg,Xg,Zg,Qg,Z,Q,$g,e_,t_,n_,r_,i_,a_,o_,s_,c_,l_,u_,d_;function f_(){return(f_=e((()=>{cc(),pg(),ig(),wg(),tf(),Jg=1e3,Yg=5,Xg=new Set,Zg=new Set,Qg=!1,Z=``,Q=null,$g=new Set,e_=null,t_=``,n_=null,r_=!1,a_=!1,o_=!1,s_=0,c_=null,l_=0,u_=``,d_=null})))()}function p_(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[],i=[];for(let t of e){let e=n.get(t.id);e?JSON.stringify(e)!==JSON.stringify(t)&&(r.push(t.id),i.push(t.id)):r.push(t.id)}return{invalidatedIds:r,changedIds:i}}var m_,h_;function g_(){return(g_=e((()=>{da(),G(),cc(),f_(),I(),m_=100,h_=class{constructor(e){this.host=e,this.runtimeConfigProfileId=null,this.profileAppearanceSource=null}reconcileServerUiPrefs(e){let t=e.state.configSnapshot,n=this.host.context;if(!t?.config||!n||n.runtimeConfig!==e||n.gateway.snapshot.phase!==`connected`)return;let r=n.gateway.connection.gatewayUrl;Rg(t.config,{scope:r,profileId:n.gateway.snapshot?.selfUser?.id,onThemeChanged:e=>n.theme.recordServerSelection(e,r),onApplied:e=>{e.sidebarEntries!==void 0&&n.navigation.update({sidebarEntries:e.sidebarEntries}),n.theme.refresh()}}),this.refreshProfileAppearancePrefs(n).catch(()=>void 0);let i=Tg(t.config,`locale`,r),a=JSON.stringify([r,i.overridden,i.value]);if(a!==this.host.lastLocalePrefSignature){if(this.host.lastLocalePrefSignature=a,i.overridden&&Na(i.value)){ia.setLocale(i.value);return}ia.useSystemLocale()}}reconcileCommittedServerUiPrefs(e,t,n=!1){if(this.host.context?.runtimeConfig===e){if(t){e.refresh();return}this.reconcileServerUiPrefs(e),n&&this.host.context?.theme.refresh()}}handleGatewayEvent(e){if(e.event===`sessions.changed`){let e=this.host.context;e&&this.host.recoverDeletedActiveSession(e.sessions.state);return}if(e.event===`session.observer`){let t=this.host.context;if(t){this.host.criticalNoticeRuntime??=R(()=>import(`./critical-observer-notice.runtime-CRMUtUuZ.js`),__vite__mapDeps([86,2,3,4,5,6,7,8,1,9,10,11,12,13,14,15,16]),import.meta.url);let n=e.payload;this.host.criticalNoticeRuntime.then(e=>e.handleCriticalObserverDigest({payload:n,selectedSessionKey:this.host.activeSessionKey,sessionHost:this.host.storedOutboxScopeHost(t),sessions:t.sessions.state.result?.sessions??[],onOpen:(e,t)=>this.host.selectChatSession(e,t)}))}return}if(e.event===`config.changed`){let e=this.host.context?.runtimeConfig;e&&!e.state.configFormDirty&&e.refresh(),this.scheduleAgentRosterRefresh();return}if(e.event===`users.prefs.changed`){let t=this.host.context,n=t?.gateway.snapshot.selfUser?.id,r=e.payload;t&&n&&r&&typeof r==`object`&&`profileId`in r&&r.profileId===n&&this.refreshProfileAppearancePrefs(t,!0).catch(()=>void 0);return}if(e.event!==`ui.command`||!e.payload)return;let t=this.host.context;if(!t)return;let n=e.payload,{command:r}=n;if(r){if(r.kind===`sidebar`){this.host.desktopNavigationExpanded=!1,t.navigation.update({navCollapsed:!r.visible});return}if(r.kind===`panel`){window.dispatchEvent(new CustomEvent(r.panel===`terminal`?Ua:Qi,{detail:{open:r.open,...r.dock?{dock:r.dock}:{},...r.panel===`terminal`&&r.terminalSessionId?{terminalSessionId:r.terminalSessionId}:{}}}));return}window.dispatchEvent(new CustomEvent(`openclaw:ui-command`,{detail:n,cancelable:!0}))&&(r.kind===`navigate`||r.kind===`split`)&&this.host.selectChatSession(r.sessionKey)}}scheduleAgentRosterRefresh(){this.host.agentRosterRefreshTimer!==null&&globalThis.clearTimeout(this.host.agentRosterRefreshTimer),this.host.agentRosterRefreshTimer=globalThis.setTimeout(()=>{this.host.agentRosterRefreshTimer=null,this.refreshAgentRoster()},m_)}async refreshAgentRoster(){let e=this.host.context;if(!e)return;let t=e.agents.state.agentsList,n=e.agentSelection.state.selectedId,r=await e.agents.refreshList();if(!r||this.host.context!==e)return;let i=p_(t?.agents??[],r.agents);i.invalidatedIds.length>0&&(e.agents.invalidateFiles(i.invalidatedIds),e.agentIdentity.invalidate(i.invalidatedIds)),i.changedIds.length>0&&e.agentIdentity.ensure(i.changedIds);let a=new Set(r.agents.map(e=>e.id));n&&e.agentSelection.state.selectedId===n&&r.agents.length>0&&!a.has(n)&&e.agentSelection.set(r.defaultId)}synchronizeGateway(e){let t=this.host.previousGatewayPhase;this.host.previousGatewayPhase=e.phase,this.updateGatewaySessionKey(e);let n=this.host.context;if(e.phase===`connected`&&n){let t=n.connectionBootstrap;t.run(`runtime-config`,async()=>(await this.ensureRuntimeConfig(e,n.runtimeConfig),this.refreshProfileAppearancePrefs(n))),this.host.routeState.routeId&&!n.agents.state.agentsList&&t.run(`agents`,()=>this.ensureAgentsList(e,n.agents)),t.run(`outbox`,()=>this.host.outboxStoreImport.load())}t!==`connected`&&e.phase===`connected`&&ia.retryPendingLocale()}ensureRuntimeConfig(e,t=this.host.context?.runtimeConfig){if(e.phase!==`connected`||!e.client||!t)return this.host.runtimeConfigClient=null,this.runtimeConfigProfileId=null,this.profileAppearanceSource=null,Promise.resolve();let n=e.selfUser?.id??null;return this.host.runtimeConfigClient===e.client&&this.host.runtimeConfigSource===t&&this.runtimeConfigProfileId===n?Promise.resolve():(this.host.runtimeConfigClient=e.client,this.host.runtimeConfigSource=t,this.runtimeConfigProfileId=n,qg(t,{profileId:n,canWrite:rc(e.hello?.auth??null),afterCommit:({needsRefresh:e,retainedLocal:n})=>this.reconcileCommittedServerUiPrefs(t,e,n)}),t.ensureLoaded())}ensureAgentsList(e,t=this.host.context?.agents){if(e.phase!==`connected`||!e.client)return this.host.agentsListClient=null,Promise.resolve();let n=this.host.routeState.routeId;return!t||!n||t.state.agentsList||this.host.agentsListClient===e.client&&this.host.agentsListSource===t?Promise.resolve():(this.host.agentsListClient=e.client,this.host.agentsListSource=t,t.ensureList().then(()=>void 0))}updateGatewaySessionKey(e){let t=e.sessionKey.trim();(e.client!==this.host.sessionKeyClient||t!==this.host.activeSessionKey)&&(this.host.sessionKeyClient=e.client,t&&(this.host.activeSessionKey=t))}refreshProfileAppearancePrefs(e,t=!1){let n=e.gateway.snapshot,r=n?.selfUser?.id;if(!r)return Promise.resolve();let i=n.client,a=e.runtimeConfig.state.configSnapshot?.config;if(n.phase!==`connected`||!i||!a)return Promise.resolve();let o=this.profileAppearanceSource;if(!t&&o?.client===i&&o.profileId===r)return Promise.resolve();let s={client:i,profileId:r};this.profileAppearanceSource=s;let c=e.gateway.connection.gatewayUrl,l=()=>this.host.context===e&&e.gateway.snapshot.client===i&&e.gateway.snapshot.selfUser?.id===r&&this.profileAppearanceSource===s;return zg({client:i,profileId:r,configObject:a,scope:c,onApplied:()=>{l()&&e.theme.refresh()},onThemeChanged:t=>{l()&&e.theme.recordServerSelection(t,c)}}).then(t=>{!t&&l()&&e.theme.refresh()}).catch(e=>{l()&&console.error(`[gateway] profile appearance preference refresh failed:`,e)})}reset(){this.host.criticalNoticeRuntime?.then(e=>e.resetCriticalObserverTracker()),this.host.agentsListClient=null,this.host.agentsListSource=null,this.host.sessionKeyClient=null,this.host.runtimeConfigClient=null,this.host.runtimeConfigSource=null,this.runtimeConfigProfileId=null,this.profileAppearanceSource=null,this.host.previousGatewayPhase=null,this.host.agentRosterRefreshTimer!==null&&(globalThis.clearTimeout(this.host.agentRosterRefreshTimer),this.host.agentRosterRefreshTimer=null),Ig()}dispose(){this.host.lastLocalePrefSignature=null,this.reset()}}})))()}function __(e){try{return e??localStorage}catch{return null}}function v_(e,t=th()){let n=t?__(e):null;if(!n)return null;try{let e=n.getItem(C_);if(e===null)return null;let t=JSON.parse(e);if(typeof t.routeId==`string`&&$a(t.routeId)&&typeof t.pathname==`string`&&typeof t.search==`string`)return{routeId:t.routeId,pathname:t.pathname,search:t.search};n.removeItem(C_)}catch{try{n.removeItem(C_)}catch{}}return null}function y_(e){let t=new URLSearchParams(e);for(let e of w_)t.delete(e);let n=t.toString();return n?`?${n}`:``}function b_(e,t,n,r,i=th()){let a=i?__(r):null;if(a)try{a.setItem(C_,JSON.stringify({routeId:e,pathname:t,search:y_(n)}))}catch{}}function x_(e,t,n,r){return r&&e===`chat`&&t.endsWith(`/chat`)&&n===``}function S_(e,t,n,r,i=th()){if(!x_(e,t,n,i))return null;let a=v_(r,i);return!a||a.routeId===e&&a.pathname===t&&a.search===n?null:a}var C_,w_;function T_(){return(T_=e((()=>{yc(),ih(),C_=`openclaw.native.lastRoute`,w_=[`draft`]})))()}var E_;function D_(){return(D_=e((()=>{ws(),q(),yc(),at(),nt(),Fl(),T_(),E_=class{constructor(e){this.host=e}selectChatSession(e,t){let n=this.host.context;if(!n)return;Nl({selection:n.agentSelection,gateway:n.gateway,sessionKey:e,agentId:t});let r=En(n,e,t);this.navigate(r,Ln({context:n,face:r,sessionKey:e,...t?{agentId:t}:{},preferenceDerivedFace:!0}).options)}chatNavigationOptions(e,t){let n=this.host.activeSessionKey.trim(),r=this.host.context;return t??(n&&r?Ln({context:r,face:e,sessionKey:n}).options:void 0)}navigate(e,t){let n=this.host.context;!n||!$a(e)||(this.host.closeNavDrawer({restoreFocus:!0}),n.navigate(e,mo(e)?this.chatNavigationOptions(e,t):t))}replaceChatWithCurrentSession(){let e=this.host.context,t=this.host.activeSessionKey.trim();if(!e)return!0;if(!qt(t)&&e.gateway.snapshot.phase!==`connected`)return!1;let n=this.host.routeState.routeId===`dashboard`?`dashboard`:`chat`,r=e.sessions.deletionState(t),i=ji(e,t),a=this.host.routeState.location?.pathname,o=!a||a===Ln({context:e,face:n,sessionKey:t}).options.pathname,s=qt(t)?.agentId,c=e.agents.state.agentsList?.agents,l=s&&(!c||c.some(e=>v(e.id)===s))?s:An(e),u=!r&&(i?.key||!o)?t:wn({agentId:l,mainKey:Nn({agentsList:e.agents.state.agentsList,hello:e.gateway.snapshot.hello})});return r&&u===t?!0:(u!==t&&(this.host.activeSessionKey=u,Nl({selection:e.agentSelection,gateway:e.gateway,sessionKey:u})),e.replace(n,Ln({context:e,face:n,sessionKey:u}).options),!0)}recoverDeletedActiveSession(e){let t=this.host.context,n=this.host.routeState.routeId,r=this.host.activeSessionKey.trim();!t||!n||!mo(n)||!r||t.sessions.deletionState(r)&&this.replaceChatWithCurrentSession()}updateRouteState(e){this.host.routeState=e,e.routeId!==void 0&&(this.host.lastConcreteRouteId===`custodian`&&e.routeId!==`custodian`&&(this.host.custodianMinimizeRequestId+=1),this.host.lastConcreteRouteId=e.routeId);let t=e.committedRouteId,n=e.committedLocation?.pathname??``,r=e.committedLocation?.search??``,i=this.host.context;if(t&&i){let a=e.routeId!==t||(e.location?.pathname??``)!==n||(e.location?.search??``)!==r;if(!this.host.didConsiderNativeRouteRestore){this.host.didConsiderNativeRouteRestore=!0;let e=a?null:S_(t,n,r);if(e){i.replace(e.routeId,{pathname:e.pathname,search:e.search});return}}if(!a){let a=e.committedSessionKey;if(a!==void 0&&i.sessions.deletionState(a)){this.replaceChatWithCurrentSession();return}b_(t,n,r),a&&(this.host.activeSessionKey=a,Nl({selection:i.agentSelection,gateway:i.gateway,sessionKey:a}))}}let a=this.host.context;a&&this.host.ensureAgentsList(a.gateway.snapshot),e.routeId&&!ns(e.routeId)&&(this.host.settingsSearchQuery=``,this.host.lastWorkspaceLocation={routeId:e.routeId,pathname:e.location?.pathname??``,search:e.location?.search??``,hash:e.location?.hash??``})}newSessionRouteAgentId(){return this.host.routeState.routeId===`new-session`?new URLSearchParams(this.host.routeState.location?.search??``).get(`agent`)?.trim()??``:``}openNewSession(e,t){this.navigate(`new-session`,{search:nr(e,t)})}exitSettings(){let e=this.host.lastWorkspaceLocation;if(e){let{routeId:t,...n}=e;this.navigate(t,n);return}this.navigate(`chat`)}}})))()}function O_(e){let t=K(`palette.placeholder`);return H`<openclaw-modal-dialog
class="cmd-palette-overlay palette"
label=${t}
style="--openclaw-modal-width: min(640px, calc(100vw - 32px));"
@modal-cancel=${e}
>
<div class="cmd-palette" role="status" aria-label=${K(`common.loading`)}>
<input class="cmd-palette__input" disabled placeholder=${t} />
<div class="cmd-palette__empty">${K(`common.loading`)}</div>
</div>
</openclaw-modal-dialog>`}function k_(){return(k_=e((()=>{Ii(),G()})))()}function A_(e){return[{available:e.homeAvailable,kind:`home`,label:K(`assistantPanel.toggle`),tooltip:`${K(`assistantPanel.toggle`)} (${Vn(V.homePanel)})`,event:Yi,icon:ma.home},{available:e.custodianAvailable,kind:`custodian`,label:K(`nav.askOpenClaw`),tooltip:K(`nav.askOpenClaw`),event:$i,icon:ma.lobster}].map(e=>e.available?H`<openclaw-tooltip .content=${e.tooltip}>
<button
type="button"
class="shell-chrome-controls__button shell-chrome-controls__${e.kind}"
aria-label=${e.label}
@click=${()=>window.dispatchEvent(new CustomEvent(e.event))}
>
${e.icon}
</button>
</openclaw-tooltip>`:W)}function j_(){return(j_=e((()=>{Ii(),Ki(),da(),G(),fn()})))()}function M_(e){return t=>{let n=()=>{let n=e.overlays.snapshot,r=n.updateStatusBanner;t({run:n.updateRun,busy:n.updateRunning||n.updateReconciliationPending,connected:e.gateway.snapshot.phase===`connected`,failure:r&&r.tone!==`info`?r.text:null})},r=e.overlays.subscribe(n),i=e.gateway.subscribe(n);return n(),()=>{r(),i()}}}async function N_(e){let{confirmAndStartUpdateRuntime:t}=await R(async()=>{let{confirmAndStartUpdateRuntime:e}=await import(`./update-confirmation.runtime-CS0ySheH.js`);return{confirmAndStartUpdateRuntime:e}},__vite__mapDeps([87,2,5,3,4,6,7,8,77,88,89,90,91]),import.meta.url);await t(e)}function P_(){return(P_=e((()=>{I()})))()}function F_(e,t){if(!t.open)return W;let n=e.devicePairSetupRenderer;if(n)return n(t);let r=e.devicePairSetupLoadFailed;r||e.loadDevicePairSetupRenderer();let i=K(`devices.pairing.title`),a=K(r?`devices.pairing.loadFailed`:`common.loading`);return H`<openclaw-modal-dialog
label=${i}
description=${a}
@modal-cancel=${t.onClose}
>
<section class="device-pair-setup" aria-busy=${r?W:`true`}>
<header class="device-pair-setup__header">
<div>
<h2>${i}</h2>
<p role=${r?W:`status`}>${a}</p>
</div>
</header>
<footer class="device-pair-setup__footer">
${r?H`<button
class="btn btn--primary"
type="button"
@click=${()=>e.retryDevicePairSetupRenderer()}
>
${K(`common.retry`)}
</button>`:W}
<button class="btn btn--ghost" type="button" @click=${t.onClose}>
${K(`common.close`)}
</button>
</footer>
</section>
</openclaw-modal-dialog>`}function I_(e){let t=e.context,n=e.runtime;if(!t||!n)return W;if(e.routeState.routeId===void 0)return H`<main class="connect-splash" role="status" aria-label=${K(`common.loading`)}>
<openclaw-mascot mood="thinking" .size=${120}></openclaw-mascot>
</main>`;let r=t.gateway.snapshot,i=t.config.current,a=r.phase===`connected`,o=J(r),s=Ka(r,`update.run`,`operator.admin`),c=s&&Ka(r,`update.hold`,`operator.admin`),l=e.storedOutboxScopeHost(t),u=e.outboxStoreRuntime?.summarizeStoredChatOutboxes(l),d=t.navigation.snapshot,f=t.overlays.snapshot,p=f.controlUiRefreshRequired,m=f.updateRunning||f.updateReconciliationPending,h=M_(t),g=_n(r,i.terminalEnabled??!1),_=Mm(r),y=Nm(r),b=Pm(t.gateway),x=Ka(r,`openclaw.chat`,`operator.admin`),S=e.lazyCustomElements.visibleState,C=e.routeState.routeId??`chat`,w=mo(C),T=r.phase===`reload-required`,E=!T&&!a&&!w&&C!==`new-session`&&C!==`appearance`,ee=C===`plugin`?Qn(e.routeState.location?.search??``):null,D=ee?kr(ee):``,O=ns(C)&&!e.onboardingMode,k=t.runtimeConfig.state,A=e.onboardingMode,j=A&&C!==`custodian`;e.lazyCustomElements.requestWhileActive(e.onboardingMemoryImportElement,j);let M=e.navDrawerOpen&&!A,N=xh(),te=th();te&&!A&&e.lazyCustomElements.preload(hl,{reportError:!0});let ne=Ch({mobileNavLayout:N,routeId:C,onboarding:A}),P=d.navCollapsed&&!e.desktopNavigationExpanded&&!M&&!O,re=Lh({onboarding:A,navCollapsed:P,navDrawerOpen:M,mobileNavLayout:N}),ie=Rh({navigationSurfaceHidden:re,mobileNavLayout:N,onboarding:A,compact:ne});(A||ie)&&e.lazyCustomElements.preload(gl,{reportError:!0});let ae=Math.max(globalThis.innerWidth||0,400),oe=e.newSessionRouteAgentId(),se=oe?v(oe):null,ce=se!==null&&t.agents.state.agentsList?.agents.some(e=>v(e.id)===se)===!0?se:v(t.agentSelection.state.selectedId??r.assistantAgentId),le=pi(r,{method:`sessions.create`,params:{}}),ue=(n,r)=>{pi(t.gateway.snapshot,{method:`sessions.create`,params:{}}).allowed&&e.openNewSession(n,r)},F=t.theme.settings,de=w||C===`new-session`;O||Object.assign(e.navigationSidebar,{basePath:t.basePath,activeRouteId:C,activePluginTabId:D,enabledRouteIds:e.enabledRouteIds(),sessionKey:e.activeSessionKey,connected:a,offline:r.offlineStable,restartPending:r.restartPending===!0,suspensionPhase:r.suspensionPhase,queuedOutboxCount:u?.total??0,lastError:r.lastError,outboxAttentionCountForSession:u?.attentionCountForSession??(()=>0),hasSessionDraft:u?.hasSessionDraft??L_,terminalAvailable:g,catalogOpenTarget:Yd(F.catalogOpenTarget),canPairDevice:a&&(o.canAdmin||o.canPair),preferencesBrowserOnly:a&&t.runtimeConfig.canPatch===!1,sidebarEntries:d.sidebarEntries,sidebarLiveActivity:F.sidebarLiveActivity!==!1,pinnedAgentIds:d.pinnedAgentIds,themeMode:t.theme.mode,lobsterPetVisits:F.lobsterPetVisits!==!1,lobsterPetSounds:F.lobsterPetSounds===!0,gatewayVersion:i.serverVersion??r.hello?.server?.version??null,devGitBranch:i.devGitBranch,watchUpdateProgress:h,onOpenApprovals:()=>e.openApprovals(),onOpenPalette:()=>e.openPalette(),onRetryConnect:()=>t.gateway.connect(),onToggleSidebar:()=>e.toggleNavigationSurface(),onOpenNewSession:ue,onUpdateSidebarEntries:e=>t.navigation.update({sidebarEntries:e}),onPairMobile:()=>void t.overlays.openDevicePairSetup(),onNavigate:(t,n)=>e.navigate(t,n),onPreloadRoute:e=>$a(e)?t.preload(e):Promise.resolve()});let fe=O?ka(e,{basePath:t.basePath,activeRouteId:C,activePathname:e.routeState.location?.pathname??``,activeSearch:e.routeState.location?.search??``,activeHash:e.routeState.location?.hash??``,offline:r.offlineStable,restartPending:r.restartPending,suspensionPhase:r.suspensionPhase,queuedOutboxCount:u?.total??0,lastError:r.lastError,gatewayVersion:i.serverVersion??r.hello?.server?.version??``,updateAvailable:re?null:f.updateAvailable,updateSchedule:re?null:f.updateSchedule,heldUpdateCampaignId:f.heldUpdateCampaignId,updateBusy:m,updateStatusBanner:f.updateStatusBanner,watchUpdateProgress:h,canUpdate:s,canHoldUpdate:c,onUpdate:()=>void t.overlays.runUpdate(),refreshRequired:!re&&p,onRefresh:e.refreshControlUi,onHoldUpdate:()=>t.overlays.holdUpdate(),onReviewUpdate:()=>e.navigate(`updates`),searchQuery:e.settingsSearchQuery,searchParams:{query:e.settingsSearchQuery,schema:k.configSchema,value:k.configForm??k.configSnapshot?.config??null,uiHints:k.configUiHints,identityAvailable:!!r.selfUser,basePath:t.basePath,canAdmin:o.canAdmin,nativeDeviceSettings:t.nativeDeviceSettings},onExit:()=>e.exitSettings(),onRetryConnect:()=>t.gateway.connect(),onNavigate:(t,n)=>e.navigate(t,n),onOpenApprovals:()=>e.openApprovals(),onPreload:e=>t.preload(e),onSearchQueryChange:t=>{e.handleSettingsSearchQueryChange(t)},preloadTimers:e.settingsPreloadTimers,saveIndicator:{status:k.configAutoSaveStatus,lastError:k.lastError,needsApply:k.configNeedsApply,applying:k.configApplying,applyDisabled:t.runtimeConfig.canApply===!1||k.configLoading||k.configSaving||k.configFormDirty&&k.configFormMode===`raw`||m,onRetry:()=>void t.runtimeConfig.save(),onReload:()=>void t.runtimeConfig.discardDraft(),onApply:()=>void t.runtimeConfig.apply()},canAdmin:o.canAdmin,nativeDeviceSettings:t.nativeDeviceSettings}):e.navigationSidebar,pe=H`
${S?.status===`loading`&&S.element===e.commandPaletteElement?O_(()=>e.lazyCustomElements.close()):Ta(e.lazyCustomElements)}
${Y(e.commandPaletteElement)?H`<openclaw-command-palette
.desktopAvailable=${y}
.custodianAvailable=${x}
.onNavigate=${(t,n)=>e.navigate(t,n)}
.onSelectSession=${t=>e.selectChatSession(t)}
.onSlashCommand=${t=>e.handleCommandPaletteSlashCommand(t)}
></openclaw-command-palette>`:W}
${Y(dl)?H`<openclaw-debug-overlay></openclaw-debug-overlay>`:W}
${Y(pl)?H`<openclaw-keyboard-shortcuts-dialog
.sendShortcut=${Gd(F.chatSendShortcut)}
></openclaw-keyboard-shortcuts-dialog>`:W}
<div
class="shell ${de?`shell--chat`:``} ${P?`shell--nav-collapsed`:``} ${N?`shell--mobile-nav`:``} ${ne?`shell--merged-chat-chrome`:``} ${M?`shell--nav-drawer-open`:``} ${A?`shell--onboarding`:``} ${O?`shell--settings`:``}"
style=${`--shell-nav-expanded-width: ${d.navWidth}px`}
@theme-change=${t=>e.handleThemeChange(t)}
>
<a class="shell-skip-link" href="#control-ui-main" ?inert=${M}>
${K(`common.skipToMainContent`)}
</a>
${te&&!A?H`
<openclaw-macos-titlebar-controls
?inert=${M}
.navCollapsed=${e.nativeNavCollapsed()}
.historyOnly=${O}
.canGoBack=${e.nativeHistoryState.canGoBack}
.canGoForward=${e.nativeHistoryState.canGoForward}
.newSessionDisabledReason=${le.allowed?void 0:le.reason}
.onToggleSidebar=${()=>e.toggleNavigationSurface()}
.onOpenPalette=${()=>e.openPalette()}
.onOpenNewSession=${()=>e.handleNativeNewSession()}
></openclaw-macos-titlebar-controls>
`:W}
<openclaw-app-topbar
?inert=${M}
.resourceBasePath=${t.resourceBasePath}
.environment=${i.environment}
.navDrawerOpen=${M}
.onOpenPalette=${()=>e.openPalette()}
.onToggleDrawer=${t=>e.toggleNavigationSurface(t)}
></openclaw-app-topbar>
${P&&!A&&!O&&!N?H`
<div class="shell-chrome-controls">
<openclaw-tooltip
.content=${`${K(`nav.expand`)} (${Vn(V.toggleSidebar)})`}
>
<button
type="button"
class="shell-chrome-controls__button shell-chrome-controls__nav-toggle"
aria-label=${K(`nav.expand`)}
aria-expanded="false"
data-env-avatar=${i.environment?i.assistantIdentity.name.charAt(0):W}
@click=${()=>e.toggleNavigationSurface()}
>
${ma.panelLeftOpen}
</button>
</openclaw-tooltip>
${Ca({basePath:t.basePath,agentId:ce,className:`shell-chrome-controls__button shell-chrome-controls__new-thread`,label:K(`chat.runControls.newSession`),disabledReason:le.allowed?void 0:le.reason,onOpen:ue})}
<openclaw-tooltip
.content=${`${K(`chat.openCommandPalette`)} (${Vn(V.commandPalette)})`}
>
<button
type="button"
class="shell-chrome-controls__button shell-chrome-controls__search"
aria-label=${K(`chat.openCommandPalette`)}
@click=${()=>e.openPalette()}
>
${ma.search}
</button>
</openclaw-tooltip>
${A_({homeAvailable:b,custodianAvailable:x})}
</div>
`:W}
<button
type="button"
class="shell-nav-backdrop"
tabindex="-1"
aria-hidden="true"
?inert=${!M}
@click=${()=>e.closeNavDrawer({restoreFocus:!0})}
></button>
<div
class="shell-nav ${N?`nav-drawer`:``}"
role=${N?`dialog`:W}
aria-modal=${N&&M?`true`:W}
aria-label=${N?K(`palette.categories.navigation`):W}
aria-hidden=${N&&re?`true`:W}
tabindex=${N?-1:W}
?inert=${re}
>
${fe}
</div>
${!P&&!A&&!O?H`
<resizable-divider
class="sidebar-resizer"
.label=${K(`nav.resize`)}
.splitRatio=${d.navWidth/ae}
.minRatio=${240/ae}
.maxRatio=${400/ae}
aria-valuetext=${`${d.navWidth} pixels`}
title=${K(`nav.resize`)}
@resize=${t=>e.resizeNavigation(t.detail.splitRatio)}
></resizable-divider>
`:W}
<main
id="control-ui-main"
class="content ${de?`content--chat`:``} ${C===`custodian`?`content--custodian`:``} ${C===`workboard`?`content--workboard`:``}"
.tabIndex=${-1}
?inert=${E||N&&M}
>
${E?H`<div class="connection-action-block" role="status" aria-live="polite">
<span class="connection-action-block__icon" aria-hidden="true"
>${ma.globeOff}</span
>
<span class="connection-action-block__text">
${K(O?`connection.settingsChangesUnavailable`:`connection.actionsUnavailable`)}
</span>
</div>`:W}
${zh({navigationSurfaceHidden:re,mobileNavLayout:N,onboarding:A,compact:ne&&!p,updateAvailable:f.updateAvailable,updateSchedule:f.updateSchedule,heldUpdateCampaignId:f.heldUpdateCampaignId,updateBusy:m,statusBanner:f.updateStatusBanner,updateRun:f.updateRun,updateRunAcknowledged:f.updateRunAcknowledged,connected:a,onAcknowledge:()=>t.overlays.acknowledgeUpdateRun(),onCheckStatus:()=>t.overlays.refreshUpdateStatus(),watchUpdateProgress:h,canUpdate:s,canHoldUpdate:c,onUpdate:()=>void t.overlays.runUpdate(),refreshRequired:p,onRefresh:e.refreshControlUi,onHoldUpdate:()=>t.overlays.holdUpdate(),onReviewUpdate:()=>e.navigate(`updates`),onNavigate:t=>e.navigate(t),onOpenApprovals:()=>e.openApprovals()})}
<openclaw-router-outlet
?inert=${E||T}
aria-disabled=${E||T?`true`:W}
.router=${n.router}
.retryContext=${t}
.onNotFound=${()=>e.replaceChatWithCurrentSession()}
.notFoundRecoveryReady=${a}
></openclaw-router-outlet>
</main>
<openclaw-terminal-panel
?inert=${M}
.client=${a?r.client:null}
.available=${g}
.agentId=${ce}
.sessionKey=${w?e.activeSessionKey:null}
.suppressed=${O}
.themeMode=${t.theme.resolvedMode}
.basePath=${t.basePath}
></openclaw-terminal-panel>
${w?W:H`
<openclaw-browser-panel
?inert=${M}
data-chat-autotype-exempt
.client=${a?r.client:null}
.available=${_}
.suppressed=${O}
.resourceBasePath=${t.resourceBasePath}
.authToken=${hf({hello:r.hello,settings:{token:t.gateway.connection.token},password:t.gateway.connection.password})}
></openclaw-browser-panel>
<openclaw-desktop-panel
?inert=${M}
data-chat-autotype-exempt
.client=${a?r.client:null}
.available=${y}
.suppressed=${O}
.basePath=${t.basePath}
></openclaw-desktop-panel>
`}
<openclaw-assistant-panel
?inert=${M}
.custodianAvailable=${x}
.homeAvailable=${b}
.custodianSuppressed=${C===`custodian`}
.pageSessionKey=${e.activeSessionKey}
.pageAgentId=${ce}
.pageRouteId=${C}
.pageRouteFailed=${e.routeState.routeFailed===!0}
.minimizeRequestId=${e.custodianMinimizeRequestId}
></openclaw-assistant-panel>
${Y(e.execApprovalElement)?H`<openclaw-exec-approval
.props=${{queue:f.approvalQueue,busy:f.approvalBusy,canGrant:f.approvalCanGrant,errors:f.approvalErrors,onDecision:(e,n)=>t.overlays.decideApproval(n,e)}}
></openclaw-exec-approval>`:W}
${F_(e,{open:f.devicePairSetupOpen,lifecycle:f.devicePairSetupLifecycle,nowMs:Date.now(),pendingCount:f.devicePairPendingCount,onRefresh:()=>void t.overlays.refreshDevicePairSetup(),onAccessChange:e=>void t.overlays.setDevicePairSetupAccess(e),onClose:()=>t.overlays.closeDevicePairSetup(),onManageDevices:()=>{t.overlays.closeDevicePairSetup(),e.navigate(`devices`)},onGetApps:()=>{t.overlays.closeDevicePairSetup(),e.navigate(`apps`)}})}
${j&&Y(e.onboardingMemoryImportElement)?H`<openclaw-onboarding-memory-import
.active=${!0}
.context=${t}
></openclaw-onboarding-memory-import>`:W}
<openclaw-toast-host></openclaw-toast-host>
</div>
`;return H`${Or(`workspace`,{sessionKey:e.activeSessionKey,agentId:ai({assistantAgentId:t.agentSelection.state.selectedId??r.assistantAgentId,agentsList:t.agents.state.agentsList,hello:r.hello},e.activeSessionKey),routeId:C},pe)}<openclaw-plugin-manager></openclaw-plugin-manager>`}var L_;function R_(){return(R_=e((()=>{Ii(),ws(),Zn(),q(),yc(),Ki(),ta(),Ma(),Fa(),G(),qa(),fn(),dr(),nt(),Wt(),Gr(),Wr(),k_(),_f(),Ol(),Oh(),ih(),Vh(),cc(),Im(),tf(),j_(),P_(),L_=()=>!1})))()}function z_(e){try{window.webkit?.messageHandlers?.openclawNav?.postMessage({type:`nav-state`,...e})}catch{}}function B_(e,t){return e.routeId===t.routeId&&e.location?.pathname===t.location?.pathname&&e.location?.search===t.location?.search&&e.location?.hash===t.location?.hash&&e.committedRouteId===t.committedRouteId&&e.committedLocation?.pathname===t.committedLocation?.pathname&&e.committedLocation?.search===t.committedLocation?.search&&e.committedLocation?.hash===t.committedLocation?.hash&&e.committedSessionKey===t.committedSessionKey}var V_,H_,$;function U_(){return(U_=e((()=>{Fi(),Wa(),aa(),ws(),Xi(),q(),yc(),G(),Qr(),ri(),jn(),bt(),nt(),Yr(),bn(),ot(),al(),lh(),Gh(),g_(),D_(),R_(),au(),Ol(),ih(),f_(),tf(),Jc(),I(),V_=`openclaw-app-sidebar`,H_={tagName:V_,label:V_,loadModule:()=>R(()=>import(`./app-sidebar-DxM9SlaJ.js`),__vite__mapDeps([92,4,2,3,5,6,7,8,13,9,10,11,12,1,14,15,16]),import.meta.url)},ia.setLocaleLoadRecovery({isUnrecoverableError:Ac,onUnrecoverableLocaleLoad:()=>{Pc()}}),$=class extends er{loadSettingsSidebarRenderer(){this.settingsSidebarRuntime??=R(()=>import(`./settings-sidebar-UFxCOjch.js`).then(e=>{this.settingsSidebarRenderer=e.renderSettingsSidebar,this.settingsSidebarLoadFailed=!1}),__vite__mapDeps([93,2,3,4,5,6,7,8,13,9,10,11,12,1,14,15,16,78,94,95,96,97]),import.meta.url).catch(()=>{this.settingsSidebarLoadFailed=!0,this.settingsSidebarRuntime=null})}retrySettingsSidebarRenderer(){this.settingsSidebarLoadFailed=!1,this.loadSettingsSidebarRenderer()}loadSidebarUpdateCard(){this.sidebarUpdateCardImport.load().catch(e=>{Ac(e)&&Pc()})}loadDevicePairSetupRenderer(){this.devicePairSetupRuntime??=R(()=>import(`./view-pairing.runtime-lXzSgb_-.js`).then(e=>{this.devicePairSetupRenderer=e.renderDevicePairSetup,this.devicePairSetupLoadFailed=!1}),__vite__mapDeps([98,2,4,3,5,6,7,8,13,9,10,11,12,1,14,15,16]),import.meta.url).catch(()=>{this.devicePairSetupLoadFailed=!0,this.devicePairSetupRuntime=null})}retryDevicePairSetupRenderer(){this.devicePairSetupLoadFailed=!1,this.loadDevicePairSetupRenderer()}get context(){return this.runtime?.context}get onboardingMode(){let e=this.routeState.location?.search;return e===void 0?this.onboarding:Ts(e)}get workspaceChromeVisible(){let e=this.routeState.routeId;return e!==void 0&&!ns(e)&&!this.onboardingMode}storedOutboxScopeHost(e){let t=e.gateway.snapshot;return{settings:{gatewayUrl:e.gateway.connection.gatewayUrl},assistantAgentId:t.assistantAgentId,agentsList:e.agents.state.agentsList,hello:t.hello}}chatTitleContext(e,t){let n=this.activeSessionKey,r=qt(n),i=rn(n)?Dt(t):r?.rest===Nn(t)?v(r.agentId):void 0,a=i?e.agents.state.agentsList?.agents.find(e=>v(e.id)===i):void 0;return a?or(a):Ai(n,e.sessions.state.result?.sessions.find(e=>e.key===n))}constructor(){super(),this.onboarding=!1,this.navDrawerOpen=!1,this.desktopNavigationExpanded=!1,this.activeSessionKey=``,this.settingsSearchQuery=``,this.routeState={},this.nativeHistoryState=nh(),this.commandPaletteElement=ll,this.terminalPanelElement=_l,this.browserPanelElement=vl,this.desktopPanelElement=yl,this.assistantPanelElement=xl,this.execApprovalElement=El,this.onboardingMemoryImportElement={tagName:`openclaw-onboarding-memory-import`,label:K(`onboarding.memoryImport.title`),loadModule:()=>R(()=>import(`./onboarding-memory-import-CFKfZGFP.js`),__vite__mapDeps([99,2,3,4,5,6,7,8,9,10,11,12,100]),import.meta.url)},this.lazyCustomElements=new cl(this,()=>this.shellChrome.cancelPendingLazyAction(),e=>this.shellChrome.retryPendingLazyAction(e)),this.queryRenderedElement=e=>this.renderRoot?.querySelector(e)??null,this.navDrawerTrigger=null,this.navigationSidebar=document.createElement(V_),this.lastWorkspaceLocation=null,this.custodianMinimizeRequestId=0,this.agentsListClient=null,this.agentsListSource=null,this.sessionKeyClient=null,this.runtimeConfigClient=null,this.runtimeConfigSource=null,this.lastLocalePrefSignature=null,this.previousGatewayPhase=null,this.agentRosterRefreshTimer=null,this.outboxStoreRuntime=null,this.outboxStoreUnsubscribe=null,this.lastDeletedSessions=null,this.outboxStoreImport=Rn(()=>R(()=>import(`./outbox-store-projection-BFrl_eSc.js`).then(e=>e),__vite__mapDeps([101,13,2,3,4,5,6,7,8,9,10,11,12,1,14,15,16]),import.meta.url),e=>this.installOutboxStoreRuntime(e)),this.didConsiderNativeRouteRestore=!1,this.pendingNativeNewSession=!1,this.settingsPreloadTimers=new Map,this.settingsSidebarRenderer=null,this.settingsSidebarLoadFailed=!1,this.settingsSidebarRuntime=null,this.sidebarUpdateCardImport=Rn(()=>R(()=>import(`./sidebar-update-card-C9_fyhkz.js`),__vite__mapDeps([102,6,2,3,4,5,7,8,103,13,9,10,11,12,1,14,15,16,89,104]),import.meta.url)),this.criticalNoticeRuntime=null,this.devicePairSetupRenderer=null,this.devicePairSetupLoadFailed=!1,this.devicePairSetupRuntime=null,this.subscriptions=new Mi(this),this.shellNavigation=new E_(this),this.shellChrome=new Wh(this),this.shellGateway=new h_(this),this.handleGatewayEvent=e=>{if(e.event===`config.changed`||e.event===`chat.metadata.changed`){let e=this.context?.gateway?.snapshot.client;e&&(Ot(e),Lt(e))}this.shellGateway.handleGatewayEvent(e)},this.handleThemeChange=e=>{let t=this.context;t&&t.theme.setMode(e.detail.mode,e.detail.element)},this.toggleNavigationSurface=this.shellChrome.toggleNavigationSurface,this.closeNavDrawer=this.shellChrome.closeNavDrawer,this.resizeNavigation=this.shellChrome.resizeNavigation,this.handleNativeToggleSidebar=this.shellChrome.handleNativeToggleSidebar,this.handleNativeOpenSearch=this.shellChrome.handleNativeOpenSearch,this.handleNativeToggleSearch=this.shellChrome.handleNativeToggleSearch,this.handleNativeNewSession=this.shellChrome.handleNativeNewSession,this.handleNativeNavigate=this.shellChrome.handleNativeNavigate,this.handleNativeHistoryState=this.shellChrome.handleNativeHistoryState,this.handleWindowResize=this.shellChrome.handleWindowResize,this.handleDocumentKeydown=this.shellChrome.handleDocumentKeydown,this.openPalette=this.shellChrome.openPalette,this.refreshControlUi=()=>Ic({timeoutMs:0,canReload:()=>this.context?.overlays.snapshot.controlUiRefreshRequired===!0}),this.handleShellNavDrawerToggle=this.shellChrome.handleShellNavDrawerToggle,this.openApprovals=this.shellChrome.openApprovals,this.handleCommandPaletteSlashCommand=this.shellChrome.handleCommandPaletteSlashCommand,this.restorePendingLazyAction=this.shellChrome.restorePendingLazyAction,this.nativeNavCollapsed=this.shellChrome.nativeNavCollapsed,this.subscriptions.effect(()=>this.context,e=>(this.pendingNativeNewSession&&(this.pendingNativeNewSession=!1,this.handleNativeNewSession()),()=>{this.context!==e&&this.resetForContextEpoch()})).watch(()=>this.context?.nativeDeviceSettings,(e,t)=>e.subscribe(t)).watch(()=>this.context?.navigation,(e,t)=>e.subscribe(t)).watch(()=>this.context?.plugins,(e,t)=>e.subscribe(t)).watch(()=>this.context?.agentSelection,(e,t)=>e.subscribe(t)).watch(()=>this.context?.gateway,(e,t)=>e.subscribe(t),e=>this.synchronizeGateway(e.snapshot)).effect(()=>this.context?.gateway,e=>e.subscribeEvents(this.handleGatewayEvent)).watch(()=>this.context?.config,(e,t)=>e.subscribe(t)).watch(()=>this.context?.theme,(e,t)=>e.subscribe(t)).watch(()=>this.context?.agents,(e,t)=>e.subscribe(t),e=>{let t=this.context?.gateway.snapshot;t&&this.ensureAgentsList(t,e)}).effect(()=>this.runtime?.router,e=>(this.updateRouteState(il(e.getState())),e.subscribeSelector(il,e=>this.updateRouteState(e),B_))).watch(()=>this.context?.overlays,(e,t)=>e.subscribe(t)).watch(()=>this.context?.sessions,(e,t)=>e.subscribe(t),e=>{this.observeDeletedSessions(e.state),this.recoverDeletedActiveSession(e.state)}).watch(()=>this.context?.runtimeConfig,(e,t)=>e.subscribe(()=>{this.reconcileServerUiPrefs(e),t()}),e=>{let t=this.context?.gateway.snapshot;t&&this.ensureRuntimeConfig(t,e),this.reconcileServerUiPrefs(e)})}reconcileServerUiPrefs(e){this.shellGateway.reconcileServerUiPrefs(e)}reconcileCommittedServerUiPrefs(e,t,n=!1){this.shellGateway.reconcileCommittedServerUiPrefs(e,t,n)}connectedCallback(){super.connectedCallback(),this.outboxStoreRuntime&&this.installOutboxStoreRuntime(this.outboxStoreRuntime),this.outboxStoreImport.schedule(),this.shellChrome.connect(),Td((e,t)=>{if(Bg())return;let n=Eg(e,t),r=this.context?.runtimeConfig;n&&r&&Kg(r,n,{profile:this.context?.gateway.snapshot,afterCommit:({needsRefresh:e,retainedLocal:t})=>this.reconcileCommittedServerUiPrefs(r,e,t)})})}disconnectedCallback(){this.shellChrome.disconnect(),$l(),this.outboxStoreImport.dispose(),this.sidebarUpdateCardImport.dispose(),this.outboxStoreUnsubscribe?.(),this.outboxStoreUnsubscribe=null,this.lastLocalePrefSignature=null,Td(null),this.resetForDocumentDisconnect(),super.disconnectedCallback()}installOutboxStoreRuntime(e){this.outboxStoreRuntime=e,this.isConnected&&(this.outboxStoreUnsubscribe?.(),this.outboxStoreUnsubscribe=e.subscribeStoredChatOutboxChanges(()=>this.requestUpdate()),this.requestUpdate())}resetForContextEpoch(){this.shellChrome.abandonPendingLazyActionForContext(),this.resetShellState()}resetForDocumentDisconnect(){this.shellChrome.preservePendingLazyActionForReload(),this.resetShellState()}resetShellState(){this.navDrawerOpen=!1,this.desktopNavigationExpanded=!1,this.navDrawerTrigger=null,this.lastWorkspaceLocation=null,this.activeSessionKey=``,this.settingsSearchQuery=``,this.commandPaletteTarget=void 0,this.lastDeletedSessions=null,this.shellGateway.reset();for(let e of this.settingsPreloadTimers.values())globalThis.clearTimeout(e);this.settingsPreloadTimers.clear()}selectChatSession(e,t){this.shellNavigation.selectChatSession(e,t)}async handleSettingsSearchQueryChange(e){this.settingsSearchQuery=e;let t=this.context?.runtimeConfig;if(!(!t||!e.trim()))try{await t.ensureLoaded(),this.context?.runtimeConfig===t&&await t.ensureSchemaLoaded()}catch{}}chatNavigationOptions(e,t){return this.shellNavigation.chatNavigationOptions(e,t)}navigate(e,t){this.shellNavigation.navigate(e,t)}replaceChatWithCurrentSession(){return this.shellNavigation.replaceChatWithCurrentSession()}recoverDeletedActiveSession(e){this.shellNavigation.recoverDeletedActiveSession(e)}observeDeletedSessions(e){let t=this.context,n=e.deletedSessions;!t||Object.is(n,this.lastDeletedSessions)||(this.lastDeletedSessions=n,n.length!==0&&R(async()=>{let{retireDeletedComposerDrafts:e}=await import(`./composer-draft-retirement.runtime-vhT3sNK4.js`);return{retireDeletedComposerDrafts:e}},__vite__mapDeps([105,2,3,4,5,6,7,8,13,9,10,11,12,1,14,15,16]),import.meta.url).then(({retireDeletedComposerDrafts:e})=>e(t,n),()=>ui({message:K(`sessionsView.draftCleanupFailed`)})))}exitSettings(){this.shellNavigation.exitSettings()}openNewSession(e,t){this.shellNavigation.openNewSession(e,t)}syncDocumentTitle(){let e=this.routeState.routeId,t=this.context;if(!e||!t)return;let n=this.storedOutboxScopeHost(t),r=e===`custodian`?K(`nav.askOpenClaw`):ss(e);mo(e)&&this.activeSessionKey&&(r=this.chatTitleContext(t,n)||r);let i=t.gateway.snapshot.phase!==`connected`,a=cs({context:r,attentionCount:t.overlays.snapshot.approvalQueue.length,gatewayDisconnected:i,...i&&{queuedCount:this.outboxStoreRuntime?.summarizeStoredChatOutboxes(n).total}}),o=t.config?.current.environment;o&&(a+=` · ${o.label}`),document.title!==a&&(document.title=a)}updated(e){this.syncDocumentTitle(),(e.has(`routeState`)||e.has(`runtime`))&&$l(),this.restorePendingLazyAction(),!customElements.get(`openclaw-sidebar-update-card`)&&this.querySelector(`openclaw-sidebar-update-card`)&&this.loadSidebarUpdateCard();let t=this.querySelector(`openclaw-chat-page`);t&&(t.navDrawerOpen=this.navDrawerOpen&&!this.onboardingMode);let n=this.context;if(!n)return;this.workspaceChromeVisible&&this.shellChrome.panels.restore(),(n.overlays?.snapshot.approvalQueue.length??0)>0&&this.lazyCustomElements.preload(this.execApprovalElement),this.restorePendingLazyAction();let r={collapsed:this.nativeNavCollapsed(),width:n.navigation.snapshot.navWidth};(r.collapsed!==this.lastNativeNavState?.collapsed||r.width!==this.lastNativeNavState.width)&&(this.lastNativeNavState=r,z_(r))}synchronizeGateway(e){this.previousGatewayPhase===`connected`&&e.phase!==`connected`&&e.client&&(Ot(e.client),Lt(e.client)),this.shellGateway.synchronizeGateway(e)}ensureRuntimeConfig(e,t=this.context?.runtimeConfig){this.shellGateway.ensureRuntimeConfig(e,t).catch(()=>void 0)}enabledRouteIds(){return Ao}newSessionRouteAgentId(){return this.shellNavigation.newSessionRouteAgentId()}ensureAgentsList(e,t=this.context?.agents){this.shellGateway.ensureAgentsList(e,t).catch(()=>void 0)}updateRouteState(e){this.shellNavigation.updateRouteState(e)}render(){return this.workspaceChromeVisible&&this.lazyCustomElements.preload(H_),I_(this)}},B([Ri({attribute:!1})],$.prototype,`runtime`,void 0),B([Ri({attribute:!1})],$.prototype,`onboarding`,void 0),B([U()],$.prototype,`navDrawerOpen`,void 0),B([U()],$.prototype,`desktopNavigationExpanded`,void 0),B([U()],$.prototype,`activeSessionKey`,void 0),B([U()],$.prototype,`settingsSearchQuery`,void 0),B([U()],$.prototype,`routeState`,void 0),B([U()],$.prototype,`nativeHistoryState`,void 0),B([Li(`openclaw-command-palette`)],$.prototype,`commandPalette`,void 0),B([Li(`openclaw-exec-approval`)],$.prototype,`approvalOverlay`,void 0),B([U()],$.prototype,`settingsSidebarRenderer`,void 0),B([U()],$.prototype,`settingsSidebarLoadFailed`,void 0),B([U()],$.prototype,`devicePairSetupRenderer`,void 0),B([U()],$.prototype,`devicePairSetupLoadFailed`,void 0),customElements.get(`openclaw-app`)||customElements.define(`openclaw-app`,ch),customElements.get(`openclaw-app-shell`)||customElements.define(`openclaw-app-shell`,$)})))()}export{qd as $,so as $n,oc as $t,sp as A,us as An,Hl as At,_f as B,So as Bn,Y as Bt,Pm as C,Jo as Cn,lu as Ct,Cm as D,rs as Dn,Zl as Dt,wm as E,ls as En,au as Et,Pf as F,Wo as Fn,kl as Ft,rf as G,ao as Gn,Ic as Gt,gf as H,Eo as Hn,Rc as Ht,If as I,Bo as In,bl as It,tf as J,bo as Jn,kc as Jt,Id as K,io as Kn,Pc as Kt,Ff as L,Io as Ln,cl as Lt,lp as M,ts as Mn,Nl as Mt,ep as N,Vo as Nn,Ml as Nt,zp as O,$o as On,Ql as Ot,Lf as P,Ho as Pn,Al as Pt,Yd as Q,uo as Qn,sc as Qt,kf as R,No as Rn,ol as Rt,Nm as S,is as Sn,su as St,Sm as T,Yo as Tn,tu as Tt,hf as U,wo as Un,Lc as Ut,mf as V,To as Vn,Jc as Vt,af as W,Do as Wn,Ac as Wt,Dd as X,$a as Xn,mc as Xt,_d as Y,q as Yn,yc as Yt,Sd as Z,mo as Zn,ac as Zt,eh as _,ws as _n,Eu as _t,f_ as a,ec as an,vo as ar,Ed as at,Im as b,ns as bn,Su as bt,ig as c,$s as cn,Ya as cr,qu as ct,xh as d,Es as dn,Vu as dt,ic as en,lo as er,id as et,wh as f,Ts as fn,Bu as ft,$m as g,os as gn,Au as gt,th as h,ds as hn,ju as ht,P_ as i,tc as in,po as ir,od as it,$f as j,ss as jn,Fl as jt,mp as k,Zo as kn,Ul as kt,Kh as l,Ns as ln,Xa as lr,Ku as lt,ih as m,bs as mn,Fu as mt,N_ as n,cc as nn,to as nr,Gd as nt,Lg as o,Qs as on,eo as or,yd as ot,bh as p,ms as pn,Hu as pt,X as q,co as qn,Dc as qt,M_ as r,J as rn,oo as rr,Zd as rt,Tg as s,Vs as sn,go as sr,Zu as st,U_ as t,rc as tn,fo as tr,nd as tt,Oh as u,Ms as un,Qa as ur,Gu as ut,Lm as v,Go as vn,gu as vt,xm as w,as as wn,ou as wt,Mm as x,es as xn,uu as xt,zm as y,Ko as yn,fu as yt,Of as z,Co as zn,Ol as zt};
//# sourceMappingURL=control-ui-core-YphAl4aM.js.map