import{i as e,n as t}from"./rolldown-runtime-BKYq3fBv.js";import{Fr as n,Nn as r,Xn as i,Xr as a}from"./vendor-primevue-D50rA9nL.js";import{Q as o,Xn as s,fn as c,nn as l,tn as u}from"./vendor-other-BnH5nyVX.js";import{n as d,r as f}from"./vendor-vue-BAQ5VIVR.js";import{dn as p,dt as m,fn as h,ft as g,on as _,sn as v}from"./api-z_dXWY_S.js";import{M as y,O as b,j as x,y as S}from"./PanelTemplate-BUPnglF3.js";import{Ho as C,Uo as w,co as T,so as E}from"./dialogService-Cr3DyAja.js";var D,useReleaseService,O=t((()=>{u(),r(),w(),m(),D=l.create({baseURL:C(),headers:{"Content-Type":`application/json`}}),useReleaseService=()=>{let e=a(!1),t=a(null);n(()=>C(),e=>{D.defaults.baseURL=e});let handleApiError=(e,t,n)=>{if(!l.isAxiosError(e))return e instanceof Error?`${t}: ${e.message}`:`${t}: Unknown error occurred`;let r=e;if(r.response){let{status:e,data:i}=r.response;if(n&&n[e])return n[e];switch(e){case 400:return`Bad request: ${i?.message||`Invalid input`}`;case 401:return`Unauthorized: Authentication required`;case 403:return`Forbidden: ${i?.message||`Access denied`}`;case 404:return`Not found: ${i?.message||`Resource not found`}`;case 500:return`Server error: ${i?.message||`Internal server error`}`;default:return`${t}: ${i?.message||r.message}`}}return`${t}: ${r.message}`},executeApiRequest=async(n,r,i)=>{e.value=!0,t.value=null;try{return(await n()).data}catch(e){return g(e)||(t.value=handleApiError(e,r,i)),null}finally{e.value=!1}},getReleases=async(e,t)=>await executeApiRequest(()=>D.get(`/releases`,{params:e,signal:t}),`Failed to get releases`,{400:`Invalid project or version parameter`});return{isLoading:e,error:t,getReleases}}})),k,A,j=t((()=>{c(),f(),k=o(),r(),_(),E(),x(),p(),S(),O(),A=d(`release`,()=>{let e=a([]),t=a(!1),n=a(null),r=useReleaseService(),o=y(),c=T(),l=i(()=>v?o?.systemStats?.system?.cloud_version??``:o?.systemStats?.system?.comfyui_version??``),u=i(()=>c.get(`Comfy.Locale`)),d=i(()=>c.get(`Comfy.Release.Version`)),f=i(()=>c.get(`Comfy.Release.Status`)),p=i(()=>c.get(`Comfy.Release.Timestamp`)),m=i(()=>c.get(`Comfy.Notification.ShowVersionUpdates`)),g=i(()=>e.value[0]??null),_=i(()=>e.value.slice(0,3)),compareVersions=(e,t)=>(0,k.valid)(e)&&(0,k.valid)(t)?(0,k.compare)(e,t):e===t?0:1,x=i(()=>!!g.value&&compareVersions(g.value.version,l.value||`0.0.0`)>0),S=i(()=>!!g.value&&compareVersions(g.value.version,l.value||`0.0.0`)===0),C=i(()=>{let e=g.value?.attention;return e===`medium`||e===`high`}),w=i(()=>!(!h()||v||!m.value||!x.value||!C.value||d.value===g.value?.version&&[`skipped`,`changelog seen`].includes(f.value))),E=i(()=>{if(!h()||v||!m.value||!x.value)return!1;let{version:e}=g.value;return d.value===e&&f.value===`changelog seen`?!1:C.value?!0:!(d.value===e&&f.value===`skipped`&&p.value&&Date.now()-p.value>=2592e5)}),D=i(()=>!(!h()&&!v||!m.value||!g.value||(0,k.valid)(l.value)&&!S.value||d.value===g.value.version&&f.value===`what's new seen`));async function handleSkipRelease(e){e!==g.value?.version||f.value===`changelog seen`||(await c.set(`Comfy.Release.Version`,e),await c.set(`Comfy.Release.Status`,`skipped`),await c.set(`Comfy.Release.Timestamp`,Date.now()))}async function handleShowChangelog(e){e===g.value?.version&&(await c.set(`Comfy.Release.Version`,e),await c.set(`Comfy.Release.Status`,`changelog seen`),await c.set(`Comfy.Release.Timestamp`,Date.now()))}async function handleWhatsNewSeen(e){e===g.value?.version&&(await c.set(`Comfy.Release.Version`,e),await c.set(`Comfy.Release.Status`,`what's new seen`),await c.set(`Comfy.Release.Timestamp`,Date.now()))}async function fetchReleases(){if(!t.value&&!(!v&&!m.value)&&!o.systemStats?.system?.argv?.includes(`--disable-api-nodes`)){t.value=!0,n.value=null;try{o.systemStats||await s(o.isInitialized);let t=await r.getReleases({project:v?`cloud`:`comfyui`,current_version:l.value,form_factor:o.getFormFactor(),locale:b(u.value)});t===null?r.error.value&&(n.value=r.error.value):e.value=t}catch(e){n.value=e instanceof Error?e.message:`Unknown error occurred`}finally{t.value=!1}}}async function initialize(){await fetchReleases()}return{releases:e,isLoading:t,error:n,recentRelease:g,recentReleases:_,shouldShowToast:w,shouldShowRedDot:E,shouldShowPopup:D,shouldShowUpdateButton:x,handleSkipRelease,handleShowChangelog,handleWhatsNewSeen,fetchReleases,initialize}})}));export{A as n,j as t};
//# sourceMappingURL=releaseStore-C4Y9m3Im.js.map