c.killtarget.com Open in urlscan Pro
195.201.81.219  Public Scan

Submitted URL: https://c.killtarget.com/get-code/main?id=1bf9f75eed33fcf0f6bdd331c5a2b26a
Effective URL: https://c.killtarget.com/get-code/main?id=1bf9f75eed33fcf0f6bdd331c5a2b26a
Submission: On March 25 via manual from US — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.firebase=e()}(this,function(){"use strict";!function(t){if(!t.fetch){var e={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(e.arrayBuffer)var r=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],n=function(t){return t&&DataView.prototype.isPrototypeOf(t)},o=ArrayBuffer.isView||function(t){return t&&r.indexOf(Object.prototype.toString.call(t))>-1};f.prototype.append=function(t,e){t=a(t),e=u(e);var r=this.map[t];this.map[t]=r?r+","+e:e},f.prototype.delete=function(t){delete this.map[a(t)]},f.prototype.get=function(t){return t=a(t),this.has(t)?this.map[t]:null},f.prototype.has=function(t){return this.map.hasOwnProperty(a(t))},f.prototype.set=function(t,e){this.map[a(t)]=u(e)},f.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},f.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),c(t)},f.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),c(t)},f.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),c(t)},e.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);var i=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},y.call(v.prototype),y.call(m.prototype),m.prototype.clone=function(){return new m(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},m.error=function(){var t=new m(null,{status:0,statusText:""});return t.type="error",t};var s=[301,302,303,307,308];m.redirect=function(t,e){if(-1===s.indexOf(e))throw new RangeError("Invalid status code");return new m(null,{status:e,headers:{location:t}})},t.Headers=f,t.Request=v,t.Response=m,t.fetch=function(t,r){return new Promise(function(n,o){var i=new v(t,r),s=new XMLHttpRequest;s.onload=function(){var t,e,r={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",e=new f,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var r=t.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();e.append(n,o)}}),e)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var o="response"in s?s.response:s.responseText;n(new m(o,r))},s.onerror=function(){o(new TypeError("Network request failed"))},s.ontimeout=function(){o(new TypeError("Network request failed"))},s.open(i.method,i.url,!0),"include"===i.credentials?s.withCredentials=!0:"omit"===i.credentials&&(s.withCredentials=!1),"responseType"in s&&e.blob&&(s.responseType="blob"),i.headers.forEach(function(t,e){s.setRequestHeader(e,t)}),s.send(void 0===i._bodyInit?null:i._bodyInit)})},t.fetch.polyfill=!0}function a(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function u(t){return"string"!=typeof t&&(t=String(t)),t}function c(t){var r={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return e.iterable&&(r[Symbol.iterator]=function(){return r}),r}function f(t){this.map={},t instanceof f?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function h(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function l(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function p(t){var e=new FileReader,r=l(e);return e.readAsArrayBuffer(t),r}function d(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function y(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,t)if("string"==typeof t)this._bodyText=t;else if(e.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(e.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(e.arrayBuffer&&e.blob&&n(t))this._bodyArrayBuffer=d(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!e.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t)&&!o(t))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=d(t)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},e.blob&&(this.blob=function(){var t=h(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(p)}),this.text=function(){var t,e,r,n=h(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=l(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},e.formData&&(this.formData=function(){return this.text().then(b)}),this.json=function(){return this.text().then(JSON.parse)},this}function v(t,e){var r,n,o=(e=e||{}).body;if(t instanceof v){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new f(t.headers)),this.method=t.method,this.mode=t.mode,o||null==t._bodyInit||(o=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new f(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),i.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function b(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}}),e}function m(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new f(e.headers),this.url=e.url||"",this._initBody(t)}}("undefined"!=typeof self?self:void 0);var t=setTimeout;function e(){}function r(t){if(!(this instanceof r))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],a(t,this)}function n(t,e){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,r._immediateFn(function(){var r=1===t._state?e.onFulfilled:e.onRejected;if(null!==r){var n;try{n=r(t._value)}catch(t){return void i(e.promise,t)}o(e.promise,n)}else(1===t._state?o:i)(e.promise,t._value)})):t._deferreds.push(e)}function o(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof r)return t._state=3,t._value=e,void s(t);if("function"==typeof n)return void a((o=n,u=e,function(){o.apply(u,arguments)}),t)}t._state=1,t._value=e,s(t)}catch(e){i(t,e)}var o,u}function i(t,e){t._state=2,t._value=e,s(t)}function s(t){2===t._state&&0===t._deferreds.length&&r._immediateFn(function(){t._handled||r._unhandledRejectionFn(t._value)});for(var e=0,o=t._deferreds.length;e<o;e++)n(t,t._deferreds[e]);t._deferreds=null}function a(t,e){var r=!1;try{t(function(t){r||(r=!0,o(e,t))},function(t){r||(r=!0,i(e,t))})}catch(t){if(r)return;r=!0,i(e,t)}}r.prototype.catch=function(t){return this.then(null,t)},r.prototype.then=function(t,r){var o=new this.constructor(e);return n(this,new function(t,e,r){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=r}(t,r,o)),o},r.prototype.finally=function(t){var e=this.constructor;return this.then(function(r){return e.resolve(t()).then(function(){return r})},function(r){return e.resolve(t()).then(function(){return e.reject(r)})})},r.all=function(t){return new r(function(e,r){if(!t||void 0===t.length)throw new TypeError("Promise.all accepts an array");var n=Array.prototype.slice.call(t);if(0===n.length)return e([]);var o=n.length;function i(t,s){try{if(s&&("object"==typeof s||"function"==typeof s)){var a=s.then;if("function"==typeof a)return void a.call(s,function(e){i(t,e)},r)}n[t]=s,0==--o&&e(n)}catch(t){r(t)}}for(var s=0;s<n.length;s++)i(s,n[s])})},r.resolve=function(t){return t&&"object"==typeof t&&t.constructor===r?t:new r(function(e){e(t)})},r.reject=function(t){return new r(function(e,r){r(t)})},r.race=function(t){return new r(function(e,r){for(var n=0,o=t.length;n<o;n++)t[n].then(e,r)})},r._immediateFn="function"==typeof setImmediate&&function(t){setImmediate(t)}||function(e){t(e,0)},r._unhandledRejectionFn=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};var u=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")}();function c(t,e){return t(e={exports:{}},e.exports),e.exports}u.Promise||(u.Promise=r);var f=c(function(t){var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)}),h=c(function(t){var e=t.exports={version:"2.5.5"};"number"==typeof __e&&(__e=e)}),l=(h.version,function(t){return"object"==typeof t?null!==t:"function"==typeof t}),p=function(t){if(!l(t))throw TypeError(t+" is not an object!");return t},d=function(t){try{return!!t()}catch(t){return!0}},y=!d(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),v=f.document,b=l(v)&&l(v.createElement),m=function(t){return b?v.createElement(t):{}},_=!y&&!d(function(){return 7!=Object.defineProperty(m("div"),"a",{get:function(){return 7}}).a}),g=function(t,e){if(!l(t))return t;var r,n;if(e&&"function"==typeof(r=t.toString)&&!l(n=r.call(t)))return n;if("function"==typeof(r=t.valueOf)&&!l(n=r.call(t)))return n;if(!e&&"function"==typeof(r=t.toString)&&!l(n=r.call(t)))return n;throw TypeError("Can't convert object to primitive value")},w=Object.defineProperty,O={f:y?Object.defineProperty:function(t,e,r){if(p(t),e=g(e,!0),p(r),_)try{return w(t,e,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[e]=r.value),t}},S=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},E=y?function(t,e,r){return O.f(t,e,S(1,r))}:function(t,e,r){return t[e]=r,t},A={}.hasOwnProperty,j=function(t,e){return A.call(t,e)},P=0,T=Math.random(),k=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++P+T).toString(36))},x=c(function(t){var e=k("src"),r=Function.toString,n=(""+r).split("toString");h.inspectSource=function(t){return r.call(t)},(t.exports=function(t,r,o,i){var s="function"==typeof o;s&&(j(o,"name")||E(o,"name",r)),t[r]!==o&&(s&&(j(o,e)||E(o,e,t[r]?""+t[r]:n.join(String(r)))),t===f?t[r]=o:i?t[r]?t[r]=o:E(t,r,o):(delete t[r],E(t,r,o)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[e]||r.call(this)})}),F=function(t,e,r){if(function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!")}(t),void 0===e)return t;switch(r){case 1:return function(r){return t.call(e,r)};case 2:return function(r,n){return t.call(e,r,n)};case 3:return function(r,n,o){return t.call(e,r,n,o)}}return function(){return t.apply(e,arguments)}},L=function(t,e,r){var n,o,i,s,a=t&L.F,u=t&L.G,c=t&L.S,l=t&L.P,p=t&L.B,d=u?f:c?f[e]||(f[e]={}):(f[e]||{}).prototype,y=u?h:h[e]||(h[e]={}),v=y.prototype||(y.prototype={});for(n in u&&(r=e),r)i=((o=!a&&d&&void 0!==d[n])?d:r)[n],s=p&&o?F(i,f):l&&"function"==typeof i?F(Function.call,i):i,d&&x(d,n,i,t&L.U),y[n]!=i&&E(y,n,s),l&&v[n]!=i&&(v[n]=i)};f.core=h,L.F=1,L.G=2,L.S=4,L.P=8,L.B=16,L.W=32,L.U=64,L.R=128;var N=L,D={}.toString,I=function(t){return D.call(t).slice(8,-1)},R=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==I(t)?t.split(""):Object(t)},B=function(t){if(void 0==t)throw TypeError("Can't call method on  "+t);return t},C=function(t){return Object(B(t))},U=Math.ceil,M=Math.floor,z=function(t){return isNaN(t=+t)?0:(t>0?M:U)(t)},G=Math.min,W=function(t){return t>0?G(z(t),9007199254740991):0},H=Array.isArray||function(t){return"Array"==I(t)},V=f["__core-js_shared__"]||(f["__core-js_shared__"]={}),q=function(t){return V[t]||(V[t]={})},K=c(function(t){var e=q("wks"),r=f.Symbol,n="function"==typeof r;(t.exports=function(t){return e[t]||(e[t]=n&&r[t]||(n?r:k)("Symbol."+t))}).store=e}),$=K("species"),J=function(t,e){return new(function(t){var e;return H(t)&&("function"!=typeof(e=t.constructor)||e!==Array&&!H(e.prototype)||(e=void 0),l(e)&&null===(e=e[$])&&(e=void 0)),void 0===e?Array:e}(t))(e)},Y=function(t,e){var r=1==t,n=2==t,o=3==t,i=4==t,s=6==t,a=5==t||s,u=e||J;return function(e,c,f){for(var h,l,p=C(e),d=R(p),y=F(c,f,3),v=W(d.length),b=0,m=r?u(e,v):n?u(e,0):void 0;v>b;b++)if((a||b in d)&&(l=y(h=d[b],b,p),t))if(r)m[b]=l;else if(l)switch(t){case 3:return!0;case 5:return h;case 6:return b;case 2:m.push(h)}else if(i)return!1;return s?-1:o||i?i:m}},X=K("unscopables"),Q=Array.prototype;void 0==Q[X]&&E(Q,X,{});var Z=function(t){Q[X][t]=!0},tt=Y(5),et=!0;"find"in[]&&Array(1).find(function(){et=!1}),N(N.P+N.F*et,"Array",{find:function(t){return tt(this,t,arguments.length>1?arguments[1]:void 0)}}),Z("find");h.Array.find;var rt=Y(6),nt=!0;"findIndex"in[]&&Array(1).findIndex(function(){nt=!1}),N(N.P+N.F*nt,"Array",{findIndex:function(t){return rt(this,t,arguments.length>1?arguments[1]:void 0)}}),Z("findIndex");h.Array.findIndex;var ot,it=function(t){return R(B(t))},st=Math.max,at=Math.min,ut=q("keys"),ct=function(t){return ut[t]||(ut[t]=k(t))},ft=(ot=!1,function(t,e,r){var n,o=it(t),i=W(o.length),s=function(t,e){return(t=z(t))<0?st(t+e,0):at(t,e)}(r,i);if(ot&&e!=e){for(;i>s;)if((n=o[s++])!=n)return!0}else for(;i>s;s++)if((ot||s in o)&&o[s]===e)return ot||s||0;return!ot&&-1}),ht=ct("IE_PROTO"),lt=function(t,e){var r,n=it(t),o=0,i=[];for(r in n)r!=ht&&j(n,r)&&i.push(r);for(;e.length>o;)j(n,r=e[o++])&&(~ft(i,r)||i.push(r));return i},pt="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),dt=Object.keys||function(t){return lt(t,pt)},yt={f:Object.getOwnPropertySymbols},vt={f:{}.propertyIsEnumerable},bt=Object.assign,mt=!bt||d(function(){var t={},e={},r=Symbol(),n="abcdefghijklmnopqrst";return t[r]=7,n.split("").forEach(function(t){e[t]=t}),7!=bt({},t)[r]||Object.keys(bt({},e)).join("")!=n})?function(t,e){for(var r=C(t),n=arguments.length,o=1,i=yt.f,s=vt.f;n>o;)for(var a,u=R(arguments[o++]),c=i?dt(u).concat(i(u)):dt(u),f=c.length,h=0;f>h;)s.call(u,a=c[h++])&&(r[a]=u[a]);return r}:bt;N(N.S+N.F,"Object",{assign:mt});h.Object.assign;var _t=K("match"),gt=function(t,e,r){if(l(n=e)&&(void 0!==(o=n[_t])?o:"RegExp"==I(n)))throw TypeError("String#"+r+" doesn't accept regex!");var n,o;return String(B(t))},wt=K("match"),Ot="".startsWith;N(N.P+N.F*function(t){var e=/./;try{"/./"[t](e)}catch(r){try{return e[wt]=!1,!"/./"[t](e)}catch(t){}}return!0}("startsWith"),"String",{startsWith:function(t){var e=gt(this,t,"startsWith"),r=W(Math.min(arguments.length>1?arguments[1]:void 0,e.length)),n=String(t);return Ot?Ot.call(e,n,r):e.slice(r,r+n.length)===n}});h.String.startsWith;N(N.P,"String",{repeat:function(t){var e=String(B(this)),r="",n=z(t);if(n<0||n==1/0)throw RangeError("Count can't be negative");for(;n>0;(n>>>=1)&&(e+=e))1&n&&(r+=e);return r}});h.String.repeat;var St=c(function(t){var e=k("meta"),r=O.f,n=0,o=Object.isExtensible||function(){return!0},i=!d(function(){return o(Object.preventExtensions({}))}),s=function(t){r(t,e,{value:{i:"O"+ ++n,w:{}}})},a=t.exports={KEY:e,NEED:!1,fastKey:function(t,r){if(!l(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!j(t,e)){if(!o(t))return"F";if(!r)return"E";s(t)}return t[e].i},getWeak:function(t,r){if(!j(t,e)){if(!o(t))return!0;if(!r)return!1;s(t)}return t[e].w},onFreeze:function(t){return i&&a.NEED&&o(t)&&!j(t,e)&&s(t),t}}}),Et=(St.KEY,St.NEED,St.fastKey,St.getWeak,St.onFreeze,O.f),At=K("toStringTag"),jt=function(t,e,r){t&&!j(t=r?t:t.prototype,At)&&Et(t,At,{configurable:!0,value:e})},Pt={f:K},Tt=O.f,kt=function(t){var e=h.Symbol||(h.Symbol=f.Symbol||{});"_"==t.charAt(0)||t in e||Tt(e,t,{value:Pt.f(t)})},xt=y?Object.defineProperties:function(t,e){p(t);for(var r,n=dt(e),o=n.length,i=0;o>i;)O.f(t,r=n[i++],e[r]);return t},Ft=f.document,Lt=Ft&&Ft.documentElement,Nt=ct("IE_PROTO"),Dt=function(){},It=function(){var t,e=m("iframe"),r=pt.length;for(e.style.display="none",Lt.appendChild(e),e.src="javascript:",(t=e.contentWindow.document).open(),t.write("<script>document.F=Object<\/script>"),t.close(),It=t.F;r--;)delete It.prototype[pt[r]];return It()},Rt=Object.create||function(t,e){var r;return null!==t?(Dt.prototype=p(t),r=new Dt,Dt.prototype=null,r[Nt]=t):r=It(),void 0===e?r:xt(r,e)},Bt=pt.concat("length","prototype"),Ct={f:Object.getOwnPropertyNames||function(t){return lt(t,Bt)}},Ut=Ct.f,Mt={}.toString,zt="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],Gt={f:function(t){return zt&&"[object Window]"==Mt.call(t)?function(t){try{return Ut(t)}catch(t){return zt.slice()}}(t):Ut(it(t))}},Wt=Object.getOwnPropertyDescriptor,Ht={f:y?Wt:function(t,e){if(t=it(t),e=g(e,!0),_)try{return Wt(t,e)}catch(t){}if(j(t,e))return S(!vt.f.call(t,e),t[e])}},Vt=St.KEY,qt=Ht.f,Kt=O.f,$t=Gt.f,Jt=f.Symbol,Yt=f.JSON,Xt=Yt&&Yt.stringify,Qt=K("_hidden"),Zt=K("toPrimitive"),te={}.propertyIsEnumerable,ee=q("symbol-registry"),re=q("symbols"),ne=q("op-symbols"),oe=Object.prototype,ie="function"==typeof Jt,se=f.QObject,ae=!se||!se.prototype||!se.prototype.findChild,ue=y&&d(function(){return 7!=Rt(Kt({},"a",{get:function(){return Kt(this,"a",{value:7}).a}})).a})?function(t,e,r){var n=qt(oe,e);n&&delete oe[e],Kt(t,e,r),n&&t!==oe&&Kt(oe,e,n)}:Kt,ce=function(t){var e=re[t]=Rt(Jt.prototype);return e._k=t,e},fe=ie&&"symbol"==typeof Jt.iterator?function(t){return"symbol"==typeof t}:function(t){return t instanceof Jt},he=function(t,e,r){return t===oe&&he(ne,e,r),p(t),e=g(e,!0),p(r),j(re,e)?(r.enumerable?(j(t,Qt)&&t[Qt][e]&&(t[Qt][e]=!1),r=Rt(r,{enumerable:S(0,!1)})):(j(t,Qt)||Kt(t,Qt,S(1,{})),t[Qt][e]=!0),ue(t,e,r)):Kt(t,e,r)},le=function(t,e){p(t);for(var r,n=function(t){var e=dt(t),r=yt.f;if(r)for(var n,o=r(t),i=vt.f,s=0;o.length>s;)i.call(t,n=o[s++])&&e.push(n);return e}(e=it(e)),o=0,i=n.length;i>o;)he(t,r=n[o++],e[r]);return t},pe=function(t){var e=te.call(this,t=g(t,!0));return!(this===oe&&j(re,t)&&!j(ne,t))&&(!(e||!j(this,t)||!j(re,t)||j(this,Qt)&&this[Qt][t])||e)},de=function(t,e){if(t=it(t),e=g(e,!0),t!==oe||!j(re,e)||j(ne,e)){var r=qt(t,e);return!r||!j(re,e)||j(t,Qt)&&t[Qt][e]||(r.enumerable=!0),r}},ye=function(t){for(var e,r=$t(it(t)),n=[],o=0;r.length>o;)j(re,e=r[o++])||e==Qt||e==Vt||n.push(e);return n},ve=function(t){for(var e,r=t===oe,n=$t(r?ne:it(t)),o=[],i=0;n.length>i;)!j(re,e=n[i++])||r&&!j(oe,e)||o.push(re[e]);return o};ie||(x((Jt=function(){if(this instanceof Jt)throw TypeError("Symbol is not a constructor!");var t=k(arguments.length>0?arguments[0]:void 0),e=function(r){this===oe&&e.call(ne,r),j(this,Qt)&&j(this[Qt],t)&&(this[Qt][t]=!1),ue(this,t,S(1,r))};return y&&ae&&ue(oe,t,{configurable:!0,set:e}),ce(t)}).prototype,"toString",function(){return this._k}),Ht.f=de,O.f=he,Ct.f=Gt.f=ye,vt.f=pe,yt.f=ve,y&&x(oe,"propertyIsEnumerable",pe,!0),Pt.f=function(t){return ce(K(t))}),N(N.G+N.W+N.F*!ie,{Symbol:Jt});for(var be="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),me=0;be.length>me;)K(be[me++]);for(var _e=dt(K.store),ge=0;_e.length>ge;)kt(_e[ge++]);N(N.S+N.F*!ie,"Symbol",{for:function(t){return j(ee,t+="")?ee[t]:ee[t]=Jt(t)},keyFor:function(t){if(!fe(t))throw TypeError(t+" is not a symbol!");for(var e in ee)if(ee[e]===t)return e},useSetter:function(){ae=!0},useSimple:function(){ae=!1}}),N(N.S+N.F*!ie,"Object",{create:function(t,e){return void 0===e?Rt(t):le(Rt(t),e)},defineProperty:he,defineProperties:le,getOwnPropertyDescriptor:de,getOwnPropertyNames:ye,getOwnPropertySymbols:ve}),Yt&&N(N.S+N.F*(!ie||d(function(){var t=Jt();return"[null]"!=Xt([t])||"{}"!=Xt({a:t})||"{}"!=Xt(Object(t))})),"JSON",{stringify:function(t){for(var e,r,n=[t],o=1;arguments.length>o;)n.push(arguments[o++]);if(r=e=n[1],(l(e)||void 0!==t)&&!fe(t))return H(e)||(e=function(t,e){if("function"==typeof r&&(e=r.call(this,t,e)),!fe(e))return e}),n[1]=e,Xt.apply(Yt,n)}}),Jt.prototype[Zt]||E(Jt.prototype,Zt,Jt.prototype.valueOf),jt(Jt,"Symbol"),jt(Math,"Math",!0),jt(f.JSON,"JSON",!0);var we=K("toStringTag"),Oe="Arguments"==I(function(){return arguments}()),Se={};Se[K("toStringTag")]="z",Se+""!="[object z]"&&x(Object.prototype,"toString",function(){return"[object "+(void 0===(t=this)?"Undefined":null===t?"Null":"string"==typeof(r=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),we))?r:Oe?I(e):"Object"==(n=I(e))&&"function"==typeof e.callee?"Arguments":n)+"]";var t,e,r,n},!0),kt("asyncIterator"),kt("observable");h.Symbol;var Ee={},Ae={};E(Ae,K("iterator"),function(){return this});var je,Pe=function(t,e,r){t.prototype=Rt(Ae,{next:S(1,r)}),jt(t,e+" Iterator")},Te=ct("IE_PROTO"),ke=Object.prototype,xe=Object.getPrototypeOf||function(t){return t=C(t),j(t,Te)?t[Te]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?ke:null},Fe=K("iterator"),Le=!([].keys&&"next"in[].keys()),Ne=function(){return this},De=function(t,e,r,n,o,i,s){Pe(r,e,n);var a,u,c,f=function(t){if(!Le&&t in d)return d[t];switch(t){case"keys":case"values":return function(){return new r(this,t)}}return function(){return new r(this,t)}},h=e+" Iterator",l="values"==o,p=!1,d=t.prototype,y=d[Fe]||d["@@iterator"]||o&&d[o],v=y||f(o),b=o?l?f("entries"):v:void 0,m="Array"==e&&d.entries||y;if(m&&(c=xe(m.call(new t)))!==Object.prototype&&c.next&&(jt(c,h,!0),"function"!=typeof c[Fe]&&E(c,Fe,Ne)),l&&y&&"values"!==y.name&&(p=!0,v=function(){return y.call(this)}),(Le||p||!d[Fe])&&E(d,Fe,v),Ee[e]=v,Ee[h]=Ne,o)if(a={values:l?v:f("values"),keys:i?v:f("keys"),entries:b},s)for(u in a)u in d||x(d,u,a[u]);else N(N.P+N.F*(Le||p),e,a);return a},Ie=(je=!0,function(t,e){var r,n,o=String(B(t)),i=z(e),s=o.length;return i<0||i>=s?je?"":void 0:(r=o.charCodeAt(i))<55296||r>56319||i+1===s||(n=o.charCodeAt(i+1))<56320||n>57343?je?o.charAt(i):r:je?o.slice(i,i+2):n-56320+(r-55296<<10)+65536});De(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,e=this._t,r=this._i;return r>=e.length?{value:void 0,done:!0}:(t=Ie(e,r),this._i+=t.length,{value:t,done:!1})});var Re=function(t,e){return{value:e,done:!!t}},Be=De(Array,"Array",function(t,e){this._t=it(t),this._i=0,this._k=e},function(){var t=this._t,e=this._k,r=this._i++;return!t||r>=t.length?(this._t=void 0,Re(1)):Re(0,"keys"==e?r:"values"==e?t[r]:[r,t[r]])},"values");Ee.Arguments=Ee.Array,Z("keys"),Z("values"),Z("entries");for(var Ce=K("iterator"),Ue=K("toStringTag"),Me=Ee.Array,ze={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},Ge=dt(ze),We=0;We<Ge.length;We++){var He,Ve=Ge[We],qe=ze[Ve],Ke=f[Ve],$e=Ke&&Ke.prototype;if($e&&($e[Ce]||E($e,Ce,Me),$e[Ue]||E($e,Ue,Ve),Ee[Ve]=Me,qe))for(He in Be)$e[He]||x($e,He,Be[He],!0)}Pt.f("iterator");var Je=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};function Ye(t,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:return new Date(e.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return e}for(var r in e)e.hasOwnProperty(r)&&(t[r]=Ye(t[r],e[r]));return t}function Xe(t,e,r){t[e]=r}var Qe="FirebaseError",Ze=Error.captureStackTrace,tr=function(){return function(t,e){if(this.code=t,this.message=e,Ze)Ze(this,er.prototype.create);else try{throw Error.apply(this,arguments)}catch(t){this.name=Qe,Object.defineProperty(this,"stack",{get:function(){return t.stack}})}}}();tr.prototype=Object.create(Error.prototype),tr.prototype.constructor=tr,tr.prototype.name=Qe;var er=function(){function t(t,e,r){this.service=t,this.serviceName=e,this.errors=r,this.pattern=/\{\$([^}]+)}/g}return t.prototype.create=function(t,e){void 0===e&&(e={});var r,n=this.errors[t],o=this.service+"/"+t;r=void 0===n?"Error":n.replace(this.pattern,function(t,r){var n=e[r];return void 0!==n?n.toString():"<"+r+"?>"}),r=this.serviceName+": "+r+" ("+o+").";var i=new tr(o,r);for(var s in e)e.hasOwnProperty(s)&&"_"!==s.slice(-1)&&(i[s]=e[s]);return i},t}();!function(t){function e(){var e=t.call(this)||this;e.chain_=[],e.buf_=[],e.W_=[],e.pad_=[],e.inbuf_=0,e.total_=0,e.blockSize=64,e.pad_[0]=128;for(var r=1;r<e.blockSize;++r)e.pad_[r]=0;return e.reset(),e}(function(t,e){function r(){this.constructor=t}Je(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)})(e,t),e.prototype.reset=function(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0},e.prototype.compress_=function(t,e){e||(e=0);var r=this.W_;if("string"==typeof t)for(var n=0;n<16;n++)r[n]=t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|t.charCodeAt(e+3),e+=4;else for(n=0;n<16;n++)r[n]=t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3],e+=4;for(n=16;n<80;n++){var o=r[n-3]^r[n-8]^r[n-14]^r[n-16];r[n]=4294967295&(o<<1|o>>>31)}var i,s,a=this.chain_[0],u=this.chain_[1],c=this.chain_[2],f=this.chain_[3],h=this.chain_[4];for(n=0;n<80;n++){n<40?n<20?(i=f^u&(c^f),s=1518500249):(i=u^c^f,s=1859775393):n<60?(i=u&c|f&(u|c),s=2400959708):(i=u^c^f,s=3395469782);o=(a<<5|a>>>27)+i+h+s+r[n]&4294967295;h=f,f=c,c=4294967295&(u<<30|u>>>2),u=a,a=o}this.chain_[0]=this.chain_[0]+a&4294967295,this.chain_[1]=this.chain_[1]+u&4294967295,this.chain_[2]=this.chain_[2]+c&4294967295,this.chain_[3]=this.chain_[3]+f&4294967295,this.chain_[4]=this.chain_[4]+h&4294967295},e.prototype.update=function(t,e){if(null!=t){void 0===e&&(e=t.length);for(var r=e-this.blockSize,n=0,o=this.buf_,i=this.inbuf_;n<e;){if(0==i)for(;n<=r;)this.compress_(t,n),n+=this.blockSize;if("string"==typeof t){for(;n<e;)if(o[i]=t.charCodeAt(n),++n,++i==this.blockSize){this.compress_(o),i=0;break}}else for(;n<e;)if(o[i]=t[n],++n,++i==this.blockSize){this.compress_(o),i=0;break}}this.inbuf_=i,this.total_+=e}},e.prototype.digest=function(){var t=[],e=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(var r=this.blockSize-1;r>=56;r--)this.buf_[r]=255&e,e/=256;this.compress_(this.buf_);var n=0;for(r=0;r<5;r++)for(var o=24;o>=0;o-=8)t[n]=this.chain_[r]>>o&255,++n;return t}}(function(){return function(){this.blockSize=-1}}());function rr(t,e){var r=new nr(t,e);return r.subscribe.bind(r)}var nr=function(){function t(t,e){var r=this;this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=e,this.task.then(function(){t(r)}).catch(function(t){r.error(t)})}return t.prototype.next=function(t){this.forEachObserver(function(e){e.next(t)})},t.prototype.error=function(t){this.forEachObserver(function(e){e.error(t)}),this.close(t)},t.prototype.complete=function(){this.forEachObserver(function(t){t.complete()}),this.close()},t.prototype.subscribe=function(t,e,r){var n,o=this;if(void 0===t&&void 0===e&&void 0===r)throw new Error("Missing Observer.");void 0===(n=function(t,e){if("object"!=typeof t||null===t)return!1;for(var r=0,n=e;r<n.length;r++){var o=n[r];if(o in t&&"function"==typeof t[o])return!0}return!1}(t,["next","error","complete"])?t:{next:t,error:e,complete:r}).next&&(n.next=or),void 0===n.error&&(n.error=or),void 0===n.complete&&(n.complete=or);var i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(function(){try{o.finalError?n.error(o.finalError):n.complete()}catch(t){}}),this.observers.push(n),i},t.prototype.unsubscribeOne=function(t){void 0!==this.observers&&void 0!==this.observers[t]&&(delete this.observers[t],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))},t.prototype.forEachObserver=function(t){if(!this.finalized)for(var e=0;e<this.observers.length;e++)this.sendOne(e,t)},t.prototype.sendOne=function(t,e){var r=this;this.task.then(function(){if(void 0!==r.observers&&void 0!==r.observers[t])try{e(r.observers[t])}catch(t){"undefined"!=typeof console&&console.error&&console.error(t)}})},t.prototype.close=function(t){var e=this;this.finalized||(this.finalized=!0,void 0!==t&&(this.finalError=t),this.task.then(function(){e.observers=void 0,e.onNoObservers=void 0}))},t}();function or(){}var ir=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},sr="[DEFAULT]",ar=[],ur=function(){function t(t,e,r){this.firebase_=r,this.isDeleted_=!1,this.services_={},this.name_=e.name,this._automaticDataCollectionEnabled=e.automaticDataCollectionEnabled||!1,this.options_=Ye(void 0,t),this.INTERNAL={getUid:function(){return null},getToken:function(){return Promise.resolve(null)},addAuthTokenListener:function(t){ar.push(t),setTimeout(function(){return t(null)},0)},removeAuthTokenListener:function(t){ar=ar.filter(function(e){return e!==t})}}}return Object.defineProperty(t.prototype,"automaticDataCollectionEnabled",{get:function(){return this.checkDestroyed_(),this._automaticDataCollectionEnabled},set:function(t){this.checkDestroyed_(),this._automaticDataCollectionEnabled=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this.checkDestroyed_(),this.name_},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return this.checkDestroyed_(),this.options_},enumerable:!0,configurable:!0}),t.prototype.delete=function(){var t=this;return new Promise(function(e){t.checkDestroyed_(),e()}).then(function(){t.firebase_.INTERNAL.removeApp(t.name_);var e=[];return Object.keys(t.services_).forEach(function(r){Object.keys(t.services_[r]).forEach(function(n){e.push(t.services_[r][n])})}),Promise.all(e.map(function(t){return t.INTERNAL.delete()}))}).then(function(){t.isDeleted_=!0,t.services_={}})},t.prototype._getService=function(t,e){if(void 0===e&&(e=sr),this.checkDestroyed_(),this.services_[t]||(this.services_[t]={}),!this.services_[t][e]){var r=e!==sr?e:void 0,n=this.firebase_.INTERNAL.factories[t](this,this.extendApp.bind(this),r);this.services_[t][e]=n}return this.services_[t][e]},t.prototype.extendApp=function(t){var e=this;Ye(this,t),t.INTERNAL&&t.INTERNAL.addAuthTokenListener&&(ar.forEach(function(t){e.INTERNAL.addAuthTokenListener(t)}),ar=[])},t.prototype.checkDestroyed_=function(){this.isDeleted_&&cr("app-deleted",{name:this.name_})},t}();function cr(t,e){throw fr.create(t,e)}ur.prototype.name&&ur.prototype.options||ur.prototype.delete||console.log("dc");var fr=new er("app","Firebase",{"no-app":"No Firebase App '{$name}' has been created - call Firebase App.initializeApp()","bad-app-name":"Illegal App name: '{$name}","duplicate-app":"Firebase App named '{$name}' already exists","app-deleted":"Firebase App named '{$name}' already deleted","duplicate-service":"Firebase service named '{$name}' already registered","sa-not-supported":"Initializing the Firebase SDK with a service account is only allowed in a Node.js environment. On client devices, you should instead initialize the SDK with an api key and auth domain","invalid-app-argument":"firebase.{$name}() takes either no argument or a Firebase App instance."});return function t(){var e={},r={},n={},o={__esModule:!0,initializeApp:function(t,r){if(void 0===r&&(r={}),"object"!=typeof r||null===r){var n=r;r={name:n}}var i=r;void 0===i.name&&(i.name=sr);var s=i.name;"string"==typeof s&&s||cr("bad-app-name",{name:s+""}),ir(e,s)&&cr("duplicate-app",{name:s});var u=new ur(t,i,o);return e[s]=u,a(u,"create"),u},app:i,apps:null,Promise:Promise,SDK_VERSION:"5.4.2",INTERNAL:{registerService:function(t,e,a,u,c){r[t]&&cr("duplicate-service",{name:t}),r[t]=e,u&&(n[t]=u,s().forEach(function(t){u("create",t)}));var f=function(e){return void 0===e&&(e=i()),"function"!=typeof e[t]&&cr("invalid-app-argument",{name:t}),e[t]()};return void 0!==a&&Ye(f,a),o[t]=f,ur.prototype[t]=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return this._getService.bind(this,t).apply(this,c?e:[])},f},createFirebaseNamespace:t,extendNamespace:function(t){Ye(o,t)},createSubscribe:rr,ErrorFactory:er,removeApp:function(t){a(e[t],"delete"),delete e[t]},factories:r,useAsService:u,Promise:Promise,deepExtend:Ye}};function i(t){return ir(e,t=t||sr)||cr("no-app",{name:t}),e[t]}function s(){return Object.keys(e).map(function(t){return e[t]})}function a(t,e){Object.keys(r).forEach(function(r){var o=u(t,r);null!==o&&n[o]&&n[o](e,t)})}function u(t,e){if("serverAuth"===e)return null;var r=e;return t.options,r}return Xe(o,"default",o),Object.defineProperty(o,"apps",{get:s}),Xe(i,"App",ur),o}()});

!function(e,t){"use strict";try{t=t&&t.hasOwnProperty("default")?t.default:t;var n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};function r(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e};function o(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})}function s(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}var a="FirebaseError",c=Error.captureStackTrace,u=function(){return function(e,t){if(this.code=e,this.message=t,c)c(this,h.prototype.create);else try{throw Error.apply(this,arguments)}catch(e){this.name=a,Object.defineProperty(this,"stack",{get:function(){return e.stack}})}}}();u.prototype=Object.create(Error.prototype),u.prototype.constructor=u,u.prototype.name=a;var h=function(){function e(e,t,n){this.service=e,this.serviceName=t,this.errors=n,this.pattern=/\{\$([^}]+)}/g}return e.prototype.create=function(e,t){void 0===t&&(t={});var n,r=this.errors[e],i=this.service+"/"+e;n=void 0===r?"Error":r.replace(this.pattern,function(e,n){var r=t[n];return void 0!==r?r.toString():"<"+n+"?>"}),n=this.serviceName+": "+n+" ("+i+").";var o=new u(i,n);for(var s in t)t.hasOwnProperty(s)&&"_"!==s.slice(-1)&&(o[s]=t[s]);return o},e}();(function(e){function t(){var t=e.call(this)||this;t.chain_=[],t.buf_=[],t.W_=[],t.pad_=[],t.inbuf_=0,t.total_=0,t.blockSize=64,t.pad_[0]=128;for(var n=1;n<t.blockSize;++n)t.pad_[n]=0;return t.reset(),t}r(t,e),t.prototype.reset=function(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0},t.prototype.compress_=function(e,t){t||(t=0);var n=this.W_;if("string"==typeof e)for(var r=0;r<16;r++)n[r]=e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3),t+=4;else for(r=0;r<16;r++)n[r]=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3],t+=4;for(r=16;r<80;r++){var i=n[r-3]^n[r-8]^n[r-14]^n[r-16];n[r]=4294967295&(i<<1|i>>>31)}var o,s,a=this.chain_[0],c=this.chain_[1],u=this.chain_[2],h=this.chain_[3],f=this.chain_[4];for(r=0;r<80;r++){r<40?r<20?(o=h^c&(u^h),s=1518500249):(o=c^u^h,s=1859775393):r<60?(o=c&u|h&(c|u),s=2400959708):(o=c^u^h,s=3395469782);i=(a<<5|a>>>27)+o+f+s+n[r]&4294967295;f=h,h=u,u=4294967295&(c<<30|c>>>2),c=a,a=i}this.chain_[0]=this.chain_[0]+a&4294967295,this.chain_[1]=this.chain_[1]+c&4294967295,this.chain_[2]=this.chain_[2]+u&4294967295,this.chain_[3]=this.chain_[3]+h&4294967295,this.chain_[4]=this.chain_[4]+f&4294967295},t.prototype.update=function(e,t){if(null!=e){void 0===t&&(t=e.length);for(var n=t-this.blockSize,r=0,i=this.buf_,o=this.inbuf_;r<t;){if(0==o)for(;r<=n;)this.compress_(e,r),r+=this.blockSize;if("string"==typeof e){for(;r<t;)if(i[o]=e.charCodeAt(r),++r,++o==this.blockSize){this.compress_(i),o=0;break}}else for(;r<t;)if(i[o]=e[r],++r,++o==this.blockSize){this.compress_(i),o=0;break}}this.inbuf_=o,this.total_+=t}},t.prototype.digest=function(){var e=[],t=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(var n=this.blockSize-1;n>=56;n--)this.buf_[n]=255&t,t/=256;this.compress_(this.buf_);var r=0;for(n=0;n<5;n++)for(var i=24;i>=0;i-=8)e[r]=this.chain_[n]>>i&255,++r;return e}})(function(){return function(){this.blockSize=-1}}());function f(e,t){var n=new d(e,t);return n.subscribe.bind(n)}var d=function(){function e(e,t){var n=this;this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(function(){e(n)}).catch(function(e){n.error(e)})}return e.prototype.next=function(e){this.forEachObserver(function(t){t.next(e)})},e.prototype.error=function(e){this.forEachObserver(function(t){t.error(e)}),this.close(e)},e.prototype.complete=function(){this.forEachObserver(function(e){e.complete()}),this.close()},e.prototype.subscribe=function(e,t,n){var r,i=this;if(void 0===e&&void 0===t&&void 0===n)throw new Error("Missing Observer.");void 0===(r=function(e,t){if("object"!=typeof e||null===e)return!1;for(var n=0,r=t;n<r.length;n++){var i=r[n];if(i in e&&"function"==typeof e[i])return!0}return!1}(e,["next","error","complete"])?e:{next:e,error:t,complete:n}).next&&(r.next=p),void 0===r.error&&(r.error=p),void 0===r.complete&&(r.complete=p);var o=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(function(){try{i.finalError?r.error(i.finalError):r.complete()}catch(e){}}),this.observers.push(r),o},e.prototype.unsubscribeOne=function(e){void 0!==this.observers&&void 0!==this.observers[e]&&(delete this.observers[e],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))},e.prototype.forEachObserver=function(e){if(!this.finalized)for(var t=0;t<this.observers.length;t++)this.sendOne(t,e)},e.prototype.sendOne=function(e,t){var n=this;this.task.then(function(){if(void 0!==n.observers&&void 0!==n.observers[e])try{t(n.observers[e])}catch(e){"undefined"!=typeof console&&console.error&&console.error(e)}})},e.prototype.close=function(e){var t=this;this.finalized||(this.finalized=!0,void 0!==e&&(this.finalError=e),this.task.then(function(){t.observers=void 0,t.onNoObservers=void 0}))},e}();function p(){}var l,_,E,b={AVAILABLE_IN_WINDOW:"only-available-in-window",AVAILABLE_IN_SW:"only-available-in-sw",SHOULD_BE_INHERITED:"should-be-overriden",BAD_SENDER_ID:"bad-sender-id",INCORRECT_GCM_SENDER_ID:"incorrect-gcm-sender-id",PERMISSION_DEFAULT:"permission-default",PERMISSION_BLOCKED:"permission-blocked",UNSUPPORTED_BROWSER:"unsupported-browser",NOTIFICATIONS_BLOCKED:"notifications-blocked",FAILED_DEFAULT_REGISTRATION:"failed-serviceworker-registration",SW_REGISTRATION_EXPECTED:"sw-registration-expected",GET_SUBSCRIPTION_FAILED:"get-subscription-failed",INVALID_SAVED_TOKEN:"invalid-saved-token",SW_REG_REDUNDANT:"sw-reg-redundant",TOKEN_SUBSCRIBE_FAILED:"token-subscribe-failed",TOKEN_SUBSCRIBE_NO_TOKEN:"token-subscribe-no-token",TOKEN_SUBSCRIBE_NO_PUSH_SET:"token-subscribe-no-push-set",TOKEN_UNSUBSCRIBE_FAILED:"token-unsubscribe-failed",TOKEN_UPDATE_FAILED:"token-update-failed",TOKEN_UPDATE_NO_TOKEN:"token-update-no-token",USE_SW_BEFORE_GET_TOKEN:"use-sw-before-get-token",INVALID_DELETE_TOKEN:"invalid-delete-token",DELETE_TOKEN_NOT_FOUND:"delete-token-not-found",DELETE_SCOPE_NOT_FOUND:"delete-scope-not-found",BG_HANDLER_FUNCTION_EXPECTED:"bg-handler-function-expected",NO_WINDOW_CLIENT_TO_MSG:"no-window-client-to-msg",UNABLE_TO_RESUBSCRIBE:"unable-to-resubscribe",NO_FCM_TOKEN_FOR_RESUBSCRIBE:"no-fcm-token-for-resubscribe",FAILED_TO_DELETE_TOKEN:"failed-to-delete-token",NO_SW_IN_REG:"no-sw-in-reg",BAD_SCOPE:"bad-scope",BAD_VAPID_KEY:"bad-vapid-key",BAD_SUBSCRIPTION:"bad-subscription",BAD_TOKEN:"bad-token",BAD_PUSH_SET:"bad-push-set",FAILED_DELETE_VAPID_KEY:"failed-delete-vapid-key",INVALID_PUBLIC_VAPID_KEY:"invalid-public-vapid-key",USE_PUBLIC_KEY_BEFORE_GET_TOKEN:"use-public-key-before-get-token",PUBLIC_KEY_DECRYPTION_FAILED:"public-vapid-key-decryption-failed"},v=((l={})[b.AVAILABLE_IN_WINDOW]="This method is available in a Window context.",l[b.AVAILABLE_IN_SW]="This method is available in a service worker context.",l[b.SHOULD_BE_INHERITED]="This method should be overriden by extended classes.",l[b.BAD_SENDER_ID]="Please ensure that 'messagingSenderId' is set correctly in the options passed into firebase.initializeApp().",l[b.PERMISSION_DEFAULT]="The required permissions were not granted and dismissed instead.",l[b.PERMISSION_BLOCKED]="The required permissions were not granted and blocked instead.",l[b.UNSUPPORTED_BROWSER]="This browser doesn't support the API's required to use the firebase SDK.",l[b.NOTIFICATIONS_BLOCKED]="Notifications have been blocked.",l[b.FAILED_DEFAULT_REGISTRATION]="We are unable to register the default service worker. {$browserErrorMessage}",l[b.SW_REGISTRATION_EXPECTED]="A service worker registration was the expected input.",l[b.GET_SUBSCRIPTION_FAILED]="There was an error when trying to get any existing Push Subscriptions.",l[b.INVALID_SAVED_TOKEN]="Unable to access details of the saved token.",l[b.SW_REG_REDUNDANT]="The service worker being used for push was made redundant.",l[b.TOKEN_SUBSCRIBE_FAILED]="A problem occured while subscribing the user to FCM: {$message}",l[b.TOKEN_SUBSCRIBE_NO_TOKEN]="FCM returned no token when subscribing the user to push.",l[b.TOKEN_SUBSCRIBE_NO_PUSH_SET]="FCM returned an invalid response when getting an FCM token.",l[b.TOKEN_UNSUBSCRIBE_FAILED]="A problem occured while unsubscribing the user from FCM: {$message}",l[b.TOKEN_UPDATE_FAILED]="A problem occured while updating the user from FCM: {$message}",l[b.TOKEN_UPDATE_NO_TOKEN]="FCM returned no token when updating the user to push.",l[b.USE_SW_BEFORE_GET_TOKEN]="The useServiceWorker() method may only be called once and must be called before calling getToken() to ensure your service worker is used.",l[b.INVALID_DELETE_TOKEN]="You must pass a valid token into deleteToken(), i.e. the token from getToken().",l[b.DELETE_TOKEN_NOT_FOUND]="The deletion attempt for token could not be performed as the token was not found.",l[b.DELETE_SCOPE_NOT_FOUND]="The deletion attempt for service worker scope could not be performed as the scope was not found.",l[b.BG_HANDLER_FUNCTION_EXPECTED]="The input to setBackgroundMessageHandler() must be a function.",l[b.NO_WINDOW_CLIENT_TO_MSG]="An attempt was made to message a non-existant window client.",l[b.UNABLE_TO_RESUBSCRIBE]="There was an error while re-subscribing the FCM token for push messaging. Will have to resubscribe the user on next visit. {$message}",l[b.NO_FCM_TOKEN_FOR_RESUBSCRIBE]="Could not find an FCM token and as a result, unable to resubscribe. Will have to resubscribe the user on next visit.",l[b.FAILED_TO_DELETE_TOKEN]="Unable to delete the currently saved token.",l[b.NO_SW_IN_REG]="Even though the service worker registration was successful, there was a problem accessing the service worker itself.",l[b.INCORRECT_GCM_SENDER_ID]="Please change your web app manifest's 'gcm_sender_id' value to '103953800507' to use Firebase messaging.",l[b.BAD_SCOPE]="The service worker scope must be a string with at least one character.",l[b.BAD_VAPID_KEY]="The public VAPID key is not a Uint8Array with 65 bytes.",l[b.BAD_SUBSCRIPTION]="The subscription must be a valid PushSubscription.",l[b.BAD_TOKEN]="The FCM Token used for storage / lookup was not a valid token string.",l[b.BAD_PUSH_SET]="The FCM push set used for storage / lookup was not not a valid push set string.",l[b.FAILED_DELETE_VAPID_KEY]="The VAPID key could not be deleted.",l[b.INVALID_PUBLIC_VAPID_KEY]="The public VAPID key must be a string.",l[b.PUBLIC_KEY_DECRYPTION_FAILED]="The public VAPID key did not equal 65 bytes when decrypted.",l),g=new h("messaging","Messaging",v),T=new Uint8Array([4,51,148,247,223,161,235,177,220,3,162,94,21,113,219,72,211,46,237,237,178,52,219,183,71,58,12,143,196,204,225,111,60,140,132,223,171,182,102,62,242,12,212,139,254,227,249,118,47,20,28,99,8,106,111,45,177,26,149,176,206,55,192,156,110]),S="https://fcm.googleapis.com";function y(e,t){if(null==e||null==t)return!1;if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(var n=new DataView(e),r=new DataView(t),i=0;i<e.byteLength;i++)if(n.getUint8(i)!==r.getUint8(i))return!1;return!0}function w(e){return function(e){var t=new Uint8Array(e);return btoa(String.fromCharCode.apply(null,t))}(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}!function(e){e.TYPE_OF_MSG="firebase-messaging-msg-type",e.DATA="firebase-messaging-msg-data"}(_||(_={})),function(e){e.PUSH_MSG_RECEIVED="push-msg-received",e.NOTIFICATION_CLICKED="notification-clicked"}(E||(E={}));var I=function(){function e(){}return e.prototype.getToken=function(e,t,n){return o(this,void 0,void 0,function(){var r,i,o,a,c,u,h,f;return s(this,function(s){switch(s.label){case 0:r=w(t.getKey("p256dh")),i=w(t.getKey("auth")),o="authorized_entity="+e+"&endpoint="+t.endpoint+"&encryption_key="+r+"&encryption_auth="+i,y(n.buffer,T.buffer)||(a=w(n),o+="&application_pub_key="+a),(c=new Headers).append("Content-Type","application/x-www-form-urlencoded"),u={method:"POST",headers:c,body:o},s.label=1;case 1:return s.trys.push([1,4,,5]),[4,fetch(S+"/fcm/connect/subscribe",u)];case 2:return[4,s.sent().json()];case 3:return h=s.sent(),[3,5];case 4:throw s.sent(),g.create(b.TOKEN_SUBSCRIBE_FAILED);case 5:if(h.error)throw f=h.error.message,g.create(b.TOKEN_SUBSCRIBE_FAILED,{message:f});if(!h.token)throw g.create(b.TOKEN_SUBSCRIBE_NO_TOKEN);if(!h.pushSet)throw g.create(b.TOKEN_SUBSCRIBE_NO_PUSH_SET);return[2,{token:h.token,pushSet:h.pushSet}]}})})},e.prototype.updateToken=function(e,t,n,r,i){return o(this,void 0,void 0,function(){var o,a,c,u,h,f,d,p;return s(this,function(s){switch(s.label){case 0:o=w(r.getKey("p256dh")),a=w(r.getKey("auth")),c="push_set="+n+"&token="+t+"&authorized_entity="+e+"&endpoint="+r.endpoint+"&encryption_key="+o+"&encryption_auth="+a,y(i.buffer,T.buffer)||(u=w(i),c+="&application_pub_key="+u),(h=new Headers).append("Content-Type","application/x-www-form-urlencoded"),f={method:"POST",headers:h,body:c},s.label=1;case 1:return s.trys.push([1,4,,5]),[4,fetch(S+"/fcm/connect/subscribe",f)];case 2:return[4,s.sent().json()];case 3:return d=s.sent(),[3,5];case 4:throw s.sent(),g.create(b.TOKEN_UPDATE_FAILED);case 5:if(d.error)throw p=d.error.message,g.create(b.TOKEN_UPDATE_FAILED,{message:p});if(!d.token)throw g.create(b.TOKEN_UPDATE_NO_TOKEN);return[2,d.token]}})})},e.prototype.deleteToken=function(e,t,n){return o(this,void 0,void 0,function(){var r,i,o,a,c;return s(this,function(s){switch(s.label){case 0:r="authorized_entity="+e+"&token="+t+"&pushSet="+n,(i=new Headers).append("Content-Type","application/x-www-form-urlencoded"),o={method:"POST",headers:i,body:r},s.label=1;case 1:return s.trys.push([1,4,,5]),[4,fetch(S+"/fcm/connect/unsubscribe",o)];case 2:return[4,s.sent().json()];case 3:if((a=s.sent()).error)throw c=a.error.message,g.create(b.TOKEN_UNSUBSCRIBE_FAILED,{message:c});return[3,5];case 4:throw s.sent(),g.create(b.TOKEN_UNSUBSCRIBE_FAILED);case 5:return[2]}})})},e}();function D(e){for(var t=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),n=atob(t),r=new Uint8Array(n.length),i=0;i<n.length;++i)r[i]=n.charCodeAt(i);return r}var N="undefined",m="fcm_token_object_Store";function O(){var e=indexedDB.open(N);e.onerror=function(e){},e.onsuccess=function(t){!function(e){if(e.objectStoreNames.contains(m)){var t=e.transaction(m).objectStore(m),n=new I,r=t.openCursor();r.onerror=function(e){console.warn("Unable to cleanup old IDB.",e)},r.onsuccess=function(){var t=r.result;if(t){var i=t.value;n.deleteToken(i.fcmSenderId,i.fcmToken,i.fcmPushSet),t.continue()}else e.close(),indexedDB.deleteDatabase(N)}}}(e.result)}}var k=function(){function e(){this.dbPromise=null}return e.prototype.get=function(e){return this.createTransaction(function(t){return t.get(e)})},e.prototype.getIndex=function(e,t){return this.createTransaction(function(n){return n.index(e).get(t)})},e.prototype.put=function(e){return this.createTransaction(function(t){return t.put(e)},"readwrite")},e.prototype.delete=function(e){return this.createTransaction(function(t){return t.delete(e)},"readwrite")},e.prototype.closeDatabase=function(){return o(this,void 0,void 0,function(){return s(this,function(e){switch(e.label){case 0:return this.dbPromise?[4,this.dbPromise]:[3,2];case 1:e.sent().close(),this.dbPromise=null,e.label=2;case 2:return[2]}})})},e.prototype.createTransaction=function(e,t){return void 0===t&&(t="readonly"),o(this,void 0,void 0,function(){var n,r,i,o;return s(this,function(s){switch(s.label){case 0:return[4,this.getDb()];case 1:return n=s.sent(),r=n.transaction(this.objectStoreName,t),i=r.objectStore(this.objectStoreName),[4,function(e){return new Promise(function(t,n){e.onsuccess=function(){t(e.result)},e.onerror=function(){n(e.error)}})}(e(i))];case 2:return o=s.sent(),[2,new Promise(function(e,t){r.oncomplete=function(){e(o)},r.onerror=function(){t(r.error)}})]}})})},e.prototype.getDb=function(){var e=this;return this.dbPromise||(this.dbPromise=new Promise(function(t,n){var r=indexedDB.open(e.dbName,e.dbVersion);r.onsuccess=function(){t(r.result)},r.onerror=function(){e.dbPromise=null,n(r.error)},r.onupgradeneeded=function(t){return e.onDbUpgrade(r,t)}})),this.dbPromise},e}();var A=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.dbName="fcm_token_details_db",t.dbVersion=3,t.objectStoreName="fcm_token_object_Store",t}return r(t,e),t.prototype.onDbUpgrade=function(e,t){var n=e.result;switch(t.oldVersion){case 0:(r=n.createObjectStore(this.objectStoreName,{keyPath:"swScope"})).createIndex("fcmSenderId","fcmSenderId",{unique:!1}),r.createIndex("fcmToken","fcmToken",{unique:!0});case 1:O();case 2:var r,o=(r=e.transaction.objectStore(this.objectStoreName)).openCursor();o.onsuccess=function(){var e=o.result;if(e){var t=e.value,n=i({},t);t.createTime||(n.createTime=Date.now()),"string"==typeof t.vapidKey&&(n.vapidKey=D(t.vapidKey)),"string"==typeof t.auth&&(n.auth=D(t.auth).buffer),"string"==typeof t.auth&&(n.p256dh=D(t.p256dh).buffer),e.update(n),e.continue()}}}},t.prototype.getTokenDetailsFromToken=function(e){return o(this,void 0,void 0,function(){return s(this,function(t){if(!e)throw g.create(b.BAD_TOKEN);return P({fcmToken:e}),[2,this.getIndex("fcmToken",e)]})})},t.prototype.getTokenDetailsFromSWScope=function(e){return o(this,void 0,void 0,function(){return s(this,function(t){if(!e)throw g.create(b.BAD_SCOPE);return P({swScope:e}),[2,this.get(e)]})})},t.prototype.saveTokenDetails=function(e){return o(this,void 0,void 0,function(){return s(this,function(t){if(!e.swScope)throw g.create(b.BAD_SCOPE);if(!e.vapidKey)throw g.create(b.BAD_VAPID_KEY);if(!e.endpoint||!e.auth||!e.p256dh)throw g.create(b.BAD_SUBSCRIPTION);if(!e.fcmSenderId)throw g.create(b.BAD_SENDER_ID);if(!e.fcmToken)throw g.create(b.BAD_TOKEN);if(!e.fcmPushSet)throw g.create(b.BAD_PUSH_SET);return P(e),[2,this.put(e)]})})},t.prototype.deleteToken=function(e){return o(this,void 0,void 0,function(){var t;return s(this,function(n){switch(n.label){case 0:return"string"!=typeof e||0===e.length?[2,Promise.reject(g.create(b.INVALID_DELETE_TOKEN))]:[4,this.getTokenDetailsFromToken(e)];case 1:if(!(t=n.sent()))throw g.create(b.DELETE_TOKEN_NOT_FOUND);return[4,this.delete(t.swScope)];case 2:return n.sent(),[2,t]}})})},t}(k);function P(e){if(e.fcmToken&&("string"!=typeof e.fcmToken||0===e.fcmToken.length))throw g.create(b.BAD_TOKEN);if(e.swScope&&("string"!=typeof e.swScope||0===e.swScope.length))throw g.create(b.BAD_SCOPE);if(e.vapidKey&&(!(e.vapidKey instanceof Uint8Array)||65!==e.vapidKey.length))throw g.create(b.BAD_VAPID_KEY);if(e.endpoint&&("string"!=typeof e.endpoint||0===e.endpoint.length))throw g.create(b.BAD_SUBSCRIPTION);if(e.auth&&!(e.auth instanceof ArrayBuffer))throw g.create(b.BAD_SUBSCRIPTION);if(e.p256dh&&!(e.p256dh instanceof ArrayBuffer))throw g.create(b.BAD_SUBSCRIPTION);if(e.fcmSenderId&&("string"!=typeof e.fcmSenderId||0===e.fcmSenderId.length))throw g.create(b.BAD_SENDER_ID);if(e.fcmPushSet&&("string"!=typeof e.fcmPushSet||0===e.fcmPushSet.length))throw g.create(b.BAD_PUSH_SET)}var C=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.dbName="fcm_vapid_details_db",t.dbVersion=1,t.objectStoreName="fcm_vapid_object_Store",t}return r(t,e),t.prototype.onDbUpgrade=function(e){e.result.createObjectStore(this.objectStoreName,{keyPath:"swScope"})},t.prototype.getVapidFromSWScope=function(e){return o(this,void 0,void 0,function(){var t;return s(this,function(n){switch(n.label){case 0:if("string"!=typeof e||0===e.length)throw g.create(b.BAD_SCOPE);return[4,this.get(e)];case 1:return[2,(t=n.sent())?t.vapidKey:void 0]}})})},t.prototype.saveVapidDetails=function(e,t){return o(this,void 0,void 0,function(){var n;return s(this,function(r){if("string"!=typeof e||0===e.length)throw g.create(b.BAD_SCOPE);if(null===t||65!==t.length)throw g.create(b.BAD_VAPID_KEY);return n={swScope:e,vapidKey:t},[2,this.put(n)]})})},t.prototype.deleteVapidDetails=function(e){return o(this,void 0,void 0,function(){var t;return s(this,function(n){switch(n.label){case 0:return[4,this.getVapidFromSWScope(e)];case 1:if(!(t=n.sent()))throw g.create(b.DELETE_SCOPE_NOT_FOUND);return[4,this.delete(e)];case 2:return n.sent(),[2,t]}})})},t}(k),B="messagingSenderId",R=function(){function e(e){var t=this;if(!e.options[B]||"string"!=typeof e.options[B])throw g.create(b.BAD_SENDER_ID);this.messagingSenderId=e.options[B],this.tokenDetailsModel=new A,this.vapidDetailsModel=new C,this.iidModel=new I,this.app=e,this.INTERNAL={delete:function(){return t.delete()}}}return e.prototype.getToken=function(){return o(this,void 0,void 0,function(){var e,t,n,r,i;return s(this,function(o){switch(o.label){case 0:if("denied"===(e=this.getNotificationPermission_()))throw g.create(b.NOTIFICATIONS_BLOCKED);return"granted"!==e?[2,null]:[4,this.getSWRegistration_()];case 1:return t=o.sent(),[4,this.getPublicVapidKey_()];case 2:return n=o.sent(),[4,this.getPushSubscription(t,n)];case 3:return r=o.sent(),[4,this.tokenDetailsModel.getTokenDetailsFromSWScope(t.scope)];case 4:return(i=o.sent())?[2,this.manageExistingToken(t,r,n,i)]:[2,this.getNewToken(t,r,n)]}})})},e.prototype.manageExistingToken=function(e,t,n,r){return o(this,void 0,void 0,function(){return s(this,function(i){switch(i.label){case 0:return function(e,t,n){if(!n.vapidKey||!y(t.buffer,n.vapidKey.buffer))return!1;var r=e.endpoint===n.endpoint,i=y(e.getKey("auth"),n.auth),o=y(e.getKey("p256dh"),n.p256dh);return r&&i&&o}(t,n,r)?Date.now()<r.createTime+6048e5?[2,r.fcmToken]:[2,this.updateToken(e,t,n,r)]:[4,this.deleteTokenFromDB(r.fcmToken)];case 1:return i.sent(),[2,this.getNewToken(e,t,n)]}})})},e.prototype.updateToken=function(e,t,n,r){return o(this,void 0,void 0,function(){var i,o,a;return s(this,function(s){switch(s.label){case 0:return s.trys.push([0,4,,6]),[4,this.iidModel.updateToken(this.messagingSenderId,r.fcmToken,r.fcmPushSet,t,n)];case 1:return i=s.sent(),o={swScope:e.scope,vapidKey:n,fcmSenderId:this.messagingSenderId,fcmToken:i,fcmPushSet:r.fcmPushSet,createTime:Date.now(),endpoint:t.endpoint,auth:t.getKey("auth"),p256dh:t.getKey("p256dh")},[4,this.tokenDetailsModel.saveTokenDetails(o)];case 2:return s.sent(),[4,this.vapidDetailsModel.saveVapidDetails(e.scope,n)];case 3:return s.sent(),[2,i];case 4:return a=s.sent(),[4,this.deleteToken(r.fcmToken)];case 5:throw s.sent(),a;case 6:return[2]}})})},e.prototype.getNewToken=function(e,t,n){return o(this,void 0,void 0,function(){var r,i;return s(this,function(o){switch(o.label){case 0:return[4,this.iidModel.getToken(this.messagingSenderId,t,n)];case 1:return r=o.sent(),i={swScope:e.scope,vapidKey:n,fcmSenderId:this.messagingSenderId,fcmToken:r.token,fcmPushSet:r.pushSet,createTime:Date.now(),endpoint:t.endpoint,auth:t.getKey("auth"),p256dh:t.getKey("p256dh")},[4,this.tokenDetailsModel.saveTokenDetails(i)];case 2:return o.sent(),[4,this.vapidDetailsModel.saveVapidDetails(e.scope,n)];case 3:return o.sent(),[2,r.token]}})})},e.prototype.deleteToken=function(e){return o(this,void 0,void 0,function(){var t,n;return s(this,function(r){switch(r.label){case 0:return[4,this.deleteTokenFromDB(e)];case 1:return r.sent(),[4,this.getSWRegistration_()];case 2:return(t=r.sent())?[4,t.pushManager.getSubscription()]:[3,4];case 3:if(n=r.sent())return[2,n.unsubscribe()];r.label=4;case 4:return[2,!0]}})})},e.prototype.deleteTokenFromDB=function(e){return o(this,void 0,void 0,function(){var t;return s(this,function(n){switch(n.label){case 0:return[4,this.tokenDetailsModel.deleteToken(e)];case 1:return t=n.sent(),[4,this.iidModel.deleteToken(t.fcmSenderId,t.fcmToken,t.fcmPushSet)];case 2:return n.sent(),[2]}})})},e.prototype.getPushSubscription=function(e,t){return e.pushManager.getSubscription().then(function(n){return n||e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:t})})},e.prototype.requestPermission=function(){throw g.create(b.AVAILABLE_IN_WINDOW)},e.prototype.useServiceWorker=function(e){throw g.create(b.AVAILABLE_IN_WINDOW)},e.prototype.usePublicVapidKey=function(e){throw g.create(b.AVAILABLE_IN_WINDOW)},e.prototype.onMessage=function(e,t,n){throw g.create(b.AVAILABLE_IN_WINDOW)},e.prototype.onTokenRefresh=function(e,t,n){throw g.create(b.AVAILABLE_IN_WINDOW)},e.prototype.setBackgroundMessageHandler=function(e){throw g.create(b.AVAILABLE_IN_SW)},e.prototype.delete=function(){return o(this,void 0,void 0,function(){return s(this,function(e){switch(e.label){case 0:return[4,Promise.all([this.tokenDetailsModel.closeDatabase(),this.vapidDetailsModel.closeDatabase()])];case 1:return e.sent(),[2]}})})},e.prototype.getNotificationPermission_=function(){return Notification.permission},e.prototype.getTokenDetailsModel=function(){return this.tokenDetailsModel},e.prototype.getVapidDetailsModel=function(){return this.vapidDetailsModel},e.prototype.getIidModel=function(){return this.iidModel},e}();var U=function(e){function t(t){var n=e.call(this,t)||this;return n.bgMessageHandler=null,self.addEventListener("push",function(e){n.onPush(e)}),self.addEventListener("pushsubscriptionchange",function(e){n.onSubChange(e)}),self.addEventListener("notificationclick",function(e){n.onNotificationClick(e)}),n}return r(t,e),t.prototype.onPush=function(e){e.waitUntil(this.onPush_(e))},t.prototype.onSubChange=function(e){e.waitUntil(this.onSubChange_(e))},t.prototype.onNotificationClick=function(e){e.waitUntil(this.onNotificationClick_(e))},t.prototype.onPush_=function(e){return o(this,void 0,void 0,function(){var t,n,r,i,o,a;return s(this,function(s){switch(s.label){case 0:if(!e.data)return[2];try{t=e.data.json()}catch(e){return[2]}return[4,this.hasVisibleClients_()];case 1:return s.sent()?[2,this.sendMessageToWindowClients_(t)]:(n=this.getNotificationData_(t))?(r=n.title||"",[4,this.getSWRegistration_()]):[3,3];case 2:return i=s.sent(),o=n.actions,a=Notification.maxActions,o&&a&&o.length>a&&console.warn("This browser only supports "+a+" actions.The remaining actions will not be displayed."),[2,i.showNotification(r,n)];case 3:return this.bgMessageHandler?[4,this.bgMessageHandler(t)]:[3,5];case 4:return s.sent(),[2];case 5:return[2]}})})},t.prototype.onSubChange_=function(e){return o(this,void 0,void 0,function(){var e,t,n,r;return s(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.getSWRegistration_()];case 1:return e=i.sent(),[3,3];case 2:throw t=i.sent(),g.create(b.UNABLE_TO_RESUBSCRIBE,{message:t});case 3:return i.trys.push([3,5,,8]),[4,e.pushManager.getSubscription()];case 4:return i.sent(),[3,8];case 5:return n=i.sent(),[4,this.getTokenDetailsModel().getTokenDetailsFromSWScope(e.scope)];case 6:if(!(r=i.sent()))throw n;return[4,this.deleteToken(r.fcmToken)];case 7:throw i.sent(),n;case 8:return[2]}})})},t.prototype.onNotificationClick_=function(e){return o(this,void 0,void 0,function(){var t,n,r,i;return s(this,function(o){switch(o.label){case 0:return e.notification&&e.notification.data&&e.notification.data.FCM_MSG?e.action?[2]:(e.stopImmediatePropagation(),e.notification.close(),(t=e.notification.data.FCM_MSG).notification&&(n=t.fcmOptions&&t.fcmOptions.link||t.notification.click_action)?[4,this.getWindowClient_(n)]:[2]):[2];case 1:return(r=o.sent())?[3,3]:[4,self.clients.openWindow(n)];case 2:return r=o.sent(),[3,5];case 3:return[4,r.focus()];case 4:r=o.sent(),o.label=5;case 5:return r?(delete t.notification,delete t.fcmOptions,i=K(E.NOTIFICATION_CLICKED,t),[2,this.attemptToMessageClient_(r,i)]):[2]}})})},t.prototype.getNotificationData_=function(e){if(e&&"object"==typeof e.notification){var t,n=i({},e.notification);return n.data=i({},e.notification.data,((t={}).FCM_MSG=e,t)),n}},t.prototype.setBackgroundMessageHandler=function(e){if(!e||"function"!=typeof e)throw g.create(b.BG_HANDLER_FUNCTION_EXPECTED);this.bgMessageHandler=e},t.prototype.getWindowClient_=function(e){return o(this,void 0,void 0,function(){var t,n,r,i;return s(this,function(o){switch(o.label){case 0:return t=new URL(e,self.location.href).href,[4,L()];case 1:for(n=o.sent(),r=null,i=0;i<n.length;i++)if(new URL(n[i].url,self.location.href).href===t){r=n[i];break}return[2,r]}})})},t.prototype.attemptToMessageClient_=function(e,t){return o(this,void 0,void 0,function(){return s(this,function(n){if(!e)throw g.create(b.NO_WINDOW_CLIENT_TO_MSG);return e.postMessage(t),[2]})})},t.prototype.hasVisibleClients_=function(){return o(this,void 0,void 0,function(){return s(this,function(e){switch(e.label){case 0:return[4,L()];case 1:return[2,e.sent().some(function(e){return"visible"===e.visibilityState})]}})})},t.prototype.sendMessageToWindowClients_=function(e){return o(this,void 0,void 0,function(){var t,n,r=this;return s(this,function(i){switch(i.label){case 0:return[4,L()];case 1:return t=i.sent(),n=K(E.PUSH_MSG_RECEIVED,e),[4,Promise.all(t.map(function(e){return r.attemptToMessageClient_(e,n)}))];case 2:return i.sent(),[2]}})})},t.prototype.getSWRegistration_=function(){return o(this,void 0,void 0,function(){return s(this,function(e){return[2,self.registration]})})},t.prototype.getPublicVapidKey_=function(){return o(this,void 0,void 0,function(){var e,t;return s(this,function(n){switch(n.label){case 0:return[4,this.getSWRegistration_()];case 1:if(!(e=n.sent()))throw g.create(b.SW_REGISTRATION_EXPECTED);return[4,this.getVapidDetailsModel().getVapidFromSWScope(e.scope)];case 2:return null==(t=n.sent())?[2,T]:[2,t]}})})},t}(R);function L(){return self.clients.matchAll({type:"window",includeUncontrolled:!0})}function K(e,t){return(n={})[_.TYPE_OF_MSG]=e,n[_.DATA]=t,n;var n}var M=function(e){function t(t){var n=e.call(this,t)||this;return n.registrationToUse=null,n.publicVapidKeyToUse=null,n.manifestCheckPromise=null,n.messageObserver=null,n.tokenRefreshObserver=null,n.onMessageInternal=f(function(e){n.messageObserver=e}),n.onTokenRefreshInternal=f(function(e){n.tokenRefreshObserver=e}),n.setupSWMessageListener_(),n}return r(t,e),t.prototype.getToken=function(){return o(this,void 0,void 0,function(){return s(this,function(t){switch(t.label){case 0:return this.manifestCheckPromise||(this.manifestCheckPromise=function(){return o(this,void 0,void 0,function(){var e,t;return s(this,function(n){switch(n.label){case 0:if(!(e=document.querySelector('link[rel="manifest"]')))return[2];n.label=1;case 1:return n.trys.push([1,4,,5]),[4,fetch(e.href)];case 2:return[4,n.sent().json()];case 3:return t=n.sent(),[3,5];case 4:return n.sent(),[2];case 5:if(!t||!t.gcm_sender_id)return[2];if("103953800507"!==t.gcm_sender_id)throw g.create(b.INCORRECT_GCM_SENDER_ID);return[2]}})})}()),[4,this.manifestCheckPromise];case 1:return t.sent(),[2,e.prototype.getToken.call(this)]}})})},t.prototype.requestPermission=function(){return o(this,void 0,void 0,function(){var e;return s(this,function(t){switch(t.label){case 0:return"granted"===this.getNotificationPermission_()?[2]:[4,Notification.requestPermission()];case 1:if("granted"===(e=t.sent()))return[2];throw"denied"===e?g.create(b.PERMISSION_BLOCKED):g.create(b.PERMISSION_DEFAULT)}})})},t.prototype.useServiceWorker=function(e){if(!(e instanceof ServiceWorkerRegistration))throw g.create(b.SW_REGISTRATION_EXPECTED);if(null!=this.registrationToUse)throw g.create(b.USE_SW_BEFORE_GET_TOKEN);this.registrationToUse=e},t.prototype.usePublicVapidKey=function(e){if("string"!=typeof e)throw g.create(b.INVALID_PUBLIC_VAPID_KEY);if(null!=this.publicVapidKeyToUse)throw g.create(b.USE_PUBLIC_KEY_BEFORE_GET_TOKEN);var t=D(e);if(65!==t.length)throw g.create(b.PUBLIC_KEY_DECRYPTION_FAILED);this.publicVapidKeyToUse=t},t.prototype.onMessage=function(e,t,n){return"function"==typeof e?this.onMessageInternal(e,t,n):this.onMessageInternal(e)},t.prototype.onTokenRefresh=function(e,t,n){return"function"==typeof e?this.onTokenRefreshInternal(e,t,n):this.onTokenRefreshInternal(e)},t.prototype.waitForRegistrationToActivate_=function(e){var t=e.installing||e.waiting||e.active;return new Promise(function(n,r){if(t)if("activated"!==t.state)if("redundant"!==t.state){var i=function(){if("activated"===t.state)n(e);else{if("redundant"!==t.state)return;r(g.create(b.SW_REG_REDUNDANT))}t.removeEventListener("statechange",i)};t.addEventListener("statechange",i)}else r(g.create(b.SW_REG_REDUNDANT));else n(e);else r(g.create(b.NO_SW_IN_REG))})},t.prototype.getSWRegistration_=function(){var e=this;return this.registrationToUse?this.waitForRegistrationToActivate_(this.registrationToUse):(this.registrationToUse=null,navigator.serviceWorker.register("/firebase-messaging-sw.js",{scope:"/firebase-cloud-messaging-push-scope"}).catch(function(e){throw g.create(b.FAILED_DEFAULT_REGISTRATION,{browserErrorMessage:e.message})}).then(function(t){return e.waitForRegistrationToActivate_(t).then(function(){return e.registrationToUse=t,t.update(),t})}))},t.prototype.getPublicVapidKey_=function(){return o(this,void 0,void 0,function(){return s(this,function(e){return this.publicVapidKeyToUse?[2,this.publicVapidKeyToUse]:[2,T]})})},t.prototype.setupSWMessageListener_=function(){var e=this;navigator.serviceWorker.addEventListener("message",function(t){if(t.data&&t.data[_.TYPE_OF_MSG]){var n=t.data;switch(n[_.TYPE_OF_MSG]){case E.PUSH_MSG_RECEIVED:case E.NOTIFICATION_CLICKED:var r=n[_.DATA];e.messageObserver&&e.messageObserver.next(r)}}},!1)},t}(R);function F(){return self&&"ServiceWorkerGlobalScope"in self?"PushManager"in self&&"Notification"in self&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey"):navigator.cookieEnabled&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&"fetch"in window&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey")}W={isSupported:F},t.INTERNAL.registerService("messaging",function(e){if(!F())throw g.create(b.UNSUPPORTED_BROWSER);return self&&"ServiceWorkerGlobalScope"in self?new U(e):new M(e)},W)}catch(e){throw console.error(e),new Error("Cannot instantiate firebase-messaging - be sure to load firebase-app.js first.")}var W}(this.firebase=this.firebase||{},firebase);

