{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/uGQZtcsxBzvxqsgxQ0Tz/MfcjwtVULiPLwFXApIho/Hubspot.js"],
  "sourcesContent": ["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport * as React from \"react\";\nimport { addPropertyControls, ControlType } from \"framer\";\nimport { emptyStateStyle, stateParagraphStyle, stateTitleStyle } from \"https://framer.com/m/framer/integrations-styles.js@0.2.0\";\nfunction poll(f, delay = 200, count = 10, i = 0) {\n  if (i > count) {\n    console.error(\"poll max attempts\", f);\n    return;\n  }\n  if (!f()) {\n    console.log(\"poll\", delay, count, i);\n    setTimeout(() => {\n      poll(f, delay, count, i + 1);\n    }, delay);\n  }\n}\nfunction EmptyState({\n  title,\n  description\n}) {\n  return /*#__PURE__*/_jsxs(\"div\", {\n    style: {\n      ...emptyStateStyle\n    },\n    children: [/*#__PURE__*/_jsx(\"h1\", {\n      style: stateTitleStyle,\n      children: title\n    }), /*#__PURE__*/_jsx(\"p\", {\n      style: stateParagraphStyle,\n      children: description\n    })]\n  });\n} /**\n  * HUBSPOT\n  *\n  * @framerIntrinsicWidth 480\n  * @framerIntrinsicHeight 300\n  *\n  * @framerSupportedLayoutWidth fixed\n  * @framerSupportedLayoutHeight fixed\n  */\nexport default function HubSpotForm({\n  portalId,\n  formId,\n  advanced,\n  region,\n  id\n}) {\n  if (!portalId || !formId || !region) {\n    return /*#__PURE__*/_jsx(EmptyState, {\n      title: \"Hubspot\",\n      description: \"Set a portal ID and form in the Properties.\"\n    });\n  } // const ref = React.createRef<HTMLDivElement>()\n  const elementId = `hubspot_form_${id}`;\n  const cleanup = () => {\n    const element = document.querySelector(`#${elementId}`);\n    if (element) element.innerHTML = \"\";\n  };\n  React.useEffect(() => {\n    if (window.hbspt) {\n      handleScriptLoad();\n      return cleanup;\n    }\n    const script = document.createElement(\"script\");\n    script.src = `https://js-${region}.hsforms.net/forms/shell.js`;\n    script.onload = handleScriptLoad();\n    document.body.appendChild(script);\n    return cleanup;\n  }, [portalId, formId, region]);\n  const handleScriptLoad = () => {\n    console.log(\"Loading HubSpot form...\", portalId);\n    poll(() => {\n      if (!window.hbspt) {\n        console.warn(`HubSpot could not be loaded: window.hbspt is missing`);\n        return false;\n      }\n      if (!document.querySelector(`#${elementId}`)) {\n        console.warn(`HubSpot could not be loaded: element not found #${elementId}`);\n        return false;\n      }\n      cleanup();\n      window.hbspt.forms.create({\n        region,\n        portalId,\n        formId,\n        target: `#${elementId}`,\n        formInstanceId: formId\n      });\n      return true;\n    });\n  };\n  return /*#__PURE__*/_jsx(\"div\", {\n    style: {\n      width: \"100%\",\n      height: \"100%\"\n    },\n    id: elementId\n  });\n}\n;\naddPropertyControls(HubSpotForm, {\n  portalId: {\n    title: \"Portal\",\n    type: ControlType.String,\n    placeholder: \"25276298\",\n    defaultValue: \"25276298\",\n    description: \"Create a [Hubspot](https://www.hubspot.com/) account, add a new form and copy your portal ID. [Learn more\u2026](https://www.framer.com/sites/integrations/hubspot/)\"\n  },\n  formId: {\n    title: \"Form\",\n    type: ControlType.String,\n    placeholder: \"e7167571-4bc4-4c2c-bfdc-a0a8dbfd22f1\",\n    defaultValue: \"e7167571-4bc4-4c2c-bfdc-a0a8dbfd22f1\"\n  },\n  advanced: {\n    title: \"Advanced\",\n    type: ControlType.Boolean,\n    enabledTitle: \"Show\",\n    disabledTitle: \"Hide\",\n    defaultValue: false\n  },\n  region: {\n    title: \"Region\",\n    type: ControlType.String,\n    placeholder: \"eu1\",\n    defaultValue: \"eu1\",\n    hidden: ({\n      advanced\n    }) => !advanced\n  }\n});\nexport const __FramerMetadata__ = {\n  \"exports\": {\n    \"default\": {\n      \"type\": \"reactComponent\",\n      \"name\": \"HubSpotForm\",\n      \"slots\": [],\n      \"annotations\": {\n        \"framerContractVersion\": \"1\",\n        \"framerSupportedLayoutWidth\": \"fixed\",\n        \"framerIntrinsicWidth\": \"480\",\n        \"framerSupportedLayoutHeight\": \"fixed\",\n        \"framerIntrinsicHeight\": \"300\"\n      }\n    },\n    \"__FramerMetadata__\": {\n      \"type\": \"variable\"\n    }\n  }\n};\n//# sourceMappingURL=./Hubspot.map"],
  "mappings": "uMAIA,SAASA,EAAKC,EAAGC,EAAQ,IAAKC,EAAQ,GAAIC,EAAI,EAAG,CAC/C,GAAIA,EAAID,EAAO,CACb,QAAQ,MAAM,oBAAqBF,CAAC,EACpC,OAEGA,EAAE,IACL,QAAQ,IAAI,OAAQC,EAAOC,EAAOC,CAAC,EACnC,WAAW,IAAM,CACfJ,EAAKC,EAAGC,EAAOC,EAAOC,EAAI,CAAC,CAC7B,EAAGF,CAAK,EAEZ,CACA,SAASG,EAAW,CAClB,MAAAC,EACA,YAAAC,CACF,EAAG,CACD,OAAoBC,EAAM,MAAO,CAC/B,MAAO,CACL,GAAGC,CACL,EACA,SAAU,CAAcC,EAAK,KAAM,CACjC,MAAOC,EACP,SAAUL,CACZ,CAAC,EAAgBI,EAAK,IAAK,CACzB,MAAOE,EACP,SAAUL,CACZ,CAAC,CAAC,CACJ,CAAC,CACH,CASe,SAARM,EAA6B,CAClC,SAAAC,EACA,OAAAC,EACA,SAAAC,EACA,OAAAC,EACA,GAAAC,CACF,EAAG,CACD,GAAI,CAACJ,GAAY,CAACC,GAAU,CAACE,EAC3B,OAAoBP,EAAKL,EAAY,CACnC,MAAO,UACP,YAAa,6CACf,CAAC,EAEH,IAAMc,EAAY,gBAAgBD,IAC5BE,EAAU,IAAM,CACpB,IAAMC,EAAU,SAAS,cAAc,IAAIF,GAAW,EAClDE,IAASA,EAAQ,UAAY,GACnC,EACMC,EAAU,IAAM,CACpB,GAAIC,EAAO,MACT,OAAAC,EAAiB,EACVJ,EAET,IAAMK,EAAS,SAAS,cAAc,QAAQ,EAC9C,OAAAA,EAAO,IAAM,cAAcR,+BAC3BQ,EAAO,OAASD,EAAiB,EACjC,SAAS,KAAK,YAAYC,CAAM,EACzBL,CACT,EAAG,CAACN,EAAUC,EAAQE,CAAM,CAAC,EAC7B,IAAMO,EAAmB,IAAM,CAC7B,QAAQ,IAAI,0BAA2BV,CAAQ,EAC/Cd,EAAK,IACEuB,EAAO,MAIP,SAAS,cAAc,IAAIJ,GAAW,GAI3CC,EAAQ,EACRG,EAAO,MAAM,MAAM,OAAO,CACxB,OAAAN,EACA,SAAAH,EACA,OAAAC,EACA,OAAQ,IAAII,IACZ,eAAgBJ,CAClB,CAAC,EACM,KAXL,QAAQ,KAAK,mDAAmDI,GAAW,EACpE,KALP,QAAQ,KAAK,sDAAsD,EAC5D,GAeV,CACH,EACA,OAAoBT,EAAK,MAAO,CAC9B,MAAO,CACL,MAAO,OACP,OAAQ,MACV,EACA,GAAIS,CACN,CAAC,CACH,CAEAO,EAAoBb,EAAa,CAC/B,SAAU,CACR,MAAO,SACP,KAAMc,EAAY,OAClB,YAAa,WACb,aAAc,WACd,YAAa,sKACf,EACA,OAAQ,CACN,MAAO,OACP,KAAMA,EAAY,OAClB,YAAa,uCACb,aAAc,sCAChB,EACA,SAAU,CACR,MAAO,WACP,KAAMA,EAAY,QAClB,aAAc,OACd,cAAe,OACf,aAAc,EAChB,EACA,OAAQ,CACN,MAAO,SACP,KAAMA,EAAY,OAClB,YAAa,MACb,aAAc,MACd,OAAQ,CAAC,CACP,SAAAX,CACF,IAAM,CAACA,CACT,CACF,CAAC",
  "names": ["poll", "f", "delay", "count", "i", "EmptyState", "title", "description", "u", "emptyStateStyle", "p", "stateTitleStyle", "stateParagraphStyle", "HubSpotForm", "portalId", "formId", "advanced", "region", "id", "elementId", "cleanup", "element", "ue", "window", "handleScriptLoad", "script", "addPropertyControls", "ControlType"]
}
