openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 3.85 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{v as t,y as n}from"./_4____________________________.js";import{AN as r,EN as i,GN as a,JN as o,X_ as s,Y_ as c,et as l,qN as u,tt as d}from"./_2_____________________________.js";import{d as f,f as p,g as m,l as h,m as g,o as _,p as v,s as y,u as b,x}from"./_6____________________.js";import{n as S,r as C}from"./sidebar-attention-focus-Cd2JD8ca.js";function w(e){switch(e.phase){case`guidance`:return o(e.reason===`role`?`connection.scopeUpgrade.roleGuidance`:`connection.scopeUpgrade.guidance`);case`available`:return o(`connection.scopeUpgrade.limited`);case`requesting`:return o(`connection.scopeUpgrade.requesting`);case`pending`:return o(`connection.scopeUpgrade.pending`,{command:`openclaw devices approve ${e.requestId}`});case`rejected`:return o(e.expired?`connection.scopeUpgrade.expired`:`connection.scopeUpgrade.rejected`);case`error`:return o(`connection.scopeUpgrade.error`,{error:e.message})}return e}function T(e){let t=()=>e.state.phase===`error`?e.state.retryable:e.state.phase===`pending`||e.state.phase===`rejected`,n=()=>e.inbox?`sidebar-issues-panel__action sidebar-issues-panel__action--primary`:`btn primary`;return p(()=>p(()=>e.state.phase===`available`||e.state.phase===`requesting`)()?(()=>{var t=E();t._$$click=()=>e.onRequest();var r=C();return(typeof r==`function`||Array.isArray(r))&&g(()=>r,t),f(t,()=>o(e.state.phase===`available`?`connection.scopeUpgrade.request`:`connection.scopeUpgrade.requestingAction`)),h(()=>({e:v(n()),t:e.state.phase===`requesting`}),({e,t:n},r)=>{_(t,e,r?.e),n!==r?.t&&m(t,`disabled`,n)}),t})():p(()=>!!(t()||e.state.phase===`error`))()?[p(()=>p(()=>!!t())()?(()=>{var t=E();t._$$click=()=>e.onRetry();var r=C();return(typeof r==`function`||Array.isArray(r))&&g(()=>r,t),f(t,()=>o(`connection.scopeUpgrade.retry`)),h(()=>v(n()),(e,n)=>{_(t,e,n)}),t})():null),(()=>{var t=E();t._$$click=()=>e.onCancel();var n=C();return(typeof n==`function`||Array.isArray(n))&&g(()=>n,t),f(t,()=>o(`connection.scopeUpgrade.cancel`)),h(()=>v(e.inbox?`sidebar-issues-panel__action`:`btn`),(e,n)=>{_(t,e,n)}),t})()]:null)}var E;function D(){return(D=e((()=>{b(),c(),a(),S(),E=x(`<button type=button>`),u(s),y([`click`])})))()}var O;function k(){return(k=e((()=>{n(),r(),l(),O=class{constructor(e,t){this.onChange=t,this.operation=null,this.value={phase:`hidden`},this.current=e,this.sync(e)}get state(){return this.value}sync(e){this.current=e;let t=e.client,n=d(e);!t||n.phase!==`available`?(this.retireOperation(),this.setState(n)):(this.operation&&this.operation.client!==t&&(this.retireOperation(),this.setState({phase:`available`})),(this.value.phase===`hidden`||this.value.phase===`guidance`)&&this.setState({phase:`available`}))}request(){this.start(!1)}retry(){this.start(!0)}cancel(){this.retireOperation(),this.setState(d(this.current))}dispose(){this.retireOperation()}start(e){let n=this.current.client;if(!n||d(this.current).phase!==`available`)return;if(this.operation){if(!e)return;this.retireOperation()}let r={client:n};this.operation=r,this.setState({phase:`requesting`}),n.requestScopeUpgrade({onPending:e=>{this.isCurrent(r)&&this.setState({phase:`pending`,requestId:e})}}).then(e=>{this.isCurrent(r)&&e.status!==`approved`&&this.setState({phase:`rejected`,requestId:e.requestId,expired:e.status===`expired`})}).catch(e=>{!this.isCurrent(r)||e instanceof Error&&e.name===`AbortError`||this.setState({phase:`error`,message:i(e),retryable:!(e instanceof t)||e.retryable})}).finally(()=>{this.isCurrent(r)&&(this.operation=null)})}isCurrent(e){return this.operation===e&&this.current.client===e.client}retireOperation(){let e=this.operation;this.operation=null,e?.client.cancelScopeUpgrade()}setState(e){JSON.stringify(this.value)!==JSON.stringify(e)&&(this.value=e,this.onChange())}}})))()}export{w as a,D as i,k as n,T as r,O as t};