{"version":3,"file":"HubSpotContactForm.CEf_m4e0.mjs","names":["useRef","useState","containerId"],"sources":["https:/framerusercontent.com/modules/UHGZOPE7T0xktQi5RpUO/UqdvJgrr6dwwH4uQpNmY/HubSpotContactForm.js"],"sourcesContent":["// HubSpot Contact Form with direct embed (no iframe)\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,startTransition,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * HubSpot Contact Form\n *\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 500\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function HubSpotContactForm(props){const{portalId=\"\",formId=\"\",region=\"na1\",backgroundColor=\"#FFFFFF\",textColor=\"#000000\",buttonColor=\"#000000\",buttonTextColor=\"#FFFFFF\",borderRadius=8,inputBorderColor=\"#CCCCCC\",customCSS=\"\",onFormSubmit,style}=props;const formContainerRef=useRef(null);const[error,setError]=useState(null);useEffect(()=>{if(typeof window===\"undefined\")return;if(!portalId||!formId){startTransition(()=>setError(\"Portal ID and Form ID are required\"));return;}if(error){startTransition(()=>setError(null));}const createForm=()=>{const container=formContainerRef.current;if(!container||!window.hbspt)return;// HubSpot's forms.create is async — it doesn't populate the\n// container synchronously. So checking children.length isn't\n// enough: two overlapping calls can both see an empty container\n// and both inject a form. Mark the container synchronously the\n// moment we commit to creating, and bail on any subsequent call.\nif(container.dataset.hsFormState===\"creating\"||container.dataset.hsFormState===\"created\")return;container.dataset.hsFormState=\"creating\";try{window.hbspt.forms.create({region:region,portalId:portalId,formId:formId,target:`#${container.id}`,onFormSubmit:()=>{if(onFormSubmit)onFormSubmit();}});container.dataset.hsFormState=\"created\";}catch(err){delete container.dataset.hsFormState;startTransition(()=>setError(\"Failed to create form. Check your Portal ID and Form ID.\"));}};if(window.hbspt){createForm();}else{// Reuse an existing script tag if one is already in flight so we\n// don't double-load. Either way, attach our own onload listener.\nconst existing=document.querySelector('script[src=\"https://js.hsforms.net/forms/v2.js\"]');if(existing){existing.addEventListener(\"load\",createForm,{once:true});}else{const script=document.createElement(\"script\");script.src=\"https://js.hsforms.net/forms/v2.js\";script.async=true;script.addEventListener(\"load\",createForm,{once:true});script.onerror=()=>{startTransition(()=>setError(\"Failed to load HubSpot forms script\"));};document.body.appendChild(script);}}},[portalId,formId,region]);useEffect(()=>{if(typeof window===\"undefined\"||!formContainerRef.current)return;const containerId=formContainerRef.current.id;const styleElement=document.createElement(\"style\");styleElement.setAttribute(\"data-form-style\",containerId);styleElement.innerHTML=`\n            #${containerId} .hs-form {\n                font-family: inherit !important;\n            }\n            #${containerId} .hs-form label {\n                color: ${textColor} !important;\n                font-size: 14px !important;\n                font-weight: 500 !important;\n                letter-spacing: -0.01em !important;\n                line-height: 1.3em !important;\n            }\n            #${containerId} .hs-form input[type=\"text\"],\n            #${containerId} .hs-form input[type=\"email\"],\n            #${containerId} .hs-form input[type=\"tel\"],\n            #${containerId} .hs-form textarea,\n            #${containerId} .hs-form select {\n                border: 1px solid ${inputBorderColor} !important;\n                border-radius: ${borderRadius}px !important;\n                padding: 10px !important;\n                color: ${textColor} !important;\n                background-color: ${backgroundColor} !important;\n                font-size: 14px !important;\n                font-weight: 500 !important;\n                letter-spacing: -0.01em !important;\n                line-height: 1.3em !important;\n            }\n            #${containerId} .hs-form input[type=\"submit\"],\n            #${containerId} .hs-form .hs-button {\n                background-color: ${buttonColor} !important;\n                color: ${buttonTextColor} !important;\n                border: none !important;\n                border-radius: ${borderRadius}px !important;\n                padding: 12px 24px !important;\n                cursor: pointer !important;\n                transition: opacity 0.2s !important;\n                font-size: 14px !important;\n                font-weight: 600 !important;\n                letter-spacing: -0.01em !important;\n                line-height: 1em !important;\n            }\n            #${containerId} .hs-form input[type=\"submit\"]:hover,\n            #${containerId} .hs-form .hs-button:hover {\n                opacity: 0.9 !important;\n            }\n            #${containerId} .hs-form .hs-error-msgs {\n                color: #ff5588 !important;\n                font-size: 12px !important;\n            }\n            ${customCSS}\n        `;document.head.appendChild(styleElement);return()=>{if(styleElement.parentNode){styleElement.parentNode.removeChild(styleElement);}};},[textColor,backgroundColor,buttonColor,buttonTextColor,borderRadius,inputBorderColor,customCSS]);const containerId=`hubspot-form-${portalId}-${formId}`.replace(/[^a-zA-Z0-9-]/g,\"\");return /*#__PURE__*/_jsx(\"div\",{style:{...style,width:\"100%\",height:\"100%\",backgroundColor:backgroundColor,padding:20,borderRadius:borderRadius,overflow:\"visible\"},children:error?/*#__PURE__*/_jsx(\"div\",{style:{color:\"#ff5588\",padding:20,textAlign:\"center\",fontSize:\"14px\",fontFamily:\"inherit\"},children:error}):/*#__PURE__*/_jsx(\"div\",{ref:formContainerRef,id:containerId})});}addPropertyControls(HubSpotContactForm,{portalId:{type:ControlType.String,title:\"Portal ID\",defaultValue:\"\",placeholder:\"Enter your HubSpot Portal ID\"},formId:{type:ControlType.String,title:\"Form ID\",defaultValue:\"\",placeholder:\"Enter your HubSpot Form ID\"},region:{type:ControlType.Enum,title:\"Region\",options:[\"na1\",\"eu1\",\"ap1\"],optionTitles:[\"North America\",\"Europe\",\"Asia Pacific\"],defaultValue:\"na1\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},inputBorderColor:{type:ControlType.Color,title:\"Input Border\",defaultValue:\"#CCCCCC\"},buttonColor:{type:ControlType.Color,title:\"Button Color\",defaultValue:\"#000000\"},buttonTextColor:{type:ControlType.Color,title:\"Button Text\",defaultValue:\"#FFFFFF\"},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:8,min:0,max:32,step:1,unit:\"px\"},customCSS:{type:ControlType.String,title:\"Custom CSS\",displayTextArea:true,placeholder:\"/* Add custom CSS here */\",defaultValue:\"\"},onFormSubmit:{type:ControlType.EventHandler}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HubSpotContactForm\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"400\",\"framerIntrinsicHeight\":\"500\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HubSpotContactForm.map"],"mappings":"6MASG,SAAwB,EAAmB,EAAM,CAAC,GAAK,CAAC,WAAS,GAAG,SAAO,GAAG,SAAO,MAAM,kBAAgB,UAAU,YAAU,UAAU,cAAY,UAAU,kBAAgB,UAAU,eAAa,EAAE,mBAAiB,UAAU,YAAU,GAAG,eAAa,SAAO,EAAY,EAAiBA,EAAO,KAAK,CAAM,CAAC,EAAM,GAAUC,EAAS,KAAK,CAAC,MAAc,CAAC,GAAU,IAAS,OAAY,OAAO,GAAG,CAAC,GAAU,CAAC,EAAO,CAAC,MAAoB,EAAS,qCAAqC,CAAC,CAAC,OAAW,GAAO,MAAoB,EAAS,KAAK,CAAC,CAAE,IAAM,MAAe,CAAC,IAAM,EAAU,EAAiB,QAAW,MAAC,GAAW,CAAC,EAAO,QAKhnB,IAAU,QAAQ,cAAc,YAAY,EAAU,QAAQ,cAAc,WAAiB,GAAU,QAAQ,YAAY,WAAW,GAAG,CAAC,EAAO,MAAM,MAAM,OAAO,CAAQ,SAAgB,WAAgB,SAAO,OAAO,IAAI,EAAU,KAAK,iBAAiB,CAAI,GAAa,GAAc,EAAG,CAAC,CAAC,EAAU,QAAQ,YAAY,eAAqB,CAAC,OAAO,EAAU,QAAQ,YAAY,MAAoB,EAAS,2DAA2D,CAAC,IAAI,GAAG,EAAO,MAAO,GAAY,KAAM,CAE9f,IAAM,EAAS,SAAS,cAAc,mDAAmD,CAAC,GAAG,EAAU,EAAS,iBAAiB,OAAO,EAAW,CAAC,KAAK,GAAK,CAAC,KAAM,CAAC,IAAM,EAAO,SAAS,cAAc,SAAS,CAAC,EAAO,IAAI,qCAAqC,EAAO,MAA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