import{n as e}from"./rolldown-runtime-DkW27tQK.js";import{er as t}from"./control-ui-foundation-CeFMP1Ly.js";import{dl as n,ml as r}from"./control-ui-core-pH6nakZ-.js";import{G as i,J as a,W as o,Z as s,at as c,rt as l}from"./lit-runtime-BEtFSUCp.js";import{A as u,C as d,E as f,M as p,T as m,j as h,k as g,w as _}from"./control-ui-core-DGVkFhVB.js";import{Ft as v,Ht as y,Lt as b,Rt as x,qt as S}from"./control-ui-core-Br5DB0Zj.js";import{Ns as C,Ps as w}from"./control-ui-boot-Cdpgu1Gm.js";import{n as T,t as E}from"./update-confirmation-BNyRSVb0.js";function D(){return(D=e((()=>{})))()}var O;function k(){return(k=e((()=>{o(),s(),p(),T(),m(),y(),r(),w(),x(),v(),O=class extends n{constructor(...e){super(...e),this.compact=!1,this.updateAvailable=null,this.updateSchedule=null,this.heldUpdateCampaignId=null,this.updateBusy=!1,this.statusBanner=null,this.watchUpdateProgress=void 0,this.canUpdate=!1,this.canHoldUpdate=!1,this.onUpdate=()=>void 0,this.refreshRequired=!1,this.onRefresh=()=>void 0,this.onHoldUpdate=async()=>!1,this.onReviewUpdate=()=>void 0,this.onDismiss=void 0,this.recoverNativeDecline=!0,this.holdingCampaignId=null,this.nativeUpdateAvailable=h(),this.nativeUpdateDeclined=!1,this.countdownPolling=new C(this,1e3,()=>this.requestUpdate(),!1),this.handleNativeUpdateAvailabilityChanged=()=>{this.nativeUpdateDeclined=!1,this.nativeUpdateAvailable=h()},this.handleNativeUpdateDeclined=()=>{this.nativeUpdateDeclined=!0,this.nativeUpdateAvailable=!1,(this.updateAvailable||this.updateSchedule?.campaign)&&!this.updateBusy&&this.canUpdate&&!this.refreshRequired&&this.onUpdate()},this.startUpdate=()=>{let e=this.updateSchedule?.campaign;this.updateBusy||e?.state===`applying`||!this.canUpdate||E({startGatewayUpdate:()=>this.onUpdate(),...this.watchUpdateProgress?{watchUpdateProgress:this.watchUpdateProgress}:{},updateAvailable:this.updateAvailable,updateSchedule:this.updateSchedule,viaNativeApp:!this.nativeUpdateDeclined&&h()})},this.holdUpdate=async e=>{this.holdingCampaignId=e,await this.onHoldUpdate(),this.holdingCampaignId=null}}connectedCallback(){super.connectedCallback(),this.nativeUpdateAvailable=!this.nativeUpdateDeclined&&h(),window.addEventListener(g,this.handleNativeUpdateAvailabilityChanged),this.recoverNativeDecline&&window.addEventListener(u,this.handleNativeUpdateDeclined)}disconnectedCallback(){window.removeEventListener(g,this.handleNativeUpdateAvailabilityChanged),this.recoverNativeDecline&&window.removeEventListener(u,this.handleNativeUpdateDeclined),super.disconnectedCallback()}updated(e){if(super.updated(e),e.has(`updateSchedule`)){let e=this.updateSchedule?.campaign?.state;e===`countdown`||e===`waiting-for-idle`?this.countdownPolling.start():this.countdownPolling.stop()}}renderStatus(){let e=this.statusBanner;return e?a`
`:i}hasAvailableUpdate(){let e=this.updateAvailable,t=this.updateSchedule?.target;return e!==null&&e.latestVersion!==e.currentVersion||e?.commitsBehind!==void 0&&e.commitsBehind>0||t?.kind===`git`&&t.commitsBehind>0}compactSummary(){if(this.refreshRequired)return{detail:S(`chat.sidebar.serverUpdatedRefresh`),icon:b.refresh,severity:`warning`,title:S(`chat.sidebar.serverUpdatedTitle`)};let e=this.updateSchedule?.campaign,t=this.updateBusy||e?.state===`applying`,n=this.statusBanner;if(!e&&!t&&!n&&!this.hasAvailableUpdate())return null;let r=_(this.updateSchedule,this.updateAvailable),i=d(this.updateSchedule),a=n&&n.tone!==`info`,o=n?.text.trim()||S(`updates.sidebar.blockedSummary`);return{detail:a?e?.state===`waiting-for-idle`&&r?S(`updates.sidebar.blockedWaiting`,{target:r}):r?`${r} · ${o}`:o:i&&r?S(`updates.sidebar.campaignTarget`,{status:i,target:r}):i??r??n?.text??S(`updates.sidebar.availableSummary`),icon:n?b.alertTriangle:t?b.refresh:b.download,critical:!!a,severity:n?.tone===`danger`?`error`:`warning`,title:S(a?`updates.sidebar.blockedTitle`:t?`updates.sidebar.updating`:`updates.sidebar.availableTitle`)}}renderCompact(){let e=this.compactSummary();return e?a``:i}renderCompactDetails(){let e=this.statusBanner;if(!e)return this.renderCard();let t=this.updateSchedule?.campaign,n=t?.holdUntilMs!==void 0&&t.holdUntilMs>Date.now(),r=!!(t&&t.state!==`applying`&&this.canUpdate&&this.canHoldUpdate&&!this.updateBusy&&!n&&this.heldUpdateCampaignId!==t.id);return a``}renderCard(){if(this.refreshRequired)return a` `;let e=this.updateAvailable,t=this.updateSchedule?.campaign,n=this.updateBusy||t?.state===`applying`,r=this.statusBanner;if(!t&&!n&&!r&&!this.hasAvailableUpdate())return i;let o=this.nativeUpdateAvailable?S(`chat.sidebar.updateMacAndGateway`):S(`chat.sidebar.updateGateway`),s=e?.channel===`beta`?` (beta)`:``,c=d(this.updateSchedule),l=_(this.updateSchedule,e),u=c?l?S(`updates.sidebar.campaignTarget`,{status:c,target:l}):c:n?S(`updates.sidebar.updating`):l?`${o} · ${l}${s}`:o,p=t?.state===`countdown`||t?.state===`waiting-for-idle`,m=t?.holdUntilMs!==void 0&&t.holdUntilMs>Date.now(),h=!!(t&&t.state!==`applying`&&this.canUpdate&&this.canHoldUpdate&&!n&&!m&&this.heldUpdateCampaignId!==t.id),g=f(e,this.updateSchedule,this.updateBusy),v=a``;return a` `}render(){return this.compact?this.renderCompact():this.renderCard()}},t([c({attribute:!1})],O.prototype,`compact`,void 0),t([c({attribute:!1})],O.prototype,`updateAvailable`,void 0),t([c({attribute:!1})],O.prototype,`updateSchedule`,void 0),t([c({attribute:!1})],O.prototype,`heldUpdateCampaignId`,void 0),t([c({attribute:!1})],O.prototype,`updateBusy`,void 0),t([c({attribute:!1})],O.prototype,`statusBanner`,void 0),t([c({attribute:!1})],O.prototype,`watchUpdateProgress`,void 0),t([c({attribute:!1})],O.prototype,`canUpdate`,void 0),t([c({attribute:!1})],O.prototype,`canHoldUpdate`,void 0),t([c({attribute:!1})],O.prototype,`onUpdate`,void 0),t([c({attribute:!1})],O.prototype,`refreshRequired`,void 0),t([c({attribute:!1})],O.prototype,`onRefresh`,void 0),t([c({attribute:!1})],O.prototype,`onHoldUpdate`,void 0),t([c({attribute:!1})],O.prototype,`onReviewUpdate`,void 0),t([c({attribute:!1})],O.prototype,`onDismiss`,void 0),t([c({attribute:!1})],O.prototype,`recoverNativeDecline`,void 0),t([l()],O.prototype,`holdingCampaignId`,void 0),t([l()],O.prototype,`nativeUpdateAvailable`,void 0),customElements.get(`openclaw-sidebar-update-card`)||customElements.define(`openclaw-sidebar-update-card`,O)})))()}export{D as n,k as t}; //# sourceMappingURL=sidebar-update-card-CQqrU8d1.js.map