import{i as e,n as t}from"./rolldown-runtime-ConPGZeh.js";import{hn as n,i as r,mn as i,r as a}from"./api-DvJuMrZn.js";import{i as o,n as s}from"./remoteConfig-BiMFcSmW.js";import{To as c,mi as l,pi as u,wo as d}from"./dialogService-DIdX_hbW.js";var useSessionCookie,f=t((()=>{i(),s(),r(),d(),useSessionCookie=()=>{let createSession=async()=>{if(n)try{let e=c(),t;if(o.value.team_workspaces_enabled){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 n=await fetch(a.apiURL(`/auth/session`),{method:`POST`,credentials:`include`,headers:{...t,"Content-Type":`application/json`}});if(!n.ok){let e=await n.json().catch(()=>({}));console.warn(`Failed to create session cookie:`,e.message||n.statusText)}}catch(e){console.warn(`Failed to create session cookie:`,e)}},deleteSession=async()=>{if(n)try{let e=await fetch(a.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}}}));t((()=>{f(),u(),l().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-6vsfXNqt.js.map