{"version":3,"file":"Hubspot.BrO-R1Ek.mjs","names":[],"sources":["https:/framerusercontent.com/modules/uGQZtcsxBzvxqsgxQ0Tz/b7VYVaGCWWNyhqVsgsiv/Hubspot.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{emptyStateStyle,stateParagraphStyle,stateTitleStyle}from\"https://framer.com/m/framer/integrations-styles.js@0.2.0\";// Poll for 5 minutes ...\nfunction poll(f,delay=200,count=5*60*5,i=0){if(i>count){console.error(\"poll max attempts\",f);return;}if(!f()){console.log(\"poll\",delay,count,i);setTimeout(()=>{poll(f,delay,count,i+1);},delay);}}function EmptyState({title,description}){return /*#__PURE__*/_jsxs(\"div\",{style:{...emptyStateStyle,width:\"100%\",height:\"100%\"},children:[/*#__PURE__*/_jsx(\"h1\",{style:stateTitleStyle,children:title}),/*#__PURE__*/_jsx(\"p\",{style:stateParagraphStyle,children:description})]});}/**\n * HUBSPOT\n *\n * @framerIntrinsicWidth 480\n * @framerIntrinsicHeight 300\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function HubSpotForm({portalId,formId,advanced,region,id}){if(!portalId||!formId||!region){return /*#__PURE__*/_jsx(EmptyState,{title:\"Hubspot\",description:\"Set a portal ID and form in the Properties.\"});}// const ref = React.createRef<HTMLDivElement>()\nconst elementId=`hubspot_form_${id}`;const cleanup=()=>{const element=document.querySelector(`#${elementId}`);if(element)element.innerHTML=\"\";};React.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);return cleanup;},[portalId,formId,region]);const handleScriptLoad=()=>{console.log(\"Loading HubSpot form...\",portalId);poll(()=>{if(!window.hbspt){console.warn(`HubSpot could not be loaded: window.hbspt is missing`);return false;}if(!document.querySelector(`#${elementId}`)){console.warn(`HubSpot could not be loaded: element not found #${elementId}`);return false;}cleanup();window.hbspt.forms.create({region,portalId,formId,target:`#${elementId}`,formInstanceId:formId});return true;});};return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\"},id:elementId});}addPropertyControls(HubSpotForm,{portalId:{title:\"Portal\",type:ControlType.String,placeholder:\"25276298\",// defaultValue: \"25276298\",\ndescription:\"Create a [Hubspot](https://www.hubspot.com/) account, add a new form and copy your portal ID. [Learn more…](https://www.framer.com/plugins/hubspot/)\"},formId:{title:\"Form\",type:ControlType.String,placeholder:\"e7167571-4bc4-4c2c-bfdc-a0a8dbfd22f1\"},advanced:{title:\"Advanced\",type:ControlType.Boolean,enabledTitle:\"Show\",disabledTitle:\"Hide\",defaultValue:false},region:{title:\"Region\",type:ControlType.String,placeholder:\"eu1\",defaultValue:\"eu1\",hidden:({advanced})=>!advanced}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HubSpotForm\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"300\",\"framerIntrinsicWidth\":\"480\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Hubspot.map"],"mappings":"kRACA,SAAS,EAAK,EAAE,EAAM,IAAI,EAAM,IAAK,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,EAAM,CAAC,QAAQ,MAAM,oBAAoB,CAAC,EAAE,MAAO,CAAK,EAAE,IAAG,QAAQ,IAAI,OAAO,EAAM,EAAM,CAAC,EAAE,eAAe,CAAC,EAAK,EAAE,EAAM,EAAM,EAAE,CAAC,CAAE,EAAE,CAAK,EAAG,CAAC,SAAS,EAAW,CAAC,QAAM,eAAa,CAAC,OAAoB,EAAM,MAAM,CAAC,MAAM,CAAC,GAAG,EAAgB,MAAM,OAAO,OAAO,MAAM,EAAE,SAAS,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