import{r as e}from"./rolldown-runtime-DIIn1E2Q.js";import"./vendor-primevue-DYf-ECwY.js";import"./vendor-firebase-yTFzdAQf.js";import"./vendor-other-D1_ndkJp.js";import{t}from"./types-Bc3W4AWd.js";import{n}from"./useFeatureFlags-CHGLLgJ4.js";import{r}from"./api-CDBLxNna.js";import"./vendor-markdown-th9BvURy.js";import"./colorUtil-vwiX_KSk.js";import"./i18n-Dg3QvWTL.js";import"./vendor-reka-ui-Dfvl2gA8.js";import"./Button-BOHBs1GV.js";import{Nr as i,_n as a}from"./dialogService-dIcYqMOB.js";import"./systemStatsStore-4wRyVqfZ.js";import"./userStore-Ctrt23xJ.js";import"./useErrorHandling-BMNIAgkQ.js";import"./vendor-tiptap-F_4ky0lj.js";import"./Popover-cEFhN-pL.js";import"./markdownRendererUtil-DO0bU-vH.js";import"./useExternalLink-Dl87dnPK.js";const useSessionCookie=()=>{let createSession=async()=>{if(!t)return;let{flags:e}=n();try{let t=i(),n;if(e.teamWorkspacesEnabled){let e=await t.getIdToken();if(!e){console.warn(`Failed to create session cookie:`,`No Firebase token available for session creation`);return}n={Authorization:`Bearer ${e}`}}else{let e=await t.getAuthHeader();if(!e){console.warn(`Failed to create session cookie:`,`No auth header available for session creation`);return}n=e}let a=await fetch(r.apiURL(`/auth/session`),{method:`POST`,credentials:`include`,headers:{...n,"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(t)try{let e=await fetch(r.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}};a().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-CuJMf9J1.js.map