{"version":3,"file":"Hubspot.pQLPacLN.mjs","names":["React.useState","__esmMin","init_ssg_sandbox_shims","init_npm_react_18_3_1","window","ce","init_jsx_runtime","c","p","_e","addPropertyControls","init_framer_DJ_0WPVq","ControlType","stateTitleStyle","stateParagraphStyle","emptyStateStyle","init_integrations_styles_js_0_2","poll","i","count","f","delay","generateRandomId","length","EmptyState","title","description","HubSpotForm","instanceId","portalId","formId","region","elementId","id","cleanup","element","handleScriptLoad","script","init_Hubspot","advanced"],"sources":["https:/framerusercontent.com/modules/uGQZtcsxBzvxqsgxQ0Tz/6XraxkFrtAod9ad0mjBj/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 generateRandomId(length=8){return Math.random().toString(36).substr(2,length);}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}){// Without this, the every breakpoint instance would render in the first breakpoint\nconst[instanceId]=React.useState(()=>generateRandomId());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();console.log(\"Creating a HubSpot instance\");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\":{\"framerIntrinsicHeight\":\"300\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerIntrinsicWidth\":\"480\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Hubspot.map"],"mappings":"A,0RACA,SAASiB,EA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