firebase.initializeApp({
    messagingSenderId: '471151006902'
});

if ('Notification' in window) {
    var messaging = firebase.messaging();


                if (document.readyState === "complete" || document.readyState === "interactive") {
          KTShowSubscribe();
        } else {
          document.addEventListener("DOMContentLoaded", KTShowSubscribe);
        }
        
        messaging.onMessage(function(payload) {
            console.log('Message received. ', payload);

            navigator.serviceWorker.register('/firebase-messaging-sw-online.js');

            Notification.requestPermission(function(permission) {
                if (permission === 'granted') {
                    navigator.serviceWorker.ready.then(function(registration) {
                        var notification = payload.data;
                        notification.data = {};
                        notification.data.click_action = payload.data.click_action;
                        notification.data.id_delivery = payload.data.id_delivery;
                        notification.data.id_message = payload.data.id_message;
                        notification.data.id_project = payload.data.id_project;

                        if (typeof payload.data.id_key !== 'undefined') {
                            notification.data.id_key = payload.data.id_key;

                            var additional_key_data = '&id_key=' + payload.data.id_key;
                        } else {
                            var additional_key_data = '';
                        }

                        if (typeof payload.data.icon !== 'undefined' && payload.data.icon.length > 0) {
                            notification.icon = payload.data.icon;
                        }

                        if (typeof payload.data.image !== 'undefined' && payload.data.image.length > 0) {
                            notification.image = payload.data.image;
                        }

                        if (typeof payload.data.requireInteraction !== 'undefined' && payload.data.requireInteraction == 1) {
                            notification.requireInteraction = true;
                        }

                        registration.showNotification(payload.data.title, notification);

                        var url = 'https://c.killtarget.biz/notify/loaded?' +
                            'id_delivery=' + payload.data.id_delivery +
                            '&id_message=' + payload.data.id_message +
                            '&id_project=' + payload.data.id_project +
                            additional_key_data;

                        var xhr = new XMLHttpRequest();
                        xhr.open('POST', url);
                        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                        xhr.send(null);
                    }).catch(function(error) {
                        console.log('ServiceWorker registration failed.', error);
                    });
                }
            });
        });

}

