(()=>{function B(C){let w=`; ${document.cookie}`.split(`; ${C}=`);if(w.length===2)return w.pop()?.split(";").shift()||null;return null}function H(C,y,w=30){let O=new Date;O.setTime(O.getTime()+w*24*60*60*1000);let U=`expires=${O.toUTCString()}`;document.cookie=`${C}=${y};${U};path=/`}async function N({apiUrl:C,urlParams:y,url:w,candidatePhoneNumbersOnPage:O}){let U=B("dni_visitor_id");return fetch(C,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({urlParams:y,visitorId:U||void 0,url:w,candidatePhoneNumbersOnPage:O})}).then((A)=>A.json())}function V(C,y=document){let{swapTargets:w,phoneNumber:O}=C,U=(R)=>R.replace(/\D/g,""),x=new Set,A=new Set;w.forEach((R)=>{x.add(U(R.nationalNumber)),A.add(U(R.e164))});let J=U(O.nationalNumber),M=U(O.e164),K=/(\+?1?[-.\s]?)?\(?\d{3}\)?[-.\s\w]*\d{3}[-.\s\w]*\d{4}|\+?1?\d{10}/g,$=(R)=>{if(x.has(R)||A.has(R))return!0;for(let v of x)if(R.endsWith(v)){for(let L of A)if(R.length===L.length)return!0}for(let v of x)if(R.includes(v))return!0;return!1},q=(R)=>{let v=U(R);if(!$(v))return R;let L;if(v.length>=11)L=M;else L=J;let Y="",z=0;for(let T=0;T{if(K.lastIndex=0,R.textContent)R.textContent=R.textContent.replace(K,q)});let S=y.querySelectorAll('a[href^="tel:"]'),h=(R)=>{let v=R.getAttribute("href")??"";try{return U(decodeURIComponent(v))}catch{return U(v)}};S.forEach((R)=>{let v=h(R);if($(v))R.href="tel:"+O.e164})}function F(C){return"fbp"in C&&"ev"in C}function W(C){let y=Object.fromEntries(new FormData(C).entries());if(F(y))return null;return y}function P(C,y){if(y.dni)y.dni.forEach(($)=>V($));I(y.sessionId);let w=new WeakSet,O=new WeakSet,U=()=>{return($)=>{let q=$.target;if(!q?.reportValidity())return;if(w.has(q))return;w.add(q);let E=W(q);if(!E)return;Z(C,y.sessionId,E)}};document.addEventListener("submit",U(),!0);let x=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){if(this.reportValidity()&&!w.has(this)){w.add(this);let $=W(this);if($)Z(C,y.sessionId,$)}return x.call(this)};let A=($)=>{if(O.has($))return;try{let q=$.contentDocument||$.contentWindow?.document;if(!q)return;if(O.add($),q.addEventListener("submit",U(),!0),y.dni)y.dni.forEach((E)=>V(E,q))}catch{}};document.querySelectorAll("iframe").forEach(($)=>{if($.contentDocument?.readyState==="complete")A($);else $.addEventListener("load",()=>A($))}),new MutationObserver(($)=>{for(let q of $)q.addedNodes.forEach((E)=>{if(E instanceof HTMLIFrameElement)if(E.contentDocument?.readyState==="complete")A(E);else E.addEventListener("load",()=>A(E));if(E instanceof HTMLFormElement)j(E,y.sessionId);if(E instanceof HTMLElement)E.querySelectorAll("iframe").forEach((_)=>{if(_.contentDocument?.readyState==="complete")A(_);else _.addEventListener("load",()=>A(_))}),E.querySelectorAll("form").forEach((_)=>{j(_,y.sessionId)})})}).observe(document.body,{childList:!0,subtree:!0});let M=!1,K=()=>{if(M)return;if(typeof window.jQuery<"u"&&typeof window.gform<"u")M=!0,window.jQuery(document).on("gform_confirmation_loaded",function($,q){let E=document.getElementById(`gform_${q}`);if(E&&!w.has(E)){w.add(E);let _=W(E);if(_)Z(C,y.sessionId,_)}})};if(K(),document.readyState==="loading")document.addEventListener("DOMContentLoaded",K);setTimeout(K,1000)}function j(C,y){if(C.querySelector('input[name="aim_session_id"]'))return;let w=document.createElement("input");w.type="hidden",w.name="aim_session_id",w.value=y,C.appendChild(w)}function I(C){document.querySelectorAll("form").forEach((y)=>{j(y,C)})}function Z(C,y,w){fetch(`${C}/form-submission`,{method:"POST",keepalive:!0,headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:y,formData:w,submissionUrl:window.location.href})})}var b=/(\+?1?[-.\s]?)?\(?\d{3}\)?[-.\s\w]*\d{3}[-.\s\w]*\d{4}|\+?1?\d{10}/g,G=(C)=>C.replace(/\D/g,"");function l(C=document){let y=[],w=new Set,O=(A)=>{if(!A||w.has(A))return;w.add(A),y.push(A)},U=C.createTreeWalker(C.body,NodeFilter.SHOW_TEXT,null),x;while(x=U.nextNode()){let A=x.parentElement;if(A&&(A.tagName==="SCRIPT"||A.tagName==="STYLE"))continue;let J=x.textContent;if(typeof J!=="string")continue;b.lastIndex=0;let M;while(M=b.exec(J))O(G(M[0]))}return C.querySelectorAll('a[href^="tel:"]').forEach((A)=>{let J=A.getAttribute("href")??"";try{O(G(decodeURIComponent(J)))}catch{O(G(J))}}),y}var u=document.currentScript;(async()=>{let C=u?.getAttribute("src");if(!C)return;let y=C.substring(0,C.lastIndexOf("/")),w=l(),O=await N({apiUrl:`${y}/session`,urlParams:window.location.search.substring(1),url:window.location.href,candidatePhoneNumbersOnPage:w});if(!O.success)return;H("dni_visitor_id",O.visitorId),P(y,O)})();})();