function norm(e){return(null==e?"":String(e)).trim().toLowerCase()}async function sha256Hex(e){e=await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(e));return Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,"0")).join("")}window.dataLayer=window.dataLayer||[];const HS_FIELDS={first:"0-1/firstname",last:"0-1/lastname",email:"0-1/email",help:"0-1/how_did_you_hear_about_us___derris_",hear:"0-1/how_did_you_hear_about_us_",budget:"0-1/estimated_budget___"};function getVal(e,t){e=e.querySelector(`[name="${CSS.escape(t)}"]`);return e?e.value:""}function readFormFromScope(e){return{first_name:norm(getVal(e,HS_FIELDS.first)),last_name:norm(getVal(e,HS_FIELDS.last)),email:norm(getVal(e,HS_FIELDS.email)),help:norm(getVal(e,HS_FIELDS.help)),hear:norm(getVal(e,HS_FIELDS.hear)),budget:norm(getVal(e,HS_FIELDS.budget))}}function pushDataLayer(e){window.dataLayer.push({event:"hubspot_form_submission",form_type:e.form_type||"",first_name:e.first_name||"",last_name:e.last_name||"",email:e.email||"",email_hash:e.email_hash||"",help:e.help||"",hear:e.hear||"",budget:e.budget||"",page_url:window.location.href})}function bindWrappers(){document.querySelectorAll(".hsfc-FormWrapper").forEach(t=>{if(!t.__hsDlBound){t.__hsDlBound=!0,t.__hsPending=null,t.__hsPushed=!1,t.addEventListener("submit",async function(e){var e=e.target&&e.target.closest?e.target.closest("form"):null;e&&((e=readFormFromScope(e)).email_hash=e.email?await sha256Hex(e.email):"",e.form_type="New business",t.__hsPending=e)},!0);const a=new MutationObserver(function(){var e;t.__hsPushed||t.querySelector(".hsfc-PostSubmit")&&((e=t.__hsPending)&&(e.email||e.first_name||e.last_name)&&pushDataLayer(e),t.__hsPushed=!0,a.disconnect())});a.observe(t,{childList:!0,subtree:!0})}})}function initHsDl(){bindWrappers(),setTimeout(bindWrappers,250),setTimeout(bindWrappers,1e3),setTimeout(bindWrappers,2500)}function watchForHubSpotMounts(){window.__hsDlDomWatchStarted||(window.__hsDlDomWatchStarted=!0,new MutationObserver(()=>{bindWrappers()}).observe(document.documentElement,{childList:!0,subtree:!0}))}initHsDl(),watchForHubSpotMounts(),window.addEventListener("pageshow",initHsDl);