function showBackdrop()
{
    var cssStyle =
        '.ktarget-backdrop {display: flex; justify-content: center; align-items: center;\n' +
        '    position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 999996;\n'+
        '    background: rgba(0,0,0,.65); text-align: center; transition: all .2s ease .1s;' +
        '}\n' +
        '.ktarget-backdrop-close, .ktarget-backdrop-text {\n' +
        '    font-family: \'Segoe UI\',\'Open Sans\',Ubuntu,\'Dejavu Sans\',Helvetica,\'Helvetica Neue\',Arial,sans-serif;\n' +
        '}\n' +
        '.ktarget-backdrop-close {\n' +
        '    position: absolute;\n' +
        '    right: 20px; top: 20px; font-weight: 300; font-size: 60px; line-height: 20px; opacity: .8; cursor: pointer;\n' +
        '    color: #fff;\n' +
        '}\n' +
        '.ktarget-backdrop-close:hover {\n' +
        '    opacity: 1;\n' +
        '}\n' +
        '.ktarget-backdrop-text {\n' +
        '    max-width: 400px; margin: 0 auto; padding: 30px; font-size: 21px; font-weight: 500;\n' +
        '    color: #fff; background-color: rgba(0,0,0,0.5); border-radius: 15px;\n'+
        '}\n';
        //

    if (navigator.userAgent.match(/Android/)) {
        cssStyle += '.ktarget-backdrop-text {position: absolute; top: 0; margin: 11vh auto 10vh; color: #fff; background-color: transparent; font-size: 25px; font-weight: 800;}';
    }

    var style = document.createElement('style');
    style.appendChild(document.createTextNode(cssStyle));
    document.getElementsByTagName('head')[0].appendChild(style);

    var backdrop = document.createElement('div');
    backdrop.className = 'ktarget-backdrop';

    var backdrop_close = document.createElement('div');
    backdrop_close.className = 'ktarget-backdrop-close';
    backdrop_close.innerHTML = '×';
    backdrop.appendChild(backdrop_close);


    document.body.appendChild(backdrop);

    backdrop_close.addEventListener('click', function(){
        document.body.removeChild(backdrop);
    });
}

