openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 5.07 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Qo as t,Ss as n,li as r,oi as i}from"./_4____________________________.js";import{$m as a,AN as o,EN as s,GN as c,JN as l,JO as u,Qm as d,YO as f,fN as p,fk as m,mb as h,mk as g,pN as _,pb as v,qN as y}from"./_2_____________________________.js";import{I as b,Rt as x,U as S,d as C,g as w,j as T,l as E,m as D,s as O,u as k,v as A,x as j,yt as M}from"./_6____________________.js";import{Et as N,Tt as P}from"./control-ui-boot-new-pHXPNTZp.js";import{M as F,bt as I,j as L,yt as R}from"./control-ui-boot-chat-CqvkfPXD.js";import{n as z,t as B}from"./cloud-worker-stop.runtime-C_o44RQn.js";function V(e){let t;var n=U(),r=n.firstChild.firstChild,i=r.firstChild,a=i.nextSibling,o=r.nextSibling,s=o.nextSibling,c=s.firstChild,u=c.nextSibling,d=u.firstChild,f=d.firstChild,m=f.nextSibling,h=d.nextSibling;return h.firstChild,n.addEventListener(`modal-cancel`,t=>{e.onCancel()||t.preventDefault()}),n.initialFocus=()=>t,n._$owner=x(),C(i,()=>e.title??l(`sessionsView.workerStopTitle`)),a._$$click=()=>e.onCancel(),C(a,T(p,{name:`x`})),C(o,()=>e.description),s._$owner=x(),c._$$click=()=>e.onCancel(),D(()=>e=>t=e,c),C(c,()=>l(`common.cancel`)),u._$$click=()=>e.onConfirm(),C(d,T(p,{name:`stop`}),f),C(d,()=>l(`sessionsView.stopWorkerConfirmAction`),m),C(h,()=>l(`sessionsView.workerStopping`),null),E(()=>({e:e.title??l(`sessionsView.workerStopTitle`),t:l(`common.close`),a:e.pending,o:e.pending,i:e.pending,n:e.pending?`true`:`false`,s:e.pending?`hidden`:`visible`,h:e.pending?`true`:`false`,r:e.pending?`visible`:`hidden`,d:e.pending?`false`:`true`}),({e,t,a:r,o:i,i:o,n:s,s:l,h:f,r:p,d:m},g)=>{e!==g?.e&&w(n,`label`,e),t!==g?.t&&w(a,`aria-label`,t),r!==g?.a&&w(a,`disabled`,r),i!==g?.o&&w(c,`disabled`,i),o!==g?.i&&w(u,`disabled`,o),s!==g?.n&&w(u,`aria-busy`,s),l!==g?.s&&A(d,`visibility`,l),f!==g?.h&&w(d,`aria-hidden`,f),p!==g?.r&&A(h,`visibility`,p),m!==g?.d&&w(h,`aria-hidden`,m)}),n}async function H(e){if(!W){W=!0;try{await h(void 0,({render:t,finish:n})=>{t(()=>{let[t,r]=b(!1),i=!1,a=()=>!i&&(n(),!0),o=M(function*(){if(!i){i=!0,r(!0);try{(yield Promise.resolve().then(e.confirm))===`close`&&n()}finally{i=!1}}});return T(V,{get description(){return e.description},get title(){return e.title},get pending(){return t()},onCancel:a,onConfirm:()=>void o()})})})}finally{W=!1}}}var U,W;function G(){return(G=e((()=>{k(),S(),v(),_(),L(),c(),U=j(`<openclaw-modal-dialog class=session-worker-stop-dialog><section class=session-worker-stop><header class=session-worker-stop__heading><h2></h2><button type=button class=session-worker-stop__close></button></header><p class=session-worker-stop__description></p><openclaw-modal-actions class="exec-approval-actions session-worker-stop__actions"><button type=button class=btn autofocus></button><button type=button class="btn danger session-worker-stop__submit"><span class=session-worker-stop__button-state><!><!></span><span class=session-worker-stop__button-state><span class=session-worker-stop__spinner>`,1),y(F),W=!1,O([`click`])})))()}async function K(e){let t=e.client,i=a(e.row.placement),o=e.reclaimingKey===e.row.key,c=e.row.placement,l=c?.state===`active`&&c.runner?.kind===`device`&&c.runner.status===`offline`;if(!t||o||l||i?.blocksActiveRun&&e.row.hasActiveRun===!0||!i)return;let u=f(e.gatewaySnapshot,i);if(!u.allowed){e.publishError(u.reason);return}let d=e.row.key,p=e.row.sessionId,m=c?.generation,h=c?.state===`active`?c.activeOwnerEpoch:void 0,_=c&&`environmentId`in c?c.environmentId:void 0,v=c?.state===`active`?c.runner?.kind===`device`?`device`:`profile`:e.placementStartup.get(d)?.targetKind,y=v===`profile`?`Cloud`:v===`device`||v===`auto-device`?`Device`:``,b=n(e.row,e.fallbackAgentId);await H({title:r(`sessionsView.workerStop${y}Title`),description:r(`sessionsView.workerStop${y}Description`,{device:e.machineName||r(`sessionsView.workerStopDeviceFallback`)}),confirm:async()=>{if(!e.isCurrent())return e.publishError(r(`sessionsView.actionUnavailable`)),`close`;let i=e.currentGatewaySnapshot(),o=e.currentRow(),c=o?.placement,l=a(c),u=c&&`environmentId`in c?c.environmentId:void 0;if(i.client!==t||!o||!l||o.key!==d||o.sessionId!==p||c?.generation!==m||u!==_||h!==void 0&&(c?.state!==`active`||c.activeOwnerEpoch!==h)||n(o,e.fallbackAgentId)!==b)return e.publishError(r(`sessionsView.actionUnavailable`)),`close`;let f=I({gatewaySnapshot:i,movingKey:null,reclaimingKey:null,row:o});if(f.reclaimDisabledReason)return e.publishError(f.reclaimDisabledReason),`close`;e.onReclaimingChange(d);let v=!1;try{if(await z(t,{key:d,...b?{agentId:b}:{}},e.placementStartup),v=!0,e.isCurrent()){let t=await e.reconcileMutation(b);t.status===`failed`&&e.isCurrent()?e.publishError(t.error):e.isCurrent()&&g({message:r(`sessionsView.workerStopped`),severity:`success`})}return`close`}catch(t){return e.isCurrent()?(e.publishError(t),g({message:s(t),severity:`error`}),v?`close`:`retry`):`close`}finally{e.onReclaimingChange(null)}}})}function q(){return(q=e((()=>{B(),d(),i(),P(),o(),u(),t(),m(),R(),G(),N()})))()}q();export{K as reclaimChatPanePlacement};