!function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t){!function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";!function(){let e;"Notification"in window&&(e=window.Notification);let t={onDocumentLoaded(e){if("interactive"===window.document.readyState||"complete"===window.document.readyState)return e();window.document.addEventListener("DOMContentLoaded",e)},addPixel(e,t){if(!e)return;let r=-1!==e.indexOf("?");"object"!=typeof t&&(t={});for(let o in t)Object.prototype.hasOwnProperty.call(t,o)&&(null!==t[o]&&void 0!==t[o]||(t[o]=""),e=e+(r?"&":"?")+o+"="+t[o],r=!0);let o=document.createElement("img");o.src=e,o.style.position="absolute",o.style.left="-200%",o.style.top="-200%",o.style.zIndex=-1,o.onload=function(){o&&o.parentNode.removeChild(o)}.bind(this),document.body.appendChild(o)},doRedirect(t,r){if(!t)return;let o=encodeURIComponent(decodeURIComponent(r.aff_sub||"")),n=encodeURIComponent(decodeURIComponent([r.q,r.keyword].filter(e=>e).join(" "))),i=encodeURIComponent(decodeURIComponent(r.source_id||"")),c=encodeURIComponent(decodeURIComponent(r.platform_id||"")),s=encodeURIComponent(decodeURIComponent(r.promo_id||""));t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace(/{AFF_SUB}/i,o)).replace(/{CLICK_ID}/i,o)).replace(/{Q}/i,n)).replace(/{QUERY}/i,n)).replace(/{KEYWORD}/i,n)).replace(/{SOURCE_ID}/i,i)).replace(/{SOURCE}/i,i)).replace(/{PL_ID}/i,c)).replace(/{PLATFORM_ID}/i,c)).replace(/{PR_ID}/i,s)).replace(/{PROMO_ID}/i,s)).replace(/{[a-zA-Z0-9_]*?}/g,""),n&&-1===t.indexOf("q=")&&(t+=(-1===t.indexOf("?")?"?":"&")+"q="+n),t=t.replace(/subscribed=\d+/,""),t+=(-1===t.indexOf("?")?"?":"&")+"subscribed="+("granted"===(e&&e.permission)?1:0),-1===location.hostname.indexOf("localhost")&&(document.location.href=t)},isType:(e,t)=>Object.prototype.toString.call(e).slice(8,-1)===t,isArray(e){return this.isType(e,"Array")},isNodeList(e){return this.isType(e,"NodeList")},removeListeners(e,t,r,o){if(e&&(this.isArray(e)||this.isNodeList(e)))for(let n=0;n<e.length;n++)e[n].removeEventListener?e[n].removeEventListener(t,r,o):e[n].detachEvent&&e[n].detachEvent("on"+t,r)},addListeners(e,t,r,o){if(!e||!this.isArray(e)&&!this.isNodeList(e))return function(){};for(let n=0;n<e.length;n++)e[n].addEventListener?e[n].addEventListener(t,r,o):e[n].attachEvent&&e[n].attachEvent("on"+t,r);return function(){this.removeListeners(e,t,r,o)}.bind(this)},listenForFocus(e){let r,o,n=e.onSuccess||function(){},i=e.onError||function(){},c=+e.timeout||6e4,s=[];o=setTimeout(function(){clearInterval(r),clearTimeout(o),s.length&&s.forEach(e=>e&&e()),i(new Error("TIMEOUT"))},c),["keydown","scroll","resize","mousemove","mousedown","touchstart","click","keypress"].forEach(e=>{let i=t.addListeners([window],e,function(){return clearInterval(r),clearTimeout(o),s.length&&s.forEach(e=>e&&e()),n()});s.push(i)}),r=setInterval(function(){if(document.hasFocus())return clearInterval(r),clearTimeout(o),s.length&&s.forEach(e=>e&&e()),n()},500)},isInIframe(){try{return window.self!==window.top}catch(e){return!0}},getBrowserInfo(){let e=window.navigator.userAgent.toLowerCase();return{name:[["Opera",e=>!!window.opr&&!!window.opr.addons||!!window.opera||navigator.userAgent.indexOf(" opr/")>=0],["Firefox",e=>"undefined"!=typeof InstallTrigger],["Safari",e=>/constructor/i.test(window.HTMLElement)||function(e){return"[object SafariRemoteNotification]"===(!window.safari||window.safari.pushNotification).toString()}()],["IE", /*@cc_on!@*/ e=>!!document.documentMode],["Edge",e=>"IE"!==e&&!!window.StyleMedia],["Chrome",t=>!!window.chrome&&e.indexOf("chrome")>-1&&"Opera"!==t&&(!!window.chrome.webstore||!!window.chrome.runtime)],["Yandex",t=>e.search(/yabrowser\/|yowser\//)>0]].reduce((e,t)=>t[1](e)?t[0]:e,null),type:t.isMobile()?"mobile":"desktop",width:window.innerWidth||window.document.documentElement.clientWidth||document.body.clientWidth,height:window.innerHeight||window.document.documentElement.clientHeight||document.body.clientHeight}},isPushSupported:()=>(0===location.host.indexOf("localhost")||"https:"===location.protocol)&&"serviceWorker"in navigator&&!!("Notification"in window&&navigator&&navigator.serviceWorker),isDenied:()=>e&&"denied"===e.permission,isSubscribed:e=>Promise.resolve(e&&e.pushManager&&e.pushManager.getSubscription().then(e=>!!e).catch(()=>!1)),ls:{can:function(){return void 0!==window.localStorage},set:function(e,t){if(e&&localStorage)return"string"!=typeof t&&(t=JSON.stringify(t)),localStorage.setItem(e,t)},get:function(e){if(e&&localStorage)return localStorage.getItem(e)},remove:function(e){if(e&&localStorage)return localStorage.removeItem(e)}},checkType:(e,t)=>Object.prototype.toString.call(e).slice(8,-1).toLowerCase()===t.toLowerCase(),parseUrlParams(){let e=location&&location.search&&location.search.slice(1).split("&")||[];if(t.isInIframe()){let t=document.referrer&&document.referrer.split("?")[1],r=t&&t.split("&")||[];e=e.concat(r)}let r={};for(let t=0;t<e.length;t++){let o=e[t].split("=");r[o[0]]||(r[o[0]]=o[1])}return r},isMobile:()=>void 0!==window.orientation||-1!==navigator.userAgent.indexOf("IEMobile"),isObject:e=>e&&"object"==typeof e,parseObject(e){if("object"==typeof e)return e;if(!e)return e;try{e=atob(e);try{e=JSON.parse(e)}catch(e){}}catch(t){try{e=JSON.parse(e)}catch(e){}}return e},request(e){let t=e.url,r=(e.method||"get").toUpperCase(),o=e.headers||{"Content-Type":"application/json"},n=e.onSuccess||function(){},i=e.onError||function(){},c=+e.timeout||6e4;try{if(!t)throw new Error("MISSING_PARAMETER_URL");if("GET"!==r&&"POST"!==r)throw new Error("MISSING_PARAMETER_METHOD");let s=new XMLHttpRequest,a=setTimeout(function(){i("TIMEOUT")},c);s.onreadystatechange=function(){try{if(s.readyState!==XMLHttpRequest.DONE)return;if(200===s.status){clearTimeout(a);let e=s.response;try{e=JSON.parse(s.response)}catch(e){}n(e)}if(s.status>=400)throw clearTimeout(a),new Error("XHR_"+s.status+"_ERROR"+(s.response?" ("+JSON.stringify(s.response)+")":""))}catch(e){i(e)}},s.open(r,t);for(let e in o)Object.prototype.hasOwnProperty.call(o,e)&&s.setRequestHeader(e,o[e]);if("POST"===r){let t=e&&e.body||{};"string"!=typeof t&&(t=JSON.stringify(t)),s.send(t)}else s.send()}catch(e){i(e)}},runWithTimeout(e,t){t=+t||0,e="function"==typeof e?e:function(){};let r=null,o=!1;return new Promise((n,i)=>{try{return r=t?setTimeout(()=>{try{o||(clearTimeout(r),r=null,i(new Error("RUN_TIMEOUT")),o=!0)}catch(e){o||(i(e),o=!0)}},t):null,Promise.resolve().then(()=>e()).then(e=>{o||(clearTimeout(r),r=null,n(e),o=!0)}).catch(e=>{o||(i(e),o=!0)})}catch(e){o||(i(e),o=!0)}})}};function r(e,t){return this.config=e,this._canRun=t,this}function o(e){let o=this,n={};["onSubscribed","onUnsupported","onSupported","onSubscribe","onDenied"].forEach(t=>{o[t]=function(){return!n[t]&&(n[t]=!0,e&&"function"==typeof e[t]?e[t]():void 0)}}),o.onError="function"==typeof e.onError?e.onError:function(e){throw e},o.config=Object.assign({},e,{onSubscribed:o.onSubscribed.bind(null),onUnsupported:o.onUnsupported.bind(null),onSupported:o.onSupported.bind(null),onSubscribe:o.onSubscribe.bind(null),onDenied:o.onDenied.bind(null),onError:o.onError.bind(null)}),o.config.pushHost=o.config.pushHost||"//push-me-down.com",o.config.serviceWorkerPath=o.config.serviceWorkerPath||"/service-worker.js",o.config.serviceWorkerScope=o.config.serviceWorkerScope||"./",o.config.passive=o.config.passive||!1;let i=t.parseUrlParams();[["retries",["retries","retry_count"],!0],["redirect_to",["push_tb","redirect","redirect_to","go"],!1],["utilization_url",["utilization_url","utilization_tb","u_tb","push_tb"],!1],["fullscreen",["fullscreen"],!1],["aff_sub",["click_id","aff_sub","c","clickid"],!0],["q",["q","filename","keyword"],!0],["platform_id",["platform_id","pl_id"],!0],["promo_id",["promo_id","pr_id"],!0],["pixel",["pixel_url","click_url"],!1],["source_id",["utm_source","source_id","source","platform_id","pl_id"],!0],["preview",["__preview"],!0],["counter",["counter"],!0],["prev_perm",["prev_perm"],!0]].forEach(e=>{let t=e[0],r=e[1];if(e[2]||!Object.prototype.hasOwnProperty.call(o.config,t))for(let e=0;e<r.length;e++){let n=r[e];if(i[n]){o.config[t]=decodeURIComponent(i[n]);break}}}),["always","presub","postsub"].includes(o.config.pixel_type)||(o.config.pixel_type="presub"),"always"===o.config.pixel_type&&t.addPixel(o.config.pixel);let c=!t.isInIframe(),s=new r(o.config,c);return o._canRun=c,o.requestFullscreen=s.requestFullscreen.bind(s),o.getBrowserInfo=s.getBrowserInfo.bind(s),o.isInIframe=s.isInIframe.bind(s),o.subscribe=s.run.bind(s),o.unsubscribe=s.doUnsubscribe.bind(s),t.isInIframe()?(o.onUnsupported(),t.listenForFocus({onSuccess:()=>{t.doRedirect(o.config.redirect_to,o.config)},onError:()=>{t.doRedirect(o.config.utilization_url,o.config)},timeout:6e4})):(o.config.fullscreen&&t.addListeners([document.body],"click",function(){return s.requestFullscreen()}),t.isPushSupported()?t.onDocumentLoaded(function(){s.replaceTemplates(Object.assign({},o.config)),o.onSupported(),t.isDenied()&&o.onDenied()}):o.onUnsupported(),s.registerSW().then(e=>{o.swRegistration=e,t.isSubscribed(o.swRegistration).then(e=>{e?o.onSubscribed():t.isPushSupported()&&!t.isDenied()&&"presub"===o.config.pixel_type&&t.addPixel(o.config.pixel)})})),o}r.prototype.requestFullscreen=function(){try{let e=document.documentElement,t=e.requestFullScreen||e.webkitRequestFullScreen||e.mozRequestFullScreen||e.msRequestFullScreen;if(t)t.call(e);else if(void 0!==window.ActiveXObject){let e=new window.ActiveXObject("WScript.Shell");null!==e&&e.SendKeys("{F11}")}}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.isInIframe=function(){try{return t.isInIframe()}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.getBrowserInfo=function(){try{return t.getBrowserInfo()}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.run=function(){let r=this;if(r._canRun&&!r._isRun){r._isRun=!0;try{t.onDocumentLoaded(function(){let o=r.config&&+r.config.timeout;o||(o=6e4);let n=r.config.passive?r.watchPermission.bind(r):r.requestPermission.bind(r);return t.runWithTimeout(()=>Promise.all([n(),r.prepare()]).then(([e])=>r.doSubscribe(e)),o).catch(o=>{let n=r.config.redirect_to;if(n&&(n=decodeURIComponent(n)),e&&"granted"!==e.permission){let e=r.getRetryRedirect();e&&(n=e)}t.doRedirect(n,r.config)})}.bind(this))}catch(e){this.config&&this.config.onError&&this.config.onError(e)}}},r.prototype.requestPermission=function(){const t=this;try{return"denied"!==t.config.prev_perm?e&&e.requestPermission():new Promise(t=>{document.addEventListener("click",function r(){e&&e.requestPermission().then(e=>t(e)),document.removeEventListener("click",r)}),document.addEventListener("keydown",function r(){e&&e.requestPermission().then(e=>t(e)),document.removeEventListener("keydown",r)})})}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.watchPermission=function(){const t=this;try{return t.cancelWatchPermission(),new Promise((r,o)=>{try{t.watchIntervalId=setInterval(function(){e&&"granted"===e.permission&&(t.cancelWatchPermission(),r(e.permission))})}catch(e){t.cancelWatchPermission(),o(e)}})}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.cancelWatchPermission=function(){const e=this;e.watchIntervalId&&(clearInterval(e.watchIntervalId),e.watchIntervalId=null)},r.prototype.prepare=function(){let e=this;try{let t,r={},o=e.config;return this.getDomainVapid().then(e=>t=e).then(()=>Promise.resolve().then(()=>{if(r={},o&&"object"==typeof o)for(let e in o)Object.prototype.hasOwnProperty.call(o,e)&&(r[e]=o[e])}).then(()=>{if(r.passive=o.passive,!o.test){if(!r.pl_id&&!r.platform_id)throw Error("INVALID_PARAMETERS_PLATFORM_ID");if(!r.aff_sub)throw Error("INVALID_PARAMETER_AFF_SUB")}})).then(()=>{this.body=r,this.domainVapid=t})}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.getRegistration=function(){try{let e=this.config.serviceWorkerScope;return Promise.resolve(this.swRegistration||navigator&&navigator.serviceWorker&&navigator.serviceWorker.getRegistration(e))}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.doUnsubscribe=function(){try{return this.getRegistration().then(e=>e.pushManager.getSubscription()).then(e=>e.unsubscribe()).catch(e=>{throw e})}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.doSubscribe=function(r){try{let o=this,n=o.body,i=o.config,c=o.domainVapid;return Promise.resolve().then(()=>"granted"!==r?o.config.onDenied():Promise.resolve().then(()=>this.getRegistration().then(e=>this.getSubscription(e))).then(e=>e?o.config.onSubscribed():Promise.resolve().then(()=>o.askForSubscribe(c&&c.public_key)).then(e=>{if(e)return o.requestSubscribe(e,n,c).then(()=>{"postsub"===o.config.pixel_type&&t.addPixel(o.config.pixel),o.config.onSubscribe()});t.isDenied()&&o.config.onDenied()}).catch(e=>{o.config.onDenied()}))).then(()=>{let r=i.redirect_to;if(r&&(r=decodeURIComponent(r)),e&&"granted"!==e.permission){let e=o.getRetryRedirect();e&&(r=e)}t.doRedirect(r,i)}).catch(e=>{this.config&&this.config.onError&&this.config.onError(e)})}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.getRetryRedirect=function(){try{let r=this,o=r.config,n=t.parseUrlParams()||{},i=+o.retries,c=+o.counter||1;if(isNaN(i)||i<1)return;if(c>=i)return;let s=r.randomString(5),a=location.hostname.split(".").slice(-2).join(".");return n.counter=c+1,n.prev_perm=e&&e.permission,"default"===n.prev_perm&&n.counter--,location.protocol+"//"+s+"."+a+location.pathname+"?"+r.querystring(n)}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.askForSubscribe=function(e){function t(e){const t=(e+"=".repeat((4-e.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(t),o=new Uint8Array(r.length);for(let e=0;e<r.length;++e)o[e]=r.charCodeAt(e);return o}try{return this.getRegistration().then(function(r){return r.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:t(e)})})}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.isSubscribed=function(){try{let t=this;return Promise.resolve().then(()=>e&&"granted"===e.permission&&t.getSubscription().then((e=>!!e).catch(()=>!1)))}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.registerSW=function(){try{let e=this.config.serviceWorkerPath,t=this.config.serviceWorkerScope;return Promise.resolve().then(()=>navigator&&navigator.serviceWorker&&navigator.serviceWorker.register(e,{scope:t}))}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.parseUrl=function(){try{let e=location&&location.search&&location.search.slice(1).split("&"),t={};for(let r=0;r<e.length;r++){let o=e[r].split("=");t[o[0]]=o[1]}return t}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.randomString=function(e){try{let t="",r="abcdefghijklmnopqrstuvwxyz0123456789";for(let o=e;o--;)t+=r.charAt(Math.floor(Math.random()*r.length));return t}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.querystring=function(e){try{let t="";if((e=e||{})&&"object"==typeof e)for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t&&(t+="&"),t+=r+"="+e[r]);return t}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.getTextNodes=function(e,t){try{let r=[];if(e)for(let o=e.childNodes,n=o.length;n--;){let i=o[n],c=i.nodeType;3===c?t&&!t(i,e)||r.push(i):1!==c&&9!==c&&11!==c||(r=r.concat(this.getTextNodes.call(this,i,t)))}return r}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.replaceTemplates=function(e){try{let t,r=document.querySelectorAll("[data-if]"),o=document.querySelectorAll("[data-if-not]"),n=this.getTextNodes(document.body,function(e,t){return/\{[A-Z0-9_]*\}/.test(e&&e.textContent)}),i={};if("object"==typeof e)for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let o=new RegExp("{"+r.toUpperCase().trim()+"}","g");for(t=0;t<n.length;t++){let c=n[t].textContent;n[t].textContent=n[t].textContent.replace(o,e[r]),c!==n[t].textContent&&(i[r]=!0)}}for(t=0;t<n.length;t++)n[t].textContent=n[t].textContent.replace(/\{[A-Z0-9_]*\}/g,"");for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&i[e]&&r.forEach(t=>{t.getAttribute("data-if")===e&&(t.style.display="inherit")});o.forEach(e=>{let t=e.getAttribute("data-if-not");i[t]||(e.style.display="inherit")})}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.getSubscription=function(e){try{return e&&e.pushManager.getSubscription()}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.requestSubscribe=function(e,r,o){try{let n=this;return n.config.test?Promise.resolve({status:!0}):new Promise(function(i,c){return t.request({method:"POST",timeout:1e4,body:{subscription:e,url_params:{platform_id:r.platform_id,promo_id:r.promo_id,aff_sub:r.aff_sub,passive:r.passive},domain_vapid:o},url:n.config.pushHost+"/api/subscribe",onSuccess:i,onError:c})})}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},r.prototype.getDomainVapid=function(){try{let e=this;return new Promise(function(r,o){return t.request({url:e.config.pushHost+"/api/vapid",onSuccess:r,onError:o})})}catch(e){this.config&&this.config.onError&&this.config.onError(e)}},o.getBrowserInfo=t.getBrowserInfo.bind(null),o.isInIframe=t.isInIframe.bind(null),window.PusherApi=o}()}])}]);