{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/pDh7xPP9Mm00ifIa1eyE/SlizefdV7iShfvlqXUxG/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,...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]);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});}},onFormSubmitted:(_,data)=>{delete data.submissionValues.hs_context;delete data.submissionValues[\"g-recaptcha-response\"];handleSubmit();if(Array.isArray(window.dataLayer)){window.dataLayer.push({event:\"hubspot-form-submitted-\"+elementId,hubspotFormId:formId});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});}}});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:()=>{},setIsFormReady:()=>{}};addPropertyControls(GainHubSpotForm,{// portalId: {\n//     title: \"Portal\",\n//     type: ControlType.String,\n//     placeholder: \"25276298\", // defaultValue: \"25276298\",\n//     description:\n//         \"Create a [Hubspot](https://www.hubspot.com/) account, add a new form and copy your portal ID. [Learn more\u2026](https://www.framer.com/plugins/hubspot/)\",\n// },\nformId:{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\":{\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":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gB,aAAa,CAAC,SAAS,UAAU,SAAS,GAAM,OAAO,MAAM,aAAa,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,CAAC,EAAEC,EAAoBD,EAAgB,CAOpQ,OAAO,CAAC,MAAM,OAAO,KAAKE,EAAY,OAAO,YAAY,sCAAsC,EAAE,gBAAgB,CAAC,KAAKA,EAAY,OAAO,MAAM,mBAAmB,aAAa,EAAE,EAAE,mBAAmB,CAAC,KAAKA,EAAY,OAAO,MAAM,4BAA4B,aAAa,EAAE,CAAC,CAAC",
  "names": ["poll", "f", "delay", "count", "i", "errorCallback", "GainHubSpotForm", "portalId", "formId", "region", "containerStyle", "id", "conversionEvent", "handleSubmit", "setIsFormReady", "oktopostConversion", "props", "scriptTriggeredRef", "pe", "u", "emptyStateStyle", "p", "elementId", "cleanup", "element", "ue", "window", "handleScriptLoad", "script", "_", "data", "GainHubSpotForm", "addPropertyControls", "ControlType"]
}