function hideBackdrop()
{
    var elements = document.getElementsByClassName('ktarget-backdrop');
    if (elements.length > 0) {
        document.body.removeChild(elements[0]);
    }

    var elements2 = document.getElementsByClassName('kt-logo');
    if (elements2.length > 0) {
        document.body.removeChild(elements2[0]);
    }
}

function ktLogo()
{
    if (navigator.userAgent.match(/Android/)) {
        return;
    }

    var cssStyle = '.kt-logo {'+
        'border-radius: 50%;' +
        'width: 896px; height: 220px;' +
        'position: fixed; top: -85px; left: -190px; z-index: 1000;'+
        "font-family: 'Segoe UI','Open Sans',Ubuntu,'Dejavu Sans',Helvetica,'Helvetica Neue',Arial,sans-serif;"+
        'margin-left: 22px;'+
        'transition-duration: .25s;'+
        'transform: scale(1);'+
        'opacity: 1;' +
    '}'+
    '@media (max-width: 768px) {.kt-logo{display: none}}' +
    '.kt-logo:after {' +
    'content: "";' +
    'position: absolute; width: 100%; height: 100%; top: 0; left: 0; '+
    '-webkit-filter: blur(100px); filter: blur(100px); background-color: rgba(0,0,0,.4);' +
    '}'+
    '.kt-inner {' +
        'position: absolute; right: calc(16% - 22px); top: calc(85px + 15px);' +
        'white-space: nowrap;' +
        'font-size: 13px; color: #fff; line-height: 15px; font-weight: 700;' +
        'filter: blur(0);' +
        'z-index: 1001;' +
        'text-shadow: -2px 0 rgba(0,0,0,.1), 0 2px rgba(0,0,0,.1), 2px 0 rgba(0,0,0,.1), 0 -2px rgba(0,0,0,.1);'+
    '}' +
    'a.kt-link {'+
        'position:relative; top: -5px;' +
        'text-decoration: none;' +
        'display: inline-block;' +
        'vertical-align: middle;' +
        'padding: 5px;' +
        'background-color: rgba(0,0,0,0.7); border-radius: 5px;' +
        'color: #fff;' +
    '}' +
    '.kt-link span { text-decoration: underline }' +
    'a.kt-link:hover, a.kt-link:focus, a.kt-link:active { color: #fff }' +
    '.kt-icon{' +
        'display: inline-block; width: 24px; height: 24px;' +
        'margin: 0 5px;'+
        'vertical-align: middle;'+
        'background-size: cover;' +
        'background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDEiIHZpZXdCb3g9IjAgMCA0MCA0MSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBjbGlwLXBhdGg9InVybCgjY2xpcDApIj48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTQuNjIyNCAyMi4xOTU2SDEuNTk3MzNDMC44NTc4NjUgMjIuMTk1NiAwLjIxOTIzOCAyMS41Njc1IDAuMjE5MjM4IDIwLjc2NTFDMC4yMTkyMzggMTkuOTYyNiAwLjgyNDI1MyAxOS4zMzQ1IDEuNTk3MzMgMTkuMzM0NUg0LjYyMjRDNS4yNjEwMyAxMS44MzMgMTEuMDQyMyA1Ljc5Njk2IDE4LjMwMjUgNS4xMzQwM1YxLjk5Mzg3QzE4LjMwMjUgMS4xOTEzOSAxOC45NDExIDAuNTYzMzU0IDE5LjY4MDUgMC41NjMzNTRDMjAuNDUzNiAwLjU2MzM1NCAyMS4wNTg2IDEuMjI2MjggMjEuMDU4NiAxLjk5Mzg3VjUuMTM0MDNDMjguMjg1MiA1Ljc5Njk2IDM0LjEwMDEgMTEuNzk4MiAzNC43Mzg3IDE5LjMzNDVIMzcuNzYzOEMzOC41MzY4IDE5LjMzNDUgMzkuMTQxOCAxOS45OTc1IDM5LjE0MTggMjAuNzY1MUMzOS4xNDE4IDIxLjU2NzUgMzguNTAzMiAyMi4xOTU2IDM3Ljc2MzggMjIuMTk1NkgzNC43Mzg3QzM0LjczODYgMjIuMTk2NSAzNC43Mzg1IDIyLjE5NzMgMzQuNzM4NSAyMi4xOTgySDMxLjk4MjJDMzEuOTgyMyAyMi4xOTczIDMxLjk4MjQgMjIuMTk2NSAzMS45ODI1IDIyLjE5NTZIMjYuNDM2NUMyNS42NjM1IDIyLjE5NTYgMjUuMDU4NCAyMS41MzI3IDI1LjA1ODQgMjAuNzY1MUMyNS4wNTg0IDE5Ljk2MjYgMjUuNjk3MSAxOS4zMzQ1IDI2LjQzNjUgMTkuMzM0NUgzMS45ODI1QzMxLjM3NzUgMTMuNDAzMSAyNi44MDYzIDguNjU3OTkgMjEuMDU4NiA3Ljk5NTA3VjEzLjc1MkMyMS4wNTg2IDE0LjU1NDUgMjAuNDIgMTUuMTgyNiAxOS42ODA1IDE1LjE4MjZDMTguOTA3NSAxNS4xODI2IDE4LjMwMjUgMTQuNTE5NiAxOC4zMDI1IDEzLjc1MlY3Ljk5NTA3QzEyLjU4ODQgOC42MjMxIDguMDE3MiAxMy4zNjgyIDcuMzc4NTggMTkuMzM0NUgxMi45MjQ1QzEzLjY2NCAxOS4zMzQ1IDE0LjMwMjYgMTkuOTk3NSAxNC4zMDI2IDIwLjc2NTFDMTQuMzAyNiAyMS41Njc1IDEzLjY2NCAyMi4xOTU2IDEyLjkyNDUgMjIuMTk1Nkg3LjM3ODU4QzcuOTgzNTkgMjguMTI3IDEyLjU1NDggMzIuODcyMSAxOC4zMDI1IDMzLjUzNVYyNy43NzgxQzE4LjMwMjUgMjYuOTc1NiAxOC45NDExIDI2LjM0NzYgMTkuNjgwNSAyNi4zNDc2QzIwLjQ1MzYgMjYuMzQ3NiAyMS4wNTg2IDI3LjAxMDUgMjEuMDU4NiAyNy43NzgxVjMzLjUzNUMyNS43NDk3IDMzLjAxOTUgMjkuNjcwNSAyOS43MjkgMzEuMjc3NCAyNS4yNjZIMzQuMTczNEMzMi40NDI4IDMxLjI5MDIgMjcuMjk2NiAzNS44MjY1IDIxLjA1ODYgMzYuMzk2MVYzOS41MzYyQzIxLjA1ODYgNDAuMzM4NyAyMC40MiA0MC45NjY4IDE5LjY4MDUgNDAuOTY2OEMxOC45MDc1IDQwLjk2NjggMTguMzAyNSA0MC4zMDM4IDE4LjMwMjUgMzkuNTM2MlYzNi4zOTYxQzExLjA3NTkgMzUuNzMzMiA1LjI2MTAzIDI5LjczMiA0LjYyMjQgMjIuMTk1NloiIGZpbGw9IndoaXRlIi8+PC9nPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHdpZHRoPSIzOC45MjI2IiBoZWlnaHQ9IjQwLjQwMzQiIGZpbGw9IndoaXRlIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwLjIxOTIzOCAwLjU2MzM1NCkiLz48L2NsaXBQYXRoPjwvZGVmcz48L3N2Zz4=);' +
    '}';

    if (navigator.userAgent.match(/Firefox/)) {
        cssStyle += '.kt-logo{top: -65px; left: -60px;}';
    }

    if (navigator.userAgent.match(/YaBrowser/)) {
        cssStyle += '.kt-logo{top: -25px; right: 490px; left: auto;}';
    }

    var style = document.createElement('style');
    style.appendChild(document.createTextNode(cssStyle));
    document.getElementsByTagName('head')[0].appendChild(style);

    var backdrop = document.createElement('div');
    backdrop.className = 'kt-logo';
    backdrop.addEventListener('click', function(){ this.remove() });
    backdrop.innerHTML = '<div class="kt-inner"><a class="kt-link" href="https://killtarget.com/?utm_source=' + window.location.host + '" target="_blank">Web Push<div class="kt-icon"></div><span>KillTarget</span></a></div>';

    document.body.appendChild(backdrop);
}

