import{$ as e,A as t,B as n,C as r,E as i,F as a,G as o,I as s,K as c,L as l,M as u,N as d,P as f,Q as p,Z as m,ct as h,f as g,ft as _,j as v,k as y,nt as b,pt as x,r as S,st as C,tt as w,y as T}from"../chunks/BBI__kVO.js";import"../chunks/xihTtKlq.js";import{d as E,t as D,u as O}from"../chunks/i-u-oQAW.js";var k=d(`<a target="_blank" rel="noopener noreferrer" class="update-banner-link svelte-1u6ojbd">Download</a>`),A=d(`<div class="update-banner svelte-1u6ojbd" role="status"><span class="update-banner-icon svelte-1u6ojbd" aria-hidden="true"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg></span> <span class="update-banner-text svelte-1u6ojbd">A new version of OpenPalm is available — <strong> </strong> <!></span> <!> <button type="button" class="update-banner-dismiss svelte-1u6ojbd" aria-label="Dismiss">×</button></div>`);function j(r,i){h(i,!0);let s=b(null),c=b(!1);function d(e){return`openpalm.updateBanner.dismissed.${e}`}S(async()=>{try{let e=await fetch(`/api/electron/update-status`);if(!e.ok)return;let t=await e.json();if(!t.inElectron||!t.updateAvailable||!t.latestVersion||typeof localStorage<`u`&&localStorage.getItem(d(t.latestVersion)))return;w(s,t,!0)}catch{}});function f(){n(s)?.latestVersion&&typeof localStorage<`u`&&localStorage.setItem(d(n(s).latestVersion),`1`),w(c,!0)}var x=u(),T=p(x),E=r=>{var i=A(),c=e(m(i),2),u=e(m(c)),d=m(u);_(u);var p=e(u,2),h=e=>{var r=a();o(()=>t(r,`(you have v${n(s).currentVersion??``})`)),v(e,r)};y(p,e=>{n(s).currentVersion&&e(h)}),_(c);var b=e(c,2),x=e=>{var t=k();o(()=>g(t,`href`,n(s).latestUrl)),v(e,t)};y(b,e=>{n(s).latestUrl&&e(x)});var S=e(b,2);_(i),o(()=>t(d,`v${n(s).latestVersion??``}`)),l(`click`,S,f),v(r,i)};y(T,e=>{n(s)&&!n(c)&&e(E)}),v(r,x),C()}s([`click`]);var M=f(`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>`),N=f(`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></svg>`),P=f(`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg>`),F=d(`<div><span class="toast-icon svelte-c82lj3" aria-hidden="true"><!> <span class="sr-only svelte-c82lj3"> </span></span> <span class="toast-message svelte-c82lj3"> </span> <button type="button" class="toast-dismiss svelte-c82lj3" aria-label="Dismiss">&times;</button></div>`),I=d(`<div class="toast-stack svelte-c82lj3" aria-live="polite"></div>`);function L(r,a){h(a,!0);let s=null;c(()=>{let e=O.errorMessage;e&&(s=E.push(`error`,e,{replaceId:s??void 0}),O.errorMessage=``)});function d(e){E.dismiss(e.id),e.id===s&&(s=null)}function f(e){return e.kind===`success`?`Success`:e.kind===`error`?`Error`:`Notice`}var b=u(),x=p(b),S=r=>{var a=I();i(a,21,()=>E.toasts,e=>e.id,(r,i)=>{var a=F(),s=m(a),c=m(s),u=e=>{v(e,M())},p=e=>{v(e,N())},h=e=>{v(e,P())};y(c,e=>{n(i).kind===`success`?e(u):n(i).kind===`error`?e(p,1):e(h,-1)});var b=e(c,2),x=m(b);_(b),_(s);var S=e(s,2),C=m(S,!0);_(S);var w=e(S,2);_(a),o(e=>{T(a,1,`toast toast-${n(i).kind??``}`,`svelte-c82lj3`),g(a,`role`,n(i).kind===`error`?`alert`:`status`),g(a,`aria-live`,n(i).kind===`error`?`assertive`:`polite`),t(x,`${e??``}:`),t(C,n(i).message)},[()=>f(n(i))]),l(`click`,w,()=>d(n(i))),v(r,a)}),_(a),v(r,a)};y(x,e=>{E.toasts.length>0&&e(S)}),v(r,b),C()}s([`click`]);var R=d(`<!> <!> <!>`,1);function z(t,n){h(n,!0),S(()=>{D.init()});var i=R(),a=p(i);j(a,{});var o=e(a,2);r(o,()=>n.children??x),L(e(o,2),{}),v(t,i),C()}export{z as component};