{"version":3,"file":"SM_Hubspot_Form.BwfqyO2u.mjs","names":["useState","email","e","_Fragment"],"sources":["https:/framerusercontent.com/modules/4GgKmlbJFezLN3fUyaS3/1JfseXllkJdvuBb9mXDd/SM_Hubspot_Form.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";function getCookieValue(name){const match=document.cookie.match(new RegExp(\"(^| )\"+name+\"=([^;]+)\"));return match?decodeURIComponent(match[2]):null;}const PERSONAL_EMAIL_DOMAINS=[\"gmail.com\",\"yahoo.com\",\"outlook.com\",\"hotmail.com\",\"icloud.com\",\"aol.com\",\"protonmail.com\",\"zoho.com\",\"mail.com\",\"yandex.com\",\"gmx.com\",\"live.com\",\"msn.com\",\"comcast.net\",\"me.com\",\"att.net\",\"verizon.net\",// Academic domains\n\"ox.ac.uk\",\"cam.ac.uk\",\"imperial.ac.uk\",\"lse.ac.uk\",\"manchester.ac.uk\",\"ed.ac.uk\",\"kcl.ac.uk\",\"ucl.ac.uk\",\"warwick.ac.uk\",\"bristol.ac.uk\",\"uni-heidelberg.de\",\"uni-muenchen.de\",\"uni-freiburg.de\",\"uni-koeln.de\",\"uni-frankfurt.de\",\"tu-berlin.de\",\"uni-hamburg.de\",\"uni-leipzig.de\",\"uni-bonn.de\",\"uni-stuttgart.de\",\"sorbonne-universite.fr\",\"univ-lyon1.fr\",\"univ-amu.fr\",\"univ-grenoble-alpes.fr\",\"univ-nantes.fr\",\"univ-tlse3.fr\",\"univ-lille.fr\",\"univ-rennes1.fr\",\"univ-bordeaux.fr\",\"univ-strasbg.fr\",\"ub.edu\",\"uam.es\",\"upf.edu\",\"usc.es\",\"uv.es\",\"ugr.es\",\"unav.es\",\"unizar.es\",\"uoc.edu\",\"unileon.es\",\"unibo.it\",\"unimi.it\",\"uniroma1.it\",\"unipd.it\",\"unipi.it\",\"unina.it\",\"unisi.it\",\"unige.it\",\"unict.it\",\"uniba.it\",\"uva.nl\",\"tudelft.nl\",\"rug.nl\",\"eur.nl\",\"vu.nl\",\"wur.nl\",\"utwente.nl\",\"tilburguniversity.edu\",\"radboudumc.nl\",\"han.nl\",\"uu.se\",\"su.se\",\"lu.se\",\"gu.se\",\"kth.se\",\"umu.se\",\"liu.se\",\"oru.se\",\"hig.se\",\"lnu.se\",\"helsinki.fi\",\"aalto.fi\",\"oulu.fi\",\"jyu.fi\",\"uef.fi\",\"utu.fi\",\"lut.fi\",\"uwasa.fi\",\"hanken.fi\",\"arcada.fi\",\"ku.dk\",\"au.dk\",\"sdu.dk\",\"ruc.dk\",\"cbs.dk\",\"aau.dk\",\"itu.dk\",\"dtu.dk\",\"phmetropol.dk\",\"via.dk\",\"uio.no\",\"ntnu.no\",\"uib.no\",\"uit.no\",\"nmbu.no\",\"hvl.no\",\"usn.no\",\"oslomet.no\",\"inn.no\",\"mf.no\"];export function HubSpotForm(props){const{placeholder,buttonText,font,layout,buttonColor,formId,portalId,trackingEvent}=props;const[email,setEmail]=useState(\"\");const[isInvalidEmailError,setIsInvalidEmailError]=useState(false);const[errorMessage,setErrorMessage]=useState(\"Please enter your work email.\");const emptyEmailMessage=\"Please enter your email address.\";const[isSubmitting,setIsSubmitting]=useState(false);const[successMessage,setSuccessMessage]=useState(null);const isInvalidEmail=email=>{if(!email||!email.includes(\"@\"))return false;const domain=email.toLowerCase().split(\"@\")[1];// Exclude personal domains and .edu domains\nreturn PERSONAL_EMAIL_DOMAINS.some(blocked=>domain.includes(blocked))||domain.endsWith(\".edu\");};useEffect(()=>{if(email){const invalid=isInvalidEmail(email);setIsInvalidEmailError(invalid);if(invalid)setErrorMessage(\"Please enter your work email.\");}else{setIsInvalidEmailError(false);}},[email]);const handleSubmit=async e=>{e.preventDefault();if(!email.trim()){setIsInvalidEmailError(true);setErrorMessage(emptyEmailMessage);return;}if(isInvalidEmail(email)){setIsInvalidEmailError(true);setErrorMessage(\"Please enter your work email.\");return;}setIsInvalidEmailError(false);setIsSubmitting(true);const urlParams=new URLSearchParams(window.location.search);const cookieValue=getCookieValue(\"utmParams\");let cookieParams={};if(cookieValue){try{cookieParams=JSON.parse(cookieValue);}catch{console.error(\"Invalid utmParams cookie\");}}const utm_source=urlParams.get(\"utm_source\")||cookieParams.utm_source||\"\";const utm_medium=urlParams.get(\"utm_medium\")||cookieParams.utm_medium||\"\";const utm_campaign=urlParams.get(\"utm_campaign\")||cookieParams.utm_campaign||\"\";const utm_term=urlParams.get(\"utm_term\")||cookieParams.utm_term||\"\";const utm_content=urlParams.get(\"utm_content\")||cookieParams.utm_content||\"\";const gclid=urlParams.get(\"gclid\")||cookieParams.gclid||\"\";const hutk=getCookieValue(\"hubspotutk\")||\"\";const commonFields=[{objectTypeId:\"0-1\",name:\"email\",value:email},{objectTypeId:\"0-1\",name:\"utm_source\",value:utm_source},{objectTypeId:\"0-1\",name:\"utm_medium\",value:utm_medium},{objectTypeId:\"0-1\",name:\"utm_campaign\",value:utm_campaign},{objectTypeId:\"0-1\",name:\"utm_term\",value:utm_term},{objectTypeId:\"0-1\",name:\"utm_content\",value:utm_content},{objectTypeId:\"0-1\",name:\"gclid\",value:gclid}];const hsPayload={fields:commonFields,context:{hutk,pageUri:window.location.href,pageName:document.title},legalConsentOptions:{consent:{consentToProcess:true,text:\"I agree to allow example.com to store and process my personal data.\"}}};try{const res=await fetch(`https://api.hsforms.com/submissions/v3/integration/submit/${portalId}/${formId}`,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify(hsPayload)});const resBody=await res.json();console.log(\"✅ HubSpot Form Response:\",resBody);// Save email to localStorage\ntry{localStorage.setItem(\"abacum_user_email\",email);console.log(\"📧 Email saved to localStorage:\",email);}catch(e){console.warn(\"⚠️ Could not save email to localStorage:\",e);}window.dataLayer?.push({event:trackingEvent,email});setSuccessMessage(\"Thanks! You're on the list.\");setEmail(\"\");}catch(error){console.error(\"❌ HubSpot form submission error:\",error);setErrorMessage(\"Something went wrong. Please try again.\");setIsInvalidEmailError(true);}finally{setIsSubmitting(false);}};const isRow=layout===\"row\";return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsxs(\"form\",{id:\"hubspot-form\",onSubmit:handleSubmit,style:{display:\"flex\",flexDirection:isRow?\"row\":\"column\",gap:isRow?\"20px\":\"12px\",alignItems:isRow?\"center\":\"stretch\",width:isRow?\"fit-content\":\"100%\",fontFamily:font},children:[/*#__PURE__*/_jsxs(\"div\",{style:{width:isRow?\"320px\":\"100%\"},children:[/*#__PURE__*/_jsx(\"input\",{name:\"email\",type:\"email\",placeholder:placeholder,value:email,onChange:e=>setEmail(e.currentTarget.value),style:{width:\"100%\",padding:\"12px\",borderRadius:\"6px\",border:`1px solid ${isInvalidEmailError?\"#e74c3c\":\"#ccc\"}`,fontSize:\"16px\",fontFamily:font}}),!isRow&&isInvalidEmailError&&/*#__PURE__*/_jsx(\"div\",{style:{color:\"#ffffff\",fontSize:\"14px\",marginTop:\"4px\"},children:errorMessage})]}),/*#__PURE__*/_jsx(\"button\",{type:\"submit\",disabled:isInvalidEmailError||isSubmitting,style:{padding:isRow?\"12px 20px\":\"12px\",borderRadius:\"6px\",backgroundColor:buttonColor,color:\"#fff\",fontSize:\"16px\",border:\"none\",cursor:isInvalidEmailError||isSubmitting?\"not-allowed\":\"pointer\",fontFamily:font},children:isSubmitting?\"Submitting…\":buttonText})]}),successMessage&&/*#__PURE__*/_jsx(\"div\",{style:{color:\"#000000\",fontSize:\"14px\",marginTop:\"8px\",fontFamily:font},children:successMessage}),isRow&&isInvalidEmailError&&/*#__PURE__*/_jsx(\"div\",{style:{color:\"#000000\",fontSize:\"14px\",marginTop:\"8px\",fontFamily:font},children:errorMessage})]});}addPropertyControls(HubSpotForm,{placeholder:{type:ControlType.String,title:\"Placeholder\",defaultValue:\"Enter your email\"},buttonText:{type:ControlType.String,title:\"Button Text\",defaultValue:\"Submit\"},font:{type:ControlType.String,title:\"Font Family\",defaultValue:\"sans-serif\"},layout:{type:ControlType.Enum,title:\"Layout\",options:[\"column\",\"row\"],defaultValue:\"column\"},buttonColor:{type:ControlType.Color,title:\"Button Color\",defaultValue:\"#007AFF\"},formId:{type:ControlType.String,title:\"Form ID\",defaultValue:\"2cdfb551-739d-4268-a293-3dae97da7cad\",description:\"Your HubSpot form ID\"},portalId:{type:ControlType.String,title:\"Portal ID\",defaultValue:\"9125123\",description:\"Your HubSpot portal ID\"},trackingEvent:{type:ControlType.String,title:\"Tracking Event\",defaultValue:\"form_completed_hs\",description:\"Google Analytics event name (e.g. form_webinar_submitted)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"HubSpotForm\":{\"type\":\"reactComponent\",\"name\":\"HubSpotForm\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SM_Hubspot_Form.map"],"mappings":"gUAAyK,SAAS,EAAe,EAAK,CAAC,IAAM,EAAM,SAAS,OAAO,MAAU,OAAO,QAAQ,EAAK,aAAa,OAAO,EAAM,mBAAmB,EAAM,IAAI,IAAM,CAC03B,SAAgB,EAAY,EAAM,CAAC,GAAK,CAAC,cAAY,aAAW,OAAK,SAAO,cAAY,SAAO,WAAS,gBAAc,CAAC,EAAW,CAAC,EAAM,EAAS,CAACA,EAAS,IAAS,CAAC,EAAoB,EAAuB,CAACA,EAAS,IAAY,CAAC,EAAa,EAAgB,CAACA,EAAS,iCAAiG,CAAC,EAAa,EAAgB,CAACA,EAAS,IAAY,CAAC,EAAe,EAAkB,CAACA,EAAS,MAAY,EAAe,GAAO,CAAC,GAAG,CAACC,GAAO,CAACA,EAAM,SAAS,KAAK,MAAO,GAAM,IAAM,EAAOA,EAAM,cAAc,MAAM,KAAK,GACpwD,OAAO,EAAuB,KAAK,GAAS,EAAO,SAAS,KAAW,EAAO,SAAS,OAAS,EAAC,MAAc,CAAC,GAAG,EAAM,CAAC,IAAM,EAAQ,EAAe,GAAO,EAAuB,GAAY,G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