{"version":3,"file":"Hubspot_Form_w_URL_parameter.CnhMEaFD.mjs","names":["React.useState","React.useRef"],"sources":["https:/framerusercontent.com/modules/BjaPBdO0UfkQ6LVitXuP/ZI7eFgMpv7ma4TW1CFOl/Hubspot_Form_w_URL_parameter.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";export function HubSpotFormEU1(props){const{portalId,formId,paramId,paramCategory,urlParamName}=props;const[scriptLoaded,setScriptLoaded]=React.useState(false);const formContainerRef=React.useRef(null);// Function to load the HubSpot script\nconst loadHubSpotScript=()=>{const script=document.createElement(\"script\");script.src=\"https://js.hsforms.net/forms/embed/v2.js\";script.async=true;script.onload=()=>{setScriptLoaded(true);};document.body.appendChild(script);};React.useEffect(()=>{// Load the HubSpot script\nloadHubSpotScript();// Set up an event listener for messages from the iframe\nconst handleMessage=event=>{// Check the origin of the message for security\nif(event.origin!==\"https://hsforms.net\"){return;}// Handle the message from the iframe\nif(event.data.type===\"formSubmitted\"){window.open(event.data.redirectUrl,\"_blank\");}};window.addEventListener(\"message\",handleMessage);// Cleanup the event listener on component unmount\nreturn()=>{window.removeEventListener(\"message\",handleMessage);};},[]);React.useEffect(()=>{if(scriptLoaded&&window.hbspt){const currentUrl=window.location.href;// Get URL parameter value\nconst urlParams=new URLSearchParams(window.location.search);const urlParamValue=urlParamName?urlParams.get(urlParamName):null;window.hbspt.forms.create({region:\"eu1\",portalId:portalId,formId:formId,target:\"#my-framerform-container\",onFormReady:function($form){// Use vanilla JavaScript to set hidden field values\nconst framerformIdInput=$form.querySelector('input[name=\"framerform_id\"]');const framerformUrlInput=$form.querySelector('input[name=\"framerform_url\"]');const framerformCategoryInput=$form.querySelector('input[name=\"framerform_category\"]');// Select dropdown option based on URL parameter\nif(urlParamValue){const dropdown=$form.querySelector(\"select\");if(dropdown){const option=dropdown.querySelector(`option[value=\"${urlParamValue}\"]`);if(option){dropdown.value=urlParamValue;dropdown.dispatchEvent(new Event(\"change\",{bubbles:true}));}}}if(framerformIdInput)framerformIdInput.value=paramId;if(framerformUrlInput)framerformUrlInput.value=currentUrl;if(framerformCategoryInput)framerformCategoryInput.value=paramCategory;}});}},[scriptLoaded,portalId,formId,paramId,paramCategory,urlParamName]);return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\"},children:/*#__PURE__*/_jsx(\"div\",{id:\"my-framerform-container\",ref:formContainerRef})});}// Property Controls so you can configure from the Framer UI\naddPropertyControls(HubSpotFormEU1,{portalId:{type:ControlType.String,title:\"Portal ID\",defaultValue:\"25700711\"},formId:{type:ControlType.String,title:\"Form ID\",defaultValue:\"cd159c5b-cb12-4a00-912b-ff06001ea080\"},paramId:{type:ControlType.String,title:\"ID\",defaultValue:\"custom-id\"},paramCategory:{type:ControlType.String,title:\"Category\",defaultValue:\"custom-category\"},urlParamName:{type:ControlType.String,title:\"URL Parameter Name\",defaultValue:\"something\",description:\"The name of the URL parameter to read (e.g., 'something' for ?something=value)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"HubSpotFormEU1\":{\"type\":\"reactComponent\",\"name\":\"HubSpotFormEU1\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Hubspot_Form_w_URL_parameter.map"],"mappings":"uMAA2H,SAAgB,EAAe,EAAM,CAAC,GAAK,CAAC,WAAS,SAAO,UAAQ,gBAAc,gBAAc,EAAW,CAAC,EAAa,GAAiBA,EAAe,GAAM,CAAO,EAAiBC,EAAa,KAAK,CAC9T,MAAsB,CAAC,IAAM,EAAO,SAAS,cAAc,SAAS,CAAC,EAAO,IAAI,2CAA2C,EAAO,MAAM,GAAK,EAAO,WAAW,CAAC,EAAgB,GAAK,EAAG,SAAS,KAAK,YAAY,EAAO,EAQ2R,OARxR,MAAoB,CACtP,GAAmB,CACnB,IAAM,EAAc,GAAO,CACxB,EAAM,SAAS,uBACf,EAAM,K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