countly-sdk-web-cip
Version:
Countly Web SDK
80 lines (79 loc) • 41.1 kB
JavaScript
(function(d,z){"function"===typeof define&&define.amd?define([],function(){return z(d.Countly)}):"object"===typeof module&&module.exports?module.exports=z(d.Countly):d.Countly=z(d.Countly)})("undefined"!==typeof window?window:this,function(d){function z(b){var d=[];if("undefined"!==typeof b.options)for(var h=0;h<b.options.length;h++)b.options[h].selected&&d.push(b.options[h].value);return d.join(", ")}function pa(){var b=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,
function(d){var h=(b+16*Math.random())%16|0;b=Math.floor(b/16);return("x"===d?h:h&3|8).toString(16)})}function m(){return Math.floor((new Date).getTime()/1E3)}function ba(){var b=(new Date).getTime();B>=b?B++:B=b;return B}function h(b,n,h){if(n&&Object.keys(n).length){if("undefined"!==typeof n[b])return n[b]}else if("undefined"!==typeof d[b])return d[b];return h}function ca(b,n,h){for(var k in d.i)d.i[k].tracking_crashes&&d.i[k].recordError(b,n,h)}function qa(b){var d=[],h;for(h in b)d.push(h+"="+
encodeURIComponent(b[h]));return d.join("&")}function da(b){return"/"===b.substr(b.length-1)?b.substr(0,b.length-1):b}function C(b,d){for(var h={},k,m=0;m<d.length;m++)k=d[m],"undefined"!==typeof b[k]&&(h[k]=b[k]);return h}function ea(b){"undefined"===typeof b.pageY&&("number"===typeof b.clientX&&document.documentElement)&&(b.pageX=b.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,b.pageY=b.clientY+document.body.scrollTop+document.documentElement.scrollTop);return b}function T(){var b=
document;return Math.max(Math.max(b.body.scrollHeight,b.documentElement.scrollHeight),Math.max(b.body.offsetHeight,b.documentElement.offsetHeight),Math.max(b.body.clientHeight,b.documentElement.clientHeight))}function fa(){var b=document;return Math.max(Math.max(b.body.scrollWidth,b.documentElement.scrollWidth),Math.max(b.body.offsetWidth,b.documentElement.offsetWidth),Math.max(b.body.clientWidth,b.documentElement.clientWidth))}function ra(){var b=document;return Math.min(Math.min(b.body.clientHeight,
b.documentElement.clientHeight),Math.min(b.body.offsetHeight,b.documentElement.offsetHeight),window.innerHeight)}function sa(b){if(b)for(var d in b)if(Object.prototype.hasOwnProperty.call(b,d))return!0;return!1}function Q(b,d,h,k,m,z){var b=document.createElement(b),C;b.setAttribute(d,h);b.setAttribute(k,m);z&&(b.onreadystatechange=b.onload=function(){C||z();C=!0});document.getElementsByTagName("head")[0].appendChild(b)}function ta(b,d){Q("script","type","text/javascript","src",b,d)}function ga(b,
d){Q("link","rel","stylesheet","href",b,d)}function ua(){var b=document.getElementById("cly-loader");if(!b){var b=document.head||document.getElementsByTagName("head")[0],d=document.createElement("style");d.type="text/css";d.styleSheet?d.styleSheet.cssText="#cly-loader {height: 4px; width: 100%; position: absolute; z-index: 99999; overflow: hidden; background-color: #fff; top:0px; left:0px;}#cly-loader:before{display: block; position: absolute; content: ''; left: -200px; width: 200px; height: 4px; background-color: #2EB52B; animation: cly-loading 2s linear infinite;}@keyframes cly-loading { from {left: -200px; width: 30%;} 50% {width: 30%;} 70% {width: 70%;} 80% { left: 50%;} 95% {left: 120%;} to {left: 100%;}}":
d.appendChild(document.createTextNode("#cly-loader {height: 4px; width: 100%; position: absolute; z-index: 99999; overflow: hidden; background-color: #fff; top:0px; left:0px;}#cly-loader:before{display: block; position: absolute; content: ''; left: -200px; width: 200px; height: 4px; background-color: #2EB52B; animation: cly-loading 2s linear infinite;}@keyframes cly-loading { from {left: -200px; width: 30%;} 50% {width: 30%;} 70% {width: 70%;} 80% { left: 50%;} 95% {left: 120%;} to {left: 100%;}}"));
b.appendChild(d);b=document.createElement("div");b.setAttribute("id","cly-loader");document.body.appendChild(b)}b.style.display="block"}function va(){var b=document.getElementById("cly-loader");b&&(b.style.display="none")}if("undefined"!==typeof window){d=d||{};d.features="sessions events views scrolls clicks forms crashes attribution users star-rating location apm feedback remote-config".split(" ");d.utm={source:!0,medium:!0,campaign:!0,term:!0,content:!0};d.q=d.q||[];d.onload=d.onload||[];var ha=
"20.11.3",wa="javascript_native_web",xa=/^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/,Ha=/(CountlySiteBot|nuhk|Googlebot|GoogleSecurityScanner|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver|bingbot|Google Web Preview|Mediapartners-Google|AdsBot-Google|Baiduspider|Ezooms|YahooSeeker|AltaVista|AVSearch|Mercator|Scooter|InfoSeek|Ultraseek|Lycos|Wget|YandexBot|Yandex|YaDirectFetcher|SiteBot|Exabot|AhrefsBot|MJ12bot|TurnitinBot|magpie-crawler|Nutch Crawler|CMS Crawler|rogerbot|Domnutch|ssearch_bot|XoviBot|netseer|digincore|fr-crawler|wesee|AliasIO|contxbot|PingdomBot|BingPreview|HeadlessChrome)/;
d.CountlyClass=function(b){function n(a){if(!f.ignore_visitor)if(a.key){a.count||(a.count=1);var e=C(a,["key","count","sum","dur","segmentation"]);e.timestamp=ba();var g=new Date;e.hour=g.getHours();e.dow=g.getDay();s.push(e);i("cly_event",s);j("Adding event: ",a)}else j("Event must have key property")}function oa(){f.ignore_prefetch&&("undefined"!==typeof document.visibilityState&&"prerender"===document.visibilityState)&&(f.ignore_visitor=!0);f.ignore_bots&&Ha.test(navigator.userAgent)&&(f.ignore_visitor=
!0)}function B(a,e){if(!document.getElementById("countly-feedback-sticker-"+a._id))try{var g=document.createElement("div");g.className="countly-iframe-wrapper";g.id="countly-iframe-wrapper-"+a._id;var b=document.createElement("span");b.className="countly-feedback-close-icon";b.id="countly-feedback-close-icon-"+a._id;b.innerText="x";var d=document.createElement("iframe");d.name="countly-feedback-iframe";d.id="countly-feedback-iframe";d.src=f.url+"/feedback?widget_id="+a._id+"&app_key="+f.app_key+"&device_id="+
f.device_id+"&sdk_version="+ha;document.body.appendChild(g);g.appendChild(b);g.appendChild(d);k(document.getElementById("countly-feedback-close-icon-"+a._id),"click",function(){document.getElementById("countly-iframe-wrapper-"+a._id).style.display="none";document.getElementById("cfbg").style.display="none"});if(e){var c=document.createElementNS("http://www.w3.org/2000/svg","svg");c.id="feedback-sticker-svg";c.setAttribute("aria-hidden","true");c.setAttribute("data-prefix","far");c.setAttribute("data-icon",
"grin");c.setAttribute("class","svg-inline--fa fa-grin fa-w-16");c.setAttribute("role","img");c.setAttribute("xmlns","http://www.w3.org/2000/svg");c.setAttribute("viewBox","0 0 496 512");var q=document.createElementNS("http://www.w3.org/2000/svg","path");q.id="smileyPathInStickerSvg";q.setAttribute("fill","white");q.setAttribute("d","M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm105.6-151.4c-25.9 8.3-64.4 13.1-105.6 13.1s-79.6-4.8-105.6-13.1c-9.9-3.1-19.4 5.4-17.7 15.3 7.9 47.1 71.3 80 123.3 80s115.3-32.9 123.3-80c1.6-9.8-7.7-18.4-17.7-15.3zM168 240c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32z");
var i=document.createElement("span");i.innerText=a.trigger_button_text;var h=document.createElement("div");h.style.color=7>a.trigger_font_color?"#"+a.trigger_font_color:a.trigger_font_color;h.style.backgroundColor=7>a.trigger_bg_color.length?"#"+a.trigger_bg_color:a.trigger_bg_color;h.className="countly-feedback-sticker "+a.trigger_position+"-"+a.trigger_size;h.id="countly-feedback-sticker-"+a._id;c.appendChild(q);h.appendChild(c);h.appendChild(i);document.body.appendChild(h);var n=document.getElementById("smileyPathInStickerSvg");
n&&(n.style.fill=7>a.trigger_font_color?"#"+a.trigger_font_color:a.trigger_font_color);k(document.getElementById("countly-feedback-sticker-"+a._id),"click",function(){document.getElementById("countly-iframe-wrapper-"+a._id).style.display="block";document.getElementById("cfbg").style.display="block"})}else document.getElementById("countly-iframe-wrapper-"+a._id).style.display="block",document.getElementById("cfbg").style.display="block"}catch(m){j("Somethings went wrong while element injecting process: "+
m)}}function J(){var a;if("undefined"!==typeof f.onload&&0<f.onload.length){for(a=0;a<f.onload.length;a++)if("function"===typeof f.onload[a])f.onload[a](f);f.onload=[]}}function K(){if(L){var a={name:L};f.check_consent("views")&&n({key:"[CLY]_view",dur:M?m()-U:V,segmentation:a});L=null}}function Q(){if(W){var a=i("cly_session");if(!a||parseInt(a)<=m())D=!1,f.begin_session(!X);i("cly_session",m()+60*ya)}}function za(a){a.app_key=f.app_key;a.device_id=f.device_id;a.sdk_name=wa;a.sdk_version=ha;f.check_consent("location")?
(f.country_code&&(a.country_code=f.country_code),f.city&&(a.city=f.city),null!==f.ip_address&&(a.ip_address=f.ip_address)):a.location="";a.timestamp=ba();var e=new Date;a.hour=e.getHours();a.dow=e.getDay()}function v(a){f.ignore_visitor||(!f.app_key||!f.device_id?j("app_key or device_id is missing"):(za(a),r.length>Ia&&r.shift(),r.push(a),i("cly_queue",r,!0)))}function Y(){J();if(f.test_mode||f.ignore_visitor)ia=!1;else{ia=!0;var a=0;if(ja&&"undefined"!==typeof d.q&&0<d.q.length){var e,g=d.q;d.q=
[];for(a=0;a<g.length;a++)if(e=g[a],j("Processing queued call",e),"function"===typeof e)e();else if(Array.isArray(e)&&0<e.length){var b=f,u=0;d.i[e[u]]&&(b=d.i[e[u]],u++);if("function"===typeof b[e[u]])b[e[u]].apply(b,e.slice(u+1));else if(0===e[u].indexOf("userData.")){var c=e[u].replace("userData.","");"function"===typeof b.userData[c]&&b.userData[c].apply(b,e.slice(u+1))}else"function"===typeof d[e[u]]&&d[e[u]].apply(d,e.slice(u+1))}}D&&(X&&M)&&(a=m(),a-G>Ja&&(f.session_duration(a-G),G=a));0<s.length&&
(s.length<=Aa?(v({events:JSON.stringify(s)}),s=[]):(a=s.splice(0,Aa),v({events:JSON.stringify(a)})),i("cly_event",s));!E&&(0<r.length&&ka&&m()>Ba)&&(ka=!1,a=r[0],sa(F)&&(H&&(clearTimeout(H),H=null),a.consent=JSON.stringify(F),F={}),j("Processing request",a),i("cly_queue",r,!0),N(f.url+Ka,a,function(a,e){j("Request Finished",e,a);a?Ba=m()+La:r.shift();i("cly_queue",r,!0);ka=!0}));setTimeout(Y,Ma)}}function la(){return i("cly_id")||pa()}function Z(){var a=JSON.parse(JSON.stringify(f.metrics||{}));a._app_version=
a._app_version||f.app_version;a._ua=a._ua||navigator.userAgent;if(screen.width){var e=screen.width?parseInt(screen.width):0,g=screen.height?parseInt(screen.height):0;if(0!==e&&0!==g){if(navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform)&&window.devicePixelRatio)e=Math.round(e*window.devicePixelRatio),g=Math.round(g*window.devicePixelRatio);else if(90===Math.abs(window.orientation))var b=e,e=g,g=b;a._resolution=a._resolution||""+e+"x"+g}}window.devicePixelRatio&&(a._density=a._density||
window.devicePixelRatio);e=navigator.language||navigator.browserLanguage||navigator.systemLanguage||navigator.userLanguage;"undefined"!==typeof e&&(a._locale=a._locale||e);if("undefined"!==typeof document.referrer&&document.referrer.length&&(e=xa.exec(document.referrer))&&e[11]&&e[11]!==window.location.hostname){e=!1;if(I&&I.length)for(g=0;g<I.length;g++)try{if(RegExp(I[g]).test(document.referrer)){j("Ignored:",document.referrer);e=!0;break}}catch(d){j("Problem with regex",I[g])}e||(a._store=a._store||
document.referrer)}j("Got metrics",a);return a}function j(){f.debug&&"undefined"!==typeof console&&(arguments[1]&&"object"===typeof arguments[1]&&(arguments[1]=JSON.stringify(arguments[1])),ja||(arguments[0]="["+f.app_key+"] "+arguments[0]),console.log(Array.prototype.slice.call(arguments).join("\n")))}function N(a,e,g){try{j("Sending XML HTTP request");var b=window.XMLHttpRequest?new window.XMLHttpRequest:window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLHTTP"):null,e=e||{},d=qa(e),c="GET";
if(f.force_post||2E3<=d.length)c="POST";"GET"===c?b.open("GET",a+"?"+d,!0):(b.open("POST",a,!0),b.setRequestHeader("Content-type","application/x-www-form-urlencoded"));for(var q in f.headers)b.setRequestHeader(q,f.headers[q]);b.onreadystatechange=function(){4===this.readyState&&200<=this.status&&300>this.status?"function"===typeof g&&g(!1,e,this.responseText):4===this.readyState&&(j("Failed Server XML HTTP request",this.status),"function"===typeof g&&g(!0,e))};"GET"===c?b.send():b.send(d)}catch(i){j("Failed XML HTTP request",
i),"function"===typeof g&&g(!0,e)}}function Ca(a){i("cly_token",a)}function i(a,e,g,b){function d(a,e,g){var b=new Date;b.setTime(b.getTime()+864E5*g);g="; expires="+b.toGMTString();document.cookie=a+"="+e+g+"; path=/"}if("none"!==f.storage){b||(a=f.app_key+"/"+a,f.namespace&&(a=da(f.namespace)+"/"+a));var g=g||"localstorage"===f.storage,c;"undefined"!==typeof e&&null!==e&&(e=f.serialize(e),R?localStorage.setItem(a,e):g||d(a,e,30));if("undefined"===typeof e){if(R)c=localStorage.getItem(a);else if(!g)a:{a+=
"=";e=document.cookie.split(";");g=0;for(b=e.length;g<b;g++){for(c=e[g];" "===c.charAt(0);)c=c.substring(1,c.length);if(0===c.indexOf(a)){c=c.substring(a.length,c.length);break a}}c=null}return f.deserialize(c)}null===e&&(R?localStorage.removeItem(a):g||d(a,"",-1))}}var f=this,ja=!d.i,D=!1,Ka="/i",Ma=h("interval",b,500),Ia=h("queue_size",b,1E3),r=[],s=[],x={},O=[],P={},I=h("ignore_referrers",b,[]),Da=null,X=!0,G,Ea=0,L=null,U=0,V=0,Ba=0,La=h("fail_timeout",b,60),Fa=h("inactivity_time",b,20),$=0,Ja=
h("session_update",b,60),Aa=h("max_events",b,10),Na=h("max_logs",b,100),W=h("use_session_cookie",b,!0),ya=h("session_cookie_timeout",b,30),ka=!0,ia=!1,E=h("offline_mode",b,!1),F={},w={},M=!0,Oa=m(),R=!0,S=null;try{localStorage.setItem("cly_testLocal",!0),localStorage.removeItem("cly_testLocal")}catch(Pa){R=!1}for(var p={},ma=0;ma<d.features.length;ma++)p[d.features[ma]]={};this.initialize=function(){this.serialize=b.serialize||d.serialize;this.deserialize=b.deserialize||d.deserialize;this.getViewName=
b.getViewName||d.getViewName;this.getViewUrl=b.getViewUrl||d.getViewUrl;this.namespace=h("namespace",b,"");this.app_key=h("app_key",b,null);this.onload=h("onload",b,[]);this.utm=h("utm",b,{source:!0,medium:!0,campaign:!0,term:!0,content:!0});this.ignore_prefetch=h("ignore_prefetch",b,!0);this.debug=h("debug",b,!1);this.test_mode=h("test_mode",b,!1);this.metrics=h("metrics",b,{});this.headers=h("headers",b,{});this.url=da(h("url",b,""));this.app_version=h("app_version",b,"0.0");this.country_code=h("country_code",
b,null);this.city=h("city",b,null);this.ip_address=h("ip_address",b,null);this.ignore_bots=h("ignore_bots",b,!0);this.force_post=h("force_post",b,!1);this.remote_config=h("remote_config",b,!1);this.ignore_visitor=h("ignore_visitor",b,!1);this.require_consent=h("require_consent",b,!1);this.track_domains=h("track_domains",b,!0);this.storage=h("storage",b,"default");"cookie"===this.storage&&(R=!1);Array.isArray(I)||(I=[]);""===this.url&&(j("Please provide server URL"),this.ignore_visitor=!0);i("cly_ignore")&&
(this.ignore_visitor=!0);if(i(f.namespace+"cly_id",void 0,!1,!0)){i("cly_id",i(f.namespace+"cly_id",void 0,!1,!0));i("cly_event",i(f.namespace+"cly_event",void 0,!1,!0));i("cly_session",i(f.namespace+"cly_session",void 0,!1,!0));var a=i(f.namespace+"cly_queue",void 0,!1,!0);Array.isArray(a)&&(a=a.filter(function(a){return a.app_key===f.app_key}),i("cly_queue",a));i(f.namespace+"cly_cmp_id",void 0,!1,!0)&&(i("cly_cmp_id",i(f.namespace+"cly_cmp_id",void 0,!1,!0)),i("cly_cmp_uid",i(f.namespace+"cly_cmp_uid",
void 0,!1,!0)));i(f.namespace+"cly_ignore",void 0,!1,!0)&&i("cly_ignore",i(f.namespace+"cly_ignore",void 0,!1,!0));i("cly_id",null,!1,!0);i("cly_event",null,!1,!0);i("cly_session",null,!1,!0);i("cly_queue",null,!1,!0);i("cly_cmp_id",null,!1,!0);i("cly_cmp_uid",null,!1,!0);i("cly_ignore",null,!1,!0)}E?this.device_id||(this.device_id="[CLY]_temp_id"):this.device_id=h("device_id",b,la());r=i("cly_queue")||[];s=i("cly_event")||[];x=i("cly_remote_configs")||{};oa();if(window.name&&0===window.name.indexOf("cly:"))try{this.passed_data=
JSON.parse(window.name.replace("cly:",""))}catch(e){j("Could not parse name",window.name)}else if(location.hash&&0===location.hash.indexOf("#cly:"))try{this.passed_data=JSON.parse(location.hash.replace("#cly:",""))}catch(g){j("Could not parse hash",location.hash)}if((this.passed_data&&this.passed_data.app_key&&this.passed_data.app_key===this.app_key||this.passed_data&&!this.passed_data.app_key&&ja)&&this.passed_data.token&&this.passed_data.purpose)this.passed_data.token!==i("cly_old_token")&&(Ca(this.passed_data.token),
i("cly_old_token",this.passed_data.token)),this.passed_data.url=this.passed_data.url||this.url,"heatmap"===this.passed_data.purpose&&(this.ignore_visitor=!0,ua(),ta(this.passed_data.url+"/views/heatmap.js",va));if(!this.ignore_visitor){j("Countly initialized");if(location.search){for(var a=location.search.substring(1).split("&"),t={},u=!1,c=0;c<a.length;c++){var q=a[c].split("=");"cly_id"===q[0]?i("cly_cmp_id",q[1]):"cly_uid"===q[0]?i("cly_cmp_uid",q[1]):"cly_device_id"===q[0]?this.device_id=q[1]:
0===(q[0]+"").indexOf("utm_")&&this.utm[q[0].replace("utm_","")]&&(t[q[0].replace("utm_","")]=q[1],u=!0)}if(u){for(var l in this.utm)t[l]?this.userData.set("utm_"+l,t[l]):this.userData.unset("utm_"+l);this.userData.save()}}E||this.device_id!==i("cly_id")&&i("cly_id",this.device_id);J();setTimeout(function(){Y();f.remote_config&&f.fetch_remote_config(f.remote_config)},1)}document.documentElement.setAttribute("data-countly-useragent",navigator.userAgent)};this.group_features=function(a){if(a)for(var e in a)p[e]?
j("Feature name "+e+" is already reserved"):"string"===typeof a[e]?p[e]={features:[a[e]]}:a[e]&&Array.isArray(a[e])&&a[e].length?p[e]={features:a[e]}:j("Incorrect feature list for "+e+" value: "+a[e]);else j("Incorrect features: "+a)};this.check_consent=function(a){if(!this.require_consent)return!0;if(p[a])return p[a]&&p[a].optin?!0:!1;j("No feature available for "+a);return!1};this.check_any_consent=function(){if(!this.require_consent)return!0;for(var a in p)if(p[a]&&p[a].optin)return!0;return!1};
this.add_consent=function(a){j("Adding consent for "+a);if(Array.isArray(a))for(var e=0;e<a.length;e++)this.add_consent(a[e]);else p[a]?p[a].features?(p[a].optin=!0,this.add_consent(p[a].features)):!0!==p[a].optin&&(F[a]=!0,p[a].optin=!0,Ga(),setTimeout(function(){"sessions"===a&&w.begin_session?(f.begin_session.apply(f,w.begin_session),w.begin_session=null):"views"===a&&w.track_pageview&&(L=null,f.track_pageview.apply(f,w.track_pageview),w.track_pageview=null);w.change_id&&(f.change_id.apply(f,w.change_id),
w.change_id=null)},1)):j("No feature available for "+a)};this.remove_consent=function(a){j("Removing consent for "+a);if(Array.isArray(a))for(var e=0;e<a.length;e++)this.remove_consent(a[e]);else p[a]?(p[a].features?this.remove_consent(p[a].features):!1!==p[a].optin&&(F[a]=!1,Ga()),p[a].optin=!1):j("No feature available for "+a)};var H,Ga=function(){H&&(clearTimeout(H),H=null);H=setTimeout(function(){sa(F)&&(v({consent:JSON.stringify(F)}),F={})},1E3)};this.enable_offline_mode=function(){E=!0;this.device_id=
"[CLY]_temp_id"};this.disable_offline_mode=function(a){E=!1;a&&this.device_id!==a?(this.device_id=a,i("cly_id",this.device_id),j("Changing id")):(this.device_id=la(),this.device_id!==i("cly_id")&&i("cly_id",this.device_id));a=!1;if(0<r.length)for(var e=0;e<r.length;e++)"[CLY]_temp_id"===r[e].device_id&&(r[e].device_id=this.device_id,a=!0);a&&i("cly_queue",r,!0)};this.begin_session=function(a,e){if(this.check_consent("sessions")){if(!D){this.report_orientation();k(window,"resize",function(){f.report_orientation()});
G=m();D=!0;X=a?!1:!0;var g=i("cly_session");if(e||!W||!g||parseInt(g)<=m())j("Session started"),null===S&&(S=!0),g={begin_session:1},g.metrics=JSON.stringify(Z()),v(g);i("cly_session",m()+60*ya)}}else w.begin_session=arguments};this.session_duration=function(a){this.check_consent("sessions")&&D&&(j("Session extended",a),v({session_duration:a}),Q())};this.end_session=function(a,e){this.check_consent("sessions")&&D&&(a=a||m()-G,K(),!W||e?(j("Ending session"),v({end_session:1,session_duration:a})):this.session_duration(a),
D=!1)};this.change_id=function(a,e){if(this.device_id!==a){e||(0<s.length&&(v({events:JSON.stringify(s)}),s=[],i("cly_event",s)),this.end_session(null,!0),P={});var g=this.device_id;this.device_id=a;i("cly_id",this.device_id);j("Changing id");e?this.check_any_consent()?v({old_device_id:g}):w.change_id=arguments:this.begin_session(!X,!0);this.remote_config&&(x={},i("cly_remote_configs",x),this.fetch_remote_config(this.remote_config))}};this.add_event=function(a){this.check_consent("events")&&n(a)};
this.start_event=function(a){P[a]?j("Timed event with key "+a+" already started"):P[a]=m()};this.end_event=function(a){"string"===typeof a&&(a={key:a});a.key?P[a.key]?(a.dur=m()-P[a.key],this.add_event(a),delete P[a.key]):j("Timed event with key "+a.key+" was not started"):j("Event must have key property")};this.report_orientation=function(a){this.check_consent("users")&&n({key:"[CLY]_orientation",segmentation:{mode:a||(window.innerWidth>window.innerHeight?"landscape":"portrait")}})};this.report_conversion=
function(a,e){this.check_consent("attribution")&&(a=a||i("cly_cmp_id")||"cly_organic",e=e||i("cly_cmp_uid"),a&&e?v({campaign_id:a,campaign_user:e}):a&&v({campaign_id:a}))};this.user_details=function(a){this.check_consent("users")&&(j("Adding user details: ",a),v({user_details:JSON.stringify(C(a,"name username email organization phone picture gender byear custom".split(" ")))}))};var y={},A=function(a,e,g){f.check_consent("users")&&(y[a]||(y[a]={}),"$push"===g||"$pull"===g||"$addToSet"===g?(y[a][g]||
(y[a][g]=[]),y[a][g].push(e)):y[a][g]=e)};this.userData={set:function(a,e){y[a]=e},unset:function(a){y[a]=""},set_once:function(a,e){A(a,e,"$setOnce")},increment:function(a){A(a,1,"$inc")},increment_by:function(a,e){A(a,e,"$inc")},multiply:function(a,e){A(a,e,"$mul")},max:function(a,e){A(a,e,"$max")},min:function(a,e){A(a,e,"$min")},push:function(a,e){A(a,e,"$push")},push_unique:function(a,e){A(a,e,"$addToSet")},pull:function(a,e){A(a,e,"$pull")},save:function(){f.check_consent("users")&&v({user_details:JSON.stringify({custom:y})});
y={}}};this.report_trace=function(a){if(this.check_consent("apm")){for(var e="type name stz etz apm_metrics apm_attr".split(" "),g=0;g<e.length;g++)if("apm_attr"!==e[g]&&"undefined"===typeof a[e[g]]){j("APM trace must have a",e[g]);return}e=C(a,e);e.timestamp=a.stz;a=new Date;e.hour=a.getHours();e.dow=a.getDay();v({apm:JSON.stringify(e)});j("Adding APM trace: ",e)}};this.track_errors=function(a){d.i[this.app_key].tracking_crashes=!0;window.cly_crashes||(window.cly_crashes=!0,Da=a,window.onerror=function(a,
g,b,f,c){if("undefined"!==typeof c)ca(c,!1);else{var f=f||window.event&&window.event.errorCharacter,d="";"undefined"!==typeof a&&(d+=a+"\n");"undefined"!==typeof g&&(d+="at "+g);"undefined"!==typeof b&&(d+=":"+b);"undefined"!==typeof f&&(d+=":"+f);d+="\n";try{for(var i=[],h=arguments.callee.caller;h;)i.push(h.name),h=h.caller;d+=i.join("\n")}catch(j){}ca(d,!1)}},window.addEventListener("unhandledrejection",function(a){ca(Error("Unhandled rejection (reason: "+(a.reason&&a.reason.stack?a.reason.stack:
a.reason)+")."),!0)}))};this.log_error=function(a,e){this.recordError(a,!0,e)};this.add_log=function(a){this.check_consent("crashes")&&(O.length>Na&&O.shift(),O.push(a))};this.fetch_remote_config=function(a,e,g){if(this.check_consent("remote-config")){var b={method:"fetch_remote_config"};this.check_consent("sessions")&&(b.metrics=JSON.stringify(Z()));a&&(!g&&"function"===typeof a?(g=a,a=null):Array.isArray(a)&&a.length&&(b.keys=JSON.stringify(a)));e&&(!g&&"function"===typeof e?(g=e,e=null):Array.isArray(e)&&
e.length&&(b.omit_keys=JSON.stringify(e)));za(b);N(this.url+"/o/sdk",b,function(a,e,f){try{var d=JSON.parse(f);if(b.keys||b.omit_keys)for(var h in d)x[h]=d[h];else x=d;i("cly_remote_configs",x)}catch(j){}"function"===typeof g&&g(a,x)})}else j("Remote config requires explicit consent"),"function"===typeof g&&g(Error("Remote config requires explicit consent"),x)};this.get_remote_config=function(a){return"undefined"!==typeof a?x[a]:x};this.stop_time=function(){M&&(M=!1,Ea=m()-G,V=m()-U)};this.start_time=
function(){M||(M=!0,G=m()-Ea,U=m()-V,V=0,Q())};this.track_sessions=function(){function a(){document[b]?f.stop_time():f.start_time()}function e(){$>=Fa&&f.start_time();$=0}this.begin_session();this.start_time();k(window,"beforeunload",function(){f.end_session()});var b="hidden";b in document?document.addEventListener("visibilitychange",a):(b="mozHidden")in document?document.addEventListener("mozvisibilitychange",a):(b="webkitHidden")in document?document.addEventListener("webkitvisibilitychange",a):
(b="msHidden")in document?document.addEventListener("msvisibilitychange",a):"onfocusin"in document?(k(window,"focusin",function(){f.start_time()}),k(window,"focusout",function(){f.stop_time()})):(k(window,"focus",function(){f.start_time()}),k(window,"blur",function(){f.stop_time()}),k(window,"pageshow",function(){f.start_time()}),k(window,"pagehide",function(){f.stop_time()}));k(window,"mousemove",e);k(window,"click",e);k(window,"keydown",e);k(window,"scroll",e);setInterval(function(){$++;$>=Fa&&
f.stop_time()},6E4)};this.track_pageview=function(a,e,b){K();a&&Array.isArray(a)&&(e=a,a=null);a||(a=this.getViewName());if(e&&e.length)for(var t=0;t<e.length;t++)try{if(RegExp(e[t]).test(a)){j("Ignored:",a);return}}catch(d){j("Problem with regex",e[t])}L=a;U=m();t={name:a,visit:1,view:this.getViewUrl()};this.track_domains&&(t.domain=window.location.hostname);if(W)if(D)S&&(S=!1,t.start=1);else{var c=i("cly_session");if(!c||parseInt(c)<=m())S=!1,t.start=1}else if("undefined"!==typeof document.referrer&&
document.referrer.length&&(c=xa.exec(document.referrer))&&c[11]&&c[11]!==window.location.hostname)t.start=1;if(b)for(var f in b)"undefined"===typeof t[f]&&(t[f]=b[f]);this.check_consent("views")?n({key:"[CLY]_view",segmentation:t}):w.track_pageview=arguments};this.track_view=function(a,e,b){this.track_pageview(a,e,b)};this.track_clicks=function(a){var a=a||document,e=!0;k(a,"click",function(a){if(e){e=!1;ea(a);if("undefined"!==typeof a.pageX&&"undefined"!==typeof a.pageY){var b=T(),d=fa();f.check_consent("clicks")&&
(a={type:"click",x:a.pageX,y:a.pageY,width:d,height:b,view:f.getViewUrl()},f.track_domains&&(a.domain=window.location.hostname),n({key:"[CLY]_action",segmentation:a}))}setTimeout(function(){e=!0},1E3)}})};this.track_scrolls=function(a){var a=a||window,e=!0,b=0;k(a,"scroll",function(){b=Math.max(b,window.scrollY,document.body.scrollTop,document.documentElement.scrollTop)});k(a,"beforeunload",function(){if(e){e=!1;var a=T(),d=fa(),c=ra();f.check_consent("scrolls")&&(a={type:"scroll",y:b+c,width:d,height:a,
view:f.getViewUrl()},f.track_domains&&(a.domain=window.location.hostname),n({key:"[CLY]_action",segmentation:a}))}})};this.track_links=function(a){a=a||document;k(a,"click",function(a){var b;a:{b=aa(a);var d;for(d="A";b;){if(b.nodeName.toUpperCase()===d)break a;b=b.parentElement}b=void 0}b&&(ea(a),f.check_consent("clicks")&&n({key:"linkClick",segmentation:{href:b.href,text:b.innerText,id:b.id,view:f.getViewUrl()}}))})};this.track_forms=function(a,b){function g(a){return a.name||a.id||a.type||a.nodeName}
a=a||document;k(a,"submit",function(a){var a=aa(a),d={id:a.attributes.id&&a.attributes.id.nodeValue,name:a.attributes.name&&a.attributes.name.nodeValue,action:a.attributes.action&&a.attributes.action.nodeValue,method:a.attributes.method&&a.attributes.method.nodeValue,view:f.getViewUrl()},c;if("undefined"!==typeof a.elements){for(var i=0;i<a.elements.length;i++)if((c=a.elements[i])&&"password"!==c.type&&-1===c.className.indexOf("cly_user_ignore"))"undefined"===typeof d["input:"+g(c)]&&(d["input:"+
g(c)]=[]),"select"===c.nodeName.toLowerCase()?"undefined"!==typeof c.multiple?d["input:"+g(c)].push(z(c)):d["input:"+g(c)].push(c.options[c.selectedIndex].value):"input"===c.nodeName.toLowerCase()?"undefined"!==typeof c.type?"checkbox"===c.type.toLowerCase()||"radio"===c.type.toLowerCase()?c.checked&&d["input:"+g(c)].push(c.value):("hidden"!==c.type.toLowerCase()||b)&&d["input:"+g(c)].push(c.value):d["input:"+g(c)].push(c.value):"textarea"===c.nodeName.toLowerCase()?d["input:"+g(c)].push(c.value):
"undefined"!==typeof c.value&&d["input:"+g(c)].push(c.value);for(var h in d)d[h]&&"function"===typeof d[h].join&&(d[h]=d[h].join(", "))}f.check_consent("forms")&&n({key:"formSubmit",segmentation:d})})};this.collect_from_forms=function(a,b){a=a||document;k(a,"submit",function(g){var g=aa(g),d={},i=!1,c;if("undefined"!==typeof g.elements){var h={},l=a.getElementsByTagName("LABEL"),k;for(k=0;k<l.length;k++)l[k].htmlFor&&""!==l[k].htmlFor&&(h[l[k].htmlFor]=l[k].innerText||l[k].textContent||l[k].innerHTML);
for(k=0;k<g.elements.length;k++)if((c=g.elements[k])&&"password"!==c.type&&-1===c.className.indexOf("cly_user_ignore"))if(l="","select"===c.nodeName.toLowerCase()?l="undefined"!==typeof c.multiple?z(c):c.options[c.selectedIndex].value:"input"===c.nodeName.toLowerCase()?"undefined"!==typeof c.type?"checkbox"===c.type.toLowerCase()||"radio"===c.type.toLowerCase()?c.checked&&(l=c.value):l=c.value:l=c.value:"textarea"===c.nodeName.toLowerCase()?l=c.value:"undefined"!==typeof c.value&&(l=c.value),c.className&&
-1!==c.className.indexOf("cly_user_")){var n=c.className.split(" ");for(c=0;c<n.length;c++)if(0===n[c].indexOf("cly_user_")){d[n[c].replace("cly_user_","")]=l;i=!0;break}}else if(c.type&&"email"===c.type.toLowerCase()||c.name&&-1!==c.name.toLowerCase().indexOf("email")||c.id&&-1!==c.id.toLowerCase().indexOf("email")||c.id&&h[c.id]&&-1!==h[c.id].toLowerCase().indexOf("email")||/[^@\s]+@[^@\s]+\.[^@\s]+/.test(l))d.email||(d.email=l),i=!0;else if(c.name&&-1!==c.name.toLowerCase().indexOf("username")||
c.id&&-1!==c.id.toLowerCase().indexOf("username")||c.id&&h[c.id]&&-1!==h[c.id].toLowerCase().indexOf("username"))d.username||(d.username=l),i=!0;else if(c.name&&(-1!==c.name.toLowerCase().indexOf("tel")||-1!==c.name.toLowerCase().indexOf("phone")||-1!==c.name.toLowerCase().indexOf("number"))||c.id&&(-1!==c.id.toLowerCase().indexOf("tel")||-1!==c.id.toLowerCase().indexOf("phone")||-1!==c.id.toLowerCase().indexOf("number"))||c.id&&h[c.id]&&(-1!==h[c.id].toLowerCase().indexOf("tel")||-1!==h[c.id].toLowerCase().indexOf("phone")||
-1!==h[c.id].toLowerCase().indexOf("number")))d.phone||(d.phone=l),i=!0;else if(c.name&&(-1!==c.name.toLowerCase().indexOf("org")||-1!==c.name.toLowerCase().indexOf("company"))||c.id&&(-1!==c.id.toLowerCase().indexOf("org")||-1!==c.id.toLowerCase().indexOf("company"))||c.id&&h[c.id]&&(-1!==h[c.id].toLowerCase().indexOf("org")||-1!==h[c.id].toLowerCase().indexOf("company")))d.organization||(d.organization=l),i=!0;else if(c.name&&-1!==c.name.toLowerCase().indexOf("name")||c.id&&-1!==c.id.toLowerCase().indexOf("name")||
c.id&&h[c.id]&&-1!==h[c.id].toLowerCase().indexOf("name"))d.name||(d.name=""),d.name+=l+" ",i=!0}i&&(j("Gathered user data",d),b?f.user_details({custom:d}):f.user_details(d))})};this.collect_from_facebook=function(a){FB&&FB.api&&FB.api("/me",function(b){var g={};b.name&&(g.name=b.name);b.email&&(g.email=b.email);"male"===b.gender?g.gender="M":"female"===b.gender&&(g.gender="F");if(b.birthday){var d=b.birthday.split("/").pop();d&&4===d.length&&(g.byear=d)}b.work&&(b.work[0]&&b.work[0].employer&&b.work[0].employer.name)&&
(g.organization=b.work[0].employer.name);if(a){g.custom={};for(var h in a){for(var d=a[h].split("."),c=b,i=0;i<d.length&&!(c=c[d[i]],"undefined"===typeof c);i++);"undefined"!==typeof c&&(g.custom[h]=c)}}f.user_details(g)})};this.opt_out=function(){this.ignore_visitor=!0;i("cly_ignore",!0)};this.opt_in=function(){i("cly_ignore",!1);this.ignore_visitor=!1;oa();!this.ignore_visitor&&!ia&&Y()};this.report_feedback=function(a){if(this.check_consent("star-rating")||this.check_consent("feedback"))if(a.widget_id)if(a.rating){if(this.check_consent("events")){var b=
{key:"[CLY]_star_rating",count:1,segmentation:{}};b.segmentation=C(a,"widget_id contactMe platform app_version rating email comment".split(" "));b.segmentation.app_version||(b.segmentation.app_version=this.metrics._app_version||this.app_version);j("Reporting feedback: ",b);this.add_event(b)}}else j("Feedback must contain rating property");else j("Feedback must contain widget_id property")};this.show_feedback_popup=function(a){if(this.check_consent("star-rating")||this.check_consent("feedback"))E?
j("Cannot show feedback popup in offline mode"):N(this.url+"/o/feedback/widget",{widget_id:a},function(a,b,d){a&&j("Error occurred",a);try{var f=JSON.parse(d);B(f,!1)}catch(c){j("JSON parse failed: "+c)}})};this.initialize_feedback_popups=function(a){if(this.check_consent("star-rating")||this.check_consent("feedback")){a||(a=i("cly_fb_widgets"));for(var b=document.getElementsByClassName("countly-feedback-sticker");0<b.length;)b[0].remove();N(this.url+"/o/feedback/multiple-widgets-by-id",{widgets:JSON.stringify(a)},
function(a,b,e){if(a)j("Errors occurred:",a);else try{for(var c=JSON.parse(e),a=0;a<c.length;a++)if("true"===c[a].is_active&&c[a].target_devices[na.device])if("string"===typeof c[a].hide_sticker&&(c[a].hide_sticker="true"===c[a].hide_sticker?!0:!1),"all"===c[a].target_page&&!c[a].hide_sticker)B(c[a],!0);else for(var d=c[a].target_pages,b=0;b<d.length;b++){var f=d[b].substr(0,d[b].length-1)===window.location.pathname.substr(0,d[b].length-1),h=d[b]===window.location.pathname;(d[b].includes("*")&&f||
h)&&!c[a].hide_sticker&&B(c[a],!0)}}catch(i){j("JSON parse error: "+i)}})}};this.enable_feedback=function(a){if(this.check_consent("star-rating")||this.check_consent("feedback"))E?j("Cannot enable feedback in offline mode"):(i("cly_fb_widgets",a.popups||a.widgets),ga(this.url+"/star-rating/stylesheets/countly-feedback-web.css"),a=a.popups||a.widgets,0<a.length?(document.body.insertAdjacentHTML("beforeend",'<div id="cfbg"></div>'),this.initialize_feedback_popups(a)):j("You should provide at least one widget id as param. Read documentation for more detail. https://resources.count.ly/plugins/feedback"))};
this.get_available_feedback_widgets=function(a){!this.check_consent("star-rating")&&!this.check_consent("feedback")?a&&a(null,Error("Consent for feedback not provided.")):E?j("Cannot enable feedback in offline mode."):N(this.url+"/o/sdk",{method:"feedback",device_id:this.device_id,app_key:this.app_key},function(b,d,f){if(b)j("Error occurred while fetching feedbacks",b),a&&a(null,b);else try{var h=JSON.parse(f).result||[];a&&a(h,null)}catch(c){j("Error while processing feedbacks",c),a&&a(null,c)}})};
this.present_feedback_widget=function(a){function b(a){document.getElementById("countly-surveys-wrapper-"+a._id).style.display="block";document.getElementById("csbg").style.display="block"}if(this.check_consent("star-rating")||this.check_consent("feedback"))if(!a||"object"!==typeof a||Array.isArray(a))j("Please provide at least one feedback widget object.");else try{var g=this.url;if("nps"===a.type)g+="/feedback/nps";else if("survey"===a.type)g+="/feedback/survey";else{j("Feedback widget only accepts nps and survey types.");
return}var g=g+("?widget_id="+a._id),g=g+("&app_key="+this.app_key),g=g+("&device_id="+this.device_id),g=g+("&sdk_name="+wa),g=g+("&platform="+this.platform),g=g+("&app_version="+this.app_version),g=g+("&sdk_version="+ha),g=g+("&origin="+(window.origin||window.location.origin)),g=g+"&widget_v=web",f=document.createElement("iframe");f.name="countly-surveys-iframe";f.id="countly-surveys-iframe";f.src=g;var h=!1;f.onload=function(){h&&(document.getElementById("countly-surveys-wrapper-"+a._id).style.display=
"none",document.getElementById("csbg").style.display="none");h=!0};ga(this.url+"/surveys/stylesheets/countly-surveys.css");for(var c=document.getElementById("csbg");c;)c.remove(),c=document.getElementById("csbg");for(var i=document.getElementsByClassName("countly-surveys-wrapper"),g=0;g<i.length;g++)i[g].remove();document.body.insertAdjacentHTML("beforeend",'<div id="csbg"></div>');i=document.createElement("div");i.className="countly-surveys-wrapper";i.id="countly-surveys-wrapper-"+a._id;"survey"===
a.type&&(i.className=i.className+" "+a.appearance.position);document.body.appendChild(i);i.appendChild(f);k(window,"message",function(b){var e={};try{e=JSON.parse(b.data)}catch(c){j("Error while parsing message body "+c)}b.origin===d.url&&e.close&&(document.getElementById("countly-surveys-wrapper-"+a._id).style.display="none",document.getElementById("csbg").style.display="none")});if("survey"===a.type){var l=!1;switch(a.showPolicy){case "afterPageLoad":"complete"===document.readyState?l||(l=!0,b(a)):
k(document,"readystatechange",function(c){"complete"===c.target.readyState&&!l&&(l=!0,b(a))});break;case "afterConstantDelay":setTimeout(function(){l||(l=!0,b(a))},1E4);break;case "onAbandon":"complete"===document.readyState?k(document,"mouseleave",function(){l||(l=!0,b(a))}):k(document,"readystatechange",function(c){"complete"===c.target.readyState&&k(document,"mouseleave",function(){l||(l=!0,b(a))})});break;case "onScrollHalfwayDown":k(window,"scroll",function(){if(!l){var c=Math.max(window.scrollY,
document.body.scrollTop,document.documentElement.scrollTop),d=T();c>=d/2&&(l=!0,b(a))}});break;default:l||(l=!0,b(a))}}else"nps"===a.type&&(document.getElementById("countly-surveys-wrapper-"+a._id).style.display="block",document.getElementById("csbg").style.display="block")}catch(n){j("Somethings went wrong while presenting the feedback",n)}};this.recordError=function(a,b,d){if(this.check_consent("crashes")&&a){var d=d||Da,f="";"object"===typeof a?"undefined"!==typeof a.stack?f=a.stack:("undefined"!==
typeof a.name&&(f+=a.name+":"),"undefined"!==typeof a.message&&(f+=a.message+"\n"),"undefined"!==typeof a.fileName&&(f+="in "+a.fileName+"\n"),"undefined"!==typeof a.lineNumber&&(f+="on "+a.lineNumber),"undefined"!==typeof a.columnNumber&&(f+=":"+a.columnNumber)):f=a+"";b=b?!0:!1;a=Z();f={_resolution:a._resolution,_error:f,_app_version:a._app_version,_run:m()-Oa,_not_os_specific:!0,_javascript:!0};if(a=navigator.battery||navigator.webkitBattery||navigator.mozBattery||navigator.msBattery)f._bat=Math.floor(100*
a.level);"undefined"!==typeof navigator.onLine&&(f._online=navigator.onLine?!0:!1);f._background=document.hasFocus()?!1:!0;0<O.length&&(f._logs=O.join("\n"));O=[];f._nonfatal=b;f._view=this.getViewName();"undefined"!==typeof d&&(f._custom=d);try{var i=document.createElement("canvas").getContext("experimental-webgl");f._opengl=i.getParameter(i.VERSION)}catch(c){}v({crash:JSON.stringify(f)})}};this.onStorageChange=function(a,b){switch(a){case "cly_queue":r=f.deserialize(b||"[]");break;case "cly_event":s=
f.deserialize(b||"[]");break;case "cly_remote_configs":x=f.deserialize(b||"{}");break;case "cly_ignore":f.ignore_visitor=f.deserialize(b);break;case "cly_id":f.device_id=f.deserialize(b)}};this._internals={store:i,getDocWidth:fa,getDocHeight:T,getViewportHeight:ra,get_page_coord:ea,get_event_target:aa,add_event:k,getProperties:C,stripTrailingSlash:da,prepareParams:qa,sendXmlHttpRequest:N,getMsTimestamp:ba,getTimestamp:m,log:j,getMetrics:Z,generateUUID:pa,isUUID:function(){return/[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-4[0-9a-fA-F]{3}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/.test(f.device_id)},
getId:la,heartBeat:Y,toRequestQueue:v,reportViewDuration:K,loadJS:ta,loadCSS:ga,getLastView:function(){return L},setToken:Ca,getToken:function(){var a=i("cly_token");i("cly_token",null);return a},showLoader:ua,hideLoader:va,add_cly_events:n,detect_device:na,getRequestQueue:function(){return r},getEventQueue:function(){return s},clearQueue:function(){r=[];i("cly_queue",[]);s=[];i("cly_event",[])}};this.initialize()};d.init=function(b){var b=b||{},h=b.app_key||d.app_key;if(!d.i||!d.i[h]){b=new d.CountlyClass(b);
if(!d.i){d.i={};for(var k in b)d[k]=b[k]}d.i[h]=b}return d.i[h]};var B=0,k=function(b,d,h){"undefined"!==typeof b.addEventListener?b.addEventListener(d,h,!1):b.attachEvent("on"+d,h)},aa=function(b){return b?"undefined"!==typeof b.target?b.target:b.srcElement:window.event.srcElement},na,J=navigator.userAgent.toLowerCase(),K=function(b){b&&(J=(b+"").toLowerCase());return/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(J)?"tablet":
/(mobi|ipod|phone|blackberry|opera mini|fennec|minimo|symbian|psp|nintendo ds|archos|skyfire|puffin|blazer|bolt|gobrowser|iris|maemo|semc|teashark|uzard)/.test(J)?"phone":"desktop"};na={device:K(),detect:K,isMobile:"desktop"!==K()?!0:!1,userAgent:J};window.addEventListener("storage",function(b){var h=(b.key+"").split("/"),k=h.pop(),h=h.pop();if(d.i&&d.i[h])d.i[h].onStorageChange(k,b.newValue)});d.serialize=function(b){"object"===typeof b&&(b=JSON.stringify(b));return b};d.deserialize=function(b){try{b=
JSON.parse(b)}catch(d){}return b};d.getViewName=function(){return window.location.pathname};d.getViewUrl=function(){return window.location.pathname};return d}});