function UET(o){var n,i,t;this.stringExists=function(n){return n&&n.length>0},this.domain="bat.bing.com",this.URLLENGTHLIMIT=2048,this.pageLoadEvt="pageLoad",this.customEvt="custom",o.Ver=o.Ver!==undefined&&(o.Ver==="1"||o.Ver===1)?1:2,this.supportsCORS=this.supportsXDR=!1,this.validKeyNames={ec:1,el:1,ev:1,ea:1},this.validCustomEventKeyNames={ec:1,el:1,ev:1,ea:1,gv:1,gc:1},this.invalidKeyException="Invalid data: Key Name: ",this.invalidEventException="Invalid event type: Event Type: ",this.evq=o.q||[],delete o.q,this.evqDispatch=!1,this.pageLoadDispatch=!1,this.documentLoaded=!!document.body,this.eventPushQueue=[],n=this,this.sessionCookieName="_uetsid",this.sessionCookieValuePrefix="_uet",this.sessionExpirationTime=1800,this.domainName=null,this.checkuetHostdocumentload=function(){this.documentLoaded=!!document.body;if(n.documentLoaded){if(n.eventPushQueue.length>0){for(var t=0;tt.name?1:n.name=0?r:r+e;n.p=encodeURIComponent(o),n.r=encodeURIComponent(u)}return n},this.removeTrailingAmp=function(n){var t=n.charAt(n.length-1);return(t==="&"||t==="?")&&(n=n.substring(0,n.length-1)),n},this.throwError=function(n){if(typeof CustomEvent=="function"){var i={errMsg:n,tagId:o.ti},t=new CustomEvent("uetError",{detail:i});window.dispatchEvent(t)}throw n;},this.validateValue=function(n,t,i){var r=0,u=t,f=i===undefined||i===0?!0:!1;return t.toString().indexOf(",")!==-1&&(u=t.replace(/,/g,"")),r=parseFloat(u),(isNaN(u)||isNaN(r)||f&&r.toString().indexOf(".")!==-1)&&this.throwError(n+" should be "+(f?"an integer":"a number")),r>999999999999?this.throwError(n+" cannot be greater than 999999999999"):r<0?this.throwError(n+" cannot be less than 0"):this.getDecimalPlaces(r)>i&&this.throwError(n+" cannot have more than "+i+" decimal places"),r},this.validateCurrency=function(n){var t=n.toString();return t.match(/^[a-zA-Z]{3}$/)||this.throwError("gc value must be ISO standard currency code"),t},this.getDecimalPlaces=function(n){var i=parseFloat(n),t;if(isNaN(n)||isNaN(i))return 0;return t=(""+n).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/),t?Math.max(0,(t[1]?t[1].length:0)-(t[2]?+t[2]:0)):0},this.validateDataObject=function(n,t){var r,i;n||this.throwError(this.invalidEventException+"undefined event."),n!==this.pageLoadEvt&&n!==this.customEvt&&this.throwError(this.invalidEventException+n),t||this.throwError("undefined data object passed to validate");if(typeof t!="object")return;r=this.validKeyNames,n!==this.pageLoadEvt&&(r=this.validCustomEventKeyNames);for(i in t)r[i]||this.throwError(this.invalidKeyException+i);t.hasOwnProperty("ev")>0&&(t.ev=this.validateValue("ev",t.ev,3)),t.hasOwnProperty("gv")>0&&(t.gv=this.validateValue("gv",t.gv,3)),t.hasOwnProperty("gc")>0&&(t.gc=this.validateCurrency(t.gc))},this.evt=function(n,t){var i,r;if(n===this.pageLoadEvt&&this.pageLoadDispatch===!0)return;t=t||{};if(t instanceof Array)if(t.length>0)t=t[0];else return;if(typeof t!="object")return;this.validateDataObject(n,t);if(n===this.customEvt){i=[];for(r in t)i.push(r);if(i.length===0)return}this.invisibleDiv||this.createInvisibleDiv(document.body),t.evt=n,window.self!=window.top&&(t.ifm=1),t=this.addSessionId(t),n===this.pageLoadEvt&&(t=this.addPageData(t),this.pageLoadDispatch=!0),this.fireBeacon(t),t.abf=!0,n===this.pageLoadEvt&&this.evqDispatch===!1&&this.dispatchq()},this.getCookie=function(n){var t,i,u,r,f;if(!n)return null;t=document.cookie;if(t.length===0)return null;u=0;while(u0&&t[i-1]!==" "&&t[i-1]!==";")u=i+n.length+1;else break}return r=t.indexOf(";",i),r=r>=0?r:t.length,f=t.substring(i+n.length+1+this.sessionCookieValuePrefix.length,r),f.length>8?null:f},this._setCookie=function(n,t,i,r){document.cookie=n+"="+t+";expires="+i+(r?";domain=."+r:"")+";path=/"},this.setCookie=function(n,t,i,r){var o=new Date,s,e,f,u;o.setTime(o.getTime()+i*1e3),s=new Date,s.setTime(0);if(this.domainName===null){e=document.location&&document.location.hostname;if(e&&typeof e=="string"&&e!=="localhost"){f=e.split("."),u=f.pop(),f.length!==3||Number(u)<0||(f=[]);while(f.length>0){u=f.pop()+"."+u,r&&(this._setCookie(n,"",s.toUTCString(),u),r=!!this.getCookie(n));if(!r){this._setCookie(n,this.sessionCookieValuePrefix+t,o.toUTCString(),u);if(this.getCookie(n)){this.domainName=u;return}}}}this.domainName=""}this._setCookie(n,this.sessionCookieValuePrefix+t,o.toUTCString(),this.domainName)},this.addSessionId=function(n){if(o.Ver<2)return n;var t=this.getCookie(this.sessionCookieName),i="0";return t||(t=this._S4()+this._S4(),i="1"),this.setCookie(this.sessionCookieName,t,this.sessionExpirationTime,i==="0"),n.sid=this.getCookie(this.sessionCookieName)===t?t+"-"+i:"N",n},this.createIframe=function(n){return this.invisibleFrame=this.createInvisibleElement(n,"iframe"),this.invisibleFrame.src="",this.invisibleFrame.name=this.invisibleFrame.id,this.invisibleFrame.id},this.clone=function(n,t){t===undefined&&(t={});for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i]);return t},this.combine=function(n,t){var i=this.clone(n);return i.alt&&delete i.alt,i=this.clone(t,i)},this.addHiddenFields=function(n,t,i,r){var e="",u,f;r&&(e=r+".");for(u in n)n.hasOwnProperty(u)&&(typeof n[u]=="object"?this.addHiddenFields(n[u],t,i,e+u):(f=i.createElement("input"),f.setAttribute("type","hidden"),f.setAttribute("name",e+u),f.setAttribute("value",n[u]),t.appendChild(f)))},this.fireBeacon=function(n){var u=this.urlPrefix,f=this.postURL,t=this.combine(o,n),i=this.stringifyToRequest(t),r=this.removeTrailingAmp(u+i);encodeURI(r).length>this.URLLENGTHLIMIT&&(delete t.kw,i=this.stringifyToRequest(t),r=this.removeTrailingAmp(u+i)),encodeURI(r).length>this.URLLENGTHLIMIT&&(delete t.p,i=this.stringifyToRequest(t),r=this.removeTrailingAmp(u+i)),encodeURI(r).length>this.URLLENGTHLIMIT&&(delete t.tl,i=this.stringifyToRequest(t),r=this.removeTrailingAmp(u+i)),this.fireBeaconImg(r)}}