const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-js-CEKCkrft.js","assets/vendor-misc-D1uXP2P6.js","assets/rolldown-runtime-B1FJdls4.js","assets/vendor-dnd-C1cICjTT.js","assets/vendor-markdown-Db1-9wH7.js","assets/dist-js-Dwx5A-d2.js"])))=>i.map(i=>d[i]);
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{m as t}from"./vendor-dnd-C1cICjTT.js";import{s as n}from"./vendor-markdown-Db1-9wH7.js";import{t as r}from"./preload-helper-Bf_JiD2A.js";var i=e(t(),1),a=n();function o(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function s(){let e=(0,i.useRef)(null),[t,n]=(0,i.useState)(null),[s,c]=(0,i.useState)(!1),[l,u]=(0,i.useState)(null),[d,f]=(0,i.useState)(null),[p,m]=(0,i.useState)(!1);(0,i.useEffect)(()=>{if(!o())return;let t=!1;return r(async()=>{let{check:e}=await import(`./dist-js-CEKCkrft.js`);return{check:e}},__vite__mapDeps([0,1,2,3,4])).then(({check:e})=>e({timeout:1e4})).then(r=>{t||!r||(e.current=r,n(r.version))}).catch(e=>{console.info(`[desktop-updater] update check unavailable`,e)}),()=>{t=!0,e.current?.close().catch(()=>void 0),e.current=null}},[]);let h=(0,i.useCallback)(async()=>{let t=e.current;if(!t)return;c(!0),f(null);let n=0,i=null;try{await t.downloadAndInstall(e=>{e.event===`Started`?(i=e.data.contentLength??null,n=0,u(i?0:null)):e.event===`Progress`?(n+=e.data.chunkLength,u(i?Math.min(100,Math.round(n/i*100)):null)):e.event===`Finished`&&u(100)});let{relaunch:e}=await r(async()=>{let{relaunch:e}=await import(`./dist-js-Dwx5A-d2.js`);return{relaunch:e}},__vite__mapDeps([5,1,2,3,4]));await e()}catch(e){c(!1),f(e instanceof Error?e.message:String(e))}},[]);return!t||p?null:(0,a.jsxs)(`div`,{className:`flex shrink-0 items-center justify-center gap-3 border-b border-cyan-500/30 bg-cyan-950/40 px-4 py-2 font-mono text-xs text-cyan-200`,children:[(0,a.jsx)(`span`,{"aria-hidden":`true`,children:`⬆`}),(0,a.jsxs)(`span`,{children:[`Desktop app `,t,` is ready`,s&&(l===null?` — installing…`:` — ${l}%`)]}),d?(0,a.jsxs)(`span`,{className:`text-red-300`,children:[`Update failed: `,d]}):null,(0,a.jsx)(`button`,{type:`button`,disabled:s,onClick:()=>void h(),className:`rounded-md border border-cyan-500/40 bg-cyan-900/40 px-3 py-1 font-semibold text-cyan-100 transition-colors hover:bg-cyan-500/30 disabled:cursor-wait disabled:opacity-60`,children:s?`Installing`:d?`Retry`:`Install & Relaunch`}),s?null:(0,a.jsx)(`button`,{type:`button`,onClick:()=>m(!0),className:`ml-1 text-terminal-muted transition-colors hover:text-terminal-text`,title:`Dismiss`,children:`✕`})]})}export{s as DesktopUpdateBanner};