35 lines
3.5 KiB
JavaScript
35 lines
3.5 KiB
JavaScript
import{n as e}from"./rolldown-runtime-DkW27tQK.js";import{er as t}from"./control-ui-foundation-CeFMP1Ly.js";import{W as n,Y as r,dl as i,ml as a}from"./control-ui-core-pH6nakZ-.js";import{G as o,J as s,W as c,Z as l,at as u,et as d,rt as f}from"./lit-runtime-BEtFSUCp.js";import{Ht as p,Nt as m,qt as h}from"./control-ui-core-Br5DB0Zj.js";import{Gr as g,Jr as _,Kr as v,Qr as y,Yr as b,Zr as x,qr as S}from"./control-ui-boot-Cdpgu1Gm.js";function C(e){let t=e.queue.filter(t=>t.id!==e.activeId);return t.length===0?o:s`
|
|
<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=S(t.request.command),r=t.request.agentId?.trim()||`—`;return s`
|
|
<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:r(n.approveAlways,e)?`allow-always`:r(n.modifiedEnter,e)?`allow-once`:r(n.denyApproval,e)?`deny`:null}var E;function D(){return(D=e((()=>{c(),l(),p(),y(),a(),_(),m(),E=class extends i{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?o:s`
|
|
<openclaw-modal-dialog
|
|
label=${v(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">
|
|
${b({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([u({attribute:!1})],E.prototype,`props`,void 0),t([d(`openclaw-modal-dialog`)],E.prototype,`dialog`,void 0),t([f()],E.prototype,`selectedApprovalId`,void 0),t([f()],E.prototype,`explicitlyOpen`,void 0),customElements.get(`openclaw-exec-approval`)||customElements.define(`openclaw-exec-approval`,E)})))()}D();
|
|
//# sourceMappingURL=exec-approval-BnwUQx-C.js.map
|