1var p=Object.defineProperty;var q=(a,e,t)=>e in a?p(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var w=(a,e)=>p(a,"name",{value:e,configurable:!0});var v=(a,e,t)=>q(a,typeof e!="symbol"?e+"":e,t);import{G as d,P as b,c as S,D as y,S as k}from"./site-CYdTkHhN.js";const n=class n{demoRequestDrawer=document.querySelector("#demoRequestDrawer");demoRequestDrawerOverlay=document.querySelector("#demoRequestDrawerOverlay");iframeSelectorClass="demo-calendly-iframe";calendlyEmbedLoaded=!1;hostname="www.activecampaign.com";autoLaunchPagesRegex=[/^\/((br|de|es|fr|it)\/)?(enterprise\/)?demo$/];constructor(e,t){this.element=e,this.options={...n.Options,...t},d.on(b.IS_OPEN,this.closeDrawer.bind(this)),this.init()}init(){return this.createChildRefs().enable(),this}createChildRefs(){return this.demoFocusTrap=S(this.element,{allowOutsideClick:!0,preventScroll:!0}),this}async enable(){return this.setHostname(),["resize","scroll"].forEach(e=>window.addEventListener(e,()=>this.setDrawerPlacement())),this.initializeForm(),this.initializeDrawerLinks(),this.observeDynamicLinks(),this.initializeCloseButtons(),this.autoLaunchOnSpecificPages(),this}autoLaunchOnSpecificPages(){const e=window.location.pathname;this.autoLaunchPagesRegex.some(s=>s.test(e))&&setTimeout(()=>{this.openDrawer()},500)}initializeForm(){const e=document.querySelector("#demoFormSubmitBtn");e&&e.addEventListener("click",t=>{t.preventDefault();const s=document.querySelector("#demoForm"),E=s.querySelector(".demo-disclaimer"),f=this.demoRequestDrawer.querySelector(".demo-calendar-container");document.querySelectorAll(".error-msg").forEach(i=>{i.textContent="",i.classList.add("hidden")});let o=!0;const c=document.querySelector("#demo-name-field");c.value.trim()||(this.showError(c),o=!1);const l=document.querySelector("#demo-email-field");/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(l.value)||(this.showError(l),o=!1);const m=document.querySelector("#demo-phone-field");/^[0-9+\-\(\)\s]{10,}$/.test(m.value)||(this.showError(m),o=!1);const h=document.querySelector("#demo-contacts-field");if(h.value||(this.showError(h),o=!1),!o){e.classList.add("shake-animation"),e.classList.add("!bg-theme-color-error"),setTimeout(()=>{e.classList.remove("shake-animation"),e.classList.remove("!bg-theme-color-error")},500);return}const r=new URLSearchParams;r.append("name",c.value.trim()),r.append("email",l.value.trim()),r.append("contacts",h.value),r.append("phone",m.value.trim()),document.querySelector("#demo_messaging_consent").checked&&r.append("messaging_consent","1");const D=e.textContent;e.textContent=e.dataset.submitText||"Sending...",e.classList.add("sending"),e.style.pointerEvents="none",fetch(`https://${this.hostname}/enterprise/demo/request/index.php`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r.toString()}).then(async i=>{if(i.status===200){const u=await i.json();if(u&&u.success){const g=u.calendly_embed_url;s.style.display="none",E.classList.add("hidden"),this.setDrawerWidth(!0),f.innerHTML=`<iframe class="${this.iframeSelectorClass}" src="${g}" width="100%" height="700" frameborder="0" aria-live="polite"></iframe>`,f.classList.remove("hidden"),this.calendlyEmbedLoaded=!0,this.setDrawerHeaderVisibility(!1),this.initializeCalendlyListener(),this.trackEvent("form_complete"),e.classList.remove("sending")}}else throw new Error("Submission failed")}).catch(i=>{console.warn(i),e.textContent=D,e.style.pointerEvents="auto",e.classList.remove("sending")})})}setHostname(){window.location.hostname!=="www.activecampaign.com"&&(this.hostname="marketing.staging.app-us1.com")}setDrawerPlacement(){const e=document.querySelector("header.site-header");e&&(this.demoRequestDrawer.style.top=e.getBoundingClientRect().bottom+"px")}hideFormErrorMessages(){document.querySelectorAll(".error-msg").forEach(e=>{e.textContent="",e.classList.add("hidden")})}initializeDrawerLinks(){const e=document.querySelectorAll('a[href*="/enterprise/demo"],a[href*="/demo"]'),t=w(s=>{(s.button===0||s.button===1)&&(s.preventDefault(),this.openDrawer(),d.emit(k.SITE_NAV_CLOSE))},"handleAction");this.resetExistingDrawerLinkListeners(t),e.forEach(s=>
1{s.dataset.drawerLink="demo",s.addEventListener("click",t),s.addEventListener("auxclick",t)})}resetExistingDrawerLinkListeners(e){document.querySelectorAll('[data-drawer-link="demo"]').forEach(s=>{s.removeEventListener("click",e),s.removeEventListener("auxclick",e),s.removeAttribute("data-drawer-link")})}observeDynamicLinks(){new MutationObserver(t=>{for(const s of t)if(s.type==="childList"&&s.addedNodes.length>0){this.initializeDrawerLinks();break}}).observe(document.body,{childList:!0,subtree:!0})}initializeCloseButtons(){const e=document.querySelectorAll("[data-demo-drawer-close]");e&&e.forEach(t=>{t.addEventListener("click",()=>{this.closeDrawer()})}),window.addEventListener("keydown",t=>{t.key==="Escape"&&this.closeDrawer()})}setDrawerHeaderVisibility(e=!0){const t=document.querySelector(".drawer-content__header");t&&(e?t.classList.remove("hidden"):t.classList.add("hidden"))}openDrawer(){this.demoRequestDrawer&&this.demoRequestDrawerOverlay&&!this.demoRequestDrawer.classList.contains("open")&&(this.calendlyEmbedLoaded||(this.setDrawerWidth(),this.setDrawerHeaderVisibility(!0),this.hideFormErrorMessages()),this.animateDrawerOpening(),this.setDrawerPlacement(),this.demoFocusTrap.activate(),this.trackEvent("open"),d.emit(y.IS_OPEN))}closeDrawer(){this.demoRequestDrawer&&this.demoRequestDrawerOverlay&&this.demoRequestDrawer.classList.contains("open")&&(this.demoRequestDrawer.getAnimations(),this.animateDrawerClosing(),this.demoFocusTrap.deactivate(),d.emit(y.IS_CLOSED))}async animateDrawerClosing(){this.demoRequestDrawer.classList.add("closing"),this.demoRequestDrawerOverlay.classList.add("closing"),this.demoRequestDrawerOverlay.classList.remove("active"),await Promise.all(this.demoRequestDrawer.getAnimations().map(e=>e.finished)),this.demoRequestDrawerOverlay.classList.remove("closing"),this.demoRequestDrawer.classList.remove("open"),this.demoRequestDrawer.classList.remove("closing"),document.body.style.overflow="auto"}async animateDrawerOpening(){this.demoRequestDrawer.classList.remove("hidden"),this.demoRequestDrawer.classList.add("open"),this.demoRequestDrawerOverlay.classList.add("active")}setDrawerWidth(e=!1){e?this.demoRequestDrawer.classList.add("widened"):this.demoRequestDrawer.classList.remove("widened")}showError(e){const t=e.nextElementSibling;t&&(t.textContent=t.dataset.error,t.classList.remove("hidden"))}initializeCalendlyListener(){window.addEventListener("message",this.calendlyEventCallback.bind(this))}calendlyEventCallback(e){if(this.isCalendlyEvent(e)){const t=document.querySelector(`.${this.iframeSelectorClass}`)?.contentWindow;e.source===t&&(e.data.event==="calendly.date_and_time_selected"&&this.trackEvent("date_selected"),e.data.event==="calendly.event_scheduled"&&this.trackEvent("success"))}}isCalendlyEvent(e){return e.origin==="https://calendly.com"&&e.data.event?.startsWith("calendly.")}trackEvent(e){let t="";switch(e){case"open":t="demo_drawer_open";break;case"form_complete":t="demo_drawer_form_complete";break;case"date_selected":t="demo_drawer_date_selected";break;case"success":t="demo_drawer_success";break}window._satellite?t?window._satellite.track(t):console.warn(`Tracking event "${t}" not found.`):console.warn("Satellite is not defined."),t&&(window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:t}))}};w(n,"DemoDrawer"),v(n,"Attributes",{}),v(n,"Options",{});let L=n;export{L as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.