import{d as v,a as m,i as E,p as N,O as u,X as f,a6 as y,_ as g,Y as F,K as c,a7 as l,a8 as T}from"./EchoChannel-Dko4GTAA.js";import{_ as w}from"./EmptyWrapper.vue_vue_type_script_setup_true_lang-Bi_uAx49.js";const k={class:"hubspot__embed"},j=v({__name:"HubspotForm",props:{portalId:{},formId:{},contact:{},isPopup:{type:Boolean}},setup(b){const s=b,h=m(null),p=m(!1);function _(t){const o=[];function e(n){(n.tagName==="INPUT"||n.tagName==="SELECT"||n.tagName==="TEXTAREA")&&o.push(n);for(const i of n.childNodes)i.nodeType===Node.ELEMENT_NODE&&e(i)}return e(t),o}function a(t,o,e){t.name===o&&(t.value=e,t.dispatchEvent(new Event("input",{bubbles:!0})))}function I(t,o){t.forEach(e=>{a(e,"firstname",o.first_name),a(e,"lastname",o.last_name),a(e,"email",o.email),a(e,"jobtitle",o.job_title),a(e,"company",o.accountName),a(e,"country",o.countryName)})}const r=E("telemetryClient"),d=async()=>{const t=document.createElement("script");t.src="https://js.hsforms.net/forms/embed/v2.js",document.body.appendChild(t),t.addEventListener("load",()=>{if(window.hbspt){const o=window.hbspt.forms.create({region:"na1",portalId:s.portalId,formId:s.formId,target:`#target-${s.formId}`});o.onFormReady(e=>{s.contact&&I(_(e),s.contact)}),o.onFormSubmitted(()=>{r==null||r.hubspotForm(s.formId)})}})};return N(()=>{s.isPopup?document.querySelectorAll(`[data-hubspot-form-id="${s.formId}"]`).forEach(o=>{o.addEventListener("click",()=>{p.value=!0,r==null||r.hubspotFormPopupView(s.formId),d()})}):d()}),(t,o)=>(u(),f(T,{to:"body",disabled:!t.isPopup},[(u(),f(y(t.isPopup?g:w),{popup:p.value,"onUpdate:popup":o[1]||(o[1]=e=>p.value=!1)},{default:F(()=>[c("div",k,[o[0]||(l(-1,!0),(o[0]=c("div",{id:`target-${t.formId}`,ref_key:"hubspot__form",ref:h},null,8,["id"])).cacheIndex=0,l(1),o[0])])]),_:1},40,["popup"]))],8,["disabled"]))}});export{j as default};