!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,(function(){"use strict";function e(e){var n=this.constructor;return this.then((function(t){return n.resolve(e()).then((function(){return t}))}),(function(t){return n.resolve(e()).then((function(){return n.reject(t)}))}))}function n(e){return!(!e||void 0===e.length)}function t(){}function o(e){if(!(this instanceof o))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],c(e,this)}function r(e,n){for(;3===e._state;)e=e._value;0!==e._state?(e._handled=!0,o._immediateFn((function(){var t=1===e._state?n.onFulfilled:n.onRejected;if(null!==t){var o;try{o=t(e._value)}catch(r){return void f(n.promise,r)}i(n.promise,o)}else(1===e._state?i:f)(n.promise,e._value)}))):e._deferreds.push(n)}function i(e,n){try{if(n===e)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var t=n.then;if(n instanceof o)return e._state=3,e._value=n,void u(e);if("function"==typeof t)return void c(function(e,n){return function(){e.apply(n,arguments)}}(t,n),e)}e._state=1,e._value=n,u(e)}catch(r){f(e,r)}}function f(e,n){e._state=2,e._value=n,u(e)}function u(e){2===e._state&&0===e._deferreds.length&&o._immediateFn((function(){e._handled||o._unhandledRejectionFn(e._value)}));for(var n=0,t=e._deferreds.length;t>n;n++)r(e,e._deferreds[n]);e._deferreds=null}function c(e,n){var t=!1;try{e((function(e){t||(t=!0,i(n,e))}),(function(e){t||(t=!0,f(n,e))}))}catch(o){if(t)return;t=!0,f(n,o)}}var a=setTimeout;o.prototype.catch=function(e){return this.then(null,e)},o.prototype.then=function(e,n){var o=new this.constructor(t);return r(this,new function(e,n,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.promise=t}(e,n,o)),o},o.prototype.finally=e,o.all=function(e){return new o((function(t,o){function r(e,n){try{if(n&&("object"==typeof n||"function"==typeof n)){var u=n.then;if("function"==typeof u)return void u.call(n,(function(n){r(e,n)}),o)}i[e]=n,0==--f&&t(i)}catch(c){o(c)}}if(!n(e))return o(new TypeError("Promise.all accepts an array"));var i=Array.prototype.slice.call(e);if(0===i.length)return t([]);for(var f=i.length,u=0;i.length>u;u++)r(u,i[u])}))},o.resolve=function(e){return e&&"object"==typeof e&&e.constructor===o?e:new o((function(n){n(e)}))},o.reject=function(e){return new o((function(n,t){t(e)}))},o.race=function(e){return new o((function(t,r){if(!n(e))return r(new TypeError("Promise.race accepts an array"));for(var i=0,f=e.length;f>i;i++)o.resolve(e[i]).then(t,r)}))},o._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){a(e,0)},o._unhandledRejectionFn=function(e){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)};var l=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw Error("unable to locate global object")}();"Promise"in l?l.Promise.prototype.finally||(l.Promise.prototype.finally=e):l.Promise=o})),function(root,factory){"function"==typeof define&&define.amd?define("calltrack",[],(function(){return root.CallTrack=factory()})):root.CallTrack=factory()}("undefined"!=typeof self?self:this,(function(){Array.prototype.findIndex=Array.prototype.findIndex||function(callback){if(null===this)throw new TypeError("Array.prototype.findIndex called on null or undefined");if("function"!=typeof callback)throw new TypeError("callback must be a function");for(var list=Object(this),length=list.length>>>0,thisArg=arguments[1],i=0;i<length;i++)if(callback.call(thisArg,list[i],i,list))return i;return-1};var CallTrack={association:17283,active:false,regex:"",continuousNumberSwap:false,defaultForwardTo:"",rules:[],brandedTerms:[""],ignoredIPs:[],imgPath:"",leaseNumbers:[],currentLeaseNumber:null,numbersToReplace:[],socialSites:{facebook:["facebook.com","fb.com","test.facebook.com"],twitter:["twitter.com","t.co","x.com"],linkedin:["linkedin.com","lnkd.in"],instagram:["instagram.com"],pinterest:["pinterest.com"],reddit:["reddit.com"],tiktok:["tiktok.com"],snapchat:["snapchat.com"],quora:["quora.com"],"google+":["googleplus.com","plus.google.com"],youtube:["youtube.com"],tumblr:["tumblr.com"],yelp:["yelp.com"]},ga:{term:null,source:null,medium:null},referrer:void 0,lastActive:new Date,setIntervals:[],init:function(){if(!this.active)return;if(this.visitorId=this.Cookie.get("__fx")||this.Cookie.get("fx_uuid"),this.visitSessionId=this.Cookie.get("mcfxVSID"),this.parseRules=this.parseRules.bind(this),this.replace=this.replace.bind(this),this.parseInfo=this.parseInfo.bind(this),this.getCurrentState=this.getCurrentState.bind(this),this.referrer=CallTrack._.getReferrer(),this.info().then(this.parseInfo).then(this.parseRules).then(this.replace),this.continuousNumberSwap){var origBody=document.body.innerHTML;setInterval((function(){origBody!=document.body.innerHTML&&(origBody=document.body.innerHTML,CallTrack.replace(CallTrack.rules))}),5e3)}this.setIntervals.forEach((v=>{clearInterval(v)})),this.setIntervals=[];let extendInterval=setInterval((function(){let seconds=((new Date).getTime()-CallTrack.lastActive.getTime())/1e3;("active"==CallTrack.getCurrentState()||seconds<=30)&&CallTrack.extendLease(),CallTrack.Cookie.get("fx_info",!0)||CallTrack.init()}),2e4);this.setIntervals.push(extendInterval);["focus","blur","visibilitychange","freeze","resume","pageshow"].forEach((evt=>{let el=addEventListener(evt,(function(e){"active"==CallTrack.getCurrentState()&&(CallTrack.lastActive=new Date)}),!0);this.setIntervals.push(el)}))},getCurrentState:function(){return"hidden"===document.visibilityState?"hidden":document.hasFocus()?"active":"passive"},info:function(){var vm=this;return new Promise((function(resolve,reject){var info=vm.Cookie.get("fx_info",!0),payload={};if(location.search)try{payload=Object.fromEntries(new URLSearchParams(window.location.search))}catch(e){console.log("Unable to parse search params: ",search)}if(payload.referrer=vm.referrer,CallTrack.ga||(CallTrack.ga=info),!info||payload.gclid||payload.wbraid||payload.gbraid||payload.msclkid||payload.fbclid)vm._.ajax({type:"POST",url:"https://t.marketingcloudfx.com/visitor",data:JSON.stringify(payload),headers:{"Content-Type":"application/json"}}).then((function(response){var info=JSON.parse(response);info?.landingPage||(info.landingPage=window.location.pathname),vm.Cookie.set("fx_info",info,{expires:7}),CallTrack.ga=info,resolve(info)}),(function(err){reject(err)}));else if(info.phoneLease?.id){let payload={action:"extend-lease",leaseId:info.phoneLease.id,visitSessionId:CallTrack.visitSessionId};vm._.ajax({type:"POST",url:"https://t.marketingcloudfx.com/ctfx-call-pool-leases",data:JSON.stringify(payload),headers:{"Content-Type":"application/json"}}).then((function(response){let lease=JSON.parse(response);lease?.expire_date&&vm.Cookie.set("fx_info",info,{expires:lease.expire_date}),resolve(info)}))}else resolve(info)}))},extendLease:async function(){let vm=this;var info=this.Cookie.get("fx_info",!0);if(!info?.phoneLease)return;let payload={action:"extend-lease",leaseId:info.phoneLease.id};CallTrack.visitSessionId=CallTrack.Cookie.get("mcfxVSID"),CallTrack.visitSessionId&&(payload.visitSessionId=CallTrack.visitSessionId);let response=await vm._.ajax({type:"POST",url:"https://t.marketingcloudfx.com/ctfx-call-pool-leases",data:JSON.stringify(payload),headers:{"Content-Type":"application/json"}}),lease=JSON.parse(response);return lease?.expire_date&&vm.Cookie.set("fx_info",info,{expires:lease.expire_date}),lease},parseInfo:function(info){CallTrack.ga=info;var source=CallTrack._.getUrlParameter("utm_source"),medium=CallTrack._.getUrlParameter("utm_medium");source?(CallTrack.ga.source=source,CallTrack.Cookie.set("utm_source",source,{expires:1})):CallTrack.Cookie.get("utm_source")&&(CallTrack.ga.source=CallTrack.Cookie.get("utm_source")),medium?(CallTrack.ga.medium=medium,CallTrack.Cookie.set("utm_medium",medium,{expires:1})):CallTrack.Cookie.get("utm_medium")&&(CallTrack.ga.medium=CallTrack.Cookie.get("utm_medium"));var fx_gclid=CallTrack.Cookie.get("gclid"),wbraid=CallTrack.Cookie.get("wbraid"),gbraid=CallTrack.Cookie.get("gbraid");return(fx_gclid&&"undefined"!=fx_gclid||wbraid&&"undefined"!=wbraid||gbraid&&"undefined"!=gbraid)&&(CallTrack.ga.source="google",CallTrack.ga.medium="ppc"),CallTrack.ga},parseRules:async function(){var cache=CallTrack.Cookie.get("MCFXNumberSwap",!0);if(cache)return CallTrack.numbersToReplace=CallTrack.addRegexRules(cache),cache;var numbersMatched=[],numbersToReplace=[];for(let i=0;i<CallTrack.rules.length;i++){let rule=CallTrack.rules[i];if(rule?.ctfx_number||(rule.ctfx_number=rule.replace),-1===numbersMatched.findIndex((function(number){return number===rule.number.join(":")}))&&(!CallTrack.ga?.phoneLease?.number||1==rule.usePool)&&CallTrack.matchRule(rule)){if(!0===rule.usePool){if(!CallTrack.ga?.phoneLease){let forwardTo=rule.forwardTo??CallTrack.defaultForwardTo,lease=await CallTrack.Queue.getNumber(rule.ctfx_number,forwardTo);lease?.number&&(CallTrack.currentLeaseNumber&&!rule.number.includes(rule.replace)&&rule.number.push(rule.replace),rule.replace=CallTrack.ga.phoneLease.number)}CallTrack.ga?.phoneLease?.number&&(rule.replace=CallTrack.ga.phoneLease.number,CallTrack.currentLeaseNumber=rule.replace,CallTrack.leaseNumbers.includes(rule.replace)||CallTrack.leaseNumbers.push(rule.replace))}numbersToReplace.push(rule),numbersMatched.push(rule.number.join(":"))}}try{numbersToReplace&&numbersToReplace.length&&!CallTrack.ga?.phoneLease?.number&&CallTrack.Cookie.set("MCFXNumberSwap",numbersToReplace,{expires:1})}catch(e){console.log("Err: ",e)}return CallTrack.numbersToReplace=CallTrack.addRegexRules(numbersToReplace),numbersToReplace},matchRule:function(rule){switch(rule.type){case"referral":return CallTrack.matchReferrer(rule);case"search":return CallTrack.matchSearch(rule);case"social":return CallTrack.matchSocial(rule);case"landingPage":return CallTrack.matchLandingPage(rule);case"urlParam":case"landingParam":return CallTrack.matchUrlParam(rule);case"cookie":return CallTrack.matchCookie(rule);case"direct":return CallTrack.isDirect(rule);case"source":return CallTrack.matchSource(rule);case"region":return CallTrack.matchRegion(rule);case"city":return CallTrack.matchCity(rule);case"country":return CallTrack.matchCountry(rule)}},replace:function(rules){if(rules&&0!==rules.length&&!(CallTrack.ignoredIPs.length>0&&-1!==CallTrack.ignoredIPs.indexOf(CallTrack.ga.ip))){var content=document.querySelector("body");if(content){for(var iterator=document.createNodeIterator(content,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,CallTrack.testNode,!0),node=iterator.nextNode();node;)node=iterator.nextNode();document.querySelectorAll(".img-phone-swap").forEach((function(image){image.setAttribute("src",CallTrack.numbersToReplace[0].imgPath)}))}else CallTrack.continuousNumberSwap||setTimeout((function(){CallTrack.replace(rules)}),100)}},testNode:function(node){if(![1,3].includes(node.nodeType))return NodeFilter.FILTER_SKIP;for(var i=0;i<CallTrack.numbersToReplace.length;i++){for(var rule=CallTrack.numbersToReplace[i],skipCauseEmpty=!1,n=0;n<rule.number.length;n++)if(!rule.number[n]||null===rule.number[n]||""===rule.number[n]||rule.number[n].length<2){skipCauseEmpty=!0;break}if(!skipCauseEmpty){if(1==node.nodeType){"string"==typeof node.href&&node.href.includes("tel:")&&("queue"===rule.replace.toLowerCase()?(CallTrack.Queue.type=rule.type,CallTrack.Queue.getNumber().then((function(number){if(number)return CallTrack.Queue.modifyReplacement(number,i)})).then((function(rule){CallTrack.modifyNodeHref(node,rule)}))):CallTrack.modifyNodeHref(node,rule));continue}if(rule.search.test(node.textContent)){"queue"===rule.replace.toLowerCase()?(CallTrack.Queue.type=rule.type,CallTrack.Queue.getNumber().then((function(number){if(number)return CallTrack.Queue.modifyReplacement(number,i)})).then((function(rule){CallTrack.modifyNode(node,rule)}))):CallTrack.modifyNode(node,rule);break}}}return NodeFilter.FILTER_ACCEPT},modifyNode:function(node,rule){if(node.nodeValue=node.nodeValue.replace(rule.search,rule.replace),void 0!==node.parentElement&&null!==node.parentElement){var href=node.parentElement.getAttribute("href");null!==href&&"tel:"===href.substr(0,4)&&node.parentElement.setAttribute("href","tel:"+rule.tel);let pp=node.parentElement;for(;void 0!==pp.parentElement&&null!==pp.parentElement;){let href=pp.parentElement.getAttribute("href");if(null!==href&&"tel:"===href.substr(0,4)){pp.parentElement.setAttribute("href","tel:"+rule.tel);break}pp=pp.parentElement}}},modifyNodeHref:function(node,rule){let newHref=node.href.replace(rule.search,rule.tel);newHref&&newHref!=node.href&&(node.href=newHref)},addRegexRules:function(rules){var re=/^\D?(\d{3})\D?\D?(\d{3})\D?(\d{4})/;return rules.map((function(rule){if("queue"===rule.replace.toLowerCase)return rule;var replace=rule.replace.replace("+1",""),combinedNumbers=rule.number.reduce(((acc,number)=>(acc.push(number.replace(/[-()+ ]/g,"")),acc)),[...rule.number]);rule.search=new RegExp(combinedNumbers.join("|").replace(/(?=[()+ ])/g,"\\"),"gi"),rule.replace=replace.replace(re,CallTrack.regex),rule.tel="+1"+replace.replace(re,"$1$2$3");var path=""===CallTrack.imgPath||"/"!==CallTrack.imgPath[CallTrack.imgPath.length-1]?CallTrack.imgPath+"/":CallTrack.imgPath;return rule.imgPath=path+replace.replace(re,"$1$2$3")+".png",rule}))},isOrganic:function(){return"organic"===CallTrack.ga.medium},isDirect:function(){return"direct"===CallTrack.ga.source},isBranded:function(){if(null!=CallTrack.ga?.term)for(var j=0;j<CallTrack.brandedTerms.length;j++)if(-1!=CallTrack.ga.term.toLowerCase().indexOf(CallTrack.brandedTerms[j].toLowerCase()))return!0;return!1},isPPC:function(){return"ppc"===CallTrack.ga.medium||"cpc"===CallTrack.ga.medium},matchReferrer:function(rule){return"all"===rule.match||null!=CallTrack.referrer&&-1!=CallTrack.referrer.indexOf(rule.match)},matchSearch:function(rule){return!!(CallTrack.matchSource(rule)&&CallTrack.matchMedium(rule)&&CallTrack.matchSegment(rule))},matchMedium:function(rule){var match=rule.match;void 0!==rule.matchValue&&(match=rule.matchValue.split("-")[0].trim());return"all"===match||("organic"===match?CallTrack.isOrganic():"paid"===match||"ppc"===match?CallTrack.isPPC():"notprov"===match?CallTrack.matchSegment("notprov"):void 0)},matchSegment:function(rule){var match=rule.match;void 0!==rule.matchValue&&(match=rule.matchValue.split("-")[1].trim());return"all"===match||("branded"===match?CallTrack.isBranded():"unbranded"===match?!CallTrack.isBranded():"notprov"===match?"not provided"===CallTrack.ga.term:"not provided"!==CallTrack.ga.term&&void 0)},matchSocial:function(rule){if(CallTrack.ga){const isSocial=CallTrack.ga.medium?.includes("social"),isSocialPaid=CallTrack.ga.medium?.includes("paid");let isSameMedium=!1;if(rule.matchValue&&"all"!==rule.matchValue?"paid"===rule.matchValue&&isSocialPaid?isSameMedium=!0:"organic"!==rule.matchValue||isSocialPaid||(isSameMedium=!0):isSameMedium=!0,!isSameMedium)return!1;if(CallTrack.ga.source&&rule.match.toLowerCase()===CallTrack.ga.source.toLowerCase())return!0;if(CallTrack.ga.source&&CallTrack.socialSites[rule.match]?.includes(CallTrack.ga.source.toLowerCase()))return!0;if("all"==rule.match){if(isSocial)return!0;if(CallTrack.ga.source&&CallTrack.socialSites[CallTrack.ga.source.toLowerCase()])return!0}}if(!CallTrack.referrer||""==CallTrack.referrer)return!1;var referringDomain=CallTrack.referrer.split("/")[2];if(!(referringDomain=referringDomain.replace(/^www\./i,""))||""==referringDomain)return!1;if("all"!==rule.match)return-1!==CallTrack.socialSites[rule.match].findIndex((function(d){return d===referringDomain}));for(var domains in CallTrack.socialSites)if(-1!==CallTrack.socialSites[domains].findIndex((function(d){return d===referringDomain})))return!0;return!1},matchLandingPage:function(rule){let info=CallTrack.Cookie.get("fx_info",!0);return(info?.landingPage?info.landingPage:window.location.pathname)==rule.match},matchUrlParam:function(rule){var param=CallTrack._.getUrlParameter(rule.match);return null!==param&&(""===param||-1!==param.indexOf(rule.matchValue))},matchCookie:function(rule){var param=CallTrack.Cookie.get(rule.match);return null!==param&&(""===param||-1!==param.indexOf(rule.matchValue))},matchRegion:function(rule){return"equals"!==rule.matchValue?rule.match.toLowerCase()!==CallTrack.ga.location.region:rule.match.toLowerCase()===CallTrack.ga.location.region},matchCity:function(rule){var isCity,isRegion,matchTo=rule.match.toLowerCase().split(",");return"equals"!==rule.matchValue?2===matchTo.length?(isCity=matchTo[0].toLowerCase().trim()===CallTrack.ga?.location?.city?.toLowerCase()?.trim(),isRegion=matchTo[1].toLowerCase().trim()===CallTrack.ga?.location?.region?.toLowerCase()?.trim(),!isCity||!isRegion):matchTo[0].toLowerCase().trim()!==CallTrack.ga?.location?.city?.toLowerCase()?.trim():2===matchTo.length?(isCity=matchTo[0].toLowerCase().trim()===CallTrack.ga?.location?.city?.toLowerCase()?.trim(),isRegion=matchTo[1].toLowerCase().trim()===CallTrack.ga?.location?.region?.toLowerCase()?.trim(),isCity&&isRegion):matchTo[0].toLowerCase().trim()===CallTrack.ga?.location?.city?.toLowerCase()?.trim()},matchCountry:function(rule){return"equals"!==rule.matchValue?rule.match.toUpperCase()!==CallTrack.ga.location.country:rule.match.toUpperCase()===CallTrack.ga.location.country},matchSource:function(rule){return"all"===rule.match||("google"===rule.match&&"adwords"===CallTrack.ga.source||CallTrack.ga.source==rule.match)},Cookie:{converter:function(){},defaults:{path:"/"},set:function(key,value,attributes){if("undefined"!=typeof document){"number"==typeof(attributes=CallTrack.Cookie.extend({domain:"."+CallTrack._.getDomainName()},CallTrack.Cookie.defaults,attributes)).expires&&(attributes.expires=new Date(1*new Date+864e5*attributes.expires)),"string"==typeof attributes.expires&&(attributes.expires=new Date(attributes.expires)),attributes.expires=attributes.expires?attributes.expires.toUTCString():"";try{var result=JSON.stringify(value);/^[\{\[]/.test(result)&&(value=result)}catch(e){}value=CallTrack.Cookie.converter.write?CallTrack.Cookie.converter.write(value,key):encodeURIComponent(String(value)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),key=encodeURIComponent(String(key)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var stringifiedAttributes="";for(var attributeName in attributes)attributes[attributeName]&&(stringifiedAttributes+="; "+attributeName,!0!==attributes[attributeName]&&(stringifiedAttributes+="="+attributes[attributeName].split(";")[0]));return document.cookie=key+"="+value+stringifiedAttributes}},get:function(key,json){if("undefined"!=typeof document){for(var jar={},cookies=document.cookie?document.cookie.split("; "):[],i=0;i<cookies.length;i++){var parts=cookies[i].split("="),cookie=parts.slice(1).join("=");json||'"'!==cookie.charAt(0)||(cookie=cookie.slice(1,-1));try{var name=CallTrack.Cookie.decode(parts[0]);if(cookie=(CallTrack.Cookie.converter.read||CallTrack.Cookie.converter)(cookie,name)||CallTrack.Cookie.decode(cookie),json)try{cookie=JSON.parse(cookie)}catch(e){}if(jar[name]=cookie,key===name)break}catch(e){}}return key&&!jar.hasOwnProperty(key)?null:key?jar[key]:jar}},extend:function(){for(var i=0,result={};i<arguments.length;i++){var attributes=arguments[i];for(var key in attributes)result[key]=attributes[key]}return result},decode:function(s){return s.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}},Queue:{type:null,getNumber:async function(ctfxNumber,forwardTo){if(CallTrack.visitorId||(CallTrack.visitorId=CallTrack.Cookie.get("__fx")||CallTrack.Cookie.get("fx_uuid")),CallTrack.visitSessionId||(CallTrack.visitSessionId=CallTrack.Cookie.get("mcfxVSID")),!CallTrack.visitorId)for(let x=0;x<5&&(await new Promise((resolve=>setTimeout(resolve,100))),CallTrack.visitorId=CallTrack.Cookie.get("__fx")||CallTrack.Cookie.get("fx_uuid"),CallTrack.visitSessionId=CallTrack.Cookie.get("mcfxVSID"),!CallTrack.visitorId);x++);if(CallTrack.visitorId)return new Promise((function(resolve,reject){let payload={action:"get-lease",source:CallTrack.ga?.source,medium:CallTrack.ga?.medium,visitorId:CallTrack.visitorId,visitSessionId:CallTrack.visitSessionId,siteId:CallTrack.association,ctfxNumber:ctfxNumber,forwardTo:forwardTo},adClickParameters=["gclid","wbraid","gbraid","msclkid","fbclid"];try{let ls=window.localStorage;if(CallTrack.Cookie.get("gclid"))payload.ad_click_id=CallTrack.Cookie.get("gclid"),payload.ad_click_parameter="gclid";else if(CallTrack.Cookie.get("wbraid"))payload.ad_click_id=CallTrack.Cookie.get("wbraid"),payload.ad_click_parameter="wbraid";else if(CallTrack.Cookie.get("gbraid"))payload.ad_click_id=CallTrack.Cookie.get("gbraid"),payload.ad_click_parameter="gbraid";else if(ls&&ls.getItem("__fx")){let fx=ls.getItem("__fx");if(fx=JSON.parse(fx),fx?.attribution?.ad?.id)payload.ad_click_id=fx.attribution.ad.id,payload.ad_click_parameter=fx.attribution.ad.parameter;else for(let i=0;i<adClickParameters.length;i++){let p=adClickParameters[i];if(fx&&fx[p]){payload.ad_click_id=fx[p],payload.ad_click_parameter=p;break}}fx?.sid&&(CallTrack.visitSessionId=fx.sid,payload.visitSessionId=fx.sid)}const fxInfo=CallTrack.Cookie.get("fx_info");if(!payload.ad_click_id&&fxInfo){let fx=fxInfo;fx=JSON.parse(fx);for(let i=0;i<adClickParameters.length;i++){let p=adClickParameters[i];if(fx&&fx[p]){payload.ad_click_id=fx[p],payload.ad_click_parameter=p;break}}}}catch(e){console.log("Error: ",e)}CallTrack._.ajax({type:"POST",url:"https://t.marketingcloudfx.com/ctfx-call-pool-leases",data:JSON.stringify(payload),headers:{"Content-type":"application/json"}}).then((function(response){let lease="";try{lease=JSON.parse(response)}catch(e){console.log("Error parsing response: ",response)}lease&&(CallTrack.ga.phoneLease=lease,lease?.expire_date&&CallTrack.Cookie.set("fx_info",CallTrack.ga,{expires:lease.expire_date})),resolve(lease)}),(function(err){reject(err)}))}))},modifyReplacement:function(number,ruleIndex){var rules=CallTrack.Cookie.get("MCFXNumberSwap",!0);return rules[ruleIndex].replace=number,CallTrack.Cookie.set("MCFXNumberSwap",rules,{expires:7}),CallTrack.numbersToReplace=CallTrack.addRegexRules(rules),rules[ruleIndex]},generateUniqueRequest:function(){var request=null;if(null==CallTrack.Cookie.get("ctfxRequest")||CallTrack.Queue.isExpired()){var visits=Number(CallTrack.Cookie.get("fx_count")),id=CallTrack.Cookie.get("fx_uuid"),type=CallTrack.Queue.type,data="";data+="ga_count="+visits+"&",data+="ga_id="+id+"&",data+="page="+window.location.href.replace(/^(?:\/\/|[^\/]+)*/,"")+"&",data+="&fx_document_title="+encodeURIComponent(document.title),data+="&fx_referrer="+encodeURIComponent(CallTrack._.getReferrer()),data+="&type="+type,CallTrack.Cookie.set("ctfxRequest",data,{expires:730}),request=data}else request=CallTrack.Cookie.get("ctfxRequest");return request},isExpired:function(){var expires=CallTrack.Cookie.get("ctfxExpires");return null==expires||parseInt((new Date).getTime()/1e3)-parseInt(expires)>0}},_:{getUrlParameter:function(name){name=name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var results=new RegExp("[\\?&]"+name+"=([^&#]*)").exec(location.search);return null===results?null:decodeURIComponent(results[1].replace(/\+/g," "))},getReferrer:function(){var ref=document.referrer,cookieRef=CallTrack.Cookie.get("fx_referrer");return null!=cookieRef?ref=cookieRef:CallTrack.Cookie.set("fx_referrer",ref,{expires:7}),ref},ajax:function(args){return args.type=args.type.toUpperCase()||"GET",new Promise((function(resolve,reject){var req=new XMLHttpRequest;req.open(args.type,args.url),args.headers&&Object.keys(args.headers).forEach((function(header){req.setRequestHeader(header,args.headers[header])})),req.onload=function(){200==req.status?resolve(req.response):reject(Error(req.statusText))},req.onerror=function(){reject(Error("Network Error"))},args.data?req.send(args.data):req.send()}))},uuid4:function(options,buf,offset){var i=buf&&offset||0;"string"==typeof options&&(buf="binary"===options?new Array(16):null,options=null);var rnds=(options=options||{}).random||(options.rng||CallTrack._.rng)();if(rnds[6]=15&rnds[6]|64,rnds[8]=63&rnds[8]|128,buf)for(var ii=0;ii<16;++ii)buf[i+ii]=rnds[ii];return buf||CallTrack._.bytesToUuid(rnds)},bytesToUuid:function(buf,offset){if(!this.byteToHex){this.byteToHex=[];for(var i=0;i<256;++i)this.byteToHex[i]=(i+256).toString(16).substr(1)}i=offset||0;var bth=this.byteToHex;return[bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]]].join("")},rng:function(){var getRandomValues="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(getRandomValues){var rnds8=new Uint8Array(16);return getRandomValues(rnds8),rnds8}for(var r,rnds=new Array(16),i=0;i<16;i++)3&i||(r=4294967296*Math.random()),rnds[i]=r>>>((3&i)<<3)&255;return rnds},getDomainName:function(){if(void 0!==CallTrack._.domain&&""!==CallTrack._.domain)return CallTrack._.domain;for(var i=0,domain=document.domain,p=domain.split("."),s="_gd"+(new Date).getTime();i<p.length-1&&-1==document.cookie.indexOf(s+"="+s);)domain=p.slice(-1-++i).join("."),document.cookie=s+"="+s+";domain="+domain+";";return document.cookie=s+"=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain="+domain+";",CallTrack._.domain=domain,CallTrack._.domain}}};return CallTrack.init(),CallTrack}));