{"version":3,"file":"GainHubSpotForm.BOSSGpkr.mjs","names":["useRef","__esmMin","init_ssg_sandbox_shims","init_npm_react_18_3_1","window","ce","init_jsx_runtime","c","p","de","addPropertyControls","init_framer_BisrWwwE","ControlType","emptyStateStyle","init_integrations_styles_js_0_2","poll","i","count","errorCallback","f","delay","GainHubSpotForm","props","scriptTriggeredRef","portalId","formId","region","elementId","id","cleanup","element","handleScriptLoad","script","trackPageVisit","currentPagePath","gatedPage","storedVisitsString","visitedPagesObject","error","updatedVisitsString","getUtmParameters","params","utmParams","key","setIsFormReady","redirectUrl","handleSubmit","data","currentUtmParams","conversionEvent","oktopostConversion","containerStyle","init_GainHubSpotForm"],"sources":["https:/framerusercontent.com/modules/pDh7xPP9Mm00ifIa1eyE/qe8InA2prS1gwCINPMnF/GainHubSpotForm.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect,useRef}from\"react\";import{emptyStateStyle}from\"https://framer.com/m/framer/integrations-styles.js@0.2.0\";function poll(f,delay=50,count=50,i=0,errorCallback){if(i>count){errorCallback();return;}if(!f()){setTimeout(()=>{poll(f,delay,count,i+1,errorCallback);},delay);}}/**\n * These annotations control how your component sizes\n * Learn more: https://www.framer.com/docs/guides/auto-sizing\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function GainHubSpotForm({portalId,formId,region,containerStyle,id,conversionEvent,handleSubmit,setIsFormReady,oktopostConversion,gatedPage,redirectUrl,...props}){const scriptTriggeredRef=useRef(false);if(!portalId||!formId||!region){return /*#__PURE__*/_jsxs(\"div\",{style:{...emptyStateStyle,width:\"100%\",height:\"100%\"},children:[/*#__PURE__*/_jsx(\"h1\",{children:\"Hubspot\"}),/*#__PURE__*/_jsx(\"p\",{children:\"Set a portal ID and form in the Properties.\"})]});}const elementId=`hubspot_form_${id}`;const cleanup=()=>{const element=document.querySelector(`#${elementId}`);if(element)element.innerHTML=\"\";};useEffect(()=>{if(window.hbspt){handleScriptLoad();return cleanup;}const script=document.createElement(\"script\");script.src=`https://js-${region}.hsforms.net/forms/shell.js`;script.onload=handleScriptLoad;document.body.appendChild(script);scriptTriggeredRef.current=true;return cleanup;},[formId]);function trackPageVisit(gatedPage){const currentPagePath=(gatedPage||window.location.pathname)?.toString();const storedVisitsString=localStorage.getItem(\"page_visit\");let visitedPagesObject={};if(storedVisitsString){try{visitedPagesObject=JSON.parse(storedVisitsString);}catch(error){console.error(\"Error parsing localStorage 'page_visit' object:\",error);visitedPagesObject={};}}visitedPagesObject[currentPagePath]=true;const updatedVisitsString=JSON.stringify(visitedPagesObject);localStorage.setItem(\"page_visit\",updatedVisitsString);}function getUtmParameters(){const params=new URLSearchParams(window.location.search);const utmParams={};// List of standard UTM parameters\nconst standardUtmKeys=[\"utm_source\",\"utm_medium\",\"utm_campaign\",\"utm_term\",\"utm_content\",\"utm_id\",\"utm_source_platform\",\"utm_creative_format\",\"utm_marketing_tactic\"];standardUtmKeys.forEach(key=>{if(params.has(key)){utmParams[key]=params.get(key);}});return utmParams;}const handleScriptLoad=()=>{poll(()=>{if(!window.hbspt){return false;}if(!id||!document.querySelector(`#${elementId}`)){return false;}cleanup();window.hbspt.forms.create({region,portalId,formId,target:`#${elementId}`,formInstanceId:formId,onFormReady:()=>{setIsFormReady();if(Array.isArray(window.dataLayer)){window.dataLayer.push({event:\"hubspot-form-ready-\"+elementId});}},onBeforeFormSubmit:()=>{if(redirectUrl){window.location.href=redirectUrl;handleSubmit();return false;}return true;},onFormSubmitted:(_,data)=>{delete data.submissionValues.hs_context;delete data.submissionValues[\"g-recaptcha-response\"];handleSubmit(data.submissionValues);const currentUtmParams=getUtmParameters();trackPageVisit(gatedPage);if(Array.isArray(window.dataLayer)){window.dataLayer.push({event:\"hubspot-form-submitted-\"+elementId,hubspotFormId:formId,...currentUtmParams});if(conversionEvent){window.dataLayer.push({event:\"hubspot-form-conversion\",hubspotFormId:formId,conversionEvent:conversionEvent,formData:data.submissionValues});}}if(oktopostConversion&&window?._oktrk){window?._oktrk(\"send\",{tag:oktopostConversion,firstName:data?.submissionValues?.firstname,lastName:data?.submissionValues?.lastname,email:data?.submissionValues?.email,company:data?.submissionValues?.company});}}});return true;},50,50,0,()=>{if(!window.hbspt){console.warn(`HubSpot could not be loaded: window.hbspt is missing`);return;}if(!document.querySelector(`#${elementId}`)){console.warn(`HubSpot could not be loaded: element not found #${elementId}`);return;}console.warn(`HubSpot could not be loaded: no idea why`);});};return /*#__PURE__*/_jsx(\"div\",{id:elementId,style:containerStyle,...props});}// Styles are written in object syntax\n// Learn more: https://reactjs.org/docs/dom-elements.html#style\nconst containerStyle={width:\"100%\",height:\"100%\"};GainHubSpotForm.displayName=\"General/GainHubSpotForm\";GainHubSpotForm.defaultProps={portalId:\"5422012\",advanced:false,region:\"na1\",handleSubmit:data=>{},setIsFormReady:()=>{}};addPropertyControls(GainHubSpotForm,{formId:{title:\"Form\",type:ControlType.String,placeholder:\"e7167571-4bc4-4c2c-bfdc-a0a8dbfd22f1\"},conversionEvent:{type:ControlType.String,title:\"Conversion Event\",defaultValue:\"\"},oktopostConversion:{type:ControlType.String,title:\"Oktopost Conversion Event\",defaultValue:\"\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"GainHubSpotForm\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./GainHubSpotForm.map"],"mappings":"A,2QAAuO,SAASe,EAAK,EAAE,EAAM,GAAG,EAAM,GAAG,EAAE,EAAE,EAAc,CAAIC,EAAEC,EAAOC,EAAc,EAAcC,EAAE,GAAG,eAAe,CAACJ,EAAKI,EAAEC,EAAMH,EAAMD,EAAE,EAAEE,CAAa,CAAE,EAAEE,CAAK,CAAG,CAMtY,SAAwBC,EAAgB,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