openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
35 lines • 3.63 kB
JavaScript
import{n as e}from"./rolldown-runtime-DkW27tQK.js";import{wr as t}from"./control-ui-foundation-Cydpkyqa.js";import{Sc as n,Y as r,et as i,yc as a}from"./control-ui-core-Rwzhj6nO.js";import{$ as o,K as s,X as c,at as l,nt as u,q as d,st as f}from"./lit-runtime-CV_MH99K.js";import{Rt as p,Yt as m,en as h}from"./control-ui-core-vvcQQV2m.js";import{Jt as g,Qt as _,Xt as v,Yt as y,Zt as b,en as x}from"./control-ui-boot-chat-_QSl8fbH.js";import{$i as S}from"./control-ui-boot-shared-CXVvK2AW.js";function C(e){let t=e.queue.filter(t=>t.id!==e.activeId);return t.length===0?d:c`
<div class="exec-approval-list" aria-label=${h(`execApproval.otherPending`)}>
<div class="exec-approval-list__heading">${h(`execApproval.otherPending`)}</div>
${t.map(t=>{let n=v(t.request.command),r=t.request.agentId?.trim()||`—`;return c`
<button
class="exec-approval-list__item"
type="button"
aria-label=${h(`execApproval.reviewRequest`,{agent:r,command:n})}
@click=${()=>e.onSelect(t.id)}
>
<span class="exec-approval-list__agent">${r}</span>
<span class="exec-approval-list__command mono">${n}</span>
<openclaw-approval-countdown
class="exec-approval-list__expiry"
aria-hidden="true"
.expiresAtMs=${t.expiresAtMs}
.compact=${!0}
></openclaw-approval-countdown>
</button>
`})}
</div>
`}function w(e){return e.composedPath().some(e=>e instanceof Element&&e.closest(`input, textarea, [contenteditable]:not([contenteditable='false'])`)!==null)}function T(e){return w(e)?null:i(r.approveAlways,e)?`allow-always`:i(r.modifiedEnter,e)?`allow-once`:i(r.denyApproval,e)?`deny`:null}var E;function D(){return(D=e((()=>{s(),o(),m(),S(),n(),b(),p(),E=class extends a{constructor(...e){super(...e),this.selectedApprovalId=null,this.explicitlyOpen=!1}show(){this.props?.queue.length&&(this.explicitlyOpen=!0,this.updateComplete.then(()=>this.dialog?.show()))}get dialogOpen(){return this.explicitlyOpen&&(this.props?.queue.length??0)>0}handleKeydown(e,t){if(e.defaultPrevented||e.repeat||this.props?.busy||!this.props?.canGrant)return;let n=T(e);!n||!x(t).includes(n)||(e.preventDefault(),this.props?.onDecision(t.id,n))}willUpdate(e){if(e.get(`props`)?.queue.length&&!this.props?.queue.length){this.explicitlyOpen=!1,this.selectedApprovalId=null;return}let t=this.props?.queue??[];t.some(e=>e.id===this.selectedApprovalId)||(this.selectedApprovalId=t.at(0)?.id??null)}render(){let e=this.props,t=e?.queue??[],n=t.find(e=>e.id===this.selectedApprovalId)??t.at(0);return!e||!this.explicitlyOpen||!n?d:c`
<openclaw-modal-dialog
label=${y(n)}
description=${g(n.expiresAtMs,Date.now())}
@keydown=${e=>this.handleKeydown(e,n)}
@modal-cancel=${t=>{if(e.busy){t.preventDefault();return}this.explicitlyOpen=!1}}
>
<div class="exec-approval-modal-stack">
${_({approval:n,busy:e.busy,canGrant:e.canGrant,error:e.errors.get(n.id)??null,variant:`modal`,queueCount:t.length,onDecision:e.onDecision})}
${C({queue:t,activeId:n.id,onSelect:e=>{this.selectedApprovalId=e}})}
</div>
</openclaw-modal-dialog>
`}},t([f({attribute:!1})],E.prototype,`props`,void 0),t([u(`openclaw-modal-dialog`)],E.prototype,`dialog`,void 0),t([l()],E.prototype,`selectedApprovalId`,void 0),t([l()],E.prototype,`explicitlyOpen`,void 0),customElements.get(`openclaw-exec-approval`)||customElements.define(`openclaw-exec-approval`,E)})))()}D();
//# sourceMappingURL=exec-approval-Bp0d8ZwT.js.map