{"version":3,"file":"HubspotFormTarget.C6SCQNKg.mjs","names":["useRef","useId"],"sources":["https:/framerusercontent.com/modules/xn5l2hcoXbUPzByufIYC/rTX9MVB5hgMwKfn1vIQ2/HubspotFormTarget.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useId,useRef}from\"react\";const TARGET_ID_PREFIX=\"focal-book-demo-hubspot-form\";const FORM_ID=\"992fd5dc-43f4-4cb3-8c3a-419bb6acd634\";const DESKTOP_MIN_HEIGHT=920;const MOBILE_MIN_HEIGHT=1150;const HEIGHT_BUFFER=12;const MAX_BOOT_TRIES=120;const BOOT_RETRY_MS=100;function addScript(id,src){if(document.getElementById(id))return;const script=document.createElement(\"script\");script.id=id;script.src=src;script.async=true;if(id===\"chilipiper-concierge\"){script.crossOrigin=\"anonymous\";}document.head.appendChild(script);}function fillAttribution($form){const form=$form?.[0]||$form;if(!form?.elements)return;const setField=(name,value)=>{if(!value)return;const field=form.elements.namedItem(name)||form.elements.namedItem(`0-1/${name}`);if(!field)return;field.value=value;field.dispatchEvent(new Event(\"input\",{bubbles:true}));field.dispatchEvent(new Event(\"change\",{bubbles:true}));};new URLSearchParams(window.location.search).forEach((value,key)=>{if(key.startsWith(\"utm_\"))setField(key,value);});setField(\"referrer\",document.referrer);}function getReservedHeight(root){const formTarget=root.querySelector(\"[data-focal-form-target]\");const formFrame=root.querySelector(\".hs-form-frame\");const iframe=root.querySelector(\"iframe\");const measuredHeight=Math.max(formTarget?.scrollHeight||0,formFrame?.offsetHeight||0,iframe?.offsetHeight||0);const minimumHeight=window.innerWidth<=409?MOBILE_MIN_HEIGHT:DESKTOP_MIN_HEIGHT;return Math.max(minimumHeight,measuredHeight+HEIGHT_BUFFER);}function syncLayout(root){if(!root)return;const reservedHeight=getReservedHeight(root);const reservedHeightValue=`${reservedHeight}px`;root.style.setProperty(\"--focal-form-reserved-height\",reservedHeightValue);const framerFrame=root.parentElement;if(!framerFrame)return;framerFrame.style.width=\"100%\";framerFrame.style.maxWidth=\"100%\";framerFrame.style.height=\"auto\";framerFrame.style.minHeight=reservedHeightValue;framerFrame.style.overflow=\"visible\";}export default function HubSpotFormTarget(){const rootRef=useRef(null);const reactId=useId().replace(/[^a-zA-Z0-9_-]/g,\"\");const targetId=`${TARGET_ID_PREFIX}-${reactId}`;useEffect(()=>{const w=window;let bootTimer;let resizeObserver;const syncTimers=[];let tries=0;const runSync=()=>syncLayout(rootRef.current);const queueSync=delay=>{syncTimers.push(window.setTimeout(runSync,delay));};addScript(\"hubspot-forms-v2\",\"https://js-na2.hsforms.net/forms/embed/v2.js\");addScript(\"chilipiper-concierge\",\"https://meetwithfocal.chilipiper.com/concierge-js/cjs/concierge.js\");const boot=()=>{const root=rootRef.current;const target=root?.querySelector(`#${targetId}`);if(!root||!target||!w.hbspt?.forms?.create||!w.ChiliPiper?.deploy){if(tries++<MAX_BOOT_TRIES){bootTimer=window.setTimeout(boot,BOOT_RETRY_MS);}return;}if(target.dataset.focalBookDemoStarted===\"true\")return;runSync();target.dataset.focalBookDemoStarted=\"true\";try{w.ChiliPiper.deploy(\"meetwithfocal\",\"hubspotform\",{formType:\"Hubspot\",formIds:[FORM_ID]});w.hbspt.forms.create({region:\"na2\",portalId:\"245583691\",formId:FORM_ID,target:`#${targetId}`,onFormReady:$form=>{fillAttribution($form);runSync();queueSync(500);queueSync(1500);},onBeforeFormSubmit:fillAttribution});}catch(error){target.dataset.focalBookDemoStarted=\"false\";console.error(\"Failed to initialize Focal demo form\",error);}};runSync();boot();if(\"ResizeObserver\"in window&&rootRef.current){resizeObserver=new ResizeObserver(runSync);resizeObserver.observe(rootRef.current);}window.addEventListener(\"resize\",runSync);return()=>{if(bootTimer)window.clearTimeout(bootTimer);syncTimers.forEach(timer=>window.clearTimeout(timer));resizeObserver?.disconnect();window.removeEventListener(\"resize\",runSync);};},[targetId]);return /*#__PURE__*/_jsxs(\"div\",{ref:rootRef,className:\"focal-book-demo-root\",children:[/*#__PURE__*/_jsx(\"style\",{children:`\n                  .focal-book-demo-root {\n                      width: 100%;\n                      max-width: 100%;\n                      min-height: var(--focal-form-reserved-height, ${DESKTOP_MIN_HEIGHT}px);\n                      overflow: visible;\n                      box-sizing: border-box;\n                  }\n\n                  .focal-book-demo-shell {\n                      width: 100%;\n                      max-width: 500px;\n                      min-height: inherit;\n                      margin: 0 auto;\n                      overflow: visible;\n                      box-sizing: border-box;\n                  }\n\n                  #${targetId},\n                  #${targetId} > div,\n                  #${targetId} .hs-form-frame,\n                  #${targetId} iframe {\n                      width: 100% !important;\n                      max-width: 100% !important;\n                      box-sizing: border-box !important;\n                  }\n\n                  #${targetId} iframe {\n                      display: block;\n                      border: 0;\n                  }\n\n                  @media (max-width: 809px) {\n                      .focal-book-demo-root {\n                          min-height: var(--focal-form-reserved-height, ${MOBILE_MIN_HEIGHT}px);\n                      }\n\n                      .focal-book-demo-shell {\n                          max-width: 100%;\n                      }\n                  }\n              `}),/*#__PURE__*/_jsx(\"div\",{className:\"focal-book-demo-shell\",children:/*#__PURE__*/_jsx(\"div\",{id:targetId,\"data-focal-form-target\":true})})]});}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HubSpotFormTarget\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HubspotFormTarget.map"],"mappings":"gJAAgV,SAAS,EAAU,EAAG,EAAI,CAAC,GAAG,SAAS,eAAe,EAAG,CAAC,OAAO,IAAM,EAAO,SAAS,cAAc,SAAS,CAAC,EAAO,GAAG,EAAG,EAAO,IAAI,EAAI,EAAO,MAAM,GAAQ,IAAK,yBAAwB,EAAO,YAAY,aAAa,SAAS,KAAK,YAAY,EAAO,CAAE,SAAS,EAAgB,EAAM,CAAC,IAAM,EAAK,IAAQ,IAAI,EAAM,GAAG,CAAC,GAAM,SAAS,OAAO,IAAM,GAAU,EAAK,IAAQ,CAAC,GAA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