(()=>{function L(e){let n=`; ${document.cookie}`.split(`; ${e}=`);if(n.length===2)return n.pop()?.split(";").shift()||null;return null}function H(e,t,n=30){let o=new Date;o.setTime(o.getTime()+n*24*60*60*1000);let a=`expires=${o.toUTCString()}`;document.cookie=`${e}=${t};${a};path=/`}async function k({apiUrl:e,urlParams:t,url:n,candidatePhoneNumbersOnPage:o}){let a=L("dni_visitor_id");return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({urlParams:t,visitorId:a||void 0,url:n,candidatePhoneNumbersOnPage:o})}).then((s)=>s.json()).catch(()=>({success:!1}))}function S(e,t=document){let{swapTargets:n,phoneNumber:o}=e,a=(r)=>r.replace(/\D/g,""),l=new Set,s=new Set;n.forEach((r)=>{l.add(a(r.nationalNumber)),s.add(a(r.e164))});let d=a(o.nationalNumber),g=a(o.e164),p=/(\+?1?[-.\s]?)?\(?\d{3}\)?[-.\s\w]*\d{3}[-.\s\w]*\d{4}|\+?1?\d{10}/g,y=(r)=>{if(l.has(r)||s.has(r))return!0;for(let m of l)if(r.endsWith(m)){for(let f of s)if(r.length===f.length)return!0}for(let m of l)if(r.includes(m))return!0;return!1},P=(r)=>{let m=a(r);if(!y(m))return r;let f;if(m.length>=11)f=g;else f=d;let b="",w=0;for(let N=0;N{if(p.lastIndex=0,r.textContent)r.textContent=r.textContent.replace(p,P)});let u=t.querySelectorAll('a[href^="tel:"]'),c=(r)=>{let m=r.getAttribute("href")??"";try{return a(decodeURIComponent(m))}catch{return a(m)}};u.forEach((r)=>{let m=c(r);if(y(m))r.href="tel:"+o.e164})}function I(e){return`dni_swap_cache:${e}`}function v(e){return e.swapTargets.map((t)=>t.e164).sort().join(",")}function M(e){try{let t=window.localStorage.getItem(I(e));if(!t)return null;let n=JSON.parse(t);if(!Array.isArray(n)||n.length===0)return null;let o=Date.now();if(!n.every((l)=>typeof l.expiresAt==="string"&&new Date(l.expiresAt).getTime()>o))return window.localStorage.removeItem(I(e)),null;return n}catch{return null}}function A(e,t){try{window.localStorage.setItem(I(e),JSON.stringify(t))}catch{}}function _(e,t){return t.flatMap((n)=>{let o=e?.find((a)=>v(a)===v(n));if(!o)return[n];if(o.phoneNumber.e164===n.phoneNumber.e164)return[];return[{swapTargets:[...n.swapTargets,o.phoneNumber],phoneNumber:n.phoneNumber}]})}function V(e){return"fbp"in e&&"ev"in e}function x(e){let t=Object.fromEntries(new FormData(e).entries());if(V(t))return null;return t}function C(e,t,n=null){let o=null,a=(i,u)=>{if(o){O(e,o.sessionId,i,u);return}t.then((c)=>{if(c)O(e,c.sessionId,i,u)})},l=new WeakSet,s=new WeakSet,d=()=>(i)=>{let u=i.target;if(!u?.reportValidity())return;let c=R(u);if(l.has(u))return;l.add(u);let r=x(u);if(!r)return;a(c,r)};document.addEventListener("submit",d(),!0);let g=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){if(this.reportValidity()&&!l.has(this)){l.add(this);let i=R(this),u=x(this);if(u)a(i,u)}return g.call(this)};let p=(i)=>{if(s.has(i))return;try{let u=i.contentDocument||i.contentWindow?.document;if(!u)return;s.add(i),u.addEventListener("submit",d(),!0),t.then((c)=>{c?.dni?.forEach((r)=>S(r,u))})}catch{}},y=(i)=>{if(i.contentDocument?.readyState==="complete")p(i);else i.addEventListener("load",()=>p(i))};document.querySelectorAll("iframe").forEach(y),new MutationObserver((i)=>{for(let u of i)u.addedNodes.forEach((c)=>{if(c instanceof HTMLIFrameElement)y(c);if(c instanceof HTMLFormElement&&o)D(c,o.sessionId);if(c instanceof HTMLElement){if(c.querySelectorAll("iframe").forEach(y),o){let{sessionId:r}=o;c.querySelectorAll("form").forEach((m)=>{D(m,r)})}}})}).observe(document.body,{childList:!0,subtree:!0});let T=!1,E=()=>{if(T)return;if(typeof window.jQuery<"u"&&typeof window.gform<"u")T=!0,window.jQuery(document).on("gform_confirmation_loaded",function(i,u){let c=document.getElementById(`gform_${u}`);if(c&&!l.has(c)){l.add(c);let r=x(c);if(r)a(U(),r)}})};if(E(),document.readyState==="loading")document.addEventListener("DOMContentLoaded",E);return setTimeout(E,1000),t.then((i)=>{if(!i)return;if(o=i,_(n,i.dni??[]).forEach((c)=>S(c)),i.dni)A(e,i.dni);J(i.sessionId)})}function D(e,t){if(e.querySelector('input[name="aim_session_id"]'))return;let n=document.createElement("input");n.type="hidden",n.name="aim_session_id",n.value=t,e.appendChild(n)}function U(){return crypto.randomUUID?.()??B()}function B(){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,(n)=>n.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function R(e){let t=U(),n=e.querySelector('input[name="aim_submission_id"]');if(n)return n.value=t,t;let o=document.createElement("input");return o.type="hidden",o.name="aim_submission_id",o.value=t,e.appendChild(o),t}function J(e){document.querySelectorAll("form").forEach((t)=>{D(t,e)})}function O(e,t,n,o){fetch(`${e}/form-submission`,{method:"POST",keepalive:!0,headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:t,submissionId:n,formData:o,submissionUrl:window.location.href})})}var q=/(\+?1?[-.\s]?)?\(?\d{3}\)?[-.\s\w]*\d{3}[-.\s\w]*\d{4}|\+?1?\d{10}/g,F=(e)=>e.replace(/\D/g,"");function j(e=document){let t=[],n=new Set,o=(s)=>{if(!s||n.has(s))return;n.add(s),t.push(s)},a=e.createTreeWalker(e.body,NodeFilter.SHOW_TEXT,null),l;while(l=a.nextNode()){let s=l.parentElement;if(s&&(s.tagName==="SCRIPT"||s.tagName==="STYLE"))continue;let d=l.textContent;if(typeof d!=="string")continue;q.lastIndex=0;let g;while(g=q.exec(d))o(F(g[0]))}return e.querySelectorAll('a[href^="tel:"]').forEach((s)=>{let d=s.getAttribute("href")??"";try{o(F(decodeURIComponent(d)))}catch{o(F(d))}}),t}var K=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function W(){let e=document.querySelector('meta[name="sid"]')?.getAttribute("content");return e&&K.test(e)?e:null}var X=document.currentScript;(async()=>{let e=X?.getAttribute("src");if(!e)return;let t=e.substring(0,e.lastIndexOf("/")),n=W();if(n)return C(t,Promise.resolve({sessionId:n}));let o=j(),a=M(t);if(a)a.forEach((s)=>S(s));let l=k({apiUrl:`${t}/session`,urlParams:window.location.search.substring(1),url:window.location.href,candidatePhoneNumbersOnPage:o}).then((s)=>{if(!s.success)return null;return H("dni_visitor_id",s.visitorId),s});return C(t,l,a)})();})();