openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1,864 lines • 343 kB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./user-prefs-request-WwABZdqk.js","./session-snapshot-database-BurLa_ut.js","./control-ui-core-yIvVj14Y.css","./control-ui-boot-shared-Dfs-gZII.js","./control-ui-boot-shared-Sj2zqjOr.js","./plugin-contracts-runtime-CNCaYops.js","./config-runtime-BecGLziM.js","./markdown-runtime-ORQpioyT.js","./sidebar-update-runtime-DonYLwN5.js","./control-ui-boot-shared-styles-DKyMAG_6.css","./control-ui-boot-shared-CXHNz0Bh.css","./sidebar-update-runtime-ah7rgQE7.css","./chat-detail-panel-DL_gv0lj.js","./control-ui-boot-chat-C8hdsB2M.js","./control-ui-boot-chat-VeeaXyJz.js","./control-ui-boot-chat-Ck7W_FPO.js","./control-ui-boot-chat-DxoNF0Ad.js","./control-ui-boot-chat-styles-BRrYkFSc.js","./control-ui-boot-chat-XcDaYmck.js","./control-ui-boot-chat-BPMc7uzL.js","./chat-transcript-styles-B_dd5Ueo.css","./control-ui-boot-chat-styles-C_Ls1c0m.css","./control-ui-boot-chat-mLz7NUiY.css","./control-ui-boot-chat-Dh5vtL-G.css"])))=>i.map(i=>d[i]);
import{n as e,r as t}from"./rolldown-runtime-8BhlS34s.js";import{$t as n,Ac as r,At as i,Ct as a,Cu as o,Ds as s,Dt as c,Eu as l,Hr as u,Kl as d,Lc as f,Mt as p,Ql as m,Qs as h,Ru as g,Sl as _,Tt as v,Tu as y,Uc as b,Ur as x,V as S,W as ee,X as C,Xl as w,Ys as T,_l as te,al as ne,cl as re,cn as ie,du as ae,en as oe,eu as se,g as ce,h as le,iu as ue,ju as E,kc as de,lu as fe,m as pe,nc as me,nl as he,nu as ge,or as _e,p as ve,pu as ye,rc as be,rl as xe,rt as Se,sr as Ce,tu as we,uu as Te,wt as Ee,z as De}from"./control-ui-core-BncvAZjR.js";import{Ai as Oe,Cn as ke,Co as Ae,Gi as je,Hi as Me,Hn as Ne,Ii as Pe,It as Fe,Ki as Ie,Kt as Le,Pi as Re,Pt as ze,Ri as Be,Sr as Ve,Ti as He,Un as Ue,Wr as We,Xn as Ge,Zn as Ke,aa as D,bi as qe,br as Je,cr as Ye,dr as Xe,ga as Ze,gr as Qe,ha as $e,ia as et,kt as tt,mn as nt,mo as rt,na as O,oi as it,qt as at,ra as k,si as ot,sr as st,ur as ct,wi as lt,xi as ut,xr as dt}from"./control-ui-core-9qYjK5B2.js";import{$ as A,C as ft,F as pt,M as mt,T as ht,X as j,Y as M,a as gt,c as _t,ct as N,h as vt,i as yt,nt as bt,p as xt,s as St,tt as P,ut as F}from"./lit-runtime-B8uOr6OX.js";import{Jt as Ct,Kt as wt,Mn as Tt,Nn as Et,jn as Dt,qn as Ot}from"./control-ui-boot-shared-umGE-sEP.js";import{c as kt,d as At,l as jt}from"./gateway-runtime-Cr51Pi7N.js";import{$ as Mt,$a as Nt,A as Pt,Aa as Ft,At as It,Bt as Lt,Et as Rt,Fo as I,Ft as zt,Gi as Bt,Io as L,K as Vt,L as Ht,M as Ut,No as Wt,Po as Gt,Pt as Kt,Q as qt,Qa as Jt,So as Yt,Ta as Xt,Ui as Zt,Vt as Qt,Y as $t,Z as en,_t as tn,bt as nn,dn as rn,ft as an,jo as on,jt as sn,ka as cn,kt as ln,lt as un,oi as dn,ot as fn,pt as pn,q as mn,ri as hn,un as gn,va as _n,wn as vn,xn as yn,xt as bn,yo as xn,yt as Sn}from"./control-ui-boot-shared-DJkUdZmL.js";import{Bi as Cn,C as wn,Do as R,Ft as Tn,Hr as En,Ht as Dn,Jt as On,Pt as kn,Qi as An,T as jn,Ur as Mn,Vr as Nn,Xa as Pn,Xr as Fn,Xt as In,Yi as Ln,Zr as Rn,_a as z,_t as zn,cn as Bn,co as Vn,hi as Hn,ia as Un,ii as B,lo as Wn,oa as Gn,pa as Kn,po as qn,qi as Jn,ro as V,sa as Yn,uo as Xn,zt as Zn}from"./ui-DuRgK6kL.js";import{A as Qn,M as $n,O as er,d as tr,k as nr,u as rr}from"./control-ui-boot-shared-em9-jnbz.js";import{$t as ir,Ai as ar,Ci as or,Di as sr,F as cr,Fi as lr,Ii as ur,M as dr,Mi as fr,N as pr,Ni as mr,Oi as hr,P as gr,Pi as _r,Qt as vr,T as yr,_i as br,bi as xr,ct as Sr,hi as Cr,ji as wr,ki as Tr,si as Er,ui as Dr,ut as Or,w as kr}from"./control-ui-boot-shared-xfDhIVun.js";import{$ as Ar,$a as jr,A as Mr,Ar as Nr,At as Pr,C as Fr,Cf as H,Ci as Ir,Cn as Lr,Co as Rr,Ct as zr,Dc as Br,Do as Vr,Dr as Hr,Dt as Ur,Eo as Wr,Et as Gr,F as Kr,Fo as qr,G as Jr,Gf as Yr,Gi as Xr,Gs as Zr,Hf as Qr,Hs as $r,I as ei,If as ti,Ja as ni,K as ri,Kr as ii,L as ai,M as oi,Md as si,Mo as ci,Mt as li,N as ui,Nd as di,No as fi,O as pi,Oo as mi,Ot as hi,P as gi,Pf as _i,Po as vi,Q as yi,Qa as bi,S as xi,Sf as Si,Si as Ci,Sn as wi,St as Ti,T as Ei,Tc as Di,Tr as Oi,Uf as ki,Ui as Ai,Ur as ji,Us as Mi,V as Ni,W as Pi,Wf as Fi,Wi as Ii,Wr as Li,Ws as Ri,X as zi,Xa as Bi,Yf as Vi,Z as Hi,_r as Ui,_t as Wi,aa as Gi,b as Ki,bf as U,bt as qi,d as Ji,dn as Yi,dr as Xi,dt as Zi,en as Qi,eo as $i,et as ea,f as ta,ff as na,fn as ra,g as ia,gr as aa,h as oa,hl as sa,hr as ca,ht as la,ia as ua,io as da,j as fa,jo as pa,jt as ma,k as ha,kr as ga,kt as _a,m as va,mf as ya,ml as ba,mn as xa,mr as Sa,nn as Ca,p as wa,pl as Ta,pn as Ea,q as Da,qa as Oa,qf as ka,qr as Aa,ur as ja,ut as Ma,vf as Na,vr as Pa,vs as Fa,vt as Ia,w as La,wf as Ra,wn as za,wo as Ba,wr as Va,wt as Ha,x as Ua,xf as Wa,xn as Ga,xt as Ka,yf as qa,ys as Ja,yt as Ya,z as Xa}from"./control-ui-boot-shared-D3oo_6Fq.js";import{d as Za,f as Qa}from"./control-ui-boot-shared-D4XEBdOG.js";import"./control-ui-boot-shared-styles-BaQ2sAfZ.js";import"./chat-transcript-styles-Dzr3t9kA.js";import"./control-ui-boot-new-styles-Bb6Ub5D3.js";var $a;function eo(){return(eo=e((()=>{Ye(),Ee(),Vt(),$a=class{constructor(e,t={}){this.notify=e,this.options=t,this.pending=!1,this.failed=!1}get snapshot(){let e=this.binding;if(!e||!this.owns(e))return{models:[],hasSnapshot:!1,retired:!1};let t=$t(e.client,e.scope,{allowStale:!0});return{...t,models:t?.models??[],hasSnapshot:t!==void 0,retired:c(e.client,e.scope)}}bind(e,t){let n=e.snapshot.client,r=this.binding;if(r&&this.owns(r)&&r.gateway===e&&i(p(r.scope))===i(p(t))||(this.clear(),!n))return!1;let a={gateway:e,client:n,scope:t,presentationKey:st(e).key};this.binding=a;let o=qt(n,()=>{this.owns(a)&&(this.failed&&$t(n,t)&&(this.failed=!1),this.notify())}),s=Mt(e,()=>{this.owns(a)?this.read():this.notify()},t);return this.unsubscribe=()=>{o(),s()},!0}owns(e){return this.binding===e&&e.gateway.snapshot.client===e.client&&e.gateway.snapshot.phase===`connected`&&st(e.gateway).key===e.presentationKey}read(){let e=this.binding;if(!e||!this.owns(e))return Promise.resolve(void 0);this.controller?.abort(),this.controller=void 0;let t=$t(e.client,e.scope);if(t)return this.pending=!1,this.failed=!1,this.options.onResult?.(t),this.notify(),Promise.resolve(t);let n=new AbortController;return this.controller=n,this.pending=!0,this.failed=!1,this.notify(),mn(e.client,{...e.scope,signal:n.signal,timeoutMs:this.options.timeoutMs}).then(t=>{if(this.owns(e)&&this.controller===n)return this.controller=void 0,this.pending=!1,this.options.onResult?.(t),this.notify(),t},()=>{this.owns(e)&&this.controller===n&&(this.controller=void 0,this.pending=!1,this.failed=!0,this.options.onError?.(),this.notify())})}clear(){this.binding=void 0,this.controller?.abort(),this.controller=void 0,this.unsubscribe?.(),this.unsubscribe=void 0,this.pending=!1,this.failed=!1}}})))()}function to(e){return/^[A-Za-z0-9_/:=.,@%+-]+$/.test(e)?e:`'${e.replaceAll(`'`,`'\\''`)}'`}var no;function ro(){return(ro=e((()=>{M(),kr(),k(),We(),l(),I(),C(),ye(),ee(),L(),no=class{constructor(e,t){this.gateway=e,this.requestUpdate=t,this.openValue=!1,this.loadingValue=!1,this.errorValue=null,this.setupValue=null,this.requestId=0}get open(){return this.openValue}start(){this.openValue=!0,this.errorValue=null,this.setupValue=null,this.requestUpdate(),this.refresh()}close(){this.requestId+=1,this.openValue=!1,this.loadingValue=!1,this.errorValue=null,this.setupValue=null}render(e,t){if(!this.open||!e)return j;let n=()=>{this.close(),this.requestUpdate()},{loadingValue:r,errorValue:i,setupValue:a}=this,o=E(`newSession.connectMachineTitle`),s=a?.joinUrl?.trim(),c=s?`npx openclaw connect ${to(s)}`:null,l=a?.expiresAtMs?S(a.expiresAtMs,{hour:`numeric`,minute:`2-digit`},``):``;return A`
<openclaw-modal-dialog
class="connect-machine-dialog"
label=${o}
description=${E(`newSession.connectMachineDescription`)}
@modal-cancel=${n}
>
<section class="exec-approval-card connect-machine-dialog__card">
<header class="exec-approval-header">
<div>
<h2 class="exec-approval-title">${o}</h2>
<p class="exec-approval-sub">${E(`newSession.connectMachineDescription`)}</p>
</div>
<button
class="btn btn--icon btn--ghost"
type="button"
aria-label=${E(`common.dismiss`)}
@click=${n}
>
${O.x}
</button>
</header>
<div class="connect-machine-dialog__body">
${r&&!c?A`<p class="connect-machine-dialog__status" role="status">
${E(`newSession.connectMachineGenerating`)}
</p>`:j}
${i?A`<p class="exec-approval-error" role="alert">
${E(`newSession.connectMachineFailed`)} ${i}
</p>`:j}
${c?A`
${yr(c)}
<p class="connect-machine-dialog__hint">
${E(`newSession.connectMachineTeamHint`)}
</p>
<p class="connect-machine-dialog__hint">
${l?E(`newSession.connectMachineSingleUseExpires`,{time:l}):E(`newSession.connectMachineSingleUse`)}
</p>
`:j}
</div>
<footer class="exec-approval-actions connect-machine-dialog__actions">
${c||i?A`<button
class="btn"
type="button"
?disabled=${r}
@click=${()=>void this.refresh()}
>
${O.refresh}
${E(r?`newSession.connectMachineRefreshing`:`newSession.connectMachineFreshCode`)}
</button>`:j}
<button class="btn btn--ghost" type="button" @click=${t}>
${E(`newSession.connectMachineManageDevices`)}
</button>
</footer>
</section>
</openclaw-modal-dialog>
`}async refresh(){if(!this.openValue||this.loadingValue)return;let{client:e,connected:t}=this.gateway();if(!t||!e){this.errorValue=E(`newSession.connectMachineUnavailable`),this.requestUpdate();return}let n=++this.requestId;this.loadingValue=!0,this.errorValue=null,this.requestUpdate();try{let t=await Se(e);if(!this.stillCurrent(n,e))return;if(!t.joinUrl?.trim()){this.setupValue=null,this.errorValue=E(`newSession.connectMachineMissingUrl`);return}this.setupValue=t}catch(t){this.stillCurrent(n,e)&&(this.errorValue=ae(t))}finally{n===this.requestId&&(this.loadingValue=!1,this.requestUpdate())}}stillCurrent(e,t){let n=this.gateway();return e===this.requestId&&t===n.client&&n.connected&&this.openValue}}})))()}function io(e){if(!e||e.length>2048||Vn(e))return;let t=Mn(e);return t?Nn(t.provider,t.modelId):void 0}function ao(e,t){let n=new URLSearchParams(Ce(e)),r=io(t);return r&&n.set(`model`,r),n.size>0?`?${n.toString()}`:``}function oo(e){let t=_e(e),n=t.catalogId?void 0:io(new URLSearchParams(e).get(`model`));return{...t,...n?{requestedModel:n}:{}}}function so(){return(so=e((()=>{En(),Wn()})))()}function co(e,t,n,r){return JSON.stringify([e,t,n,...r?[r]:[]])}function lo(e){return co(e?.requestedAgentId??``,e?.catalogId??``,e?.group??``,e?.requestedModel)}function uo(e){let t=oo(e);return co(t.agentId,t.catalogId,t.group??``,t.requestedModel)}function fo(e,t){return!e?.requestedAgentId||V(e.requestedAgentId)===V(t)?e?.requestedModel:void 0}function W(e){return!!e?.catalogId}function po(e){return!!(e?.catalogId&&e.startTerminal&&e.catalogLabel)}function mo(e){return W(e)&&!po(e)||!!(e?.group&&e.groupStatus!==`resolved`)}function ho(e){return JSON.stringify([e?.groupStatus??``,e?.groupCwd??``,e?.groupWorktree===!0,e?.groupCatalogGeneration??-1,e?.groupDefaultsStatus??`idle`])}function go(e,t){let n=e?.group?.trim();if(!n)return!1;let r=t.groupsGeneration(),i=t.groupsStatus();if(e?.groupCatalogGeneration!==r||e.groupDefaultsStatus!==i)return!0;if(i!==`ready`)return!1;let a=t.state.groupSettings.find(e=>e.name===n);return a?e.groupStatus!==`resolved`||(e.groupCwd??``)!==(a.cwd??``)||e.groupWorktree!==(a.worktree===!0):e.groupStatus===`resolved`}function _o(e,t){let n=t.state.groupSettings.find(t=>t.name===e?.group);return JSON.stringify([e?.group??``,t.groupsGeneration(),t.groupsStatus(),!!n,n?.cwd??``,n?.worktree===!0])}function vo(e,t){return!(!e?.group||t&&!go(e,t))}function yo(e,t){return mo(e)||vo(e,t)}function bo(e,t){return e?.groupStatus===`resolved`&&!vo(e,t)?e.group:void 0}function xo(e,t,n){let r=e?.agentId?.trim();if(!r)return n&&V(n);let i=V(r);return t.some(e=>V(e.id)===i)?i:n&&V(n)}function So(e,t){return!W(e)||po(e)&&!!t}async function Co(e,t,n){try{let r=(await e.request(`sessions.catalog.list`,{...n?{agentId:n}:{},catalogId:t,limitPerHost:1})).catalogs.find(e=>e.id===t),i=r?.capabilities.startTerminal;return r&&i===!0?{catalogLabel:r.label,startTerminal:!0,terminalHosts:r.hosts.filter(e=>e.canStartTerminal===!0).map(({hostId:e,label:t})=>({hostId:e,label:t}))}:void 0}catch{return}}function wo(e){if(!W(e))return j;let t=po(e),n=e?.catalogLabel||e?.catalogId||``;return A`<span
class="new-session-page__trigger new-session-page__runtime"
title=${E(t?`newSession.nativeTerminalHint`:`newSession.catalogUnavailable`)}
>
<span class="new-session-page__target-icon" aria-hidden="true">${O.terminal}</span>
<span class="new-session-page__trigger-label">${n}</span>
</span>`}function To(e){let t=mo(e.data)||e.groupPending===!0;return A`
<div class="new-session-page__triggers">
${wo(e.data)} ${W(e.data)?j:e.agentSelect}
${e.placeSelect}
${t?A`<span class="new-session-page__catalog-unavailable">
${E(`newSession.catalogUnavailable`)}
<button
class="btn btn--sm"
type="button"
?disabled=${e.retrying}
@click=${e.onRetry}
>
${e.retrying?E(`common.loading`):E(`lazyView.retry`)}
</button>
</span>`:j}
</div>
`}var Eo,Do;function G(){return(G=e((()=>{M(),k(),l(),I(),jt(),_(),so(),L(),Eo=class{constructor(e,t){this.readData=e,this.revalidate=t,this.pending=null,this.lastKey=``}synchronize(e){if(this.pending)return;let t=this.readData(),n=_o(t,e);if(this.lastKey===n||!go(t,e))return;let r=this.revalidate();r&&(this.lastKey=n,this.pending=r,r.catch(()=>void 0).finally(()=>{this.pending===r&&(this.pending=null,this.synchronize(e))}))}},Do=class{constructor(e){this.notify=e,this.state={status:`idle`}}clear(){let e=this.state;this.state={status:`idle`},e.status===`loading`&&e.controller.abort(),e.status!==`idle`&&this.notify()}startRequest(e){let t=new AbortController,n={status:`loading`,owner:e,controller:t};this.state=n,this.notify(),e.client.request(`sessions.catalog.list`,{agentId:e.agentId,metadataOnly:!0},{signal:t.signal}).then(t=>{this.state===n&&(this.state={status:`ready`,owner:e,targets:t.catalogs.filter(e=>e.capabilities.startTerminal===!0).map(({id:e,label:t})=>({id:e,label:t}))},this.notify())},()=>{this.state===n&&(this.state={status:`error`,owner:e},this.notify())})}load(e,t,n){let r=e?.gateway.snapshot,i=r?.client,a=t.trim()?V(t):``;if(!n||r?.phase!==`connected`||!i||!a||At(r,`sessions.catalog.list`)!==!0){this.clear();return}let o={agentId:a,client:i},s=this.state;(s.status===`idle`||s.owner.client!==o.client||s.owner.agentId!==o.agentId)&&(this.clear(),this.startRequest(o))}retry(e,t){let n=this.state;n.status===`error`&&n.owner.client===e&&n.owner.agentId===t&&this.startRequest(n.owner)}groups(){let e=this.state;if(!(e.status===`idle`||e.status===`ready`&&!e.targets.length))return[{errorLabel:E(`newSession.cliAgentsUnavailable`),id:`cliAgents`,label:E(`newSession.cliAgentsGroup`),options:e.status===`ready`?e.targets.map(({id:e,label:t})=>({value:e,label:t})):[],status:e.status}]}}})))()}var Oo;function ko(){return(ko=e((()=>{Oo=[1e3,3e3,1e4,3e4,6e4]})))()}function Ao(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0?Math.trunc(e):void 0}function jo(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0&&e<=65536?e:void 0}function Mo(e){let t=(Array.isArray(e)?e:[]).flatMap(e=>{if(!z(e))return[];if(e.code===`worker-host-unavailable`){let t=R(e.message);return t&&t.length<=1024?[{code:`worker-host-unavailable`,message:t}]:[]}return e.code===`update-required`&&e.action===`update-and-reconnect`&&e.updateCommand===`openclaw update`&&e.headlessReconnectCommand===`openclaw node restart`?[{code:e.code,action:e.action,updateCommand:e.updateCommand,headlessReconnectCommand:e.headlessReconnectCommand}]:[]});return t.length>0?t:void 0}function No(e){return Array.isArray(e)?e.length===1&&(e[0]===`worker-turn`||e[0]===`remote-exec`)?[e[0]]:e.length===2&&e[0]===`worker-turn`&&e[1]===`remote-exec`?[`worker-turn`,`remote-exec`]:[]:[]}function Po(e,t){return e.executionModes?.includes(t)===!0}function Fo(e){return(Array.isArray(e)?e:[]).flatMap(e=>{let t=Kn(e);if(!t)return[];let n=R(t.id),r=R(t.providerId);if(!n||!r)return[];let i=t.trust===`persistent`||t.trust===`disposable`?t.trust:void 0,a=Io(t.machines),o=Lo(t.operatingSystems);return[{id:n,providerId:r,...typeof t.providerDisplayId==`string`&&/^[a-z][a-z0-9-]{0,63}$/.test(t.providerDisplayId)&&t.providerDisplayId.trim()===t.providerDisplayId?{providerDisplayId:t.providerDisplayId}:{},trust:i,...Object.hasOwn(t,`executionModes`)?{executionModes:No(t.executionModes)}:{},...a.length>0?{machines:a}:{},...o.length>0?{operatingSystems:o}:{}}]}).toSorted((e,t)=>e.id.localeCompare(t.id))}function Io(e){let t=new Map;for(let n of(Array.isArray(e)?e:[]).slice(0,64)){if(!z(n))continue;let e=R(n.id),r=R(n.label),i=R(n.os),a=JSON.stringify([i,e]);if(!e||e.length>128||!r||r.length>128||t.has(a)||n.os!==void 0&&(!i||i.length>64))continue;let o=jo(n.cpu),s=jo(n.memoryGb);t.set(a,{id:e,label:r,...i?{os:i}:{},...o===void 0?{}:{cpu:o},...s===void 0?{}:{memoryGb:s},...typeof n.default==`boolean`?{default:n.default}:{}})}return[...t.values()]}function Lo(e){let t=new Map;for(let n of(Array.isArray(e)?e:[]).slice(0,8)){if(!z(n))continue;let e=R(n.id),r=R(n.label),i=R(n.disabledReason)?.slice(0,256);!e||e.length>64||!r||r.length>64||t.has(e)||t.set(e,{id:e,label:r,...typeof n.default==`boolean`?{default:n.default}:{},...i?{disabledReason:i}:{}})}return[...t.values()]}function Ro(e){return e.operatingSystems?.find(e=>e.default)?.id??e.operatingSystems?.[0]?.id??e.machines?.find(e=>e.os)?.os??``}function zo(e,t){return(e.machines??[]).filter(e=>!e.os||e.os===t)}function Bo(e,t=Ro(e)){let n=zo(e,t);return n.find(e=>e.default)??n[0]}function Vo(e){return typeof e==`string`&&Wo.has(e)}function Ho(e){if(!z(e)||Object.keys(e).some(e=>e!==`command`&&e!==`state`&&e!==`message`))return;let t=R(e.command),n=e.state,r=R(e.message);return t&&t.length<=128&&(n===`invocable`||n===`pending-approval`||n===`undeclared`||n===`unauthorized`)?{command:t,state:n,...r?{message:r}:{}}:void 0}function Uo(e){return(Array.isArray(e)?e:[]).flatMap(e=>{let t=Kn(e);if(!t)return[];let n=R(t.id),r=R(t.type);if(!n||r!==`local`&&r!==`node`&&r!==`worker`||!Vo(t.status))return[];let i=t.status,a=R(t.label),o=R(t.platform),s=t.trust===`persistent`||t.trust===`disposable`?t.trust:void 0,c=Xn(t.capabilities),l=Array.isArray(t.invocableCommands)?qn(t.invocableCommands).filter(e=>e.length<=128).slice(0,128):void 0,u=Ho(t.requiredNodeCommand),d=Ao(t.lastConnectedAtMs),f=Ao(t.lastDisconnectedAtMs),p=Ao(t.lastSeenAtMs),m=R(t.lastSeenReason),h=Mo(t.issues),g=Et(t.workerSlots);return[{id:n,type:r,status:i,...a?{label:a}:{},...o?{platform:o}:{},...typeof t.sessionHost==`boolean`?{sessionHost:t.sessionHost}:{},...g?{workerSlots:g}:{},...d===void 0?{}:{lastConnectedAtMs:d},...f===void 0?{}:{lastDisconnectedAtMs:f},...p===void 0?{}:{lastSeenAtMs:p},...m?{lastSeenReason:m}:{},...s?{trust:s}:{},...c?{capabilities:c}:{},...l?{invocableCommands:l}:{},...u?{requiredNodeCommand:u}:{},...h?{issues:h}:{}}]}).toSorted((e,t)=>e.id.localeCompare(t.id))}var Wo;function Go(){return(Go=e((()=>{Wn(),Tt(),Wo=new Set([`available`,`unavailable`,`starting`,`stopping`,`error`])})))()}async function Ko(e,t){let n=await e.request(`environments.list`,t?{runtimeId:t}:{});return{profiles:Fo(n?.profiles),environments:Uo(n?.environments)}}function qo(e,t){return t===`enable-session-hosting`?A`<div>${E(`newSession.sessionHostingAction`)}</div>
<code class="new-session-page__command">openclaw connect --service --session-host</code>`:t===`update-device`?A`<div>${E(`newSession.updateAction`)}</div>
<code class="new-session-page__command">openclaw update</code>
<div>${E(`newSession.reconnectAction`)}</div>
<code class="new-session-page__command">openclaw node restart</code>`:e}function K(e,t){return A`<div class="new-session-page__card-row">
<span class="new-session-page__card-icon" aria-hidden="true">${e}</span><span>${t}</span>
</div>`}function q(e,t){let n=e.disabled?e.title||e.description:void 0,r=e.compact?void 0:e.description,i=e.compact&&e.disabled&&!e.hideDetails,a=e.compact&&!e.disabled&&!e.hideDetails,o=[e.suggested?E(`newSession.machineDefault`):void 0,e.accessibleProvider?E(`newSession.cloudWorkerProvider`,{provider:e.accessibleProvider}):void 0].filter(Boolean).join(`, `),s=[o,e.accessibleProvider?n:void 0].filter(Boolean).join(`, `),c=A`
<button
type="button"
class="session-menu__item ${r?`session-menu__item--described`:``} ${e.compact?`new-session-page__environment-option`:``}"
data-suggested=${e.suggested?`true`:j}
aria-description=${s||j}
data-value=${e.value}
data-popover=${e.keepOpen||i?j:`close`}
aria-pressed=${String(e.checked)}
title=${e.compact?j:e.title??j}
?disabled=${t||!!e.disabled&&!i}
aria-disabled=${i?`true`:j}
@click=${t=>{if(e.disabled){t.preventDefault(),t.stopPropagation();return}e.onSelect()}}
>
${e.icon?A`<span class="session-menu__icon" aria-hidden="true">${e.icon}</span>`:j}
<span class="session-menu__text">
${e.label}
${e.selectedSummary?A`<span class="new-session-page__selected-summary"
>${e.selectedSummary}</span
>`:j}
${r?A`<span class="session-menu__description">${r}</span>`:j}
</span>
${!e.compact&&e.facts?.length?A`<span class="new-session-page__menu-meta">
<span class="new-session-page__menu-facts">
${e.facts.map(e=>A`<span class="new-session-page__menu-fact">${e}</span>`)}
</span>
</span>`:j}
${!e.compact&&e.sub?A`<span class="session-menu__sub">${e.sub}</span>`:j}
<span class="session-menu__check" aria-hidden="true"
>${e.checked?O.check:j}</span
>
${e.hasSubmenu?A`<span class="new-session-page__submenu-chevron" aria-hidden="true"
>${O.chevronRight}</span
>`:j}
</button>
`;return e.compact&&!e.hideDetails?A`<openclaw-tooltip
class="new-session-page__environment-details"
placement="right-start"
?open-on-click=${i||a}
>
<div class="new-session-page__environment-detail-trigger">
${c}
${a?A`<button
type="button"
class="new-session-page__touch-details"
aria-label=${E(`newSession.environmentDetails`,{name:e.label})}
?disabled=${t}
>
${O.info}
</button>`:j}
</div>
<div slot="content" class="new-session-page__environment-card">
${o?A`<span hidden>${o}, </span>`:j}
${n?A`<span>${qo(n,e.remediation)}</span>`:A`
<strong>${e.label}</strong>
${e.summary?K(O.info,e.summary):j}
${e.platform?K(O.layers,e.platform):j}
${e.sub?K(O.info,e.sub):j}
${e.capabilityLabels?.length?K(O.info,e.capabilityLabels.join(`, `)):j}
${e.trust?K(e.trust===`persistent`?O.repeat:O.clock,E(e.trust===`persistent`?`newSession.persistentEnvironmentHint`:`newSession.disposableEnvironmentHint`)):j}
${e.provider?K(O.server,e.provider):j}
${e.hardware?K(O.info,e.hardware):j}
${[...new Set([e.description,...e.facts??[],e.provider&&!e.disabled?void 0:e.title].filter(Boolean))].map(e=>K(O.info,e))}
${e.capacityLabel?A`<div class="new-session-page__card-row">
<span class="new-session-page__card-icon" aria-hidden="true"
>${O.activity}</span
><span class="new-session-page__capacity-caption"
>${e.capacityLabel}</span
>
</div>`:j}
`}
</div>
</openclaw-tooltip>`:c}function Jo(e){return e.profiles.toSorted(Er).map(t=>{let n=Cr(t),r=e.profileDisabledReason?.(t),i=e.selectedId===t.id,a=(i?e.selectedOs:void 0)||Ro(t),o=t.operatingSystems?.find(e=>e.id===a),s=zo(t,a),c=(i&&e.selectedMachine?s.find(t=>t.id===e.selectedMachine):void 0)??Bo(t,a),l=e.compact&&!e.disabled&&!r&&((t.operatingSystems?.some(e=>!e.disabledReason)??!1)||s.length>0),u=q({value:`cloud:${t.id}`,label:e.compact?t.id:E(`newSession.cloudWorker`,{profile:t.id}),hasSubmenu:l,selectedSummary:e.compact&&i?[o?.label,c?.label].filter(Boolean).join(` · `):void 0,icon:n.icon,accessibleProvider:n.label,compact:e.compact,facts:!e.compact&&t.trust===`disposable`?[E(`newSession.environmentDisposable`)]:!e.compact&&t.trust===`persistent`?[E(`newSession.environmentPersistent`)]:void 0,trust:e.compact?t.trust:void 0,provider:e.compact?n.label:void 0,platform:e.compact?o?.label:void 0,hardware:e.compact&&c?Yo(c):void 0,hideDetails:e.compact&&!e.disabled&&!r,keepOpen:e.compact,checked:e.selectedId===t.id,disabled:e.disabled||!!r,title:(e.disabled?e.disabledReason:r)??E(`newSession.cloudWorkerProvider`,{provider:n.label}),onSelect:()=>e.compact&&!i?e.onSelect(t.id,!0):e.onSelect(t.id)},e.submitting);return l?A`<openclaw-tooltip
class="new-session-page__environment-details new-session-page__cloud-config-card"
placement="right"
open-on-click
>
${u}
<div slot="content">
<span hidden
>${E(`newSession.cloudWorkerProvider`,{provider:n.label})}</span
>
${Xo({profile:t,operatingSystems:t.operatingSystems??[],machines:s,suggested:!i,selectedOs:i?a:``,selectedMachine:i?c?.id??``:``,submitting:e.submitting,onSelectOs:n=>{i||e.onSelect(t.id,!0),e.onSelectOs?.(n)},onSelectMachine:n=>{i||e.onSelect(t.id,!0),e.onSelectMachine?.(n)}})}
</div>
</openclaw-tooltip>`:u})}function Yo(e){let t=e.cpu===void 0?void 0:String(e.cpu),n=e.memoryGb===void 0?void 0:String(e.memoryGb);return t&&n?E(`newSession.machineShape`,{cpu:t,memory:n}):t?E(`newSession.machineCpu`,{cpu:t}):n?E(`newSession.machineMemory`,{memory:n}):void 0}function Xo(e){let t=e.operatingSystems.filter(e=>!e.disabledReason),n=t.length===1?t[0]:void 0,r=e.machines.length===1?e.machines[0]:void 0,i=[[t.length,E(`newSession.operatingSystem`),()=>n?A`<span class="new-session-page__fixed-os" data-value=${`os:${n.id}`}
>${n.label}</span
>`:$o({operatingSystems:t,selectedId:e.selectedOs,suggestedId:e.suggested?Ro(e.profile):void 0,submitting:e.submitting,onSelect:e.onSelectOs})],[e.machines.length,E(`newSession.machine`),()=>r?Zo(r):Qo({machines:e.machines,selectedId:e.selectedMachine,suggestedId:e.suggested?Bo(e.profile,e.selectedOs)?.id:void 0,submitting:e.submitting,onSelect:e.onSelectMachine})]];return A`<section
class="new-session-page__cloud-configuration"
aria-label=${e.profile.id}
>
${i.map(([e,t,n])=>e?A`<div class="new-session-page__environment-heading">${t}</div>
<div class="new-session-page__cloud-choice-list" role="group" aria-label=${t}>
${n()}
</div>`:j)}
</section>`}function Zo(e){let t=Yo(e);return A`<span class="new-session-page__fixed-machine" data-value=${`machine:${e.id}`}>
<span>${e.label}</span>${t?A`<span>${t}</span>`:j}
</span>`}function Qo(e){return e.machines.map(t=>q({suggested:e.suggestedId===t.id,value:`machine:${t.id}`,label:t.label,sub:Yo(t),checked:e.selectedId===t.id||!e.selectedId&&e.suggestedId===t.id,keepOpen:!0,onSelect:()=>e.onSelect(t.id)},e.submitting))}function $o(e){return e.operatingSystems.map(t=>q({suggested:e.suggestedId===t.id,value:`os:${t.id}`,label:t.label,description:t.disabledReason,disabled:!!t.disabledReason,title:t.disabledReason,checked:e.selectedId===t.id||!e.selectedId&&e.suggestedId===t.id,keepOpen:!0,onSelect:()=>e.onSelect(t.id)},e.submitting))}function es(){return(es=e((()=>{M(),Oe(),k(),Dr(),l(),I(),Go(),L()})))()}function ts(e){if(!z(e)||typeof e.agentId!=`string`||!e.agentId.trim())return null;let t=os(e.selection);if(!t||!z(e.selection))return null;for(let n of[`folder`,`projectId`,`baseRef`]){let r=e.selection[n];typeof r==`string`&&(t[n]=r.trim())}return delete t.model,delete t.agentRuntime,delete t.thinkingLevel,delete t.fastMode,delete t.worktreeName,{agentId:V(e.agentId),selection:t}}function ns(e){return e.cloudProfileId?{kind:`cloud`,id:e.cloudProfileId}:e.deviceId?{kind:`device`,id:e.deviceId}:e.autoDevice?{kind:`auto-device`}:{kind:`local`}}function rs(e){return!!(e?.model||e?.thinkingLevel||e?.fastMode!==void 0)}function is(e,t){let n=e?.folder??``,r=!!n&&n===e?.workspace&&e.workspace!==t,i=n&&!r?n:t;return{folder:i,workspaceMoved:r,freshWorkspace:e?.freshWorkspace??!(e?.worktree===!0||e?.projectId||i&&i!==t)}}function as(e){return`${hs}${Bn(e)}`}function os(e){if(!z(e))return null;let t={};for(let n of[`workspace`,`folder`,`projectId`,`baseRef`,`worktreeName`,`model`,`thinkingLevel`]){let r=R(e[n]);r&&(t[n]=r)}let n=R(e.agentRuntime);if(t.model&&n&&(t.agentRuntime=n),(typeof e.fastMode==`boolean`||e.fastMode===`auto`||e.fastMode===`ultrafast`)&&(t.fastMode=e.fastMode),typeof e.worktree==`boolean`&&(t.worktree=e.worktree),typeof e.freshWorkspace==`boolean`?t.freshWorkspace=e.freshWorkspace:t.worktree===!0&&(t.freshWorkspace=!1),typeof e.defaultRepositoryOptOut==`boolean`&&(t.defaultRepositoryOptOut=e.defaultRepositoryOptOut),e.remoteProject===null)t.remoteProject=null;else if(z(e.remoteProject)){let n=R(e.remoteProject.identity)?.slice(0,200),r=R(e.remoteProject.cloneUrl)?.slice(0,2048),i=R(e.remoteProject.defaultBranch)?.slice(0,255);n&&r&&(t.remoteProject={identity:n,cloneUrl:r,...i?{defaultBranch:i}:{}})}let r=cs(e.where);return r&&(t.where=r),Object.keys(t).length?t:null}function ss(e){let t=os(e);return t?(delete t.remoteProject,delete t.defaultRepositoryOptOut,Object.keys(t).length?t:null):null}function cs(e){if(!z(e)||typeof e.kind!=`string`)return;if(e.kind===`local`||e.kind===`auto-device`)return{kind:e.kind};let t=R(e.id);return t&&(e.kind===`device`||e.kind===`cloud`)?{kind:e.kind,id:t}:void 0}function ls(e,t){try{let n=JSON.parse(e.getItem(as(t))??`null`);return z(n)?n:{}}catch{return{}}}function us(e,t){let n=g(),r=V(t);return!n||!e||!r?null:ss(ls(n,e).agents?.[r])}function ds(e){let t=g();if(!t||!e)return{};let n=Object.entries(ls(t,e).agents??{}).flatMap(([e,t])=>{let n=V(e),r=ss(t);return n&&r?[[n,r]]:[]});return Object.fromEntries(n)}function fs(e){return Object.fromEntries(Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[`${gs}${e}`,t]))}function ps(e){return Object.fromEntries(Object.entries(e).flatMap(([e,t])=>{if(!e.startsWith(gs))return[];let n=V(e.slice(15)),r=os(t);return n&&r?[[n,r]]:[]}))}function ms(e,t,n){let r=g(),i=V(t);if(!r||!e||!i)return!1;let a=ls(r,e),o=Object.fromEntries(Object.entries(a.agents??{}).flatMap(([e,t])=>{let n=ss(t);return n?[[e,n]]:[]})),s=ss(n);s?o[i]=s:delete o[i];try{return r.setItem(as(e),JSON.stringify({...a,agents:o})),!0}catch{return!1}}var hs,gs,_s,vs;function ys(){return(ys=e((()=>{_(),hs=`openclaw.new-session.preferences.v1:`,gs=`new-session.v1:`,_s=`new-session.migration.v1`,vs=`new-session.palette.v1`})))()}var bs;function xs(){return(xs=e((()=>{Ot(),ze(),l(),I(),jt(),_(),fe(),G(),ys(),Yn(),L(),bs=class e{static{this.preferenceWriters=new WeakMap}constructor(e,t){this.read=e,this.callbacks=t,this.preferenceModeValue=`local`,this.identityPreferences={},this.preferenceLoad=Promise.resolve()}get loading(){return this.preferenceModeValue===`loading`}synchronize(){let e=this.read(),t=e.source;if(!t)return;let n={...e,profileId:t.snapshot.selfUser?.id};if(this.preferenceScope&&[`source`,`client`,`connected`,`recoveryScope`,`connectionEpoch`,`profileId`].every(e=>n[e]===this.preferenceScope?.[e]))return;this.disconnect(),this.preferenceScope=n,this.identityPreferences={};let{client:r,connected:i,recoveryScope:a,profileId:o}=n;if(i){let e=this.preferenceWrites(t).listeners,i=(e,i,s)=>{let c=t.snapshot;this.preferenceScope===n&&c.client===r&&c.hello?.auth?.recoveryScope===a&&c.selfUser?.id===o&&(this.identityPreferences={...this.identityPreferences,[e]:i},s?this.adoptPreferences():this.callbacks.requestUpdate())};e.add(i),this.stopPreferencePublication=()=>e.delete(i)}let s=i&&r&&o&&At(t.snapshot,`users.prefs.get`)===!0&&At(t.snapshot,`users.prefs.set`)===!0;this.preferenceModeValue=s?`loading`:`local`,this.preferenceLoad=s?this.loadIdentityPreferences({client:r,profileId:o,gatewayUrl:e.gatewayUrl,scope:n}):Promise.resolve()}disconnect(){this.stopPreferencePublication?.(),this.stopPreferencePublication=void 0,this.preferenceScope=void 0}adoptPreferences(){this.read().agentsHydrated&&this.callbacks.onAdoptAgentDefaults(),this.callbacks.requestUpdate()}readPreference(e){return this.preferenceModeValue===`remote`?this.identityPreferences[V(e)]??null:us(this.read().gatewayUrl,e)}preferenceWrites(t){let n=e.preferenceWriters.get(t);return n||(n={agents:new Map,revision:{},listeners:new Set},e.preferenceWriters.set(t,n)),n}capturePreferenceConsumption(e,t,n){return this.preparePreferenceWrite(e,t,{worktreeName:``},n)}persistPreference(e,t,n){return this.preparePreferenceWrite(e,t,n)?.()}preparePreferenceWrite(e,t,n,r){let{source:i,client:a,gatewayUrl:o,recoveryScope:s,bootId:c,data:l,pendingPlacementSessionKey:u}=this.read(),d=r!==void 0,f=!W(l)&&!l?.group&&(d||!u);if(!f&&!d||!i)return;let p=this.preferenceScope,m=i.snapshot.selfUser?.id,h=this.preferenceLoad,g=V(e),_=this.preferenceWrites(i),v=_.agents.get(g);v||(v={selection:{},write:Promise.resolve()},_.agents.set(g,v));let y=v.selection,b=()=>!!(a&&i.snapshot.client===a&&i.snapshot.phase===`connected`&&i.connection.gatewayUrl===o&&a.recoveryScope===s&&(i.snapshot.hello?.auth?.recoveryScope??``)===s&&i.snapshot.hello?.server?.bootId===c&&i.snapshot.selfUser?.id===m),x=d?n:{workspace:t,...n},S=e=>r?!e||e.worktreeName!==r.worktreeName||e.worktree!==!0||(e.workspace??t)!==t||is(e,t).folder!==r.folder||(e.projectId??``)!==(r.projectId??``)?`superseded`:r.selectedBaseRef===void 0?!e.baseRef&&r.baseRef?`unconfirmed`:(e.baseRef??``)===(r.baseRef??``)?`match`:`superseded`:(e.baseRef??``)===r.selectedBaseRef?`match`:`superseded`:`match`;return async e=>{if(d&&(!b()||v.selection!==y))return;let t=Object.keys(n).some(e=>![`model`,`agentRuntime`,`thinkingLevel`,`fastMode`].includes(e))?{}:v.selection;if(v.selection=t,e?.(),!f)return;let r=()=>d?b()&&v.selection===t:b()&&this.preferenceScope===p,i=this.preferenceModeValue!==`local`,s=async()=>{if(!(i&&(await h,!a||!r())))try{for(let e=0;e<3;e+=1){let e;if(this.preferenceModeValue!==`local`){if(!a||!m||!r())return;let{loadUserPreferences:t}=await Gn(async()=>{let{loadUserPreferences:e}=await import(`./user-prefs-request-WwABZdqk.js`).then(e=>(e.t(),e.r));return{loadUserPreferences:e}},__vite__mapDeps([0,1,2]),import.meta.url),n=await t(a,m);if(!r())return;if(n.status!==`ok`)return!1;e=n.entries}let t=e?ps(e)[g]:us(o,g),n=S(t);if(n!==`match`)return n===`superseded`;let i={...t,...x};if(e&&a){let t=fs({[g]:i}),n=await Fe(a,{entries:t,expectedEntries:Object.fromEntries(Object.keys(t).map(t=>[t,e[t]??null]))});if(!b()||n.status!==`ok`&&!r())return;if(n.status===`conflict`)continue;if(n.status!==`ok`)return!1;ms(o,g,i)}else{if(!ms(o,g,i))return!1;i=us(o,g)??{}}_.revision={};for(let e of _.listeners)e(g,i,d);return e&&this.preferenceScope===p&&(this.identityPreferences={...this.identityPreferences,[g]:i},this.callbacks.requestUpdate()),!0}return!1}catch{return!1}},c=i?v.write.then(s,s):s();return v.write=c.then(e=>{e===!1&&r()&&Te({message:E(d?`newSession.worktreeNameClearUnconfirmed`:`newSession.preferenceSaveUnconfirmed`)})}),v.write}}async loadIdentityPreferences(e){let t=this.read().source,n=t?this.preferenceWrites(t):void 0,r=n?.revision,i=0;try{let{loadUserPreferences:t}=await Gn(async()=>{let{loadUserPreferences:e}=await import(`./user-prefs-request-WwABZdqk.js`).then(e=>(e.t(),e.r));return{loadUserPreferences:e}},__vite__mapDeps([0,1,2]),import.meta.url),a=async()=>{let n=await t(e.client,e.profileId);if(n.status!==`ok`)throw Error(`User preferences unavailable`);return n.entries};if(this.preferenceScope!==e.scope)return;let o=await a(),s=ds(e.gatewayUrl);for(;this.preferenceScope===e.scope;){if(n?.revision!==r)return this.loadIdentityPreferences(e);let t=ps(o);if(o[`new-session.migration.v1`]!==!0&&i<3){let n=Object.fromEntries(Object.entries(s).filter(([e])=>!Object.hasOwn(t,e))),r=Object.entries(fs(n)),c=Object.fromEntries(r.slice(0,31));r.length<32&&(c[_s]=!0);let l=await Fe(e.client,{entries:c,expectedEntries:{...Object.fromEntries(Object.keys(c).map(e=>[e,o[e]??null])),[_s]:o[`new-session.migration.v1`]??null}}).catch(()=>null);if(this.preferenceScope!==e.scope)return;if(l?.status===`conflict`){i+=1,o=await a();continue}if(l?.status===`ok`){o={...o,...c};continue}i===0&&(t={...s,...t})}if(n?.revision!==r)return this.loadIdentityPreferences(e);this.identityPreferences=t,this.preferenceModeValue=`remote`;for(let[n,r]of Object.entries(t))ms(e.gatewayUrl,n,r);this.adoptPreferences();return}}catch{this.preferenceScope===e.scope&&(this.preferenceModeValue=i>0?`remote`:`local`,this.callbacks.requestUpdate())}}}})))()}async function Ss(e,t,n){if(!e||!t)return``;try{let{value:t}=await Xr(e,n,{fresh:!0});return R(t.machineName)??R(t.hostname)?.split(`.`,1)[0]??``}catch{return``}}function Cs(){return(Cs=e((()=>{Ii()})))()}function ws(e){let t=Ts.get(e.client);t||(t=new WeakMap,Ts.set(e.client,t));let n=t.get(e.hello);n||(n=new Map,t.set(e.hello,n));let r=JSON.stringify([e.gatewayUrl,e.profileId]),i=n.get(r);if(!i){let t=n,a=new Es(e,()=>{t.get(r)===a&&t.delete(r)});i=a,n.set(r,i)}return i}var Ts,Es;function Ds(){return(Ds=e((()=>{ze(),ys(),Yn(),Ts=new WeakMap,Es=class{constructor(e,t){this.owner=e,this.release=t,this.mode=`loading`,this.palettePreference=null,this.listeners=new Map,this.writing=Promise.resolve(),this.pendingWrites=0,this.loading=this.load()}subscribe(e,t){return this.listeners.set(e,t),()=>{this.listeners.delete(e),this.releaseIfIdle()}}releaseIfIdle(){!this.listeners.size&&!this.pendingWrites&&this.release()}hasCurrentBinding(){return[...this.listeners.values()].some(e=>e())}setPalettePreference(e,t){if(!t())return Promise.resolve(!1);let n=async()=>{if(await this.loading,!this.hasCurrentBinding()||this.mode!==`remote`)return!1;try{return(await Fe(this.owner.client,{entries:{"new-session.palette.v1":e}})).status===`ok`&&(this.palettePreference=e,this.publish(`changed`),!0)}catch{return!1}};this.pendingWrites+=1;let r=this.writing.then(n,n);return this.writing=r.then(()=>{},()=>{}),r.finally(()=>{--this.pendingWrites,this.releaseIfIdle()})}publish(e){for(let[t,n]of this.listeners)n()&&t(e)}async load(){try{let{loadUserPreferences:e}=await Gn(async()=>{let{loadUserPreferences:e}=await import(`./user-prefs-request-WwABZdqk.js`).then(e=>(e.t(),e.r));return{loadUserPreferences:e}},__vite__mapDeps([0,1,2]),import.meta.url);if(!this.hasCurrentBinding())return;let t=await e(this.owner.client,this.owner.profileId);if(!this.hasCurrentBinding())return;if(t.status!==`ok`){this.mode=`local`;return}this.palettePreference=ts(t.entries[vs]),this.mode=`remote`}catch{this.mode=`local`}finally{this.publish(`loaded`)}}}})))()}function Os(e){return e.gatewayIdentityChanged||!e.placementDraftOwned?`gateway-changed`:`placement-interrupted`}var ks,As;function js(){return(js=e((()=>{ki(),Tn(),ks=new WeakMap,As=class{constructor(e){this.readOwner=e,this.sessionKey=``,this.messageId=``,this.message=``,this.target=null,this.agentId=``,this.gatewayUrl=``,this.recoveryScope=``,this.phase=`dispatching`,this.retryAllowed=!1,this.restored=!1,this.persistent=!0}releaseClaim(){this.claim?.owners.get(this.claim.key)===this&&this.claim.owners.delete(this.claim.key),this.claim=void 0}claimOwners(){let e=this.readOwner?.();if(!e)return;let t=ks.get(e);return t||(t=new Map,ks.set(e,t)),t}claimKey(e,t,n){return JSON.stringify([e,t,n])}clear(){this.persistent&&Qr(this.gatewayUrl,this.recoveryScope,this.sessionKey,this.messageId),this.reset()}hasOtherLiveOwner(e,t,n){let r=this.claimOwners()?.get(this.claimKey(e,t,n));return r!==void 0&&r!==this}owns(e,t,n){return!this.hasOtherLiveOwner(e,t,n)&&this.gatewayUrl===e&&this.recoveryScope===t&&this.sessionKey===n}reset(){this.releaseClaim(),this.sessionKey=``,this.messageId=``,this.message=``,this.mentions=void 0,this.attachments=void 0,this.target=null,this.agentId=``,this.gatewayUrl=``,this.recoveryScope=``,this.phase=`dispatching`,this.createParams=void 0,this.retryAllowed=!1,this.restored=!1,this.persistent=!0}restore(e,t){let n=this.claimOwners(),r=Fi(e,t).find(r=>{let i=n?.get(this.claimKey(e,t,r.sessionKey));return r.phase===`creating`&&(!i||i===this)});return!r||r.phase!==`creating`?null:(this.apply(r,!0,!0),r)}capture(){return this.snapshot(this.sessionKey,this.phase)}stageCreate(e){let t=`agent:${e.agentId}:dashboard:${kn()}`,n=Yr({...e.createParams,key:t},t,e.agentId);if(!n)return null;let r=e.persistent!==!1;r||delete n.key;let i={sessionKey:t,messageId:kn(),message:e.message,...e.mentions?.length?{mentions:e.mentions.map(e=>({...e}))}:{},attachments:e.attachments,target:e.target,agentId:e.agentId,gatewayUrl:e.gatewayUrl,recoveryScope:e.recoveryScope,phase:`creating`,createParams:n};return r&&!Vi(i)?null:(this.apply(i,!1,r),n)}promoteToDispatching(e){let t=this.sessionKey,n=this.snapshot(e,`dispatching`);return!n||this.persistent&&!ka(t,n)?!1:(this.releaseClaim(),this.sessionKey=e,this.phase=`dispatching`,this.createParams=void 0,!0)}snapshot(e,t){return!this.sessionKey||!this.messageId||!this.target||!this.agentId||t===`creating`&&!this.createParams?null:{sessionKey:e,messageId:this.messageId,message:this.message,...this.mentions?.length?{mentions:this.mentions.map(e=>({...e}))}:{},attachments:this.attachments?[...this.attachments]:void 0,target:{...this.target},agentId:this.agentId,gatewayUrl:this.gatewayUrl,recoveryScope:this.recoveryScope,phase:t,...t===`creating`&&this.createParams?{createParams:{...this.createParams}}:{}}}apply(e,t,n){this.releaseClaim();let r=this.claimOwners();if(r&&e.phase===`creating`){let t=this.claimKey(e.gatewayUrl,e.recoveryScope,e.sessionKey);r.set(t,this),this.claim={owners:r,key:t}}this.sessionKey=e.sessionKey,this.messageId=e.messageId,this.message=e.message,this.mentions=e.mentions,this.attachments=e.attachments,this.target={...e.target},this.agentId=e.agentId,this.gatewayUrl=e.gatewayUrl,this.recoveryScope=e.recoveryScope,this.phase=e.phase,this.createParams=e.createParams,this.retryAllowed=!0,this.restored=t,this.persistent=n}}})))()}var Ms,Ns;function Ps(){return(Ps=e((()=>{er(),ct(),dt(),l(),I(),jt(),_(),Ii(),r(),G(),ko(),es(),xs(),Cs(),Ds(),js(),L(),Ms=[0,1e3,3e3],Ns=class{constructor(e,t,n){this.read=t,this.callbacks=n,this.cloudProfilesValue=[],this.environmentsValue=null,this.cloudProfilesReadyValue=!1,this.catalogRetryingValue=!1,this.catalogRevalidationPending=!1,this.gatewaySource=null,this.gatewayClientValue=null,this.gatewayUrlValue=``,this.gatewayBootIdValue=``,this.gatewayRecoveryScopeValue=``,this.gatewayRecoveryScopeReady=!1,this.gatewayConnectedValue=!1,this.gatewayConnectionEpochValue=0,this.catalogRetryScope=``,this.catalogRetryAttempt=0,this.cloudProfileRetryAttempt=0,this.cloudProfileRefresh=null,this.handleCatalogRetry=()=>{let{context:e,data:t}=this.read();if(!this.gatewayConnectedValue||t?.group&&e?.sessions.groupsStatus()===`loading`||!t?.startTerminal&&!yo(t,e?.sessions))return;if(this.catalogRetryingValue){this.catalogRevalidationPending=!0;return}t?.group&&e?.sessions.groupsInvalidate();let n=e?.revalidate(`new-session`);n&&(globalThis.clearTimeout(this.catalogRetryTimer),this.catalogRetryTimer=void 0,this.catalogRetryingValue=!0,this.callbacks.requestUpdate(),n.catch(()=>void 0).then(()=>this.callbacks.updateComplete()).finally(()=>{this.catalogRetryingValue=!1,this.catalogRevalidationPending?(this.catalogRevalidationPending=!1,this.handleCatalogRetry()):this.retryPendingCatalogTarget(),this.callbacks.requestUpdate()}))},this.preferences=new bs(()=>({source:this.gatewaySource,client:this.gatewayClientValue,gatewayUrl:this.gatewayUrlValue,recoveryScope:this.gatewayRecoveryScopeValue,bootId:this.gatewayBootIdValue,connected:this.gatewayConnectedValue,connectionEpoch:this.gatewayConnectionEpochValue,data:this.read().data,pendingPlacementSessionKey:this.read().pendingPlacement.sessionKey,agentsHydrated:this.read().agentsHydrated}),n),this.gatewayNameTask=new nr(e,{args:()=>[this.read().isConnected&&this.gatewayConnectedValue?this.gatewaySource:null,Ai(this.read().context?.gateway.snapshot)&&document.visibilityState!==`hidden`,this.gatewayConnectionEpochValue],task:([e,t,n],{signal:r})=>Ss(e,t,r)}),new de(e).watch(()=>document,(e,t)=>(e.addEventListener(`visibilitychange`,t),()=>e.removeEventListener(`visibilitychange`,t))),this.cloudProfileTask=new nr(e,{args:()=>[this.read().isConnected&&this.gatewayConnectedValue?this.gatewayClientValue:null,this.gatewayConnectionEpochValue,Je(this.read().context?.gateway.snapshot.hello?.auth??null),this.read().isAdmin,this.gatewayRecoveryScopeValue,this.read().runtimeId],task:async([e,t,n,r,i,a])=>{if(!e)return Qn;if(!n)return{profiles:[],environments:[]};let o=await Ko(e,a);return{...o,profiles:r?o.profiles:[]}},onComplete:e=>{this.resetCloudProfileRetry(),this.environmentsValue=e.environments,this.applyCloudProfiles(e.profiles),this.cloudProfilesReadyValue=!0},onError:()=>{this.scheduleCloudProfileRetry()}})}get gatewayName(){return this.gatewayNameTask.status===$n.COMPLETE?this.gatewayNameTask.value??``:``}get cloudProfiles(){return this.cloudProfilesValue}get environments(){return this.environmentsValue}get cloudProfilesReady(){return this.cloudProfilesReadyValue}get cloudProfilesPending(){return this.cloudProfileTask.status===$n.PENDING}get deviceCatalogDisabledReason(){return this.cloudProfilesReadyValue&&this.cloudProfileTask.status===$n.COMPLETE?void 0:E(`newSession.placementNotReady`)}get catalogRetrying(){return this.catalogRetryingValue}get client(){return this.gatewayClientValue}get gatewayUrl(){return this.gatewayUrlValue}get recoveryScope(){return this.gatewayRecoveryScopeValue}get sessionCreateScope(){let e=[this.gatewayUrlValue,this.gatewayRecoveryScopeValue,this.gatewayBootIdValue];return e.every(Boolean)?JSON.stringify(e):``}get connected(){return this.gatewayConnectedValue}get connectionEpoch(){return this.gatewayConnectionEpochValue}get preferenceLoading(){return this.preferences.loading||this.identityPreferences?.mode===`loading`}resolvedGroupCategory(){let e=this.read();return At(e.context?.gateway.snapshot??{},`sessions.groups.defaults`)===!0?bo(e.data,e.context?.sessions):void 0}refreshCloudProfiles(){if(this.cloudProfileTask.status===$n.PENDING){let e=this.cloudProfileRefresh??this.cloudProfileTask.taskComplete.catch(()=>void 0).then(()=>{if(this.cloudProfileRefresh===e)return this.cloudProfileRefresh=null,this.refreshCloudProfiles()});return this.cloudProfileRefresh=e,e}return globalThis.clearTimeout(this.cloudProfileRetryTimer),this.cloudProfileRetryTimer=void 0,this.cloudProfileTask.run()}synchronize(e){let t=e.snapshot,n=t.phase===`connected`,r=this.gatewaySource===null,i=n?t.hello?.server?.bootId?.trim()??``:this.gatewayBootIdValue,a=!r&&n&&!!this.gatewayBootIdValue&&i!==this.gatewayBootIdValue,o=!r&&this.gatewayUrlValue!==e.connection.gatewayUrl,s=!r&&this.gatewaySource!==e,c=!r&&(s||this.gatewayClientValue!==t.client),l=!r&&this.gatewayConnectedValue!==n,u=n&&(c||!this.gatewayConnectedValue),d=n&&t.client?.recoveryScopeReady===!0&&!this.gatewayRecoveryScopeReady,f=n?t.hello?.auth?.recoveryScope??``:Xe({client:t.client})??``,p=!r&&this.gatewayRecoveryScopeValue!==f;if(this.gatewaySource=e,this.gatewayClientValue=t.client,this.gatewayUrlValue=e.connection.gatewayUrl,this.gatewayBootIdValue=i,this.gatewayRecoveryScopeValue=f,this.gatewayRecoveryScopeReady=t.client?.recoveryScopeReady===!0,this.gatewayConnectedValue=n,this.read().visibility===`draft`&&!this.read().canStartAsDraft&&this.callbacks.onVisibilityRetired(),o||a||c||l||p){let e=s||o||p,t=o||p;this.invalidateDiscovery(e,Os({gatewayIdentityChanged:t,placementDraftOwned:!!this.read().pendingPlacement.sessionKey}))}if(r||o||p||d||u){let e=this.read().pendingPlacement;e.gatewayUrl&&(e.gatewayUrl!==this.gatewayUrlValue||e.recoveryScope!==this.gatewayRecoveryScopeValue)&&this.callbacks.onPendingPlacementReset(),f&&(!n||t.client?.recoveryScopeReady)&&this.callbacks.onRecoveryReady(this.gatewayUrlValue,this.gatewayRecoveryScopeValue)}u&&(this.gatewayConnectionEpochValue+=1,!r&&this.read().data?.startTerminal?this.handleCatalogRetry():this.retryPendingCatalogTarget()),this.preferences.synchronize(),this.synchronizeIdentityPreferences(t.selfUser?.id),this.callbacks.requestUpdate()}invalidateDiscovery(e,t){this.cloudProfileRefresh=null,this.cloudProfileTask.run([null,-1,!1,!1,``]),this.cloudProfilesValue=[],this.cloudProfilesReadyValue=!1,e&&(this.environmentsValue=null),this.resetCloudProfileRetry(),this.callbacks.onInvalidate(e,t),this.callbacks.requestUpdate()}retryPendingCatalogTarget(){let{context:e,data:t}=this.read();if(this.catalogRetryingValue)return;if(t?.group&&e?.sessions.groupsStatus()===`loading`){globalThis.clearTimeout(this.catalogRetryTimer),this.catalogRetryTimer=void 0;return}if(!this.gatewayConnectedValue||!yo(t,e?.sessions)){globalThis.clearTimeout(this.catalogRetryTimer),this.catalogRetryTimer=void 0,this.catalogRetryScope=``,this.catalogRetryAttempt=0;return}let n=`${this.gatewayConnectionEpochValue}:${lo(t)}`;if(this.catalogRetryScope!==n&&(globalThis.clearTimeout(this.catalogRetryTimer),this.catalogRetryTimer=void 0,this.catalogRetryScope=n,this.catalogRetryAttempt=0),this.catalogRetryTimer||this.catalogRetryAttempt>=Ms.length)return;let r=Ms[this.catalogRetryAttempt];this.catalogRetryAttempt+=1,this.catalogRetryTimer=globalThis.setTimeout(()=>{this.catalogRetryTimer=void 0;let e=this.read();if(this.catalogRetryScope!==n||!this.gatewayConnectedValue||e.data?.group&&e.context?.sessions.groupsStatus()===`loading`||!yo(e.data,e.context?.sessions))return;e.data?.group&&e.context?.sessions.groupsInvalidate();let t=e.context?.revalidate(`new-session`);t&&t.catch(()=>void 0).then(()=>this.callbacks.updateComplete()).then(()=>this.retryPendingCatalogTarget())},r)}get preferenceState(){return this.identityPreferences}savePalettePreference(e){let t=this.identityPreferences,n=this.read().context?.gateway.snapshot,r=n?.client,i=n?.hello,a=n?.selfUser?.id,o=this.gatewayUrlValue;return t?.setPalettePreference(e,()=>this.identityPreferences===t&&this.gatewayConnectedValue&&this.read().context?.gateway.snapshot.client===r&&this.read().context?.gateway.snapshot.hello===i&&this.read().context?.gateway.snapshot.selfUser?.id===a&&this.read().context?.gateway.connection.gatewayUrl===o)??Promise.resolve(!1)}readPreference(e){let t=this.read();if(W(t.data)||t.data?.group||t.pendingPlacement.sessionKey)return null;let n=this.preferences.readPreference(e);if(this.callbacks.preferenceScope!==`palette`)return n;let r=this.callbacks.readPalettePreference?.();return{...n,...r?.agentId===V(e)?r.selection:{},worktreeName:``}}capturePreferenceConsumption(e,t,n){if(this.callbacks.preferenceScope!==`palette`)return this.preferences.capturePreferenceConsumption(e,t,n)}persistPreference(e,t,n){if(this.callbacks.preferenceScope!==`palette`)return this.preferences.persistPreference(e,t,n)}disconnect(){this.preferences.disconnect(),this.stopPreferences?.(),this.stopPreferences=void 0,this.identityPreferences=void 0,this.cloudProfileRefresh=null,this.gatewaySource=null,this.gatewayClientValue=null,this.gatewayConnectedValue=!1,this.gatewayConnectionEpochValue=0,this.catalogRetryScope=``,this.catalogRetryAttempt=0,globalThis.clearTimeout(this.catalogRetryTimer),this.catalogRetryTimer=void 0,this.gatewayNameTask.run([null,!1,-1]),this.cloudProfileTask.run([null,-1,!1,!1,``]),this.resetCloudProfileRetry()}applyCloudProfiles(e){let t=e.length>0&&!this.gatewayRecoveryScopeValue;this.cloudProfilesValue=t?[]:e;let n=this.read(),r=!!n.pendingPlacement.sessionKey,i=Je(n.context?.gateway.snapshot.hello?.auth??null);(!this.gatewayConnectedValue||!i)&&!r&&this.callbacks.onCloudProfileCleared(),!r&&n.cloudProfileId&&!e.some(e=>e.id===n.cloudProfileId)?this.callbacks.onCloudState(E(`newSession.catalogUnavailable`)):t?this.callbacks.onCloudState(E(`newSession.cloudRecoveryUnavailable`)):this.callbacks.onCloudState(null)}resetCloudProfileRetry(){globalThis.clearTimeout(this.cloudProfileRetryTimer),this.cloudProfileRetryTimer=void 0,this.cloudProfileRetryAttempt=0}scheduleCloudProfileRetry(){if(this.cloudProfileRetryTimer||!this.gatewayConnectedValue||!this.gatewayClientValue)return;if(this.cloudProfileRetryAttempt>=Oo.length){this.cloudProfilesReadyValue||=(this.applyCloudProfiles([]),!0);return}let e=Oo[this.cloudProfileRetryAttempt];this.cloudProfileRetryAttempt+=1,this.cloudProfileRetryTimer=globalThis.setTimeout(()=>{this.cloudProfileRetryTimer=void 0,this.gatewayConnectedValue&&this.cloudProfileTask.run()},e)}synchronizeIdentityPreferences(e){let t=this.gatewayConnectedValue?this.gatewayClientValue:null,n=this.read().context,r=n?.gateway.snapshot.hello,i=n&&At(n.gateway.snapshot,`users.prefs.get`)===!0&&At(n.gateway.snapshot,`users.prefs.set`)===!0,a=this.callbacks.preferenceScope===`palette`&&t&&r&&e&&i?ws({client:t,hello:r,profileId:e,gatewayUrl:this.gatewayUrlValue}):void 0;if(a===this.identityPreferences||(this.stopPreferences?.(),this.stopPreferences=void 0,this.identityPreferences=a,!a))return;let o=()=>{this.identityPreferences===a&&this.callbacks.requestUpdate()};this.stopPreferences=a.subscribe(o,()=>this.identityPreferences===a&&this.gatewayConnectedValue&&this.read().context?.gateway.snapshot.client===t&&this.read().context?.gateway.snapshot.hello===r&&this.read().context?.gateway.connection.gatewayUrl===this.gatewayUrlValue),a.mode!==`loading`&&o()}}})))()}function Fs(e){if(!Ua(e))return null;let t=/^[A-Za-z]:[\\/]/u.test(e)?3:1,n=e.search(/[\\/]+$/u);if(n>=0)return{directory:e.slice(0,Math.max(t,n)),prefix:``};let r=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return{directory:e.slice(0,Math.max(t,r)),prefix:e.slice(r+1)}}function Is(e,t){if(!t)return[...e];let n=t.toLowerCase(),r=[],i=[],a=[],o=[];for(let s of e){if(s.hidden&&!t.startsWith(`.`))continue;let e=s.name.toLowerCase();s.name===t?r.push(s):e===n?i.push(s):e.startsWith(n)?a.push(s):e.includes(n)&&o.push(s)}return[...r,...i,...a,...o]}function Ls(e){let{listing:t,draft:n,loading:r}=e,i=Fs(n);if(t&&La(n,t.path)||!i){let e=t?.entries??[];return{entries:e,empty:t&&e.length===0&&!r?`no-subfolders`:`none`}}if(t&&La(i.directory,t.path)){let e=Is(t.entries,i.prefix);return{entries:e,empty:e.length===0&&!r?i.prefix?`no-matches`:`no-subfolders`:`none`}}return{entries:[],empty:r?`none`:`no-matches`}}function Rs(){return(Rs=e((()=>{Ki()})))()}var zs;function Bs(){return(Bs=e((()=>{Zn(),l(),I(),Ki(),Rs(),L(),zs=class{constructor(e,t,n){this.listDirectory=e,this.requestUpdate=t,this.onListing=n,this.listing=null,this.draft=``,this.loading=!1,this.error=null,this.activeIndex=0,this.token=0,this.listingGenerationValue=0}get listingGeneration(){return this.listingGenerationValue}navigate(e){return this.cancelPending(),this.draft=e??``,this.error=null,this.loading=!0,this.requestUpdate(),this.load(e,!0,this.token)}setDraft(e){this.cancelPending(),this.draft=e,this.activeIndex=0,this.error=null;let t=Fs(e.trim());if(this.loading=!(!t||this.draftInLoadedDirectory()),t&&this.loading){let e=this.token;this.timer=globalThis.setTimeout(()=>{this.timer=void 0,this.load(t.directory,!1,e)},300)}this.requestUpdate()}draftInLoadedDirectory(){if(!this.listing)return!1;let e=this.draft.trim(),t=Fs(e);return!t||La(e,this.listing.path)||La(t.directory,this.listing.path)}moveHighlight(e){let t=this.view().entries.length;t!==0&&(this.activeIndex=(this.activeIndex+e+t)%t,this.requestUpdate())}highlightedEntry(){let e=this.view().entries;return this.activeIndex=Math.max(0,Math.min(this.activeIndex,e.length-1)),e[this.activeIndex]}completeHighlighted(){let e=this.highlightedEntry();return!e||this.draft.trim()===e.path?!1:(this.setDraft(e.path),!0)}async activate(){let e=this.usablePath();e!==null&&await this.navigate(this.highlightedEntry()?.path??(e||void 0))}usablePath(){let e=this.draft.trim();return!e||Ua(e)?e:null}reset(){this.cancelPending(),this.listing=null,this.listingGenerationValue+=1,this.draft=``,this.loading=!1,this.error=null,this.activeIndex=0}view(){let e=this.draft.trim();return Ls({listing:this.listing,draft:e,loading:this.loading})}cancelPending(){this.token+=1,globalThis.clearTimeout(this.timer),this.timer=void 0}async load(e,t,n){let r=this.listing,i=this.draft;try{let r=await this.listDirectory(e);if(n!==this.token)return;this.listing=r,this.listingGenerationValue+=1,t&&this.draft===i&&(this.draft=r.path),this.activeIndex=0,this.onListing?.(r)}catch(i){if(n!==this.token)return;t&&(this.error??=Dn(i)?.missingScope?E(`newSession.browseRequiresAdmin`):E(`newSession.browserLoadFailed`),!r&&e&&(this.draft=``,await this.load(void 0,!0,n)))}finally{n===this.token&&(this.loading=!1,this.requestUpdate())}}}})))()}function Vs(e,t,n){return A`
<span class="new-session-page__target-icon" aria-hidden="true">${e}</span>
<span class="new-session-page__trigger-label">${t}</span>
${n?A`<span class="new-session-page__trigger-summary">${n}</span>`:j}
<span
class="new-session-page__trigger-chevron new-session-page__trigger-chevron--desktop"
aria-hidden="true"
>${O.chevronDown}</span
>
<span
class="new-session-page__trigger-chevron new-session-page__trigger-chevron--mobile"
aria-hidden="true"
>${O.chevronsUpDown}</span
>
`}function Hs(){return(Hs=e((()=>{M(),k()})))()}function Us(e){let{browser:t,id:n}=e,{entries:r,empty:i}=t.view(),a=t.highlightedEntry(),o=t.usablePath(),s=e.registerProjectPath;return A`
<div
class="new-session-page__browser"
@keydown=${t=>{t.key===`Escape`&&(t.preventDefault(),t.stopImmediatePropagation(),e.onBack())}}
>
<div class="new-session-page__browser-head">
<button
type="button"
class="new-session-page__browser-nav"
title=${E(`newSession.browserUp`)}
aria-label=${E(`newSession.browserUp`)}
@click=${()=>{t.listing?.parent?t.navigate(t.listing.parent):e.onBack()}}
>
${O.arrowLeft}
</button>
<input
class="new-session-page__browser-path"
type="text"
role="combobox"
aria-expanded="true"
aria-autocomplete="list"
aria-controls=${`${n}-list`}
aria-activedescendant=${a?`${n}-option-${t.activeIndex}`:j}
aria-label=${E(`newSession.folder`)}
placeholder=${e.label}
.value=${t.draft}
@input=${e=>{t.setDraft(e.target.value)}}
@keydown=${e=>{switch(e.key){case`ArrowDown`:case`ArrowUp`:e.preventDefault(),t.moveHighlight(e.key===`ArrowDown`?1:-1),requestAnimationFrame(()=>document.getElementById(`${n}-option-${t.activeIndex}`)?.scrollIntoView({block:`nearest`}));break;case`Enter`:e.preventDefault(),t.activate();break;case`Tab`:!e.shiftKey&&t.completeHighlighted()&&e.preventDefault()}}}
/>
${t.loading?A`<span class="new-session-page__browser-loading" role="status"
>${E(`common.loading`)}</span
>`:j}
<button
type="button"
class="new-session-page__browser-nav"
title=${E(`common.close`)}
aria-label=${E(`common.close`)}
@click=${e.onClose}
>
${O.x}
</button>
</div>
${t.error?A`<div class="new-session-page__error" role="alert">${t.error}</div>`:j}
<div
class="new-session-page__browser-list"
role="listbox"
id=${`${n}-list`}
aria-label=${E(`newSession.folder`)}
>
${i===`none`?j:A`<div class="new-session-page__browser-empty">
${E(i===`no-matches`?`newSession.browserNoMatches`:`newSession.browserEmpty`)}
</div>`}
${r.map((e,r)=>A`
<button
type="button"
role="option"
id=${`${n}-option-${r}`}
aria-selected=${r===t.activeIndex}
class="new-session-page__browser-entry ${r===t.activeIndex?`new-session-page__browser-entry--active`:``} ${e.hidden?`new-session-page__browser-entry--hidden`:``}"
title=${e.hidden?E(`newSession.hiddenFolder`):j}
@click=${()=>void t.navigate(e.path)}
>
<span class="new-session-page__target-icon" aria-hidden="true">${O.folder}</span>
<span>${e.name}</span>
</button>
`)}
</div>
<div class="new-session-page__browser-actions">
${s?A`
<button
type="button"
class="new-session-page__browser-register"
?disabled=${e.registeringProject}
@click=${()=>e.onRegisterProject(s)}
>
${E(`newSession.registerProject`)}
</button>
`:j}
<button
type="button"
class="new-session-page__browser-use"
?disabled=${o===null||e.registeringProject}
@click=${()=>{o!==null&&(e.onApplyFolder(o),e.onClose())}}
>
${E(`newSession.browserUse`)}
</button>
</div>
</div>
`}function Ws(){return(Ws=e((()=>{M(),k(),l(),I(),L()})))()}function Gs(e,t,n){let r=new Map;for(let[n,i]of e.entries()){let e=t(i);r.set(e,[...r.get(e)??[],n])}let i=e.map(()=>void 0);for(let t of r.values()){if(t.length<2)continue;let r=n.at(-1);if(!r)continue;let a=n.find(n=>{let i=t.map(t=>n(e[t])??r(e[t]));return i.every(e=>e!==void 0)&&new Set(i).size===t.length})??r;for(let n of t)i[n]=a(e[n])??r(e[n])}return i}function Ks(e){let t=e.trim();return!t||t.startsWith(`-`)||/\s/u.test(t)?null:/^(?:https:\/\/|ssh:\/\/git@|git@[^:]+:)/iu.test(t)?t:null}function qs(e){return e.target instanceof HTMLInputElement?e.target.value:``}function Js(e){let t=e.folder.trim(),n=e.projects.find(t=>t.id===e.projectId),r=e.projectQuery.trim().toLowerCase(),i=r?e.projects.filter(e=>[e.displayName,e.originUrl??``,e.repoRoot??``].join(`
`).toLowerCase().includes(r)):e.projects;return{label:e.freshWorkspace?E(`newSession.newWorkspace`):n?n.displayName:e.selectedRemoteProject?.identity?e.selectedRemoteProject.identity:t?me(t):me(e.workspace)||E(`newSession.folderPlaceholder`),localProjects:i,recents:r?[]:e.recents.filter(e=>e.kind!==`project`),showWorkspace:!r||[me(e.workspace),e.workspace].join(`
`).toLowerCase().includes(r)}}function Ys(e){let t=e.folder.trim(),n=Ks(e.projectQuery),r=e.projectQuery.trim(),i=!e.browseAvailable&&!e.isAdmin,a=e.state.recents,o=Gs(a,e=>e.displayName,[e=>e.kind===`folder`?Fr(e.folder):void 0,e=>e.kind===`folder`?e.folder:void 0,e=>e.kind===`folder`?e.folder:e.url]),s=A`
<button
type="button"
class="session-menu__item"
data-value="browse"
aria-pressed="false"
aria-disabled=${i?`true`:j}
?disabled=${e.submitting||e.pendingPlacement||!e.browseAvailable&&!i}
@click=${()=>{e.browseAvailable&&!e.submitting&&!e.pendingPlacement&&e.onBrowse()}}
>
<span class="session-menu__check" aria-hidden="true"></span>
<span class="session-menu__text">${E(`newSession.browse`)}</span>
<span class="new-session-page__menu-chevron" aria-hidden="true">${O.chevronRight}</span>
</button>
`;return A`
<span class="new-session-page__select">
<button
id=${(e.idPrefix??`new-session`)+`-project-trigger`}
type="button"
class="new-session-page__trigger ${e.popoverHiding?`new-session-page__trigger--hiding`:``}"
aria-label="${E(`newSession.what`)}: ${e.state.label}"
data-project-id=${e.projectId||j}
aria-haspopup="dialog"
aria-expanded=${String(e.popoverOpen)}
?disabled=${e.submitting||e.pendingPlacement}
@click=${e.onGuardTransition}
>
${Vs(e.projectId?O.gitBranch:O.folder,e.state.label)}
</button>
</span>
<wa-popover
${pt(Or)}
class="new-session-page__select new-session-page__project-popover new-session-page__picker-popover"
for=${(e.idPrefix??`new-session`)+`-project-trigger`}
placement="bottom-start"
without-arrow
@wa-show=${e.onPopoverShow}
@wa-hide=${e.onPopoverHide}
@wa-after-hide=${e.onPopoverAfterHide}
>
${e.browserOpen?Us({browser:e.browser,id:(e.idPrefix??`new-session`)+`-place-browser`,label:e.gatewayLabel,registerProjectPath:e.registerProjectPath,registeringProject:e.registeringProject,onBack:e.onBrowserBack,onRegisterProject:e.onRegisterProject,onClose:e.onClose,onApplyFolder:e.onApplyFolder}):A`
<div class="new-session-page__picker-root">
<div class="new-session-page__menu-title">${E(`newSession.projects`)}</div>
${e.onNewWorkspace&&!r?q({value:`new-workspace`,label:E(`newSession.newWorkspace`),icon:O.folder,sub:E(`newSession.newWorkspaceDescription`),checked:e.freshWorkspace===!0,onSelect:e.onNewWorkspace},e.submitting||e.pendingPlacement):j}
${e.workspace&&e.state.showWorkspace?q({value:`workspace`,label:me(e.workspace),icon:O.folder,checked:!e.freshWorkspace&&!e.projectId&&t===e.workspace,onSelect:()=>e.onApplyFolder(e.workspace)},e.submitting):j}
<label class="new-session-page__project-search">
<span class="sr-only">${E(`newSession.projectSearchPlaceholder`)}</span>
<input
type="search"
placeholder=${E(`newSession.projectSearchPlaceholder`)}
.value=${e.projectQuery}
?disabled=${e.submitting||e.pendingPlacement}
@input=${t=>e.onProjectQueryInput(qs(t))}
@keydown=${t=>{t.key===`Enter`&&n&&e.projectAddAvailable&&(t.preventDefault(),e.onSelectRemoteProject({identity:n,cloneUrl:n}))}}
/>
</label>
${e.state.localProjects.map(t=>q({value:`project:${t.id}`,label:t.displayName,icon:O.gitBranch,checked:e.projectId===t.id,title:t.repoRoot,onSelect:()=>e.onSelectProject(t.id)},e.submitting))}
${n&&e.projectAddAvailable?q({value:`project-clone-url`,label:n,icon:O.gitBranch,sub:E(`newSession.cloneProject`),checked:e.selectedRemoteProject?.cloneUrl===n,onSelect:()=>e.onSelectRemoteProject({identity:n,cloneUrl:n})},e.submitting):j}
${!n&&r.length>=2&&e.projectSearchAvailable?A`
<div class="new-session-page__menu-title">
${E(`newSession.githubProjects`)}
</div>
${e.projectSearchCredentialMissing?A`<div class="new-session-page__menu-note">
${E(`newSession.githubTokenHint`)}
</div>`:j}
${e.projectSearchLoading?A`<div class="new-session-page__project-status" role="status">
${E(`common.loading`)}
</div>`:j}
${e.projectSearchError?A`<div class="new-session-page__project-error" role="alert">
${e.projectSearchError}
</div>`:j}
${e.remoteProjects.map(t=>q({value:`remote-project:${t.fullName}`,label:t.fullName,icon:O.gitBranch,sub:t.description??E(`newSession.cloneProject`),checked:e.selectedRemoteProject?.cloneUrl===t.cloneUrl,title:t.webUrl,onSelect:()=>e.onSelectRemoteProject({identity:t.fullName,cloneUrl:t.cloneUrl,...t.defaultBranch?{defaultBranch:t.defaultBranch}:{}})},e.submitting||!e.projectAddAvailable))}
`:j}
${e.projects.length===0&&e.canWrite&&!e.isAdmin?A`<div class="new-session-page__menu-note">
${E(`newSession.projectsAdminHint`)}
</div>`:j}
${e.state.recents.length>0?A`
<div class="new-session-page__menu-title">
${E(`newSession.recentFolders`)}
</div>
${a.map((n,r)=>q({value:n.kind===`repository`?`repository:${n.url}`:`recent:${n.folder}`,label:n.displayName,icon:n.kind===`folder`?O.folder:O.gitBranch,sub:o[r],checked:n.kind===`repository`?e.selectedRemoteProject?.cloneUrl===n.url:!e.freshWorkspace&&!e.projectId&&t===n.folder,title:n.kind===`repository`?n.url:n.folder,onSelect:()=>n.kind===`repository`?e.onSelectRemoteProject({identity:n.displayName,cloneUrl:n.url}):e.onApplyFolder(n.folder)},e.submitting))}
`:j}
${i?A`<openclaw-tooltip .content=${E(`newSession.browseRequiresAdmin`)}>
${s}
</openclaw-tooltip>`:s}
</div>
`}
</wa-popover>
`}function Xs(){return(Xs=e((()=>{M(),mt(),k(),Sr(),l(),I(),es(),Ki(),Hs(),Ws(),L()})))()}function Zs(e,t){let n=new Set,r=[];for(let i of e){let e=R(i.execCwd)??R(i.worktree?.repoRoot),a=R(i.execNode);if(e&&!a&&e!==t.workspace&&t.allowGatewayFolder(e)&&!n.has(e)&&(n.add(e),r.push({folder:e}),r.length>=4))break}return r}function Qs(){return(Qs=e((()=>{})))()}var $s;function ec(){return(ec=e((()=>{er(),ye(),jt(),Kt(),Ki(),Bs(),Xs(),Qs(),$s=class{constructor(e,t,n,r){this.host=e,this.gateway=t,this.read=n,this.callbacks=r,this.lastProjectResult=null,this.projectSelection=null,this.projectQueryValue=``,this.environmentQueryValue=``,this.debouncedProjectQuery=``,this.browserOpenValue=!1,this.browserProjectPathValue=null,this.browserRegistrationId=null,this.browserRegistrationCounter=0,this.openPopoverValue=null,this.focusRequestId=0,this.hidingPopovers=new Set,this.browser=new zs(e=>{let t=this.read().context?.gateway.snapshot;return t?.phase!==`connected`||!t.client||!this.browserOpenValue?Promise.reject(Error(`Folder browser is unavailable`)):t.client.request(`fs.listDir`,e?{path:e}:{})},this.callbacks.requestUpdate,e=>{this.browserProjectPathValue=null,this.callbacks.onApprovedListing(e);let t=this.read(),n=t.context?.gateway.snapshot.client;t.isAdmin&&n&&n.request(`worktrees.branches`,{repoRoot:e.path,includeRepositoryStatus:!0}).then(t=>{this.browser.listing===e&&t.repositoryStatus===`git`&&(this.browserProjectPathValue=e.path,this.callbacks.requestUpdate())}).catch(()=>void 0)}),e.addController({hostUpdate:()=>this.bindProjectCatalog()}),this.projectSearchTask=new nr(e,{args:()=>[this.read().context&&this.gateway.connected?this.gateway.client:null,this.read().context?kt(this.read().context?.gateway.snapshot,`projects.searchRemote`,`operator.read`):!1,this.debouncedProjectQuery,this.gateway.connectionEpoch],task:([e,t,n],{signal:r})=>!e||!t||n.length<2||Ks(n)?Qn:e.request(`projects.searchRemote`,{query:n},{signal:r})})}get projects(){return this.projectCatalog?.snapshot.result?.projects??[]}get projectsReady(){return this.projectCatalog?.snapshot.ready??!1}get projectsLoading(){return this.projectCatalog?.loading??!1}get projectRecents(){return this.projectCatalog?.snapshot.result?.recents}get githubHost(){return this.projectCatalog?.snapshot.result?.githubHost}get defaultRemoteProject(){let e=this.projectCatalog?.snapshot.result?.defaultRepository;return e?{identity:e.identity,cloneUrl:e.url,...e.ref?{defaultBranch:e.ref}:{}}:null}get defaultRemoteProjectProfileId(){return this.projectCatalog?.snapshot.result?.defaultRepository?.profileId??``}get projectId(){return this.projectSelection?.kind===`local`?this.projectSelection.id:``}get remoteProject(){return this.projectSelection?.kind===`remote`?this.projectSelection.project:null}get projectQuery(){return this.projectQueryValue}get environmentQuery(){return this.environmentQueryValue}changeEnvironmentQuery(e){this.environmentQueryValue=e,this.callbacks.requestUpdate()}get projectSearchResult(){return this.projectSearchTask.status===$n.COMPLETE&&this.debouncedProjectQuery===this.projectQueryValue.trim()?this.projectSearchTask.value??null:null}get projectSearchLoading(){return this.debouncedProjectQuery.length>=2&&this.debouncedProjectQuery===this.projectQueryValue.trim()&&this.projectSearchTask.status===$n.PENDING}get projectSearchError(){return this.projectSearchTask.status!==$n.ERROR||this.debouncedProjectQuery!==this.projectQueryValue.trim()?null:ae(this.projectSearchTask.error)}get browserOpen(){return this.browserOpenValue}get browserProjectPath(){return this.browser.loading||!this.browser.draftInLoadedDirectory()?null:this.browserProjectPathValue}get browserRegistering(){return this.browserRegistrationId!==null}popoverOpen(e){return this.openPopoverValue===e}popoverHiding(e){return this.hidingPopovers.has(e)}popoverCallbacks(e){return{popoverOpen:this.popoverOpen(e),popoverHiding:this.popoverHiding(e),onGuardTransition:t=>this.guardPopoverTransition(t,e),onPopoverShow:()=>this.onPopoverShow(e),onPopoverHide:()=>this.onPopoverHide(e),onPopoverAfterHide:()=>this.onPopoverAfterHide(e)}}bindProjectCatalog(){let e=this.gateway.connected?this.read().context?.gateway:void 0;if(e===this.projectCatalogGateway)return;this.projectCatalogCleanup?.(),this.projectCatalogGateway=e,this.projectCatalog=e?zt(e):void 0,this.lastProjectResult=null;let t=()=>{let e=this.projectCatalog?.snapshot.result??null;e&&e!==this.lastProjectResult&&(this.lastProjectResult=e,this.projectId&&!e.projects.some(e=>e.id===this.projectId)&&this.callbacks.onProjectMissing()),this.callbacks.requestUpdate()};this.projectCatalogCleanup=this.projectCatalog?.subscribe(t),t()}async refreshProjects(e=!1){this.bindProjectCatalog(),await this.projectCatalog?.refresh(e)}selectedProject(){return this.projects.find(e=>e.id===this.projectId)??(this.gateway.connected?void 0:this.selectedProjectRecord)}selectProject(e){this.projectSelection=e,this.selectedProjectRecord=this.projects.find(e=>e.id===this.projectId)}recordRemoteProjectId(e,t){let n=this.remoteProject;n?.cloneUrl===e&&(this.projectSelection={kind:`remote`,project:{...n,projectId:t}})}clearProjectSelection(){this.projectSelection=null,this.selectedProjectRecord=void 0}resolveProjectRecents(e){let t=t=>e.isAdmin||xi(e.workspaceRoots,t);return this.projectRecents?.filter(e=>e.kind===`project`?this.projects.some(t=>t.id===e.projectId):e.kind===`repository`||!e.execNode&&t(e.folder))??Zs(e.sessions,{workspace:e.workspace,allowGatewayFolder:t}).map(e=>({kind:`folder`,folder:e.folder,displayName:me(e.folder)}))}changeProjectQuery(e){this.projectQueryValue=e,this.clearProjectSearchTimer(),this.debouncedProjectQuery=``,this.projectSearchTask.run([null,!1,``,this.gateway.connectionEpoch]);let t=e.trim(),n=this.read().context;if(t.length<2||Ks(t)||!this.gateway.connected||!this.gateway.client||!n||!kt(n.gateway.snapshot,`projects.searchRemote`,`operator.read`)){this.callbacks.requestUpdate();return}let r=this.gateway.client,i=this.gateway.connectionEpoch;this.projectSearchTimer=globalThis.setTimeout(()=>{this.projectSearchTimer=void 0,r===this.gateway.client&&i===this.gateway.connectionEpoch&&(this.debouncedProjectQuery=t,this.projectSearchTask.run([r,!0,t,i]),this.callbacks.requestUpdate())},300),this.callbacks.requestUpdate()}resetProjectSearch(){this.clearProjectSearchTimer(),this.projectQueryValue=``,this.debouncedProjectQuery=``,this.callbacks.requestUpdate()}resetProjects(e=!0){this.projectCatalog&&this.refreshProjects(!0),e&&(this.clearProjectSelection(),this.resetProjectSearch())}close(){this.resetBrowser(!0);for(let e of[`where`,`project`,`checkout`]){let t=this.callbacks.querySelector(`.new-session-page__${e}-popover`);t&&(t.open=!1)}}showRoot(){let e=this.browserOpenValue;this.resetBrowser(!1),e&&this.focusProjectView(`[data-value="browse"]`)}selectGatewayBrowser(e){this.browserOpenValue=!0,this.loadBrowser(e&&Ua(e)?e:void 0),this.focusProjectView(`.new-session-page__browser-path`)}loadBrowser(e){let t=this.read().context?.gateway.snapshot;t?.phase===`connected`&&t.client&&this.browserOpenValue&&(this.browserProjectPathValue=null,this.browser.navigate(e))}async registerBrowserProject(e){let t=this.read(),n=t.context?.gateway.snapshot,r=n?.client;if(n?.phase!==`connected`||!r||!t.isAdmin||this.browserProjectPath!==e||this.browserRegistering)return;let i=this.browser.listingGeneration,a=++this.browserRegistrationCounter;this.browserRegistrationId=a;let o=()=>this.browserRegistrationId===a&&this.browser.listingGeneration===i&&this.browserProjectPath===e&&r===this.gateway.client;this.browser.error=null,this.callbacks.requestUpdate();try{let t=await r.request(`projects.register`,{path:e});if(!o()||(await this.refreshProjects(!0),!o()))return;this.callbacks.onSelectProject(t.id),this.close()}catch(e){o()&&(this.browser.error=ae(e))}finally{this.browserRegistrationId===a&&(this.browserRegistrationId=null,this.callbacks.requestUpdate())}}onPopoverShow(e){this.openPopoverValue=e,e===`where`&&(this.environmentQueryValue=``),e===`project`?this.showRoot():this.callbacks.requestUpdate()}onPopoverHide(e){this.openPopoverValue===e&&(this.openPopoverValue=null),this.hidingPopovers.add(e),e===`project`?this.showRoot():this.callbacks.requestUpdate()}onPopoverAfterHide(e){this.hidingPopovers.delete(e),this.restorePopoverTrigger(`${this.callbacks.pickerIdPrefix??`new-session`}-${e}-trigger`,`.new-session-page__${e}-popover`),this.callbacks.requestUpdate()}guardPopoverTransition(e,t){this.hidingPopovers.has(t)&&(e.preventDefault(),e.stopImmediatePropagation())}clearPopoverHiding(){this.hidingPopovers.clear(),this.callbacks.requestUpdate()}disconnect(){this.focusRequestId+=1,this.environmentQueryValue=``,this.browser.reset(),this.clearProjectSearchTimer(),this.projectCatalogCleanup?.(),this.projectCatalogCleanup=void 0,this.projectCatalogGateway=void 0,this.projectCatalog=void 0,this.projectSearchTask.run([null,!1,``,-1])}resetBrowser(e){this.focusRequestId+=1,this.browser.reset(),this.browserOpenValue=!1,this.browserProjectPathValue=null,this.browserRegistrationId=null,e&&(this.openPopoverValue=null),this.callbacks.requestUpdate()}clearProjectSearchTimer(){globalThis.clearTimeout(this.projectSearchTimer),this.projectSearchTimer=void 0}focusProjectView(e){let t=++this.focusRequestId,n=this.callbacks.activeElement();this.host.updateComplete.then(()=>{if(t!==this.focusRequestId||this.openPopoverValue!==`project`||this.hidingPopovers.has(`project`))return;let r=this.callbacks.activeElement();if(r&&r!==n&&r!==this.callbacks.body())return;let i=this.callbacks.querySelector(`.new-session-page__project-popover`)?.querySelector(e);i?.isConnected&&i.focus({preventScroll:!0})})}restorePopoverTrigger(e,t){let n=this.callbacks.activeElement(),r=this.callbacks.querySelector(t),i=this.callbacks.body();(!n||n===i||r?.contains(n))&&this.callbacks.querySelector(`#${e}`)?.focus()}}})))()}function tc(e){if(e.connected)return;let t=e.environment;if(t?.lastConnectedAtMs===void 0)return E(`newSession.neverConnected`);if(t.lastDisconnectedAtMs!==void 0){let n=yn(Math.max(0,e.nowMs-t.lastDisconnectedAtMs))??E(`common.justNow`);return E(`newSession.offlineFor`,{duration:n})}let n=t.lastSeenAtMs??t.lastConnectedAtMs;return E(`newSession.lastSeen`,{time:De(n)})}function nc(e,t={}){let n=e?.issues?.find(e=>e.code===`update-required`),r=e?.issues?.find(e=>e.code===`worker-host-unavailable`),i=tc({environment:e,connected:t.connected??!0,nowMs:t.nowMs??Date.now()}),a=n?E(`newSession.nodeUpdateRequired`,{updateCommand:n.updateCommand,restartCommand:n.headlessReconnectCommand}):r?.message??i,o=a?[a]:[];e?.platform&&o.push(Qt(e.platform));for(let t of rc(e?.capabilities))if(o.includes(t)||o.push(t),o.length>=4)break;return o}function rc(e=[]){return[...new Set(e.flatMap(e=>{let t=e.split(`.`,1)[0]?.toLowerCase(),n=Object.entries(ic).find(([e])=>e===t)?.[1];return n?[E(n)]:[]}))]}var ic;function ac(){return(ac=e((()=>{l(),I(),vn(),ee(),Lt(),L(),ic={camera:`newSession.capabilityCamera`,location:`newSession.capabilityLocation`,talk:`newSession.capabilityTalk`,screen:`newSession.capabilityScreenCapture`,canvas:`newSession.capabilityCanvas`,microphone:`newSession.capabilityVoice`,voice:`newSession.capabilityVoice`}})))()}function oc(e,t){let n=e.issues?.find(e=>e.code===`update-required`);if(n)return E(`newSession.nodeUpdateRequired`,{updateCommand:n.updateCommand,restartCommand:n.headlessReconnectCommand});let r=e.issues?.find(e=>e.code===`worker-host-unavailable`);if(r)return r.message;if(e.status!==`available`)return E(`newSession.deviceUnavailable`);if(e.sessionHost!==!0)return E(`newSession.sessionHostingDisabled`);if(t.requiredNodeCommands.length>0){let t=e.requiredNodeCommand;if(!t)return E(`newSession.placementNotReady`);if(t.state!==`invocable`&&t.message)return t.message;if(t.state===`pending-approval`)return E(`newSession.nodeCommandPendingApproval`,{command:t.command});if(t.state===`undeclared`)return E(`newSession.nodeCommandUndeclared`,{command:t.command});if(t.state===`unauthorized`)return E(`newSession.nodeCommandUnauthorized`,{command:t.command})}if(t.consumesWorkerSlot)return e.workerSlots?Dt(e.workerSlots)===0?E(`newSession.deviceNoSlots`):void 0:E(`newSession.deviceCapacityUnavailable`)}function sc(e,t=uc,n){let r=(e??[]).flatMap(e=>{if(e.type!==`node`||!e.id.startsWith(`node:`))return[];let r=e.id.slice(5).trim();if(!r)return[];let i=n??oc(e,t),a=nc(e,{connected:e.status===`available`}),o=+((e.issues?.length??0)>0||e.status!==`available`),s=i&&!a.includes(i)?[...a.slice(0,o),i,...a.slice(o)].slice(0,4):a;return[{deviceId:r,label:e.label??r,platform:e.platform,hideDetails:!n&&e.status===`unavailable`&&!e.issues?.length,remediation:n?void 0:e.issues?.some(e=>e.code===`update-required`)?`update-device`:e.status===`available`&&e.sessionHost!==!0&&!e.issues?.length?`enable-session-hosting`:void 0,facts:n?[n]:s,workerSlots:e.workerSlots,capabilities:e.capabilities,invocableCommands:e.invocableCommands,selectable:i===void 0,...i?{disabledReason:i}:{}}]}).toSorted((e,t)=>e.label.localeCompare(t.label)||e.deviceId.localeCompare(t.deviceId)),i=Gs(r,e=>e.label,[e=>e.deviceId.slice(0,8)]);return r.forEach((e,t)=>{let n=i[t];n&&(r[t]={...e,subtitle:n})}),r}function cc(e,t,n){if(n)return n;let r=new Set((e??[]).filter(e=>e.type===`node`&&e.sessionHost===!0).map(e=>e.id));if(r.size===0){let t=(e??[]).find(e=>e.issues?.some(e=>e.code===`update-required`||e.code===`worker-host-unavailable`));return t?oc(t,uc):E(`newSession.noSessionHosts`)}return t.some(e=>e.selectable)?void 0:t.find(e=>r.has(`node:${e.deviceId}`))?.disabledReason}function lc(e,t,n){let r=e.find(e=>e.deviceId===n.deviceId);return{ready:n.autoDevice?e.some(e=>e.selectable):!n.deviceId||r?.selectable===!0,disabledReason:n.autoDevice?cc(t,e):n.deviceId?r?.disabledReason??E(`newSession.nodeUnavailable`):void 0}}var uc;function dc(){return(dc=e((()=>{Tt(),l(),I(),ac(),L(),uc={requiredNodeCommands:[],consumesWorkerSlot:!0}})))()}var fc;function pc(){return(pc=e((()=>{Go(),fc=class{constructor(){this.overrides=new Map}clear(){this.overrides.clear()}applyPending(e,t,n){t||n?this.overrides.set(e,{machineClass:t,os:n}):this.overrides.delete(e)}resolve(e){return this.overrides.get(e)?.machineClass??``}resolveOs(e){return this.overrides.get(e)?.os??``}selection(e,t){let n=t.find(t=>t.id===e),r=this.resolveOs(e)||n&&Ro(n)||``;return{machineClass:this.resolve(e)||n&&Bo(n,r)?.id||``,os:r}}selectedOs(e){return this.resolveOs(e.id)||Ro(e)}machines(e){return zo(e,this.selectedOs(e))}selectOs(e,t,n,r=!1,i){let a=n.find(t=>t.id===e),o=a?.operatingSystems?.find(e=>e.id===t);if(r||!a||!o||o.disabledReason)return!1;let s=this.resolve(e);return this.applyPending(e,zo(a,o.id).some(e=>e.id===s)?s:void 0,o.id),i?.(),!0}select(e,t,n,r=!1,i){let a=n.find(t=>t.id===e),o=a&&this.machines(a).find(e=>e.id===t);return r||!o?!1:(this.applyPending(e,o.id,this.selectedOs(a)),i?.(),!0)}}})))()}function mc(){return{preferredWhereRestore:null,preferredProjectRestore:``,preferredRemoteProjectRestore:null,configuredDefaultRepositoryPending:!1,configuredDefaultRepositoryOptOut:!1,whereSelectedByUser:!1,projectSelectedByUser:!1}}function hc(e,t){e.projectSelectedByUser=!0,e.preferredProjectRestore=``,e.preferredRemoteProjectRestore=null,e.configuredDefaultRepositoryPending=!1,e.configuredDefaultRepositoryOptOut=t}function gc(e,t,n,r){let i=n||r;if(!e.whereSelectedByUser){let n=i?void 0:t?.where;e.preferredWhereRestore=n?.kind===`local`?null:n??null}e.preferredProjectRestore=i?``:t?.projectId??``,e.preferredRemoteProjectRestore=i?null:t?.remoteProject??null,e.configuredDefaultRepositoryOptOut=t?.defaultRepositoryOptOut===!0,e.configuredDefaultRepositoryPending=!i&&!e.configuredDefaultRepositoryOptOut&&!t?.projectId&&!t?.remoteProject,e.preferredRemoteProjectRestore&&(e.preferredProjectRestore=``),e.projectSelectedByUser=!1}function _c(e,t,n){return t&&!(e.configuredDefaultRepositoryPending&&n)&&e.preferredWhereRestore===null&&!e.preferredProjectRestore&&!e.preferredRemoteProjectRestore}function vc(e){let{state:t,browser:n,where:r}=e;return{workspace:e.workspace,folder:e.folder,projectId:t.preferredProjectRestore||n.projectId,remoteProject:t.preferredRemoteProjectRestore??n.remoteProject,defaultRepositoryOptOut:t.configuredDefaultRepositoryOptOut,where:r,worktree:(r.kind!==`local`||e.preferenceWorktree)&&!e.remoteRepository,freshWorkspace:e.freshWorkspace,baseRef:e.baseRef,worktreeName:e.worktreeName}}function yc(e){let{state:t,browser:n,gateway:r,modelControl:i,repositoryState:a,isAdmin:o,persistPreference:s,requestUpdate:c,setDeviceId:l,setAutoDevice:u,setCloudProfileId:d,setFreshWorkspace:f,setFolderSelectedByUser:p}=e,m=!1,h=t.whereSelectedByUser?null:t.preferredWhereRestore,g=t.projectSelectedByUser?``:t.preferredProjectRestore,_=t.preferredRemoteProjectRestore,v=n.remoteProject;if((_||v)&&n.projectsReady&&n.githubHost){let e=e=>Qa(e.cloneUrl,n.githubHost)!==null,r=_&&!e(_),i=v&&!e(v);(r||i)&&(r&&(t.preferredRemoteProjectRestore=null),i&&(n.clearProjectSelection(),t.projectSelectedByUser=!1),(i||r&&!v&&!n.projectId)&&a.clearDetails(!0),t.configuredDefaultRepositoryPending=!t.configuredDefaultRepositoryOptOut&&!g,s({remoteProject:t.preferredRemoteProjectRestore??n.remoteProject??null}),m=!0)}let y=n.defaultRemoteProject,b=n.defaultRemoteProjectProfileId,x=b?r.cloudProfiles.find(e=>e.id===b):void 0,S=!!(y&&t.preferredRemoteProjectRestore?.cloneUrl===y.cloneUrl),ee=t.configuredDefaultRepositoryPending||S,C=ee&&n.projectsReady&&(!b||r.cloudProfilesReady),w=!!(C&&(!b||o()&&x&&!i.cloudRuntimeUnsupportedReason(x))),T=t.projectSelectedByUser||!n.projectsReady?null:S?C&&w?t.preferredRemoteProjectRestore:null:t.preferredRemoteProjectRestore??(w?y:null);if(C&&(t.configuredDefaultRepositoryPending=!1,S&&!w&&(t.preferredRemoteProjectRestore=null,m=!0),c()),T){let r=ee&&T.cloneUrl===y?.cloneUrl;b&&r&&w&&!t.whereSelectedByUser&&!h&&e.where.kind===`local`&&(l(``),u(!1),d(b)),n.selectProject({kind:`remote`,project:T}),f(!1),p(!1),(r&&!S||!a.baseRef&&T.defaultBranch)&&a.setBaseRef(T.defaultBranch??``,!1),t.preferredRemoteProjectRestore=null,m=!0}if(g&&!T){let e=n.projects.find(e=>e.id===g);e?(n.selectProject({kind:`local`,id:e.id}),p(!1),t.preferredProjectRestore=``,m=!0):n.projectsReady&&(t.preferredProjectRestore=``,m=!0)}if((h?.kind===`device`||h?.kind===`auto-device`)&&r.cloudProfilesReady)u(h.kind===`auto-device`),l(h.kind===`device`?h.id:``),d(``),t.preferredWhereRestore=null,m=!0;else if(h?.kind===`cloud`&&r.cloudProfilesReady){let e=r.cloudProfiles.find(e=>e.id===h.id);o()&&e&&!i.cloudRuntimeUnsupportedReason(e)?(l(``),u(!1),d(h.id)):(d(``),s({where:{kind:`local`}})),t.preferredWhereRestore=null,m=!0}m&&(a.synchronize(),c())}function bc(){return(bc=e((()=>{Za()})))()}function xc(e){if(e.remoteProject)return{kind:`pending-clone`,cloneUrl:e.remoteProject.cloneUrl};let t=e.selectedProject?.repoRoot??(e.folder.trim()||e.workspace);return!t||e.selectedProject&&!e.selectedProject.repoRoot?{kind:`idle`}:!e.selectedProject&&t===e.workspace&&!e.workspaceGit?{kind:`direct`,repoRoot:t}:{kind:`checking`,repoRoot:t}}var Sc;function Cc(){return(Cc=e((()=>{_(),Sc=class{constructor(e,t){this.read=e,this.callbacks=t,this.worktreeValue=!1,this.worktreeNameValue=``,this.repositoryValue={kind:`idle`},this.requestToken=0,this.selectionRevision=0,this.preferredWorktreeRestore=!1,this.worktreeSelectedByUser=!1,this.baseRefSelectedByUser=!1,this.nameSelectedByUser=!1}get worktree(){return this.worktreeValue}get preferenceWorktree(){return this.worktreeValue||this.preferredWorktreeRestore}get worktreeName(){return this.worktreeNameValue}get baseRef(){return this.baseRefOverride??``}get remoteRepository(){let{remotePlacement:e,remoteProject:t}=this.read();if(!e||!t)return;let n=this.baseRef.trim();return{url:t.cloneUrl,...n?{ref:n}:{}}}get repository(){return this.repositoryValue}get preferenceReady(){return!this.preferredWorktreeRestore}get hasUserSelection(){return this.worktreeSelectedByUser||this.baseRefSelectedByUser||this.nameSelectedByUser}adoptPreference(e){if(this.worktreeSelectedByUser||(this.worktreeValue=!1,this.preferredWorktreeRestore=e?.worktree===!0&&(!e.where||e.where.kind===`local`)),!this.baseRefSelectedByUser){let t=e?.baseRef||void 0;this.baseRefOverride!==t&&(this.selectionRevision+=1),this.baseRefOverride=t}if(!this.nameSelectedByUser){let t=e?.worktreeName??``;this.worktreeNameValue!==t&&(this.selectionRevision+=1),this.worktreeNameValue=t}this.matchesCurrentRepo()?this.repositoryValue.kind!==`checking`&&this.adoptResolvedRepository(this.repositoryValue):this.invalidate()}reset(){this.invalidate(),this.worktreeValue=!1,this.clearDetails(),this.preferredWorktreeRestore=!1,this.worktreeSelectedByUser=!1}clearDetails(e=!1){this.selectionRevision+=1,this.baseRefOverride=void 0,this.worktreeNameValue=``,this.baseRefSelectedByUser=!1,this.nameSelectedByUser=!1,e&&this.callbacks.persistPreference({baseRef:``,worktreeName:``})}invalidate(){this.requestToken+=1,this.repositoryValue={kind:`idle`}}selectWorktree(e,t=!0){this.selectionRevision+=1,this.preferredWorktreeRestore=!1,this.worktreeSelectedByUser=!0,this.worktreeValue=e,t&&this.clearDetails(!0)}rejectPreferredWorktree(){this.preferredWorktreeRestore=!1,this.worktreeValue=!1,this.clearDetails(!0)}select(e){return this.worktreeValue===e||this.read().remotePlacement||e&&!this.available()?!1:(this.selectWorktree(e,!1),this.callbacks.persistPreference({folder:this.read().folder.trim()||this.read().workspace,worktree:this.worktreeValue}),this.callbacks.requestUpdate(),!0)}setBaseRef(e,t){t||(this.selectionRevision+=1,this.baseRefOverride=e,this.baseRefSelectedByUser=!0,this.callbacks.persistPreference({baseRef:e}),this.callbacks.requestUpdate())}setWorktreeName(e,t){t||(this.selectionRevision+=1,this.worktreeNameValue=e,this.nameSelectedByUser=!0,this.callbacks.persistPreference({worktreeName:e}),this.callbacks.requestUpdate())}captureSubmittedName(e,t){let n=e.worktreeName?.trim();if(!e.worktree||!n)return;let r=this.selectionRevision,i=this.read(),a=V(t.agentId),o=i.agents.find(e=>V(e.id)===a),s={agentId:a,workspace:R(o?.workspace)??``},c=s.agentId===i.agentId,l=this.callbacks.capturePreferenceConsumption(s,{worktreeName:n,...t.recovered?{}:{selectedBaseRef:this.baseRefOverride?.trim()??``},folder:e.cwd??(c&&i.folder.trim()||s.workspace),baseRef:e.worktreeBaseRef??(c?this.baseRef:void 0),projectId:e.projectId??(c?i.selectedProject?.id:void 0)});return l&&(()=>l(()=>{s.agentId===this.read().agentId&&r===this.selectionRevision&&n===this.worktreeNameValue.trim()&&(this.selectionRevision+=1,this.worktreeNameValue=``,this.nameSelectedByUser=!0,this.callbacks.requestUpdate())}))}available(){let e=this.repositoryValue;return e.kind===`git`||e.kind===`pending-clone`}matchesCurrentRepo(){let e=this.read(),t=this.repositoryValue;if(t.kind===`pending-clone`)return e.remoteProject?.cloneUrl===t.cloneUrl;if(t.kind===`idle`||e.remoteProject)return!1;let n=e.selectedProject?.repoRoot??(e.folder.trim()||e.workspace);return t.repoRoot===n}load(){let e=++this.requestToken,t=this.read(),n=xc(t);if(n.kind!==`checking`)return this.adoptResolvedRepository(n);let r=t.gateway?.client;if(t.gateway?.phase!==`connected`||!r)return this.adoptResolvedRepository({kind:`idle`});let{repoRoot:i}=n;this.repositoryValue=n,r.request(`worktrees.branches`,{repoRoot:i,includeRepositoryStatus:!0}).then(t=>{e===this.requestToken&&this.adoptResolvedRepository(t?.repositoryStatus===`git`?{kind:`git`,repoRoot:i,branches:t.branches,...t.defaultBranch?{defaultBranch:t.defaultBranch}:{},...t.headBranch?{headBranch:t.headBranch}:{},...t.branchesUnavailable?{branchesUnavailable:!0}:{}}:{kind:t?.repositoryStatus===`not_git`?`direct`:`unavailable`,repoRoot:i})}).catch(()=>{e===this.requestToken&&this.adoptResolvedRepository({kind:`unavailable`,repoRoot:i})})}synchronize(){this.matchesCurrentRepo()||this.load()}adoptResolvedRepository(e){if(this.repositoryValue=e,e.kind===`direct`){let e=this.worktreeValue||this.preferredWorktreeRestore;this.worktreeValue=!1,e&&!this.read().remotePlacement&&this.callbacks.persistPreference({worktree:!1})}else this.preferredWorktreeRestore&&!this.worktreeSelectedByUser&&(this.worktreeValue=!0);this.preferredWorktreeRestore=!1,this.callbacks.requestUpdate()}}})))()}function wc(e){return e instanceof Ge&&e.gatewayCode===`INVALID_REQUEST`&&/^(?:Error:\s+)?(?:ENOENT|ENOTDIR):/u.test(e.message)}var Tc;function Ec(){return(Ec=e((()=>{Ke(),Tc=class{constructor(e,t){this.read=e,this.callbacks=t,this.state=`none`,this.requestToken=0,this.approvedRoots=[]}knownWorkspaceRoots(e){return e?[e,...this.approvedRoots]:this.approvedRoots}recordApprovedListing(e){if(this.read().isAdmin)return;let t=new Set(this.approvedRoots);t.add(e.path),e.parent&&t.add(e.parent),t.size!==this.approvedRoots.length&&(this.approvedRoots=[...t],this.callbacks.onApprovedRootsChange())}reset(){this.cancel(),this.approvedRoots=[]}get blocked(){return this.state!==`none`}cancel(){this.requestToken+=1,this.state=`none`}restore(){this.state=`none`,this.callbacks.onMissing()}validate(e){let t=this.read().gateway,n=t?.client;if(t?.phase!==`connected`||!n){this.restore();return}let r=++this.requestToken;this.state=`checking`;let i=()=>{let t=this.read();return r===this.requestToken&&!t.selectedByUser&&t.folder===e};n.request(`fs.listDir`,{path:e}).then(e=>{i()&&(this.recordApprovedListing(e),this.state=`none`,this.callbacks.onVerified())}).catch(e=>{if(i()){if(!this.read().isAdmin||wc(e)){this.restore();return}this.state=`failed`,this.callbacks.onFailed()}})}}})))()}function Dc(){return{catalog:[],hasSnapshot:!1,status:`idle`}}function Oc(e){let{model:t,selection:n,metadata:r,agent:i,defaults:a}=e,o=r.modelSelectionPolicy,s=o?.restricted?o.defaultModel??void 0:i?.model?.primary,c=J(o?.restricted?o.defaultModel:s??a?.model,o?.restricted||s?void 0:a?.modelProvider,r.catalog),l=J(t,void 0,r.catalog,n.agentRuntime),u=l?.entry??c?.entry;return{defaultTarget:c,agentDefaultModel:s,modelCatalogState:{hasSnapshot:i!==void 0&&r.hasSnapshot,initialized:!r.retired&&(r.initialized??r.hasSnapshot),refreshFailed:r.refreshFailed,pendingProviders:r.pendingProviders,modelSelectionPolicy:o,retired:r.retired,status:!i&&r.status!==`error`?`loading`:r.status},contextWindowTarget:kc(u,n.contextWindow),fastModeTarget:{agentRuntime:u?.agentRuntime,model:l?.model??c?.model,modelProvider:l?.provider??c?.provider??void 0,fastMode:n.fastMode,effectiveFastMode:n.fastMode??u?.effectiveFastMode},thinkingDefaults:jc(c,o?.restricted?void 0:i,o?.restricted?void 0:a,r.catalog),thinkingSession:Ac(l,void 0,n)}}function kc(e,t){let n=t||e?.contextWindowDefault;return e?.contextWindows&&n?{contextWindow:n,contextWindows:e.contextWindows,...e.contextWindowDefault?{contextWindowDefault:e.contextWindowDefault}:{}}:void 0}function Ac(e,t,n){let r=n?.agentRuntime?e?.entry:void 0;return{model:e?.model??t?.model?.primary,modelProvider:e?.provider??void 0,agentRuntime:t?.agentRuntime??e?.entry?.agentRuntime,thinkingLevels:t?.thinkingLevels??r?.thinkingLevels,thinkingOptions:t?.thinkingOptions,thinkingDefault:t?.thinkingDefault??r?.thinkingDefault,thinkingLevel:n?.thinkingLevel||void 0}}function jc(e,t,n,r){let i=Ht(Ac(e,t),n,r);return{modelProvider:e?.provider??null,model:e?.model??null,contextTokens:n?.contextTokens??null,agentRuntime:i?.agentRuntime,thinkingLevels:i?.thinkingLevels,thinkingDefault:i?.thinkingDefault}}function J(e,t,n,r){let i=we(e,t,n);if(!i)return null;let a=i.toLowerCase(),o=n.find(e=>w(e.id,e.provider).toLowerCase()===a);if(o)return{entry:ln(o,r),model:o.id,provider:se(o.provider)||null};let s=i.indexOf(`/`);return s>0?{model:i.slice(s+1),provider:se(i.slice(0,s))||null}:{model:i,provider:se(t??``)||null}}function Mc(e){let{metadata:t,agent:n}=e;if(!t.hasSnapshot||t.status===`offline`)return;let r=t.modelSelectionPolicy,i=e.model||(r?.restricted?r.defaultModel??void 0:n?.model?.primary);return e.agentRuntime?J(i,void 0,t.catalog,e.agentRuntime)?.entry?.unavailableReason:Rt(i,void 0,t.catalog)}function Nc(e,t,n){let r=J(e.model,void 0,t,n);return r?.entry?.available===!0&&r.entry.manualSelectionAllowed!==!1&&r.provider===e.provider}function Pc(e){let{metadata:t,model:n,agentRuntime:r}=e;if(t.retired||e.initialModelPending||!t.hasSnapshot&&(n||r))return E(t.status===`error`?`chat.modelControls.modelsUnavailable`:`chat.modelControls.loadingModels`);if(t.modelSelectionPolicy?.restricted&&!n&&!t.modelSelectionPolicy.defaultModel)return E(t.catalog.length?`chat.modelControls.selectionRequired`:`chat.modelControls.noPermittedModels`);if(r&&t.hasSnapshot&&!J(n,void 0,t.catalog,r)?.entry)return E(`chat.modelControls.modelsUnavailable`);let i=tn(Mc(e));if(e.accountSelected){if(t.status===`error`)return E(`chat.modelControls.modelsUnavailable`);if(e.metadataPending||!t.hasSnapshot)return E(`chat.modelControls.loadingModels`);if(!e.accountReady)return i??E(`chat.modelControls.modelsUnavailable`)}return i}function Fc(e){if(e.retired)return;let t=e.modelSelectionPolicy,n=e.model||(t?.restricted?t.defaultModel??``:``),r;if(n)r=J(n,void 0,e.catalog,e.agentRuntime)?.entry?.agentRuntime;else if(!t?.restricted){let t=e.agent?.model?.primary;r=J(t??e.defaults?.model,t?void 0:e.defaults?.modelProvider,e.catalog)?.entry?.agentRuntime??e.agent?.agentRuntime??e.defaults?.agentRuntime}let i=r?.id.trim();if(r&&i&&i!==`auto`&&i!=="default")return i===r.id?r:{...r,id:i}}function Ic(e){let t=e.model.trim(),n=t?J(t,void 0,e.catalog,e.agentRuntime):null;if(t&&(!n?.entry||n.entry.available===!1||n.entry.manualSelectionAllowed===!1))return{model:``,thinkingLevel:``,repaired:!0};let r=n?.entry?w(n.entry.id,n.entry.provider):``,i=e.modelSelectionPolicy,a=i?.restricted?void 0:e.agent,o=i?.restricted?void 0:e.defaults,s=i?.restricted?i.defaultModel:a?.model?.primary,c=r?null:J(s??o?.model,s?void 0:o?.modelProvider,e.catalog),l=(n??c)?.provider,u=n?.entry??c?.entry,d=u?.supportsFastMode??(!l||nn(l))?e.fastMode:void 0,f={model:r,...r&&e.agentRuntime?{agentRuntime:e.agentRuntime}:{},fastMode:d},p=d!==e.fastMode;if(!e.thinkingLevel)return{...f,thinkingLevel:``,repaired:p};let m=Ht(Ac(n??c,r?void 0:a,{agentRuntime:e.agentRuntime}),r?void 0:o,e.catalog)?.thinkingLevels,h=Ut(e.thinkingLevel),g=m?.some(e=>Ut(e.id)===h);return u?.reasoning===!1||m!==void 0&&!g?{...f,thinkingLevel:``,repaired:!0}:{...f,thinkingLevel:e.thinkingLevel,repaired:p}}function Lc(e){return e&&!e.devicePlacement?E(`newSession.deviceRuntimeUnsupported`):void 0}function Rc(e,t){return e?.cloudPlacementSupported===!1?E(`newSession.cloudRuntimeUnsupported`,{runtime:e.id}):e&&t&&e.cloudPlacementExecutionMode&&!Po(t,e.cloudPlacementExecutionMode)?E(`newSession.cloudProfileRuntimeUnsupported`,{runtime:e.id}):void 0}function zc(){return(zc=e((()=>{l(),It(),I(),m(),Sn(),Pt(),Go(),L(),sn()})))()}var Bc;function Vc(){return(Vc=e((()=>{zc(),Bc=class{constructor(e){this.onSelectionChange=e,this.explicitSelection=!1,this.restoredSelection=!1,this.fastModeSelected=!1,this.selected=``,this.contextWindow=``,this.thinkingLevel=``}resetSelection(e=``){this.selected=e,this.agentRuntime=void 0,this.contextWindow=``,this.thinkingLevel=``,this.fastMode=void 0,this.explicitSelection=!1,this.restoredSelection=!1,this.fastModeSelected=!1}applyModelSelection(e){this.selected=e.model,this.agentRuntime=e.agentRuntime,this.thinkingLevel=e.thinkingLevel,this.fastMode=e.fastMode}draftSelection(e){return this.explicitSelection?{agentId:e,model:this.selected,agentRuntime:this.agentRuntime,thinkingLevel:this.thinkingLevel}:void 0}preferenceForDraft(e,t){let n=this.fastModeSelected||e===void 0?this.fastMode:e?.fastMode;return this.explicitSelection?{model:this.selected,agentRuntime:this.agentRuntime,thinkingLevel:this.thinkingLevel,fastMode:n}:t.initialModel?t.initialModelPending?{model:t.initialModel}:void 0:t.policy===`configured`||t.policy===null?{fastMode:n}:this.fastModeSelected?{...e,fastMode:n}:e}takeDraftSelection(e,t,n){let r=this.pendingDraftSelection;if(t&&r&&r.agentId===e&&(this.pendingDraftSelection=void 0,!this.explicitSelection||this.restoredSelection))return this.explicitSelection=!0,this.restoredSelection=!0,this.selected=r.model,this.agentRuntime=r.agentRuntime,this.thinkingLevel=r.thinkingLevel,this.fastModeSelected||(this.fastMode=n??this.fastMode),{...r,fastMode:this.fastMode}}markExplicitSelection(){this.explicitSelection=!0,this.restoredSelection=!1}retireModelSelection(e){return e&&!this.restoredSelection?!1:(this.restoredSelection=!1,this.explicitSelection=!1,e||(this.fastModeSelected=!1),this.pendingDraftSelection=void 0,this.selected=``,this.agentRuntime=void 0,this.thinkingLevel=``,this.contextWindow=``,!0)}restoreModelPreference(e,t,n){if(!e)return;let r=Ic({model:e.model??``,agentRuntime:e.agentRuntime,thinkingLevel:e.thinkingLevel??``,fastMode:e.fastMode,...t});this.applyModelSelection(r),r.repaired&&n&&this.persistSelection(e.agentRuntime?this.agentRuntime??``:void 0)}persistSelection(e=this.agentRuntime){this.onSelectionChange({model:this.selected,...e===void 0?{}:{agentRuntime:e},thinkingLevel:this.thinkingLevel,fastMode:this.fastMode})}}})))()}var Hc;function Uc(){return(Uc=e((()=>{In(),dt(),m(),Sn(),Pt(),Ee(),eo(),Vt(),_(),ua(),wa(),Ji(),G(),Vc(),zc(),ys(),Hc=class extends Bc{constructor(e,t=()=>void 0,n=()=>void 0){super(t),this.notify=e,this.onCatalogTargetSelect=n,this.selectionGeneration=0,this.initialModelPending=!1,this.agentId=``,this.metadataState=Dc(),this.restoringPreference=!1,this.pendingSelectionGeneration=0,this.catalogTargets=new Do(e),this.metadataReader=new $a(()=>{if(this.metadataClient&&this.metadataScope&&!this.ownsMetadata(this.metadataClient,this.metadataScope)){this.restoringPreference=!1,this.draftAccount=void 0,this.clearMetadataSubscription(),this.updateMetadataState({catalog:[],hasSnapshot:!1,status:`offline`});return}if(this.metadataReader.pending){let e=this.metadataReader.snapshot;e.retired?this.metadataState={catalog:[],hasSnapshot:!1,retired:!0,status:`loading`}:e.hasSnapshot&&!this.metadataState.hasSnapshot&&this.assignMetadataCatalog(e,!0),this.updateMetadataState({...this.metadataState,status:this.metadataState.hasSnapshot?this.metadataState.status===`error`?`error`:`ready`:`loading`})}else this.notify()},{timeoutMs:On,onResult:e=>{this.ownsMetadata()&&this.publishMetadataCatalog(e)},onError:()=>{this.ownsMetadata()&&this.metadataFailed()}})}get catalog(){return this.metadataState.catalog}get effectiveModel(){return this.draftAccount?.model??this.selected}clearMetadataSubscription(){this.metadataReader.clear(),this.metadataScope=void 0,this.metadataGateway=void 0}ownsMetadata(e=this.metadataClient,t=this.metadataScope){let n=this.pendingContext?.gateway.snapshot;return!!(e&&t&&this.metadataClient===e&&this.metadataGateway===this.pendingContext?.gateway&&this.metadataScope===t&&n?.phase===`connected`&&n.client===e&&n.hello===this.metadataHello&&n.selfUser?.id===this.metadataIdentityId)}bindMetadataSubscription(e,t){if(this.metadataScope&&this.metadataClient===e&&this.metadataGateway===this.pendingContext?.gateway&&this.metadataScope.agentId===t.agentId&&this.metadataScope.authProfileId===t.authProfileId)return this.metadataScope;this.clearMetadataSubscription(),this.metadataClient=e,this.metadataScope=t;let n=this.pendingContext?.gateway;return this.metadataGateway=n,n&&this.metadataReader.bind(n,t),t}loadCatalogTargets(e,t,n){this.catalogTargets.load(e,t,n)}updateMetadataState(e){this.metadataState={...e,initialized:!e.retired&&e.status!==`offline`&&(e.hasSnapshot||a(this.metadataClient))},this.notify()}assignMetadataCatalog(e,t=!1){this.metadataState={...this.metadataState,catalog:e.models,displayOnly:t,...en(e)}}publishMetadataCatalog(e){if(this.assignMetadataCatalog(e),this.metadataState.accountSelection=e.accountSelection,!this.draftAccount&&this.pendingSelectionGeneration===this.selectionGeneration&&(this.initialModelPending&&!e.modelSelectionPolicy?.restricted?this.resetSelection(this.initialModel):this.restorePreference()),this.initialModelPending=!1,!this.draftAccount&&e.modelSelectionPolicy?.restricted&&this.selected){let t=Ic({model:this.selected,agentRuntime:this.agentRuntime,thinkingLevel:this.thinkingLevel,fastMode:this.fastMode,modelSelectionPolicy:e.modelSelectionPolicy,catalog:e.models});this.applyModelSelection(t)}this.restoringPreference=!1,this.notify()}metadataFailed(){!this.metadataState.retired&&!this.metadataState.modelSelectionPolicy?.restricted&&!this.draftAccount&&this.pendingSelectionGeneration===this.selectionGeneration&&(this.initialModelPending?(this.resetSelection(this.initialModel),this.initialModelPending=!1):this.pendingPreference&&(this.selected=this.pendingPreference.model??``,this.agentRuntime=this.pendingPreference.agentRuntime,this.thinkingLevel=this.pendingPreference.thinkingLevel??``,this.fastMode=this.pendingPreference.fastMode)),this.restoringPreference=!1,this.updateMetadataState({...this.metadataState,status:`error`})}selectDraftAccount(e,t){let n=this.metadataClient;if(!n||!t)return Promise.resolve(!1);this.selectionGeneration+=1,this.restoringPreference=!1,this.draftAccount={authProfileId:e.authProfileId,provider:e.provider,model:t};let r={agentId:this.agentId,authProfileId:e.authProfileId};this.metadataState={catalog:[],accountSelection:this.metadataState.accountSelection,hasSnapshot:!1,status:`loading`};let i=this.bindMetadataSubscription(n,r);return this.metadataReader.read().then(e=>!!e&&this.ownsMetadata(n,i))}clearDraftAccount(){return this.draftAccount?(this.draftAccount=void 0,this.clearMetadataSubscription(),this.metadataState=Dc(),!0):!1}retryPickerCatalogs(){let e=this.metadataClient,t=this.metadataScope;!this.metadataReader.pending&&e&&t&&this.metadataReader.read(),this.catalogTargets.retry(e,this.agentId)}invalidate(e=!1){if(!e&&this.metadataClient&&v(this.metadataClient,this.metadataScope),this.clearDraftAccount(),this.clearMetadataSubscription(),this.catalogTargets.clear(),this.restoringPreference=!1,e){this.pendingDraftSelection=void 0,this.agentId=``,this.metadataClient=void 0,this.resetSelection(),this.initialModel=void 0,this.initialModelPending=!1,this.updateMetadataState(Dc());return}this.updateMetadataState({...this.metadataState,status:this.metadataState.hasSnapshot?this.metadataState.status:`idle`})}reset(){this.invalidate(!0)}load(e,t,n,r={}){let i=e?.gateway.snapshot,a=i?.client,o=t.trim()?V(t):``;if(this.pendingContext=e,(this.agentId!==o||this.metadataClient&&this.metadataClient!==a||this.metadataGateway&&this.metadataGateway!==e?.gateway||this.metadataIdentityId!==i?.selfUser?.id||this.metadataHello&&this.metadataHello!==i?.hello)&&(this.draftAccount=void 0,this.clearMetadataSubscription(),this.agentId!==o&&(this.resetSelection(),this.initialModel=void 0,this.initialModelPending=!1),this.agentId=o,this.metadataClient=void 0,this.metadataState=Dc()),this.metadataIdentityId=i?.selfUser?.id,this.metadataHello=i?.hello,!e||i?.phase!==`connected`||!a||!o||!n){this.clearDraftAccount(),this.clearMetadataSubscription(),this.metadataClient=void 0,this.restoringPreference=!1,e&&i?.phase!==`connected`&&(this.metadataState={catalog:[],hasSnapshot:!1,status:`offline`}),this.notify();return}let s=r.initialModel;s&&s!==this.initialModel&&(this.resetSelection(),this.selectionGeneration+=1,this.initialModel=s,this.initialModelPending=!0);let c=this.selectionGeneration,l={agentId:o,...this.draftAccount?{authProfileId:this.draftAccount.authProfileId}:{}},u=this.metadataScope,d=this.bindMetadataSubscription(a,l)!==u;if(this.pendingPreference=this.preferenceForDraft(r.preference,{policy:e.config?.current.newSessionModelDefaults,initialModel:this.initialModel,initialModelPending:this.initialModelPending}),this.pendingAgent=r.agent,this.pendingSelectionGeneration=c,this.applyPendingDraftSelection(),this.restoringPreference=!this.draftAccount&&rs(this.pendingPreference),this.metadataReader.pending){this.notify();return}if(!d&&this.metadataState.status!==`idle`){this.metadataState.status===`ready`&&this.metadataState.hasSnapshot&&!this.draftAccount&&this.pendingSelectionGeneration===this.selectionGeneration&&this.restorePreference(),this.restoringPreference=!1;return}this.metadataReader.read()}isRestoringPreference(){return this.restoringPreference}requiresModelSetup(e){return Gi({...e,modelSelectionPolicy:this.metadataState.modelSelectionPolicy,catalogInitialized:this.metadataState.hasSnapshot&&!this.metadataState.retired})}modelUnavailableReason(e){return Mc({model:this.effectiveModel,agentRuntime:this.agentRuntime,metadata:this.metadataState,agent:e})}modelSelectionBlockedReason(e){return Pc({model:this.effectiveModel,agentRuntime:this.agentRuntime,metadata:this.metadataState,agent:e,initialModelPending:this.initialModelPending,accountSelected:!!this.draftAccount,accountReady:this.accountSelectionReady(),metadataPending:this.metadataReader.pending})}modelForSubmission(){return this.draftAccount?`${this.draftAccount.model}@${this.draftAccount.authProfileId}`:this.selected}accountSelectionReady(){if(!this.draftAccount)return!0;let e=this.metadataState.accountSelection;return!this.ownsMetadata()||this.metadataReader.pending||this.metadataState.status!==`ready`||e?.kind!==`personal`||e.authProfileId!==this.draftAccount.authProfileId?!1:Nc(this.draftAccount,this.catalog,this.agentRuntime)}restorePreference(){let e=this.metadataState.modelSelectionPolicy;this.restoreModelPreference(this.pendingPreference,{agent:this.pendingAgent,defaults:this.pendingContext?.sessions.state.result?.defaults,modelSelectionPolicy:e,catalog:this.catalog},!this.initialModelPending&&!e?.restricted&&this.pendingContext?.config?.current.newSessionModelDefaults!==`configured`&&this.pendingContext?.config?.current.newSessionModelDefaults!==null)}restoreDraftSelection(e){this.pendingDraftSelection=e,e||this.retireDraftSelection(!0),this.applyPendingDraftSelection()}retireDraftSelection(e=!1){this.retireModelSelection(e)&&(this.pendingSelectionGeneration=++this.selectionGeneration,this.pendingPreference={fastMode:this.fastMode},!e&&this.clearDraftAccount()&&this.load(this.pendingContext,this.agentId,!0,{agent:this.pendingAgent}),this.notify())}applyPendingDraftSelection(){let e=this.takeDraftSelection(this.agentId,this.pendingContext?.config?.current.newSessionModelDefaults===`configured`,this.pendingPreference?.fastMode);e&&(this.selectionGeneration+=1,this.initialModelPending=!1,this.pendingPreference=e,this.pendingSelectionGeneration=this.selectionGeneration,this.metadataState.status===`ready`&&this.restorePreference(),this.notify())}resolveAgentRuntime(e={agent:this.pendingAgent,context:this.pendingContext}){return Fc({model:this.effectiveModel,agentRuntime:this.agentRuntime,agent:e.agent,defaults:e.context?.sessions.state.result?.defaults,catalog:this.metadataState.displayOnly?[]:this.catalog,modelSelectionPolicy:this.metadataState.modelSelectionPolicy,retired:this.metadataState.retired})}devicePlacementUnsupportedReason(){return Lc(this.resolveAgentRuntime())}autoPlacementSelectionMode(){return this.resolveAgentRuntime()?.cloudPlacementExecutionMode===`remote-exec`?`eligible-order`:`least-busy`}cloudRuntimeUnsupportedReason(e){return Rc(this.resolveAgentRuntime(),e)}render(e){let t=e.context?.gateway.snapshot,n=`new-session:${V(e.agentId)}`,r=e.context?.sessions.state.result??null,i=e.agent!==void 0,{defaultTarget:a,...o}=Oc({model:this.effectiveModel,selection:this,metadata:this.metadataState,agent:e.agent,defaults:r?.defaults}),s=t?.client,c=this.metadataScope,l=this.metadataState.accountSelection,u=()=>!!(s&&c&&this.ownsMetadata(s,c)&&this.metadataState.accountSelection===l);return ta({...o,renderAccountSection:n=>va({owner:this,client:s,selection:u()&&t?.selfUser?l:void 0,model:n,disabled:e.sending||!n||!Je(t?.hello?.auth??null),ownsSelection:u,onSelect:e=>u()?this.selectDraftAccount(e,n):Promise.resolve(!1),onAutomatic:this.draftAccount?()=>{u()&&(this.selectionGeneration+=1,this.clearDraftAccount(),this.load(e.context,e.agentId,!0,{agent:e.agent}))}:void 0,onManage:()=>e.context?.navigate(`profile`),onRequestUpdate:this.notify}),activeRunId:null,connected:t?.phase===`connected`,gatewayAvailable:!!t?.client,loading:!1,modelCatalog:this.catalog,modelOverrides:{[n]:this.effectiveModel||null},modelPickerTargetGroups:this.catalogTargets.groups(),modelSwitching:!1,sending:e.sending,sessionKey:n,selectedSession:void 0,selectedAgentRuntime:this.agentRuntime,sessionsResult:i?r:null,stream:null,onModelSelect:(t,n,r)=>{this.selectionGeneration+=1,this.initialModelPending=!1,this.restoringPreference=!1;let i=Ic({model:t,agentRuntime:r??void 0,thinkingLevel:this.thinkingLevel,fastMode:this.fastMode,agent:e.agent,defaults:e.context?.sessions.state.result?.defaults,modelSelectionPolicy:this.metadataState.modelSelectionPolicy,catalog:this.catalog});if(i.model===this.effectiveModel&&i.agentRuntime===this.agentRuntime&&i.fastMode===this.fastMode&&Ut(i.thinkingLevel)===Ut(this.thinkingLevel))return;this.metadataState.displayOnly=!1;let o=this.agentRuntime!==i.agentRuntime;this.applyModelSelection(i),this.markExplicitSelection();let s=J(i.model,void 0,this.catalog,this.agentRuntime)??a;this.draftAccount&&this.draftAccount.provider!==s?.provider?(this.clearDraftAccount(),this.load(e.context,e.agentId,!0,{agent:e.agent})):this.draftAccount&&s&&(this.draftAccount={...this.draftAccount,model:w(s.model,s.provider)}),this.contextWindow=``,this.persistSelection(o?this.agentRuntime??``:void 0),this.onDraftSelectionChange?.()},onModelPickerTargetSelect:(e,t)=>{e===`cliAgents`&&this.onCatalogTargetSelect(t)},onModelPickerTargetRetry:e=>{e===`cliAgents`&&this.catalogTargets.retry(this.metadataClient,this.agentId)},onThinkingSelect:e=>{this.selectionGeneration+=1,this.restoringPreference=!1,this.thinkingLevel=e,this.markExplicitSelection(),this.persistSelection(),this.onDraftSelectionChange?.()},onFastModeSelect:e=>{this.selectionGeneration+=1,this.restoringPreference=!1,this.fastModeSelected=!0,this.fastMode=bn(e),this.persistSelection(),this.notify()},onContextWindowSelect:e=>{this.selectionGeneration+=1,this.restoringPreference=!1,this.contextWindow=e,this.notify()},onModelSetup:()=>e.context?.navigate(`model-setup`),onProviderSettings:t=>Oa(e.context,e.agentId,t),onModelPickerOpen:()=>this.retryPickerCatalogs(),onRequestUpdate:this.notify})}}})))()}var Wc;function Gc(){return(Gc=e((()=>{dt(),l(),I(),he(),_(),G(),dc(),pc(),bc(),Cc(),Ec(),Uc(),ys(),L(),Wc=class{get terminalOnNode(){return this.terminalHostId.startsWith(`node:`)}selectTerminalHost(e){this.read().submitting||(this.terminalHostInitialized=!0,e!==this.terminalHostId&&(this.terminalHostId=e,this.folderValidation.cancel(),this.browser.clearProjectSelection(),this.repositoryState.reset(),this.folderValue=this.terminalOnNode?``:this.workspacePath(),this.folderSelectedByUser=!0,this.terminalOnNode||this.repositoryState.load(),this.callbacks.requestUpdate()))}synchronizeTerminalHosts(){let e=this.read().data?.terminalHosts;!this.terminalHostInitialized&&e?.length&&this.selectTerminalHost(e.find(e=>e.hostId===this.terminalHostId)?.hostId??e[0].hostId)}constructor(e,t,n,r){this.gateway=e,this.browser=t,this.read=n,this.callbacks=r,this.terminalHostId=`gateway:local`,this.terminalHostInitialized=!1,this.agentIdValue=``,this.folderValue=``,this.freshWorkspaceValue=!0,this.deviceIdValue=``,this.autoDeviceValue=!1,this.cloudProfileIdValue=``,this.cloudMachines=new fc,this.agentsHydratedValue=!1,this.agentSelectedByUser=!1,this.routeModelIntentActive=!0,this.folderSelectedByUser=!1,this.restoreState=mc(),this.folderValidation=new Tc(()=>({gateway:this.read().context?.gateway.snapshot,folder:this.folderValue,selectedByUser:this.folderSelectedByUser,isAdmin:this.isAdmin()}),{onApprovedRootsChange:r.requestUpdate,onVerified:()=>{this.callbacks.onClearError(E(`newSession.browserLoadFailed`)),this.repositoryState.load()},onMissing:()=>this.restoreWorkspaceFolder(),onFailed:()=>this.callbacks.onError(E(`newSession.browserLoadFailed`))}),this.repositoryState=new Sc(()=>({agentId:this.agentIdValue,agents:this.agents(),remotePlacement:this.remotePlacement,selectedProject:this.browser.selectedProject(),remoteProject:this.browser.remoteProject,folder:this.folderValue,workspace:this.workspacePath(),workspaceGit:this.selectedAgent()?.workspaceGit===!0,gateway:this.read().context?.gateway.snapshot}),{requestUpdate:r.requestUpdate,persistPreference:e=>this.persistPreference(e),capturePreferenceConsumption:(e,t)=>this.gateway.capturePreferenceConsumption(e.agentId,e.workspace,t)}),this.modelControl=new Hc(r.requestUpdate,e=>this.persistPreference(e),e=>this.read().context?.navigate(`new-session`,{search:Ce(this.agentIdValue,{catalogId:e})}))}get agentId(){return this.agentIdValue}get folder(){return this.folderValue}get worktree(){return(this.remotePlacement||this.repositoryState.worktree)&&!this.remoteRepository}get checkoutVisible(){return!this.freshWorkspace&&this.repository.kind!==`direct`&&(this.worktreeAvailable()||this.worktree)}get freshWorkspace(){return this.remotePlacement&&this.freshWorkspaceValue}get remoteRepository(){return this.repositoryState.remoteRepository}get worktreeName(){return this.freshWorkspace?``:this.repositoryState.worktreeName}get baseRef(){return this.freshWorkspace?``:this.repositoryState.baseRef}get repository(){return this.repositoryState.repository}get deviceId(){return this.deviceIdValue}get autoDevice(){return this.autoDeviceValue}get remotePlacement(){return!!(this.deviceIdValue||this.autoDeviceValue||this.cloudProfileIdValue)}get cloudProfileId(){return this.cloudProfileIdValue}get cloudSelection(){return this.cloudMachines.selection(this.cloudProfileIdValue,this.gateway.cloudProfiles)}get agentsHydrated(){return this.agentsHydratedValue}preferenceSelection(){let e=this.restoreState.preferredWhereRestore??ns(this);return vc({state:this.restoreState,browser:this.browser,workspace:this.workspacePath(),folder:this.folderValue,where:e,preferenceWorktree:this.repositoryState.preferenceWorktree,remoteRepository:!!this.remoteRepository,freshWorkspace:this.freshWorkspaceValue,baseRef:this.repositoryState.baseRef,worktreeName:this.repositoryState.worktreeName})}get placementPreferenceReady(){return _c(this.restoreState,this.freshWorkspace||this.repositoryState.preferenceReady,this.browser.projectsLoading||this.browser.projectsReady)}canAdoptGroupDefaults(){return!this.folderSelectedByUser&&!this.restoreState.whereSelectedByUser&&!this.restoreState.projectSelectedByUser&&!this.repositoryState.hasUserSelection}adoptGroupDefaults(){this.read().data?.groupStatus===`resolved`&&this.canAdoptGroupDefaults()&&this.adoptAgentDefaults({preserveSelectedAgent:!0})}setAgentsHydrated(e){this.agentsHydratedValue=e}agents(){return xe(this.read().context?.agents.state.agentsList?.agents??[])}selectedAgent(){let e=V(this.agentIdValue);return this.agents().find(t=>V(t.id)===e)}devicePlacementRuntime(){return this.modelControl.resolveAgentRuntime({agent:this.selectedAgent(),context:this.read().context})}devices(){return sc(this.gateway.environments,this.devicePlacementRuntime()?.devicePlacement,this.gateway.deviceCatalogDisabledReason)}devicePlacement(){return lc(this.devices(),this.gateway.environments,this)}isAdmin(){return Qe(this.read().context?.gateway.snapshot.hello?.auth??null)}canWrite(){return Je(this.read().context?.gateway.snapshot.hello?.auth??null)}workspacePath(){return R(this.selectedAgent()?.workspace)??``}knownWorkspaceRoots(){return this.folderValidation.knownWorkspaceRoots(this.workspacePath())}recordGatewayApprovedListing(e){this.folderValidation.recordApprovedListing(e)}folderSubmissionBlocked(){return this.freshWorkspace?!1:this.browser.projectId||this.browser.remoteProject?!this.browser.remoteProject&&!this.browser.selectedProject():this.folderValidation.blocked}adoptAgentDefaults(e={}){let t=this.read(),n=this.agents(),r=t.context?.agents.state.agentsList?.defaultId,i=n.some(e=>e.id===r)?r??``:n[0]?.id??``;if(e.preserveSelectedAgent&&this.agentSelectedByUser&&this.selectedAgent()||(this.agentIdValue=xo(t.data,n,i),this.agentSelectedByUser=!1),W(t.data)&&this.terminalOnNode){this.callbacks.requestUpdate();return}let a=this.agentIdValue?this.gateway.readPreference(this.agentIdValue):null,o=e.preserveSelectedFolder&&this.folderSelectedByUser;if(!o&&!t.pendingPlacementSessionKey){let e=this.workspacePath(),n=is(a,e),r=!!t.data?.group,i=t.data?.groupCwd??``,o=t.data?.groupWorktree===!0;this.folderValue=r?i||e:n.folder,this.restoreState.projectSelectedByUser||(this.freshWorkspaceValue=!r&&n.freshWorkspace),this.folderSelectedByUser=!1,this.repositoryState.adoptPreference(r?{worktree:o}:a),gc(this.restoreState,a,r,W(t.data)),n.workspaceMoved&&!r&&this.persistPreference({folder:e})}o&&!t.pendingPlacementSessionKey&&this.agentIdValue&&this.persistPreference({folder:this.folderValue,worktree:this.worktree}),this.modelControl.load(t.context,this.agentIdValue,!W(t.data),{agent:this.selectedAgent(),preference:a,initialModel:this.routeModelIntentActive?fo(t.data,this.agentIdValue):void 0}),this.restoreState.preferredProjectRestore?this.folderValidation.cancel():!this.folderSelectedByUser&&this.folderValue!==this.workspacePath()&&!t.pendingPlacementSessionKey?this.folderValidation.validate(this.folderValue):(this.folderValidation.cancel(),this.repositoryState.synchronize()),this.callbacks.requestUpdate()}resetPlaceSelection(){this.freshWorkspaceValue=!0,this.folderSelectedByUser=!1,this.folderValidation.reset(),this.restoreState.preferredWhereRestore=null,this.restoreState.preferredProjectRestore=``,this.restoreState.preferredRemoteProjectRestore=null,this.restoreState.configuredDefaultRepositoryPending=!1,this.restoreState.configuredDefaultRepositoryOptOut=!1,this.restoreState.whereSelectedByUser=!1,this.restoreState.projectSelectedByUser=!1,this.deviceIdValue=``,this.autoDeviceValue=!1,this.cloudProfileIdValue=``,this.repositoryState.reset()}resetDraft(){this.routeModelIntentActive=!0,this.terminalHostId=`gateway:local`,this.terminalHostInitialized=!1,this.agentSelectedByUser=!1,this.folderValue=``,this.browser.clearProjectSelection(),this.resetPlaceSelection(),this.browser.resetProjectSearch(),this.modelControl.reset(),this.cloudMachines.clear(),this.callbacks.requestUpdate()}invalidateGatewayDiscovery(e){if(this.repositoryState.invalidate(),this.agentsHydratedValue=!1,this.modelControl.invalidate(e),this.browser.close(),this.folderValidation.reset(),this.browser.resetProjectSearch(),this.browser.resetProjects(e),!e){this.callbacks.requestUpdate();return}this.agentIdValue=``,this.agentSelectedByUser=!1,this.folderValue=``,this.resetPlaceSelection(),this.cloudMachines.clear(),this.callbacks.requestUpdate()}applyPendingPlacement(e){this.agentIdValue=e.agentId,this.deviceIdValue=e.deviceId??``,this.autoDeviceValue=e.autoDevice===!0,this.cloudProfileIdValue=e.profileId,this.cloudMachines.applyPending(e.profileId,e.machineClass,e.os),this.folderValue=e.cwd??``,this.freshWorkspaceValue=e.worktreeSource===`empty`,this.freshWorkspaceValue&&this.browser.clearProjectSelection(),e.repository&&(this.browser.selectProject({kind:`remote`,project:{identity:e.repository.url,cloneUrl:e.repository.url}}),this.repositoryState.setBaseRef(e.repository.ref??``,!1),this.repositoryState.load()),this.callbacks.requestUpdate()}clearCloudProfile(){this.cloudProfileIdValue=``,this.browser.close(),this.callbacks.requestUpdate()}clearProjectSelection(){(this.browser.projectId||this.browser.remoteProject)&&this.repositoryState.clearDetails(!0),this.browser.clearProjectSelection(),hc(this.restoreState,!0),this.persistPreference({projectId:``,remoteProject:null,defaultRepositoryOptOut:!0}),this.repositoryState.load(),this.callbacks.requestUpdate()}selectAgentId(e){let t=this.read();t.submitting||t.pendingPlacementSessionKey||W(t.data)||V(e)!==V(this.agentIdValue)&&(this.agentIdValue=V(e),this.routeModelIntentActive=!1,this.modelControl.reset(),this.callbacks.onError(null),this.agentSelectedByUser=!0,this.browser.clearProjectSelection(),this.resetPlaceSelection(),this.browser.close(),this.adoptAgentDefaults({preserveSelectedAgent:!0}))}applyFolder(e){let t=this.read();if(!(t.submitting||t.pendingPlacementSessionKey)){if(this.browser.clearProjectSelection(),this.folderValidation.cancel(),this.callbacks.onError(null),this.folderValue=e.trim(),this.freshWorkspaceValue=!1,this.folderSelectedByUser=!0,hc(this.restoreState,!0),W(t.data)&&this.terminalOnNode){this.callbacks.requestUpdate();return}this.repositoryState.selectWorktree(!1),this.agentsHydratedValue&&this.persistPreference({folder:this.folderValue,projectId:``,remoteProject:null,defaultRepositoryOptOut:!0,worktree:this.worktree,freshWorkspace:!1}),this.repositoryState.load()}}selectNewWorkspace(){let e=this.read();e.submitting||e.pendingPlacementSessionKey||!this.remotePlacement||(this.folderValidation.cancel(),this.browser.clearProjectSelection(),this.browser.resetProjectSearch(),this.callbacks.onError(null),this.folderValue=this.workspacePath(),this.folderSelectedByUser=!0,hc(this.restoreState,!0),this.freshWorkspaceValue=!0,this.repositoryState.selectWorktree(!1),this.persistPreference({folder:this.folderValue,projectId:``,remoteProject:null,defaultRepositoryOptOut:!0,worktree:!0,freshWorkspace:!0}),this.browser.close(),this.callbacks.requestUpdate())}selectProjectId(e){let t=this.browser.projects.find(t=>t.id===e);t&&this.selectProject({kind:`local`,id:t.id})}selectRemoteProject(e){this.selectProject({kind:`remote`,project:e})}selectProject(e){let t=this.read();t.submitting||t.pendingPlacementSessionKey||(this.browser.selectProject(e),this.freshWorkspaceValue=!1,this.folderValidation.cancel(),this.browser.resetProjectSearch(),this.callbacks.onError(null),this.folderSelectedByUser=!1,hc(this.restoreState,!1),this.repositoryState.selectWorktree(!1),e.kind===`local`?this.persistPreference({projectId:e.id,remoteProject:null,defaultRepositoryOptOut:!1,where:ns(this),worktree:this.worktree,worktreeName:``,freshWorkspace:!1}):(this.persistPreference({projectId:``,remoteProject:e.project,defaultRepositoryOptOut:!1,worktree:this.worktree,freshWorkspace:!1}),e.project.defaultBranch&&this.repositoryState.setBaseRef(e.project.defaultBranch,!1)),this.repositoryState.load(),this.browser.close())}selectDevice(e,t=!1){let n=this.read();n.submitting||n.pendingPlacementSessionKey||e&&this.devices().find(t=>t.deviceId===e)?.selectable!==!0||t&&!this.devices().some(e=>e.selectable)||(this.restoreState.whereSelectedByUser=!0,this.restoreState.preferredWhereRestore=null,(e!==this.deviceIdValue||t!==this.autoDeviceValue||this.cloudProfileIdValue)&&(this.folderValidation.cancel(),this.deviceIdValue=e,this.autoDeviceValue=t,this.cloudProfileIdValue=``,this.persistPreference({where:ns({cloudProfileId:``,deviceId:e,autoDevice:t}),projectId:this.browser.projectId,folder:this.folderValue,worktree:!!(e||t)||this.worktree,freshWorkspace:this.freshWorkspaceValue}),this.browser.close(),this.repositoryState.synchronize(),this.callbacks.requestUpdate()))}selectCloudProfile(e){let t=this.read(),n=this.gateway.cloudProfiles.find(t=>t.id===e);t.submitting||t.pendingPlacementSessionKey||!this.isAdmin()||!n||this.modelControl.cloudRuntimeUnsupportedReason(n)||(this.cloudProfileIdValue=e,this.deviceIdValue=``,this.autoDeviceValue=!1,this.restoreState.whereSelectedByUser=!0,this.restoreState.preferredWhereRestore=null,this.callbacks.onError(null),this.persistPreference({where:{kind:`cloud`,id:e},projectId:this.browser.projectId,worktree:!0,freshWorkspace:this.freshWorkspaceValue}),this.repositoryState.synchronize(),this.callbacks.requestUpdate())}selectWorktree(e){!this.read().submitting&&this.repositoryState.select(e)&&e&&this.freshWorkspaceValue&&(this.freshWorkspaceValue=!1,this.persistPreference({freshWorkspace:!1}))}setBaseRef(e){this.repositoryState.setBaseRef(e,this.read().submitting)}setWorktreeName(e){this.repositoryState.setWorktreeName(e,this.read().submitting)}captureSubmittedWorktreeName(e,t,n=!1){return this.repositoryState.captureSubmittedName(e,{agentId:t,recovered:n})}restorePreferenceSelections(){yc({state:this.restoreState,browser:this.browser,gateway:this.gateway,where:ns(this),modelControl:this.modelControl,repositoryState:this.repositoryState,isAdmin:()=>this.isAdmin(),persistPreference:e=>this.persistPreference(e),requestUpdate:this.callbacks.requestUpdate,setDeviceId:e=>{this.deviceIdValue=e},setAutoDevice:e=>{this.autoDeviceValue=e},setCloudProfileId:e=>{this.cloudProfileIdValue=e},setFreshWorkspace:e=>{this.freshWorkspaceValue=e},setFolderSelectedByUser:e=>{this.folderSelectedByUser=e}})}browseAvailable(){return this.gateway.connected&&(this.isAdmin()||!!this.workspacePath())}worktreeAvailable(){return this.repositoryState.available()}persistPreference(e){this.gateway.persistPreference(this.agentIdValue,this.workspacePath(),e)}restoreWorkspaceFolder(){this.callbacks.onClearError(E(`newSession.browserLoadFailed`)),this.folderValue=this.workspacePath(),this.repositoryState.rejectPreferredWorktree(),this.persistPreference({folder:this.folderValue,worktree:!1}),this.repositoryState.load()}}})))()}var Kc;function qc(){return(qc=e((()=>{_i(),Oi(),Kc=class{constructor(e,t){this.notify=e,this.onUserChange=t,this.attachments=[],this.reads=new Va(e)}replace(e){this.attachments=e,this.onUserChange(),this.notify()}restore(e){ti(this.attachments,[e]),this.attachments=e,this.notify()}take(){this.reads.abortReads();let e=this.attachments;return this.attachments=[],this.notify(),e}reset(e){this.reads.abortReads(),this.clearAfterSubmit(e.release)}clearAfterSubmit(e){e&&ie(this.attachments),this.attachments=[],this.notify()}}})))()}function Jc(e){let{gateway:t}=e,n=t.snapshot.client,r=t.connectionRevision,i=t.connection.gatewayUrl,a=t.snapshot.hello?.auth?.recoveryScope;return()=>e.gateway===t&&t.snapshot.phase===`connected`&&t.connection.gatewayUrl===i&&t.connectionRevision===r&&t.snapshot.hello?.auth?.recoveryScope===a&&(!!a||t.snapshot.client===n)}function Yc(){return(Yc=e((()=>{})))()}async function Xc(e){let t;for(;!t;)try{let n=await e.client.request(`agent.wait`,{runId:e.runId,timeoutMs:3e4},{timeoutMs:null});if(e.context.gateway.snapshot.client!==e.client)return;let r=n.status===`timeout`&&n.endedAt===void 0&&!n.error&&!n.stopReason&&n.providerStarted!==!0;if(n.status===`pending`||n.pendingError===!0)await An($c);else if(r){let n=e.context.placementStartup.get(e.key)?.initialTurn;n?.sendState===`failed`&&n.sendRunId===e.runId?t={status:`error`,error:n.sendError}:await An($c)}else t=n}catch{let t=e.context.gateway.snapshot,n=t.phase===`connecting`||t.phase===`starting`||t.phase===`reconnecting`;if(t.client!==e.client||!n)return;await An($c)}if(!e.isCurrentOwner())return;let n=e.context.gateway.snapshot;if(d(n,e.key,e.agentId))return;let r=e.context.sessions.state.result?.sessions.find(t=>te(t.key,e.key)),i=t.status===`ok`?E(`sessionsView.statusDone`):t.status===`timeout`?E(`sessionsView.statusTimeout`):t.stopReason===`rpc`?E(`sessionsView.statusKilled`):E(`sessionsView.statusFailed`),a=b({face:`chat`,sessionKey:e.key,fallbackAgentId:e.agentId,exactKey:!0});e.context.nativeNotifications?.backgroundSessionCompleted({runId:e.runId,path:a.options.pathname,...a.options.search?{search:a.options.search}:{}}),Te({fifo:!0,message:`${h(e.key,r)}: ${i}`,actionLabel:E(`sessionsView.openSession`),onAction:()=>{e.isCurrentOwner()&&(ut({selection:e.context.agentSelection,gateway:e.context.gateway,sessionKey:e.key,agentId:e.agentId}),e.context.navigate(`chat`,b({context:e.context,face:`chat`,sessionKey:e.key,agentId:e.agentId}).options))}})}function Zc(e){let t=Jc(e.context);return(n,r)=>{let i=r?.trim();return e.enabled?(i&&Xc({agentId:e.agentId,client:e.client,context:e.context,key:n,runId:i,isCurrentOwner:t}),!0):!1}}function Qc(e,t,n,r){cr({connected:e.gateway.snapshot.phase===`connected`,directComposerSend:r&&pr(),message:t,hasAttachments:n,isCommand:Yt(t)!==null})&&dr(e)}var $c;function el(){return(el=e((()=>{Ln(),qe(),gr(),l(),xn(),T(),f(),_(),fe(),$c=1e3})))()}function tl(e){return e.allowedVisibilities?.includes(`draft`)===!0&&e.hasMultipleIdentities===!0}function nl(e){let t=e.trim();return!t||il.test(t)}function rl(e){let t=R(e.displayName),n=R(e.baseRef),r=R(e.worktreeName),i=R(e.cwd),a=R(e.workspace),o=R(e.catalogId),s=R(e.category),c=R(e.model),l=R(e.agentRuntime),u=R(e.contextWindow),d=R(e.thinkingLevel),f=e.deferInitialTurn?``:e.message,p=e.deferInitialTurn&&e.visibility!==`incognito`?Jn(e.message.trim(),1e3):void 0,m=e.worktreeSource===`empty`,h=m?void 0:e.repository,g=m||h?void 0:R(e.projectId),_=!m&&!h&&!g&&(f.trim()||!e.deferInitialTurn&&e.attachments?.length)?R(e.projectGitUrl):void 0,v=!m&&!h&&!g&&!_&&i&&i!==a?i:void 0;return{agentId:V(e.agentId),message:f,...!e.deferInitialTurn&&e.mentions?.length?{mentions:e.mentions.map(e=>({...e}))}:{},...t?{displayName:t}:{},...p?{titleSource:p}:{},...e.visibility===`incognito`?{incognito:!0}:{},...e.visibility===`draft`?{visibility:`draft`}:{},...!e.deferInitialTurn&&e.attachments?.length?{attachments:e.attachments}:{},...o?{catalogId:o}:{},...s?{category:s}:{},...!o&&c?{model:c}:{},...!o&&c&&l?{agentRuntime:l}:{},...!o&&u?{contextWindow:u}:{},...!o&&d?{thinkingLevel:d}:{},...!o&&e.fastMode!==void 0?{fastMode:e.fastMode}:{},...e.toolOverrides?{toolOverrides:e.toolOverrides}:{},...e.permissionMode?{permissionMode:e.permissionMode}:{},...g?{projectId:g}:{},..._?{projectGitUrl:_}:{},...h?{repository:{...h}}:{},...v?{cwd:v}:{},...m?{worktree:!0,worktreeSource:`empty`}:{},...e.worktree&&!h&&!m?{worktree:!0,...n?{worktreeBaseRef:n}:{},...r?{worktreeName:r}:{}}:{}}}var il;function al(){return(al=e((()=>{_(),il=/^[a-z0-9][a-z0-9-]{0,63}$/})))()}var ol;function sl(){return(sl=e((()=>{dt(),l(),fn(),Ea(),al(),ol=class{constructor(e){this.notify=e,this.toolOverridesValue=null,this.onMutation=()=>{},this.skillCatalog=new Yi(e)}setMutationCallback(e){this.onMutation=e}get toolOverrides(){return this.toolOverridesValue}setToolOverrides(e){let t=xa(e)>0?e:null;t!==this.toolOverridesValue&&(this.onMutation(),this.toolOverridesValue=t,this.notify())}reset(){this.toolOverridesValue=null}restoreToolOverrides(e){e!==void 0&&this.setToolOverrides(e)}canStartAsDraft(e){return tl({allowedVisibilities:e?.gateway.snapshot.hello?.policy?.allowedSessionVisibilities,hasMultipleIdentities:e?.gateway.snapshot.hello?.policy?.hasMultipleSessionSharingIdentities})}composerProps(e,t,n){return{toolOverrides:this.toolOverridesValue,capabilityMenu:e?this.props(e,t,n):void 0}}props(e,t,n){this.skillCatalog.synchronize(t.client,t.connectionEpoch);let r=e.runtimeConfig.state,i=r.configSnapshot?.runtimeConfig??null,a=t.connected&&!!t.client,o=Ve(e.gateway.snapshot),s=a?i?o.canAdmin?null:E(`chat.composer.menu.adminBlocked`):r.lastError??E(`common.loading`):E(`chat.composer.menu.offlineBlocked`);return{basePath:e.basePath,skills:this.skillCatalog.rows(n,this.toolOverridesValue),skillsLoading:this.skillCatalog.isLoading(n),skillsError:this.skillCatalog.hasError(n),mcpServers:un(i)??[],toolsEffectiveResult:null,toolsEffectiveLoading:!1,toolsEffectiveError:!1,toolAccessMutationBlockedReason:s,webSearchBaseEnabled:ra(i),mutationBlockedReason:s,canAdmin:o.canAdmin&&a,adminBlockedReason:o.canAdmin?a?null:E(`chat.composer.menu.offlineBlocked`):E(`chat.composer.menu.adminBlocked`),onLoadSkills:()=>{let e=t.client,r=t.connectionEpoch;this.skillCatalog.load(e,r,n,()=>t.connected&&t.client===e&&t.connectionEpoch===r)},onPatchToolOverrides:e=>this.setToolOverrides(e),onNavigate:(t,n)=>e.navigate(t,n)}}}})))()}var cl;function ll(){return(ll=e((()=>{bi(),li(),Pr(),Ha(),Ia(),Ar(),cl=class{constructor(){this.critterVisit=Math.random(),this.textarea=null,this.placeholderFrame=null,this.placeholderStartedAt=null,this.placeholderText=``,this.placeholderTarget=``,this.placeholderEntered=!1,this.capturedSelection=null,this.skillCommandClient=null,this.skillCommandAgentId=``,this.skillCommandDraftOwnerKey=``,this.skillMenuState=Ti(),this.slashMenuState=la(),this.mentionMenu=new _a,this.emojiMenu=new ma,this.composing=!1,this.capabilityMenuOpen=!1,this.capabilityMenuView=`root`,this.ref=e=>{let t=e instanceof HTMLTextAreaElement?e:null;this.textarea&&this.textarea!==t&&Bi(this.textarea),this.textarea&&!t&&this.resetPlaceholder(),this.textarea=t,t&&(jr(t),da(t))},this.getTextarea=()=>this.textarea}syncDraft(e){this.textarea?.isConnected&&this.textarea.value!==e&&da(this.textarea)}getPlaceholder(e,t,n){if(t.length>0||this.placeholderEntered)return this.placeholderEntered=!0,this.placeholderFrame!==null&&(globalThis.cancelAnimationFrame?.(this.placeholderFrame),this.placeholderFrame=null),e;this.placeholderTarget!==e&&(this.resetPlaceholder(),this.placeholderTarget=e);let r=globalThis.requestAnimationFrame?.bind(globalThis);if(!r||(globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1))return this.placeholderText=e,this.placeholderEntered=!0,e;if(this.placeholderFrame===null){let t=i=>{this.placeholderStartedAt??=i;let a=Math.max(0,i-this.placeholderStartedAt-180),o=Math.min(e.length,Math.floor(a/26));if(o!==this.placeholderText.length&&(this.placeholderText=e.slice(0,o),n()),o<e.length){this.placeholderFrame=r(t);return}this.placeholderFrame=null,this.placeholderEntered=!0};this.placeholderFrame=r(t)}return this.placeholderText}resetPlaceholder(){this.placeholderFrame!==null&&(globalThis.cancelAnimationFrame?.(this.placeholderFrame),this.placeholderFrame=null),this.placeholderStartedAt=null,this.placeholderText=``,this.placeholderTarget=``,this.placeholderEntered=!1}captureSelection(){let e=this.textarea;this.capturedSelection=e?{start:e.selectionStart,end:e.selectionEnd,value:e.value}:null}previewTranscript(e){let t=this.textarea;if(!t)return;let n=this.capturedSelection??{start:t.selectionStart,end:t.selectionEnd,value:t.value};return ea(n.value,e,n.start,n.end).value}insertTranscript(e,t){let n=this.textarea;if(!n)return null;let r=this.capturedSelection,i=r&&(!t||r.value===n.value)?r:{start:t?n.selectionStart:n.value.length,end:t?n.selectionEnd:n.value.length,value:n.value};this.capturedSelection=null;let a=ea(i.value,e,i.start,i.end);return a.value===i.value?null:(n.value=a.value,ni(n),queueMicrotask(()=>{n.isConnected&&(n.focus({preventScroll:!0}),n.selectionStart=a.caret,n.selectionEnd=a.caret)}),a.value)}syncSkillCommandOwner(e,t,n){let r=t.trim();(this.skillCommandClient!==e||this.skillCommandAgentId!==r||this.skillCommandDraftOwnerKey!==n)&&(this.skillCommandClient=e,this.skillCommandAgentId=r,this.skillCommandDraftOwnerKey=n,this.emojiMenu.close(),Ur(this.skillMenuState))}ownsSkillCommands(e,t,n){return this.skillCommandClient===e&&this.skillCommandAgentId===t.trim()&&this.skillCommandDraftOwnerKey===n}disconnect(){this.emojiMenu.close(),this.composing=!1,this.mentionMenu.dispose(),this.resetPlaceholder(),this.skillCommandClient=null,this.skillCommandAgentId=``,this.skillCommandDraftOwnerKey=``,Ur(this.skillMenuState),qi(this.slashMenuState),this.capabilityMenuOpen=!1,this.capabilityMenuView=`root`,this.textarea&&=(Bi(this.textarea),null)}}})))()}var ul,dl,fl,pl;function ml(){return(ml=e((()=>{cn(),_n(),Si(),Yn(),ul=()=>({writeId:Math.random().toString(36).slice(2),retired:!1,committedRevision:0,writes:new Set}),dl=Gn(()=>import(`./control-ui-boot-shared-DJkUdZmL.js`).then(e=>(e.d(),e.u)),__vite__mapDeps([1,3,4,5,6,7,8,2,9,10,11]),import.meta.url),fl=200,pl=class e{static{this.active=new Set}constructor(e,t,n){this.read=e,this.apply=t,this.onStorageError=n,this.contentReconciled=!1,this.pendingModelSelectionMutation=!1,this.gatewayOwner=``,this.recoveryScope=``,this.routeKey=``,this.revision=0,this.mutationGeneration=0,this.mutation=ul(),this.inheritedWriteIds=[],this.disconnected=!1,this.pendingHandoffMutation=null,this.submittedMutation=null,this.pristineMutationBaseline=0,this.restoreGeneration=0,this.restoredIdentity=``,this.pending=null,this.timer=null,this.lineageByScope=new Map}setOwner(e,t,n=!1){let r=Xt(e).gatewayOwner,i=JSON.stringify([r,t]),a=this.gatewayOwner?JSON.stringify([this.gatewayOwner,this.recoveryScope]):``;if(a===i)return;let o=this.routeKey;this.persistNow(),this.restoreGeneration+=1,this.restoredIdentity=``,this.contentReconciled=!1,this.routeKey=``,this.gatewayOwner=r,this.recoveryScope=t,a&&!n&&(this.pendingModelSelectionMutation=!1,this.apply(``,[],!0)),n||this.activateRoute(o)}setIncognito(e){if(e)return this.retireActive();let t=this.scope();return(t?this.lineage(t).retirement:void 0)?.then(()=>{})??Promise.resolve()}transitionIncognito(e,t,n){let r=this.setIncognito(t);if(e&&!t){this.noteUserMutation(),r.finally(n);return}n()}selectRoute(e){e&&this.routeKey!==e&&(this.persistNow(),this.routeKey&&(this.pendingModelSelectionMutation=!1),this.routeKey=e,this.contentReconciled=!1,this.revision=0)}activateRoute(e){this.selectRoute(e);let t=this.scope();if(!t)return;let n=U(t);if(n===this.restoredIdentity)return;if(this.restoredIdentity=n,this.contentReconciled=!1,this.read().incognito){this.retireActive();return}let r=++this.restoreGeneration,i=this.mutationGeneration,a=this.read(),o=qa(a.message,a.attachments,void 0,a.mentions),s=this.restoreScope(t,r,i,o);this.restorePromise=s,s.then(e=>{this.restorePromise===s&&(this.restorePromise=void 0,this.contentReconciled=e,this.flushModelSelectionMutation())},()=>{this.restorePromise===s&&(this.restorePromise=void 0,this.contentReconciled=!1,H(t,this.onStorageError))})}noteDraftReplaced(){this.restoreGeneration+=1,this.mutationGeneration+=1,this.mutation=ul(),this.pendingHandoffMutation=null,this.submittedMutation=null,this.inheritedWriteIds=[],this.pristineMutationBaseline=this.mutationGeneration}noteModelSelectionMutation(){let e=!this.contentReconciled&&this.mutationGeneration===this.pristineMutationBaseline&&(this.submittedMutation===this.mutation||!this.restorePromise);this.submittedMutation=null,this.pendingModelSelectionMutation=!0,e?(this.restoredIdentity=``,this.activateRoute(this.routeKey)):this.flushModelSelectionMutation()}flushModelSelectionMutation(){this.pendingModelSelectionMutation&&!this.restorePromise&&this.restoredIdentity&&(this.contentReconciled||this.mutationGeneration>this.pristineMutationBaseline)&&!this.disconnected&&this.submittedMutation!==this.mutation&&this.noteUserMutation()}noteUserMutation(){if(this.pendingModelSelectionMutation=!1,this.mutationGeneration+=1,this.mutation=ul(),this.pendingHandoffMutation=null,this.submittedMutation=null,this.revision=Ft(this.revision),this.read().incognito)return;this.discardPending();let e=this.snapshot();e&&(this.pending=e,this.timer=globalThis.setTimeout(()=>this.persistNow(),fl))}retireActive(){this.mutationGeneration+=1,this.mutation.retired=!0,this.discardPending();let e=Ft(this.revision);this.revision=e;let t=this.scope();if(!t)return Promise.resolve();let n=this.lineage(t);return n.localWriteIds.clear(),n.retirement=(async()=>{let{retireDurableComposerDraft:r}=await dl,i=Math.max(e,n.revision),a=await r(t,i);if(a.status===`storage-failed`)H(t,this.onStorageError);else if(a.status===`persisted`){let e=a.revision??i;return this.adoptCommittedRevision(t,e,a.writeId),{revision:e,writeId:a.writeId}}})(),n.retirement.then(()=>{})}captureSubmission(){this.pendingModelSelectionMutation=!1,this.reconcileHandoffCommit(),this.submittedMutation=this.mutation,this.mutationGeneration===this.pristineMutationBaseline&&(this.restorePromise&&(this.contentReconciled=!1),this.restoreGeneration+=1),this.persistNow();let e=this.scope(),t=e?this.lineage(e):null;return{scope:e,mutation:this.mutation,revision:this.revision,incognito:this.read().incognito,pendingEdit:this.mutationGeneration>this.pristineMutationBaseline&&this.mutation.committedRevision===0,writeIds:new Set([t?.writeId,this.mutation.writeId,...this.inheritedWriteIds,...t?.localWriteIds??[]])}}adoptHandoff(e){let t=this.scope();t&&e.scope&&U(t)===U(e.scope)&&(this.mutation=e.mutation,this.revision=Math.max(this.revision,e.revision),e.pendingEdit&&!e.mutation.committedRevision&&(this.pristineMutationBaseline=this.mutationGeneration-1,this.pendingHandoffMutation=e.mutation),this.inheritedWriteIds=[...e.writeIds])}async clearSubmittedDraft(t,n){t.mutation.retired=!0;let{scope:r}=t,i=this.scope();if(this.mutation===t.mutation&&(!r&&!i||r&&i&&U(r)===U(i))&&(this.modelSelection?.retire(),n?.()),await Promise.all(t.mutation.writes),!r)return;let{readDurableComposerDraft:a}=await dl;for(let n=0;n<3;n+=1){let n=await a(r);if(n.status===`storage-failed`){H(r,this.onStorageError);return}if(n.status!==`found`||!t.writeIds.has(n.draft.writeId))return;let i=n.draft.revision,o=n.draft.writeId,s=Ft(i),c=`clear:${s}`,{result:l}=await Ra({scope:r,expectedRevision:i,...o?{expectedWriteId:o}:{},revision:s,text:``,storedAttachments:[],writeId:c});if(l.status===`persisted`){this.adoptCommittedRevision(r,l.revision??s,l.writeId??c);for(let t of e.active){let e=t.scope();e&&U(e)===U(r)&&(t.restoredIdentity=``,t.activateRoute(e.scopeKey))}return}if(l.status===`storage-failed`){H(r,this.onStorageError);return}}}persistNow(){this.clearTimer();let e=this.pending;if(!e)return;if(this.read().incognito){this.discardPending();return}this.pending=null;let t=(async()=>{try{let t=e.retirement?await e.retirement:void 0;if(e.mutation.retired||!this.lineage(e.scope).localWriteIds.has(e.writeId))return;let n=t&&t.revision>e.expectedRevision?{...e,expectedRevision:t.revision,expectedWriteId:t.writeId,revision:Ft(Math.max(e.revision,t.revision))}:e,{result:r,payloadUnavailable:i}=await Ra(n);if(i&&H(e.scope,this.onStorageError),r.status===`persisted`||r.status===`payload-too-large`){let t=r.revision??n.revision;e.mutation.committedRevision=t,this.adoptCommittedRevision(e.scope,t,r.writeId??e.writeId),r.status===`payload-too-large`&&H(e.scope,this.onStorageError);return}if(r.status===`storage-failed`){H(e.scope,this.onStorageError);return}if(this.disconnected||e.mutation.retired||this.routeKey!==e.scope.scopeKey||this.revision!==e.revision)return;this.restoredIdentity=``,this.activateRoute(this.routeKey)}finally{this.forgetLocalWrite(e)}})();e.mutation.writes.add(t),t.finally(()=>e.mutation.writes.delete(t))}connect(){this.disconnected=!1,e.active.add(this)}disconnect(){this.disconnected=!0,e.active.delete(this),this.persistNow(),this.restoreGeneration+=1}scope(){return!this.gatewayOwner||!this.recoveryScope||!this.routeKey?null:{gatewayOwner:this.gatewayOwner,recoveryScope:this.recoveryScope,scopeKey:this.routeKey}}snapshot(){let e=this.scope();if(!e||this.revision<=0||this.mutation.retired)return null;let t=this.read(),n=this.lineage(e),r=[...n.localWriteIds],i=this.mutation.writeId;return n.localWriteIds.add(i),{scope:e,mutation:this.mutation,retirement:n.retirement,expectedRevision:n.revision,...n.writeId?{expectedWriteId:n.writeId}:{},expectedWriteIds:r,revision:this.revision,text:t.message,...t.mentions?.length?{mentions:t.mentions.map(e=>({...e}))}:{},modelSelection:this.modelSelection?.read(),storedAttachments:Na(t.attachments),writeId:i}}isRestoreCurrent(e,t,n,r){let i=this.read(),a=this.scope();return t===this.restoreGeneration&&n===this.mutationGeneration&&a!==null&&U(e)===U(a)&&r===qa(i.message,i.attachments,void 0,i.mentions)}async restoreScope(e,t,n,r){let{readDurableComposerDraft:i}=await dl,a=await i(e);if(a.status===`storage-failed`)return H(e,this.onStorageError),!1;let o=a.status===`found`?a.draft.revision:a.revision,s=a.status===`found`?a.draft.writeId:a.writeId,c=this.lineage(e);if(c.revision=o??0,c.writeId=s,!this.isRestoreCurrent(e,t,n,r)||(this.reconcileHandoffCommit(),this.submittedMutation===this.mutation&&this.mutation.committedRevision>0))return!1;if(o===void 0||o<this.revision||n>this.pristineMutationBaseline)return o!==void 0&&o>=this.revision?this.revision=Ft(o):this.revision<=0&&n>this.pristineMutationBaseline&&(this.revision=Ft(0)),this.pending=this.snapshot(),this.persistNow(),!0;let l=[];if(a.status===`found`)try{l=await Wa(a.draft.attachments)}catch{return H(e,this.onStorageError),!1}return this.isRestoreCurrent(e,t,n,r)?(this.revision=o,a.status===`found`&&a.draft.mentions?this.apply(a.draft.text,l,void 0,a.draft.mentions):this.apply(a.status===`found`?a.draft.text:``,l),this.modelSelection?.restore(a.status===`found`?a.draft.modelSelection:void 0),this.mutation.committedRevision=o,!0):!1}reconcileHandoffCommit(){this.pendingHandoffMutation===this.mutation&&this.mutation.committedRevision>0&&this.submittedMutation!==this.mutation&&(this.revision=Math.max(this.revision,this.mutation.committedRevision),this.pristineMutationBaseline=this.mutationGeneration,this.pendingHandoffMutation=null)}clearTimer(){this.timer!==null&&(globalThis.clearTimeout(this.timer),this.timer=null)}discardPending(){this.clearTimer();let e=this.pending;this.pending=null,e&&this.forgetLocalWrite(e)}forgetLocalWrite(e){let t=U(e.scope),n=this.lineageByScope.get(t);n&&(n.localWriteIds.delete(e.writeId),!n.revision&&!n.writeId&&!n.localWriteIds.size&&!n.retirement&&this.lineageByScope.delete(t))}lineage(e){let t=U(e),n=this.lineageByScope.get(t);return n||(n={revision:0,localWriteIds:new Set},this.lineageByScope.set(t,n)),n}adoptCommittedRevision(e,t,n){let r=U(e),i=this.lineage(e);i.revision=t,n&&(i.writeId=n);let a=this.scope();a&&U(a)===r&&t>this.revision&&(this.revision=t)}}})))()}function hl(e,t){let{os:n,machineClass:r}=t.cloudSelection;return e.sessionKey?e.target:t.cloudProfileId?{kind:`profile`,profileId:t.cloudProfileId,...n?{os:n}:{},...r?{machineClass:r}:{}}:t.deviceId?{kind:`device`,deviceId:t.deviceId}:t.autoDevice?{kind:`auto-device`}:null}function gl(e){let t=e.createParams?.incognito?`incognito`:e.createParams?.visibility===`draft`?`draft`:`normal`;return{placement:{agentId:e.agentId,profileId:e.target.kind===`profile`?e.target.profileId:``,...e.target.kind===`profile`?{os:e.target.os,machineClass:e.target.machineClass}:e.target.kind===`device`?{deviceId:e.target.deviceId}:{autoDevice:!0},cwd:e.createParams?.cwd,...e.createParams?.worktreeSource?{worktreeSource:e.createParams.worktreeSource}:{},...e.createParams?.repository?{repository:{...e.createParams.repository}}:{}},draft:{message:e.message,...e.mentions?.length?{mentions:e.mentions}:{},attachments:oe(e.attachments),visibility:t,toolOverrides:e.createParams?.toolOverrides??null,permissionMode:e.createParams?.permissionMode}}}async function _l(e){let{pending:t,submittedRecovery:n,sessionKey:r}=e,{gatewayUrl:i,recoveryScope:a}=n,o=e=>t.owns(i,a,e),s=()=>o(n.sessionKey);if(n.phase===`creating`&&(!e.isLifecycleCurrent()||!s())){if(t.hasOtherLiveOwner(i,a,n.sessionKey))return;let o=await Ta({client:e.client,describe:e.context.sessions.describe},r,e.agentId);o?(s()&&(t.promoteToDispatching(r),t.retryAllowed=!0),e.setError(E(`newSession.placementStartFailed`,{error:o}))):s()&&e.clearRecovery();return}if(n.phase===`creating`&&e.isLifecycleCurrent()&&s()&&!t.promoteToDispatching(r)){e.onRecoveryUnavailable();return}let c=t.capture();if(!c||c.phase===`creating`){e.onRecoveryUnavailable();return}if(!e.isRequestCurrent())return;e.context.placementStartup.start({recovery:c,persistRecovery:t.persistent,mode:n.phase===`creating`?`dispatch`:`recover`,createdAt:e.createdAt}),await e.consumeWorktreeName?.();let l=()=>e.isLifecycleCurrent()&&o(c.sessionKey);if(l()&&(await e.clearDraft(),l())){if(t.reset(),e.completeInBackground(c.sessionKey,c.messageId)){e.onAccepted();return}await e.navigate()}}function vl(){return(vl=e((()=>{l(),I(),ba(),n(),L()})))()}var yl;function bl(){return(bl=e((()=>{Ct(),Tn(),yl=class{constructor(e){this.gateway=e,this.pending=null}get active(){return this.pending!==null}start(e,t=!1){let n=this.gateway.sessionCreateScope;if(!n)return e;if(!this.pending){let r=Date.now();this.pending={params:Object.freeze({...e,idempotencyKey:kn()}),scope:n,startedAt:r,deadline:r+wt,interrupted:!1,background:t}}return this.pending.params}clear(){this.pending=null}interrupt(){return!this.pending||!this.matchesGateway()?(this.clear(),!1):(this.pending.interrupted=!0,!0)}retireChangedOwner(){return!this.pending||this.matchesGateway()?!1:(this.clear(),!0)}resume(){return this.pending?.interrupted?Date.now()>=this.pending.deadline?(this.clear(),{kind:`expired`}):this.matchesGateway()?this.gateway.connected?(this.pending.interrupted=!1,{kind:`resume`,params:this.pending.params,startedAt:this.pending.startedAt,background:this.pending.background}):{kind:`wait`}:(this.clear(),{kind:`owner-changed`}):{kind:`wait`}}matchesGateway(){return this.pending?.scope===this.gateway.sessionCreateScope}}})))()}function xl(e,t){return rl({...t,deferInitialTurn:e.remotePlacement,agentId:e.agentId,model:e.modelControl.modelForSubmission(),agentRuntime:e.modelControl.agentRuntime,contextWindow:e.modelControl.contextWindow,thinkingLevel:e.modelControl.thinkingLevel,fastMode:e.modelControl.fastMode,projectId:e.browser.remoteProject?.projectId??e.browser.projectId,projectGitUrl:e.browser.remoteProject?.cloneUrl,repository:e.remoteRepository,worktree:e.worktree,worktreeSource:e.freshWorkspace?`empty`:void 0,baseRef:e.baseRef,worktreeName:e.worktreeName,cwd:e.folder,workspace:e.workspacePath()})}function Sl(){return(Sl=e((()=>{al()})))()}function Cl(e,t,n,r,i={}){return xl(e,{...i,message:i.message??``,toolOverrides:n.capabilities.toolOverrides,permissionMode:n.permissionMode,visibility:i.visibility??n.visibility,catalogId:r.data?.catalogId,category:t.resolvedGroupCategory()})}function wl(e,t,n,r,i=!1){let a=t.pendingPlacement,o=!r&&!!a.sessionKey,s=Wt(t.message,t.mentions),c=r?.params.message??(o?a.message:s.text),l=(r?r.params.mentions:o?a.mentions:s.mentions)?.map(({profileId:e,start:t,end:n})=>({profileId:e,start:t,end:n})),u=t.attachmentDraft.attachments;if(!r&&!o){let t=Hr(u,e.gateway.snapshot.hello?.policy);if(t!==void 0)return Te({message:t}),null}let d=r?r.params.attachments:o?void 0:ja(u),f=o?a.attachments:d,p=r?.params.agentId??(o?a.agentId:V(n.agentId)),m=o?a.gatewayUrl:e.gateway.connection.gatewayUrl,h=e.gateway.snapshot.client;if(!h||!e.gateway.snapshot.hello)return null;let g=Zc({enabled:i,agentId:p,client:h,context:e}),_=o?a.recoveryScope:h.recoveryScope,v=r?.params??(o?a.createParams:xl(n,{message:c,visibility:t.visibility}));return{consumeWorktreeName:v&&n.captureSubmittedWorktreeName(v,p,!!(r||o)),pendingPlacement:o,message:c,mentions:l,attachments:u,draftAttachments:d,apiAttachments:f,agentId:p,gatewayUrl:m,client:h,recoveryScope:_,completeInBackground:g,hasInitialTurn:!!(c||f?.length)}}function Tl(e,t,n){let{hello:r,selfUser:i}=e.gateway.snapshot,a=pn(r,t.client.instanceId,i)??void 0;return{text:t.message,mentions:t.mentions,attachments:t.attachments,createdAt:n,sender:a}}function El(){return(El=e((()=>{an(),on(),_(),fe(),Xi(),ga(),el(),Sl()})))()}function Dl(e,t,n){let{router:r,lifecycleAbortSignal:i}=e,a=new AbortController,o=r.navigate(t,e,{history:`none`},n),s=r.getState().location,c=i?AbortSignal.any([a.signal,i]):a.signal,l=r.subscribe(e=>{e.location!==s&&a.abort()});return c.addEventListener(`abort`,l,{once:!0}),{ready:o.catch(()=>void 0),signal:c,isActive:()=>!c.aborted&&r.getState().location===s,dispose:()=>{l(),c.removeEventListener(`abort`,l)}}}function Ol(e,t){let n=Ml.get(e);if(n&&n.search===t&&n.owns())return Ml.delete(e),Nl.set(n.draft.data,{page:n.draft.page,canDisplay:n.canDisplay}),n.draft.data}function kl(e,t){e&&Nl.get(e)?.page===t&&Nl.delete(e)}function Al(e){let t=e&&typeof e==`object`?Nl.get(e):void 0;return t?.canDisplay()?t.page:void 0}function jl(e,t){return Ml.set(e,t),()=>{Ml.get(e)===t&&Ml.delete(e)}}var Ml,Nl;function Pl(){return(Pl=e((()=>{Ml=new WeakMap,Nl=new WeakMap})))()}function Fl(e){let{context:t,params:n,agentId:r,retainDraft:i}=e;if(!e.enabled||!t.gateway.snapshot.hello?.auth?.recoveryScope||!i)return;let a=(e.resumed?n.key:void 0)??`agent:${r}:dashboard:${n.incognito?`incognito-`:``}${kn()}`;return e.resumed||(n.key=a),()=>{let n=i();return n?new Il(t,a,r,n,e.message):void 0}}var Y,Il;function Ll(){return(Ll=e((()=>{Ye(),Ne(),f(),Tn(),Pl(),Y=new WeakMap,Il=class{constructor(e,t,n,r,i){this.context=e,this.key=t,this.draft=r,this.stopGateway=()=>{},this.clearPendingCreate=()=>{},this.disposed=!1,this.lifetime=new AbortController,this.onLeave=()=>{this.dispose()},this.creation={sessionKey:t,admitted:!1},this.client=e.gateway.snapshot.client,this.hello=e.gateway.snapshot.hello,this.gatewayUrl=e.gateway.connection.gatewayUrl,this.recoveryScope=this.hello?.auth?.recoveryScope,this.presentationScope=st(e.gateway);let a=Y.get(e);this.previousSessionKey=e.gateway.snapshot.sessionKey,this.previousAgentId=e.agentSelection.state.selectedId,a?.dispose(),this.returnLocation={pathname:globalThis.location.pathname,search:globalThis.location.search,hash:globalThis.location.hash},Y.set(e,this);let o={pathname:b({context:e,face:`chat`,sessionKey:t,agentId:n,exactKey:!0}).options.pathname,search:``,hash:``};this.transition=Dl(e,`chat`,o),this.clearPendingCreate=e.chatSubmissions.beginCreate({creation:this.creation,message:i,canDisplay:()=>this.canDisplay()}),this.transition.signal.addEventListener(`abort`,this.onLeave,{once:!0}),this.stopGateway=e.gateway.subscribe(()=>{let t=e.gateway.snapshot;(t.phase!==`connected`||t.hello!==this.hello||t.client!==this.client||e.gateway.connection.gatewayUrl!==this.gatewayUrl||t.hello?.auth?.recoveryScope!==this.recoveryScope)&&(t.phase!==`connected`&&e.gateway.connection.gatewayUrl===this.gatewayUrl&&r.synchronizeGateway(),this.rollback())})}sameIdentity(){let{gateway:e}=this.context;return!!this.recoveryScope&&e.connection.gatewayUrl===this.gatewayUrl&&e.snapshot.phase===`connected`&&e.snapshot.hello?.auth?.recoveryScope===this.recoveryScope}canDisplay(){return st(this.context.gateway)===this.presentationScope&&this.context.gateway.connection.gatewayUrl===this.gatewayUrl&&(this.context.gateway.snapshot.phase!==`connected`||this.sameIdentity())}liveConnection(){return this.sameIdentity()&&this.context.gateway.snapshot.client===this.client&&this.context.gateway.snapshot.hello===this.hello}ownsSelection(){let e=this.admittedSelection?.key??this.previousSessionKey,t=this.admittedSelection?.agentId??this.previousAgentId;return this.context.gateway.snapshot.sessionKey===e&&this.context.agentSelection.state.selectedId===t}async waitForReady(){await this.transition.ready}isCurrent(){return!this.disposed&&!this.rollingBack&&Y.get(this.context)===this&&this.transition.isActive()&&this.liveConnection()&&this.ownsSelection()}rollback(){return this.rollingBack??=this.restore(),this.rollingBack}async restore(){await this.transition.ready;try{await Ue(this.context.gateway,this.lifetime.signal)}catch{return}if(this.disposed||Y.get(this.context)!==this||!this.transition.isActive())return;let e=this.sameIdentity()&&this.ownsSelection();this.transition.dispose(),this.stopGateway();let t=this.context.agentSelection.state.selectedId,n={draft:this.draft,search:this.returnLocation.search??``,owns:()=>Y.get(this.context)===this&&!this.disposed&&this.sameIdentity(),canDisplay:()=>this.sameIdentity()&&this.context.agentSelection.state.selectedId===t},r=()=>{};e&&(this.draft.synchronizeGateway(),r=jl(this.context,n));try{let e=Dl(this.context,`new-session`,this.returnLocation);await e.ready,await new Promise(e=>{globalThis.setTimeout(e,0)}),e.dispose()}finally{r(),this.dispose()}}admitted(e,t){this.admittedSelection={key:e,agentId:t},!this.disposed&&e===this.key&&(this.creation.admitted=!0,this.clearPendingCreate())}commit(){return this.disposed||this.rollingBack||!this.transition.isActive()||!this.liveConnection()?!1:(this.transition.dispose(),this.stopGateway(),!0)}async finish(){await this.rollingBack,this.dispose()}dispose(){this.disposed||(this.disposed=!0,this.lifetime.abort(),this.clearPendingCreate(),this.transition.dispose(),this.stopGateway(),Y.get(this.context)===this&&Y.delete(this.context),this.draft.release())}}})))()}async function Rl(e,t){let n=t.name?.trim(),r=t.baseRef?.trim();return e.request(`worktrees.create`,{repoRoot:t.repoRoot.trim(),...n?{name:n}:{},...r?{baseRef:r}:{}})}function zl(){return(zl=e((()=>{})))()}function Bl(e,t){let n=x(e,{method:`sessions.catalog.startTerminal`,requiredScope:`operator.admin`});return!n.allowed||!t?n:x(e,{method:`worktrees.create`,requiredScope:`operator.admin`})}async function Vl(e,t,n){let r=t.cwd;if(t.worktree){let i=await Rl(e,{repoRoot:r,name:t.worktreeName,baseRef:t.baseRef});if(!n())return null;r=i.path}return Br(e,{catalogId:t.catalogId,agentId:t.agentId,hostId:t.hostId,cwd:r,...t.initialMessage?{initialMessage:t.initialMessage}:{}},n)}async function Hl(e){let{context:t,data:n}=e.snapshot,{place:r,flow:i}=e,a=t?.gateway.snapshot.client,o=n?.catalogId.trim()??``,s=V(r.agentId);if(!t||!a||!o||!s||!i.canSubmit()){i.noteBlockedSubmitAttempt();return}let c=e.capture(a),l=i.message.trim(),u={catalogId:o,agentId:s,hostId:r.terminalHostId,cwd:r.folder.trim()||(r.terminalOnNode?``:r.workspacePath()),initialMessage:l,worktree:r.worktree,worktreeName:r.worktreeName,baseRef:r.baseRef},d=r.captureSubmittedWorktreeName(u,s);c.publish(si({text:l,createdAt:Date.now()},`available`),!0),r.browser.close(),e.closeTransientUi();try{let e=await Vl(a,u,c.isCurrent);if(!e||!c.isCurrent()||(await d?.(),!c.isCurrent()))return;await c.consume(),c.isCurrent()&&t.replace(`terminal`,{pathname:Ae(e.sessionId,t.basePath),search:``,hash:``})}catch(e){c.isCurrent()&&i.setError(e instanceof Error?e.message:String(e))}finally{c.isRequestCurrent()&&c.publish(null,!1)}}function Ul(e){return e.hosts?e.hosts.length===0?A`<span class="new-session-page__catalog-unavailable" role="status">
${E(`newSession.nativeHostsUnavailable`)}
</span>`:e.hosts.length===1&&e.hosts[0]?.hostId===e.hostId?j:A`<div class="new-session-page__select new-session-page__menu-field">
<span>${E(`newSession.where`)}</span>
<select
class="new-session-page__trigger"
aria-label=${E(`newSession.where`)}
.value=${e.hostId}
?disabled=${e.submitting}
@change=${t=>{t.currentTarget instanceof HTMLSelectElement&&e.onSelect(t.currentTarget.value)}}
>
${e.hosts.some(t=>t.hostId===e.hostId)?j:A`<option value=${e.hostId} selected disabled>
${E(`newSession.chooseNativeHost`)}
</option>`}
${e.hosts.map(t=>A`<option value=${t.hostId} ?selected=${t.hostId===e.hostId}>
${t.label}
</option>`)}
</select>
</div>`:j}function Wl(){return(Wl=e((()=>{M(),rt(),l(),I(),u(),Di(),_(),di(),L()})))()}function Gl(e){let{gateway:t,place:n,pendingPlacement:r,hasInitialTurn:i,createParams:a}=e,o=!!r.sessionKey,s=hl(r,n),c=!s&&!i?n.browser.remoteProject:null;if(!o&&c&&!c.projectId){let e=x(t,{method:`projects.add`,requiredScope:`operator.write`});if(!e.allowed)return e}if(!s||!o||r.phase===`creating`){let e=x(t,{method:`sessions.create`,params:a,sessionScope:!0});if(!e.allowed||!s)return e}return x(t,{method:`sessions.dispatch`,requiredScope:s.kind===`profile`?`operator.admin`:`operator.write`,params:sa({key:r.sessionKey,agentId:r.agentId||n.agentId,target:s})})}function Kl(e){let{snapshot:t,gateway:n,place:r,pendingPlacement:i}=e,a=r.selectedAgent(),o=t.context?.agents.state;return r.modelControl.requiresModelSetup({catalog:W(t.data)||r.remotePlacement||!!i.sessionKey,connected:n.connected,agentsLoaded:!!o?.agentsList,selectedAgentFound:a!==void 0,agentModel:a?.model?.primary})}function ql(e,t,n,r){let i=W(r.data)?`terminal`:`session`,a=!!n.pendingPlacement.sessionKey;if(n.mentions.length>0&&(i===`terminal`||n.visibility===`incognito`||n.message.trimStart().startsWith(`/`)))return{gate:`mentions-unsupported`,reason:E(`chat.mentions.unsupported`)};if(e.preferenceLoading||i===`session`&&t.modelControl.isRestoringPreference()||!t.placementPreferenceReady)return{gate:`preference-restore`,reason:E(`newSession.restoringPreferences`)};if(i===`session`&&n.requiresModelSetup())return{gate:`model-setup`,reason:E(`modelSetup.required.title`)};if(yo(r.data,r.context?.sessions))return{gate:`route-pending`,reason:E(`newSession.catalogUnavailable`)};if(n.attachmentDraft.reads.pendingReads>0)return{gate:`attachment-reads`,reason:E(`newSession.readingAttachment`)};if(!a&&n.submissionOutcomeUnknown)return{gate:`outcome-unknown`,reason:E(n.submissionOutcomeUnknown===`gateway-changed`?`newSession.createOutcomeUnknown`:`newSession.placementSetupInterrupted`)};let o=r.context?.gateway,s=o?.snapshot.phase===`connected`?o.snapshot.client??null:null;if(!o||!s)return{gate:`disconnected`,reason:E(`sessionsView.actionRequiresConnection`)};let c=i===`terminal`?Bl(o.snapshot,t.worktree):n.submissionAccess();if(!c.allowed)return{gate:`access`,reason:c.reason};if(i===`terminal`){if(r.context?.config.current.cliAgentsEnabled!==!0||!r.context.config.current.terminalEnabled)return{gate:`terminal-capabilities`,reason:E(`newSession.terminalDisabled`)};if(!r.data?.terminalHosts?.some(e=>e.hostId===t.terminalHostId))return{gate:`device`,reason:E(`newSession.terminalHostUnavailable`)};if(n.attachmentDraft.attachments.length>0)return{gate:`terminal-capabilities`,reason:E(`newSession.terminalAttachmentsUnsupported`)};if(t.remotePlacement||n.pendingPlacement.sessionKey)return{gate:`device`,reason:E(`newSession.terminalPlacementUnsupported`)}}if(i===`terminal`&&n.capabilities.toolOverrides!==null)return{gate:`terminal-capabilities`,reason:E(`newSession.terminalCapabilityOverridesUnsupported`)};if(t.folderSubmissionBlocked())return{gate:`folder`,reason:E(`newSession.checkingPlace`)};if(a)return n.pendingPlacement.retryAllowed&&s.recoveryScopeReady&&hl(n.pendingPlacement,t)&&n.pendingPlacement.agentId&&n.pendingPlacement.gatewayUrl===o.connection.gatewayUrl&&n.pendingPlacement.recoveryScope===s.recoveryScope?Jl(n,i,a):{gate:`placement-recovery`,reason:E(`newSession.placementNotReady`)};if(!r.context?.agents.state.agentsList)return{gate:`agents`,reason:E(r.context?.agents.state.agentsError?`newSession.agentDefaultsUnavailable`:`newSession.loadingAgentDefaults`)};let l=i===`session`&&t.modelControl.modelSelectionBlockedReason(t.selectedAgent());if(l)return{gate:`model-unavailable`,reason:l};if(t.agents().length===0)return{gate:`agents`,reason:E(`newSession.agentsUnavailable`)};if(!So(r.data,t.selectedAgent()))return{gate:`agent-not-allowed`,reason:E(`newSession.catalogUnavailable`)};let u=i===`session`?t.devicePlacement():void 0;if(u&&!u.ready)return{gate:`device`,reason:u.disabledReason??E(`newSession.nodeUnavailable`)};let d=t.modelControl.devicePlacementUnsupportedReason();if((t.deviceId||t.autoDevice)&&d)return{gate:`device-runtime`,reason:d};let f=hl(n.pendingPlacement,t);if(f&&(!s.recoveryScope||!s.recoveryScopeReady||e.cloudProfilesPending))return{gate:`placement-recovery`,reason:E(`newSession.placementNotReady`)};let p=f?.kind===`profile`?f.profileId:``;if(p){let n=t.modelControl.cloudRuntimeUnsupportedReason(e.cloudProfiles.find(e=>e.id===t.cloudProfileId));if(!e.cloudProfilesReady||!e.cloudProfiles.some(e=>e.id===p)||n)return{gate:`cloud`,reason:n??E(`newSession.placementNotReady`)}}return t.worktree&&!t.freshWorkspace&&!t.worktreeAvailable()?{gate:`worktree-unavailable`,reason:t.repository.kind===`checking`?E(`newSession.checkingGit`):t.remotePlacement?E(`newSession.remoteSourceUnavailable`):E(`newSession.gitCheckUnavailable`)}:t.worktree&&!t.freshWorkspace&&!nl(t.worktreeName)?{gate:`worktree-name`,reason:E(`newSession.worktreeNameInvalid`)}:i===`terminal`&&!(t.folder.trim()||!t.terminalOnNode&&t.workspacePath())?{gate:`terminal-folder`,reason:E(`newSession.terminalNeedsFolder`)}:Jl(n,i,a)}function Jl(e,t,n){if(t!==`session`)return;let r=n?e.pendingPlacement.message:e.message.trim(),i=n?!!e.pendingPlacement.attachments?.length:e.attachmentDraft.attachments.length>0;return r||i?void 0:{gate:`empty-draft`}}var Yl;function Xl(){return(Xl=e((()=>{l(),I(),u(),ba(),G(),al(),vl(),Wl(),L(),Yl=new Set([`attachment-reads`,`outcome-unknown`,`worktree-name`])})))()}var Zl;function Ql(){return(Ql=e((()=>{l(),I(),on(),u(),pe(),ya(),qc(),el(),sl(),G(),ll(),ml(),vl(),bl(),El(),za(),Ll(),js(),wi(),Xl(),Wl(),L(),Zl=class{get messageValue(){return this.messageText}set messageValue(e){e!==this.messageText&&(this.messageText=e,this.callbacks.onMessageChange?.(e))}constructor(e,t,n,r){this.gateway=e,this.place=t,this.read=n,this.callbacks=r,this.visibilityValue=`normal`,this.messageText=``,this.mentionsValue=[],this.activeSubmission=null,this.blockedSubmitGate=null,this.rejectedPromptError=null,this.submissionOutcomeUnknown=null,this.startedSession=new Ga,this.error=null,this.submitRequestToken=0,this.pendingPlacement=new As(()=>this.read().context),this.composerTextarea=new cl,this.buildDraftSessionCreateParams=(e={})=>Cl(this.place,this.gateway,this,this.read(),e),this.submissionAccess=(e=this.pendingPlacement.createParams??this.buildDraftSessionCreateParams())=>Gl({gateway:this.read().context?.gateway.snapshot,place:this.place,pendingPlacement:this.pendingPlacement,hasInitialTurn:!!(this.messageValue.trim()||this.attachmentDraft.attachments.length),createParams:e}),this.submitDisabledReason=()=>this.submitBlock()?.reason,this.canSubmit=()=>this.submitBlock()===void 0,this.requiresModelSetup=()=>Kl({snapshot:this.read(),gateway:this.gateway,place:this.place,pendingPlacement:this.pendingPlacement}),this.capabilities=new ol(r.requestUpdate),this.capabilities.setMutationCallback(()=>this.startedSession.current=null),this.sessionStartup=new yl(e),this.draftPersistence=new pl(()=>({message:this.messageValue,mentions:this.mentionsValue,attachments:this.attachmentDraft.attachments,incognito:this.visibilityValue===`incognito`}),(e,t,n,r)=>{this.restoreDraftState({message:e,mentions:r,attachments:t,visibility:n?`normal`:this.visibilityValue})},()=>this.setError(na)),this.attachmentDraft=new Kc(r.requestUpdate,()=>{this.rejectedPromptError=null,this.startedSession.current=null,this.draftPersistence.noteUserMutation()})}get visibility(){return this.visibilityValue}get message(){return this.messageValue}get mentions(){return this.mentionsValue}get submitting(){return this.activeSubmission!==null||this.sessionStartup.active}get pendingMessage(){return this.activeSubmission?.message??this.completedSubmission?.message??null}get completedSubmission(){return this.activeSubmission?null:this.startedSession.submission(this.read().context)}openSubmittedSession(){return this.startedSession.openSubmission(this.read().context,this.completedSubmission,{capture:()=>{let e=++this.submitRequestToken;return()=>e===this.submitRequestToken},publish:(e,t)=>{this.activeSubmission=e?{phase:`accepted`,message:e}:null,t!==void 0&&(this.error=t),this.callbacks.requestUpdate()}})}resumeInterruptedSubmission(){let e=this.sessionStartup.resume();e.kind===`resume`?this.submit(e):e.kind!==`wait`&&(this.activeSubmission=null,this.submissionOutcomeUnknown=`gateway-changed`,this.callbacks.requestUpdate())}setMessage(e,t){e!==this.messageValue&&(this.rejectedPromptError=null),this.startedSession.current=null,this.mentionsValue=t??Gt(this.messageValue,e,this.mentionsValue),this.messageValue=e,this.draftPersistence.noteUserMutation(),this.callbacks.requestUpdate()}restoreMessage(e,t=[]){this.rejectedPromptError=null,this.draftPersistence.noteDraftReplaced(),this.messageValue=e,this.mentionsValue=t,this.callbacks.requestUpdate()}restoreDraftState(e){this.draftPersistence.noteDraftReplaced(),this.messageValue=e.message,this.mentionsValue=e.mentions??[],this.visibilityValue=e.visibility,this.capabilities.restoreToolOverrides(e.toolOverrides),`permissionMode`in e&&(this.permissionMode=e.permissionMode),this.attachmentDraft.restore(e.attachments)}setPermissionMode(e){this.permissionMode=e,this.startedSession.current=null,this.callbacks.requestUpdate()}setVisibility(e){this.startedSession.current=null;let t=this.visibilityValue===`incognito`,n=this.callbacks.requestUpdate;this.visibilityValue=e,this.draftPersistence.transitionIncognito(t,e===`incognito`,n)}setError(e){(e!==null||this.error===E(`newSession.cloudRecoveryUnavailable`))&&(this.error=e),this.callbacks.requestUpdate()}clearError(e){(e===void 0||this.error===e)&&(this.error=null,this.callbacks.requestUpdate())}markPendingPlacementUnavailable(e){this.pendingPlacement.retryAllowed=!1,this.submissionOutcomeUnknown=e,this.callbacks.requestUpdate()}noteBlockedSubmitAttempt(){this.blockedSubmitGate=this.submitBlock()?.gate??null,this.callbacks.requestUpdate()}blockedSubmitNotice(){let e=this.blockedSubmitGate?this.submitBlock():void 0;return e?.gate===this.blockedSubmitGate&&!Yl.has(e.gate)?e.reason:void 0}incognitoDisabledReason(){let e=x(this.read().context?.gateway.snapshot,{method:`sessions.create`,params:this.buildDraftSessionCreateParams({visibility:`incognito`})});return e.allowed?void 0:e.reason}submitBlock(){return this.rejectedPromptError?{gate:`initial-turn-rejected`,reason:this.rejectedPromptError}:!W(this.read().data)&&this.attachmentDraft.reads.pendingReads===0&&this.startedSession.isCurrent(this.read().context,this.place.agentId)?this.activeSubmission?{gate:`submitting`}:void 0:this.activeSubmission?{gate:`submitting`}:ql(this.gateway,this.place,this,this.read())}invalidate(e=null){this.submitRequestToken+=1,this.startedSession.current=null;let t=this.activeSubmission?.phase===`creating`,n=e!==null&&t&&this.sessionStartup.interrupt();(e&&t&&!n||this.sessionStartup.retireChangedOwner())&&(this.submissionOutcomeUnknown=e),n||(this.activeSubmission=null),this.callbacks.requestUpdate()}resetDraft(){this.startedSession.clearSubmission(),this.rejectedPromptError=null,this.sessionStartup.clear();let e=!!this.pendingPlacement.sessionKey;this.blockedSubmitGate=null,this.invalidate(),this.submissionOutcomeUnknown=e?this.submissionOutcomeUnknown??`placement-interrupted`:null,this.visibilityValue=`normal`,this.capabilities.reset(),this.permissionMode=void 0,this.attachmentDraft.reset({release:!0}),e?(this.pendingPlacement.restored||(this.pendingPlacement.retryAllowed=!1),this.applyRecoveryDraft(this.pendingPlacement.capture()),this.pendingPlacement.restored=!1):(this.clearPendingPlacementRecovery(),this.draftPersistence.noteDraftReplaced(),this.messageValue=``,this.mentionsValue=[]),this.clearError()}clearPendingPlacementRecovery(){this.pendingPlacement.clear(),this.submissionOutcomeUnknown=null,this.callbacks.requestUpdate()}releasePendingPlacementOwner(){this.pendingPlacement.reset(),this.submissionOutcomeUnknown=null,this.callbacks.requestUpdate()}restorePendingPlacementRecovery(e,t){this.applyRecoveryDraft(this.pendingPlacement.restore(e,t))}async submit(e,t=!1){if(!e&&W(this.read().data))return this.startInTerminal();let n=e?.background??(t&&this.visibilityValue!==`draft`),r=this.read().context;if(!r||!e&&!this.canSubmit()){this.noteBlockedSubmitAttempt();return}if(!ce(r.config)&&(this.attachmentDraft.attachments.length||this.pendingPlacement.attachments?.length||e?.params.attachments?.length)){this.error=le(),this.callbacks.requestUpdate();return}this.blockedSubmitGate=null;let i=wl(r,this,this.place,e,n);if(!i)return;let a=this.callbacks.takePreparedTitle?.(),o=++this.submitRequestToken,s=this.draftPersistence.captureSubmission(),c=e?.startedAt??Date.now(),l=Tl(r,i,c),u=this.startedSession.messageForTurn(r,this.place.agentId,l),d=this.startedSession.captureSubmission(r,i.agentId,u,()=>o===this.submitRequestToken);this.activeSubmission={phase:`creating`,message:u},this.error=null,this.place.browser.close(),this.callbacks.closeTransientUi(),this.callbacks.requestUpdate();let f;try{let t=this.startedSession.current;if(t&&this.startedSession.isCurrent(r,this.place.agentId)){await this.startedSession.navigate(r,t);return}this.startedSession.current=null;let u=e?null:hl(this.pendingPlacement,this.place);Qc(r,i.message,!!i.apiAttachments?.length,!e&&!i.pendingPlacement);let p=!e&&!i.pendingPlacement&&!u&&!i.hasInitialTurn?this.place.browser.remoteProject:null;if(p&&!p.projectId&&!this.place.browser.projectId){let e=await i.client.request(`projects.add`,{gitUrl:p.cloneUrl},{timeoutMs:null});if(o!==this.submitRequestToken||this.gateway.client!==i.client)return;this.place.browser.recordRemoteProjectId(p.cloneUrl,e.id)}let m=e?.params??this.buildDraftSessionCreateParams({message:i.message,mentions:i.mentions,displayName:a,visibility:this.visibilityValue===`draft`&&!this.capabilities.canStartAsDraft(this.read().context)?`normal`:this.visibilityValue,attachments:i.draftAttachments}),h=Fl({context:r,params:m,resumed:!!e,enabled:!n&&!u,agentId:i.agentId,retainDraft:this.callbacks.retainForHandoff,message:this.pendingMessage}),g=u?i.pendingPlacement?this.pendingPlacement.createParams:this.pendingPlacement.stageCreate({agentId:i.agentId,target:u,message:i.message,mentions:i.mentions,attachments:i.apiAttachments,gatewayUrl:i.gatewayUrl,recoveryScope:i.recoveryScope,createParams:m,persistent:this.visibilityValue!==`incognito`}):void 0,_=e?x(r.gateway.snapshot,{method:`sessions.create`,params:m,sessionScope:!0}):this.submissionAccess(g??m);if(!_.allowed){this.sessionStartup.clear(),this.error=_.reason;return}let v=u?this.pendingPlacement.capture():null;if(u&&!v){this.setPlacementRecoveryUnavailable(`creating`);return}i.apiAttachments?.length&&ve(r.config);let y=i.pendingPlacement&&this.pendingPlacement.phase!==`creating`?Promise.resolve({key:this.pendingPlacement.sessionKey,initialRun:{status:`idle`}}):r.sessions.createResult(g??e?.params??this.sessionStartup.start(m,n),{reconciliation:`background`});f=h?.();let b=await y;if(b&&!u&&b.initialRun.status!==`rejected`&&await i.consumeWorktreeName?.(),o!==this.submitRequestToken&&!u){b&&b.initialRun.status!==`rejected`&&await this.clearSubmittedDraft(!0,s,!1);return}if(!b){if(o!==this.submitRequestToken)return;this.sessionStartup.clear(),this.error=r.sessions.state.error??E(`newSession.createFailed`),f&&await f.rollback();return}if(u&&v){await _l({context:r,client:i.client,agentId:i.agentId,pending:this.pendingPlacement,submittedRecovery:v,sessionKey:b.key,createdAt:c,isRequestCurrent:()=>o===this.submitRequestToken,isLifecycleCurrent:()=>this.read().isConnected&&i.client.recoveryScopeReady&&o===this.submitRequestToken&&this.gateway.client===i.client&&this.gateway.gatewayUrl===i.gatewayUrl&&this.gateway.recoveryScope===i.recoveryScope,clearRecovery:()=>this.clearPendingPlacementRecovery(),setError:e=>this.setError(e),onRecoveryUnavailable:()=>this.setPlacementRecoveryUnavailable(`created`),clearDraft:()=>(d(b.key),this.clearSubmittedDraft(!0,s)),consumeWorktreeName:i.consumeWorktreeName,completeInBackground:i.completeInBackground,onAccepted:()=>this.callbacks.onAccepted?.({...b,agentId:i.agentId}),navigate:()=>this.startedSession.navigate(r,{client:i.client,key:b.key,agentId:i.agentId})});return}await Lr({onRejectedPrompt:n&&this.callbacks.retainRejectedPrompt?e=>{this.rejectedPromptError=e,this.error=e,this.sessionStartup.clear()}:void 0,context:r,client:i.client,agentId:i.agentId,result:b,turn:l,instant:f,navigation:this.startedSession,isCurrent:()=>o===this.submitRequestToken,clearDraft:(e,t)=>(t!==!1&&d(b.key,b.initialRun.status===`rejected`?b.initialRun.error:void 0),this.clearSubmittedDraft(e,s,t)),completeInBackground:i.completeInBackground,onAccepted:()=>this.callbacks.onAccepted?.({...b,agentId:i.agentId}),finishNavigation:()=>this.sessionStartup.clear()})}catch(e){o===this.submitRequestToken&&this.gateway.client===i.client&&(this.sessionStartup.clear(),this.error=e instanceof Error?e.message:String(e),f&&await f.rollback())}finally{f&&await f.finish(),o===this.submitRequestToken&&(this.activeSubmission=null,this.callbacks.requestUpdate())}}startInTerminal(){return Hl({snapshot:this.read(),place:this.place,flow:this,closeTransientUi:this.callbacks.closeTransientUi,capture:e=>{this.blockedSubmitGate=null,this.error=null;let t=++this.submitRequestToken,n=this.draftPersistence.captureSubmission(),r=()=>t===this.submitRequestToken;return{isRequestCurrent:r,isCurrent:()=>r()&&this.gateway.client===e,publish:(e,t)=>{this.activeSubmission=t?{phase:`creating`,message:e}:null,this.callbacks.requestUpdate()},consume:()=>(this.startedSession.current=null,this.clearSubmittedDraft(!0,n))}}})}clearSubmittedDraft(e,t,n=!0){return this.draftPersistence.clearSubmittedDraft(t,()=>{n?this.activeSubmission&&(this.activeSubmission.phase=`accepted`):this.activeSubmission=null,this.messageValue=``,this.mentionsValue=[],this.draftPersistence.noteDraftReplaced(),this.attachmentDraft.clearAfterSubmit(e),this.sessionStartup.clear()})}disconnect(){this.pendingPlacement.releaseClaim(),this.startedSession.current=null,this.draftPersistence.disconnect(),this.attachmentDraft.reset({release:!0}),this.composerTextarea.disconnect()}setPlacementRecoveryUnavailable(e){this.error=e===`creating`?E(`newSession.placementCreateFailed`):E(`newSession.placementStartFailed`,{error:`placement recovery storage is unavailable`})}applyRecoveryDraft(e){if(!e)return;let t=gl(e);this.place.applyPendingPlacement(t.placement),this.restoreDraftState(t.draft)}}})))()}function $l(e){return ru.has(e)}function eu(e){let t=new Map;for(let n of e){let e=(n.deviceId??n.instanceId)?.trim().toLowerCase();e&&n.roles?.includes(`node`)&&t.set(e,n.reason?.trim().toLowerCase()===`disconnect`?`offline`:`connected`)}return JSON.stringify([...t].toSorted(([e],[t])=>e.localeCompare(t)))}function tu(e){let t=e.querySelector(`.new-session-page__select--agent wa-dropdown`);t&&(t.open=!1)}function nu(e){for(let t of[`wa-dropdown[open]`,`wa-popover.new-session-page__picker-popover`])for(let n of e.querySelectorAll(t))n.open=!1}var ru;function iu(){return(iu=e((()=>{ru=new Set([`config.changed`,`node.pair.requested`,`node.pair.resolved`,`node.runnerInventory.changed`,`device.pair.requested`,`device.pair.resolved`])})))()}var au;function ou(){return(ou=e((()=>{je(),at(),Be(),l(),fe(),r(),ii(),G(),Ps(),ec(),Gc(),Ql(),iu(),au=class{protectPrivateDraftFromReload(){let e=()=>this.submission.visibility===`incognito`&&!!(this.submission.message||this.submission.mentions.length||this.submission.attachmentDraft.attachments.length||this.submission.attachmentDraft.reads.pendingReads),t=(e=!1)=>Te({message:E(e?`chat.privateDraftReload.changed`:`chat.privateDraftReload.blocked`),actionLabel:E(`chat.privateDraftReload.review`),onAction:()=>void n()}),n=async()=>{let n=this.read().context;if(!n||!this.read().isConnected||!e()||this.privateDraftReview)return;let r=new AbortController,i=n.gateway.snapshot.client,a=n.gateway.connection,o=this.submission.message,s=this.submission.mentions,c=[...this.submission.attachmentDraft.attachments],l=this.submission.attachmentDraft.reads.pendingReads,u=()=>!r.signal.aborted&&this.read().isConnected&&this.read().context===n&&n.gateway.snapshot.client===i&&n.gateway.connection===a,d=()=>u()&&this.submission.visibility===`incognito`&&this.submission.message===o&&this.submission.mentions===s&&this.submission.attachmentDraft.reads.pendingReads===l&&this.submission.attachmentDraft.attachments.length===c.length&&c.every((e,t)=>this.submission.attachmentDraft.attachments[t]===e);this.privateDraftReview={controller:r,isCurrent:d};let f=Le(n.gateway);try{let n=await Aa({text:o,attachments:c,hasGoal:!1,pendingReads:l,isCurrent:d,signal:r.signal});if(!d()){u()&&e()&&t(!0);return}if(!n)return;this.submission.attachmentDraft.reset({release:!0}),this.submission.setMessage(``,[]),await Me({timeoutMs:0,...f})}catch{u()&&Te({message:E(`chat.privateDraftReload.unavailable`)})}finally{this.privateDraftReview?.controller===r&&(this.privateDraftReview=void 0),r.signal.reason===`draft-changed`&&this.read().isConnected&&this.read().context===n&&n.gateway.connection===a&&n.gateway.snapshot.client===i&&e()&&t(!0)}},r=Ie(()=>!e(),()=>t());return()=>{r(),this.privateDraftReview?.controller.abort()}}constructor(e,t,n){this.read=t;let r=()=>{this.privateDraftReview&&!this.privateDraftReview.isCurrent()&&this.privateDraftReview.controller.abort(`draft-changed`),n.requestUpdate()};this.gateway=new Ns(e,()=>({...t(),isAdmin:this.place?.isAdmin()??!1,canStartAsDraft:this.submission?.capabilities.canStartAsDraft(t().context)??!1,visibility:this.submission?.visibility??`normal`,cloudProfileId:this.place?.cloudProfileId??``,pendingPlacement:this.submission?.pendingPlacement??{sessionKey:``,gatewayUrl:``,recoveryScope:``},agentsHydrated:this.place?.agentsHydrated??!1,runtimeId:this.place?.devicePlacementRuntime()?.id??``}),{preferenceScope:n.preferenceScope,readPalettePreference:n.readPalettePreference,requestUpdate:r,updateComplete:()=>e.updateComplete,onInvalidate:(e,t)=>{this.invalidate(e,t),n.onInvalidate()},onVisibilityRetired:()=>this.submission.setVisibility(`normal`),onCloudProfileCleared:()=>this.place.clearCloudProfile(),onCloudState:e=>this.submission.setError(e),onPendingPlacementReset:()=>this.submission.releasePendingPlacementOwner(),onRecoveryReady:n.onRecoveryReady,onAdoptAgentDefaults:()=>this.place.adoptAgentDefaults({preserveSelectedAgent:!0,preserveSelectedFolder:!0})}),this.browser=new $s(e,this.gateway,()=>({context:t().context,isAdmin:this.place?.isAdmin()??!1}),{requestUpdate:r,onProjectMissing:()=>this.place.clearProjectSelection(),onSelectProject:e=>this.place.selectProjectId(e),onApprovedListing:e=>this.place.recordGatewayApprovedListing(e),querySelector:n.querySelector,activeElement:n.activeElement,body:n.body,pickerIdPrefix:n.pickerIdPrefix}),this.place=new Wc(this.gateway,this.browser,()=>({context:t().context,data:t().data,submitting:this.submission?.submitting??!1,pendingPlacementSessionKey:this.submission?.pendingPlacement.sessionKey??``}),{requestUpdate:r,onError:e=>e===null?this.submission.clearError():this.submission.setError(e),onClearError:e=>this.submission.clearError(e)}),this.submission=new Zl(this.gateway,this.place,t,{...n,requestUpdate:r}),this.submission.draftPersistence.modelSelection={read:()=>t().context?.config?.current.newSessionModelDefaults===`configured`?this.place.modelControl.draftSelection(this.place.agentId):void 0,restore:e=>this.place.modelControl.restoreDraftSelection(e),retire:()=>{t().context?.config?.current.newSessionModelDefaults===`configured`&&this.place.modelControl.retireDraftSelection()}},this.place.modelControl.onDraftSelectionChange=()=>{t().context?.config?.current.newSessionModelDefaults===`configured`&&this.submission.draftPersistence.noteModelSelectionMutation()},this.subscriptions=new de(e).effect(()=>this.read().context,()=>this.protectPrivateDraftFromReload()).watchStore(()=>this.read().context?.gateway,e=>this.gateway.synchronize(e)).effect(()=>this.read().context?.gateway,e=>{let t=eu(tt(e.snapshot.hello?.snapshot)??[]);return e.subscribeEvents(n=>{if(this.read().context?.gateway!==e)return;let r=n.event===`presence`?tt(n.payload):null,i=r?eu(r):t;($l(n.event)||i!==t)&&(t=i,this.gateway.refreshCloudProfiles(),this.gateway.handleCatalogRetry())})})}agentsReady(){let e=this.read().context?.agents.state;return!!(this.gateway.connected&&this.gateway.client&&e?.connected&&e.client===this.gateway.client&&this.place.agents().length>0)}synchronizeSelections(){let e=this.read().context?.config?.current.newSessionModelDefaults;if(!this.place.agentsHydrated&&this.agentsReady())this.place.setAgentsHydrated(!0),this.place.adoptAgentDefaults({preserveSelectedAgent:!0,preserveSelectedFolder:!0});else if(this.place.agentsHydrated&&e!==this.modelDefaultsPolicy){let{context:e,data:t}=this.read();this.place.modelControl.load(e,this.place.agentId,!W(t),{agent:this.place.selectedAgent(),preference:this.gateway.readPreference(this.place.agentId)})}e===`configured`&&this.modelDefaultsPolicy!==`configured`&&!this.submission.submitting&&this.place.modelControl.draftSelection(this.place.agentId)&&this.submission.draftPersistence.noteModelSelectionMutation(),this.modelDefaultsPolicy=e,this.place.restorePreferenceSelections(),this.place.synchronizeTerminalHosts()}invalidate(e,t){this.place.invalidateGatewayDiscovery(e),this.submission.attachmentDraft.reads.abortReads(),this.submission.invalidate(t),e&&this.submission.pendingPlacement.sessionKey&&this.submission.markPendingPlacementUnavailable(t),e&&this.submission.clearError()}disconnect(){this.subscriptions.clear(),this.gateway.invalidateDiscovery(!0,this.submission.pendingPlacement.sessionKey?`placement-interrupted`:`gateway-changed`),this.gateway.disconnect(),this.browser.disconnect(),this.submission.disconnect()}}})))()}function su(e){let t=e.context?.gateway,n=t?.snapshot.client,r=t?.snapshot.selfUser?.identity;if(n&&t?.snapshot.phase===`connected`&&r?.type===`profile`&&Je(t.snapshot.hello?.auth??null)&&!e.isCatalogTarget&&!e.nativeTerminal&&e.visibility!==`incognito`)return{client:n,ownerKey:JSON.stringify([t.connectionRevision,n.recoveryScope,r.id,e.draftOwnerKey]),params:{agentId:e.agentId,...e.visibility===`draft`?{visibility:`draft`}:{}}}}function cu(){return(cu=e((()=>{dt()})))()}function lu(e){_u=e.type===`pointerdown`}function uu(e,t){if(e.target!==e.currentTarget)return;let n=document.activeElement;if(n instanceof HTMLInputElement&&_u&&n.selectionStart!==n.selectionEnd){_u=!1,e.preventDefault();return}t()}function du(e){e?.querySelector(`input`)?.removeAttribute(`aria-activedescendant`);for(let t of e?.querySelectorAll(`[data-worktree-suggestion]`)??[])t.setAttribute(`aria-selected`,`false`)}function fu(e,t){if(!(e instanceof HTMLElement))return;let n=e.closest(`.new-session-page__branch-field`);n?.querySelector(`wa-popup`)?.toggleAttribute(`active`,t),(n?.querySelector(`input`))?.setAttribute(`aria-expanded`,String(t)),t||du(n)}function pu(e,t){let n=[...e.closest(`.new-session-page__branch-field`)?.querySelectorAll(`[data-worktree-suggestion]`)??[]];if(n.length===0)return!1;let r=n.findIndex(e=>e.getAttribute(`aria-selected`)===`true`);if(t.key===`Enter`&&!t.isComposing&&r>=0)return n[r].click(),!0;if(t.key!==`ArrowDown`&&t.key!==`ArrowUp`)return!1;let i=t.key===`ArrowDown`?1:-1,a=r<0?i===1?0:n.length-1:(r+i+n.length)%n.length;for(let[e,t]of n.entries())t.setAttribute(`aria-selected`,String(e===a));return e.setAttribute(`aria-activedescendant`,n[a].id),fu(e,!0),!0}function mu(e){let t=e.worktreeName.trim();return e.worktree&&!e.repository&&t?{label:E(`newSession.checkoutWorktreeNamed`,{name:t})}:e.destination===`cloud`?{label:e.baseRef?E(`newSession.checkoutCloudFrom`,{branch:e.baseRef}):E(`newSession.checkoutCloud`)}:e.repository?{label:e.baseRef?E(`newSession.checkoutRepositoryFrom`,{branch:e.baseRef}):E(`newSession.checkoutRepository`)}:e.worktree?{label:e.baseRef?E(`newSession.checkoutWorktreeFrom`,{branch:e.baseRef}):E(`newSession.checkoutWorktree`)}:{label:e.headBranch||E(`newSession.checkoutCurrent`)}}function hu(e){let t=t=>{let n=t.currentTarget;if(!(n instanceof HTMLElement))return;if(pu(n,t)){t.preventDefault(),t.stopPropagation();return}if(t.key===`Escape`){t.preventDefault(),t.stopPropagation(),n.closest(`wa-popover`)?.removeAttribute(`open`);return}let r=n.closest(`wa-popover`),i=r?.querySelector(`input[data-worktree-name]`)?.value??e.worktreeName;if(!(t.key!==`Enter`||t.isComposing||!e.repository&&!nl(i))&&(_u=!1,t.preventDefault(),r)){let t=n=>{n.target===r&&(r.removeEventListener(`wa-after-hide`,t),e.onConfirm())};r.addEventListener(`wa-after-hide`,t),r.removeAttribute(`open`)}},n=(e.branches?.branches??[]).slice(0,8),r=e.worktreeName.trim(),i=A`<input
id=${(e.idPrefix??`new-session`)+`-worktree-base-ref`}
type="text"
role=${n.length?`combobox`:j}
aria-label=${E(`newSession.worktreeBaseRef`)}
aria-autocomplete=${n.length?`list`:j}
aria-controls=${n.length?(e.idPrefix??`new-session`)+`-worktree-branch-suggestions`:j}
aria-expanded=${n.length?`false`:j}
?disabled=${e.submitting||e.pendingPlacement}
placeholder=${e.branchesLoading?E(`common.loading`):e.branches?.defaultBranch??E(`newSession.worktreeBaseRef`)}
.value=${e.baseRef}
@focus=${e=>fu(e.currentTarget,!0)}
@input=${t=>{t.currentTarget instanceof HTMLInputElement&&(du(t.currentTarget.closest(`.new-session-page__branch-field`)),fu(t.currentTarget,!0),e.onBaseRefInput(t.currentTarget.value))}}
@keydown=${t}
@pointerdown=${lu}
@pointerup=${lu}
@pointercancel=${lu}
/>`;return A`
<div class="new-session-page__menu-field">
<span>${E(`newSession.worktreeBaseRef`)}</span>
${n.length?A`<div
class="new-session-page__branch-field"
@focusout=${e=>{let t=e.currentTarget;t instanceof HTMLElement&&(!(e.relatedTarget instanceof Node)||!t.contains(e.relatedTarget))&&fu(t,!1)}}
>
${i}
<wa-popup
class="new-session-page__branch-popup"
anchor=${(e.idPrefix??`new-session`)+`-worktree-base-ref`}
placement="bottom-start"
sync="width"
>
<div
id=${(e.idPrefix??`new-session`)+`-worktree-branch-suggestions`}
class="new-session-page__branch-suggestions"
role="listbox"
aria-label=${E(`newSession.worktreeBaseRef`)}
>
${n.map((t,n)=>A`<button
id=${`${e.idPrefix??`new-session`}-worktree-branch-suggestion-${n}`}
type="button"
role="option"
aria-selected="false"
class="session-menu__item"
data-worktree-suggestion=${t.name}
tabindex="-1"
@mousedown=${e=>e.preventDefault()}
@click=${n=>{e.onBaseRefInput(t.name),fu(n.currentTarget,!1)}}
>
<span class="session-menu__text">${t.name}</span>
</button>`)}
</div>
</wa-popup>
</div>`:i}
</div>
<div class="new-session-page__menu-note">
${E(e.branches?.branchesUnavailable?`newSession.worktreeBranchesUnavailable`:`newSession.worktreeBranchesLimited`)}
</div>
${e.repository?j:A`<label class="new-session-page__menu-field">
<span>${E(`newSession.worktreeName`)}</span>
<input
type="text"
data-worktree-name
?disabled=${e.submitting||e.pendingPlacement}
placeholder=${E(`newSession.worktreeNamePlaceholder`)}
.value=${e.worktreeName}
@input=${t=>{t.currentTarget instanceof HTMLInputElement&&e.onWorktreeNameInput(t.currentTarget.value)}}
@keydown=${t}
@pointerdown=${lu}
@pointerup=${lu}
@pointercancel=${lu}
/>
</label>
<div class="new-session-page__menu-note">
${r?E(`newSession.worktreeBranchNote`,{branch:`openclaw/${r}`}):E(`newSession.worktreeBranchFromTitleNote`)}
</div>`}
`}function gu(e){return A`
<span class="new-session-page__select">
<button
id=${(e.idPrefix??`new-session`)+`-checkout-trigger`}
type="button"
class="new-session-page__trigger ${e.popoverHiding?`new-session-page__trigger--hiding`:``}"
title="${E(`newSession.checkout`)}: ${e.state.label}"
aria-label="${E(`newSession.checkout`)}: ${e.state.label}"
data-worktree=${String(e.worktree)}
aria-haspopup="dialog"
aria-expanded=${String(e.popoverOpen)}
?disabled=${e.submitting||e.pendingPlacement}
@click=${e.onGuardTransition}
>
${Vs(O.gitBranch,e.state.label)}
</button>
</span>
<wa-popover
${pt(Or)}
class="new-session-page__select new-session-page__checkout-popover new-session-page__picker-popover"
for=${(e.idPrefix??`new-session`)+`-checkout-trigger`}
placement="bottom-start"
without-arrow
@wa-show=${t=>{t.target===t.currentTarget&&e.onPopoverShow()}}
@wa-hide=${t=>uu(t,e.onPopoverHide)}
@wa-after-hide=${t=>{t.target===t.currentTarget&&e.onPopoverAfterHide()}}
>
<div class="new-session-page__picker-root">
<div class="new-session-page__menu-title">${E(`newSession.checkout`)}</div>
${e.repository?j:A`${q({value:`checkout`,label:E(`newSession.checkoutCurrent`),icon:O.folder,sub:e.branches?.headBranch,checked:!e.worktree,disabled:e.remotePlacement,title:e.remotePlacement?E(`newSession.checkoutRemoteLocked`):void 0,onSelect:()=>e.onSelectWorktree(!1),keepOpen:!0},e.submitting)}
${q({value:`worktree`,label:E(`newSession.checkoutWorktree`),icon:O.gitBranch,sub:E(`newSession.checkoutWorktreeSub`),checked:e.worktree,disabled:!e.worktreeAvailable,title:e.worktreeAvailable?void 0:e.repositoryUnavailable?E(`newSession.gitCheckUnavailable`):E(`newSession.worktreeUnavailable`),onSelect:()=>e.onSelectWorktree(!0),keepOpen:!0},e.submitting)} `}
${e.worktree||e.repository?hu(e):j}
${e.remotePlacement?A`<div class="new-session-page__menu-note">
${E(e.repository?`newSession.placementClonesRepository`:`newSession.placementSyncsFolder`,{folder:e.folderLabel})}
</div>`:j}
</div>
</wa-popover>
`}var _u;function vu(){return(vu=e((()=>{M(),mt(),k(),Sr(),l(),I(),es(),al(),Hs(),L(),_u=!1})))()}var yu;function bu(){return(bu=e((()=>{M(),et(),k(),yu={laptop:D(P`<path
d="M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z"
/>
<path d="M20.054 15.987H3.946" />`),pcCase:D(P`<rect width="14" height="20" x="5" y="2" rx="2" />
<path d="M15 14h.01M9 6h6M9 10h6" />`),macMini:D(P`<path
d="M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"
/>
<path d="M21.946 12.013H2.054M6 16h.01M10 16h.01" />`),macStudio:D(P`<path d="m3 8 3-4h12l3 4v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z" />
<path d="M3 8h18M6 15h2M11 15h2M17 15h.01" />`),allInOne:O.monitor,tablet:D(P`<rect width="16" height="20" x="4" y="2" rx="2" ry="2" />
<path d="M12 18h.01" />`),watch:D(P`<circle cx="12" cy="12" r="6" />
<polyline points="12 10 12 12 13 13" />
<path d="m16.13 7.66-.81-4.05a2 2 0 0 0-2-1.61h-2.68a2 2 0 0 0-2 1.61l-.78 4.05" />
<path d="m7.88 16.36.8 4a2 2 0 0 0 2 1.61h2.72a2 2 0 0 0 2-1.61l.81-4.05" />`),smartphone:O.smartphone,browser:O.globe,terminal:O.terminal,server:O.server}})))()}function xu(e){let t=e?.trim();if(t)return t.startsWith(`MacBook`)?`laptop`:t.startsWith(`Macmini`)?`mini`:t.startsWith(`MacPro`)?`pro`:t.startsWith(`iMac`)?`imac`:wu[t]}function Su(e){let t=e?.replace(/[_-]+/g,` `);if(t){if(/\bmac\s*book(?:\s*(?:pro|air))?\b/i.test(t))return`laptop`;if(/\bmac\s*mini\b/i.test(t))return`mini`;if(/\bmac\s*studio\b/i.test(t))return`studio`}}function Cu(e){let t=e?.trim();if(t)switch(xu(t)){case`laptop`:return t.startsWith(`MacBookAir`)||Tu.has(t)?`MacBook Air`:/^MacBook\d/.test(t)?`MacBook`:`MacBook Pro`;case`mini`:return`Mac mini`;case`studio`:return`Mac Studio`;case`pro`:return`Mac Pro`;case`imac`:return`iMac`;default:return}}var wu,Tu;function Eu(){return(Eu=e((()=>{wu={"Mac13,1":`studio`,"Mac13,2":`studio`,"Mac14,2":`laptop`,"Mac14,3":`mini`,"Mac14,5":`laptop`,"Mac14,6":`laptop`,"Mac14,7":`laptop`,"Mac14,8":`pro`,"Mac14,9":`laptop`,"Mac14,10":`laptop`,"Mac14,12":`mini`,"Mac14,13":`studio`,"Mac14,14":`studio`,"Mac14,15":`laptop`,"Mac15,3":`laptop`,"Mac15,4":`imac`,"Mac15,5":`imac`,"Mac15,6":`laptop`,"Mac15,7":`laptop`,"Mac15,8":`laptop`,"Mac15,9":`laptop`,"Mac15,10":`laptop`,"Mac15,11":`laptop`,"Mac15,12":`laptop`,"Mac15,13":`laptop`,"Mac15,14":`studio`,"Mac16,1":`laptop`,"Mac16,2":`imac`,"Mac16,3":`imac`,"Mac16,5":`laptop`,"Mac16,6":`laptop`,"Mac16,7":`laptop`,"Mac16,8":`laptop`,"Mac16,9":`studio`,"Mac16,10":`mini`,"Mac16,11":`mini`,"Mac16,12":`laptop`,"Mac16,13":`laptop`,"Mac17,2":`laptop`},Tu=new Set([`Mac14,2`,`Mac14,15`,`Mac15,12`,`Mac15,13`,`Mac16,12`,`Mac16,13`])})))()}function Du(e){let t=sc(e.environments,e.devicePlacement,e.deviceDisabledReason),n=cc(e.environments,t,e.deviceDisabledReason),r=t.find(t=>t.deviceId===e.deviceId),i=e.cloudProfiles.find(t=>t.id===e.cloudProfileId);if(e.cloudProfileId){let r=i?Ro(i):``,a=e.os||r,o=i?.operatingSystems??[],s=i?zo(i,a):[],c=i?Bo(i,a):void 0,l=e.machineClass?s.find(t=>t.id===e.machineClass):c;return{kind:`cloud`,label:i?.id??e.cloudProfileId,operatingSystems:o,selectedOsId:a,cloudMachines:s,selectedMachineId:l?.id??``,devices:t,cloudProfiles:e.cloudProfiles,autoDeviceDisabledReason:n}}return{kind:e.deviceId?`device`:e.autoDevice?`auto-device`:`local`,label:e.deviceId?r?.label??e.deviceId:E(e.autoDevice?`newSession.autoDevice`:`newSession.local`),cloudMachines:[],selectedMachineId:``,operatingSystems:[],selectedOsId:``,devices:t,cloudProfiles:e.cloudProfiles,autoDeviceDisabledReason:n}}function Ou(e){let t=e?.platform?.trim();if(t&&!/^(?:darwin|macos|mac os(?: x)?)\b/i.test(t))return O.monitor;let n=Su(e?.label),r=n===`laptop`?yu.laptop:n===`mini`?yu.macMini:n===`studio`?yu.macStudio:void 0;return r?A`<span class="new-session-page__device-icon" data-form=${n}>${r}</span>`:O.monitor}function ku(e){return A`<div
class="new-session-page__environment-skeletons"
role="status"
aria-label=${E(`common.loading`)}
aria-busy="true"
data-section=${e}
>
<span class="skeleton new-session-page__environment-skeleton-row" aria-hidden="true"></span>
<span class="skeleton new-session-page__environment-skeleton-row" aria-hidden="true"></span>
</div>`}function Au(e,t,n,r){return A`<div class="new-session-page__environment-heading new-session-page__devices-heading">
<span>${e}</span>
${r?A`<button
type="button"
class="new-session-page__connect-device"
data-action=${t}
aria-label=${E(t===`connect-machine`?`newSession.connectMachine`:`newSession.manageCloudWorkers`)}
?disabled=${n}
@click=${r}
>
${Nu}
</button>`:j}
</div>`}function ju(e){let t=Cr(e.state.cloudProfiles.find(t=>t.id===e.cloudProfileId)),n=e.state.kind===`cloud`?t.icon:e.state.kind===`local`?O.home:e.state.kind===`auto-device`?Mu:Ou(e.state.devices.find(t=>t.deviceId===e.deviceId)),r=e.gatewayName.trim()||E(`newSession.local`),i=e.state.kind===`local`?r:e.state.label,a=e.state.kind===`cloud`?[e.state.operatingSystems.find(t=>t.id===e.state.selectedOsId)?.label,e.state.cloudMachines.find(t=>t.id===e.state.selectedMachineId)?.label].filter(Boolean).join(` · `):``,o=e.environmentQuery.trim().toLocaleLowerCase(),s=(...e)=>e.some(e=>e?.toLocaleLowerCase().includes(o)),c=s(E(`newSession.local`),E(`newSession.gatewayHost`),e.gatewayName),l=e.state.devices.filter(e=>s(E(`newSession.device`),E(`newSession.yourDevices`),e.label,e.deviceId,...e.facts)).toSorted((e,t)=>Number(t.selectable)-Number(e.selectable)),u=e.isAdmin?e.state.cloudProfiles.filter(e=>s(E(`newSession.cloud`),e.id,e.providerId,e.providerDisplayId,Cr(e).label,e.trust===`disposable`?E(`newSession.environmentDisposable`):e.trust===`persistent`?E(`newSession.environmentPersistent`):void 0)):[],d=e.isAdmin&&!!e.cloudProfileId&&!e.state.cloudProfiles.some(t=>t.id===e.cloudProfileId)&&s(E(`newSession.cloud`),e.cloudProfileId),f=e.state.devices.length>1&&(l.length>0||s(E(`newSession.autoDeviceChoose`),E(`newSession.autoDevice`))),p=e.state.autoDeviceDisabledReason??E(e.autoPlacementMode===`eligible-order`?`newSession.autoDeviceHintEligible`:`newSession.autoDeviceHint`),m=e.submitting||e.pendingPlacement,h=e.catalogLoading&&l.length===0,g=e.isAdmin&&e.catalogLoading&&u.length===0;return A`
<span class="new-session-page__select new-session-page__select--where">
<button
id=${(e.idPrefix??`new-session`)+`-where-trigger`}
type="button"
class="new-session-page__trigger ${e.popoverHiding?`new-session-page__trigger--hiding`:``}"
aria-label="${E(`newSession.where`)}: ${i}${a?`, ${a}`:``}"
aria-description=${e.state.kind===`cloud`&&t.label?E(`newSession.cloudWorkerProvider`,{provider:t.label}):j}
data-cloud-profile=${e.cloudProfileId||j}
data-machine-class=${e.machineClass||j}
data-os=${e.os||j}
data-device-id=${e.deviceId||j}
data-auto-device=${e.autoDevice?`true`:j}
aria-haspopup="dialog"
aria-expanded=${String(e.popoverOpen)}
?disabled=${e.submitting||e.pendingPlacement}
@click=${e.onGuardTransition}
>
${Vs(n,i,a)}
</button>
</span>
<wa-popover
${pt(Or)}
class="new-session-page__select new-session-page__where-popover new-session-page__picker-popover"
for=${(e.idPrefix??`new-session`)+`-where-trigger`}
placement="bottom-start"
without-arrow
@wa-show=${t=>{t.target===t.currentTarget&&(t.currentTarget instanceof tr&&(t.currentTarget.popup.autoSize=`vertical`,t.currentTarget.popup.autoSizePadding=8),e.onPopoverShow())}}
@wa-hide=${t=>{t.target===t.currentTarget&&e.onPopoverHide()}}
@wa-after-hide=${t=>{t.target===t.currentTarget&&e.onPopoverAfterHide()}}
>
<div class="new-session-page__environment-layout">
<div class="new-session-page__picker-root new-session-page__environment-picker">
<label class="new-session-page__environment-search">
<span aria-hidden="true">${O.search}</span>
<input
type="search"
autofocus
aria-label=${E(`newSession.environmentSearchPlaceholder`)}
placeholder=${E(`newSession.environmentSearchPlaceholder`)}
.value=${e.environmentQuery}
?disabled=${m}
@input=${t=>{t.currentTarget instanceof HTMLInputElement&&e.onEnvironmentQueryInput(t.currentTarget.value)}}
/>
</label>
<div class="new-session-page__environment-list">
${c||l.length||f?Au(E(`newSession.yourDevices`),`connect-machine`,m,e.isAdmin?e.onConnectMachine:void 0):j}
${f?A`<openclaw-tooltip
class="new-session-page__environment-details"
placement="right-start"
>
<button
type="button"
class="session-menu__item new-session-page__environment-option"
data-value="auto-device"
data-popover="close"
aria-pressed=${String(e.autoDevice===!0)}
aria-description=${p}
?disabled=${m||!e.autoDevice&&!!e.state.autoDeviceDisabledReason}
@click=${e.onSelectAutoDevice}
>
<span class="session-menu__icon" aria-hidden="true">${Mu}</span>
<span class="session-menu__text">${E(`newSession.autoDeviceChoose`)}</span>
<span class="session-menu__check" aria-hidden="true"
>${e.autoDevice?O.check:j}</span
>
</button>
<div slot="content" class="new-session-page__environment-card">
<strong>${E(`newSession.autoDeviceChoose`)}</strong>
<div class="new-session-page__card-row">
<span class="new-session-page__card-icon" aria-hidden="true"
>${O.info}</span
>
<span>${p}</span>
</div>
</div>
</openclaw-tooltip>`:j}
${c?q({value:`gateway`,label:r,icon:O.home,summary:E(`newSession.runsOnGateway`),compact:!0,checked:e.state.kind===`local`,onSelect:()=>e.onSelectDevice(``)},m):j}
${gt(l,e=>e.deviceId,t=>q({value:`device:${t.deviceId}`,label:t.label,sub:t.subtitle,icon:Ou(t),platform:t.platform?Qt(t.platform):void 0,capabilityLabels:rc(t.capabilities),hideDetails:t.hideDetails,remediation:t.remediation,capacityLabel:t.selectable&&t.workerSlots?E(`newSession.concurrentSessionsValue`,{used:String(t.workerSlots.total-t.workerSlots.available),total:String(t.workerSlots.total)}):void 0,compact:!0,checked:e.state.kind===`device`&&e.deviceId===t.deviceId,disabled:!t.selectable,title:t.disabledReason,onSelect:()=>e.onSelectDevice(t.deviceId)},m))}
${h?ku(`devices`):j}
${u.length||d||g?Au(E(`newSession.cloud`),`manage-cloud-workers`,m,e.isAdmin&&!g?e.onManageCloudWorkers:void 0):j}
${Jo({profiles:u,selectedId:e.cloudProfileId,selectedOs:e.state.selectedOsId,selectedMachine:e.state.selectedMachineId,onSelectOs:e.onSelectCloudOs,onSelectMachine:e.onSelectCloudMachine,submitting:m,compact:!0,disabled:!!e.cloudDisabledReason,disabledReason:e.cloudDisabledReason,profileDisabledReason:e.cloudProfileDisabledReason,onSelect:e.onSelectCloudProfile})}
${g?ku(`cloud`):j}
${d?q({value:`cloud:${e.cloudProfileId}`,label:e.cloudProfileId,icon:O.cloud,description:E(`newSession.catalogUnavailable`),compact:!0,checked:!0,disabled:!0,title:E(`newSession.catalogUnavailable`),onSelect:()=>void 0},m):j}
${!c&&l.length===0&&u.length===0&&!d&&!h&&!g?A`<div class="new-session-page__environment-empty" role="status">
${E(`newSession.environmentSearchEmpty`)}
</div>`:j}
</div>
</div>
</div>
</wa-popover>
`}var Mu,Nu;function Pu(){return(Pu=e((()=>{rr(),M(),mt(),yt(),bu(),et(),k(),Dr(),Sr(),l(),I(),Eu(),Lt(),es(),dc(),Go(),Hs(),ac(),L(),Mu=D(P`<rect x="2" y="7" width="14" height="11" />
<path d="M6 7V3h16v12h-6M6 22h6M9 18v4" />`),Nu=D(P`<circle cx="12" cy="12" r="9" />
<path d="M12 8v8M8 12h8" />`)})))()}function Fu(e){let t=V(e.agentId);return A`
<span class="new-session-page__select new-session-page__select--agent">
<openclaw-agent-select
.variant=${e.variant??`compact`}
.options=${e.agents.map(t=>({value:V(t.id),label:ne(t,e.agentIdentity?.get(t.id)),agent:t}))}
.identityById=${Object.fromEntries(e.agents.flatMap(t=>{let n=e.agentIdentity?.get(t.id);return n?[[t.id,n]]:[]}))}
.value=${t}
.accessibleLabel=${E(`newSession.agent`)}
.menuLabel=${E(`newSession.agents`)}
.disabled=${e.disabled}
.onSelect=${e.onSelect}
@wa-show=${()=>e.onOpenChange(!0)}
@wa-hide=${()=>e.onOpenChange(!1)}
></openclaw-agent-select>
</span>
`}function Iu({idPrefix:e,context:t,data:n,gateway:r,place:i,submitting:a,pendingPlacement:o,onConnectMachine:s,onNavigate:c,onFocusComposer:l,requestUpdate:u}){let d=i.browser,{machineClass:f,os:p}=i.cloudSelection,m=W(n),h=m||!i.isAdmin()?[]:r.cloudProfiles,g=i.repository.kind===`git`?i.repository:null,_=m?[]:d.projects,v=m?[]:d.resolveProjectRecents({sessions:t?.sessions.state.result?.sessions??[],workspace:i.workspacePath(),workspaceRoots:i.knownWorkspaceRoots(),isAdmin:i.isAdmin()}),y=Du({environments:i.canWrite()?r.environments:[],cloudProfiles:h,cloudProfileId:i.cloudProfileId,machineClass:f,os:p,deviceId:i.deviceId,autoDevice:i.autoDevice,devicePlacement:i.devicePlacementRuntime()?.devicePlacement,deviceDisabledReason:i.modelControl.devicePlacementUnsupportedReason()??r.deviceCatalogDisabledReason}),b=Js({folder:i.folder,workspace:i.workspacePath(),projectId:d.projectId,selectedRemoteProject:d.remoteProject,projects:_,recents:v,projectQuery:d.projectQuery,freshWorkspace:i.freshWorkspace}),x=mu({destination:i.cloudProfileId?`cloud`:i.remotePlacement?`remote`:`local`,worktree:i.worktree,worktreeName:i.worktreeName,headBranch:g?.headBranch,baseRef:i.baseRef,repository:!!i.remoteRepository}),S=r.gatewayName?E(`newSession.gatewayNamed`,{name:r.gatewayName}):E(`newSession.gateway`);return A`${m?Ul({hosts:n?.terminalHosts,hostId:i.terminalHostId,submitting:a,onSelect:e=>i.selectTerminalHost(e)}):ju({idPrefix:e,state:y,environmentQuery:d.environmentQuery,onEnvironmentQueryInput:e=>d.changeEnvironmentQuery(e),gatewayName:r.gatewayName,cloudProfileId:i.cloudProfileId,machineClass:f,os:p,deviceId:i.deviceId,autoDevice:i.autoDevice,autoPlacementMode:i.modelControl.autoPlacementSelectionMode(),cloudDisabledReason:i.modelControl.cloudRuntimeUnsupportedReason(),cloudProfileDisabledReason:e=>i.modelControl.cloudRuntimeUnsupportedReason(e),submitting:a,pendingPlacement:o,catalogLoading:i.canWrite()&&r.cloudProfilesPending,isAdmin:i.isAdmin(),...d.popoverCallbacks(`where`),onSelectDevice:e=>i.selectDevice(e),onSelectAutoDevice:()=>i.selectDevice(``,!0),onSelectCloudProfile:(e,t)=>{t&&i.cloudMachines.applyPending(e),i.selectCloudProfile(e)},onSelectCloudOs:e=>i.cloudMachines.selectOs(i.cloudProfileId,e,h,a||o,u),onSelectCloudMachine:e=>i.cloudMachines.select(i.cloudProfileId,e,h,a||o,u),onConnectMachine:s,onManageCloudWorkers:()=>{d.close(),c(`cloud-workers`)}})}${m&&i.terminalOnNode?A`<label class="new-session-page__select new-session-page__menu-field"
><span>${E(`newSession.terminalNodeFolder`)}</span
><input
aria-label=${E(`newSession.terminalNodeFolder`)}
.value=${i.folder}
?disabled=${a}
@input=${e=>{e.currentTarget instanceof HTMLInputElement&&i.applyFolder(e.currentTarget.value)}}
/></label>`:Ys({idPrefix:e,state:b,browseAvailable:i.browseAvailable(),isAdmin:i.isAdmin(),canWrite:i.canWrite(),folder:i.folder,workspace:i.workspacePath(),projects:_,projectQuery:d.projectQuery,projectSearchAvailable:!m&&kt(t?.gateway.snapshot,`projects.searchRemote`,`operator.read`),projectAddAvailable:!m&&kt(t?.gateway.snapshot,i.remotePlacement?`sessions.create`:`projects.add`,`operator.write`),remoteProjects:d.projectSearchResult?.projects??[],selectedRemoteProject:d.remoteProject,projectSearchCredentialMissing:d.projectSearchResult?.credential===`missing`,projectSearchLoading:d.projectSearchLoading,projectSearchError:d.projectSearchError,projectId:d.projectId,freshWorkspace:i.freshWorkspace,onNewWorkspace:i.remotePlacement?()=>i.selectNewWorkspace():void 0,gatewayLabel:S,submitting:a,pendingPlacement:o,...d.popoverCallbacks(`project`),browserOpen:d.browserOpen,browser:d.browser,registerProjectPath:d.browserProjectPath,registeringProject:d.browserRegistering,onSelectProject:e=>i.selectProjectId(e),onProjectQueryInput:e=>d.changeProjectQuery(e),onSelectRemoteProject:e=>i.selectRemoteProject(e),onApplyFolder:e=>i.applyFolder(e),onBrowse:()=>d.selectGatewayBrowser(i.folder.trim()||i.workspacePath()),onBrowserBack:()=>d.showRoot(),onRegisterProject:e=>void d.registerBrowserProject(e),onClose:()=>d.close()})}${i.checkoutVisible&&!(m&&i.terminalOnNode)?gu({idPrefix:e,state:x,remotePlacement:i.remotePlacement,repository:!!i.remoteRepository,folderLabel:b.label,worktree:i.worktree,worktreeAvailable:i.worktreeAvailable(),repositoryUnavailable:i.repository.kind===`unavailable`,branches:g,branchesLoading:i.repository.kind===`checking`,baseRef:i.baseRef,worktreeName:i.worktreeName,submitting:a,pendingPlacement:o,...d.popoverCallbacks(`checkout`),onSelectWorktree:e=>i.selectWorktree(e),onBaseRefInput:e=>i.setBaseRef(e),onWorktreeNameInput:e=>i.setWorktreeName(e),onConfirm:l}):j}`}function Lu(){return(Lu=e((()=>{M(),l(),I(),he(),jt(),_(),G(),vu(),br(),Xs(),Wl(),Pu(),L()})))()}function Ru(e){let t=`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()}`,n=2166136261;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619);return n>>>0}function zu(e){return Ru(e)%16==3}function Bu(){try{let e=g()?.getItem(Qu),t=e?JSON.parse(e):{},n=new Map;if(Array.isArray(t)){for(let e of t)typeof e==`string`&&e&&n.set(e,{firstSeenAt:null,name:null,shinySeenAt:null});return n}if(t&&typeof t==`object`)for(let[e,r]of Object.entries(t))e&&n.set(e,{firstSeenAt:typeof r?.firstSeenAt==`number`?r.firstSeenAt:null,name:typeof r?.name==`string`&&r.name?r.name:null,shinySeenAt:typeof r?.shinySeenAt==`number`?r.shinySeenAt:null});return n}catch{return new Map}}function Vu(e){let t={};for(let[n,r]of[...e.entries()].toSorted(([e],[t])=>e.localeCompare(t)))t[n]={...r.firstSeenAt===null?{}:{firstSeenAt:r.firstSeenAt},...r.name===null?{}:{name:r.name},...r.shinySeenAt===null?{}:{shinySeenAt:r.shinySeenAt}};g()?.setItem(Qu,JSON.stringify(t))}function Hu(){return new Set(Bu().keys())}function Uu(){return Bu()}function Wu(e,t={}){try{let n=Bu(),r=n.get(e);if(r){let e=t.shiny===!0&&r.shinySeenAt===null;if(r.firstSeenAt!==null&&r.name!==null&&!e)return}n.set(e,{firstSeenAt:r?.firstSeenAt??Date.now(),name:r?.name??t.name??null,shinySeenAt:r?.shinySeenAt??(t.shiny===!0?Date.now():null)}),Vu(n)}catch{}}function Gu(){try{let e=g()?.getItem($u),t=e?JSON.parse(e):{},n=t&&typeof t==`object`?t:{};return{visits:typeof n.visits==`number`&&n.visits>=0?n.visits:0,shoos:typeof n.shoos==`number`&&n.shoos>=0?n.shoos:0}}catch{return{visits:0,shoos:0}}}function Ku(e){try{g()?.setItem($u,JSON.stringify(e))}catch{}}function qu(){let e=Gu();Ku({...e,visits:e.visits+1})}function Ju(){let e=Gu();Ku({...e,shoos:e.shoos+1})}function Yu(){let{visits:e,shoos:t}=Gu();return{tier:e<3?`shy`:e<15?`regular`:`friend`,wary:t>=3&&t>e*.3,visits:e,shoos:t}}function Xu(e){return td.find(([t])=>e>=t)?.[1]??null}function Zu(e,t){if(e===null||t.getTime()-e<nd)return!1;let n=new Date(e);return n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()}var Qu,$u,ed,td,nd;function rd(){return(rd=e((()=>{Qu=`openclaw.control.lobsterdex.v1`,$u=`openclaw.control.lobsterpet.familiarity.v1`,ed={shy:{stayMul:.6,firstDelayMul:1.3,gapMul:1},regular:{stayMul:1,firstDelayMul:1,gapMul:1},friend:{stayMul:1.6,firstDelayMul:.7,gapMul:.8},waryGapMul:1.7},td=[[250,`Elder`],[100,`Captain`],[50,`Sir`]],nd=2592e7})))()}function id(e){return(s(e)^sd)>>>0}function ad(e){let t=null;for(let n of e??[]){if(!n.status||n.status===`running`)continue;let e=n.endedAt??n.lastActivityAt??n.updatedAt??0;(!t||e>t.at)&&(t={at:e,outcome:n.status===`failed`||n.status===`timeout`?`error`:n.status===`killed`?`aborted`:`ok`})}return t?.outcome??`ok`}function od(e,t){return e?t?.some(zn)?`busy`:`idle`:`offline`}var sd;function cd(){return(cd=e((()=>{sd=Math.trunc(Math.random()*4294967295)})))()}function ld(e){let t=e.position;return t?A`
<wa-dropdown
class="session-menu lobster-pet-dismiss-menu"
.open=${!0}
placement="top-start"
.distance=${0}
aria-label=${E(`quickSettings.appearance.lobsterVisits`)}
@wa-select=${t=>{t.preventDefault(),t.detail.item.value===`dismiss`?e.onDismiss(!1):t.detail.item.value===`dismiss-permanently`&&e.onDismiss(!0)}}
@wa-after-hide=${e.onClose}
>
<button
slot="trigger"
type="button"
tabindex="-1"
aria-hidden="true"
aria-label=${E(`quickSettings.appearance.lobsterVisits`)}
style="position: fixed; left: ${t.x}px; top: ${t.y}px; width: 1px; height: 1px; opacity: 0; pointer-events: none;"
></button>
<wa-dropdown-item class="session-menu__item" value="dismiss"
>${E(`common.dismiss`)}</wa-dropdown-item
>
<wa-dropdown-item class="session-menu__item" value="dismiss-permanently"
>${E(`common.dismissAndDontShowAgain`)}</wa-dropdown-item
>
</wa-dropdown>
`:j}function ud(){return(ud=e((()=>{M(),l(),xr()})))()}function dd(e,t,n){let r=e;if(!t)return r;try{let e=window.AudioContext;if(!e)return r;r??=new e,r.state===`suspended`&&r.resume();let t=r.currentTime,i=r.createOscillator(),a=r.createGain();i.type=`sine`,n===`poke`?(i.frequency.setValueAtTime(330,t),i.frequency.exponentialRampToValueAtTime(165,t+.09)):(i.frequency.setValueAtTime(392,t),i.frequency.exponentialRampToValueAtTime(523,t+.18)),a.gain.setValueAtTime(1e-4,t),a.gain.exponentialRampToValueAtTime(.05,t+.02),a.gain.exponentialRampToValueAtTime(1e-4,t+(n===`poke`?.12:.24)),i.connect(a).connect(r.destination),i.start(t),i.stop(t+.26)}catch{}return r}function fd(){let e=dd(null,!0,`poke`);e&&window.setTimeout(()=>void e.close().catch(()=>{}),300)}function pd(){return(pd=e((()=>{})))()}function md(e){return gd[e]??e}function hd(e){return Cn(_d[(e>>>3)%_d.length],`lobster pet name catalog entry`)}var gd,_d,vd;function yd(){return(yd=e((()=>{Hn(),gd={blue:`Blueberry`,gold:`Goldie`,lumen:`Glimmer`,magma:`Ember`,oilslick:`Slick`,aurora:`Borealis`,nebula:`Cosmo`,banana:`Peel`,mood:`Ringo`,bee:`Buzz`,rubberduck:`Debuggy`,watermelon:`Pips`,clawtron:`Clawtron`,selene:`Selene`,geode:`Amethyst`,ghost:`Boo`,glass:`Prism`,split:`Picasso`,sourdough:`Boule`,zombie:`Shambles`,plush:`Buttons`,balloon:`Squeaky`,cottoncandy:`Taffy`,cryptid:`Nessie`,flatpack:`Skaldjur`,tinfoil:`Mulder`,actual:`Homarus`,disco:`Boogie`,chimera:`Frankie`,blueprint:`Prototype`,phosphor:`TTY`,ascii:`Figlet`,portal:`Warp`,notexture:`Magenta`,loading:`Spinner`,eclipse:`Umbra`,heisenbug:`Segfault`,invisible:`Nobody`,pixel:`Sprite`,retro:`OG`,goldenretro:`24K`},_d=[`Pinchy`,`Barnaby`,`Thermidor`,`Clawdette`,`Sheldon`,`Scuttles`,`Bisque`,`Crusty`,`Snips`,`Bubbles`,`Clawdia`,`Ferdinand`,`Maple`,`Pearl`,`Biscuit`,`Captain`,`Ziggy`,`Noodle`,`Waffles`,`Pippin`,`Squirt`,`Chip`,`Clementine`,`Moss`],vd={crimson:{flavor:`The classic red, first in every tide pool.`,hint:`Where every story starts.`},blue:{flavor:`1 in 2 million, and knows it.`,hint:`One in two million.`},gold:{flavor:`1 in 30 million karats.`,hint:`Worth its weight.`},lumen:{flavor:`Brings its own night lights.`,hint:`Glows where it's darkest.`},magma:{flavor:`Fresh from the vent, still cooling.`,hint:`Runs hot.`},oilslick:{flavor:`Black shell, rainbow finish.`,hint:`Spilled, not stirred.`},aurora:{flavor:`Northern lights, southern claws.`,hint:`Best seen on clear nights.`},nebula:{flavor:`Not from any ocean on this planet.`,hint:`Came from very far away.`},banana:{flavor:`Banana. For scale.`,hint:`For scale.`},mood:{flavor:`Wears whatever color you're feeling.`,hint:`Matches your vibe.`},bee:{flavor:`Technically not a bee.`,hint:`Do not tell the bees.`},rubberduck:{flavor:`Listens to your bugs. Judges silently.`,hint:`Quack.`},watermelon:{flavor:`Contains 6% lobster.`,hint:`Ripe when thumped.`},clawtron:{flavor:`60% rivets, 40% love.`,hint:`Beep boop snip.`},selene:{flavor:`Carries the current moon on its belly.`,hint:`Waxes and wanes.`},geode:{flavor:`Rock outside, amethyst inside.`,hint:`Crack the surface.`},ghost:{flavor:`1 in 100 million, barely there.`,hint:`You'd walk right past it.`},glass:{flavor:`Fully transparent. Nothing to hide.`,hint:`Easy to miss, hard to forget.`},split:{flavor:`Two lobsters, one shell.`,hint:`Can't pick a side.`},sourdough:{flavor:`Started from a starter. 24-hour proof.`,hint:`Still proofing.`},zombie:{flavor:`Slightly used. Still friendly.`,hint:`It's been better.`},plush:{flavor:`Machine washable. Air dry only.`,hint:`Soft to the touch.`},balloon:{flavor:`Do not pop.`,hint:`Handle with care.`},cottoncandy:{flavor:`Pastel, like the famous Maine catch.`,hint:`Sweeter than it looks.`},cryptid:{flavor:`Every photo comes out blurry.`,hint:`Sightings unconfirmed.`},flatpack:{flavor:`Some assembly required.`,hint:`Missing one screw.`},tinfoil:{flavor:`The tide is a psyop.`,hint:`They know.`},actual:{flavor:`An actual lobster. Unsettling, honestly.`,hint:`Anatomically correct.`},disco:{flavor:`Born under a mirror ball.`,hint:`The night is still young.`},chimera:{flavor:`Borrowed parts. No refunds.`,hint:`Something's off.`},blueprint:{flavor:`Final hardware pending approval.`,hint:`Still on the drawing board.`},phosphor:{flavor:`80 columns, 24 rows, one lobster.`,hint:`Hums at sixty hertz.`},ascii:{flavor:`Renders anywhere. Even over SSH.`,hint:`chmod +x`},portal:{flavor:`Arrives before it leaves.`,hint:`Mind the gap.`},notexture:{flavor:`Texture not found.`,hint:`404.`},loading:{flavor:`Still loading. Any second now.`,hint:`…`},eclipse:{flavor:`Do not look directly at it.`,hint:`Once in a blue moon.`},heisenbug:{flavor:`Only renders right when nobody's watching.`,hint:`Cannot be reproduced.`},invisible:{flavor:`It's right there. Look closer.`,hint:`Trust me, it exists.`},pixel:{flavor:`Rendered in 1987. Still runs.`,hint:`Insert coin.`},retro:{flavor:`The original: big claw, no apologies.`,hint:`The one that started it all.`},goldenretro:{flavor:`One in a generation.`,hint:`Worth the wait.`}}})))()}function bd(e){return((e.getTime()-Sd)/864e5%xd+xd)%xd/xd}var xd,Sd;function Cd(){return(Cd=e((()=>{xd=29.53059,Sd=Date.parse(`2000-01-06T18:14:00.000Z`)})))()}var wd,Td;function Ed(){return(Ed=e((()=>{wd=[[{id:`crimson`,shell:`#ff4f40`,claw:`#ff775f`},26],[{id:`blue`,shell:`#4a7dfc`,claw:`#7fa4ff`},7],[{id:`gold`,shell:`#f4b840`,claw:`#f9d47a`},5],[{id:`lumen`,shell:`#1d2f4e`,claw:`#2e4a77`},2],[{id:`magma`,shell:`#241214`,claw:`#3a1d18`},2],[{id:`oilslick`,shell:`#15171d`,claw:`#23262e`},2],[{id:`aurora`,shell:`#dce6f0`,claw:`#e9f0f7`},2],[{id:`nebula`,shell:`#34255c`,claw:`#4a3a7d`},2],[{id:`banana`,shell:`#f7e27d`,claw:`#f3d55b`},2],[{id:`mood`,shell:`var(--accent, #7f77dd)`,claw:`var(--accent-hover, #9a93e8)`},1.5],[{id:`bee`,shell:`#f4c531`,claw:`#2b2b23`},1.5],[{id:`rubberduck`,shell:`#ffd93b`,claw:`#ffb03b`},1.5],[{id:`watermelon`,shell:`#3f9d63`,claw:`#4fb072`},1.5],[{id:`clawtron`,shell:`#8d99a6`,claw:`#a2aeba`},1],[{id:`selene`,shell:`#c9ced8`,claw:`#d8dde5`},1],[{id:`geode`,shell:`#6b6474`,claw:`#7d7588`},1],[{id:`ghost`,shell:`#dce8f2`,claw:`#ecf3fa`},1],[{id:`glass`,shell:`#cfe4f4`,claw:`#e0eef8`},1],[{id:`split`,shell:`#ff4f40`,claw:`#ff775f`},1],[{id:`sourdough`,shell:`#d9a662`,claw:`#e6bc82`},1],[{id:`zombie`,shell:`#9db08a`,claw:`#86a17a`},1],[{id:`plush`,shell:`#e8967a`,claw:`#f2b09a`},1],[{id:`balloon`,shell:`#ff5c8a`,claw:`#ff7ea1`},1],[{id:`cryptid`,shell:`#6e6257`,claw:`#7d7263`},.9],[{id:`flatpack`,shell:`#d9c9a8`,claw:`#d9c9a8`},.9],[{id:`tinfoil`,shell:`#9aa4ad`,claw:`#a8b2bb`},.9],[{id:`actual`,shell:`#a63c28`,claw:`#8f3220`},.9],[{id:`cottoncandy`,shell:`#f6a8c9`,claw:`#a5c6f0`},.8],[{id:`disco`,shell:`#b8c4d8`,claw:`#cbd5e6`},.8],[{id:`chimera`,shell:`#b0685a`,claw:`#b0685a`},.75],[{id:`pixel`,shell:`#d84c3e`,claw:`#ef8f6a`},.7],[{id:`blueprint`,shell:`#123a66`,claw:`#123a66`},.7],[{id:`phosphor`,shell:`#0d2415`,claw:`#0f2b19`},.7],[{id:`ascii`,shell:`var(--lob-ascii-ink, #d8dee6)`,claw:`var(--lob-ascii-ink, #d8dee6)`},.7],[{id:`portal`,shell:`#4a9df8`,claw:`#ff9a2e`},.7],[{id:`notexture`,shell:`#ff00dc`,claw:`#111111`},.65],[{id:`loading`,shell:`#3a4150`,claw:`#454d5e`},.65],[{id:`eclipse`,shell:`#14161d`,claw:`#1d2026`},.65],[{id:`heisenbug`,shell:`#262a33`,claw:`#343945`},.6],[{id:`invisible`,shell:`rgba(127,140,160,0.07)`,claw:`rgba(127,140,160,0.07)`},.55],[{id:`retro`,shell:`#e8262c`,claw:`#f04a3e`},.5],[{id:`goldenretro`,shell:`#e8b422`,claw:`#f6cf5a`},.1]],Td=wd.map(([e])=>e)})))()}function Dd(e,t){return P`
<g class="lob-flatpack">
<path
d="M48 10 C28 10 17 25 17 41 C17 58 29 69 48 69 C67 69 79 58 79 41 C79 25 68 10 48 10 Z"
fill="var(--lob-shell)"
stroke="#8a7c5f"
stroke-width="2"
stroke-dasharray="4 3"
/>
<g class="lob-eye-open" style=${e}>
<circle cx="39" cy="34" r="4.5" fill="#0a1014" />
<circle cx="57" cy="34" r="4.5" fill="#0a1014" />
<circle cx="40.2" cy="32.8" r="1.7" fill="var(--lob-glint, #00e5cc)" />
<circle cx="58.2" cy="32.8" r="1.7" fill="var(--lob-glint, #00e5cc)" />
</g>
<g
class="lob-eye-closed"
stroke="#0a1014"
stroke-width="2.5"
stroke-linecap="round"
fill="none"
style=${t}
>
<path d="M34 35 Q39 31 44 35" />
<path d="M52 35 Q57 31 62 35" />
</g>
<g fill="none" stroke="#8a7c5f" stroke-width="1.5" stroke-dasharray="4 3">
<path d="M27 48 Q50 58 75 61" />
<path d="M68 47 Q79 58 92 70" />
</g>
<g class="lob-claw lob-claw--l">
<path
d="M76 53 C66 50 62 58 67 65 C72 72 82 68 85 60 C87 55 82 53 76 53 Z"
fill="var(--lob-claw)"
stroke="#8a7c5f"
stroke-width="1.5"
stroke-dasharray="4 3"
/>
</g>
<g class="lob-claw lob-claw--r">
<path
d="M98 65 C109 62 115 70 111 79 C107 88 96 84 91 76 C88 70 92 66 98 65 Z"
fill="var(--lob-claw)"
stroke="#8a7c5f"
stroke-width="1.5"
stroke-dasharray="4 3"
/>
</g>
<g fill="var(--lob-shell)" stroke="#8a7c5f" stroke-width="1.5" stroke-dasharray="4 3">
<rect x="15" y="88" width="15" height="6" rx="2" />
<rect x="34" y="88" width="15" height="6" rx="2" />
<rect x="53" y="88" width="15" height="6" rx="2" />
<rect x="72" y="88" width="15" height="6" rx="2" />
</g>
<g fill="none" stroke="#5f5648" stroke-width="3" stroke-linecap="round">
<path d="M84 24 L101 8" />
<path d="M93 31 L113 14" />
</g>
<g fill="#8a7c5f">
<circle cx="105" cy="29" r="3" />
<circle cx="113" cy="35" r="3" />
</g>
<path
class="lob-flatpack__allen-key"
d="M101 84 L101 99 L115 99"
fill="none"
stroke="#5f5648"
stroke-width="3"
stroke-linecap="round"
stroke-linejoin="round"
/>
</g>
`}function Od(e,t){return P`
<!-- Skeleton placeholders stay neutral instead of inheriting palette colors. -->
<g class="lob-skeleton">
<rect class="lob-skeleton__block" style="--i:0" x="24" y="18" width="72" height="64" rx="10" fill="#2f3542" />
<rect class="lob-skeleton__block" style="--i:1" x="2" y="43" width="24" height="20" rx="8" fill="#39404f" />
<rect class="lob-skeleton__block" style="--i:2" x="94" y="43" width="24" height="20" rx="8" fill="#39404f" />
<path class="lob-skeleton__block" style="--i:3" d="M45 21 L34 7" stroke="#39404f" stroke-width="6" stroke-linecap="round" />
<path class="lob-skeleton__block" style="--i:4" d="M75 21 L86 7" stroke="#39404f" stroke-width="6" stroke-linecap="round" />
<rect class="lob-skeleton__block" style="--i:5" x="31" y="79" width="10" height="22" rx="4" fill="#2f3542" />
<rect class="lob-skeleton__block" style="--i:6" x="46" y="79" width="10" height="24" rx="4" fill="#39404f" />
<rect class="lob-skeleton__block" style="--i:7" x="64" y="79" width="10" height="24" rx="4" fill="#39404f" />
<rect class="lob-skeleton__block" style="--i:8" x="79" y="79" width="10" height="22" rx="4" fill="#2f3542" />
<g class="lob-eye-open" style=${e}>
<circle cx="47" cy="43" r="5" fill="#4a5364" />
<circle cx="73" cy="43" r="5" fill="#4a5364" />
</g>
<g class="lob-eye-closed" style=${t} fill="#4a5364">
<rect x="41" y="42" width="12" height="3" rx="1.5" />
<rect x="67" y="42" width="12" height="3" rx="1.5" />
</g>
</g>
`}function kd(e,t){return P`
<g class="lob-actual">
<g fill="none" stroke="#6f281d" stroke-linecap="round">
<path d="M47 27 Q27 5 2 3" stroke-width="2" />
<path d="M73 27 Q93 5 118 3" stroke-width="2" />
<path d="M46 29 Q34 16 22 13" stroke-width="1.3" />
<path d="M74 29 Q86 16 98 13" stroke-width="1.3" />
</g>
<g fill="none" stroke="#7f3022" stroke-width="2.2" stroke-linecap="round">
<path d="M39 48 Q22 52 10 65" />
<path d="M38 56 Q20 62 8 77" />
<path d="M40 65 Q24 72 15 88" />
<path d="M43 74 Q31 82 27 97" />
<path d="M81 48 Q98 52 110 65" />
<path d="M82 56 Q100 62 112 77" />
<path d="M80 65 Q96 72 105 88" />
<path d="M77 74 Q89 82 93 97" />
</g>
<g class="lob-actual__tail" fill="#8f3220" stroke="#6f281d" stroke-width="1.4">
<path d="M48 88 Q38 91 31 103 Q44 103 55 96 Z" />
<path d="M72 88 Q82 91 89 103 Q76 103 65 96 Z" />
<path d="M54 89 Q60 96 66 89 L69 104 Q60 101 51 104 Z" />
</g>
<g class="lob-claw lob-claw--l">
<path
d="M34 43 Q25 31 12 33 Q0 35 2 48 Q4 61 17 63 Q28 64 35 54 L30 49 Q22 54 15 50 Q10 47 13 42 Q17 37 24 42 Z"
fill="var(--lob-claw)"
stroke="#6f281d"
stroke-width="1.5"
/>
</g>
<g class="lob-claw lob-claw--r">
<path
d="M86 44 Q94 32 104 34 Q113 35 116 42 L107 45 L118 49 Q115 58 105 60 Q96 61 87 53 Z"
fill="var(--lob-claw)"
stroke="#6f281d"
stroke-width="1.5"
/>
</g>
<path
class="lob-actual__carapace"
d="M60 20 Q38 20 34 38 Q32 50 41 58 Q49 64 60 64 Q71 64 79 58 Q88 50 86 38 Q82 20 60 20 Z"
fill="var(--lob-shell)"
stroke="#6f281d"
stroke-width="1.8"
/>
<g class="lob-actual__abdomen" stroke="#6f281d" stroke-width="1.4">
<path d="M39 54 Q60 62 81 54 L79 65 Q60 72 41 65 Z" fill="#b34b35" />
<path d="M41 65 Q60 72 79 65 L76 76 Q60 82 44 76 Z" fill="#a63c28" />
<path d="M44 76 Q60 82 76 76 L72 87 Q60 92 48 87 Z" fill="#b34b35" />
<path d="M48 87 Q60 92 72 87 L67 96 Q60 99 53 96 Z" fill="#a63c28" />
</g>
<path d="M48 42 Q60 48 72 42 Q69 56 60 58 Q51 56 48 42 Z" fill="#bd6044" opacity="0.72" />
<g fill="none" stroke="#6f281d" stroke-width="2.2" stroke-linecap="round">
<path d="M47 28 L45 23" />
<path d="M73 28 L75 23" />
</g>
<g class="lob-eye-open" style=${e}>
<circle cx="45" cy="22" r="3.5" fill="#17100e" />
<circle cx="75" cy="22" r="3.5" fill="#17100e" />
<circle cx="46" cy="21" r="1" fill="#f2c6a8" />
<circle cx="76" cy="21" r="1" fill="#f2c6a8" />
</g>
<g class="lob-eye-closed" style=${t} fill="none" stroke="#17100e" stroke-width="2" stroke-linecap="round">
<path d="M41.5 22 H48.5" />
<path d="M71.5 22 H78.5" />
</g>
</g>
`}function Ad(e,t){return P`
<g class="lob-balloon">
<g fill="none" stroke="var(--lob-shell)" stroke-width="4" stroke-linecap="round">
<path d="M48 13 Q45 5 42 3" />
<path d="M72 13 Q75 5 78 3" />
</g>
<g class="lob-claw lob-claw--l" fill="var(--lob-claw)">
<ellipse cx="29" cy="29" rx="9" ry="7" transform="rotate(-20 29 29)" />
<ellipse cx="20" cy="35" rx="8" ry="6" transform="rotate(18 20 35)" />
</g>
<g class="lob-claw lob-claw--r" fill="var(--lob-claw)">
<ellipse cx="91" cy="29" rx="9" ry="7" transform="rotate(20 91 29)" />
<ellipse cx="100" cy="35" rx="8" ry="6" transform="rotate(-18 100 35)" />
</g>
<ellipse cx="60" cy="29" rx="24" ry="19" fill="var(--lob-shell)" />
<circle cx="60" cy="48" r="4" fill="#d94b72" />
<ellipse cx="60" cy="61" rx="18" ry="14" fill="var(--lob-shell)" />
<circle cx="60" cy="75" r="3.5" fill="#d94b72" />
<ellipse cx="60" cy="86" rx="13" ry="10" fill="var(--lob-shell)" />
<g fill="#ffffff" opacity="0.55">
<ellipse cx="50" cy="22" rx="4" ry="10" transform="rotate(35 50 22)" />
<ellipse cx="52" cy="56" rx="3" ry="7" transform="rotate(32 52 56)" />
<ellipse cx="54" cy="82" rx="2.4" ry="5" transform="rotate(28 54 82)" />
</g>
<g class="lob-eye-open" style=${e}>
<circle cx="50" cy="30" r="4.5" fill="#0a1014" />
<circle cx="70" cy="30" r="4.5" fill="#0a1014" />
<circle cx="51.3" cy="28.7" r="1.8" fill="var(--lob-glint, #00e5cc)" />
<circle cx="71.3" cy="28.7" r="1.8" fill="var(--lob-glint, #00e5cc)" />
</g>
<g
class="lob-eye-closed"
style=${t}
fill="none"
stroke="#0a1014"
stroke-width="2.5"
stroke-linecap="round"
>
<path d="M45 31 Q50 27 55 31" />
<path d="M65 31 Q70 27 75 31" />
</g>
<path d="M55 96 L60 91 L65 96 L60 101 Z" fill="#d94b72" />
<path
d="M60 100 Q67 102 62 105 Q57 108 65 111"
fill="none"
stroke="#c9d2da"
stroke-width="1.2"
stroke-linecap="round"
/>
</g>
`}function jd(e,t){return P`
<!-- Like pet names and lore, terminal glyph art is an English-only easter-egg channel. -->
<g
class="lob-ascii"
fill="var(--lob-shell)"
font-family="ui-monospace, SFMono-Regular, Menlo, monospace"
font-size="11"
text-anchor="middle"
xml:space="preserve"
>
<text x="60" y="17">\\ / \\ /</text>
<text x="60" y="31">{ \\_______/ }</text>
<g class="lob-eye-open" style=${e}>
<text x="60" y="45">(o) (o)</text>
</g>
<g class="lob-eye-closed" style=${t}>
<text x="60" y="45">(-) (-)</text>
</g>
<text x="60" y="59">( '---' )</text>
<text x="60" y="73"> \\ _____ /</text>
<text x="60" y="87"> (_________)</text>
<text x="60" y="101"> | | | |</text>
</g>
`}function Md(e,t){return P`
<g class="lob-portal">
<ellipse
class="lob-portal-ring lob-portal-ring--blue"
cx="30"
cy="50"
rx="14"
ry="30"
fill="#0d1b33"
fill-opacity="0.85"
stroke="currentColor"
stroke-width="3"
transform="rotate(-12 30 50)"
/>
<!-- Fixed lobster red preserves the split-body gag while shell/claw vars carry portal identity. -->
<path d="M31 30 Q45 20 56 30 Q62 39 60 53 Q58 64 47 70 L31 67 Z" fill="#b0432f" />
<g class="lob-claw lob-claw--l">
<path
d="M52 54 Q58 48 63 51 Q67 56 63 62 Q58 67 52 63 Z"
fill="#b0432f"
/>
</g>
<g fill="none" stroke="#b0432f" stroke-width="2" stroke-linecap="round">
<path d="M42 31 Q43 16 50 7" />
<path d="M52 28 Q58 14 66 9" />
</g>
<g class="lob-eye-open" style=${e}>
<circle cx="45" cy="39" r="4" fill="#0a1014" />
<circle cx="57" cy="37" r="4" fill="#0a1014" />
<circle cx="46" cy="38" r="1.5" fill="var(--lob-glint, #00e5cc)" />
<circle cx="58" cy="36" r="1.5" fill="var(--lob-glint, #00e5cc)" />
</g>
<g
class="lob-eye-closed"
style=${t}
fill="none"
stroke="#0a1014"
stroke-width="2.2"
stroke-linecap="round"
>
<path d="M41 40 Q45 37 49 40" />
<path d="M53 38 Q57 35 61 38" />
</g>
<g class="lob-portal-rear" fill="#b0432f">
<path d="M91 44 Q82 40 75 44 L82 51 L74 56 L82 61 L75 68 Q83 70 92 64 Z" />
<path d="M88 52 Q82 49 78 45" fill="none" stroke="#7f3022" stroke-width="2" />
<path d="M88 61 Q82 64 78 69" fill="none" stroke="#7f3022" stroke-width="2" />
</g>
<ellipse
class="lob-portal-ring lob-portal-ring--orange"
cx="92"
cy="58"
rx="14"
ry="30"
fill="#0d1b33"
fill-opacity="0.85"
stroke="currentColor"
stroke-width="3"
transform="rotate(10 92 58)"
/>
</g>
`}function Nd(e){return P`
<g class="lob-tinfoil" fill="none" stroke="#c9d2da" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M27 31 L38 27 L45 34 L55 25 L64 33 L75 26 L91 34" />
<path d="M20 51 L31 45 L43 54 L55 45 L68 54 L82 44 L100 53" />
<path d="M23 70 L36 64 L47 73 L60 63 L74 72 L90 65 L98 72" />
<path d="M35 86 L46 80 L58 87 L70 79 L84 85" />
</g>
${e?P`
<g class="lob-tinfoil-hat">
<path d="M43 14 L57 0 L78 15 L60 11 Z" fill="#c0c9d1" />
<path d="M57 0 L60 11 L78 15" fill="none" stroke="#7f8992" stroke-width="1.5" />
<path d="M43 14 L60 11 L53 5" fill="none" stroke="#9aa4ad" stroke-width="1.5" />
</g>
`:``}
`}var Pd,Fd,Id,Ld,Rd;function zd(){return(zd=e((()=>{M(),Pd=P`
<g class="lob-watermelon">
<g fill="none" stroke="#2c7a4a" stroke-width="4" stroke-linecap="round">
<path d="M31 25 Q39 13 48 11" />
<path d="M48 22 Q54 10 60 9" />
<path d="M66 22 Q72 10 80 15" />
<path d="M82 28 Q89 20 94 30" />
</g>
<ellipse cx="60" cy="69" rx="35" ry="23" fill="#e5484d" />
<g fill="#28211c">
<ellipse cx="42" cy="62" rx="2" ry="3.4" transform="rotate(-20 42 62)" />
<ellipse cx="58" cy="58" rx="2" ry="3.4" transform="rotate(8 58 58)" />
<ellipse cx="76" cy="64" rx="2" ry="3.4" transform="rotate(24 76 64)" />
<ellipse cx="49" cy="77" rx="2" ry="3.4" transform="rotate(18 49 77)" />
<ellipse cx="68" cy="79" rx="2" ry="3.4" transform="rotate(-16 68 79)" />
<ellipse cx="84" cy="75" rx="1.8" ry="3.1" transform="rotate(30 84 75)" />
</g>
</g>
`,Fd=P`
<path
class="lob-eclipse-corona"
d="M29 31 Q40 10 61 9 Q82 9 94 31"
fill="none"
stroke="#ffe9b8"
stroke-width="2.5"
stroke-linecap="round"
/>
`,Id=[{y:12,x:44,count:4},{y:20,x:36,count:6},{y:28,x:28,count:8},{y:36,x:20,count:10},{y:44,x:16,count:11},{y:52,x:16,count:11},{y:60,x:16,count:11},{y:68,x:20,count:10},{y:76,x:24,count:9},{y:84,x:32,count:7},{y:92,x:44,count:4}],Ld=P`
<g class="lob-notexture" shape-rendering="crispEdges">
${Id.flatMap((e,t)=>Array.from({length:e.count},(n,r)=>P`<rect
x=${e.x+r*8}
y=${e.y}
width="8"
height="8"
fill=${(t+r)%2==0?`#ff00dc`:`#111111`}
/>`))}
</g>
`,Rd=P`
<g class="lob-chimera-stitches" fill="none" stroke="#4a3f3a" stroke-width="1.8" stroke-linecap="round">
<path d="M18 47 L27 50 M19 51 L22 46 M23 53 L26 48" />
<path d="M93 50 L102 47 M94 48 L97 53 M98 46 L101 51" />
</g>
`})))()}function Bd(e){let t=(Math.round(e)%8+8)%8;if(t===0)return P`<g class="lob-selene-moon"><circle cx="60" cy="64" r="12" fill="#26304a" /><circle cx="60" cy="64" r="11" fill="none" stroke="#f4f7fc" stroke-width="1" /></g>`;if(t===4)return P`<g class="lob-selene-moon"><circle cx="60" cy="64" r="12" fill="#26304a" /><circle cx="60" cy="64" r="11" fill="#f4f7fc" /></g>`;let n=t<4?[-5,-9,-14][t-1]:[14,9,5][t-5];return P`
<g class="lob-selene-moon">
<circle cx="60" cy="64" r="12" fill="#26304a" />
<circle cx="60" cy="64" r="11" fill="#f4f7fc" />
<circle cx=${60+(n??0)} cy="64" r="11" fill="#26304a" />
</g>
`}function Vd(e,t){return P`
<g class="lob-pixel-frame" shape-rendering="crispEdges">
<g class="lob-pixel-antennae" fill="#d84c3e">
<rect x="30" y="0" width="6" height="6" /><rect x="36" y="6" width="6" height="6" /><rect x="42" y="12" width="6" height="6" />
<rect x="84" y="0" width="6" height="6" /><rect x="78" y="6" width="6" height="6" /><rect x="72" y="12" width="6" height="6" />
</g>
<g class="lob-pixel-claws">
<path d="M18 42 H6 V48 H0 V60 H6 V66 H18 V60 H24 V48 H18 Z M6 48 H12 V60 H6 Z" fill="#d84c3e" />
<rect x="6" y="60" width="12" height="6" fill="#a83428" />
<path d="M102 42 H114 V48 H120 V60 H114 V66 H102 V60 H96 V48 H102 Z M108 48 H114 V60 H108 Z" fill="#d84c3e" />
<rect x="102" y="60" width="12" height="6" fill="#a83428" />
</g>
<!-- Main cells keep the palette variable so offline and mood-style tinting still read. -->
<g class="lob-pixel-body" fill="var(--lob-shell, #d84c3e)">
<rect x="42" y="12" width="36" height="6" /><rect x="36" y="18" width="48" height="6" />
<rect x="30" y="24" width="60" height="6" /><rect x="24" y="30" width="72" height="48" />
<rect x="30" y="78" width="60" height="12" /><rect x="36" y="90" width="48" height="6" />
<rect x="36" y="96" width="12" height="9" /><rect x="72" y="96" width="12" height="9" />
</g>
<g fill="#ef8f6a"><rect x="36" y="24" width="24" height="6" /><rect x="30" y="30" width="18" height="12" /><rect x="24" y="42" width="12" height="12" /></g>
<g fill="#a83428"><rect x="30" y="78" width="60" height="12" /><rect x="36" y="90" width="48" height="6" /><rect x="36" y="96" width="12" height="9" /><rect x="72" y="96" width="12" height="9" /></g>
<g class="lob-eye-open" style=${e}>
<rect x="42" y="30" width="6" height="6" fill="#0a1014" /><rect x="72" y="30" width="6" height="6" fill="#0a1014" />
<rect x="42" y="30" width="2.5" height="2.5" fill="#fff" /><rect x="72" y="30" width="2.5" height="2.5" fill="#fff" />
</g>
<g class="lob-eye-closed" style=${t} fill="#0a1014"><rect x="42" y="33" width="6" height="3" /><rect x="72" y="33" width="6" height="3" /></g>
</g>
`}function Hd(e){return P`
<svg
class="lobster-pet__svg"
viewBox="0 0 120 105"
preserveAspectRatio="none"
aria-hidden="true"
>
${e}
</svg>
`}function Ud(e){return P`
<svg class="lobster-bottle__svg" viewBox="0 0 48 44" aria-hidden="true">
<g transform="rotate(-16 24 30)">
<rect x="5" y="18" width="30" height="16" rx="7" fill="#7fc8b8" opacity="0.72" />
<rect x="33" y="22" width="9" height="8" rx="2.5" fill="#7fc8b8" opacity="0.72" />
${e?P`
<rect x="36" y="20" width="11" height="7" rx="1.5" fill="#f2e5c9" transform="rotate(-24 41 23)" />
<rect x="43" y="30" width="4.5" height="8" rx="1.6" fill="#8a5a2b" transform="rotate(38 45 34)" />
`:P`<rect x="41" y="21.5" width="5" height="9" rx="1.8" fill="#8a5a2b" />`}
<rect x="11" y="22" width="12" height="8" rx="1.5" fill="#f2e5c9" />
<path d="M13 24.5 L21 24.5 M13 27 L19 27" stroke="#b6a071" stroke-width="1" />
<ellipse cx="13" cy="20.5" rx="5" ry="2" fill="#ffffff" opacity="0.35" />
</g>
</svg>
`}var Wd,Gd,Kd,qd,Jd,Yd,Xd,Zd,Qd,$d,ef,tf,nf,rf,af,of,sf,cf,lf,uf,df,ff,pf,mf,hf,gf,_f,vf,yf,bf,xf,Sf,Cf,wf,Tf,Ef,Df,Of,kf;function Af(){return(Af=e((()=>{M(),_r(),zd(),Wd={crown:mr.crown,sprout:P`
<g>
<path d="M60 12 Q58 4 63 1" stroke="#3f9d63" stroke-width="3" stroke-linecap="round" fill="none" />
<ellipse cx="67" cy="3" rx="5" ry="3" fill="#57c785" transform="rotate(-24 67 3)" />
</g>
`,patch:P`
<g>
<path d="M28 27 Q60 14 92 22" stroke="#101820" stroke-width="4" stroke-linecap="round" fill="none" />
<circle cx="75" cy="32" r="9" fill="#101820" />
</g>
`,santa:mr.santa,pumpkin:mr.pumpkin,party:mr.party,barnacle:P`
<g class="lob-barnacles">
<path d="M32 22 L36.5 13 L41 22 Z" fill="#cfd8de" />
<path d="M42 18 L45.5 11 L49 18 Z" fill="#b8c4cc" />
<path d="M27 26 L30 20.5 L33 26 Z" fill="#b8c4cc" />
<circle cx="36.5" cy="18.5" r="1.1" fill="#8a949d" />
<circle cx="45.5" cy="15" r="0.9" fill="#8a949d" />
</g>
`,monocle:P`
<g class="lob-monocle" fill="none" stroke="#f4b840">
<circle cx="75" cy="32" r="8.5" stroke-width="2.5" />
<path d="M81 39 Q85 48 80 56" stroke-width="1.5" />
</g>
`},Gd=P`
<g class="lob-freckles" fill="#ffffff" opacity="0.3">
<circle cx="42" cy="45" r="1.6" />
<circle cx="50" cy="41" r="1.2" />
<circle cx="70" cy="45" r="1.6" />
<circle cx="78" cy="41" r="1.2" />
<circle cx="55" cy="62" r="1.4" />
<circle cx="67" cy="66" r="1.2" />
</g>
`,Kd=P`
<g class="lob-lumen" fill="#7ef5dd">
<circle cx="36" cy="54" r="2.4" />
<circle cx="50" cy="66" r="2" />
<circle cx="66" cy="70" r="2.2" />
<circle cx="80" cy="60" r="2" />
<circle cx="88" cy="46" r="1.7" />
<circle cx="60" cy="86" r="1.7" />
</g>
`,qd=P`
<g class="lob-magma" fill="none" stroke="#ff6a3d" stroke-width="2" stroke-linecap="round">
<path d="M40 44 L48 54 L42 66 L50 78" />
<path d="M74 40 L68 52 L78 64" />
<path d="M56 82 L62 90" />
</g>
`,Jd=P`
<g class="lob-oilsheen">
<ellipse cx="46" cy="60" rx="22" ry="11" fill="#7f77dd" opacity="0.3" transform="rotate(-14 46 60)" />
<ellipse cx="76" cy="74" rx="17" ry="8" fill="#1d9e75" opacity="0.28" transform="rotate(10 76 74)" />
</g>
`,Yd=P`
<g class="lob-aurora" fill="none" stroke-linecap="round">
<path class="lob-aurora__band1" d="M24 62 Q48 48 70 58 T102 54" stroke="#4ecfa6" stroke-width="6" opacity="0.5" />
<path class="lob-aurora__band2" d="M28 76 Q54 62 78 72 T100 68" stroke="#a184ec" stroke-width="5" opacity="0.45" />
</g>
`,Xd=P`
<g class="lob-nebula-stars">
<circle cx="38" cy="52" r="1" fill="#fff" />
<circle cx="52" cy="70" r="1.2" fill="#fff" />
<circle cx="84" cy="48" r="1.4" fill="#fff" />
<circle cx="66" cy="86" r="1" fill="#fff" />
<circle cx="72" cy="60" r="1.6" fill="#8be9fd" />
<circle cx="46" cy="40" r="1.4" fill="#ff9de2" />
<path class="lob-twinkle" d="M60 52 L61.5 55.5 L65 57 L61.5 58.5 L60 62 L58.5 58.5 L55 57 L58.5 55.5 Z" fill="#fff" />
</g>
`,Zd=P`
<g class="lob-glass-glints" fill="none" stroke="#ffffff" stroke-width="2.5" stroke-linecap="round" opacity="0.7">
<path d="M34 22 L28 32" />
<path d="M40 16 L37 22" />
</g>
`,Qd=P`
<g class="lob-geode-facets">
<polygon points="70,34 80,30 78,44" fill="#9b6ff0" />
<polygon points="82,46 94,42 88,58" fill="#b48ef0" />
<polygon points="72,58 84,62 74,74" fill="#7a4fd0" />
<polygon points="86,68 96,64 90,80" fill="#9b6ff0" />
<circle class="lob-twinkle" cx="90" cy="50" r="1.8" fill="#fff" />
</g>
`,$d=P`
<g class="lob-scanlines" stroke="#3fff7d" stroke-width="1" opacity="0.16">
<path d="M40 20 H80 M30 27 H90 M26 34 H94 M21 41 H99 M18 48 H102 M17 55 H103 M17 62 H103 M18 69 H102 M22 76 H98 M31 83 H89 M45 90 H75" />
</g>
`,ef=P`
<g class="lob-glitch-ghosts">
<path d="M60 8 C32 8 16 32 16 52 C16 72 30 90 44 95 L44 104 L54 104 L54 96 C58 97.5 62 97.5 66 96 L66 104 L76 104 L76 95 C90 90 104 72 104 52 C104 32 88 8 60 8 Z" transform="translate(-3 0)" fill="#ff3355" opacity="0.4" />
<path d="M60 8 C32 8 16 32 16 52 C16 72 30 90 44 95 L44 104 L54 104 L54 96 C58 97.5 62 97.5 66 96 L66 104 L76 104 L76 95 C90 90 104 72 104 52 C104 32 88 8 60 8 Z" transform="translate(3 1)" fill="#22d3ee" opacity="0.4" />
</g>
`,tf=P`
<g class="lob-blueprint" fill="none" stroke="#cfe3ff">
<path class="lob-bp-outline" d="M60 8 C32 8 16 32 16 52 C16 72 30 90 44 95 L44 104 L54 104 L54 96 C58 97.5 62 97.5 66 96 L66 104 L76 104 L76 95 C90 90 104 72 104 52 C104 32 88 8 60 8 Z" stroke-width="1.5" stroke-dasharray="5 3" />
<path d="M54 58 H66 M60 52 V64" stroke-width="1" opacity="0.7" />
<path d="M16 100 H104" stroke-width="1" stroke-dasharray="2 3" opacity="0.7" />
</g>
`,nf=P`
<g class="lob-mecha">
<g fill="none" stroke="#5f6a75" stroke-width="1.5">
<path d="M28 56 Q60 66 92 56" />
<path d="M34 74 Q60 82 86 74" />
</g>
<g fill="#5f6a75">
<circle cx="36" cy="61" r="1.4" />
<circle cx="60" cy="64" r="1.4" />
<circle cx="84" cy="61" r="1.4" />
</g>
<circle class="lob-led" cx="89" cy="7" r="3" fill="#ff4444" />
</g>
`,rf=new Set(`split.retro.lumen.magma.oilslick.aurora.nebula.glass.geode.phosphor.heisenbug.blueprint.clawtron.selene.pixel.banana.bee.rubberduck.watermelon.sourdough.zombie.plush.balloon.disco.cryptid.flatpack.tinfoil.actual.chimera.notexture.loading.eclipse.ascii.portal.invisible.goldenretro`.split(`.`)),af=P`
<g fill="#8a6430">
<rect x="56" y="8" width="8" height="6" rx="2.5" />
<ellipse cx="60" cy="91" rx="6" ry="3.5" />
<circle cx="37" cy="48" r="2.5" />
<circle cx="79" cy="55" r="2" />
<circle cx="47" cy="70" r="1.8" />
<circle cx="72" cy="79" r="2.3" />
</g>
`,of=P`
<g class="lob-bee-wings" fill="#ffffff" opacity="0.45">
<ellipse cx="38" cy="14" rx="8" ry="4.5" transform="rotate(-24 38 14)" />
<ellipse cx="82" cy="14" rx="8" ry="4.5" transform="rotate(24 82 14)" />
</g>
<g fill="#2b2b23" opacity="0.9">
<path d="M19 42 Q60 51 101 42 L103 50 Q60 60 17 50 Z" />
<path d="M17 58 Q60 67 103 58 L101 67 Q60 76 19 67 Z" />
<path d="M24 76 Q60 84 96 76 L90 85 Q60 92 30 85 Z" />
</g>
`,sf=P`
<g>
<ellipse cx="60" cy="71" rx="21" ry="14" fill="#ffffff" opacity="0.5" />
<rect x="47" y="41" width="26" height="8" rx="4" fill="#ff9a2e" />
<rect x="50" y="47" width="20" height="5" rx="2.5" fill="#e98322" />
</g>
`,cf=P`
<g fill="none" stroke="#a8763e" stroke-width="2.5" stroke-linecap="round">
<path d="M38 23 Q45 29 52 30" />
<path d="M52 17 Q59 24 66 25" />
<path d="M67 18 Q74 24 81 25" />
</g>
<g fill="#ffffff" opacity="0.5">
<circle cx="34" cy="39" r="1.2" /><circle cx="86" cy="38" r="1" />
<circle cx="45" cy="57" r="1.4" /><circle cx="74" cy="62" r="1.1" />
<circle cx="56" cy="78" r="1" /><circle cx="83" cy="75" r="1.3" />
</g>
`,lf=P`
<g fill="none" stroke="#5a6b52" stroke-width="2" stroke-linecap="round">
<path d="M32 24 Q47 19 61 23" />
<path d="M38 19 L40 26 M46 18 L47 25 M54 19 L53 26" />
<path d="M57 72 Q72 78 87 72" />
<path d="M65 72 L63 79 M73 73 L72 80 M81 71 L83 78" />
</g>
<ellipse cx="35" cy="61" rx="9" ry="6" fill="#86987a" opacity="0.8" transform="rotate(-18 35 61)" />
`,uf=P`
<g fill="none" stroke="#c97a5e" stroke-width="1.5" stroke-dasharray="3 3">
<path d="M30 32 Q60 4 90 32" />
<path d="M60 50 Q58 72 60 96" />
</g>
<g class="lob-plush-button">
<circle cx="78" cy="44" r="3.5" fill="#7a4a3a" />
<circle cx="76.8" cy="44" r="0.7" fill="#e8967a" />
<circle cx="79.2" cy="44" r="0.7" fill="#e8967a" />
</g>
`,df=P`
<g class="lob-disco" fill="#ffffff">
<rect x="42" y="18" width="4" height="4" opacity="0.3" /><rect x="52" y="16" width="4" height="4" opacity="0.5" />
<rect x="63" y="17" width="4" height="4" opacity="0.25" /><rect x="74" y="20" width="4" height="4" opacity="0.4" />
<rect x="31" y="40" width="4" height="4" opacity="0.4" /><rect x="53" y="39" width="4" height="4" opacity="0.25" />
<rect x="65" y="42" width="4" height="4" opacity="0.5" /><rect x="86" y="40" width="4" height="4" opacity="0.3" />
<rect x="39" y="59" width="4" height="4" opacity="0.25" /><rect x="51" y="62" width="4" height="4" opacity="0.45" />
<rect x="68" y="60" width="4" height="4" opacity="0.3" /><rect x="80" y="58" width="4" height="4" opacity="0.5" />
<rect x="49" y="79" width="4" height="4" opacity="0.35" /><rect x="70" y="80" width="4" height="4" opacity="0.25" />
</g>
`,ff={lumen:Kd,magma:qd,oilslick:Jd,aurora:Yd,nebula:Xd,glass:Zd,geode:Qd,phosphor:$d,blueprint:tf,clawtron:nf,banana:af,bee:of,rubberduck:sf,sourdough:cf,zombie:lf,plush:uf,disco:df,watermelon:Pd,eclipse:Fd,notexture:Ld,chimera:Rd},pf=P`
<path
class="lob-split-half"
d="M60 8 C88 8 104 32 104 52 C104 72 90 90 76 95 L76 104 L66 104 L66 96 C64 96.8 62 97.1 60 97.1 L60 8 Z"
fill="var(--lob-shell2, #46536b)"
/>
`,mf=P`
<path
d="M95 55 C112 53 119 39 116 25 C113 11 99 5 91 12 C88 15 87 19 88 23 C83 27 83 36 88 43 C91 49 93 52 95 55 Z"
fill="var(--lob-claw)"
/>
<path
d="M92 14 C97 22 99 31 95 41"
class="lob-retro-claw-line"
stroke="#b8151b"
stroke-width="3"
stroke-linecap="round"
fill="none"
/>
`,hf=P`
<g class="lob-antennae" stroke="var(--lob-shell)" stroke-width="4" stroke-linecap="round" fill="none">
<path d="M50 16 Q45 4 37 1" />
<path d="M70 16 Q75 4 83 1" />
</g>
`,gf=P`
<g stroke="#0a1014" stroke-linecap="round" fill="none">
<path d="M37 24 L51 28" stroke-width="3.5" />
<path d="M69 28 L83 24" stroke-width="3.5" />
<path d="M49 45 Q59 51 69 45 L72 42" stroke-width="3" />
</g>
`,_f=P`
<g class="lob-tail">
<ellipse cx="16" cy="84" rx="11" ry="7" transform="rotate(-32 16 84)" />
<ellipse cx="104" cy="84" rx="11" ry="7" transform="rotate(32 104 84)" />
</g>
`,vf=P`
<g class="lob-bindle">
<path d="M70 62 L99 30" stroke="#8a5a2b" stroke-width="3.5" stroke-linecap="round" />
<circle cx="101" cy="27" r="9.5" fill="#e8b04b" />
<circle cx="98" cy="24" r="1.6" fill="#b6791f" />
<circle cx="104" cy="29" r="1.6" fill="#b6791f" />
<circle cx="100" cy="32" r="1.3" fill="#b6791f" />
</g>
`,yf=new Set([`crown`,`sprout`,`santa`,`pumpkin`,`party`]),bf=P`
<g class="lob-cap">
<path d="M46 10 Q60 -3 74 10 L74 13 Q60 7 46 13 Z" fill="#f5f7fa" />
<path d="M45 12 Q60 6 75 12 L75 16 Q60 10.5 45 16 Z" fill="#dfe7ee" />
<circle cx="60" cy="2.5" r="1.8" fill="#3b6ea5" />
</g>
`,xf=P`
<g stroke="#0a1014" stroke-linecap="round" fill="none">
<path d="M37 24 L51 28" stroke-width="3.5" />
<path d="M69 28 L83 24" stroke-width="3.5" />
<path d="M50 48 Q60 42 70 48" stroke-width="3" />
</g>
`,Sf={perky:P`
<g class="lob-antennae" stroke="var(--lob-shell)" stroke-width="4" stroke-linecap="round" fill="none">
<path d="M46 14 Q38 4 31 7" />
<path d="M74 14 Q82 4 89 7" />
</g>
`,droopy:P`
<g class="lob-antennae" stroke="var(--lob-shell)" stroke-width="4" stroke-linecap="round" fill="none">
<path d="M46 14 Q36 8 34 18" />
<path d="M74 14 Q84 8 86 18" />
</g>
`},Cf=Hd(P`
<g stroke="#a63a2e" stroke-width="4" stroke-linecap="round" fill="none">
<path d="M22 78 L8 88" />
<path d="M28 88 L16 99" />
<path d="M98 78 L112 88" />
<path d="M92 88 L104 99" />
</g>
<g stroke="#c44536" stroke-width="3.5" stroke-linecap="round" fill="none">
<path d="M44 38 L40 24" />
<path d="M76 38 L80 24" />
</g>
<circle cx="40" cy="22" r="4.5" fill="#0a1014" />
<circle cx="80" cy="22" r="4.5" fill="#0a1014" />
<circle cx="41.5" cy="20.5" r="1.8" fill="#ffd166" />
<circle cx="81.5" cy="20.5" r="1.8" fill="#ffd166" />
<ellipse cx="60" cy="70" rx="46" ry="30" fill="#c44536" />
<ellipse cx="48" cy="60" rx="16" ry="9" fill="#ffffff" opacity="0.1" />
<path
d="M16 58 C2 52 -2 62 4 72 C10 82 20 76 24 66 C26 60 22 58 16 58 Z"
fill="#d95f4b"
/>
<path
d="M104 58 C118 52 122 62 116 72 C110 82 100 76 96 66 C94 60 98 58 104 58 Z"
fill="#d95f4b"
/>
<path d="M48 82 Q60 90 72 82" stroke="#7e2a20" stroke-width="3" stroke-linecap="round" fill="none" />
`),wf=Hd(P`
<path
d="M14 96 Q32 84 58 88 L96 88 Q110 90 112 97 Q112 103 102 103 L24 103 Q14 103 14 96 Z"
fill="#c9a06a"
/>
<g stroke="#c9a06a" stroke-width="3.5" stroke-linecap="round" fill="none">
<path d="M94 88 Q96 76 91 68" />
<path d="M103 88 Q107 76 103 66" />
</g>
<circle cx="90" cy="65" r="3.6" fill="#0a1014" />
<circle cx="103" cy="63" r="3.6" fill="#0a1014" />
<circle cx="91" cy="64" r="1.3" fill="#ffd166" />
<circle cx="104" cy="62" r="1.3" fill="#ffd166" />
<circle cx="50" cy="62" r="27" fill="#8a5a2b" />
<path
d="M50 41 a21 21 0 1 1 -15 36 a14 14 0 1 0 11 -25 a8 8 0 1 0 4 14"
stroke="#5f3d1c"
stroke-width="4"
stroke-linecap="round"
fill="none"
/>
`),Tf=Hd(P`
<path d="M30 82 Q20 74 27 65 Q30 76 40 79 Z" fill="#f0b52e" />
<ellipse cx="58" cy="85" rx="34" ry="17" fill="#ffd23e" />
<circle cx="82" cy="50" r="18" fill="#ffd23e" />
<path d="M98 49 Q112 52 99 59 Q95 56 95 51 Z" fill="#ff8c2e" />
<circle cx="86" cy="44" r="3.6" fill="#0a1014" />
<circle cx="87" cy="43" r="1.3" fill="#ffffff" />
<path d="M44 82 Q58 72 72 82 Q58 93 44 82 Z" fill="#f0b52e" opacity="0.75" />
`),Ef=Hd(P`
<g class="lob-jelly-tentacles" stroke="#9f7dfa" stroke-width="2.5" stroke-linecap="round" fill="none" opacity="0.8">
<path d="M40 58 Q35 74 42 90" />
<path d="M54 61 Q52 78 57 96" />
<path d="M68 61 Q71 78 64 94" />
<path d="M80 58 Q85 72 78 88" />
</g>
<path
d="M30 52 C30 22 90 22 90 52 L90 58 Q82 52 75 58 Q67 52 60 58 Q52 52 45 58 Q38 52 30 58 Z"
fill="#b79bff"
opacity="0.78"
/>
<ellipse cx="47" cy="37" rx="12" ry="6" fill="#ffffff" opacity="0.25" />
<circle cx="52" cy="45" r="2.6" fill="#0a1014" />
<circle cx="66" cy="45" r="2.6" fill="#0a1014" />
`),Df={crab:Cf,snail:wf,duck:Tf,jellyfish:Ef},Of=P`
<svg class="lobster-pet__balloon" viewBox="0 0 40 62" aria-hidden="true">
<path d="M20 34 Q23 46 18 60" stroke="#8a949d" stroke-width="1.5" fill="none" />
<ellipse cx="20" cy="16" rx="13" ry="15" fill="#ff5c8a" />
<path d="M17 30 L20 34.5 L23 30 Z" fill="#e0446f" />
<ellipse cx="15" cy="10" rx="4" ry="6" fill="#ffffff" opacity="0.3" />
</svg>
`,kf={stranger:`a stranger`,crab:`definitely a lobster`,snail:`in no particular hurry`,duck:`a duck. obviously`,jellyfish:`just drifting`}})))()}function jf(e){let t=Uf.map(e=>Cn(Td.find(t=>t.id===e),`chimera donor palette ${e}`)),n=()=>{let n=Math.floor(e()*t.length);return Cn(t.splice(n,1)[0],`distinct chimera donor`)};return{body:n().shell,clawLeft:n().shell,clawRight:n().shell,antennae:n().shell}}function Mf(e){return{palette:e,scale:2,accessory:`none`,antennae:`perky`,side:`left`,spotPct:0,facing:1,personality:`friendly`,blinkDelayS:s(e.id)%36/10,clawSize:`regular`,tailFan:!1,shiny:!1,crusherSide:null,freckles:!1,glint:null,chimeraParts:e.id===`chimera`?Wf:null}}function Nf(e){return e.getMonth()===Kf.month&&e.getDate()===Kf.day}function Pf(e){let t=e.getMonth(),n=e.getDate();return t===11?[[`santa`,18]]:t===9&&n>=20?[[`pumpkin`,18]]:t===8&&n===25?[[`monocle`,24]]:[]}function Ff(e,t){let n=md(e.palette.id);return n===e.palette.id?hd(t):n}function X(e){let t=e>>>0;return()=>{t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function If(e,t){let n=t.reduce((e,[,t])=>e+t,0),r=e()*n;for(let[e,n]of t)if(r-=n,r<=0)return e;return Cn(t.at(-1),`weighted lobster choice fallback`)[0]}function Z(e,t,n){return t+e()*(n-t)}function Lf(e,t=new Date){let n=X(e),r=If(n,wd),i=If(n,Jf),a=If(n,[...Gf,...Pf(t)]),o=n()<.6?`perky`:`droopy`,s=n()<.5?`left`:`right`,c=$f[s],l=Math.round(Z(n,c[0],c[1])),u=n()<.5?1:-1,d=If(n,qf),f=Math.round(Z(n,0,4)*10)/10;n();let p=If(n,Yf),m=n()<.3,h=n()<1/512,g=n(),_=n()<.5?`left`:`right`,v=g<.15?_:null,y=n()<.12,b=n(),x=Zf[Math.floor(n()*Zf.length)]??null,S=b<.3?x:null,ee=jf(n),C={palette:r,scale:i,accessory:a,antennae:o,side:s,spotPct:l,facing:u,personality:d,blinkDelayS:f,clawSize:p,tailFan:m,shiny:h,crusherSide:v,freckles:y,glint:S,chimeraParts:r.id===`chimera`?ee:null},w=r.id===`clawtron`?{...C,antennae:`perky`}:C;if(r.id===`zombie`&&(w={...C,antennae:`droopy`}),Nf(t)){let e=wd.find(([e])=>e.id===`retro`)?.[0];return{...w,palette:e??r,accessory:`party`,chimeraParts:null}}return w}function Rf(e,t={}){let n=e.palette.id===`flatpack`,r=Hf[e.palette.id],i=Bf.has(e.palette.id),a=t.shell||t.sleeping&&!t.reading,o=a?`display:none`:``,s=a?`opacity:1`:t.standalone||t.reading?`display:none`:``,c=Math.round(bd(new Date)*8)%8;return P`
<svg
class="lobster-pet__svg"
viewBox="0 0 120 105"
preserveAspectRatio="xMidYMax meet"
aria-hidden="true"
>
<g class=${Vf[e.palette.id]??``}>
${r?r(o,s):P`
${i?hf:Sf[e.antennae]}
${e.tailFan?_f:j}
<g class="lob-claw lob-claw--l">
<path d="M20 42 C5 37 0 47 5 57 C10 67 20 62 25 52 C28 45 25 42 20 42 Z" fill="var(--lob-claw)" />
</g>
${i?j:P`<g class="lob-claw lob-claw--r"><path d="M100 42 C115 37 120 47 115 57 C110 67 100 62 95 52 C92 45 95 42 100 42 Z" fill="var(--lob-claw)" /></g>`}
${e.palette.id===`heisenbug`?ef:j}
<path class="lob-standard-dome" d="M60 8 C32 8 16 32 16 52 C16 72 30 90 44 95 L44 104 L54 104 L54 96 C58 97.5 62 97.5 66 96 L66 104 L76 104 L76 95 C90 90 104 72 104 52 C104 32 88 8 60 8 Z" fill="var(--lob-shell)" />
${e.palette.id===`split`||e.palette.id===`geode`?pf:j}
${e.palette.id===`selene`?Bd(c):j}
${ff[e.palette.id]??j}
${e.palette.id===`tinfoil`?Nd(!yf.has(e.accessory)):j}
${e.freckles&&!rf.has(e.palette.id)?Gd:j}
${e.palette.id===`invisible`?j:P`<ellipse cx="48" cy="28" rx="20" ry="11" fill="#ffffff" opacity="0.1" />`}
<g class="lob-eye-open" style=${o}>
<circle cx="45" cy="32" r="5.5" fill="#0a1014" />
<circle cx="75" cy="32" r="5.5" fill="#0a1014" />
<circle cx="46.5" cy="30.5" r="2.2" fill="var(--lob-glint, #00e5cc)" />
<circle cx="76.5" cy="30.5" r="2.2" fill="var(--lob-glint, #00e5cc)" />
</g>
${t.sleeping&&!t.reading?P`<g class="lob-eye-peek"><circle cx="45" cy="32" r="4" fill="#0a1014" /><circle cx="46" cy="30.8" r="1.6" fill="var(--lob-glint, #00e5cc)" /></g>`:j}
<g class="lob-eye-closed" stroke="#0a1014" stroke-width="3" stroke-linecap="round" fill="none" style=${s}>
<path d="M39 33 Q45 28 51 33" /><path d="M69 33 Q75 28 81 33" />
</g>
`}
${i?P`
${gf}
<g class="lob-claw lob-claw--r">${mf}</g>
`:j}
${t.grumpy&&!i&&(!r||e.palette.id===`pixel`)?xf:j}
${e.accessory===`none`||t.shell||n?j:Wd[e.accessory]}
${t.bindle&&!i&&!n?vf:j}
${t.sailorCap&&!t.shell&&!n&&!yf.has(e.accessory)&&e.palette.id!==`tinfoil`?bf:j}
${t.reading?Qf:j}
</g>
</svg>
`}function zf(e){let t=e.crusherSide,n=(s(e.palette.id)>>>8)%34/10,r=e.chimeraParts,i=r?Td.find(e=>e.shell===r.body)?.claw:void 0,a=n=>t===null?Xf[e.clawSize]:t===n?Xf.mighty:Xf.dainty;return[`--lob-shell:${e.chimeraParts?.body??e.palette.shell}`,`--lob-claw:${i??e.palette.claw}`,`--lob-blink-delay:${e.blinkDelayS}s`,`--lob-breathe-delay:-${n}s`,`--lob-claw-l:${a(`left`)}`,`--lob-claw-r:${a(`right`)}`,...e.chimeraParts?[`--lob-chimera-l:${e.chimeraParts.clawLeft}`,`--lob-chimera-r:${e.chimeraParts.clawRight}`,`--lob-antennae-color:${e.chimeraParts.antennae}`]:[],...e.glint?[`--lob-glint-seed:${e.glint}`]:[]].join(`;`)}var Bf,Vf,Hf,Uf,Wf,Gf,Kf,qf,Jf,Yf,Xf,Zf,Qf,$f;function ep(){return(ep=e((()=>{Hn(),M(),yd(),Cd(),Ed(),zd(),Af(),Bf=new Set([`retro`,`goldenretro`]),Vf={heisenbug:`lob-heisenbug-frame`,cryptid:`lob-cryptid-frame`,balloon:`lob-balloon-frame`},Hf={flatpack:Dd,loading:Od,actual:kd,balloon:Ad,ascii:jd,portal:Md,pixel:Vd},Uf=[`crimson`,`blue`,`gold`,`banana`,`watermelon`],Wf={body:`#ff4f40`,clawLeft:`#4a7dfc`,clawRight:`#f4b840`,antennae:`#3f9d63`},Gf=[[`none`,62],[`sprout`,14],[`patch`,14],[`crown`,10]],Kf={month:10,day:24},qf=[[`sleepy`,25],[`zoomy`,25],[`friendly`,25],[`showoff`,25]],Jf=[[1.7,25],[2,55],[2.5,20]],Yf=[[`regular`,55],[`dainty`,25],[`mighty`,20]],Xf={dainty:.85,regular:1,mighty:1.18},Zf=[`#ffd166`,`#ff8ac2`,`#b79bff`],Qf=P`
<g class="lob-reading-book" transform="translate(0 2)">
<path
d="M25 62 Q43 56 59 66 L59 92 Q43 82 25 86 Z M61 66 Q77 56 95 62 L95 86 Q77 82 61 92 Z"
fill="var(--lob-claw)"
stroke="color-mix(in srgb, var(--lob-claw) 72%, #0a1014)"
stroke-width="2.5"
stroke-linejoin="round"
/>
<path d="M29 62 Q44 58 59 68 L59 88 Q44 79 29 82 Z" fill="#fffaf0" />
<path d="M61 68 Q76 58 91 62 L91 82 Q76 79 61 88 Z" fill="#fffaf0" />
<path d="M60 67 L60 89" stroke="#d7cfc0" stroke-width="1.5" />
<g stroke="#b8b0a3" stroke-width="1.25" stroke-linecap="round" opacity="0.58">
<path d="M34 67 L51 71" /><path d="M34 72 L50 75" /><path d="M67 71 L85 67" />
<path d="M68 76 L85 72" /><path d="M70 80 L83 77" />
</g>
<path
class="lob-reading-book__page-glow"
d="M31 62 Q45 59 57 68 L57 72 Q44 65 31 67 Z"
fill="#ffffff"
opacity="0"
/>
</g>
`,$f={left:[12,38],right:[60,84]}})))()}function tp(e,t,n=new Date){return e===`busy`||e===`offline`?_p[e]:mp(n)?gp.sleepy:t?gp[t]:null}function np(e){return e===`error`?`droop`:e===`aborted`?`startle`:`cheer`}function rp(e){return e<.06?`balloon`:e<.13?`bubble`:`walk`}function ip(e){return X((e^12317)>>>0)()<.12}function ap(e){return X((e^30485)>>>0)()<.04}function op(e,t){return(Object.hasOwn(yp,e)?yp[e]:void 0)??t?.[e]?.crossMs??12e3}function sp(e,{critters:t=[],strangers:n=!0}={}){let r=X((e^3243)>>>0),i=r()*1e3,a=[[`crab`,15],[`snail`,12],[`duck`,12],[`jellyfish`,11],...n?[[`stranger`,45]]:[],...t.map(e=>[e,20])],o=0,s=a.find(([,e])=>(o+=e,i<o))?.[0];return s?{kind:s,atMs:Math.round(2500+r()*6500),direction:r()<.5?1:-1,floor:r()<.55,hops:r()<.35&&s!==`snail`}:null}function cp(e){return X((e^57811)>>>0)()<.015}function lp(e,t){if(t.length===0)return null;let n=X((e^61982)>>>0);return n()>=.08?null:t[Math.floor(n()*t.length)]??null}function up(e,t){let n=Hu(),r={elder:!1,oldFriend:!1,friendName:null,dexComplete:Td.every(e=>n.has(e.id)),look:t};if(cp(e))return{...r,elder:!0,look:{...t,scale:3,accessory:`barnacle`,personality:`sleepy`,clawSize:`mighty`,crusherSide:null}};if(t.palette.id===`retro`||t.palette.id===`goldenretro`)return r;let i=lp(e,[...n].filter(e=>Td.some(t=>t.id===e)).toSorted()),a=i?Td.find(e=>e.id===i):void 0;return a?{...r,oldFriend:!0,friendName:Uu().get(a.id)?.name??null,look:{...t,palette:a,chimeraParts:a.id===`chimera`?Mf(a).chimeraParts:null}}:r}function dp(e,t){return e.elder?`Methuselah`:e.friendName??Ff(e.look,t)}function fp(e){let t=X((e^45175)>>>0);return t()>=.03?null:{atMs:Math.round(3500+t()*6500),spotPct:Math.round(15+t()*70),fortuneIndex:Math.floor(t()*Cp.length)}}function pp(e){try{let t=g();if(!t)return!1;let n=t.getItem(wp);return n!==e&&(t.setItem(wp,e),n!==null)}catch{return!1}}function mp(e=new Date){let t=e.getHours();return t>=22||t<6}function Q(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var hp,gp,_p,vp,yp,bp,xp,Sp,Cp,wp;function Tp(){return(Tp=e((()=>{rd(),ep(),Ed(),wr(),hp={wave:1400,snip:1e3,hop:750,spin:950,peek:1700,nap:4400,bubble:2600,scuttle:1250,startle:750,cheer:1300,molt:2600,pet:1500,droop:1600,sweep:1800},gp={sleepy:{delayMs:[6e3,12e3],acts:[[`nap`,40],[`bubble`,20],[`wave`,12],[`scuttle`,12],[`peek`,10],[`hop`,6]]},zoomy:{delayMs:[2800,6e3],acts:[[`scuttle`,42],[`hop`,22],[`spin`,12],[`peek`,12],[`wave`,12]]},friendly:{delayMs:[3600,7500],acts:[[`wave`,32],[`snip`,22],[`scuttle`,18],[`hop`,14],[`bubble`,14]]},showoff:{delayMs:[3600,7500],acts:[[`spin`,24],[`snip`,22],[`peek`,20],[`hop`,18],[`wave`,16]]}},_p={busy:{delayMs:[2200,4500],acts:[[`scuttle`,40],[`hop`,20],[`snip`,20],[`wave`,12],[`spin`,8]]},offline:{delayMs:[2800,5600],acts:[[`scuttle`,55],[`peek`,30],[`hop`,15]]}},vp={walk:450,balloon:1250,bubble:700},yp={stranger:11e3,crab:11e3,snail:9e4,duck:14e3,jellyfish:16e3,...hr},bp=[1800,7500],xp=[9e4,3e5],Sp=[18e5,36e5],Cp=[`the tide returns every branch to shore`,`molt before you feel ready`,`a shell is just armor you outgrew`,`somewhere, a test is green because of you`,`swim sideways when forward fails`,`the reef remembers kind commits`,`even the deep keeps a night light`,`barnacles are only patient passengers`,`no current lasts forever`,`bury your treasure in version control`,`the crab was a lobster all along`,`small claws, firm grip`,`rest is also progress`,`what washes away was never pinned`],wp=`openclaw.control.lobsterpet.gatewayVersion.v1`})))()}var Ep;function Dp(){return(Dp=e((()=>{Tp(),Ep=class{constructor(e,t){this.host=e,this.hooks=t,this.grumpyTimer=null,this.holdTimer=null,this.audioCtx=null,this.pokeTimes=[],this.lastGazeAt=0,this.handleHoldStart=e=>{e.button!==0||Q()||(this.holdTimer!==null&&window.clearTimeout(this.holdTimer),this.holdTimer=window.setTimeout(()=>{this.holdTimer=null,this.hooks.onGrumpyChange(!1),this.playChirp(`pet`),this.hooks.onAct(`pet`)},600))},this.handleHoldEnd=e=>{e.button===0&&this.holdTimer!==null&&(window.clearTimeout(this.holdTimer),this.holdTimer=null,this.pokeNow())},this.handleHoldCancel=()=>{this.holdTimer!==null&&(window.clearTimeout(this.holdTimer),this.holdTimer=null)},this.handleGaze=e=>{if(!this.hooks.canGaze()||Q())return;let t=Date.now();if(t-this.lastGazeAt<120)return;this.lastGazeAt=t;let n=this.host.querySelector(`.lobster-pet:not(.lobster-pet--shell)`);if(!n)return;let r=n.getBoundingClientRect(),i=r.left+r.width/2;this.hooks.onFacing(e.clientX<i?-1:1)},e.addController(this)}hostConnected(){document.addEventListener(`pointermove`,this.handleGaze,{passive:!0})}hostDisconnected(){document.removeEventListener(`pointermove`,this.handleGaze),this.handleHoldCancel(),this.clearGrumpyTimer(),this.audioCtx&&=(this.audioCtx.close().catch(()=>{}),null)}suspend(){this.handleHoldCancel(),this.clearGrumpyTimer(),this.hooks.onGrumpyChange(!1)}playChirp(e){this.audioCtx=dd(this.audioCtx,this.hooks.soundsEnabled(),e)}pokeNow(){this.playChirp(`poke`);let e=Date.now();if(this.pokeTimes=[...this.pokeTimes.filter(t=>e-t<6e3),e],this.pokeTimes.length>=10&&this.hooks.canHuff()){this.huffOff();return}this.pokeTimes.length>=3&&this.enterGrumpy(),this.hooks.onAct(`startle`)}clearGrumpyTimer(){this.grumpyTimer!==null&&(window.clearTimeout(this.grumpyTimer),this.grumpyTimer=null)}enterGrumpy(){this.hooks.onGrumpyChange(!0),this.clearGrumpyTimer(),this.grumpyTimer=window.setTimeout(()=>{this.grumpyTimer=null,this.hooks.onGrumpyChange(!1)},6e4)}huffOff(){this.pokeTimes=[],this.hooks.onGrumpyChange(!1),this.hooks.onHuff()}}})))()}function Op(e){return e.hop?1100:Math.max(850,Math.min(2600,Math.abs(e.to.x-e.from.x)*8))}function kp(e,t,n,r){let i=e,a=null;for(let e of n.toSorted((e,t)=>e.left-t.left)){let n=Math.min(t,e.left-r);n>i&&(!a||n-i>a[1]-a[0])&&(a=[i,n]),i=Math.max(i,e.right+r)}return t>i&&(!a||t-i>a[1]-a[0])&&(a=[i,t]),a}function Ap(e){let{composer:t,footer:n,editor:r}=e,i={top:null,floor:null,passage:null};if(t.width<=0||t.height<=0)return i;let a=Mp+(e.twins?28:0),o=kp(t.left+a,t.right-a,e.topObstacles.filter(e=>e.height>0&&e.bottom>t.top-Np&&e.top<t.top),a),s=o?{start:o[0]-t.left,end:o[1]-t.left,y:0}:null;if(!n||n.height<=0)return{...i,top:s};let c=Math.min(t.bottom-8,n.bottom-5);if(c-48<(r?.bottom??t.top))return{...i,top:s};let l=kp(Math.max(t.left,n.left)+a,Math.min(t.right,n.right)-a,e.controls.filter(e=>e.width>0&&e.height>0&&e.top<c&&e.bottom>c-48),a),u=l&&l[1]-l[0]>=24?{start:l[0]-t.left,end:l[1]-t.left,y:c-t.top}:null,d=Math.max(s?.start??1/0,u?.start??1/0,e.placeholderRight-t.left+a),f=Math.min(s?.end??-1/0,u?.end??-1/0);return{top:s,floor:u,passage:f-d>=28?[d,f]:null}}function jp(e,t){return{x:e?e.start+(e.end-e.start)*t/100:0,y:e?.y??0}}var Mp,Np,Pp;function Fp(){return(Fp=e((()=>{Mp=38,Np=88,Pp=class{constructor(e,t){this.host=e,this.twins=t,this.scene={top:null,floor:null,passage:null},this.resize=null,this.mutation=null,this.active=!1,this.frame=null,this.observed=[],this.scheduleMeasure=()=>{this.active&&this.frame===null&&(this.frame=requestAnimationFrame(()=>this.measure()))},e.addController(this)}planWalk(e,t,n){let r=this.scene[e];if(!r)return null;let i=Math.round(n*100);return Math.abs(i-t)<4&&(i=t>50?0:100),{anchor:e,spotPct:i,facing:i<t?-1:1,travel:{from:jp(r,t),to:jp(r,i),hop:!1}}}planHop(e,t){let{passage:n,floor:r}=this.scene,i=this.scene[e];if(!n||!r||!i)return null;let a=jp(i,t),o=(n[0]+n[1])/2;if(a.x<n[0]||a.x>n[1])return{anchor:e,spotPct:(o-i.start)/(i.end-i.start)*100,facing:o<a.x?-1:1,travel:{from:a,to:{x:o,y:i.y},hop:!1}};let s=e===`top`?`floor`:`top`,c=this.scene[s];if(!c)return null;let l=a.x<o?n[1]:n[0];return{anchor:s,spotPct:(l-c.start)/(c.end-c.start)*100,facing:l<a.x?-1:1,travel:{from:a,to:{x:l,y:c.y},hop:!0}}}hostConnected(){this.active=!0,typeof ResizeObserver<`u`?this.resize=new ResizeObserver(()=>this.measure()):window.addEventListener(`resize`,this.scheduleMeasure);let e=this.host.parentElement,t=e?.closest(`.new-session-page__draft`)??e;t&&(this.mutation=new MutationObserver(e=>{e.some(e=>e.target!==this.host&&!this.host.contains(e.target))&&this.scheduleMeasure()}),this.mutation.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`class`,`style`,`hidden`,`aria-label`]})),this.scheduleMeasure()}hostDisconnected(){this.active=!1,this.frame!==null&&(cancelAnimationFrame(this.frame),this.frame=null),this.resize?.disconnect(),this.resize=null,this.mutation?.disconnect(),this.mutation=null,this.observed=[],window.removeEventListener(`resize`,this.scheduleMeasure)}measure(){if(this.frame!==null&&(cancelAnimationFrame(this.frame),this.frame=null),!this.active||!this.host.isConnected)return;let e=this.host.parentElement;if(!e?.matches(`.agent-chat__input`))return;let t=e.querySelector(`.agent-chat__composer-footer`),n=e.querySelector(`textarea`),r=Array.from(t?.querySelectorAll(`.agent-chat__composer-lead, .chat-composer-model-control, .agent-chat__composer-actions, button, wa-button, [role=button]`)??[]),i=e.closest(`.new-session-page__draft`),a=Array.from(i?.querySelectorAll(`.new-session-page__triggers > *, .new-session-page__incognito-notice--visible`)??[]),o=[e,...r,...a,...t?[t]:[],...n?[n]:[]];if(o.length!==this.observed.length||o.some((e,t)=>e!==this.observed[t])){this.resize?.disconnect();for(let e of o)this.resize?.observe(e);this.observed=o}let s=n?.getBoundingClientRect()??null,c=s?.left??0;if(n&&s){let e=getComputedStyle(n),t=n.getAttribute(`aria-label`)??n.placeholder,r=Number.parseFloat(e.fontSize)||16,i=t.length*r*.65;if(typeof CanvasRenderingContext2D<`u`){let n=document.createElement(`canvas`).getContext(`2d`);n&&(n.font=e.font,i=n.measureText(t).width)}c+=Math.min(s.width,i+(Number.parseFloat(e.paddingLeft)||0))}let l=Ap({composer:e.getBoundingClientRect(),footer:t?.getBoundingClientRect()??null,controls:r.map(e=>e.getBoundingClientRect()),topObstacles:a.map(e=>e.getBoundingClientRect()),editor:s,placeholderRight:c,twins:this.twins()});this.host.toggleAttribute(`data-scene-ready`,l.top!==null),JSON.stringify(l)!==JSON.stringify(this.scene)&&(this.scene=l,this.host.requestUpdate())}}})))()}function Ip(e,t){for(let n=1;n<=24;n++){let r=Lf(e+n*7919>>>0);if(r.palette.id!==t)return r}return Lf(e+1>>>0)}function Lp(e,t,n,r){return[zf(e),`--lob-scale:${t}`,`--lob-x:${n}%`,`--lob-face:${r}`].join(`;`)}function Rp(e){if(!e.scene.top)return j;let t=e.scene[e.anchor]??e.scene.top,n=n=>{let r=e.anniversary&&e.look.accessory!==`party`?{...e.look,accessory:`party`}:e.look,i=[`lobster-pet`,`lobster-pet--${e.mode}`,`lobster-pet--palette-${e.look.palette.id}`,n?`lobster-pet--twin`:``,r.accessory===`party`?`lobster-pet--party`:``,e.look.shiny?`lobster-pet--shiny`:``,e.elder?`lobster-pet--elder`:``,e.presence===`leaving`?`lobster-pet--away`:``,e.entering?`lobster-pet--entering`:``,e.entering&&e.entrance!==`walk`?`lobster-pet--enter-${e.entrance}`:``,e.grumpy?`lobster-pet--grumpy`:``,e.vigil?`lobster-pet--vigil`:``,e.act?`lobster-pet--act-${e.act}`:``].filter(Boolean).join(` `),a=jp(t,e.spotPct);n&&(a.x=Math.max(t.start,Math.min(t.end,a.x-e.facing*28)));let o=n?e.look.scale*.55:e.look.scale,s=`${Lp(e.look,o,e.spotPct,e.facing)};--lob-x:${a.x}px;--lob-y:${a.y}px${n?`;--lob-act-delay:0.18s`:``}`,c=e.travel,l=c?`--lob-from-x:${c.from.x-c.to.x}px;--lob-from-y:${c.from.y-c.to.y}px;--lob-travel-ms:${Op(c)}ms${n?`;animation-delay:0.18s`:``}`:``,u=Xu(e.familiarityVisits),d=e.nameOverride??Ff(e.look,e.seed),f=u?`${u} ${d}`:d,p=e.look.shiny?`✦ ${f}`:f,m=e.movingDay&&!n,h=n?`${p} Jr.`:m?`${p} · just moved in`:e.flavor?`${p} · ${e.flavor}`:p;return A`
<div
class="lobster-pet__motion ${c?c.hop?`lobster-pet__motion--hop`:`lobster-pet__motion--walk`:``}"
style=${l}
>
<div
class=${i}
style=${s}
aria-hidden="true"
title=${h}
@pointerdown=${e.onPointerDown}
@pointerup=${e.onPointerUp}
@pointercancel=${e.onPointerCancel}
@pointerleave=${e.onPointerCancel}
@contextmenu=${e.onContextMenu}
>
<div class="lobster-pet__body">
${Rf(r,{grumpy:e.grumpy,bindle:m,sailorCap:e.sailorDay})}
${e.entering&&e.entrance===`balloon`?Of:j}
${e.entering&&e.entrance===`bubble`?A`<span class="lobster-pet__entry-bubble"></span>`:j}
${e.look.shiny?A`
<span class="lobster-pet__sparkle" style="--i:0;left:12%;bottom:64%">✦</span>
<span class="lobster-pet__sparkle" style="--i:1;left:76%;bottom:82%">✦</span>
`:j}
<span class="lobster-pet__z" style="--i:0">z</span>
<span class="lobster-pet__z" style="--i:1">z</span>
<span class="lobster-pet__z" style="--i:2">Z</span>
<span class="lobster-pet__bubble" style="--i:0"></span>
<span class="lobster-pet__bubble" style="--i:1"></span>
<span class="lobster-pet__bubble" style="--i:2"></span>
<span class="lobster-pet__heart">♥</span>
<svg class="lobster-pet__broom" viewBox="0 0 24 40" aria-hidden="true">
<path d="M12 2 L12 24" stroke="#8a5a2b" stroke-width="3" stroke-linecap="round" />
<path d="M6 24 L18 24 L21 38 L3 38 Z" fill="#e8b04b" />
<path
d="M7.5 28 L6.5 36 M12 28 L12 36 M16.5 28 L17.5 36"
stroke="#b6791f"
stroke-width="1.5"
/>
</svg>
</div>
</div>
</div>
`},r=e.residentEnabled&&e.presence!==`out`,i=e.residentEnabled&&e.shellVisible&&e.visitsEnabled&&!e.dismissed,a=e.passer&&!jn(e.passer.kind)?e.critterArtwork?.[e.passer.kind]:void 0,o=e.passer?.kind===`stranger`&&!a,s=e.passer!==null&&e.visitsEnabled&&(e.residentEnabled||!o)&&!e.dismissed&&(e.passer.anchor===`top`||e.floorEnabled&&e.scene.floor!==null),c=e.bottle!==null&&e.visitsEnabled&&!e.dismissed;if(!r&&!i&&!s&&!c)return j;let l=Lp(e.look,e.shellScale,e.shellSpotPct,e.facing),u=jp(e.scene[e.shellAnchor],e.shellSpotPct),d=o?Ip(e.seed,e.look.palette.id):e.look,f=e.passer?[`lobster-pet`,`lobster-pet--passer`,o?`lobster-pet--palette-${d.palette.id}`:`lobster-pet--${e.passer.kind}`,o&&d.shiny?`lobster-pet--shiny`:``,e.passer.direction===1?`lobster-pet--passer-ltr`:`lobster-pet--passer-rtl`,e.passer.hops&&e.scene.passage?`lobster-pet--passer-hop`:``].filter(Boolean).join(` `):``,p=e.passer?e.scene[e.passer.anchor]:null,m=e.passer?.hops&&e.scene.passage?e.scene.passage:[p?.start??0,p?.end??0],h=e.passer?.direction===1?m[0]:m[1],g=e.passer?.direction===1?m[1]:m[0],_=e.passer?`${zp(e.passer.kind,e.passer.direction,d,!!a)};--lob-cross:${e.passer.crossMs}ms;--lob-cross-from:${h}px;--lob-cross-to:${g}px;--lob-y:${p?.y??0}px`:``,v=e.passer&&Object.hasOwn(Bp,e.passer.kind)?Bp[e.passer.kind]:void 0,y=e.passer&&Object.hasOwn(Vp,e.passer.kind)?Vp[e.passer.kind]:void 0,b=jp(e.scene.top,e.bottle?.spotPct??50);return A`
${i?A`
<div
class="lobster-pet lobster-pet--shell"
style=${`${l};--lob-x:${u.x}px;--lob-y:${u.y}px`}
aria-hidden="true"
>
<div class="lobster-pet__body">${Rf(e.look,{shell:!0})}</div>
</div>
`:j}
${c&&e.bottle?A`
<div
class="lobster-bottle ${e.bottle.opened?`lobster-bottle--open`:``}"
style="--lob-x:${b.x}px"
title=${e.bottle.opened?e.bottle.fortune:`a message in a bottle`}
aria-hidden="true"
@pointerdown=${e.onBottleOpen}
>
${Ud(e.bottle.opened)}
</div>
`:j}
${r?n(!1):j}
${r&&e.twinPlanned?n(!0):j}
${s&&e.passer?A`
<div
class=${f}
style=${_}
aria-hidden="true"
title=${(a?a.title:y)??e.passer.kind}
>
<div class="lobster-pet__body">
${a?ur(a.url,`lobster-pet__svg`):o?Rf(d,{standalone:!0}):v??j}
</div>
</div>
`:j}
`}function zp(e,t,n,r){if(r)return`--lob-scale:1.8;--lob-w:1;--lob-h:1;--lob-face:${t}`;if(e===`stranger`)return Lp(n,Math.min(n.scale,2),0,t);if(jn(e))return fr(e,t);let i={crab:`--lob-scale:2;--lob-w:1;--lob-h:0.82;--lob-face:1`,snail:`--lob-scale:1.7;--lob-w:1;--lob-h:0.9;--lob-face:${t}`,duck:`--lob-scale:1.9;--lob-w:1;--lob-h:1;--lob-face:${t}`,jellyfish:`--lob-scale:1.7;--lob-w:0.9;--lob-h:1.1;--lob-face:1`};return(Object.hasOwn(i,e)?i[e]:void 0)??`--lob-scale:1.8;--lob-w:1;--lob-h:1;--lob-face:${t}`}var Bp,Vp;function Hp(){return(Hp=e((()=>{M(),wn(),rd(),ep(),Fp(),Af(),lr(),wr(),Bp={...Df,...Tr},Vp={...kf,...ar}})))()}var Up;function Wp(){return(Wp=e((()=>{Hn(),Tp(),Up=class{constructor(e,t){this.host=e,this.hooks=t,this.passer=null,this.connected=!1,this.bottlePlan=null,this.bottleVisible=!1,this.bottleOpened=!1,this.passerTimer=null,this.passerEndTimer=null,this.passerWatchTimer=null,this.seed=null,this.passerConsumed=!1,this.crossingMs=0,this.bottleTimer=null,this.bottleEndTimer=null,this.openBottle=()=>{!this.bottleOpened&&this.bottleVisible&&(this.bottleOpened=!0,this.armBottleEbb(12e4),this.host.requestUpdate())},e.addController(this)}hostConnected(){this.connected=!0}hostUpdate(){this.hooks.visitsEnabled()||(this.clearTimers(),this.passer=null,this.bottleVisible=!1)}hostDisconnected(){this.connected=!1,this.clearTimers(),this.passer=null,this.bottleVisible=!1,this.host.requestUpdate()}reset(e){e!==this.seed&&(this.seed=e,this.passerConsumed=!1),this.clearTimers(),this.passer=null,this.bottleVisible=!1,this.bottleOpened=!1,this.connected&&this.hooks.visitsEnabled()&&(this.schedulePasser(e),this.scheduleBottle(e))}replanPasser(e){let t=this.passer,n=this.hooks.passerOptions(),r=t&&[`stranger`,`crab`,`snail`,`duck`,`jellyfish`].includes(t.kind);if(t&&(t.kind!==`stranger`||n.strangers!==!1||n.critters?.includes(t.kind))&&(r||n.critters?.includes(t.kind)))return;let i=this.passer!==null;this.clearPasserTimers(),this.passer=null,i&&this.hooks.onPasserDone(),this.connected&&this.hooks.visitsEnabled()&&this.schedulePasser(e)}passerCrossMs(){return this.passer?this.crossingMs:0}bottle(){return!this.bottleVisible||!this.bottlePlan?null:{spotPct:this.bottlePlan.spotPct,opened:this.bottleOpened,fortune:Cn(Cp[this.bottlePlan.fortuneIndex],`lobster bottle fortune`)}}clearTimers(){this.clearPasserTimers();for(let e of[this.bottleTimer,this.bottleEndTimer])e!==null&&window.clearTimeout(e);this.bottleTimer=null,this.bottleEndTimer=null}clearPasserTimers(){for(let e of[this.passerTimer,this.passerEndTimer,this.passerWatchTimer])e!==null&&window.clearTimeout(e);this.passerTimer=null,this.passerEndTimer=null,this.passerWatchTimer=null}schedulePasser(e){if(this.passerConsumed)return;let t=sp(e,this.hooks.passerOptions());t&&!Q()&&(this.passerTimer=window.setTimeout(()=>{if(this.passerTimer=null,this.passerConsumed=!0,!this.connected||!this.hooks.visitsEnabled()||document.hidden||Q())return;this.hooks.onPasserStart(t),this.passer=t,this.crossingMs=op(t.kind,this.hooks.passerOptions().critterArtwork),this.host.requestUpdate();let e=this.passerCrossMs();this.hooks.onPasserFacing(t.direction===1?-1:1),this.passerWatchTimer=window.setTimeout(()=>{this.passerWatchTimer=null,this.hooks.onPasserFacing(t.direction),this.hooks.onPasserMidCross()},e/2),this.passerEndTimer=window.setTimeout(()=>{this.passerEndTimer=null,this.passer=null,this.host.requestUpdate(),this.hooks.onPasserDone()},e)},t.atMs))}scheduleBottle(e){this.bottlePlan=fp(e),this.bottlePlan&&(this.bottleTimer=window.setTimeout(()=>{this.bottleTimer=null,this.connected&&this.hooks.visitsEnabled()&&(this.bottleVisible=!0,this.host.requestUpdate(),this.armBottleEbb(3e5))},this.bottlePlan.atMs))}armBottleEbb(e){this.bottleEndTimer!==null&&window.clearTimeout(this.bottleEndTimer),this.bottleEndTimer=window.setTimeout(()=>{this.bottleEndTimer=null,this.bottleVisible=!1,this.host.requestUpdate()},e)}}})))()}var Gp=t({}),$;function Kp(){return(Kp=e((()=>{M(),bt(),nt(),rd(),cd(),ud(),Dp(),ep(),Tp(),Hp(),Fp(),Wp(),$=class extends Un{constructor(...e){super(...e),this.seed=0,this.mode=`idle`,this.visitsEnabled=!0,this.residentEnabled=!0,this.floorEnabled=!1,this.runOutcome=`ok`,this.soundsEnabled=!1,this.gatewayVersion=null,this.onVisitsDisabled=()=>void 0,this.act=null,this.spotPct=80,this.facing=1,this.entering=!1,this.entrance=`walk`,this.presence=`out`,this.anchor=`top`,this.geometry=new Pp(this,()=>this.residentEnabled&&this.twinPlanned),this.travel=null,this.travelScene=this.geometry.scene,this.motionRng=X(0),this.passerAnchor=`top`,this.passerHops=!1,this.shellAnchor=`top`,this.scheduledVisiting=!1,this.dismissed=!1,this.dismissMenuPosition=null,this.grumpy=!1,this.vigil=!1,this.outcomePresenceOwner=null,this.movingDay=!1,this.movingDayChecked=!1,this.anniversary=!1,this.sailorDay=!1,this.identity=null,this.entranceRng=X(0),this.traffic=new Up(this,{visitsEnabled:()=>this.visitsEnabled&&!this.dismissed,passerOptions:()=>({critters:this.critters,strangers:this.residentEnabled,critterArtwork:this.critterArtwork}),onPasserStart:e=>{this.passerAnchor=e.floor&&this.floorEnabled&&this.geometry.scene.floor?`floor`:`top`,this.passerHops=this.passerAnchor===`floor`&&e.hops&&this.geometry.scene.passage!==null},onPasserFacing:e=>this.watchTraffic(e),onPasserMidCross:()=>this.reactToPasser(),onPasserDone:()=>this.scheduleNextAct()}),this.interactions=new Ep(this,{soundsEnabled:()=>this.soundsEnabled,canHuff:()=>this.mode!==`offline`,canGaze:()=>this.presence===`in`&&this.act===null&&!this.vigil,onGrumpyChange:e=>{this.grumpy=e},onAct:e=>this.performAct(e),onFacing:e=>{this.facing=e},onHuff:()=>{this.clearVisitTimers(),this.scheduledVisiting=!1,this.armArrival(Z(this.visitRng,Sp[0],Sp[1]))}}),this.shellVisible=!1,this.shellSpotPct=50,this.shellScale=2,this.molted=!1,this.moltPlanned=!1,this.twinPlanned=!1,this.shellTimer=null,this.familiarity={tier:`regular`,wary:!1,visits:0,shoos:0},this.greetedThisLoad=!1,this.look=null,this.rng=X(0),this.visitRng=X(0),this.idleTimer=null,this.actEndTimer=null,this.enterTimer=null,this.visitTimer=null,this.leaveTimer=null,this.vigilTimer=null,this.restartPending=!1,this.handleVisibilityChange=()=>{document.hidden?(this.outcomePresenceOwner=null,this.clearActTimers(),this.act=null):this.scheduleNextAct()},this.openDismissMenu=e=>{this.residentEnabled&&this.visitsEnabled&&(e.preventDefault(),e.stopPropagation(),this.interactions.handleHoldCancel(),this.dismissMenuPosition={x:e.clientX,y:e.clientY})}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.hasUpdated&&(this.look=null,this.requestUpdate()),document.addEventListener(`visibilitychange`,this.handleVisibilityChange)}disconnectedCallback(){document.removeEventListener(`visibilitychange`,this.handleVisibilityChange),this.clearActTimers(),this.clearVisitTimers(),this.restartPending=!1,this.scheduledVisiting=!1,this.presence=`out`,this.act=null,this.shellTimer!==null&&(window.clearTimeout(this.shellTimer),this.shellTimer=null),this.vigilTimer!==null&&(window.clearTimeout(this.vigilTimer),this.vigilTimer=null),super.disconnectedCallback()}wantsVisible(){return this.visitsEnabled&&this.residentEnabled&&!this.dismissed&&(this.mode===`offline`||this.vigil||this.outcomePresenceOwner!==null||this.scheduledVisiting)}willUpdate(e){if(!this.isConnected)return;let t=this.look===null||e.has(`seed`);if(t)this.look=Lf(this.seed),this.rng=X(this.seed^2654435769),this.motionRng=X(this.seed^987138),this.visitRng=X(this.seed^99282957),this.entranceRng=X((this.seed^57978)>>>0),this.identity=up(this.seed,this.look),this.look=this.identity.look,this.spotPct=this.look.spotPct,this.facing=this.look.facing,this.clearActTimers(),this.act=null,this.dismissed=!1,this.dismissMenuPosition=null,this.presence=`out`,this.molted=!1,this.shellVisible=!1,this.shellTimer!==null&&(window.clearTimeout(this.shellTimer),this.shellTimer=null),this.moltPlanned=ip(this.seed)&&!this.identity.elder,this.twinPlanned=ap(this.seed),this.geometry.scheduleMeasure(),this.familiarity=Yu(),this.sailorDay=zu(new Date),this.greetedThisLoad=!1,this.scheduleVisits(),this.traffic.reset(this.seed),this.vigil=!1,this.outcomePresenceOwner=null,this.trackVigil();else if(e.has(`mode`)){let t=e.get(`mode`)===`busy`&&this.mode===`idle`,n=t&&this.vigil?`vigil`:null;if(this.trackVigil(),this.presence===`in`&&!Q()){let e=np(this.runOutcome);this.performAct(t?e:`startle`,n)}}(e.has(`visitsEnabled`)||e.has(`residentEnabled`))&&(this.visitsEnabled&&e.get(`visitsEnabled`)===!1&&(this.dismissed=!1,this.traffic.reset(this.seed)),!this.visitsEnabled||!this.residentEnabled?this.suspendResident():(e.get(`visitsEnabled`)===!1||e.get(`residentEnabled`)===!1)&&(this.scheduleVisits(),this.trackVigil()));let n=e.get(`critters`)??[],r=this.critters??[],i=e.has(`critters`)&&(n.length!==r.length||n.some((e,t)=>e!==r[t]));!t&&(e.has(`residentEnabled`)||i)&&(this.traffic.replanPasser(this.seed),this.geometry.scheduleMeasure()),this.residentEnabled&&!this.movingDayChecked&&this.gatewayVersion&&(this.movingDayChecked=!0,this.movingDay=pp(this.gatewayVersion)),this.toggleAttribute(`data-dex-complete`,(this.identity?.dexComplete??!1)&&this.visitsEnabled&&this.residentEnabled&&!this.dismissed),((!this.floorEnabled||!this.geometry.scene.floor)&&this.anchor===`floor`||this.travel&&this.travelScene!==this.geometry.scene)&&(this.clearActTimers(),this.act=null,this.anchor=`top`,this.restartPending=this.presence===`in`),this.setAttribute(`data-spot`,this.anchor),this.toggleAttribute(`data-floor-enabled`,this.floorEnabled),this.reconcilePresence()}reconcilePresence(){let e=this.wantsVisible();if(e&&this.presence!==`in`){this.leaveTimer!==null&&(window.clearTimeout(this.leaveTimer),this.leaveTimer=null),this.presence===`out`&&(this.rollPerch(),this.entrance=rp(this.entranceRng()),this.look&&(this.anniversary=Zu(Uu().get(this.look.palette.id)?.firstSeenAt??null,new Date),Wu(this.look.palette.id,{name:this.identity?dp(this.identity,this.seed):Ff(this.look,this.seed),shiny:this.look.shiny}),qu())),this.presence=`in`,this.entering=!Q(),this.restartPending=!0;return}!e&&this.presence===`in`&&(this.dismissMenuPosition=null,this.outcomePresenceOwner=null,this.clearActTimers(),this.act=null,this.entering=!1,this.presence=`leaving`,this.leaveTimer=window.setTimeout(()=>{this.leaveTimer=null,this.presence=`out`},350))}updated(){this.isConnected&&this.restartPending&&(this.restartPending=!1,this.enterTimer=window.setTimeout(()=>{this.enterTimer=null,this.entering=!1,!this.greetedThisLoad&&(this.familiarity.tier===`friend`||this.identity?.oldFriend===!0)&&this.presence===`in`&&!Q()&&(this.greetedThisLoad=!0,this.performAct(`wave`))},vp[this.entrance]),this.scheduleNextAct())}trackVigil(){this.vigilTimer!==null&&(window.clearTimeout(this.vigilTimer),this.vigilTimer=null),this.mode===`busy`&&this.visitsEnabled&&this.residentEnabled&&!this.dismissed?this.vigilTimer=window.setTimeout(()=>{this.vigilTimer=null,this.vigil=!0,this.clearActTimers(),this.act=null},6e5):this.vigil=!1}dismiss(e){this.dismissMenuPosition=null,this.dismissed=!0,Ju(),e&&(this.visitsEnabled=!1,ke({lobsterPetVisits:!1}),this.onVisitsDisabled())}clearActTimers(){this.travel=null;for(let e of[this.idleTimer,this.actEndTimer,this.enterTimer])e!==null&&window.clearTimeout(e);this.idleTimer=null,this.actEndTimer=null,this.enterTimer=null}clearVisitTimers(){for(let e of[this.visitTimer,this.leaveTimer])e!==null&&window.clearTimeout(e);this.visitTimer=null,this.leaveTimer=null}suspendResident(){this.clearActTimers(),this.clearVisitTimers(),this.interactions.suspend();for(let e of[this.shellTimer,this.vigilTimer])e!==null&&window.clearTimeout(e);this.shellTimer=null,this.vigilTimer=null,this.shellVisible=!1,this.vigil=!1,this.outcomePresenceOwner=null,this.dismissMenuPosition=null,this.scheduledVisiting=!1,this.presence=`out`,this.act=null,this.entering=!1,this.restartPending=!1}scheduleVisits(){if(this.clearVisitTimers(),this.scheduledVisiting=!1,!this.visitsEnabled||!this.residentEnabled||this.visitRng()<.5)return;let e=ed[this.familiarity.tier];this.armArrival(Z(this.visitRng,bp[0],bp[1])*e.firstDelayMul)}armArrival(e){this.isConnected&&this.visitsEnabled&&this.residentEnabled&&(this.visitTimer=window.setTimeout(()=>{this.visitTimer=null,this.scheduledVisiting=!0,this.armDeparture(Z(this.visitRng,xp[0],xp[1])*ed[this.familiarity.tier].stayMul)},e))}armDeparture(e){this.visitTimer=window.setTimeout(()=>{this.visitTimer=null,this.scheduledVisiting=!1;let e=ed[this.familiarity.tier],t=this.familiarity.wary?ed.waryGapMul:1;this.armArrival(Z(this.visitRng,Sp[0],Sp[1])*e.gapMul*t)},e)}watchTraffic(e){this.presence===`in`&&this.act!==`scuttle`&&!this.vigil&&(this.facing=e)}reactToPasser(){let e=this.familiarity.tier===`friend`?`wave`:this.familiarity.tier===`shy`?`peek`:null;e===null||this.presence!==`in`||this.act!==null||this.vigil||this.mode!==`idle`||Q()||this.performAct(e)}rollPerch(){this.anchor=`top`,this.spotPct=Math.round(Z(this.visitRng,12,88)),this.facing=this.visitRng()<.5?1:-1}scheduleNextAct(){if(!this.isConnected||!this.visitsEnabled||!this.residentEnabled||!this.look||this.presence!==`in`||this.vigil||this.traffic.passer!==null||this.idleTimer!==null||this.actEndTimer!==null||Q())return;let e=tp(this.mode,this.look.personality);if(!e)return;let t=Z(this.rng,e.delayMs[0],e.delayMs[1]);this.idleTimer=window.setTimeout(()=>{this.idleTimer=null;let e=tp(this.mode,this.look?.personality??null);if(e&&!document.hidden&&this.presence===`in`&&this.traffic.passer===null){if(this.moltPlanned&&!this.molted&&this.mode===`idle`){this.performAct(`molt`);return}this.performAct(If(this.rng,e.acts))}},t)}performAct(e,t=null){if(!this.visitsEnabled||!this.residentEnabled||this.presence!==`in`)return;this.clearActTimers(),this.outcomePresenceOwner=t,this.entering=!1,e===`hop`?this.startFloorHop():e===`scuttle`&&this.applyMove(this.geometry.planWalk(this.anchor,this.spotPct,this.rng()));let n=this.travel?Op(this.travel):hp[e];this.act=this.travel&&!this.travel.hop?`scuttle`:e,this.actEndTimer=window.setTimeout(()=>{if(this.actEndTimer=null,this.act=null,this.travel=null,e===`molt`&&this.completeMolt(),e===`droop`){this.performAct(`sweep`,t);return}this.outcomePresenceOwner=null,this.wantsVisible()&&this.scheduleNextAct()},n+(this.twinPlanned?180:0))}completeMolt(){this.molted=!0,this.look&&=(this.shellScale=this.look.scale,{...this.look,scale:this.look.scale<2?2:2.5}),this.shellSpotPct=this.spotPct,this.shellAnchor=this.anchor,this.shellVisible=!0,this.spotPct=Math.min(100,Math.max(0,this.spotPct+this.facing*9)),this.shellTimer!==null&&window.clearTimeout(this.shellTimer),this.shellTimer=window.setTimeout(()=>{this.shellTimer=null,this.shellVisible=!1},6e4)}applyMove(e){e&&(this.anchor=e.anchor,this.spotPct=e.spotPct,this.facing=e.facing,this.travel=e.travel,this.travelScene=this.geometry.scene)}startFloorHop(){!this.floorEnabled||this.identity?.elder||this.anchor===`top`&&this.motionRng()>=.45||this.applyMove(this.geometry.planHop(this.anchor,this.spotPct))}render(){let e=this.look;if(!e)return j;let t=this.identity,n=t?.elder?`old as the tides`:t?.oldFriend?`an old friend`:null;return[Rp({look:e,mode:this.mode,presence:this.presence,shellVisible:this.shellVisible&&(this.shellAnchor===`top`||this.floorEnabled&&this.geometry.scene.floor!==null),shellAnchor:this.shellAnchor,scene:this.geometry.scene,travel:this.travel,floorEnabled:this.floorEnabled,visitsEnabled:this.visitsEnabled,residentEnabled:this.residentEnabled,critterArtwork:this.critterArtwork,dismissed:this.dismissed,passer:this.traffic.passer?{kind:this.traffic.passer.kind,direction:this.traffic.passer.direction,crossMs:this.traffic.passerCrossMs(),anchor:this.passerAnchor,hops:this.passerHops}:null,twinPlanned:this.twinPlanned,anniversary:this.anniversary,entering:this.entering,entrance:this.entrance,grumpy:this.grumpy,vigil:this.vigil,elder:t?.elder??!1,act:this.act,spotPct:this.spotPct,facing:this.facing,anchor:this.anchor,shellScale:this.shellScale,shellSpotPct:this.shellSpotPct,familiarityVisits:this.familiarity.visits,seed:this.seed,movingDay:this.movingDay,sailorDay:this.sailorDay,nameOverride:t?dp(t,this.seed):null,flavor:n,bottle:this.traffic.bottle(),onPointerDown:this.interactions.handleHoldStart,onPointerUp:this.interactions.handleHoldEnd,onPointerCancel:this.interactions.handleHoldCancel,onContextMenu:this.openDismissMenu,onBottleOpen:this.traffic.openBottle}),ld({position:this.dismissMenuPosition,onDismiss:e=>this.dismiss(e),onClose:()=>{this.dismissMenuPosition=null}})]}},B([F({attribute:!1})],$.prototype,`seed`,void 0),B([F({attribute:!1})],$.prototype,`mode`,void 0),B([F({attribute:!1})],$.prototype,`visitsEnabled`,void 0),B([F({attribute:!1})],$.prototype,`residentEnabled`,void 0),B([F({attribute:!1})],$.prototype,`critters`,void 0),B([F({attribute:!1})],$.prototype,`critterArtwork`,void 0),B([F({attribute:!1})],$.prototype,`floorEnabled`,void 0),B([F({attribute:!1})],$.prototype,`runOutcome`,void 0),B([F({attribute:!1})],$.prototype,`soundsEnabled`,void 0),B([F({attribute:!1})],$.prototype,`gatewayVersion`,void 0),B([F({attribute:!1})],$.prototype,`onVisitsDisabled`,void 0),B([N()],$.prototype,`act`,void 0),B([N()],$.prototype,`spotPct`,void 0),B([N()],$.prototype,`facing`,void 0),B([N()],$.prototype,`entering`,void 0),B([N()],$.prototype,`entrance`,void 0),B([N()],$.prototype,`presence`,void 0),B([N()],$.prototype,`anchor`,void 0),B([N()],$.prototype,`scheduledVisiting`,void 0),B([N()],$.prototype,`dismissed`,void 0),B([N()],$.prototype,`dismissMenuPosition`,void 0),B([N()],$.prototype,`grumpy`,void 0),B([N()],$.prototype,`vigil`,void 0),B([N()],$.prototype,`outcomePresenceOwner`,void 0),B([N()],$.prototype,`movingDay`,void 0),B([N()],$.prototype,`anniversary`,void 0),B([N()],$.prototype,`shellVisible`,void 0),customElements.get(`openclaw-lobster-pet`)||customElements.define(`openclaw-lobster-pet`,$)})))()}function qp(e,t){return A`
<div class="callout danger new-session-page__error new-session-page__alert" role="alert">
<span class="new-session-page__alert-icon" aria-hidden="true">${O.alertTriangle}</span>
<span class="callout__content new-session-page__alert-message"
>${ae(e)}</span
>
${t?A`<button
class="btn btn--sm"
type="button"
?disabled=${t.disabled}
@click=${t.onClick}
>
${t.label}
</button>`:j}
</div>
`}function Jp(e){let{pendingMessage:t}=e,n=t?Bt(t):null,r=Zr(!0,n?.sender?e.userId:null),i=e.submitting&&!t;return A`
<div class="sr-only" role="status" aria-live="polite">
${t?e.completion?.label??e.statusLabel??E(`newSession.starting`):j}
</div>
<div
class="new-session-page__scroll ${t?`chat-thread ${r===`footer`?`chat-thread--direct`:``}`:``}"
?inert=${i}
aria-busy=${String(e.submitting)}
@mousedown=${$e}
>
${e.error?qp(e.error,e.errorAction):j}
${t&&n?Yp(t,n,r,e.onOpenImage,e.statusLabel,e.completion):e.renderDraft()}
${t&&e.showDraft?e.renderDraft():j}
</div>
`}function Yp(e,t,n,r,i=E(`newSession.starting`),a){let o=`new-session-submission`,s=t.sender?dn(t.sender):null,{images:c,attachments:l}=Ja(e,t.content),u=fi(l),d=rn(e,t),f=ir(d),p={onOpenImage:r};return A`<div class="new-session-page__starting chat-thread-inner">
<div
class="chat-group user ${t.sender?`chat-group--with-footer`:``} ${s===null?``:`chat-group--sender-tint`}"
style=${s===null?j:`--chat-sender-hue: ${s}`}
data-chat-row-key=${o}
>
${t.sender&&n===`gutter`?Ri(sr(t.sender),Jt(t.sender)??``):j}
<div class="chat-group-messages">
<div
class="chat-bubble ${c.length||u?`chat-bubble--with-images`:``} ${u?`chat-bubble--with-files`:``}"
data-message-id=${o}
data-message-text=${d||j}
>
${ci(c,p)}
${qr(l,p,void 0,void 0,!1)}
${f?Vr(f,o,{role:`user`,isStreaming:!1},{codeBlockChrome:`none`}):d?mi(d,o,{role:`user`,isStreaming:!1},{codeBlockChrome:`none`}):j}
</div>
</div>
${t.sender&&n===`footer`?A`<div class="chat-group-footer">
<div class="chat-group-footer__meta">
${Mi(t.sender)}
</div>
</div>`:j}
</div>
<div class="chat-group assistant chat-group--working">
<div class="chat-group-messages">
${a?A`<div class="callout" role="status">
<span class="callout__content">${a.label}</span>
${a.onOpen?A`<button
class="btn btn--sm"
type="button"
?disabled=${a.disabled}
@click=${a.onOpen}
>
${E(`sessionsView.openSession`)}
</button>`:j}
</div>`:Ba({kind:`reading-indicator`,key:o,startedAt:e.timestamp},{startupLabel:i})}
</div>
</div>
</div>`}function Xp(){return(Xp=e((()=>{M(),Ze(),k(),or(),vr(),l(),I(),gn(),Zt(),Nt(),ye(),hn(),$r(),vi(),pa(),Fa(),Wr(),Rr(),L()})))()}var Zp;function Qp(){return(Qp=e((()=>{M(),nt(),l(),I(),Ni(),Ar(),Hi(),L(),Zp=class{constructor(e){this.options=e,this.dictation=null,this.owner=null,this.devicePicker=new zi(e.requestUpdate)}dispose(){this.owner=null,this.dictation?.dispose(),this.dictation=null,this.devicePicker.dispose()}get active(){return this.dictation?.active===!0}previewDraft(){let e=this.dictation;return e?.active?this.options.textarea.previewTranscript(e.transcript):void 0}renderStatus(){return Jr(this.dictation??void 0)}render(e,t){this.owner?.key!==e&&(this.owner={key:e},this.dictation?.dispose(),this.dictation=null);let n=this.owner,r=()=>this.owner===n,i=this.options.getClient(),a=this.options.isConnected()&&i!==null;this.devicePicker.syncCatalog(i,a);let o=this.options.canCommit(),s={client:i,connected:a,enabled:o,dictationAvailable:this.devicePicker.dictationStatus===`ready`,realtimeTalkActive:!1,onCommit:(e,t)=>{if(!r()||!this.options.canCommit())return;let n=this.options.textarea.insertTranscript(e,t);n!==null&&this.options.onMessage(n),this.options.requestUpdate()},onError:e=>{r()&&this.options.onError(e)},onStateChange:()=>{r()&&this.options.requestUpdate()},onDictationUnavailable:this.devicePicker.handleOpen};this.dictation??=new yi(s),this.dictation.update(s);let c=this.dictation;return A`
${ri({connected:a,sending:!1,isBusy:!o,dictation:c,idleLabel:E(`newSession.dictate`),microphonePicker:Da({devices:this.devicePicker.devices,loading:this.devicePicker.loading,open:this.devicePicker.open,selectedDeviceId:t?.trim()??``,voiceActive:!1,issue:this.devicePicker.issue,showRealtimeCapability:!1,realtimeStatus:this.devicePicker.realtimeStatus,dictationStatus:this.devicePicker.dictationStatus,onOpen:this.devicePicker.handleOpen,onClose:this.devicePicker.handleClose,onSelect:e=>{ke({realtimeTalkInputDeviceId:e.trim()||void 0}),this.devicePicker.handleClose()}}),onDirectDictationStart:()=>this.options.textarea.captureSelection()})}
${Pi(c,()=>{r()&&this.options.canCommit()&&this.options.onSubmit()})}
`}}})))()}function $p(e){let t=e.visibility===`draft`,n=e.submitting||e.messageLocked,r=E(`newSession.draft`);return A`
<button
type="button"
class="new-session-page__visibility new-session-page__visibility--draft ${t?`new-session-page__visibility--active`:``}"
role="switch"
aria-label=${r}
aria-checked=${String(t)}
?disabled=${n}
title=${E(`newSession.draftDescription`)}
@click=${()=>e.onVisibilityChange?.(t?`normal`:`draft`)}
>
<span class="new-session-page__visibility-icon" aria-hidden="true">${O.pencil}</span>
<span class="new-session-page__visibility-label">${r}</span>
</button>
`}function em(e,t){let n=e.visibility===`draft`,r=e.submitting||e.messageLocked===!0,i=e.textareaController;return gi({attachments:t,capabilityMenu:e.capabilityMenu,disabled:r,open:i.capabilityMenuOpen,view:i.capabilityMenuView,toolOverrides:e.toolOverrides,rootToggles:e.draftAvailable?[{value:`new-session-draft`,label:E(`newSession.draft`),icon:O.pencil,checked:n,disabled:r,title:E(`newSession.draftDescription`),onChange:t=>e.onVisibilityChange?.(t?`draft`:`normal`)}]:void 0,onOpenChange:t=>{i.capabilityMenuOpen=t,t||(i.capabilityMenuView=`root`),e.requestUpdate()},onViewChange:t=>{i.capabilityMenuView=t,e.requestUpdate()}})}function tm(e){let t=xa(e.toolOverrides);if(t===0)return j;let n=e.submitting||e.messageLocked===!0;return A`
<button
type="button"
class="new-session-page__selection-status"
?disabled=${n}
@click=${()=>{e.textareaController.capabilityMenuView=`root`,e.textareaController.capabilityMenuOpen=!0,e.requestUpdate()}}
>
${E(t===1?`chat.composer.overrides.countOne`:`chat.composer.overrides.count`,{count:String(t)})}
</button>
`}function nm(){return(nm=e((()=>{M(),k(),l(),I(),ui(),L()})))()}function rm(e){e.textareaController.emojiMenu.close(),e.textareaController.mentionMenu.close(),Ur(e.textareaController.skillMenuState),qi(e.textareaController.slashMenuState),e.onSubmit()}function im(e){let t=e.submitting?E(`newSession.starting`):E(e.nativeTerminal?`newSession.startInTerminal`:`newSession.start`),n=!e.canSubmit&&e.submitDisabledReason!==void 0,r=e.submitting||e.pendingAttachmentReads>0;return A` <openclaw-tooltip content=${e.submitDisabledReason??t}>
<button
type="button"
class="chat-send-btn new-session-page__start-submit ${n?`new-session-page__start-submit--blocked`:``} ${r?`new-session-page__start-submit--busy`:``}"
?disabled=${!e.canSubmit&&!n}
aria-disabled=${String(!e.canSubmit)}
aria-busy=${String(r)}
aria-label=${t}
@click=${()=>rm(e)}
>
${r?O.loader:e.nativeTerminal?O.squareTerminal:O.arrowUp}
</button>
</openclaw-tooltip>`}function am(e,t,n,r,i){if(t.dictationActive||t.submitting||t.messageLocked||t.textareaController.composing||e.isComposing||e.keyCode===229||t.textareaController.emojiMenu.handleKeydown(e,`new-session`,t.requestUpdate)||t.textareaController.mentionMenu.handleKeydown(e,i,t.requestUpdate)||zr(e,t.textareaController.skillMenuState,n,t.requestUpdate)||Wi(e,t.textareaController.slashMenuState,r,t.requestUpdate)||e.key!==`Enter`)return;let a=e.metaKey||e.ctrlKey,o=t.requiresModifier?a&&e.shiftKey:a&&!e.shiftKey;if(!e.altKey&&o&&t.onBackgroundSubmit){if(e.repeat){e.preventDefault();return}(t.canSubmit||t.submitDisabledReason!==void 0)&&(e.preventDefault(),Ur(t.textareaController.skillMenuState),qi(t.textareaController.slashMenuState),t.textareaController.mentionMenu.close(),t.onBackgroundSubmit());return}if(!(e.shiftKey||t.requiresModifier&&!a)){if(e.repeat){e.preventDefault();return}(t.canSubmit||t.submitDisabledReason!==void 0)&&(e.preventDefault(),rm(t))}}function om(e){let t=e.textareaController.skillMenuState,n=e.textareaController.slashMenuState,r=e.textareaController.mentionMenu,i=e.textareaController.emojiMenu,a=e.submitting||e.messageLocked===!0||e.dictationActive===!0;r.syncDirectory(a?void 0:e.mentionDirectory);let o={paneId:`new-session`,getDraft:()=>e.textareaController.getTextarea()?.value??e.message,commitDraft:e.onInput,getTextarea:e.textareaController.getTextarea,refreshCommands:e.refreshCommands},s={...o,resolveArgOptions:e=>e.argOptions??[],runCommand:()=>rm(e),canRun:e=>!e,commandFilter:e=>e.executeLocal!==!0},c={paneId:o.paneId,getDraft:o.getDraft,getTextarea:o.getTextarea,getMentions:()=>e.getMentions?.()??e.mentions??[],commitDraft:e.onInput},l=o=>{i.update(o,e.requestUpdate,!a&&!e.nativeTerminal&&!e.textareaController.composing&&!t.skillMenuOpen&&!n.slashMenuOpen&&!r.open)},u=(a,c)=>{if(e.nativeTerminal||e.textareaController.composing||c?.isComposing){i.close();return}Ka(a.value,n,s,e.requestUpdate),hi(a.value,a.selectionStart,t,o,e.requestUpdate),c?.inputType===`insertFromPaste`||c?.inputType===`insertFromDrop`?r.close():r.update(a,e.requestUpdate,c?c.inputType===`insertText`&&c.data?.includes(`@`)===!0?`trigger`:`input`:`selection`),l(a)},d=t=>{let n=t.currentTarget;n instanceof HTMLTextAreaElement&&(t.type===`keyup`?(r.update(n,e.requestUpdate),l(n)):u(n))};(a||e.nativeTerminal||e.textareaController.composing)&&i.close();let f={attachmentReads:e.attachmentReads,attachmentLimits:e.attachmentLimits,uploadConfig:e.uploadConfig,attachments:e.attachments,get disabled(){return e.submitting||e.messageLocked===!0||e.dictationActive===!0},getAttachments:e.getAttachments,draft:e.message,getDraft:()=>e.message,onAttachmentsChange:e.onAttachmentsChange,onDraftChange:e.onInput,onPendingReadsChange:e.onPendingReadsChange,onOpenImage:e.onOpenImage,onOpenSidebar:e.onOpenSidebar,readSignal:e.readSignal},p=Sa({...f,canCompose:!a&&!e.nativeTerminal}),m=e.dictationPreview??e.message;e.textareaController.syncDraft(m);let h=E(e.nativeTerminal?`newSession.nativeTerminalPrompt`:`newSession.messagePlaceholder`),g=e.dictationActive?``:e.textareaController.getPlaceholder(h,e.message,e.requestUpdate),{skillMenuVisible:_,slashMenuVisible:v,menuVisible:y,menuListboxId:b,activeMenuOptionId:x,activeMenuOptionLabel:S}=Xa(o.paneId,!e.nativeTerminal&&!a,t,n,r,i),ee=$i(o.paneId,`active-menu-announcement`),C=e.requiresModifier?`Control+Enter Meta+Enter`:`Enter`,w=e.requiresModifier?`Control+Shift+Enter Meta+Shift+Enter`:`Control+Enter Meta+Enter`,T=e.onBackgroundSubmit?`${C} ${w}`:C;return A`
<div
class="agent-chat__composer-shell new-session-page__composer"
@drop=${t=>{e.nativeTerminal&&t.dataTransfer?.files.length?(t.preventDefault(),e.onUnsupportedAttachment?.()):p.onDrop(t)}}
@dragenter=${p.onDragenter}
@dragleave=${p.onDragleave}
@dragover=${p.onDragover}
>
<div
class="agent-chat__input agent-chat__input--mobile-toolbar${e.dictationActive?` agent-chat__input--dictating`:``}"
@openclaw-composer-dismiss-invocations=${()=>{r.close(),i.dismiss(e.textareaController.getTextarea()),e.requestUpdate()}}
>
${e.renderCritters(!a&&m.length===0&&e.attachments.length===0&&e.pendingAttachmentReads===0&&!y&&!e.textareaController.capabilityMenuOpen)}
${r.render(c,e.requestUpdate)}
${i.render(`new-session`,e.textareaController.getTextarea(),e.requestUpdate)}
${e.nativeTerminal?j:ei(f)}
${oi(e.message,e.mentions,()=>e.onInput(e.message,[]),r.selectedAvatarUrls)}
${Ui(f)}
${Pa(e.pendingAttachmentReads)}
<div class="agent-chat__composer-lede">${e.dictationStatus??j}</div>
<div class="agent-chat__composer-input-row">
<div class="agent-chat__composer-combobox">
${v?Ya(n,s,e.message,e.requestUpdate):j}
${_?Gr(t,o,e.requestUpdate):j}
<textarea
${pt(e.textareaController.ref)}
class="new-session-page__message"
rows="1"
?autofocus=${globalThis.matchMedia?.(`(max-width: 560px)`)?.matches??!1}
?disabled=${e.submitting||e.messageLocked}
?readonly=${e.dictationActive}
placeholder=${g}
aria-label=${h}
aria-keyshortcuts=${T}
.value=${_t([m],()=>vt(m))}
aria-autocomplete="list"
aria-controls=${ht(y?b:void 0)}
aria-haspopup=${ht(y?`listbox`:void 0)}
aria-activedescendant=${ht(x??void 0)}
aria-describedby=${ee}
@input=${t=>{if(e.dictationActive)return;let n=t.target;ni(n);let r=c.getMentions();e.onInput(n.value,r.length?Gt(e.message,n.value,r,e.textareaController.mentionInput):void 0),e.textareaController.mentionInput=void 0,u(n,t)}}
@beforeinput=${t=>{let n=t.target;e.textareaController.mentionInput={value:n.value,start:n.selectionStart,end:n.selectionEnd,inputType:t.inputType},i.complete(t,e.requestUpdate,!a&&!e.nativeTerminal&&!e.textareaController.composing)}}
@select=${d}
@focus=${d}
@pointerup=${d}
@keyup=${e=>{i.handleKeyup(e),(e.key.startsWith(`Arrow`)||e.key===`Home`||e.key===`End`)&&d(e)}}
@blur=${()=>{let t=i.open;e.textareaController.composing=!1,i.close(),t&&e.requestUpdate()}}
@compositionend=${t=>{e.textareaController.composing=!1,t.target instanceof HTMLTextAreaElement&&u(t.target)}}
@keydown=${t=>am(t,e,o,s,c)}
@compositionstart=${()=>{e.textareaController.composing=!0,i.close(),r.close(),e.requestUpdate()}}
@paste=${t=>{e.nativeTerminal&&t.clipboardData?.files.length?(t.preventDefault(),e.onUnsupportedAttachment?.()):!a&&!e.nativeTerminal&&ca(t,f)}}
></textarea>
<span class="agent-chat__composer-placeholder" aria-hidden="true"
>${g}</span
>
<span
id=${ee}
class="sr-only"
role="status"
aria-live="polite"
aria-atomic="true"
>${S}</span
>
</div>
</div>
<div class="agent-chat__composer-footer">
<div class="agent-chat__composer-lead">
${e.nativeTerminal?j:em(e,f)}
${e.permissionControl??j}
${!e.nativeTerminal&&e.draftAvailable?$p(e):j}
${e.nativeTerminal?j:tm(e)}
</div>
<div class="agent-chat__composer-trail">
<div class="agent-chat__composer-controls">
${e.modelControl&&e.modelControl!==j?A`<div class="chat-composer-model-control">${e.modelControl}</div>`:j}
</div>
<div class="agent-chat__composer-actions">
${e.voiceControl??j}${e.dictationActive?j:im(e)}
</div>
</div>
</div>
</div>
${e.blockedSubmitNotice?A`<div
class="new-session-page__blocked-submit agent-chat__composer-status"
data-tone="info"
role="status"
>
<div class="agent-chat__composer-status-band">
<span class="agent-chat__composer-status-icon" aria-hidden="true"
>${O.info}</span
>
<span class="agent-chat__composer-status-text">${e.blockedSubmitNotice}</span>
</div>
</div>`:j}
</div>
`}function sm(){return(sm=e((()=>{M(),St(),ft(),xt(),mt(),k(),l(),I(),on(),Oe(),Kr(),aa(),bi(),ai(),fa(),Ha(),Ia(),nm(),L()})))()}function cm(e,t,n){let r=e.worktree&&!nl(e.worktreeName),i=t.capabilities;return A`
${r?qp(E(`newSession.worktreeNameInvalid`)):j}
${n&&i.toolOverrides?qp(E(`newSession.terminalCapabilityOverridesUnsupported`),{label:E(`common.reset`),onClick:()=>i.setToolOverrides(null)}):j}
${t.submissionOutcomeUnknown?qp(E(t.submissionOutcomeUnknown===`gateway-changed`?`newSession.createOutcomeUnknown`:`newSession.placementSetupInterrupted`),t.pendingPlacement.sessionKey?{label:E(`common.reset`),onClick:()=>t.clearPendingPlacementRecovery()}:void 0):j}
`}function lm(e){let t=e.attachmentDraft.reads.readSignal,n=e.nativeTerminal?null:e.context?.gateway.snapshot.client??null,r=e.context?.gateway,i=su(e);return e.textareaController.syncSkillCommandOwner(n,e.agentId,e.draftOwnerKey),om({...e,renderCritters:t=>A`<openclaw-lobster-pet
.seed=${id(`${e.textareaController.critterVisit}:${e.draftOwnerKey}`)}
.mode=${od(!r?.snapshot.offlineStable,e.context?.sessions.state.result?.sessions)}
.runOutcome=${ad(e.context?.sessions.state.result?.sessions)}
.visitsEnabled=${e.context?.theme.settings.lobsterPetVisits!==!1}
.residentEnabled=${e.context?.theme.branding.mascot!==`none`}
.critters=${e.context?.theme.branding.critters}
.critterArtwork=${e.context?.theme.branding.artwork?.critters}
.soundsEnabled=${e.context?.theme.settings.lobsterPetSounds===!0}
.gatewayVersion=${e.context?.config.current.serverVersion??r?.snapshot.hello?.server?.version??null}
.onVisitsDisabled=${()=>e.context?.theme.refresh()}
.floorEnabled=${t}
></openclaw-lobster-pet>`,uploadConfig:e.context?.config,attachmentLimits:Nr(e.context?.gateway.snapshot.hello?.policy),attachments:e.attachmentDraft.attachments,getAttachments:()=>e.attachmentDraft.attachments,get message(){return e.message},mentionDirectory:i,modelControl:e.isCatalogTarget?j:e.modelControl.render({agent:e.agent,agentId:e.agentId,context:e.context,sending:e.submitting}),pendingAttachmentReads:e.attachmentDraft.reads.pendingReads,attachmentReads:e.attachmentDraft.reads,readSignal:t,refreshCommands:n?()=>Ca({client:n,agentId:e.agentId,shouldApply:()=>e.textareaController.ownsSkillCommands(n,e.agentId,e.draftOwnerKey)}):void 0,get dictationActive(){return e.dictationActive},get submitting(){return e.submitting},get messageLocked(){return e.messageLocked},onAttachmentsChange:t=>{!e.submitting&&!e.messageLocked&&e.attachmentDraft.replace(t)},onPendingReadsChange:n=>e.attachmentDraft.reads.updatePending(t,n)})}function um(){return(um=e((()=>{M(),cd(),l(),I(),Qi(),ga(),sm(),al(),Xp(),cu(),L()})))()}function dm(e,t,n,r){t.draftPersistence.persistNow();let i=e?.gateway.snapshot.client;if(!e||!i||t.submitting||t.pendingPlacement.sessionKey)return;let a=n??uo(window.location.search);e.chatAttachmentHandoff.prepare({reviewPrivateDraft:Aa,owner:i,paneId:hm,scopeKey:a,message:r===a?t.message:``,mentions:r===a?t.mentions:void 0,newSessionDraft:t.draftPersistence.captureSubmission(),attachments:t.attachmentDraft.take(),fallbacks:{}})}function fm(e,t,n,r,i){let a=e?.gateway.snapshot.client;e&&a?.recoveryScopeReady&&t.draftPersistence.setOwner(e.gateway.connection.gatewayUrl,a.recoveryScope,!0),t.draftPersistence.selectRoute(n);let o=e&&a?e.chatAttachmentHandoff.consume({owner:a,paneId:hm,scopeKey:n}):null;return o?(t.restoreDraftState({message:r||o.message||``,mentions:r?i:o.mentions,attachments:o.attachments,visibility:o.newSessionDraft?.incognito?`incognito`:t.visibility}),!r&&o.newSessionDraft&&t.draftPersistence.adoptHandoff(o.newSessionDraft)):r&&t.restoreMessage(r,i),pm(t,n),n}function pm(e,t){e.pendingPlacement.sessionKey||e.draftPersistence.activateRoute(t)}function mm(e,t,n){e.restorePendingPlacementRecovery(t,n),e.draftPersistence.setOwner(t,n,!!e.pendingPlacement.sessionKey)}var hm;function gm(){return(gm=e((()=>{ii(),G(),hm=`new-session-draft`})))()}function _m(e,t){return e?.client===t?.client&&e?.agentId===t?.agentId&&e?.ownerKey===t?.ownerKey&&e?.message===t?.message&&e?.model===t?.model}var vm;function ym(){return(ym=e((()=>{jt(),G(),vm=class{constructor(e,t){this.read=t,this.current=null,this.title=null,this.active=!1,this.pending=!1,this.readyAt=0,this.connected=!1,this.composing=!1,this.submitted=null,e.addController(this)}hostConnected(){this.connected=!0}hostUpdated(){this.sync(this.input())}hostDisconnected(){this.connected=!1,this.sync(null),this.submitted=null}setComposing(e){this.composing=e,this.hostUpdated()}takePreparedTitle(){let e=this.input(),t=_m(this.current,e)?this.title??void 0:void 0;return this.submitted=e??this.submitted,this.sync(null),t}sync(e){let t=e?.message.trim()??``,n=e&&t.length>=12&&!t.startsWith(`/`)?{...e,message:t}:null;_m(this.current,n)||(clearTimeout(this.timer),this.current=n,this.title=null,this.pending=n!==null,this.readyAt=Date.now()+1e3,this.schedule())}schedule(){this.pending&&!this.active&&(this.timer=setTimeout(()=>void this.prepare(),Math.max(0,this.readyAt-Date.now())))}async prepare(){let e=this.current;if(e&&this.pending){this.pending=!1,this.active=!0;try{let t=await e.client.request(`sessions.title.prepare`,{agentId:e.agentId,message:Jn(e.message,1e3),...e.model?{model:e.model}:{}},{timeoutMs:2e4});this.current===e&&(this.title=t.title)}catch{}finally{this.active=!1,this.schedule()}}}input(){let{context:e,data:t,place:n,submission:r,dictating:i}=this.read(),a=e?.gateway.snapshot;if(!this.connected||W(t)||this.composing||i||r.submitting||r.visibility===`incognito`||r.pendingPlacement.sessionKey||!n.agentId||!n.modelControl.accountSelectionReady()||!kt(a,`sessions.title.prepare`,`operator.write`)||!a?.client)return null;let o={client:a.client,ownerKey:lo(t),agentId:n.agentId,message:r.message.trim(),model:n.modelControl.modelForSubmission()};return _m(o,this.submitted)?null:o}}})))()}function bm(e,t){let n=e.visibility===`incognito`,r=e.visibility===`draft`,i=e.incognitoDisabledReason(),a=e.submitting||!!e.pendingPlacement.sessionKey||!!i,o=i??E(`newSession.incognitoDescription`);return A`
<div class="new-session-page__incognito-rail">
${t?A`
<openclaw-tooltip
class="new-session-page__draft-tooltip"
.content=${E(`newSession.draftDescription`)}
>
<button
type="button"
class="shell-chrome-controls__button new-session-page__draft-toggle ${r?`new-session-page__draft-toggle--active`:``}"
role="switch"
aria-label=${`${E(`newSession.draft`)}: ${E(`newSession.draftDescription`)}`}
aria-checked=${String(r)}
?disabled=${e.submitting||!!e.pendingPlacement.sessionKey}
title=${E(`newSession.draftDescription`)}
@click=${()=>e.setVisibility(r?`normal`:`draft`)}
>
${O.pencil}
${r?A`<span class="new-session-page__draft-toggle-label"
>${E(`newSession.draft`)}</span
>`:j}
</button>
</openclaw-tooltip>
`:j}
<openclaw-tooltip .content=${o}>
<button
type="button"
class="shell-chrome-controls__button new-session-page__incognito-toggle ${n?`new-session-page__incognito-toggle--active`:``}"
role="switch"
aria-label=${E(`newSession.incognito`)}
aria-checked=${String(n)}
?disabled=${a}
title=${o}
@click=${()=>{a||e.setVisibility(n?`normal`:`incognito`)}}
>
${Sm}
</button>
</openclaw-tooltip>
</div>
`}function xm(e){let t=E(`newSession.incognitoDescription`);return A`
<div
class="new-session-page__incognito-notice ${e?`new-session-page__incognito-notice--visible`:``}"
role="status"
aria-hidden=${String(!e)}
>
<span class="new-session-page__incognito-notice-icon" aria-hidden="true">
${Sm}
</span>
<span>${t}</span>
</div>
`}var Sm;function Cm(){return(Cm=e((()=>{M(),et(),k(),Oe(),l(),I(),L(),Sm=D(P` <path
d="M4 13V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5"
/>
<path d="M14 2v5a1 1 0 0 0 1 1h5" />
<path d="M10 22v-5" />
<path d="M14 19v-2" />
<path d="M18 20v-3" />
<path d="M2 13h20" />
<path d="M6 20v-3" />`)})))()}var wm,Tm;function Em(){return(Em=e((()=>{Rn(),M(),bt(),qe(),He(),Pe(),it(),l(),I(),he(),ge(),Sr(),f(),_(),y(),r(),Li(),Ir(),Ei(),ha(),Ma(),oa(),G(),Qp(),ro(),Xp(),um(),ou(),gm(),ym(),Cm(),Pl(),iu(),Lu(),Yn(),L(),wm={tagName:`openclaw-chat-detail-panel`,get label(){return E(`chat.attachments.pastedText`)},loadModule:async()=>{await Gn(()=>import(`./control-ui-boot-shared-styles-BaQ2sAfZ.js`).then(e=>(e.l(),e.u)),__vite__mapDeps([9]),import.meta.url),await Gn(()=>import(`./chat-detail-panel-DL_gv0lj.js`),__vite__mapDeps([12,1,3,4,5,6,7,8,13,14,15,16,17,18,19,2,9,10,11,20,21,22,23]),import.meta.url)}},Tm=class extends o{constructor(){super(),this.retainedForHandoff=null,this.openedFor=null,this.critterImport=be(()=>Gn(()=>Promise.resolve().then(()=>(Kp(),Gp)),void 0,import.meta.url)),this.openedGroupDefaults=``,this.openedAgentId=``,this.messageOwnerKey=``,this.attachmentPanel=null,this.attachmentPanelLoader=new Re(this),this.closeAttachmentPanel=()=>{this.attachmentPanel=null},this.openAttachmentPanel=e=>{e.kind===`attachment`&&(this.attachmentPanel={content:e,ownerKey:this.routeOwnerKey(),agentId:this.place.agentId})},this.imageLightbox=null,this.agentPickerOpen=!1,this.groupRouteRevalidation=new Eo(()=>this.data,()=>this.context?.revalidate(`new-session`)),this.titlePreparation=new vm(this,()=>({context:this.context,data:this.data,place:this.place,submission:this.submission,dictating:this.dictation.active})),this.flushDraft=()=>this.submission.draftPersistence.persistNow(),this.setImageLightbox=e=>{this.imageLightbox=e},this.draft=new au(this,()=>({context:this.context,data:this.data,isConnected:this.isConnected}),{requestUpdate:()=>this.requestUpdate(),querySelector:e=>this.querySelector(e),activeElement:()=>this.ownerDocument.activeElement,body:()=>this.ownerDocument.body,onInvalidate:()=>{this.closeAttachmentPanel(),this.connectMachine?.close()},onRecoveryReady:(e,t)=>mm(this.submission,e,t),closeTransientUi:()=>{this.closeAttachmentPanel(),nu(this)},takePreparedTitle:()=>this.titlePreparation.takePreparedTitle(),retainForHandoff:()=>{if(!this.data||!this.isConnected)return;let e={};return this.retainedForHandoff=e,{page:this,data:this.data,synchronizeGateway:()=>{this.context&&this.gateway.synchronize(this.context.gateway)},release:()=>{this.retainedForHandoff===e&&(this.retainedForHandoff=null,this.isConnected||this.disposeDraft())}}}}),this.gateway=this.draft.gateway,this.browser=this.draft.browser,this.place=this.draft.place,this.submission=this.draft.submission,this.connectMachine=new no(()=>({client:this.gateway.client,connected:this.gateway.connected}),()=>this.requestUpdate()),this.dictation=new Zp({textarea:this.submission.composerTextarea,getClient:()=>this.gateway.client,isConnected:()=>this.gateway.connected,canCommit:()=>!this.submission.submitting&&!this.submission.pendingPlacement.sessionKey,onMessage:e=>this.setMessageFromUser(e),onError:e=>this.submission.setError(e),onSubmit:()=>void this.submission.submit(),requestUpdate:()=>this.requestUpdate()}),this.subscriptions=new de(this).effect(()=>this.ownerDocument,Zi).watchStore(()=>this.context?.theme).watchStore(()=>this.context?.agents).watchStore(()=>this.context?.agentIdentity).watchStore(()=>this.context?.sessions,e=>this.groupRouteRevalidation.synchronize(e)).watchStore(()=>this.context?.placementStartup).watchStore(()=>this.context?.runtimeConfig).watch(()=>this.context?.config,(e,t)=>e.subscribe(()=>t()))}handleEvent(e){e instanceof KeyboardEvent&&ji(this,e)}focusComposer(){let e=this.context,t=this.routeOwnerKey(),n=document.activeElement;this.updateComplete.then(()=>{this.isConnected&&!this.retainedForHandoff&&this.context===e&&this.routeOwnerKey()===t&&(document.activeElement===n||document.activeElement===document.body)&&!document.openClawModalLayers?.size&&this.submission.composerTextarea.getTextarea()?.focus({preventScroll:!0})})}connectedCallback(){super.connectedCallback(),this.submission.draftPersistence.connect(),this.critterImport.schedule(),document.addEventListener(`keydown`,this,!0),window.addEventListener(`beforeunload`,this.flushDraft)}disconnectedCallback(){this.closeAttachmentPanel(),this.attachmentPanelLoader.requestWhileActive(wm,!1),this.critterImport.dispose(),document.removeEventListener(`keydown`,this,!0),window.removeEventListener(`beforeunload`,this.flushDraft),this.subscriptions.clear(),this.dictation.dispose(),this.connectMachine.close(),this.retainedForHandoff||this.disposeDraft(),super.disconnectedCallback()}disposeDraft(){kl(this.data,this),dm(this.context,this.submission,this.openedFor,this.messageOwnerKey),this.draft.disconnect()}willUpdate(){let e=this.attachmentPanel;e&&(e.ownerKey!==this.routeOwnerKey()||e.agentId!==this.place.agentId||this.submission.submitting||this.submission.pendingPlacement.sessionKey||!this.submission.attachmentDraft.attachments.some(t=>t.id===e.content.sourceIdentity))&&(this.attachmentPanel=null),this.attachmentPanelLoader.requestWhileActive(wm,this.attachmentPanel!==null)}updated(){this.connectMachine.open&&!this.place.isAdmin()&&this.connectMachine.close(),this.gateway.retryPendingCatalogTarget(),this.context?.agentIdentity.ensure(this.agentPickerOpen?this.place.agents().map(e=>e.id):[this.place.agentId]);let e=this.draft.agentsReady();this.place.modelControl.loadCatalogTargets(this.context,e&&this.place.agentId?this.place.selectedAgent()?.id??``:``,this.context?.config.current.cliAgentsEnabled===!0&&!W(this.data));let t=this.routeOwnerKey(),n=this.data?.agentId??``,r=ho(this.data);if(this.openedFor!==t){this.openedFor!==null&&this.submission.visibility===`incognito`&&dm(this.context,this.submission,this.openedFor,this.messageOwnerKey);let i=this.messageOwnerKey===t?this.submission.message:``,a=this.messageOwnerKey===t?this.submission.mentions:void 0;this.openedFor=t,this.openedGroupDefaults=r,this.openedAgentId=n,this.place.setAgentsHydrated(e),this.resetDraft(),this.messageOwnerKey=fm(this.context,this.submission,t,i,a),this.focusComposer();return}this.openedGroupDefaults!==r&&(this.openedGroupDefaults=r,this.place.adoptGroupDefaults()),this.openedAgentId!==n&&(this.openedAgentId=n,this.place.setAgentsHydrated(!1)),this.draft.synchronizeSelections(),pm(this.submission,t),this.submission.resumeInterruptedSubmission()}resetDraft(){this.place.resetDraft(),this.submission.resetDraft(),this.messageOwnerKey=lo(this.data),this.browser.clearPopoverHiding(),tu(this),this.browser.close(),this.connectMachine.close(),this.place.adoptAgentDefaults()}routeOwnerKey(){return this.data?lo(this.data):uo(window.location.search)}setMessageFromUser(e,t){!this.submission.submitting&&!this.submission.pendingPlacement.sessionKey&&(this.submission.setMessage(e,t),this.messageOwnerKey=uo(window.location.search))}renderTargetBar(){let e=this.place.agents(),t=this.context?.sessions;return To({data:this.data,groupPending:vo(this.data,t),agentSelect:e.length>1?Fu({agents:e,agentId:this.place.agentId,agentIdentity:this.context?.agentIdentity,disabled:this.submission.submitting||!!this.submission.pendingPlacement.sessionKey,onSelect:e=>this.place.selectAgentId(e),onOpenChange:e=>{this.agentPickerOpen=e}}):j,placeSelect:Iu({context:this.context,data:this.data,gateway:this.gateway,place:this.place,submitting:this.submission.submitting,pendingPlacement:!!this.submission.pendingPlacement.sessionKey,onConnectMachine:()=>this.openConnectMachine(),onNavigate:(e,t)=>this.context?.navigate(e,t),onFocusComposer:()=>this.submission.composerTextarea.getTextarea()?.focus({preventScroll:!0}),requestUpdate:()=>this.requestUpdate()}),retrying:this.gateway.catalogRetrying||!!(this.data?.group&&t?.groupsStatus()===`loading`),onRetry:this.gateway.handleCatalogRetry})}openConnectMachine(){this.place.isAdmin()&&(this.browser.close(),this.connectMachine.start())}renderDraftBlock(){let{context:e,gateway:t,place:n,submission:r,dictation:i,titlePreparation:a}=this,o=this.routeOwnerKey(),s=W(this.data),c=r.capabilities,l=e?.theme.settings,u=i.render(o,l?.realtimeTalkInputDeviceId),d=i.active;return A`
<div
class="new-session-page__draft"
aria-busy=${String(r.submitting)}
@compositionstart=${()=>{a.setComposing(!0)}}
@compositionend=${()=>{a.setComposing(!1)}}
@focusout=${()=>{a.setComposing(!1)}}
>
${this.renderTargetBar()} ${cm(n,r,s)}
${lm({agent:n.selectedAgent(),agentId:n.agentId,attachmentDraft:r.attachmentDraft,canSubmit:!r.submitting&&!d&&r.canSubmit(),submitDisabledReason:r.submitDisabledReason(),blockedSubmitNotice:r.blockedSubmitNotice(),get dictationActive(){return i.active},dictationPreview:i.previewDraft(),dictationStatus:i.renderStatus(),context:e,isCatalogTarget:s,draftOwnerKey:o,get message(){return r.message},mentions:r.mentions,getMentions:()=>r.mentions,visibility:r.visibility,draftAvailable:c.canStartAsDraft(e),...c.composerProps(e,t,n.agentId),modelControl:n.modelControl,permissionControl:s?void 0:Mr({canSelectFull:n.isAdmin(),defaultMode:n.selectedAgent()?.defaultPermissionMode,disabled:r.submitting||!!r.pendingPlacement.sessionKey,disabledReason:r.submitting?E(`newSession.starting`):void 0,mode:r.permissionMode,onSelect:e=>r.setPermissionMode(e??void 0)}),requiresModifier:l?.chatSendShortcut===`modifier-enter`,requestUpdate:()=>this.requestUpdate(),get submitting(){return r.submitting},textareaController:r.composerTextarea,voiceControl:u,get messageLocked(){return!!r.pendingPlacement.sessionKey},nativeTerminal:s,onUnsupportedAttachment:()=>r.setError(E(`newSession.terminalAttachmentsUnsupported`)),onInput:(e,t)=>this.setMessageFromUser(e,t),onOpenImage:this.setImageLightbox,onOpenSidebar:this.openAttachmentPanel,onVisibilityChange:e=>{!r.submitting&&!r.pendingPlacement.sessionKey&&r.setVisibility(e)},onSubmit:()=>void r.submit(),onBackgroundSubmit:r.visibility===`draft`||s?void 0:()=>void r.submit(void 0,!0)})}
${s?j:xm(r.visibility===`incognito`)}
</div>
`}renderWelcome(){let e=this.place.selectedAgent(),t=this.context?.agentIdentity.get(this.place.agentId),n=this.context?.gateway.snapshot;return ia({currentAgentId:this.place.agentId,assistantName:e?ne(e,t):``,assistantAvatar:re(e??{},t),assistantAvatarUrl:ue(e??{},t),hint:E(W(this.data)?`newSession.nativeTerminalHint`:`newSession.hint`),composer:this.renderDraftBlock(),hideSecondaryContent:this.submission.visibility===`incognito`,fadeSecondaryContent:this.submission.message.trim().length>0,modelSetupRequired:this.submission.requiresModelSetup(),onModelSetup:()=>this.context?.navigate(`model-setup`),sessions:this.context?.sessions.state.result,sessionKey:Pn({agentId:this.place.agentId||`main`,mainKey:this.context?.agents.state.agentsList?.mainKey}),sessionHost:{assistantAgentId:n?.assistantAgentId??null,agentsList:this.context?.agents.state.agentsList??null,hello:n?.hello??null},onDraftChange:e=>this.setMessageFromUser(e),onSend:()=>void this.submission.submit(),onOpenSession:e=>{let{context:t,submission:n}=this;!t||n.submitting||n.pendingPlacement.sessionKey||(ut({selection:t.agentSelection,gateway:t.gateway,sessionKey:e,agentId:this.place.agentId}),t.navigate(`chat`,b({context:t,face:`chat`,sessionKey:e}).options))}})}render(){let e=this.submission.pendingMessage,t=this.submission.completedSubmission,n=t?this.context?.placementStartup.get(t.key):null,r=this.context?.gateway.snapshot.selfUser?.identity,i=this.submission.visibility===`incognito`,a=this.attachmentPanelLoader.visibleState;return A`
<div
class="new-session-page ${e?`chat`:``} ${i?`new-session-page--incognito`:``}"
>
${W(this.data)?j:bm(this.submission,this.submission.capabilities.canStartAsDraft(this.context))}
${Jp({error:this.submission.error,pendingMessage:e,userId:r?.type===`profile`?r.id:null,submitting:this.submission.submitting,statusLabel:this.context?.gateway.snapshot.phase===`connected`?void 0:E(`connection.reconnecting`),completion:t?{label:t.error??n?.error??Ci(null,n)??E(`newSession.created`),onOpen:()=>void this.submission.openSubmittedSession(),disabled:this.context?.gateway.snapshot.phase!==`connected`}:void 0,showDraft:!!t,renderDraft:()=>t?this.renderDraftBlock():this.renderWelcome(),onOpenImage:this.setImageLightbox})}
${this.connectMachine.render(this.place.isAdmin(),()=>{this.connectMachine.close(),this.context?.navigate(`devices`)})}
${pi(this.imageLightbox,()=>this.setImageLightbox(null))}
</div>
${this.attachmentPanel?A`<aside class="new-session-attachment-panel">
${a?.status===`error`?ot({error:a.error,stale:a.stale,onRetry:()=>this.attachmentPanelLoader.retry(),onClose:this.closeAttachmentPanel}):a?A`<div role="status">${E(`common.loading`)}</div>`:j}
<openclaw-chat-detail-panel
.content=${{...this.attachmentPanel.content}}
@chat-detail-panel-close=${this.closeAttachmentPanel}
></openclaw-chat-detail-panel>
</aside>`:j}
`}},B([F({attribute:!1})],Tm.prototype,`data`,void 0),B([Fn({context:lt,subscribe:!0})],Tm.prototype,`context`,void 0),B([N()],Tm.prototype,`attachmentPanel`,void 0),B([N()],Tm.prototype,`imageLightbox`,void 0),B([N()],Tm.prototype,`agentPickerOpen`,void 0)})))()}var Dm=t({render:()=>Om}),Om;function km(){return(km=e((()=>{M(),Pl(),Em(),customElements.get(`openclaw-new-session-page`)||customElements.define(`openclaw-new-session-page`,Tm),Om=e=>Al(e)??A`<openclaw-new-session-page .data=${e}></openclaw-new-session-page>`})))()}var Am=t({load:()=>jm});async function jm(e,t,n){let r=n&&n!==`preload`&&Ol(e,t);if(r)return r;let i=oo(t),a=i.agentId.trim(),o=``,s=!1,c,l,u;if(i.group){let t=e.sessions.groupsGeneration(),n=await e.sessions.groupsLoad();l=e.sessions.groupsGeneration(),u=e.sessions.groupsStatus();let r=t===l&&u===`ready`?n:null,a=r?.find(e=>e.name===i.group);c=r===null?`unavailable`:a?`resolved`:`missing`,o=a?.cwd??``,s=a?.worktree===!0}let d={...i,requestedAgentId:a,groupStatus:c,groupCwd:o,groupWorktree:s,groupCatalogGeneration:l,groupDefaultsStatus:u,catalogLabel:``,startTerminal:!1};if(!i.catalogId)return d;let f=(e=``)=>({...d,agentId:e}),p=e.gateway.snapshot,m=e.agents.state;if(p.phase!==`connected`||!p.client||!m.connected||m.client!==p.client)return f();let h=m.agentsList??await e.agents.ensureList(),g=e.gateway.snapshot,_=e.agents.state;if(g.phase!==`connected`||!g.client||g.client!==p.client||!_.connected||_.client!==g.client||!h||_.agentsList!==h)return f();let v=xe(h.agents),y=v.some(e=>e.id===h.defaultId)?h.defaultId:v[0]?.id,b=y?xo(i,v,y):``,x=f(b);if(!b)return x;let S=await Co(g.client,i.catalogId,b);return S?{...x,...S}:x}function Mm(){return(Mm=e((()=>{he(),G(),Pl(),so()})))()}export{Qo as $,yu as A,Jc as B,Lu as C,Eu as D,Du as E,ou as F,sc as G,fc as H,nu as I,Ws as J,Xs as K,iu as L,cu as M,su as N,Cu as O,au as P,es as Q,Rl as R,rd as S,Pu as T,pc as U,Yc as V,dc as W,zs as X,Us as Y,Bs as Z,pd as _,Xp as a,Go as at,id as b,Lf as c,no as ct,Rf as d,eo as dt,$o as et,Td as f,md as g,yd as h,Dm as i,Po as it,bu as j,xu as k,ep as l,ro as lt,vd as m,Am as n,q as nt,Jp as o,so as ot,Ed as p,Js as q,km as r,Ko as rt,Mf as s,ao as st,Mm as t,Jo as tt,zf as u,$a as ut,fd as v,Fu as w,Uu as x,cd as y,zl as z};