import"./rolldown-runtime-DIIn1E2Q.js";import"./vendor-primevue-BDZ_jj__.js";import"./vendor-firebase-D7u00oy9.js";import"./vendor-other-CiPV8GBG.js";import{t as e}from"./types-DPJvCrdo.js";import{n as t}from"./useFeatureFlags-CeS8LuDc.js";import{r as n}from"./api-Cw7jP9TY.js";import"./vendor-markdown-Da9QPS2x.js";import"./colorUtil-Bsa2N3Sq.js";import"./i18n-CF_88JEG.js";import"./vendor-reka-ui-B53kLmAc.js";import"./Button-Ca3rDegY.js";import{Vi as r,ur as i}from"./dialogService-CfgsFapJ.js";import"./formatUtil-CeKPWstn.js";import"./dialogStore-G2juoay4.js";import"./userStore-Czt6jT20.js";import"./useErrorHandling-DXaBpHI1.js";import"./extensionStore-MnMxnUwx.js";import"./useExternalLink-BItqlDxr.js";import"./vendor-tiptap-Bk1lVUYZ.js";import"./markdownRendererUtil-_EbNpPBW.js";import"./Popover-CXKWNrM3.js";import"./electronDownloadStore-DudKQmD7.js";var useSessionCookie=()=>{let createSession=async()=>{if(!e)return;let{flags:i}=t();try{let e=r(),t;if(i.teamWorkspacesEnabled){let n=await e.getIdToken();if(!n){console.warn(`Failed to create session cookie:`,`No Firebase token available for session creation`);return}t={Authorization:`Bearer ${n}`}}else{let n=await e.getAuthHeader();if(!n){console.warn(`Failed to create session cookie:`,`No auth header available for session creation`);return}t=n}let a=await fetch(n.apiURL(`/auth/session`),{method:`POST`,credentials:`include`,headers:{...t,"Content-Type":`application/json`}});if(!a.ok){let e=await a.json().catch(()=>({}));console.warn(`Failed to create session cookie:`,e.message||a.statusText)}}catch(e){console.warn(`Failed to create session cookie:`,e)}},deleteSession=async()=>{if(e)try{let e=await fetch(n.apiURL(`/auth/session`),{method:`DELETE`,credentials:`include`});if(!e.ok){let t=await e.json().catch(()=>({}));console.warn(`Failed to delete session cookie:`,t.message||e.statusText)}}catch(e){console.warn(`Failed to delete session cookie:`,e)}};return{createSession,deleteSession}};i().registerExtension({name:`Comfy.Cloud.SessionCookie`,onAuthUserResolved:async()=>{let{createSession:e}=useSessionCookie();await e()},onAuthTokenRefreshed:async()=>{let{createSession:e}=useSessionCookie();await e()},onAuthUserLogout:async()=>{let{deleteSession:e}=useSessionCookie();await e()}});
//# sourceMappingURL=cloudSessionCookie-DYe4Mu-D.js.map