import{Channel as e,Resource as t,invoke as n}from"./core-SwWLTXZB.js";var r=class extends t{constructor(e){super(e.rid),this.available=!0,this.currentVersion=e.currentVersion,this.version=e.version,this.date=e.date,this.body=e.body,this.rawJson=e.rawJson}async download(r,i){a(i);let o=new e;r&&(o.onmessage=r);let s=await n(`plugin:updater|download`,{onEvent:o,rid:this.rid,...i});this.downloadedBytes=new t(s)}async install(){if(!this.downloadedBytes)throw Error(`Update.install called before Update.download`);await n(`plugin:updater|install`,{updateRid:this.rid,bytesRid:this.downloadedBytes.rid}),this.downloadedBytes=void 0}async downloadAndInstall(t,r){a(r);let i=new e;t&&(i.onmessage=t),await n(`plugin:updater|download_and_install`,{onEvent:i,rid:this.rid,...r})}async close(){await this.downloadedBytes?.close(),await super.close()}};async function i(e){a(e);let t=await n(`plugin:updater|check`,{...e});return t?new r(t):null}function a(e){e?.headers&&(e.headers=Array.from(new Headers(e.headers).entries()))}export{r as Update,i as check};