(()=>{"use strict";const n=document.createElement("span"),t=n.attachShadow({mode:"open"}),e=(n="N",e)=>{const o=document.createElement("script"),i=t.querySelector(".dommus-chat-whats-button"),a=t.querySelector(".dommus-chat-btn-close"),s=t.querySelector("#phone-number"),r=t.querySelector("#name-lead");function d(n){n.target.value.length>0&&e.classList.remove("error-input")}s.addEventListener("input",(function(n){const t=n.target,e=t.value.replace(/\D/g,""),o=e.slice(0,2),i=e.slice(2,7),a=e.slice(7,11);let s="";o&&(s+=`(${o})`),i&&(s+=` ${i}`),a&&(s+=`-${a}`),t.value=s})),s.addEventListener("change",d),r.addEventListener("change",d);const m=async()=>{const n=t.querySelector("#name-lead"),o=t.querySelector("#phone-number");let i=null;if("S"===e.collectEmail){if(i=t.querySelector("#lead-email"),!i?.value?.trim())return void i.classList.add("error-input");i&&i.classList&&i.classList.remove("error-input")}let a=o.value.replace(/\D/g,"");if((9!=Number(a[2])||11!=a.length)&&10!=a.length){o.classList.add("error-input");let n=t.querySelector(".dommus-form-send"),e=t.createElement("div");return e.classList.add("error-span"),e.innerText="O número de telefone informado não é válido! Ok.",e.addEventListener("click",(function(n){this.style.display="none",o.classList.remove("error-input")})),void n.appendChild(e)}o.classList.remove("error-input"),n.value.trim()&&a.trim()&&e.inquilino_token?e.confirmPhone?(t.querySelector(".dommus-form-box").style.display="none",Swal.fire({title:"Confirme o número de telefone",text:`${a}`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",cancelButtonText:"Cancelar",confirmButtonText:"Confirmar"}).then((async t=>{t.isConfirmed&&("S"===e.collectEmail?await l(n.value,a,i.value):await l(n.value,a),e.link&&(window.location.href=e.link))}))):(await l(n.value,a),e.link&&(window.location.href=e.link)):(n.value.trim()||n.classList.add("error-input"),o.value.trim()||o.classList.add("error-input"))},l=async(n,t,o=null)=>{e.inquilino_number.includes("+55")||e.inquilino_number.includes("55")||(e.inquilino_number="55"+e.inquilino_number);const i=encodeURIComponent(e.message??""),a=`https://wa.me/${e.inquilino_number}?text=${i}`;window.open(a,"_blank");const s={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({nome:n,telefone:t,id_midia:e.midia,id_campanha:e.campanha,id_origem:e.origem,url:window.location.href,id_canal:6})};"S"===e.collectEmail&&(s.body.email=o);const r=await fetch(`https://api.leads.dommus.com.br/webhook/forms/${e.inquilino_token}`,s);if(r.ok)return r.json()};if("S"===e.collectEmail){const n=t.querySelector(".dommus-chat-send-button-2");n&&n.addEventListener("click",m)}else{const n=t.querySelector(".dommus-chat-send-button");n&&n.addEventListener("click",m)}i.addEventListener("click",(function(){t.querySelector(".dommus-form-box").style.display="block";const n=t.querySelectorAll(".dommus-message-badge"),e=Array.from(n);setTimeout((()=>{e[0].style.display="block",e[0].classList.add("fade-in")}),100),setTimeout((()=>{e[1].style.display="block",e[1].classList.add("fade-in")}),700),setTimeout((()=>{e[2].style.display="block",e[2].classList.add("fade-in")}),1500)})),a.addEventListener("click",(function(){t.querySelector(".dommus-form-box").style.display="none";const n=t.querySelectorAll(".dommus-message-badge");Array.from(n).forEach((n=>{n.style.opacity=0,n.classList.remove("fade-in")}))})),t.appendChild(o)};class o{inquilino_name;inquilino_token;inquilino_number;midia;campanha;origem;origin;position;message;confirmPhone;link;collectEmail;mapHtml;classOrId;bottomAfter;leftAfter;alturaMensagens;constructor(n){this.position=n.position,this.inquilino_token=n.token,this.inquilino_name=n.name,this.inquilino_number=n.number,this.midia=n.midia,this.campanha=n.campanha,this.origem=n?.origem??n?.origin,this.message=n.message,this.confirmPhone=n.confirmPhone,this.link=n.link,this.collectEmail=n.collectEmail,this.mapHtml=n.mapHtml,this.classOrId=n.classOrId,this.bottomAfter=n.bottomAfter,this.leftAfter=n.leftAfter,this.alturaMensagens=n.alturaMensagens||null,this.setUpDommusShadow(),this.getFormStyle(),this.getButtonFormHtml(),this.getFormHtml(),this.getFormScript(),this.getIonIcons(),this.getSweetAlert()}setUpDommusShadow(){document.body.appendChild(n)}getFormStyle(){((n="R",e="N",o="N",i=null)=>{const a=document.createElement("template"),s=document.createElement("style");s.textContent=`\n\n\n :root{\n --dommus-whats-after-position-bottom:53px;\n --dommus-whats-after-position-left:42px;\n }\n\n .dommus-chat-whats-button{\n box-sizing: content-box !important;\n width: 45px !important;\n height: 45px !important;\n background-color: #25D366 !important;\n padding: 10px !important;\n border-radius: 50px !important;\n display: flex !important;\n justify-content: center !important;\n align-items: center !important;\n ${"N"===o?"position: fixed":"position:static"} !important;\n bottom: 20px !important;\n ${"R"===n?"right:10px":"left:10px"} !important;\n cursor: pointer !important;\n z-index: 1000000 !important;\n }\n\n .dommus-chat-whats-button::after{\n display:flex !important;\n justify-content:center !important;\n align-items: center !important;\n box-sizing: content-box !important;\n width: 16px !important;\n height: 16px !important;\n content: "1" !important;\n position: absolute !important;\n bottom:53px;\n left: 42px!important;\n background-color: #FF0000 !important;\n color: #FFF !important;\n font-weight: bold !important;\n border-radius: 50px !important;\n text-align: center !important;\n padding: 1px !important;\n animation: radar 3s linear infinite !important;\n }\n\n #dommus-whatsapp-icon{\n font-size: 40px;\n color: #fff;\n }\n\n .dommus-form-box{\n display:none;\n position: fixed !important;\n bottom: 14% !important;\n ${"R"===n?"right:10px":"left:10px"} !important;\n width: calc(100% - 20px) !important;\n max-width: ${"S"===e?"440px !important":"400px !important"};\n border:1px solid #ccc;\n box-shadow:1px 1px 4px #CCC;\n border-radius: 10px !important;\n z-index: 1000000 !important;\n }\n\n .dommus-form-header{\n display: flex !important;\n justify-content: space-between !important;\n background-color: #075E54 !important;\n color: #FFF !important;\n padding: 16px !important;\n border-top-right-radius:10px !important;\n border-top-left-radius:10px !important;\n }\n\n\n .dommus-form-header{\n font-family: Roboto, sans-serif !important;\n }\n\n .dommus-title-header{\n font-weight:bold !important;\n }\n\n .dommus-chat-btn-close{\n cursor: pointer !important;\n font-size:20px !important;\n font-weight:bold !important;\n }\n\n .dommus-message-form-box{\n background-color: #F0EFF0 !important;\n padding: 15px !important;\n height: ${i||"250px"} !important;\n\n }\n .dommus-badge-hour,\n .dommus-badge{\n font-family: 'Roboto', sans-serif !important;\n }\n\n .dommus-badge-hour{\n font-size:11px !important;\n color:#666 !important;\n }\n\n .dommus-message-badge{\n display: none;\n border: 1px solid #CCC !important;\n background-color: #FFF !important;\n border-top-right-radius: 26px !important;\n border-bottom-right-radius: 26px !important;\n border-bottom-left-radius: 26px !important;\n border-top-left-radius: -50px !important;\n padding: 16px !important;\n margin-bottom: 7px !important;\n }\n\n .dommus-form-send{\n display: flex;\n gap: 10px;\n background-color: #FFF;\n padding: 10px;\n }\n\n .dommus-form-send-row{\n width:100%;\n display: flex;\n flex-direction:row;\n gap: 5px;\n background-color: #FFF;\n padding: 10px 0px ;\n aling-items:center;\n }\n\n \n .dommus-form-send{\n flex-direction:column;\n }\n\n .dommus-chat-input{\n padding: 10px;\n border: 1px solid #CCC;\n border-radius: 20px;\n box-shadow: 1px 1px 4px #F2F2F2;\n outline: none;\n max-width: ${"S"===e?"100%":"140px"};\n max-height: 70px;\n }\n\n .dommus-chat-send-button-2,\n .dommus-chat-send-button{\n background-color: #075E54 !important;\n border: none !important;\n border-radius: 100px !important;\n display: flex !important;\n justify-content: center !important;\n cursor:pointer !important;\n }\n\n .dommus-box-email{\n width:100%;\n }\n\n .dommus-box-email input {\n width:100%;\n }\n .dommus-chat-send-button{\n height: 3.125rem !important;\n width: 3.125rem !important;\n\n }\n\n .dommus-chat-send-button-2{\n background-color: #075E54 !important;\n color:#FFF !important;\n padding:10px;\n\n }\n\n .error-span{\n width:100%;\n display:block;\n font-family:sans-serif;\n padding:10px !important;\n background-color: #FFF;\n color:#FF0000;\n border:1px solid #FF0000;\n border-radius:4px;\n cursor:pointer;\n\n }\n\n .btn-error-message-close{\n color:#FFF;\n position:relative;\n top:0;\n left:0;\n }\n\n .dommus-send-icon{\n color: #FFF !important;\n font-size: 28px !important;\n align-self: center !important;\n }\n\n @keyframes fade{\n 0%{\n opacity: 0;\n }\n 100%{\n opacity: 1;\n }\n }\n\n @keyframes radar {\n 0% {\n box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.4);\n }\n 25% {\n box-shadow: 0 0 0 30px rgba(255, 0, 0, 0);\n }\n 50% {\n box-shadow: 0 0 0 60px rgba(255, 0, 0, 0);\n }\n 75% {\n box-shadow: 0 0 0 90px rgba(255, 0, 0, 0);\n }\n 100% {\n box-shadow: 0 0 0 120px rgba(255, 0, 0, 0);\n }\n }\n\n\n .dommus-badge-hour-box{\n display:flex;\n justify-content:flex-end;\n }\n\n .fade-in{\n animation: fade 0.2s forwards;\n }\n\n .error-input{\n border: 1px solid #FF0000 !important;\n\n }\n\n @media screen and (max-width:692px) {\n .dommus-message-badge{\n width: 90%;\n }\n\n\n .dommus-badge{\n font-size: 11px;\n }\n\n\n .dommus-form-send{\n width: 100% !important;\n }\n\n\n .dommus-form-send-row{\n display: flex !important;\n gap:10px;\n flex-direction: column !important;\n }\n\n .dommus-chat-input{\n max-width: 100% !important;\n }\n \n\n .dommus-chat-send-button{\n width: 100% !important;\n height: auto !important;\n }\n }\n `,a.appendChild(s),t.appendChild(a)})(this.position,this.collectEmail,this.mapHtml,this.alturaMensagens)}getButtonFormHtml(){((n="N",e=null,o="58px",i="46px")=>{const a=document.createElement("div");a.classList.add("dommus-chat-whats-button");const s="http://www.w3.org/2000/svg",r=document.createElementNS(s,"svg");r.setAttribute("height","2.3rem"),r.setAttribute("xmlns","http://www.w3.org/2000/svg"),r.setAttribute("viewBox","0 0 448 512"),r.setAttribute("id","dommus-whatsapp-icon"),r.setAttribute("fill","white");const d=document.createElementNS(s,"path");d.setAttribute("d","M380.9 97.1C339 55.1 283.2 32 223.9 32c-122.4 0-222 99.6-222 222 0 39.1 10.2 77.3 29.6 111L0 480l117.7-30.9c32.4 17.7 68.9 27 106.1 27h.1c122.3 0 224.1-99.6 224.1-222 0-59.3-25.2-115-67.1-157zm-157 341.6c-33.2 0-65.7-8.9-94-25.7l-6.7-4-69.8 18.3L72 359.2l-4.4-7c-18.5-29.4-28.2-63.3-28.2-98.2 0-101.7 82.8-184.5 184.6-184.5 49.3 0 95.6 19.2 130.4 54.1 34.8 34.9 56.2 81.2 56.1 130.5 0 101.8-84.9 184.6-186.6 184.6zm101.2-138.2c-5.5-2.8-32.8-16.2-37.9-18-5.1-1.9-8.8-2.8-12.5 2.8-3.7 5.6-14.3 18-17.6 21.8-3.2 3.7-6.5 4.2-12 1.4-32.6-16.3-54-29.1-75.5-66-5.7-9.8 5.7-9.1 16.3-30.3 1.8-3.7.9-6.9-.5-9.7-1.4-2.8-12.5-30.1-17.1-41.2-4.5-10.8-9.1-9.3-12.5-9.5-3.2-.2-6.9-.2-10.6-.2-3.7 0-9.7 1.4-14.8 6.9-5.1 5.6-19.4 19-19.4 46.3 0 27.3 19.9 53.7 22.6 57.4 2.8 3.7 39.1 59.7 94.8 83.8 35.2 15.2 49 16.5 66.6 13.9 10.7-1.6 32.8-13.4 37.4-26.4 4.6-13 4.6-24.1 3.2-26.4-1.3-2.5-5-3.9-10.5-6.6z"),r.appendChild(d),a.appendChild(r),"S"===n&&e?((n,t,e="58px",o="46px")=>{let i=document.querySelector(n);i?(t.style.bottom=e,t.style.left=o,i.appendChild(t)):alert("Elemento não encontrado!")})(e,a,o,i):t.appendChild(a)})(this.mapHtml,this.classOrId,this.bottomAfter,this.leftAfter)}getFormHtml(){((n,e="N")=>{const o=document.createElement("div"),i=document.createElement("div"),a=document.createElement("div"),s=document.createElement("div"),r=document.createElement("div"),d=document.createElement("div");o.classList.add("dommus-form-box"),i.classList.add("dommus-form-header"),a.classList.add("dommus-message-form-box"),s.classList.add("dommus-form-send"),r.classList.add("dommus-form-send-row"),d.classList.add("dommus-box-email");const m=document.createElement("span"),l=document.createElement("span");l.classList.add("dommus-chat-btn-close"),l.innerHTML="x",m.innerText=`${n}`,m.classList.add("dommus-title-header"),i.appendChild(m),i.appendChild(l);const p=document.createElement("div"),c=document.createElement("div"),u=document.createElement("div"),h=document.createElement("div"),b=document.createElement("div"),g=document.createElement("div"),x=document.createElement("div"),f=document.createElement("span"),w=document.createElement("div"),y=document.createElement("span"),E=document.createElement("div"),C=document.createElement("span"),v=new Date;f.innerText=v.getHours()+":"+v.getUTCMinutes(),f.classList.add("dommus-badge-hour"),x.appendChild(f),x.classList.add("dommus-badge-hour-box"),y.innerText=v.getHours()+":"+v.getMinutes(),y.classList.add("dommus-badge-hour"),w.appendChild(y),w.classList.add("dommus-badge-hour-box"),C.innerText=v.getHours()+":"+v.getMinutes(),C.classList.add("dommus-badge-hour"),E.appendChild(C),E.classList.add("dommus-badge-hour-box"),p.classList.add("dommus-message-badge"),c.classList.add("dommus-badge"),u.classList.add("dommus-message-badge"),h.classList.add("dommus-badge"),b.classList.add("dommus-message-badge"),g.classList.add("dommus-badge"),c.innerHTML="Olá,seja bem-vindo",h.innerHTML="Estamos disponíveis para mais informações",g.innerHTML="Entre em contato via whatsapp",p.appendChild(c),u.appendChild(h),b.appendChild(g),p.appendChild(x),u.appendChild(w),b.appendChild(E),a.appendChild(p),a.appendChild(u),a.appendChild(b);const L=document.createElement("input"),F=document.createElement("input");let k=null;"S"===e&&(k=document.createElement("input"),k.classList.add("dommus-chat-input"),k.setAttribute("id","lead-email"),k.setAttribute("placeholder","Email"));const S=document.createElement("button"),q=document.createElement("ion-icon");L.classList.add("dommus-chat-input"),F.classList.add("dommus-chat-input"),L.setAttribute("placeholder","Nome"),F.setAttribute("placeholder","(DD) 0000-0000"),F.setAttribute("id","phone-number"),L.setAttribute("id","name-lead"),q.setAttribute("name","send"),q.classList.add("dommus-send-icon"),S.appendChild(q),r.appendChild(L),r.appendChild(F),s.appendChild(r),o.appendChild(i),o.appendChild(a),o.appendChild(s),"S"===e?(d.appendChild(k),s.appendChild(d),S.innerText="Enviar",S.classList.add("dommus-chat-send-button-2"),s.appendChild(S)):(S.classList.add("dommus-chat-send-button"),r.appendChild(S)),t.appendChild(o)})(this.inquilino_name,this.collectEmail)}getFormScript(){e(this.collectEmail,{link:this.link,midia:this.midia,campanha:this.campanha,origem:this.origem,classList:this.classList,confirmPhone:this.confirmPhone,inquilino_token:this.inquilino_token,inquilino_number:this.inquilino_number,message:this.message})}getIonIcons(){!function(n){var e=(o=n.scripts[n.scripts.length-1]).src.split("/");e.pop(),e.push("ionicons");var o,i=e.join("/");(o=n.createElement("script")).setAttribute("type","module"),o.src="https://unpkg.com/ionicons@4.5.10-0/dist/ionicons/ionicons.esm.js",n.head.appendChild(o),(o=n.createElement("script")).setAttribute("nomodule",""),o.src=i+"/ionicons.js",t.appendChild(o)}(document)}getSweetAlert(){var n;(n=document.createElement("script")).setAttribute("src","https://cdn.jsdelivr.net/npm/sweetalert2@11"),t.appendChild(n)}}const i={DommusFormFactory:n=>new o(n)};window.FACADES=i})();