{"version":3,"file":"NotificationsLoader.1pXbGXFu.mjs","names":["useRef","useState","GCS_APP_URL","GCS_APP_ORIGIN","TOKEN_FUNCTION_URL","useRef","useState"],"sources":["https:/framerusercontent.com/modules/otUVVSHA4nn6jxx6KYAb/sDlqIiq3xhBRtz6e10h7/CalendarLoader.js","https:/framerusercontent.com/modules/JmRf0kgpCknhCgw8sAD2/rnw9woZeaBlAdxQdDoan/NotificationsLoader.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect,useRef}from\"react\";// Import authentication handling directly from this file instead of importing from a module\n// to avoid path resolution issues in Framer\n// Configuration\nconst GCS_APP_URL=\"https://storage.googleapis.com/framer-portal-studio-framer/calendar-booking.html\";const GCS_APP_ORIGIN=\"https://storage.googleapis.com\";const TOKEN_FUNCTION_URL=\"https://us-central1-studio-framer.cloudfunctions.net/get-outseta-token\";export function CalendarLoader(props){const{width,height:initialHeight}=props;const iframeRef=useRef(null);const[iframeSrc,setIframeSrc]=useState(\"\");const[dynamicHeight,setDynamicHeight]=useState(undefined);// Track if we've sent a non-authenticated message to avoid timing issues\nconst hasNotifiedNonAuth=useRef(false);useEffect(()=>{// Reset on mount\nhasNotifiedNonAuth.current=false;// Add timestamp to prevent caching\nsetIframeSrc(`${GCS_APP_URL}?v=${new Date().getTime()}`);const handleMessageFromIframe=async event=>{// Handle height resize messages from the iframe\nif(event.data&&event.data.type===\"framer:resize\"&&typeof event.data.height===\"number\"){// Set the iframe height based on content\nsetDynamicHeight(event.data.height);return;}// Handle authentication messages directly in this file\nif(event.origin!==GCS_APP_ORIGIN){return;}if(event.data&&(event.data.type===\"outseta:ready_for_token\"||event.data===\"outseta:getAuthToken\")){const targetIframeWindow=iframeRef.current?.contentWindow;if(!targetIframeWindow){return;}if(!window.Outseta){targetIframeWindow.postMessage({type:\"outseta:authToken\",token:null,error:\"Outseta SDK not found.\"},GCS_APP_ORIGIN);hasNotifiedNonAuth.current=true;return;}try{const user=await window.Outseta.getUser();if(!user||!user.Email){// Send null token WITHOUT error for non-logged-in users\ntargetIframeWindow.postMessage({type:\"outseta:authToken\",token:null,error:null},GCS_APP_ORIGIN);hasNotifiedNonAuth.current=true;return;}const response=await fetch(TOKEN_FUNCTION_URL,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify({user_email:user.Email,account_uid:user.Account?.Uid})});const responseData=await response.json();if(!response.ok||!responseData.access_token){throw new Error(responseData.error||\"Failed to get token from backend.\");}targetIframeWindow.postMessage({type:\"outseta:authToken\",token:responseData.access_token,error:null},GCS_APP_ORIGIN);}catch(e){targetIframeWindow.postMessage({type:\"outseta:authToken\",token:null,error:e.message},GCS_APP_ORIGIN);}}};window.addEventListener(\"message\",handleMessageFromIframe);return()=>{window.removeEventListener(\"message\",handleMessageFromIframe);};},[]);// Calculate the effective height to use\nconst effectiveHeight=dynamicHeight||initialHeight;return /*#__PURE__*/_jsx(\"iframe\",{ref:iframeRef,src:iframeSrc,style:{width:\"100%\",height:effectiveHeight,border:\"none\",transition:\"height 0.2s ease\"},title:\"Booking Calendar Portal\"});}CalendarLoader.defaultProps={width:\"100%\",height:500};\nexport const __FramerMetadata__ = {\"exports\":{\"CalendarLoader\":{\"type\":\"reactComponent\",\"name\":\"CalendarLoader\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CalendarLoader.map","import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect,useRef}from\"react\";// Configuration\nconst GCS_APP_URL=\"https://storage.googleapis.com/framer-portal-studio-framer/notifications.html\";const GCS_APP_ORIGIN=\"https://storage.googleapis.com\";const TOKEN_FUNCTION_URL=\"https://us-central1-studio-framer.cloudfunctions.net/get-outseta-token\";export function NotificationsLoader(props){const iframeRef=useRef(null);const[iframeSrc,setIframeSrc]=useState(\"\");const[dynamicHeight,setDynamicHeight]=useState(undefined);useEffect(()=>{setIframeSrc(`${GCS_APP_URL}?v=${new Date().getTime()}`);const handleMessageFromIframe=async event=>{// Handle height resize messages from the iframe\nif(event.data&&event.data.type===\"framer:resize\"&&typeof event.data.height===\"number\"){// Set the iframe height based on content\nsetDynamicHeight(event.data.height);return;}if(event.origin!==GCS_APP_ORIGIN){return;}if(event.data&&(event.data.type===\"outseta:ready_for_token\"||event.data===\"outseta:getAuthToken\")){const targetIframeWindow=iframeRef.current?.contentWindow;if(!targetIframeWindow){return;}if(!window.Outseta){targetIframeWindow.postMessage({type:\"outseta:authToken\",token:null,error:\"Outseta SDK not found.\"},GCS_APP_ORIGIN);return;}try{const user=await window.Outseta.getUser();if(!user||!user.Email){throw new Error(\"Not logged in or email not available.\");}const response=await fetch(TOKEN_FUNCTION_URL,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify({user_email:user.Email,account_uid:user.Account?.Uid})});const responseData=await response.json();if(!response.ok||!responseData.access_token){throw new Error(responseData.error||\"Failed to get token from backend.\");}targetIframeWindow.postMessage({type:\"outseta:authToken\",token:responseData.access_token,error:null},GCS_APP_ORIGIN);}catch(e){targetIframeWindow.postMessage({type:\"outseta:authToken\",token:null,error:e.message},GCS_APP_ORIGIN);}}};window.addEventListener(\"message\",handleMessageFromIframe);return()=>{window.removeEventListener(\"message\",handleMessageFromIframe);};},[]);// Use dynamic height if available, otherwise use a reasonable default\nconst effectiveHeight=dynamicHeight||500;return /*#__PURE__*/_jsx(\"div\",{style:{position:\"fixed\",bottom:0,right:0,width:\"350px\",height:\"auto\",maxHeight:\"90vh\",pointerEvents:\"none\",zIndex:1e3},children:/*#__PURE__*/_jsx(\"iframe\",{ref:iframeRef,src:iframeSrc,style:{width:\"100%\",height:effectiveHeight,maxHeight:\"90vh\",border:\"none\",pointerEvents:\"auto\",transition:\"height 0.2s ease\"},title:\"Notifications Portal\"})});}\nexport const __FramerMetadata__ = {\"exports\":{\"NotificationsLoader\":{\"type\":\"reactComponent\",\"name\":\"NotificationsLoader\",\"slots\":[],\"annotations\":{\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