import{r as e}from"./rolldown-runtime-DCMCV6zW.js";import"./vendor-primevue-DsBxnwSO.js";import"./vendor-firebase-CdLSXhbt.js";import"./vendor-other-C_YjAAj3.js";import{t}from"./types-BW--Ya-K.js";import{t as n}from"./useFeatureFlags-Bfb3fghV.js";import{r}from"./api-Ckh8-1rW.js";import"./colorUtil-DCPbkdH3.js";import"./i18n-C2nvaQjh.js";import"./vendor-reka-ui-djAAohzU.js";import"./Button-CJj3KtkO.js";import{Kt as i,ir as a}from"./dialogService-Daa_oID7.js";import"./systemStatsStore-CSnXy46l.js";import"./useErrorHandling-BfFOVBcK.js";import"./dialogStore-CBXn_TDV.js";import"./useCopyToClipboard-DcMopO23.js";import"./vendor-tiptap-CjhX_1DY.js";import"./vendor-markdown-CyF8uRn7.js";import"./markdownRendererUtil-DU6rKHAL.js";import"./useExternalLink-C8tDmXU8.js";const useSessionCookie=()=>{let createSession=async()=>{if(!t)return;let{flags:e}=n();try{let t=a(),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 i=await fetch(r.apiURL(`/auth/session`),{method:`POST`,credentials:`include`,headers:{...n,"Content-Type":`application/json`}});if(!i.ok){let e=await i.json().catch(()=>({}));console.warn(`Failed to create session cookie:`,e.message||i.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}};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-BCaEnObA.js.map