{"version":3,"file":"Embed3.BkurCXtq.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/W0HDkPA3NuO7pd4MT9gF/e5kkTguQ8gxFhbORfBg7/Embed3.js"],"sourcesContent":["// // Welcome to Code in Framer\n// // Get Started: https://www.framer.com/developers/\n// import React, { useEffect, useRef } from \"react\"\n// /**\n//  * These annotations control how your component sizes\n//  * Learn more: https://www.framer.com/developers/#code-components-auto-sizing\n//  *\n//  * @framerSupportedLayoutWidth fill\n//  * @framerSupportedLayoutHeight fill\n//  */\n// export default function Embed(props) {\n//     const containerRef = useRef(null)\n//     useEffect(() => {\n//         if (containerRef.current) {\n//             // Clear any previous content\n//             containerRef.current.innerHTML = \"\"\n//             const isContactPage =\n//                 window.location.href.includes(\"/contact-us\") ||\n//                 document.body.classList.contains(\"contact-page\") ||\n//                 document.querySelector(\"h1\")?.textContent.includes(\"Contact\")\n//             // Build the base form URL\n//             let formUrl = \"https://form.jotform.com/251391353870054\"\n//             // Only add course parameter if NOT on contact page\n//             if (!isContactPage) {\n//                 const courseTitle = getCourseTitle(props)\n//                 if (courseTitle && courseTitle !== \"Let's get in touch!\") {\n//                     formUrl += `?course=${encodeURIComponent(courseTitle)}`\n//                 }\n//             }\n//             const iframe = document.createElement(\"iframe\")\n//             // Set the iframe styles to ensure it fits the container\n//             iframe.src = formUrl\n//             iframe.style.width = \"100%\"\n//             iframe.style.height = \"100%\"\n//             iframe.style.border = \"none\"\n//             iframe.style.flex = \"1\"\n//             // Append the iframe to the container div\n//             containerRef.current.appendChild(iframe)\n//         }\n//     }, [props.document?.title, props.content?.title]) // Watch for title changes\n//     return (\n//         <div ref={containerRef} style={containerStyle}>\n//             {/* Jotform will be embedded here */}\n//         </div>\n//     )\n// }\n// // Helper function to get the course title\n// function getCourseTitle(props) {\n//     // Method 1: From direct CMS props\n//     if (props.document?.title) return props.document.title\n//     if (props.content?.title) return props.content.title\n//     // Method 2: From specific page elements\n//     const courseTitleElement =\n//         document.querySelector(\"[data-course-title]\") ||\n//         document.querySelector(\".course-title\") ||\n//         document.querySelector(\"h1:not(nav h1)\")\n//     return courseTitleElement?.innerText || \"Course Registration\"\n// }\n// // Styles are written in object syntax\n// // Learn more: https://reactjs.org/docs/dom-elements.html#style\n// const containerStyle = {\n//     width: \"100%\",\n//     height: \"100%\",\n//     display: \"flex\",\n//     justifyContent: \"center\",\n//     alignItems: \"center\",\n//     overflow: \"hidden\",\n//     backgroundColor: \"#ffffff\", // Ensure the background is white to distinguish it from the Framer background\n//     position: \"relative\", // Ensure the component's position is relative\n// }\n// Welcome to Code in Framer\n// Get Started: https://www.framer.com/developers/\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";/**\n * These annotations control how your component sizes\n * Learn more: https://www.framer.com/developers/#code-components-auto-sizing\n *\n * @framerSupportedLayoutWidth fill\n * @framerSupportedLayoutHeight fill\n */export default function Embed(props){const containerRef=useRef(null);const handleMessageRef=useRef(null);useEffect(()=>{if(containerRef.current){// Clear any previous content\ncontainerRef.current.innerHTML=\"\";const isContactPage=window.location.href.includes(\"/contact-us\")||document.body.classList.contains(\"contact-page\")||document.querySelector(\"h1\")?.textContent.includes(\"Contact\");// Build the base form URL\nlet formUrl=\"https://form.jotform.com/251391353870054\";// Only add course parameter if NOT on contact page\nif(!isContactPage){const courseTitle=getCourseTitle(props);if(courseTitle&&courseTitle!==\"Let's get in touch!\"){formUrl+=`?course=${encodeURIComponent(courseTitle)}`;}}const iframe=document.createElement(\"iframe\");// Set the iframe styles to ensure it fits the container\niframe.src=formUrl;iframe.style.width=\"100%\";iframe.style.height=\"100%\";iframe.style.border=\"none\";iframe.style.flex=\"1\";// Append the iframe to the container div\ncontainerRef.current.appendChild(iframe);// Track form view after iframe loads\niframe.onload=function(){setTimeout(()=>{if(typeof window.gtag!==\"undefined\"){window.gtag(\"event\",\"view_tinkercademy_public_enquiry_form\",{form_location:window.location.pathname,form_url:formUrl,timestamp:new Date().toISOString()});console.log(\"✅ Form view tracked:\",window.location.pathname);}else{console.warn(\"⚠️ GA4 gtag not found\");}},500);};// Track form submission\nconst handleMessage=e=>{try{if(!e.origin||!e.origin.includes(\"jotform.com\"))return;const data=e.data;console.log(\"📨 Message from Jotform:\",data);// Check for submission - handles both string and object formats\nlet isSubmission=false;// Check if it's a string message\nif(typeof data===\"string\"){isSubmission=data.indexOf(\"submissionCompleted\")!==-1||data.indexOf(\"submission-completed\")!==-1;}else if(typeof data===\"object\"&&data!==null){isSubmission=data.action===\"submission-completed\"||data.action===\"submissionCompleted\";}if(isSubmission){if(typeof window.gtag!==\"undefined\"){window.gtag(\"event\",\"submit_tinkercademy_public_enquiry_form\",{form_location:window.location.pathname,form_url:formUrl,timestamp:new Date().toISOString()});console.log(\"✅ Form submission tracked:\",window.location.pathname);}else{console.warn(\"⚠️ GA4 gtag not found\");}}}catch(error){console.error(\"Error in message handler:\",error);}};// Store reference for cleanup\nhandleMessageRef.current=handleMessage;window.addEventListener(\"message\",handleMessage);}// Cleanup function\nreturn()=>{if(handleMessageRef.current){window.removeEventListener(\"message\",handleMessageRef.current);}};},[props.document?.title,props.content?.title]);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:containerStyle});}function getCourseTitle(props){if(props.document?.title)return props.document.title;if(props.content?.title)return props.content.title;const courseTitleElement=document.querySelector(\"[data-course-title]\")||document.querySelector(\".course-title\")||document.querySelector(\"h1:not(nav h1)\");return courseTitleElement?.innerText||\"Course Registration\";}const containerStyle={width:\"100%\",height:\"100%\",display:\"flex\",justifyContent:\"center\",alignItems:\"center\",overflow:\"hidden\",backgroundColor:\"#ffffff\",position:\"relative\"};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Embed\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"fill\",\"framerSupportedLayoutWidth\":\"fill\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Embed3.map"],"mappings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