function KT_FP_Show(){}

function KTShowSubscribe() {
    var showBackdropSetting = 0;
    var showKtLogo = 0;

    if (window.localStorage.getItem('sentFirebaseMessagingToken') === null &&
        window.localStorage.getItem('KilltargetAlreadySentDecline') === null &&
        navigator.userAgent.match(/Chrome|Firefox/) && !navigator.userAgent.match(/Edge/)
    ) {
        if (showBackdropSetting) {
            showBackdrop();
        } else if (showKtLogo) {
            ktLogo();
        }
    }

    // запрашиваем разрешение на получение уведомлений
    messaging.requestPermission().then(function () {
        hideBackdrop();
		KT_FP_Show();
		// получаем ID устройства
		messaging.getToken()
			.then(function (currentToken) {
				console.log(currentToken);

				if (currentToken) {
					sendTokenToServer(currentToken);
				} else {
					console.warn('Не удалось получить токен.');
					setTokenSentToServer(false);
				}
			})
			.catch(function (err) {


				console.warn('При получении токена произошла ошибка.', err);
				setTokenSentToServer(false);
			});
    }).catch(function (err) {
        hideBackdrop();

        KT_FP_Show();

        if (window.localStorage.getItem('KilltargetAlreadySentDecline') === null) {
            var url = 'https://c.killtarget.biz/notify/declined?site_hash=1bf9f75eed33fcf0f6bdd331c5a2b26a';

            var xhr = new XMLHttpRequest();
            xhr.open('POST', url);
            xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            xhr.send(null);

             window.localStorage.setItem('KilltargetAlreadySentDecline', 1);
        }
        console.warn('Не удалось получить разрешение на показ уведомлений.', err);
    });
}

// отправка ID на сервер
function sendTokenToServer(currentToken) {
    if (!isTokenSentToServer(currentToken)) {
        console.log('Отправка токена на сервер...');

        var url = 'https://c.killtarget.biz/notify/key';

        var data = {
            key: currentToken,
            site_hash: '1bf9f75eed33fcf0f6bdd331c5a2b26a'
        };

        var params = Object.keys(data).map(
            function(k){ return encodeURIComponent(k) + '=' + encodeURIComponent(data[k]) }
        ).join('&');

        var xhr = new XMLHttpRequest();
        xhr.open('POST', url);
        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        xhr.send(params);

        setTokenSentToServer(currentToken);
    } else {
        console.log('Токен уже отправлен на сервер.');
    }
}

// используем localStorage для отметки того, что пользователь уже подписался на уведомления
function isTokenSentToServer(currentToken) {
    return window.localStorage.getItem('sentFirebaseMessagingToken') == currentToken;
}

function setTokenSentToServer(currentToken) {
    window.localStorage.setItem(
        'sentFirebaseMessagingToken',
        currentToken ? currentToken : ''
    );
}