web-push-notifications 3.39.6 → 3.39.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(this,(()=>(()=>{"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var s in e=arguments[n])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t},n.apply(this,arguments)};function r(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]])}return n}function s(t,e,n,r){return new(n||(n=Promise))((function(s,i){function o(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}u((r=r.apply(t,e||[])).next())}))}function i(t,e){var n,r,s,i={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(s=2&a[0]?r.return:a[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,a[1])).done)return s;switch(r=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(s=i.trys,(s=s.length>0&&s[s.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){i.label=a[1];break}if(6===a[0]&&i.label<s[1]){i.label=s[1],s=a;break}if(s&&i.label<s[2]){i.label=s[2],i.ops.push(a);break}s[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],r=0}finally{n=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}Object.create;function o(t,e,n){if(n||2===arguments.length)for(var r,s=0,i=e.length;s<i;s++)!r&&s in e||(r||(r=Array.prototype.slice.call(e,0,s)),r[s]=e[s]);return t.concat(r||Array.prototype.slice.call(e))}Object.create;"function"==typeof SuppressedError&&SuppressedError;var a="deviceRegistrationStatus",u="registered",c="unregistered";const h={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let p;const d=new Uint8Array(16);const l=[];for(let t=0;t<256;++t)l.push((t+256).toString(16).slice(1));function f(t,e=0){return(l[t[e+0]]+l[t[e+1]]+l[t[e+2]]+l[t[e+3]]+"-"+l[t[e+4]]+l[t[e+5]]+"-"+l[t[e+6]]+l[t[e+7]]+"-"+l[t[e+8]]+l[t[e+9]]+"-"+l[t[e+10]]+l[t[e+11]]+l[t[e+12]]+l[t[e+13]]+l[t[e+14]]+l[t[e+15]]).toLowerCase()}const v=function(t,e,n){if(h.randomUUID&&!e&&!t)return h.randomUUID();const r=(t=t||{}).random??t.rng?.()??function(){if(!p){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");p=crypto.getRandomValues.bind(crypto)}return p(d)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){if((n=n||0)<0||n+16>e.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let t=0;t<16;++t)e[n+t]=r[t];return e}return f(r)};var g,m=function(){var t=this;this.addEventHandler=function(e,n){var r=t.savedEventHandlersMap[e];r||(r=[]),r.push(n),t.savedEventHandlersMap[e]=r},this.removeEventHandler=function(e,n){var r=t.savedEventHandlersMap[e];r&&(t.savedEventHandlersMap[e]=r.filter((function(t){return t!==n})))},this.dispatchEvent=function(e,r){var s=r.eventId||v(),i=t.savedEventHandlersMap[e];return i?(i.forEach((function(t){"function"==typeof t&&setTimeout((function(){t(n(n({},r),{eventId:s}))}),0)})),s):s},this.savedEventHandlersMap={}};function y(){return globalThis}function b(t,e){if("string"==typeof t)try{return JSON.parse(t)}catch(t){console.log(t)}return void 0===t&&void 0!==e?e:t}var w="silent",S="fatal",E="error",M="warn",x="info",P="debug",D=((g={})[w]=0,g[S]=10,g[E]=20,g[M]=30,g[x]=40,g[P]=50,g),C=function(){function t(t){this.relations=D,this.level=t&&void 0!==t.level?t.level:E,this.applicationType=t&&void 0!==t.applicationType?t.applicationType:"sdk",this.subscribers=t&&void 0!==t.subscribers?t.subscribers:[]}return t.prototype.updateLogLevel=function(t){this.level=t},t.prototype.updateApplicationType=function(t){this.applicationType=t},t.prototype.updateApplicationCode=function(t){this.applicationCode=t},t.prototype.updateDomain=function(t){this.domain=t},t.prototype.updateDeviceInfo=function(t){this.deviceInfo=t},t.prototype.subscribe=function(t,e){this.subscribers.push({handler:e,level:t})},t.prototype.log=function(t){return s(this,void 0,void 0,(function(){var e,s,o,a,u,c,h=this;return i(this,(function(i){switch(i.label){case 0:return e=[],s=t.options,o=r(t,["options"]),a=o,s&&(s.handler,u=r(s,["handler"]),a=n(n({},o),u)),c=this.getMessage(a),this.subscribers.forEach((function(n){n.level===t.type&&h.relations[n.level]<=h.relations[h.level]&&e.push(n.handler.call(null,c))})),s&&s.handler&&this.level!==w&&s.handler.call(null,c),[4,Promise.all(e)];case 1:return i.sent(),[2]}}))}))},t.prototype.debug=function(t,e){return s(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.log({type:P,text:t,options:e})]}))}))},t.prototype.info=function(t,e){return s(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.log({type:x,text:t,options:e})]}))}))},t.prototype.warn=function(t,e,n){return s(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.log({type:M,text:t,code:e,options:n})]}))}))},t.prototype.error=function(t,e,n){return s(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.log({type:E,text:t,code:e,options:n})]}))}))},t.prototype.fatal=function(t,e,n){return s(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.log({type:S,text:t,code:e,options:n})]}))}))},t.prototype.errorAndThrow=function(t,e,n){return s(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.logAndThrow({type:E,text:t,code:e,options:n})]}))}))},t.prototype.errorAndReject=function(t,e,n,r){return s(this,void 0,void 0,(function(){return i(this,(function(s){return[2,this.logAndReject(t,{type:E,text:e,code:n,options:r})]}))}))},t.prototype.fatalAndThrow=function(t,e,n){return s(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.logAndThrow({type:S,text:t,code:e,options:n})]}))}))},t.prototype.fatalAndReject=function(t,e,n,r){return s(this,void 0,void 0,(function(){return i(this,(function(s){return[2,this.logAndReject(t,{type:S,text:e,code:n,options:r})]}))}))},t.prototype.logAndThrow=function(t){return s(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this.log(t)];case 1:throw n.sent(),e=new Error(t.text),t.code&&(e.code=t.code),e}}))}))},t.prototype.logAndReject=function(t,e){return s(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.log(e)];case 1:return r.sent(),n=new Error(e.text),e.code&&(n.code=e.code),t(n),[2]}}))}))},t.prototype.getMessage=function(t){return n({applicationCode:this.applicationCode,domain:this.domain,applicationType:this.applicationType,deviceInfo:this.deviceInfo},t)},t}();function T(t){var e=t.code,n=t.text,r=t.type,s=function(t){switch(t){case"fatal":case"error":return console.error;case"warn":case"info":case"debug":return console.log}}(r);console.groupCollapsed(r),s(e?"".concat(e,": ").concat(n):n),console.groupEnd()}var I=new C({level:"error",subscribers:[{level:"fatal",handler:T},{level:"error",handler:T}]});function k(t){return s(this,void 0,void 0,(function(){var e;return i(this,(function(n){return e=A(t),[2,I.fatal(e.text,e.code,e.options)]}))}))}function A(t){var e=t.message,s=t.code,i=t.error,o=r(t,["message","code","error"]),a=function(t){var e=new Error("unknown error");"string"!=typeof t&&"number"!=typeof t&&"boolean"!=typeof t||(e.message=t.toString());t instanceof Error&&(e=t);return e}(i);return{text:e,code:s,options:n(n({},o),{errorText:a.message,errorStack:a.stack})}}var O="keyValue",R="messages",_="log",N="inboxMessages";function U(t,e){return function(n){n.objectStoreNames.contains(t)||e(n)}}const q=[U(N,(function(t){var e="status",n=t.createObjectStore(N,{keyPath:"inbox_id",autoIncrement:!1});n.createIndex(e,e,{unique:!1,multiEntry:!0}),n.createIndex("rt","rt",{unique:!1,multiEntry:!0})}))];const W=[U(O,(function(t){t.createObjectStore(O,{keyPath:"key"})})),U(_,(function(t){var e=t.createObjectStore(_,{keyPath:"id",autoIncrement:!0});e.createIndex("environment","environment",{unique:!1}),e.createIndex("date","date",{unique:!1}),e.createIndex("type","type",{unique:!1})})),U(R,(function(t){t.createObjectStore(R,{keyPath:"id",autoIncrement:!0}).createIndex("date","date",{unique:!1})}))];const L=function(){function t(t){void 0===t&&(t=new Date),this._date=t}return Object.defineProperty(t.prototype,"date",{get:function(){return this._date},set:function(t){this._date=t},enumerable:!1,configurable:!0}),t.prototype.getUtcTimestamp=function(){return Math.floor((this.date.getTime()+60*this.date.getTimezoneOffset()*1e3)/1e3)},t.prototype.getTimestamp=function(){return Math.round(this.date.getTime()/1e3)},t.prototype.setLocal=function(){var t=this._date.getTime()-60*this.date.getTimezoneOffset()*1e3;this._date=new Date(t)},t.prototype.addDays=function(t){var e=this._date.getTime()+24*t*60*60*1e3;this._date=new Date(e)},t.prototype.getInboxFakeOrder=function(){return(100*this._date.getTime()+9e9).toString()},t}();const j=function(){function t(t){void 0===t&&(t=new L),this.migrations={initial:W,"2018/11/26":q},this.dateModule=t}return Object.defineProperty(t.prototype,"initial",{get:function(){return this.migrations.initial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dateSorted",{get:function(){var t=this;return Object.keys(this.migrations).filter((function(t){return"initial"!==t})).sort((function(t,e){var n=new L(new Date(t)),r=new L(new Date(e));return n.getTimestamp()-r.getTimestamp()})).map((function(e){return t.migrations[e]}))},enumerable:!1,configurable:!0}),t}();const V=function(){function t(t,e){void 0===e&&(e=new j),this.db=t,this.migrationsBuilder=e}return t.prototype.applyMigrations=function(){var t=this;this.applyMigrationsPack(this.migrationsBuilder.initial),this.migrationsBuilder.dateSorted.forEach((function(e){t.applyMigrationsPack(e)}))},t.prototype.applyMigrationsPack=function(t){var e=this;t.forEach((function(t){t(e.db)}))},t}();function B(t,e){console.info("onversionchange",e),t.close()}var H;function F(t){return(H||(H=new Promise((function(t,e){var n=indexedDB.open("PUSHWOOSH_SDK_STORE",7);n.onsuccess=function(n){var r=n.target.result;r.onversionchange=B.bind(null,r,e),t(r)},n.onerror=function(){return e(n.error)},n.onupgradeneeded=function(t){var n=t.target.result;n.onversionchange=B.bind(null,n,e),new V(n).applyMigrations()}}))),H).then((function(e){return new Promise((function(n,r){return t(e,n,r)}))}))}var K,z=function(){function t(){}return t.prototype._add=function(t){var e=this;return F((function(n,r,s){var i=n.transaction([e.name],"readwrite").objectStore(e.name).add(t);i.onsuccess=function(){r(t)},i.onerror=function(){s(i.error)}})).then((function(t){return e.getAll().then((function(n){if(Array.isArray(n)){var r=n.map((function(t){return t.id})).sort((function(t,e){return t==e?0:t<e?1:-1}));if(r.length>e.maxItems)return Promise.all(r.slice(e.maxItems).map((function(t){return e.delete(t)}))).then((function(){return t}))}return t}))}))},t.prototype.delete=function(t){var e=this;return F((function(n,r,s){var i=n.transaction([e.name],"readwrite").objectStore(e.name).delete(t);i.onsuccess=function(){r(i.result)},i.onerror=function(){s(i.error)}}))},t.prototype.getAll=function(){var t=this;return F((function(e,n,r){var s=[],i=e.transaction(t.name).objectStore(t.name).openCursor();i.onsuccess=function(t){var e=t.target.result;e?(e.value&&s.push(e.value),e.continue()):n(s)},i.onerror=function(){r(i.error)}}))},t}(),J=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name=_,e.maxItems=100,e.environment="undefined"!=typeof self&&self.registration?"worker":"browser",e}return e(n,t),n.prototype.add=function(t,e,n){var r={type:t,environment:this.environment,message:"".concat(e),date:new Date};return e instanceof Error&&(r.stack=e.stack),n&&(r.additional=n),this._add(r)},n}(z),G=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.name=R,e.maxItems=25,e}return e(r,t),r.prototype.add=function(t){return this._add(n(n({},t),{date:new Date}))},r}(z),Y=(K=O,{get:function(t,e){return F((function(n,r,s){var i,o=n.transaction(K).objectStore(K).get(t),a=!1,u=!1,c=function(){if(clearTimeout(i),a){var t=o.result;r(t&&t.value||e)}else u?s(o.error):i=setTimeout(c,0)};o.onsuccess=function(){return a=!0},o.onerror=function(){return u=!0},c()}))},getAll:function(){return F((function(t,e,n){var r,s={},i=t.transaction(K).objectStore(K).openCursor(),o=!1,a=!1,u=function(){clearTimeout(r),o?e(s):a?n(i.error):r=setTimeout(u,0)};i.onsuccess=function(t){var e=t.target.result;e?(s[e.key]=e.value.value,e.continue()):o=!0},i.onerror=function(){return a=!0},u()}))},extend:function(t,e){return s(this,void 0,void 0,(function(){var s,o;return i(this,(function(i){switch(i.label){case 0:return[4,this.get(t)];case 1:return s=i.sent(),o=r(e,[]),[4,this.set(t,n(n({},s),o))];case 2:return i.sent(),[2]}}))}))},set:function(t,e){return F((function(n,r,s){var i,o=n.transaction([K],"readwrite").objectStore(K).put({key:t,value:e}),a=!1,u=!1,c=function(){clearTimeout(i),a?r(t):u?s(o.error):i=setTimeout(c,0)};o.onsuccess=function(){return a=!0},o.onerror=function(){return u=!0},c()}))}}),$=new J,Q=new G,X={error:1,info:2,debug:3},Z=3;!function(){for(var t,e=function(){},n=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],r=n.length,s=y(),i=s.console=s.console||{};r--;)i[t=n[r]]||(i[t]=e)}();var tt={setLevel:function(t){X[t]||(t="error"),Z=X[t]},write:function(t,e,n){return"error"===t?this.error(e):this.info(e),$.add(t,e,n)}};Object.keys(X).forEach((function(t){var e=X[t];tt[t]=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];e<=Z&&(console.groupCollapsed(t),console.info.apply(console,o([""],n,!1)),console.trace("trace"),console.groupEnd())}}));var et=function(){function t(t,e,n,r){void 0===r&&(r=new L),this.data=t,this.api=e,this.inboxModel=n,this.dateModule=r,this.publicMessageBuilder=this.publicMessageBuilder.bind(this)}return t.prototype.messageTypeFactory=function(t,e){var n=0;return 2===t?n=1:"l"in e&&null!=e.l&&(n=e.l.startsWith("http")?2:3),n},t.prototype.updateMessagesStatusWithCodes=function(t,e,n){return s(this,void 0,void 0,(function(){var r,o,a=this;return i(this,(function(u){switch(u.label){case 0:return r=[],o=[],e.forEach((function(e){return s(a,void 0,void 0,(function(){return i(this,(function(s){return-1===t.indexOf(e.inbox_id)||(e.status=n,r.push(e),o.push(this.api.inboxStatus(e.order,e.status))),[2]}))}))})),[4,this.inboxModel.putBulkMessages(r)];case 1:return u.sent(),[4,Promise.all(o)];case 2:return u.sent(),[2]}}))}))},t.prototype.publicMessageBuilder=function(t){return s(this,arguments,void 0,(function(t){var e,n,r,s,o,a=t.action_type,u=t.action_params,c=t.image,h=t.title,p=t.send_date,d=t.inbox_id,l=t.text,f=t.status;return i(this,(function(t){switch(t.label){case 0:return(n=c)?[3,2]:[4,this.data.getDefaultNotificationImage()];case 1:n=t.sent(),t.label=2;case 2:return e=n,(s=h)?[3,4]:[4,this.data.getDefaultNotificationTitle()];case 3:s=t.sent(),t.label=4;case 4:return r=s,o=JSON.parse(u),this.dateModule.date=new Date(1e3*parseInt(p)),this.dateModule.setLocal(),[2,{title:r,imageUrl:e,code:d,message:l,sendDate:this.dateModule.date.toISOString(),type:this.messageTypeFactory(a,o),link:(null==o?void 0:o.l)||"/",isRead:2===f||3===f,isActionPerformed:3===f}]}}))}))},t.prototype.messagesWithNoActionPerformedCount=function(){return this.inboxModel.getDeliveredReadMessagesCount()},t.prototype.unreadMessagesCount=function(){return this.inboxModel.getDeliveredMessagesCount()},t.prototype.messagesCount=function(){return this.inboxModel.messagesCount()},t.prototype.loadMessages=function(){return s(this,void 0,void 0,(function(){var t,e,n;return i(this,(function(r){switch(r.label){case 0:return[4,this.inboxModel.getReadOpenMessages()];case 1:return t=r.sent(),[4,this.inboxModel.getDeliveredMessages()];case 2:return e=r.sent(),n=o(o([],t,!0),e,!0).sort((function(t,e){return parseInt(e.send_date,10)-parseInt(t.send_date,10)})).sort((function(t,e){return parseInt(e.order||"0",10)-parseInt(t.order||"0",10)})).map(this.publicMessageBuilder),[2,Promise.all(n)]}}))}))},t.prototype.readMessagesWithCodes=function(t){return s(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this.inboxModel.getDeliveredMessages()];case 1:return e=n.sent(),[4,this.updateMessagesStatusWithCodes(t,e,2)];case 2:return n.sent(),[2]}}))}))},t.prototype.performActionForMessageWithCode=function(t){return s(this,void 0,void 0,(function(){var e,n,r;return i(this,(function(s){switch(s.label){case 0:return[4,this.inboxModel.getMessage(t)];case 1:return e=s.sent(),n=JSON.parse(e.action_params),2===(r=this.messageTypeFactory(e.action_type,n))&&null!=n.l?document.location.href=n.l:3===r&&null!=n.l&&window.history.go(n.l),e.status=3,[4,this.inboxModel.putMessage(e)];case 2:return s.sent(),[4,this.api.inboxStatus(e.order,e.status)];case 3:return s.sent(),[2]}}))}))},t.prototype.deleteMessagesWithCodes=function(t){return s(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return[4,this.inboxModel.getReadOpenMessages()];case 1:return e=r.sent(),[4,this.inboxModel.getDeliveredMessages()];case 2:return n=r.sent(),[4,this.updateMessagesStatusWithCodes(t,o(o([],e,!0),n,!0),4)];case 3:return r.sent(),[2]}}))}))},t.prototype.syncMessages=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.inboxModel.updateMessages()];case 1:return t.sent(),[2]}}))}))},t}();const nt=et;var rt=function(){function t(t,e){this.name=e,this.store=t.transaction(this.name,"readwrite").objectStore(this.name)}return Object.defineProperty(t.prototype,"index",{set:function(t){this.store.indexNames.contains(t)?this._index=this.store.index(t):console.warn('Index "'.concat(t,'" in '))},enumerable:!1,configurable:!0}),t.prototype.writeRequestPromise=function(t,e){return new Promise((function(n,r){t.onsuccess=function(){n(e)},t.onerror=function(){r(t.error)}}))},t.prototype.readRequestPromise=function(t,e){return new Promise((function(n,r){t.onsuccess=function(t){var r=t.target;n(r.result||e)},t.onerror=function(){r(t.error)}}))},t.prototype.put=function(t,e){var n=this.store.put(t,e);return this.writeRequestPromise(n,e)},t.prototype.add=function(t,e){return this.put(t,e)},t.prototype.delete=function(t){var e=this.store.delete(t);return this.writeRequestPromise(e)},t.prototype.get=function(t,e){var n=this.store.get(t);return this.readRequestPromise(n,e)},t.prototype.getAll=function(){var t=this.store.openCursor(),e=[];return new Promise((function(n,r){t.onsuccess=function(t){var r=t.target.result;r?(e.push(r.value),r.continue()):n(e)},t.onerror=function(){r(t.error)}}))},t.prototype.count=function(t){var e=this.store.count(t);return this.readRequestPromise(e,0)},t.prototype.countByIndex=function(t){var e=this._index.count(t);return this.readRequestPromise(e,0)},t}();const st=rt;var it=function(){function t(){}return t.prototype.dbVersionChangeHandler=function(t,e){console.info("onversionchange",e),t.close()},t.prototype.dbRequestSuccessHandler=function(t,e){var n=this,r=e.target.result;r.onversionchange=function(t){n.dbVersionChangeHandler(r,t)},t(r)},t.prototype.dbRequestUpgradeNeededHandler=function(t){var e=this,n=t.target.result;n.onversionchange=function(t){e.dbVersionChangeHandler(n,t)},new V(n).applyMigrations()},t.prototype.getDB=function(){var t=this;return new Promise((function(e,n){var r=indexedDB.open("PUSHWOOSH_SDK_STORE",7);r.onsuccess=function(n){t.dbRequestSuccessHandler(e,n)},r.onupgradeneeded=function(e){t.dbRequestUpgradeNeededHandler(e)},r.onerror=function(){return n(r.error)}}))},t.prototype.put=function(t,e,n){return s(this,void 0,void 0,(function(){var r,s;return i(this,(function(i){switch(i.label){case 0:return[4,this.getDB()];case 1:return r=i.sent(),[4,new st(r,t).put(e,n)];case 2:return s=i.sent(),r.close(),[2,s]}}))}))},t.prototype.delete=function(t,e){return s(this,void 0,void 0,(function(){var n,r;return i(this,(function(s){switch(s.label){case 0:return[4,this.getDB()];case 1:return n=s.sent(),[4,new st(n,t).delete(e)];case 2:return r=s.sent(),n.close(),[2,r]}}))}))},t.prototype.get=function(t,e,n){return s(this,void 0,void 0,(function(){var r,s;return i(this,(function(i){switch(i.label){case 0:return[4,this.getDB()];case 1:return r=i.sent(),[4,new st(r,t).get(e,n)];case 2:return s=i.sent(),r.close(),[2,s]}}))}))},t.prototype.getAll=function(t){return s(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getDB()];case 1:return e=r.sent(),[4,new st(e,t).getAll()];case 2:return n=r.sent(),e.close(),[2,n||[]]}}))}))},t.prototype.count=function(t,e){return s(this,void 0,void 0,(function(){var n,r;return i(this,(function(s){switch(s.label){case 0:return[4,this.getDB()];case 1:return n=s.sent(),[4,new st(n,t).count(e)];case 2:return r=s.sent(),n.close(),[2,r]}}))}))},t.prototype.countByIndex=function(t,e,n){return s(this,void 0,void 0,(function(){var r,s,o;return i(this,(function(i){switch(i.label){case 0:return[4,this.getDB()];case 1:return r=i.sent(),(s=new st(r,t)).index=e,[4,s.countByIndex(n)];case 2:return o=i.sent(),r.close(),[2,o]}}))}))},t}();const ot=it;var at=function(){function t(t,e,n,r,s){void 0===r&&(r=new ot),void 0===s&&(s=new L),this.eventBus=t,this.data=e,this.api=n,this.storage=r,this.storeName="inboxMessages",this.dateModule=s}return t.prototype.getInboxMessages=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this.api.getInboxMessages()];case 1:return t=e.sent(),[4,this.storeGetInboxMessagesRequestParams(t.next,t.new_inbox)];case 2:return e.sent(),[2,t]}}))}))},t.prototype.storeGetInboxMessagesRequestParams=function(t,e){return s(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return this.dateModule.date=new Date,[4,this.data.setInboxLastRequestTime(this.dateModule.getUtcTimestamp())];case 1:return n.sent(),[4,this.data.setInboxLastRequestCode(t)];case 2:return n.sent(),[4,this.data.setInboxNewMessagesCount(e)];case 3:return n.sent(),[2]}}))}))},t.prototype.putServerMessages=function(t){return s(this,void 0,void 0,(function(){var e,n=this;return i(this,(function(r){return e=t.map((function(t){return s(n,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this.storage.get(this.storeName,t.inbox_id,{})];case 1:return"status"in(e=n.sent())&&(t.status=e.status),[2,this.putMessage(t)]}}))}))})),[2,Promise.all(e)]}))}))},t.prototype.putMessage=function(t){return this.storage.put(this.storeName,t)},t.prototype.putBulkMessages=function(t){var e=this,n=t.map((function(t){return e.putMessage(t)}));return Promise.all(n)},t.prototype.deleteMessages=function(t){var e=this,n=t.map((function(t){return e.storage.delete(e.storeName,t)}));return Promise.all(n)},t.prototype.deleteExpiredMessages=function(){return s(this,void 0,void 0,(function(){var t,e,n;return i(this,(function(r){switch(r.label){case 0:return this.dateModule.date=new Date,t=this.dateModule.getTimestamp().toString(),[4,this.storage.getAll(this.storeName)];case 1:return e=r.sent(),n=e.filter((function(e){return e.rt<t})).map((function(t){return t.inbox_id})),[2,this.deleteMessages(n)]}}))}))},t.prototype.getMessage=function(t){return this.storage.get(this.storeName,t)},t.prototype.getReadOpenMessages=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.storage.getAll(this.storeName)];case 1:return[2,t.sent().filter((function(t){return 2===t.status||3===t.status}))]}}))}))},t.prototype.getDeliveredMessages=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.storage.getAll(this.storeName)];case 1:return[2,t.sent().filter((function(t){return 1===t.status}))]}}))}))},t.prototype.messagesCount=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.storage.count(this.storeName)]}))}))},t.prototype.getDeliveredMessagesCount=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.storage.countByIndex(this.storeName,"status",1)]}))}))},t.prototype.getReadMessagesCount=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.storage.countByIndex(this.storeName,"status",2)]}))}))},t.prototype.getDeliveredReadMessagesCount=function(){return s(this,void 0,void 0,(function(){var t,e,n,r;return i(this,(function(s){return e=(t=[2,3])[0],n=t[1],r=IDBKeyRange.bound(e,n),[2,this.storage.countByIndex(this.storeName,"status",r)]}))}))},t.prototype.updateMessages=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this.getInboxMessages()];case 1:return t=e.sent(),[4,this.deleteExpiredMessages()];case 2:return e.sent(),t.deleted?[4,this.deleteMessages(t.deleted)]:[3,4];case 3:e.sent(),e.label=4;case 4:return[4,this.putServerMessages(t.messages)];case 5:return e.sent(),this.eventBus.dispatchEvent("update-inbox-messages",{messages:new nt(this.data,this.api,this)}),[2]}}))}))},t}();const ut=at;var ct={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},ht=/&(?:amp|lt|gt|quot|#39);/g,pt=RegExp(ht.source);var dt=function(){function t(t){void 0===t&&(t=Y),this.store=t}return t.prototype.clearAll=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.set("params.applicationCode",void 0)];case 1:return t.sent(),[4,this.store.set("params.hwid",void 0)];case 2:return t.sent(),[4,this.store.set("params.deviceType",void 0)];case 3:return t.sent(),[4,this.store.set("params.deviceModel",void 0)];case 4:return t.sent(),[4,this.store.set("params.language",void 0)];case 5:return t.sent(),[4,this.store.set("params.apiEntrypoint",void 0)];case 6:return t.sent(),[4,this.store.set("params.tokens",void 0)];case 7:return t.sent(),[4,this.store.set("params.applicationServerKey",void 0)];case 8:return t.sent(),[4,this.store.set("params.senderId",void 0)];case 9:return t.sent(),[4,this.store.set("params.webSitePushId",void 0)];case 10:return t.sent(),[4,this.store.set("params.defaultNotificationImage",void 0)];case 11:return t.sent(),[4,this.store.set("params.defaultNotificationTitle",void 0)];case 12:return t.sent(),[4,this.store.set("params.userId",void 0)];case 13:return t.sent(),[4,this.store.set("params.email",void 0)];case 14:return t.sent(),[4,this.store.set("params.userIdWasChanged",void 0)];case 15:return t.sent(),[4,this.store.set("params.isLastPermissionStatus",void 0)];case 16:return t.sent(),[4,this.store.set("params.isManualUnsubscribed",void 0)];case 17:return t.sent(),[4,this.store.set("params.isCommunicationDisabled",void 0)];case 18:return t.sent(),[4,this.store.set("params.isDropAllData",void 0)];case 19:return t.sent(),[4,this.store.set("params.sdkVersion",void 0)];case 20:return t.sent(),[4,this.store.set("params.serviceWorkerVersion",void 0)];case 21:return t.sent(),[4,this.store.set("params.serviceWorkerUrl",void 0)];case 22:return t.sent(),[4,this.store.set("params.serviceWorkerScope",void 0)];case 23:return t.sent(),[4,this.store.set("params.lastOpenMessage",void 0)];case 24:return t.sent(),[4,this.store.set("params.lastOpenApplicationTime",void 0)];case 25:return t.sent(),[4,this.store.set("params.features",void 0)];case 26:return t.sent(),[4,this.store.set("params.init",void 0)];case 27:return t.sent(),[4,this.store.set("API_PARAMS",void 0)];case 28:return t.sent(),[4,this.store.set("SENDER_ID",void 0)];case 29:return t.sent(),[4,this.store.set("COMMUNICATION_ENABLED",void 0)];case 30:return t.sent(),[4,this.store.set("DEVICE_DATA_REMOVED",void 0)];case 31:return t.sent(),[4,this.store.set("LAST_OPEN_MESSAGE",void 0)];case 32:return t.sent(),[4,this.store.set("DELAYED_EVENT",void 0)];case 33:return t.sent(),[2]}}))}))},t.prototype.setApplicationCode=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.applicationCode",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getApplicationCode=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.applicationCode")];case 1:return[2,t.sent()]}}))}))},t.prototype.setApiToken=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.apiToken",t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getApiToken=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.apiToken")];case 1:return[2,t.sent()]}}))}))},t.prototype.setHwid=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.hwid",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getHwid=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.hwid")];case 1:return[2,t.sent()]}}))}))},t.prototype.setDeviceType=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.deviceType",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getDeviceType=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.deviceType")];case 1:return[2,t.sent()]}}))}))},t.prototype.setDeviceModel=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.deviceModel",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getDeviceModel=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.deviceModel")];case 1:return[2,t.sent()]}}))}))},t.prototype.setLanguage=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.language",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getLanguage=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.language","en")];case 1:return[2,t.sent()]}}))}))},t.prototype.setApiEntrypoint=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.apiEntrypoint",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getApiEntrypoint=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.apiEntrypoint","https://cp.pushwoosh.com/json/1.3/")];case 1:return[2,t.sent()]}}))}))},t.prototype.setTokens=function(t){return s(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return[4,this.getHwid()];case 1:return e=r.sent(),[4,this.store.set("API_PARAMS",n({hwid:e},t))];case 2:return r.sent(),[4,this.store.set("params.tokens",t)];case 3:return r.sent(),[2]}}))}))},t.prototype.getTokens=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.store.get("API_PARAMS")];case 1:return t=n.sent(),[4,this.store.get("params.tokens")];case 2:return[2,void 0!==(e=n.sent())?e:t]}}))}))},t.prototype.setApplicationServerKey=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.applicationServerKey",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getApplicationServerKey=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.applicationServerKey")];case 1:return[2,t.sent()]}}))}))},t.prototype.setIsVapidChanged=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.isVapidChanged",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getIsVapidChanged=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.isVapidChanged",!1)];case 1:return[2,t.sent()]}}))}))},t.prototype.setWebSitePushId=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.webSitePushId",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getWebSitePushId=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.webSitePushId")];case 1:return[2,t.sent()]}}))}))},t.prototype.setDefaultNotificationImage=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.defaultNotificationImage",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getDefaultNotificationImage=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.defaultNotificationImage","https://cp.pushwoosh.com/img/logo-medium.png")];case 1:return[2,t.sent()]}}))}))},t.prototype.setDefaultNotificationTitle=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.defaultNotificationTitle",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getDefaultNotificationTitle=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.defaultNotificationTitle","Pushwoosh notification")];case 1:return[2,t.sent()]}}))}))},t.prototype.setUserId=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return t?[3,2]:[4,this.store.set("params.userId",void 0)];case 1:case 3:return e.sent(),[2];case 2:return[4,this.store.set("params.userId",t.toString())]}}))}))},t.prototype.getUserId=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.userId")];case 1:return[2,t.sent()]}}))}))},t.prototype.setStatusUserIdWasChanged=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.userIdWasChanged",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getStatusUserIdWasChanged=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.userIdWasChanged",!1)];case 1:return[2,t.sent()]}}))}))},t.prototype.setEmail=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return t?[3,2]:[4,this.store.set("params.email",void 0)];case 1:case 3:return e.sent(),[2];case 2:return[4,this.store.set("params.email",t.toString())]}}))}))},t.prototype.getEmail=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.email")];case 1:return[2,t.sent()]}}))}))},t.prototype.setStatusEmailWasChanged=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.emailWasChanged",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getStatusEmailWasChanged=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.emailWasChanged",!1)];case 1:return[2,t.sent()]}}))}))},t.prototype.setLastPermissionStatus=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.isLastPermissionStatus",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getLastPermissionStatus=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.isLastPermissionStatus")];case 1:return[2,t.sent()]}}))}))},t.prototype.setStatusManualUnsubscribed=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("MANUAL_UNSUBSCRIBE",t)];case 1:return e.sent(),[4,this.store.set("params.isManualUnsubscribed",t)];case 2:return e.sent(),[2]}}))}))},t.prototype.getStatusManualUnsubscribed=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.store.get("MANUAL_UNSUBSCRIBE",!1)];case 1:return t=n.sent(),[4,this.store.get("params.isManualUnsubscribed",!1)];case 2:return[2,void 0!==(e=n.sent())?e:t]}}))}))},t.prototype.setStatusCommunicationDisabled=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("COMMUNICATION_ENABLED",t?0:1)];case 1:return e.sent(),[4,this.store.set("params.isCommunicationDisabled",t)];case 2:return e.sent(),[2]}}))}))},t.prototype.getStatusCommunicationDisabled=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.store.get("COMMUNICATION_ENABLED")];case 1:return t=n.sent(),[4,this.store.get("params.isCommunicationDisabled",!1)];case 2:return[2,void 0!==(e=n.sent())?e:0==t]}}))}))},t.prototype.setStatusDropAllData=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("DEVICE_DATA_REMOVED",t)];case 1:return e.sent(),[4,this.store.set("params.isDropAllData",t)];case 2:return e.sent(),[2]}}))}))},t.prototype.getStatusDropAllData=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.store.get("DEVICE_DATA_REMOVED",!1)];case 1:return t=n.sent(),[4,this.store.get("params.isDropAllData",!1)];case 2:return[2,void 0!==(e=n.sent())?e:t]}}))}))},t.prototype.setSdkVersion=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.sdkVersion",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getSdkVersion=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.sdkVersion")];case 1:return[2,t.sent()]}}))}))},t.prototype.setServiceWorkerVersion=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("WORKER_VERSION",t)];case 1:return e.sent(),[4,this.store.set("params.serviceWorkerVersion",t)];case 2:return e.sent(),[2]}}))}))},t.prototype.getServiceWorkerVersion=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.store.get("WORKER_VERSION")];case 1:return t=n.sent(),[4,this.store.get("params.serviceWorkerVersion")];case 2:return[2,void 0!==(e=n.sent())?e:t]}}))}))},t.prototype.setServiceWorkerUrl=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return t?[4,this.store.set("params.serviceWorkerUrl",t)]:[2];case 1:return e.sent(),[2]}}))}))},t.prototype.getServiceWorkerUrl=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.serviceWorkerUrl","/pushwoosh-service-worker.js")];case 1:return[2,t.sent()]}}))}))},t.prototype.setServiceWorkerScope=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return t?[4,this.store.set("params.serviceWorkerScope",t)]:[2];case 1:return e.sent(),[2]}}))}))},t.prototype.getServiceWorkerScope=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.serviceWorkerScope")];case 1:return[2,t.sent()]}}))}))},t.prototype.setLastOpenMessage=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("LAST_OPEN_MESSAGE",t)];case 1:return e.sent(),[4,this.store.set("params.lastOpenMessage",t)];case 2:return e.sent(),[2]}}))}))},t.prototype.getLastOpenMessage=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.store.get("LAST_OPEN_MESSAGE")];case 1:return t=n.sent(),[4,this.store.get("params.lastOpenMessage")];case 2:return[2,void 0!==(e=n.sent())?e:t]}}))}))},t.prototype.setLastOpenApplicationTime=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.lastOpenApplicationTime",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getLastOpenApplicationTime=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.lastOpenApplicationTime")];case 1:return[2,t.sent()]}}))}))},t.prototype.setFeatures=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.features",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getFeatures=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.features")];case 1:return[2,t.sent()]}}))}))},t.prototype.setInitParams=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.init",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getInitParams=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.init")];case 1:return[2,t.sent()]}}))}))},t.prototype.setInboxLastRequestCode=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.inbox.lastRequestCode",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getInboxLastRequestCode=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.inbox.lastRequestCode","")];case 1:return[2,t.sent()]}}))}))},t.prototype.setInboxLastRequestTime=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.inbox.lastRequestTime",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getInboxLastRequestTime=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.store.get("params.inbox.lastRequestTime",0)]}))}))},t.prototype.setInboxNewMessagesCount=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.inbox.newMessagesCount",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getInboxNewMessagesCount=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.store.get("params.inbox.newMessagesCount",0)]}))}))},t.prototype.setDelayedEvent=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("DELAYED_EVENT",t)];case 1:return e.sent(),[4,this.store.set("params.delayedEvent",t)];case 2:return e.sent(),[2]}}))}))},t.prototype.getDelayedEvent=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.store.get("DELAYED_EVENT")];case 1:return t=n.sent(),[4,this.store.get("params.delayedEvent")];case 2:return[2,void 0!==(e=n.sent())?e:t]}}))}))},t.prototype.setPromptDisplayCount=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.promptDisplayCount",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getPromptDisplayCount=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.store.get("params.promptDisplayCount",0)]}))}))},t.prototype.setPromptLastSeenTime=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.promptLastSeenTime",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getPromptLastSeenTime=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.store.get("params.promptLastSeenTime",0)]}))}))},t}(),lt=function(){function t(t,e,n){if(void 0===e&&(e=new dt),void 0===n&&(n=new L),"data"in t){var r=t;this.payload=r.data}else this.payload=t;this.data=e,this.code="notificationCode-".concat(Date.now(),"-").concat(Math.random().toString(16).slice(2,10)),this.dateModule=n}return t.prototype.getIcon=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return(t=this.payload.i)?[3,2]:[4,this.data.getDefaultNotificationImage()];case 1:t=e.sent(),e.label=2;case 2:return[2,t]}}))}))},t.prototype.getTitle=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return(t=this.payload.header)?[3,2]:[4,this.data.getDefaultNotificationTitle()];case 1:t=e.sent(),e.label=2;case 2:return[2,t]}}))}))},Object.defineProperty(t.prototype,"silent",{get:function(){return Boolean(this.payload.silent)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"body",{get:function(){return this.payload.body},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"messageHash",{get:function(){return this.payload.p||""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"metaData",{get:function(){return this.payload.md?b(this.payload.md):{}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"image",{get:function(){return this.payload.image||""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttons",{get:function(){return this.payload.buttons?b(this.payload.buttons):[]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"customData",{get:function(){return this.payload.u?b(this.payload.u):{}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"campaignCode",{get:function(){return this.payload.pwcid||""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"link",{get:function(){return this.payload.l?(t=this.payload.l)&&pt.test(t)?t.replace(ht,(function(t){return ct[t]})):t:"/";var t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"inboxId",{get:function(){return this.payload.pw_inbox||""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"inboxParams",{get:function(){return this.payload.inbox_params?b(this.payload.inbox_params):{}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"inboxRemovalTime",{get:function(){return this.inboxParams&&this.inboxParams.rt?this.inboxParams.rt:(this.dateModule.date=new Date,this.dateModule.addDays(1),this.dateModule.getUtcTimestamp().toString())},enumerable:!1,configurable:!0}),t.prototype.getInboxImage=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return this.inboxParams&&this.inboxParams.image?[2,this.inboxParams.image]:[2,""]}))}))},Object.defineProperty(t.prototype,"rootParams",{get:function(){var t=this.payload;t.body,t.p,t.header,t.i,t.u,t.l,t.pwcid,t.image,t.buttons,t.pw_inbox,t.inbox_params;return r(t,["body","p","header","i","u","l","pwcid","image","buttons","pw_inbox","inbox_params"])},enumerable:!1,configurable:!0}),t.prototype.getNotificationOptionsPayload=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(r){switch(r.label){case 0:return[4,this.getTitle()];case 1:return t=r.sent(),[4,this.getIcon()];case 2:return e=r.sent(),[2,n(n({},this.rootParams),{body:this.body,title:t,icon:e,image:this.image,buttons:this.buttons,customData:this.customData,metaData:this.metaData,campaignCode:this.campaignCode,openUrl:this.link,messageHash:this.messageHash})]}}))}))},t.prototype.getShowNotificationOptions=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(r){switch(r.label){case 0:return[4,this.getIcon()];case 1:return t=r.sent(),e=this.buttons.map((function(t,e){return t.action="action-".concat(e),t})),[2,n(n({renotify:!0},this.rootParams),{body:this.body,icon:t,tag:JSON.stringify({url:this.link,messageHash:this.messageHash,customData:this.customData,metaData:this.metaData}),data:{code:this.code,buttons:e,image:this.image,campaignCode:this.campaignCode,inboxId:this.inboxId},silent:this.silent,actions:e,image:this.image,buttons:e})]}}))}))},t.prototype.getInboxMessage=function(){return s(this,void 0,void 0,(function(){var t,e,n;return i(this,(function(r){switch(r.label){case 0:return this.dateModule.date=new Date,t=this.dateModule.getTimestamp().toString(),e=this.payload.header||"",[4,this.getInboxImage()];case 1:return n=r.sent(),[2,{title:e,image:n,status:1,order:this.dateModule.getInboxFakeOrder(),inbox_id:this.inboxId,send_date:t,rt:this.inboxRemovalTime,text:this.body,action_type:1,action_params:JSON.stringify({l:this.link})}]}}))}))},t}();const ft=lt;var vt=function(){function t(t,e){void 0===t&&(t=new dt),void 0===e&&(e=tt),this.data=t,this.logger=e}return t.prototype.checkDevice=function(t){return this.createRequest("checkDevice",t)},t.prototype.getConfig=function(t){return this.createRequest("getConfig",t,"",!0)},t.prototype.applicationOpen=function(t){return this.createRequest("applicationOpen",t)},t.prototype.registerDevice=function(t){return this.createRequest("registerDevice",t)},t.prototype.unregisterDevice=function(t){return this.createRequest("unregisterDevice",t)},t.prototype.deleteDevice=function(t){return this.createRequest("deleteDevice",t)},t.prototype.messageDeliveryEvent=function(t){return this.createRequest("messageDeliveryEvent",t)},t.prototype.pushStat=function(t){return this.createRequest("pushStat",t)},t.prototype.setTags=function(t){return this.createRequest("setTags",t)},t.prototype.getTags=function(t){return this.createRequest("getTags",t)},t.prototype.registerUser=function(t){return this.createRequest("registerUser",t)},t.prototype.registerEmail=function(t){return this.createRequest("registerEmail",t)},t.prototype.registerEmailUser=function(t){return this.createRequest("registerEmailUser",t)},t.prototype.setEmailTags=function(t){return this.createRequest("setEmailTags",t)},t.prototype.postEvent=function(t){return this.createRequest("postEvent",t)},t.prototype.getInboxMessages=function(t){return this.createRequest("getInboxMessages",t)},t.prototype.inboxStatus=function(t){return this.createRequest("inboxStatus",t)},t.prototype.pageVisit=function(t,e){return this.createRequest("pageVisit",t,e)},t.prototype.setPurchase=function(t){return this.createRequest("setPurchase",t)},t.prototype.createRequest=function(t,e,r,o){return s(this,void 0,void 0,(function(){var s,a,u,c,h,p,d;return i(this,(function(i){switch(i.label){case 0:return[4,this.data.getApiEntrypoint()];case 1:return s=i.sent(),o?(u="",[3,4]):[3,2];case 2:return[4,this.data.getApiToken()];case 3:u=i.sent(),i.label=4;case 4:return c=r||s+t,h=(a=u)?{headers:{Authorization:"Token ".concat(a),"Content-Type":"text/plain;charset=UTF-8",Origin:globalThis.location.origin},credentials:"include"}:{},[4,fetch(c,n({method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8"},body:JSON.stringify({request:e})},h))];case 5:return p=i.sent(),[4,this.checkResponse(p)];case 6:return(d=i.sent()).base_url?[4,this.data.setApiEntrypoint(d.base_url)]:[3,8];case 7:i.sent(),i.label=8;case 8:return[4,this.logger.write("apirequest","".concat(t," call with arguments: ").concat(JSON.stringify(e)," to Pushwoosh has been successful. Result: ").concat(JSON.stringify(d.response)))];case 9:return i.sent(),[2,d.response]}}))}))},t.prototype.checkResponse=function(t){return s(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:if(200!==t.status)throw new Error("Error code: ".concat(t.status,". Error text: ").concat(t.statusText));return[4,t.json()];case 1:if(200!==(e=n.sent()).status_code)throw new Error("Error code: ".concat(e.status_code,". Error text: ").concat(e.status_message));return[2,e]}}))}))},t}(),gt=function(){function t(t,e,n){void 0===e&&(e=new dt),void 0===n&&(n=new vt),this.eventBus=t,this.data=e,this.apiClient=n}return t.prototype.checkDevice=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this.getRequestParams()];case 1:return t=e.sent(),[4,this.apiClient.checkDevice(t)];case 2:return[2,e.sent()]}}))}))},t.prototype.checkDeviceSubscribeForPushNotifications=function(){return s(this,arguments,void 0,(function(t){var e,n,r,s;return void 0===t&&(t=!0),i(this,(function(i){switch(i.label){case 0:return void 0!==(e=localStorage.getItem(a))&&t?[3,2]:[4,this.checkDevice()];case 1:n=i.sent(),r=n.exist,s=n.push_token_exist,localStorage.setItem(a,r&&s?u:c),e=localStorage.getItem(a),i.label=2;case 2:return[2,e===u]}}))}))},t.prototype.getConfig=function(t){return s(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return[4,this.getRequestParams()];case 1:return e=r.sent(),[2,this.apiClient.getConfig(n(n({},e),{features:t}))]}}))}))},t.prototype.applicationOpen=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this.getRequestParams()];case 1:return t=e.sent(),[4,this.data.setLastOpenApplicationTime(Date.now())];case 2:return e.sent(),[2,this.apiClient.applicationOpen(t)]}}))}))},t.prototype.registerDevice=function(){return s(this,void 0,void 0,(function(){var t,e,r;return i(this,(function(s){switch(s.label){case 0:return[4,this.data.getStatusCommunicationDisabled()];case 1:if(s.sent())throw new Error("Can't register device: Communication is disabled!");return[4,this.getRequestParams()];case 2:return t=s.sent(),[4,this.data.getTokens()];case 3:if(!(e=s.sent()).pushToken)throw new Error("Can't register device: pushToken is not exist!");return[4,this.apiClient.registerDevice(n(n({},t),{push_token:e.pushToken,auth_token:e.authToken,public_key:e.publicKey}))];case 4:return r=s.sent(),[4,this.data.setStatusManualUnsubscribed(!1)];case 5:return s.sent(),localStorage.setItem(a,u),this.eventBus.dispatchEvent("register",{}),[2,r]}}))}))},t.prototype.unregisterDevice=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.getRequestParams()];case 1:return t=n.sent(),e=this.apiClient.unregisterDevice(t),localStorage.setItem(a,c),this.eventBus.dispatchEvent("unsubscribe",{}),[2,e]}}))}))},t.prototype.deleteDevice=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.getRequestParams()];case 1:return t=n.sent(),e=this.apiClient.deleteDevice(t),[4,this.data.setStatusManualUnsubscribed(!0)];case 2:return n.sent(),localStorage.setItem(a,c),this.eventBus.dispatchEvent("unsubscribe",{}),[2,e]}}))}))},t.prototype.messageDeliveryEvent=function(t,e){return s(this,arguments,void 0,(function(t,e,r){var s;return void 0===r&&(r={}),i(this,(function(e){switch(e.label){case 0:return[4,this.getRequestParams()];case 1:return s=e.sent(),[4,this.apiClient.messageDeliveryEvent(n(n({},s),{hash:t,metaData:r}))];case 2:return[2,e.sent()]}}))}))},t.prototype.pushStat=function(t,e){return s(this,arguments,void 0,(function(t,e,r){var s;return void 0===r&&(r={}),i(this,(function(e){switch(e.label){case 0:return[4,this.getRequestParams()];case 1:return s=e.sent(),[4,this.apiClient.pushStat(n(n({},s),{hash:t,metaData:r}))];case 2:return[2,e.sent()]}}))}))},t.prototype.setTags=function(t){return s(this,void 0,void 0,(function(){var e,s,o,a,u;return i(this,(function(i){switch(i.label){case 0:return[4,this.getRequestParams()];case 1:return e=i.sent(),s=e.hwid,o=e.device_type,a=r(e,["hwid","device_type"]),[4,this.data.getEmail()];case 2:return(u=i.sent())?[4,this.apiClient.setEmailTags(n(n({},a),{email:u,tags:t}))]:[3,4];case 3:i.sent(),i.label=4;case 4:return[2,this.apiClient.setTags(n(n({},a),{hwid:s,device_type:o,tags:t}))]}}))}))},t.prototype.getTags=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this.getRequestParams()];case 1:return t=e.sent(),[2,this.apiClient.getTags(t)]}}))}))},t.prototype.registerUser=function(t){return s(this,void 0,void 0,(function(){var e,s,o,a,u,c,h;return i(this,(function(i){switch(i.label){case 0:return[4,this.getRequestParams()];case 1:return e=i.sent(),s=e.hwid,e.device_type,o=r(e,["hwid","device_type"]),[4,this.data.getDeviceType()];case 2:return a=i.sent(),u="".concat(t),[4,this.data.getEmail()];case 3:return c=i.sent(),[4,this.apiClient.registerUser(n(n({},o),{hwid:s,userId:u,ts_offset:60*-(new Date).getTimezoneOffset(),device_type:a}))];case 4:return h=i.sent(),c?[4,this.apiClient.registerEmailUser(n(n({},o),{email:c,userId:u,ts_offset:60*-(new Date).getTimezoneOffset()}))]:[3,6];case 5:i.sent(),i.label=6;case 6:return[4,this.data.setUserId("".concat(t))];case 7:return i.sent(),[4,this.data.setStatusUserIdWasChanged(!0)];case 8:return i.sent(),[2,h]}}))}))},t.prototype.registerEmail=function(t){return s(this,void 0,void 0,(function(){var e,s,o;return i(this,(function(i){switch(i.label){case 0:return[4,this.getRequestParams()];case 1:return e=i.sent(),e.hwid,e.device_type,s=r(e,["hwid","device_type"]),[4,this.apiClient.registerEmail(n(n({},s),{email:t,ts_offset:60*-(new Date).getTimezoneOffset()}))];case 2:return o=i.sent(),[4,this.data.setEmail("".concat(t))];case 3:return i.sent(),[4,this.data.setStatusEmailWasChanged(!0)];case 4:return i.sent(),[2,o]}}))}))},t.prototype.postEvent=function(t,e){return s(this,void 0,void 0,(function(){var r,s,o,a,u,c,h;return i(this,(function(i){switch(i.label){case 0:return[4,this.getRequestParams()];case 1:return r=i.sent(),s=new Date,o=s.getTime(),a=Math.floor(o/1e3),u=a-s.getTimezoneOffset()/60*3600,[4,this.data.getLastOpenMessage()];case 2:if((c=i.sent())&&c.expiry>Date.now()){if(e.msgHash)return[2,Promise.reject("attribute msgHash already defined")];e=n(n({},e),{msgHash:c.messageHash})}return[4,this.data.setLastOpenMessage(void 0)];case 3:return i.sent(),[4,this.apiClient.postEvent(n(n({},r),{event:t,timestampUTC:a,timestampCurrent:u,attributes:e}))];case 4:return(h=i.sent())&&h.code&&this.eventBus.dispatchEvent("receive-in-app-code",{code:h.code}),[2,h]}}))}))},t.prototype.getInboxMessages=function(){return s(this,arguments,void 0,(function(t){var e,r,s;return void 0===t&&(t=0),i(this,(function(i){switch(i.label){case 0:return[4,this.getRequestParams()];case 1:return e=i.sent(),[4,this.data.getInboxLastRequestCode()];case 2:return r=i.sent(),[4,this.data.getInboxLastRequestTime()];case 3:return s=i.sent(),[2,this.apiClient.getInboxMessages(n(n({},e),{count:t,last_code:r,last_request_time:s}))]}}))}))},t.prototype.inboxStatus=function(t,e){return s(this,void 0,void 0,(function(){var r;return i(this,(function(s){switch(s.label){case 0:return[4,this.getRequestParams()];case 1:return r=s.sent(),[2,this.apiClient.inboxStatus(n(n({},r),{inbox_code:t,status:e,time:(new Date).getTime()}))]}}))}))},t.prototype.triggerEvent=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){throw new Error("Method has been deprecated, because we don't aggregate this statistics.")}))}))},t.prototype.pageVisit=function(t){return s(this,void 0,void 0,(function(){var e,r,s;return i(this,(function(i){switch(i.label){case 0:return[4,this.getRequestParams()];case 1:return e=i.sent(),[4,this.data.getFeatures()];case 2:return r=i.sent(),(s=r&&r.page_visit&&r.page_visit.entrypoint)?[2,this.apiClient.pageVisit(n(n({},e),t),s)]:[2]}}))}))},t.prototype.setPurchase=function(t){return s(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return[4,this.getRequestParams()];case 1:return e=r.sent(),[2,this.apiClient.setPurchase(n(n({},e),t))]}}))}))},t.prototype.getParams=function(){return s(this,void 0,void 0,(function(){var t,e,r,s;return i(this,(function(i){switch(i.label){case 0:return[4,this.data.getApplicationCode()];case 1:return t=i.sent(),[4,this.data.getHwid()];case 2:return e=i.sent(),[4,this.data.getTokens()];case 3:return r=i.sent(),[4,this.data.getInitParams()];case 4:return s=i.sent(),[2,n(n({applicationCode:t,hwid:e},r),s)]}}))}))},Object.defineProperty(t.prototype,"params",{get:function(){throw new Error('Property "Pushwoosh.api.params" have been deprecated. Use the async method "Pushwoosh.api.getParams()"')},enumerable:!1,configurable:!0}),t.prototype.getRequestParams=function(){return s(this,void 0,void 0,(function(){var t,e,n,r,s,o,a,u;return i(this,(function(i){switch(i.label){case 0:return[4,this.data.getApplicationCode()];case 1:return t=i.sent(),[4,this.data.getHwid()];case 2:return e=i.sent(),[4,this.data.getUserId()];case 3:return n=i.sent(),[4,this.data.getDeviceType()];case 4:return r=i.sent(),[4,this.data.getDeviceModel()];case 5:return s=i.sent(),[4,this.data.getLanguage()];case 6:return o=i.sent(),[4,this.data.getSdkVersion()];case 7:return a=i.sent(),u=60*-(new Date).getTimezoneOffset(),[2,{application:t,hwid:e,userId:n||e,device_type:r,device_model:s,timezone:u,language:o,v:a}]}}))}))},t}(),mt=function(){function t(t,e,n){this.api=t,this.data=e,this.config=n}return t.prototype.getPermission=function(){return Notification.permission},t.prototype.checkIsPermissionGranted=function(){return"granted"===this.getPermission()},t.prototype.checkIsPermissionDefault=function(){return"default"===this.getPermission()},t.prototype.checkIsManualUnsubscribed=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.data.getStatusManualUnsubscribed()]}))}))},t.prototype.askPermission=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,Notification.requestPermission()];case 1:return t.sent(),[2]}}))}))},t.prototype.getTokens=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.data.getTokens()]}))}))},t.prototype.subscribe=function(t){return s(this,void 0,void 0,(function(){var e,n,r,s,o,a,u;return i(this,(function(i){switch(i.label){case 0:return(n=t)?[3,2]:[4,this.trySubscribe()];case 1:n=i.sent(),i.label=2;case 2:if(e=n,!this.checkIsPermissionGranted())return tt.error("You must have permission granted before subscribe!"),[2];if(r=this.getPushToken(e),s=e.getKey("p256dh"),o=e.getKey("auth"),!s||!o)throw new Error("Can't get subscription keys!");return a=btoa(String.fromCharCode.apply(String,new Uint8Array(s))),u=btoa(String.fromCharCode.apply(String,new Uint8Array(o))),[4,this.data.setTokens({publicKey:a,pushToken:r,authToken:u,endpoint:e.endpoint})];case 3:return i.sent(),[4,this.api.registerDevice()];case 4:return i.sent(),[2]}}))}))},t.prototype.unsubscribe=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this.getServiceWorkerRegistration()];case 1:return[4,e.sent().pushManager.getSubscription()];case 2:return t=e.sent(),[4,this.data.setTokens({})];case 3:return e.sent(),[4,this.data.setStatusManualUnsubscribed(!0)];case 4:return e.sent(),[4,this.api.unregisterDevice()];case 5:return e.sent(),t?[4,t.unsubscribe()]:[2];case 6:return e.sent(),[2]}}))}))},t.prototype.checkIsRegister=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.api.checkDeviceSubscribeForPushNotifications()]}))}))},t.prototype.checkIsNeedResubscribe=function(){return s(this,void 0,void 0,(function(){var t,e,n,r,s,o,a,u;return i(this,(function(i){switch(i.label){case 0:return[4,this.data.getLastPermissionStatus()];case 1:return t=i.sent(),e=this.getPermission(),t===e?[3,3]:[4,this.data.setLastPermissionStatus(e)];case 2:return i.sent(),[2,!0];case 3:return[4,this.getCredentials()];case 4:return n=i.sent(),r=this.getPushToken(n),[4,this.data.getTokens()];case 5:return s=i.sent(),o=s&&s.pushToken||"",a=r===o,[4,this.data.getIsVapidChanged()];case 6:return u=i.sent(),[2,!a||u]}}))}))},t.prototype.getServiceWorkerRegistration=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return this.registration?[3,5]:[4,this.registerServiceWorker()];case 1:return n.sent(),[4,this.data.getServiceWorkerUrl()];case 2:return t=n.sent(),e=this,[4,navigator.serviceWorker.getRegistration(t)];case 3:return e.registration=n.sent(),[4,this.registration.update()];case 4:n.sent(),n.label=5;case 5:if(!this.registration)throw new Error("Internal Error: Can't register service worker!");return[2,this.registration]}}))}))},t.prototype.registerServiceWorker=function(){return s(this,void 0,void 0,(function(){var t,e,n,r,s;return i(this,(function(i){switch(i.label){case 0:return[4,this.data.getServiceWorkerUrl()];case 1:return t=i.sent(),[4,this.data.getServiceWorkerScope()];case 2:return e=i.sent(),[4,this.data.getSdkVersion()];case 3:return n=i.sent(),[4,this.data.getServiceWorkerVersion()];case 4:return r=i.sent(),s="",n!==r&&(s="?cache_clean=".concat(v())),[4,navigator.serviceWorker.register("".concat(t).concat(s),{scope:e})];case 5:return i.sent(),[2]}}))}))},t.prototype.trySubscribe=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,4]),[4,this.subscribePushManager()];case 1:return[2,e.sent()];case 2:return t=e.sent(),console.error(t),[4,this.unsubscribe()];case 3:return e.sent(),[2,this.subscribePushManager()];case 4:return[2]}}))}))},t.prototype.subscribePushManager=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.getServiceWorkerRegistration()];case 1:return t=n.sent(),[4,this.getApplicationServerKey()];case 2:return e=n.sent(),[2,t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:e?this.urlBase64ToUint8Array(e):null})]}}))}))},t.prototype.getCredentials=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.getServiceWorkerRegistration()];case 1:return[4,t.sent().pushManager.getSubscription()];case 2:return[2,t.sent()]}}))}))},t.prototype.getPushToken=function(t){return t?t.endpoint:""},t.prototype.getApplicationServerKey=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.data.getDeviceType()];case 1:return 11!==t.sent()?[2]:[4,this.data.getApplicationServerKey()];case 2:return[2,t.sent()]}}))}))},t.prototype.urlBase64ToUint8Array=function(t){for(var e=(t+"=".repeat((4-t.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/"),n=atob(e),r=new Uint8Array(n.length),s=0;s<n.length;++s)r[s]=n.charCodeAt(s);return r},t}(),yt=function(){function t(t,e,n){this._listeners={},this.eventBus=t,this.data=e,this.api=n}return t.prototype.push=function(t){Array.isArray(t)&&"onPush"===t[0]&&"function"==typeof t[1]&&(this._listeners[t[0]]||(this._listeners[t[0]]=[]),this._listeners[t[0]].push(t[1]))},t.prototype.getListeners=function(t){return this._listeners[t]||[]},t.prototype.initApi=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,Promise.resolve()]}))}))},t}();const bt=yt;var wt=function(){function t(t,e,n){this._canceled=!1,this.showNotificationOptions=t,this.body=e,this.title=n}return t.prototype.show=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return this._canceled?[2]:(t=this.showNotificationOptions).silent?[3,2]:[4,self.registration.showNotification(this.title,t)];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.cancel=function(){this._canceled=!0},t}();const St=wt;var Et=new m,Mt=new dt,xt=new gt(Et,Mt),Pt=self.Pushwoosh=new bt(Et,Mt,xt),Dt=[];function Ct(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,self.clients.matchAll()];case 1:return e.sent().forEach((function(e){return e.postMessage(t)})),[2]}}))}))}function Tt(t){return s(this,void 0,void 0,(function(){var e,n,r,s,o,a;return i(this,(function(i){return e=t.notification,r=(n=void 0===e?{}:e).data,s=b(n.tag,{}),o="",t.action&&Array.isArray(r.buttons)?(a=r.buttons.find((function(e){return e.action===t.action}))||{},o=a.url):o=s.url,[2,{title:n.title,body:n.body,icon:n.icon,buttons:r.buttons,image:r.image,code:r.code,campaignCode:r.campaignCode,inboxId:r.inboxId,messageHash:s.messageHash,customData:s.customData,metaData:s.metaData,openUrl:s.url,tag:n.tag,url:o}]}))}))}function It(t){return s(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return[4,Pt.data.getApplicationCode()];case 1:return e=r.sent(),[4,Pt.data.getServiceWorkerVersion()];case 2:return n=r.sent(),[4,k({message:"Error in onInstallEventHandler",code:"FATAL-SW-001",error:t,applicationCode:e,workerVersion:n})];case 3:return r.sent(),[2]}}))}))}function kt(t){return s(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return[4,Pt.data.getApplicationCode()];case 1:return e=r.sent(),[4,Pt.data.getServiceWorkerVersion()];case 2:return n=r.sent(),[4,k({message:"Error in onActivateEventHandler",code:"FATAL-SW-002",error:t,applicationCode:e,workerVersion:n})];case 3:return r.sent(),[2]}}))}))}function At(t){return s(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return[4,Pt.data.getApplicationCode()];case 1:return e=r.sent(),[4,Pt.data.getServiceWorkerVersion()];case 2:return n=r.sent(),[4,k({message:"Error in onNotificationClickEventHandler",code:"FATAL-SW-004",error:t,applicationCode:e,workerVersion:n})];case 3:return r.sent(),[2]}}))}))}function Ot(t){return s(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return[4,Pt.data.getApplicationCode()];case 1:return e=r.sent(),[4,Pt.data.getServiceWorkerVersion()];case 2:return n=r.sent(),[4,k({message:"Error in onNotificationCloseEventHandler",code:"FATAL-SW-005",error:t,applicationCode:e,workerVersion:n})];case 3:return r.sent(),[2]}}))}))}function Rt(t){return s(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return[4,Pt.data.getApplicationCode()];case 1:return e=r.sent(),[4,Pt.data.getServiceWorkerVersion()];case 2:return n=r.sent(),[4,k({message:"Error in onPushSubscriptionChange",code:"FATAL-SW-006",error:t,applicationCode:e,workerVersion:n})];case 3:return r.sent(),[2]}}))}))}return self.addEventListener("install",(function(t){return t.waitUntil(function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,Promise.all([Pt.data.setServiceWorkerVersion("3.39.6"),tt.write("info","install")])];case 1:return t.sent(),[4,self.skipWaiting()];case 2:return t.sent(),[2]}}))}))}().catch(It))})),self.addEventListener("activate",(function(t){t.waitUntil(function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,Promise.all([tt.write("info","activate")])];case 1:return t.sent(),[4,self.clients.claim()];case 2:return t.sent(),[2]}}))}))}().catch(kt))})),self.addEventListener("push",(function(t){t.waitUntil(function(t){return s(this,void 0,void 0,(function(){var e,n,r,s,o,a,u,c,h,p,d,l,f;return i(this,(function(i){switch(i.label){case 0:return[4,self.clients.claim()];case 1:return i.sent(),[4,t.data.json()];case 2:return e=i.sent(),[4,(n=new ft(e)).getNotificationOptionsPayload()];case 3:return r=i.sent(),[4,n.getShowNotificationOptions()];case 4:return s=i.sent(),o=n.messageHash,[4,tt.write("info",JSON.stringify(r),"onPush")];case 5:return i.sent(),u=St.bind,c=[void 0,s,n.body],[4,n.getTitle()];case 6:return a=new(u.apply(St,c.concat([i.sent()]))),[4,Pt.getListeners("onPush").reduce((function(t,e){return t.then((function(){return e(a)}))}),Promise.resolve())];case 7:return i.sent(),h=[a.show(),Q.add({payload:e,parsedPayload:r,showOptions:s}),Ct({type:"onPushDelivery",payload:r})],o&&h.push(Pt.initApi().then((function(){return Pt.api.messageDeliveryEvent(o,!0,r.metaData)}))),""===n.inboxId?[3,10]:(p=new ut(Pt.eventBus,Pt.data,Pt.api),d=new nt(Pt.data,Pt.api,p),[4,n.getInboxMessage()]);case 8:return l=i.sent(),[4,d.publicMessageBuilder(l)];case 9:f=i.sent(),h.push(p.putMessage(l),Ct({type:"onPutNewMessageToInboxStore",payload:f})),i.label=10;case 10:return[4,Promise.all(h)];case 11:return i.sent(),[2]}}))}))}(t).catch((function(e){return function(t,e){return s(this,void 0,void 0,(function(){var n,r;return i(this,(function(s){switch(s.label){case 0:return[4,Pt.data.getApplicationCode()];case 1:return n=s.sent(),[4,Pt.data.getServiceWorkerVersion()];case 2:return r=s.sent(),[4,k({message:"Error in onPushEventHandler",code:"FATAL-SW-003",error:t,applicationCode:n,workerVersion:r})];case 3:return s.sent(),t instanceof Error||(t=new Error(t)),[2,Q.add({error:"".concat(t),stack:t.stack,payload:e.data&&e.data.text()})]}}))}))}(e,t)})))})),self.addEventListener("notificationclick",(function(t){t.waitUntil(function(t){return s(this,void 0,void 0,(function(){var e,n,r,o,a,u,c,h,p;return i(this,(function(d){switch(d.label){case 0:return[4,self.clients.claim()];case 1:return d.sent(),[4,Tt(t)];case 2:return e=d.sent(),n=e.messageHash,r=e.metaData,o=e.url,a=e.code,u=e.inboxId,a&&Dt.push(a),""===u?[3,5]:[4,(c=new ut(Pt.eventBus,Pt.data,Pt.api)).getMessage(u)];case 3:return(h=d.sent()).status=3,[4,c.putMessage(h)];case 4:d.sent(),d.label=5;case 5:return t.notification.close(),p={type:"onNotificationClick",payload:e},o&&t.waitUntil(self.clients.matchAll({type:"window"}).then((function(t){return function(t,e){return s(this,void 0,void 0,(function(){var n,r,s,o;return i(this,(function(i){switch(i.label){case 0:return n=new URL(e,self.location.origin),r=n.hostname,s=n.pathname,o=t.find((function(t){var e=new URL(t.url),n=e.hostname,i=e.pathname;return n===r&&i===s})),o?[4,o.focus()]:[3,2];case 1:return i.sent(),[2,!1];case 2:return[4,self.clients.openWindow(e).then((function(t){t&&t.focus()}))];case 3:return i.sent(),[2,!0]}}))}))}(t,o)})).then((function(t){t&&Pt.data.setDelayedEvent(p)}))),[2,Promise.all([Pt.initApi().then((function(){return Pt.api.pushStat(n,!0,r)})),Pt.data.setLastOpenMessage({url:o,messageHash:n,expiry:Date.now()+864e5}),Ct(p)])]}}))}))}(t).catch(At))})),self.addEventListener("notificationclose",(function(t){t.waitUntil(function(t){return s(this,void 0,void 0,(function(){var e,n,r;return i(this,(function(s){switch(s.label){case 0:return[4,self.clients.claim()];case 1:return s.sent(),[4,Tt(t)];case 2:return e=s.sent(),n=e.code,t.notification.close(),n?(r=Dt.indexOf(n))>=0?(Dt.splice(r,1),[2]):[2,Ct({type:"onNotificationClose",payload:e})]:[2]}}))}))}(t).catch(Ot))})),self.addEventListener("pushsubscriptionchange",(function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){return t.waitUntil(function(t){return s(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return(e=t.newSubscription)?[3,2]:[4,self.registration.pushManager.getSubscription()];case 1:if(!(e=n.sent()))return[2];n.label=2;case 2:return[4,new mt(xt,Mt,{}).subscribe(e)];case 3:return n.sent(),[2]}}))}))}(t).catch(Rt)),[2]}))}))})),{}})()));
1
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(this,(()=>(()=>{"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var s in e=arguments[n])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t},n.apply(this,arguments)};function r(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]])}return n}function s(t,e,n,r){return new(n||(n=Promise))((function(s,i){function o(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}u((r=r.apply(t,e||[])).next())}))}function i(t,e){var n,r,s,i={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(s=2&a[0]?r.return:a[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,a[1])).done)return s;switch(r=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(s=i.trys,(s=s.length>0&&s[s.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){i.label=a[1];break}if(6===a[0]&&i.label<s[1]){i.label=s[1],s=a;break}if(s&&i.label<s[2]){i.label=s[2],i.ops.push(a);break}s[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],r=0}finally{n=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}Object.create;function o(t,e,n){if(n||2===arguments.length)for(var r,s=0,i=e.length;s<i;s++)!r&&s in e||(r||(r=Array.prototype.slice.call(e,0,s)),r[s]=e[s]);return t.concat(r||Array.prototype.slice.call(e))}Object.create;"function"==typeof SuppressedError&&SuppressedError;var a="deviceRegistrationStatus",u="registered",c="unregistered";const h={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let p;const d=new Uint8Array(16);const l=[];for(let t=0;t<256;++t)l.push((t+256).toString(16).slice(1));function f(t,e=0){return(l[t[e+0]]+l[t[e+1]]+l[t[e+2]]+l[t[e+3]]+"-"+l[t[e+4]]+l[t[e+5]]+"-"+l[t[e+6]]+l[t[e+7]]+"-"+l[t[e+8]]+l[t[e+9]]+"-"+l[t[e+10]]+l[t[e+11]]+l[t[e+12]]+l[t[e+13]]+l[t[e+14]]+l[t[e+15]]).toLowerCase()}const v=function(t,e,n){if(h.randomUUID&&!e&&!t)return h.randomUUID();const r=(t=t||{}).random??t.rng?.()??function(){if(!p){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");p=crypto.getRandomValues.bind(crypto)}return p(d)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){if((n=n||0)<0||n+16>e.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let t=0;t<16;++t)e[n+t]=r[t];return e}return f(r)};var g,m=function(){var t=this;this.addEventHandler=function(e,n){var r=t.savedEventHandlersMap[e];r||(r=[]),r.push(n),t.savedEventHandlersMap[e]=r},this.removeEventHandler=function(e,n){var r=t.savedEventHandlersMap[e];r&&(t.savedEventHandlersMap[e]=r.filter((function(t){return t!==n})))},this.dispatchEvent=function(e,r){var s=r.eventId||v(),i=t.savedEventHandlersMap[e];return i?(i.forEach((function(t){"function"==typeof t&&setTimeout((function(){t(n(n({},r),{eventId:s}))}),0)})),s):s},this.savedEventHandlersMap={}};function y(){return globalThis}function b(t,e){if("string"==typeof t)try{return JSON.parse(t)}catch(t){console.log(t)}return void 0===t&&void 0!==e?e:t}var w="silent",S="fatal",E="error",M="warn",x="info",P="debug",D=((g={})[w]=0,g[S]=10,g[E]=20,g[M]=30,g[x]=40,g[P]=50,g),C=function(){function t(t){this.relations=D,this.level=t&&void 0!==t.level?t.level:E,this.applicationType=t&&void 0!==t.applicationType?t.applicationType:"sdk",this.subscribers=t&&void 0!==t.subscribers?t.subscribers:[]}return t.prototype.updateLogLevel=function(t){this.level=t},t.prototype.updateApplicationType=function(t){this.applicationType=t},t.prototype.updateApplicationCode=function(t){this.applicationCode=t},t.prototype.updateDomain=function(t){this.domain=t},t.prototype.updateDeviceInfo=function(t){this.deviceInfo=t},t.prototype.subscribe=function(t,e){this.subscribers.push({handler:e,level:t})},t.prototype.log=function(t){return s(this,void 0,void 0,(function(){var e,s,o,a,u,c,h=this;return i(this,(function(i){switch(i.label){case 0:return e=[],s=t.options,o=r(t,["options"]),a=o,s&&(s.handler,u=r(s,["handler"]),a=n(n({},o),u)),c=this.getMessage(a),this.subscribers.forEach((function(n){n.level===t.type&&h.relations[n.level]<=h.relations[h.level]&&e.push(n.handler.call(null,c))})),s&&s.handler&&this.level!==w&&s.handler.call(null,c),[4,Promise.all(e)];case 1:return i.sent(),[2]}}))}))},t.prototype.debug=function(t,e){return s(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.log({type:P,text:t,options:e})]}))}))},t.prototype.info=function(t,e){return s(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.log({type:x,text:t,options:e})]}))}))},t.prototype.warn=function(t,e,n){return s(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.log({type:M,text:t,code:e,options:n})]}))}))},t.prototype.error=function(t,e,n){return s(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.log({type:E,text:t,code:e,options:n})]}))}))},t.prototype.fatal=function(t,e,n){return s(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.log({type:S,text:t,code:e,options:n})]}))}))},t.prototype.errorAndThrow=function(t,e,n){return s(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.logAndThrow({type:E,text:t,code:e,options:n})]}))}))},t.prototype.errorAndReject=function(t,e,n,r){return s(this,void 0,void 0,(function(){return i(this,(function(s){return[2,this.logAndReject(t,{type:E,text:e,code:n,options:r})]}))}))},t.prototype.fatalAndThrow=function(t,e,n){return s(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.logAndThrow({type:S,text:t,code:e,options:n})]}))}))},t.prototype.fatalAndReject=function(t,e,n,r){return s(this,void 0,void 0,(function(){return i(this,(function(s){return[2,this.logAndReject(t,{type:S,text:e,code:n,options:r})]}))}))},t.prototype.logAndThrow=function(t){return s(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this.log(t)];case 1:throw n.sent(),e=new Error(t.text),t.code&&(e.code=t.code),e}}))}))},t.prototype.logAndReject=function(t,e){return s(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.log(e)];case 1:return r.sent(),n=new Error(e.text),e.code&&(n.code=e.code),t(n),[2]}}))}))},t.prototype.getMessage=function(t){return n({applicationCode:this.applicationCode,domain:this.domain,applicationType:this.applicationType,deviceInfo:this.deviceInfo},t)},t}();function T(t){var e=t.code,n=t.text,r=t.type,s=function(t){switch(t){case"fatal":case"error":return console.error;case"warn":case"info":case"debug":return console.log}}(r);console.groupCollapsed(r),s(e?"".concat(e,": ").concat(n):n),console.groupEnd()}var I=new C({level:"error",subscribers:[{level:"fatal",handler:T},{level:"error",handler:T}]});function k(t){return s(this,void 0,void 0,(function(){var e;return i(this,(function(n){return e=A(t),[2,I.fatal(e.text,e.code,e.options)]}))}))}function A(t){var e=t.message,s=t.code,i=t.error,o=r(t,["message","code","error"]),a=function(t){var e=new Error("unknown error");"string"!=typeof t&&"number"!=typeof t&&"boolean"!=typeof t||(e.message=t.toString());t instanceof Error&&(e=t);return e}(i);return{text:e,code:s,options:n(n({},o),{errorText:a.message,errorStack:a.stack})}}var O="keyValue",R="messages",_="log",N="inboxMessages";function U(t,e){return function(n){n.objectStoreNames.contains(t)||e(n)}}const q=[U(N,(function(t){var e="status",n=t.createObjectStore(N,{keyPath:"inbox_id",autoIncrement:!1});n.createIndex(e,e,{unique:!1,multiEntry:!0}),n.createIndex("rt","rt",{unique:!1,multiEntry:!0})}))];const W=[U(O,(function(t){t.createObjectStore(O,{keyPath:"key"})})),U(_,(function(t){var e=t.createObjectStore(_,{keyPath:"id",autoIncrement:!0});e.createIndex("environment","environment",{unique:!1}),e.createIndex("date","date",{unique:!1}),e.createIndex("type","type",{unique:!1})})),U(R,(function(t){t.createObjectStore(R,{keyPath:"id",autoIncrement:!0}).createIndex("date","date",{unique:!1})}))];const L=function(){function t(t){void 0===t&&(t=new Date),this._date=t}return Object.defineProperty(t.prototype,"date",{get:function(){return this._date},set:function(t){this._date=t},enumerable:!1,configurable:!0}),t.prototype.getUtcTimestamp=function(){return Math.floor((this.date.getTime()+60*this.date.getTimezoneOffset()*1e3)/1e3)},t.prototype.getTimestamp=function(){return Math.round(this.date.getTime()/1e3)},t.prototype.setLocal=function(){var t=this._date.getTime()-60*this.date.getTimezoneOffset()*1e3;this._date=new Date(t)},t.prototype.addDays=function(t){var e=this._date.getTime()+24*t*60*60*1e3;this._date=new Date(e)},t.prototype.getInboxFakeOrder=function(){return(100*this._date.getTime()+9e9).toString()},t}();const j=function(){function t(t){void 0===t&&(t=new L),this.migrations={initial:W,"2018/11/26":q},this.dateModule=t}return Object.defineProperty(t.prototype,"initial",{get:function(){return this.migrations.initial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dateSorted",{get:function(){var t=this;return Object.keys(this.migrations).filter((function(t){return"initial"!==t})).sort((function(t,e){var n=new L(new Date(t)),r=new L(new Date(e));return n.getTimestamp()-r.getTimestamp()})).map((function(e){return t.migrations[e]}))},enumerable:!1,configurable:!0}),t}();const V=function(){function t(t,e){void 0===e&&(e=new j),this.db=t,this.migrationsBuilder=e}return t.prototype.applyMigrations=function(){var t=this;this.applyMigrationsPack(this.migrationsBuilder.initial),this.migrationsBuilder.dateSorted.forEach((function(e){t.applyMigrationsPack(e)}))},t.prototype.applyMigrationsPack=function(t){var e=this;t.forEach((function(t){t(e.db)}))},t}();function B(t,e){console.info("onversionchange",e),t.close()}var H;function F(t){return(H||(H=new Promise((function(t,e){var n=indexedDB.open("PUSHWOOSH_SDK_STORE",7);n.onsuccess=function(n){var r=n.target.result;r.onversionchange=B.bind(null,r,e),t(r)},n.onerror=function(){return e(n.error)},n.onupgradeneeded=function(t){var n=t.target.result;n.onversionchange=B.bind(null,n,e),new V(n).applyMigrations()}}))),H).then((function(e){return new Promise((function(n,r){return t(e,n,r)}))}))}var K,z=function(){function t(){}return t.prototype._add=function(t){var e=this;return F((function(n,r,s){var i=n.transaction([e.name],"readwrite").objectStore(e.name).add(t);i.onsuccess=function(){r(t)},i.onerror=function(){s(i.error)}})).then((function(t){return e.getAll().then((function(n){if(Array.isArray(n)){var r=n.map((function(t){return t.id})).sort((function(t,e){return t==e?0:t<e?1:-1}));if(r.length>e.maxItems)return Promise.all(r.slice(e.maxItems).map((function(t){return e.delete(t)}))).then((function(){return t}))}return t}))}))},t.prototype.delete=function(t){var e=this;return F((function(n,r,s){var i=n.transaction([e.name],"readwrite").objectStore(e.name).delete(t);i.onsuccess=function(){r(i.result)},i.onerror=function(){s(i.error)}}))},t.prototype.getAll=function(){var t=this;return F((function(e,n,r){var s=[],i=e.transaction(t.name).objectStore(t.name).openCursor();i.onsuccess=function(t){var e=t.target.result;e?(e.value&&s.push(e.value),e.continue()):n(s)},i.onerror=function(){r(i.error)}}))},t}(),J=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name=_,e.maxItems=100,e.environment="undefined"!=typeof self&&self.registration?"worker":"browser",e}return e(n,t),n.prototype.add=function(t,e,n){var r={type:t,environment:this.environment,message:"".concat(e),date:new Date};return e instanceof Error&&(r.stack=e.stack),n&&(r.additional=n),this._add(r)},n}(z),G=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.name=R,e.maxItems=25,e}return e(r,t),r.prototype.add=function(t){return this._add(n(n({},t),{date:new Date}))},r}(z),Y=(K=O,{get:function(t,e){return F((function(n,r,s){var i,o=n.transaction(K).objectStore(K).get(t),a=!1,u=!1,c=function(){if(clearTimeout(i),a){var t=o.result;r(t&&t.value||e)}else u?s(o.error):i=setTimeout(c,0)};o.onsuccess=function(){return a=!0},o.onerror=function(){return u=!0},c()}))},getAll:function(){return F((function(t,e,n){var r,s={},i=t.transaction(K).objectStore(K).openCursor(),o=!1,a=!1,u=function(){clearTimeout(r),o?e(s):a?n(i.error):r=setTimeout(u,0)};i.onsuccess=function(t){var e=t.target.result;e?(s[e.key]=e.value.value,e.continue()):o=!0},i.onerror=function(){return a=!0},u()}))},extend:function(t,e){return s(this,void 0,void 0,(function(){var s,o;return i(this,(function(i){switch(i.label){case 0:return[4,this.get(t)];case 1:return s=i.sent(),o=r(e,[]),[4,this.set(t,n(n({},s),o))];case 2:return i.sent(),[2]}}))}))},set:function(t,e){return F((function(n,r,s){var i,o=n.transaction([K],"readwrite").objectStore(K).put({key:t,value:e}),a=!1,u=!1,c=function(){clearTimeout(i),a?r(t):u?s(o.error):i=setTimeout(c,0)};o.onsuccess=function(){return a=!0},o.onerror=function(){return u=!0},c()}))}}),$=new J,Q=new G,X={error:1,info:2,debug:3},Z=3;!function(){for(var t,e=function(){},n=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],r=n.length,s=y(),i=s.console=s.console||{};r--;)i[t=n[r]]||(i[t]=e)}();var tt={setLevel:function(t){X[t]||(t="error"),Z=X[t]},write:function(t,e,n){return"error"===t?this.error(e):this.info(e),$.add(t,e,n)}};Object.keys(X).forEach((function(t){var e=X[t];tt[t]=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];e<=Z&&(console.groupCollapsed(t),console.info.apply(console,o([""],n,!1)),console.trace("trace"),console.groupEnd())}}));var et=function(){function t(t,e,n,r){void 0===r&&(r=new L),this.data=t,this.api=e,this.inboxModel=n,this.dateModule=r,this.publicMessageBuilder=this.publicMessageBuilder.bind(this)}return t.prototype.messageTypeFactory=function(t,e){var n=0;return 2===t?n=1:"l"in e&&null!=e.l&&(n=e.l.startsWith("http")?2:3),n},t.prototype.updateMessagesStatusWithCodes=function(t,e,n){return s(this,void 0,void 0,(function(){var r,o,a=this;return i(this,(function(u){switch(u.label){case 0:return r=[],o=[],e.forEach((function(e){return s(a,void 0,void 0,(function(){return i(this,(function(s){return-1===t.indexOf(e.inbox_id)||(e.status=n,r.push(e),o.push(this.api.inboxStatus(e.order,e.status))),[2]}))}))})),[4,this.inboxModel.putBulkMessages(r)];case 1:return u.sent(),[4,Promise.all(o)];case 2:return u.sent(),[2]}}))}))},t.prototype.publicMessageBuilder=function(t){return s(this,arguments,void 0,(function(t){var e,n,r,s,o,a=t.action_type,u=t.action_params,c=t.image,h=t.title,p=t.send_date,d=t.inbox_id,l=t.text,f=t.status;return i(this,(function(t){switch(t.label){case 0:return(n=c)?[3,2]:[4,this.data.getDefaultNotificationImage()];case 1:n=t.sent(),t.label=2;case 2:return e=n,(s=h)?[3,4]:[4,this.data.getDefaultNotificationTitle()];case 3:s=t.sent(),t.label=4;case 4:return r=s,o=JSON.parse(u),this.dateModule.date=new Date(1e3*parseInt(p)),this.dateModule.setLocal(),[2,{title:r,imageUrl:e,code:d,message:l,sendDate:this.dateModule.date.toISOString(),type:this.messageTypeFactory(a,o),link:(null==o?void 0:o.l)||"/",isRead:2===f||3===f,isActionPerformed:3===f}]}}))}))},t.prototype.messagesWithNoActionPerformedCount=function(){return this.inboxModel.getDeliveredReadMessagesCount()},t.prototype.unreadMessagesCount=function(){return this.inboxModel.getDeliveredMessagesCount()},t.prototype.messagesCount=function(){return this.inboxModel.messagesCount()},t.prototype.loadMessages=function(){return s(this,void 0,void 0,(function(){var t,e,n;return i(this,(function(r){switch(r.label){case 0:return[4,this.inboxModel.getReadOpenMessages()];case 1:return t=r.sent(),[4,this.inboxModel.getDeliveredMessages()];case 2:return e=r.sent(),n=o(o([],t,!0),e,!0).sort((function(t,e){return parseInt(e.send_date,10)-parseInt(t.send_date,10)})).sort((function(t,e){return parseInt(e.order||"0",10)-parseInt(t.order||"0",10)})).map(this.publicMessageBuilder),[2,Promise.all(n)]}}))}))},t.prototype.readMessagesWithCodes=function(t){return s(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this.inboxModel.getDeliveredMessages()];case 1:return e=n.sent(),[4,this.updateMessagesStatusWithCodes(t,e,2)];case 2:return n.sent(),[2]}}))}))},t.prototype.performActionForMessageWithCode=function(t){return s(this,void 0,void 0,(function(){var e,n,r;return i(this,(function(s){switch(s.label){case 0:return[4,this.inboxModel.getMessage(t)];case 1:return e=s.sent(),n=JSON.parse(e.action_params),2===(r=this.messageTypeFactory(e.action_type,n))&&null!=n.l?document.location.href=n.l:3===r&&null!=n.l&&window.history.go(n.l),e.status=3,[4,this.inboxModel.putMessage(e)];case 2:return s.sent(),[4,this.api.inboxStatus(e.order,e.status)];case 3:return s.sent(),[2]}}))}))},t.prototype.deleteMessagesWithCodes=function(t){return s(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return[4,this.inboxModel.getReadOpenMessages()];case 1:return e=r.sent(),[4,this.inboxModel.getDeliveredMessages()];case 2:return n=r.sent(),[4,this.updateMessagesStatusWithCodes(t,o(o([],e,!0),n,!0),4)];case 3:return r.sent(),[2]}}))}))},t.prototype.syncMessages=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.inboxModel.updateMessages()];case 1:return t.sent(),[2]}}))}))},t}();const nt=et;var rt=function(){function t(t,e){this.name=e,this.store=t.transaction(this.name,"readwrite").objectStore(this.name)}return Object.defineProperty(t.prototype,"index",{set:function(t){this.store.indexNames.contains(t)?this._index=this.store.index(t):console.warn('Index "'.concat(t,'" in '))},enumerable:!1,configurable:!0}),t.prototype.writeRequestPromise=function(t,e){return new Promise((function(n,r){t.onsuccess=function(){n(e)},t.onerror=function(){r(t.error)}}))},t.prototype.readRequestPromise=function(t,e){return new Promise((function(n,r){t.onsuccess=function(t){var r=t.target;n(r.result||e)},t.onerror=function(){r(t.error)}}))},t.prototype.put=function(t,e){var n=this.store.put(t,e);return this.writeRequestPromise(n,e)},t.prototype.add=function(t,e){return this.put(t,e)},t.prototype.delete=function(t){var e=this.store.delete(t);return this.writeRequestPromise(e)},t.prototype.get=function(t,e){var n=this.store.get(t);return this.readRequestPromise(n,e)},t.prototype.getAll=function(){var t=this.store.openCursor(),e=[];return new Promise((function(n,r){t.onsuccess=function(t){var r=t.target.result;r?(e.push(r.value),r.continue()):n(e)},t.onerror=function(){r(t.error)}}))},t.prototype.count=function(t){var e=this.store.count(t);return this.readRequestPromise(e,0)},t.prototype.countByIndex=function(t){var e=this._index.count(t);return this.readRequestPromise(e,0)},t}();const st=rt;var it=function(){function t(){}return t.prototype.dbVersionChangeHandler=function(t,e){console.info("onversionchange",e),t.close()},t.prototype.dbRequestSuccessHandler=function(t,e){var n=this,r=e.target.result;r.onversionchange=function(t){n.dbVersionChangeHandler(r,t)},t(r)},t.prototype.dbRequestUpgradeNeededHandler=function(t){var e=this,n=t.target.result;n.onversionchange=function(t){e.dbVersionChangeHandler(n,t)},new V(n).applyMigrations()},t.prototype.getDB=function(){var t=this;return new Promise((function(e,n){var r=indexedDB.open("PUSHWOOSH_SDK_STORE",7);r.onsuccess=function(n){t.dbRequestSuccessHandler(e,n)},r.onupgradeneeded=function(e){t.dbRequestUpgradeNeededHandler(e)},r.onerror=function(){return n(r.error)}}))},t.prototype.put=function(t,e,n){return s(this,void 0,void 0,(function(){var r,s;return i(this,(function(i){switch(i.label){case 0:return[4,this.getDB()];case 1:return r=i.sent(),[4,new st(r,t).put(e,n)];case 2:return s=i.sent(),r.close(),[2,s]}}))}))},t.prototype.delete=function(t,e){return s(this,void 0,void 0,(function(){var n,r;return i(this,(function(s){switch(s.label){case 0:return[4,this.getDB()];case 1:return n=s.sent(),[4,new st(n,t).delete(e)];case 2:return r=s.sent(),n.close(),[2,r]}}))}))},t.prototype.get=function(t,e,n){return s(this,void 0,void 0,(function(){var r,s;return i(this,(function(i){switch(i.label){case 0:return[4,this.getDB()];case 1:return r=i.sent(),[4,new st(r,t).get(e,n)];case 2:return s=i.sent(),r.close(),[2,s]}}))}))},t.prototype.getAll=function(t){return s(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getDB()];case 1:return e=r.sent(),[4,new st(e,t).getAll()];case 2:return n=r.sent(),e.close(),[2,n||[]]}}))}))},t.prototype.count=function(t,e){return s(this,void 0,void 0,(function(){var n,r;return i(this,(function(s){switch(s.label){case 0:return[4,this.getDB()];case 1:return n=s.sent(),[4,new st(n,t).count(e)];case 2:return r=s.sent(),n.close(),[2,r]}}))}))},t.prototype.countByIndex=function(t,e,n){return s(this,void 0,void 0,(function(){var r,s,o;return i(this,(function(i){switch(i.label){case 0:return[4,this.getDB()];case 1:return r=i.sent(),(s=new st(r,t)).index=e,[4,s.countByIndex(n)];case 2:return o=i.sent(),r.close(),[2,o]}}))}))},t}();const ot=it;var at=function(){function t(t,e,n,r,s){void 0===r&&(r=new ot),void 0===s&&(s=new L),this.eventBus=t,this.data=e,this.api=n,this.storage=r,this.storeName="inboxMessages",this.dateModule=s}return t.prototype.getInboxMessages=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this.api.getInboxMessages()];case 1:return t=e.sent(),[4,this.storeGetInboxMessagesRequestParams(t.next,t.new_inbox)];case 2:return e.sent(),[2,t]}}))}))},t.prototype.storeGetInboxMessagesRequestParams=function(t,e){return s(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return this.dateModule.date=new Date,[4,this.data.setInboxLastRequestTime(this.dateModule.getUtcTimestamp())];case 1:return n.sent(),[4,this.data.setInboxLastRequestCode(t)];case 2:return n.sent(),[4,this.data.setInboxNewMessagesCount(e)];case 3:return n.sent(),[2]}}))}))},t.prototype.putServerMessages=function(t){return s(this,void 0,void 0,(function(){var e,n=this;return i(this,(function(r){return e=t.map((function(t){return s(n,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this.storage.get(this.storeName,t.inbox_id,{})];case 1:return"status"in(e=n.sent())&&(t.status=e.status),[2,this.putMessage(t)]}}))}))})),[2,Promise.all(e)]}))}))},t.prototype.putMessage=function(t){return this.storage.put(this.storeName,t)},t.prototype.putBulkMessages=function(t){var e=this,n=t.map((function(t){return e.putMessage(t)}));return Promise.all(n)},t.prototype.deleteMessages=function(t){var e=this,n=t.map((function(t){return e.storage.delete(e.storeName,t)}));return Promise.all(n)},t.prototype.deleteExpiredMessages=function(){return s(this,void 0,void 0,(function(){var t,e,n;return i(this,(function(r){switch(r.label){case 0:return this.dateModule.date=new Date,t=this.dateModule.getTimestamp().toString(),[4,this.storage.getAll(this.storeName)];case 1:return e=r.sent(),n=e.filter((function(e){return e.rt<t})).map((function(t){return t.inbox_id})),[2,this.deleteMessages(n)]}}))}))},t.prototype.getMessage=function(t){return this.storage.get(this.storeName,t)},t.prototype.getReadOpenMessages=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.storage.getAll(this.storeName)];case 1:return[2,t.sent().filter((function(t){return 2===t.status||3===t.status}))]}}))}))},t.prototype.getDeliveredMessages=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.storage.getAll(this.storeName)];case 1:return[2,t.sent().filter((function(t){return 1===t.status}))]}}))}))},t.prototype.messagesCount=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.storage.count(this.storeName)]}))}))},t.prototype.getDeliveredMessagesCount=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.storage.countByIndex(this.storeName,"status",1)]}))}))},t.prototype.getReadMessagesCount=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.storage.countByIndex(this.storeName,"status",2)]}))}))},t.prototype.getDeliveredReadMessagesCount=function(){return s(this,void 0,void 0,(function(){var t,e,n,r;return i(this,(function(s){return e=(t=[2,3])[0],n=t[1],r=IDBKeyRange.bound(e,n),[2,this.storage.countByIndex(this.storeName,"status",r)]}))}))},t.prototype.updateMessages=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this.getInboxMessages()];case 1:return t=e.sent(),[4,this.deleteExpiredMessages()];case 2:return e.sent(),t.deleted?[4,this.deleteMessages(t.deleted)]:[3,4];case 3:e.sent(),e.label=4;case 4:return[4,this.putServerMessages(t.messages)];case 5:return e.sent(),this.eventBus.dispatchEvent("update-inbox-messages",{messages:new nt(this.data,this.api,this)}),[2]}}))}))},t}();const ut=at;var ct={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},ht=/&(?:amp|lt|gt|quot|#39);/g,pt=RegExp(ht.source);var dt=function(){function t(t){void 0===t&&(t=Y),this.store=t}return t.prototype.clearAll=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.set("params.applicationCode",void 0)];case 1:return t.sent(),[4,this.store.set("params.hwid",void 0)];case 2:return t.sent(),[4,this.store.set("params.deviceType",void 0)];case 3:return t.sent(),[4,this.store.set("params.deviceModel",void 0)];case 4:return t.sent(),[4,this.store.set("params.language",void 0)];case 5:return t.sent(),[4,this.store.set("params.apiEntrypoint",void 0)];case 6:return t.sent(),[4,this.store.set("params.tokens",void 0)];case 7:return t.sent(),[4,this.store.set("params.applicationServerKey",void 0)];case 8:return t.sent(),[4,this.store.set("params.senderId",void 0)];case 9:return t.sent(),[4,this.store.set("params.webSitePushId",void 0)];case 10:return t.sent(),[4,this.store.set("params.defaultNotificationImage",void 0)];case 11:return t.sent(),[4,this.store.set("params.defaultNotificationTitle",void 0)];case 12:return t.sent(),[4,this.store.set("params.userId",void 0)];case 13:return t.sent(),[4,this.store.set("params.email",void 0)];case 14:return t.sent(),[4,this.store.set("params.userIdWasChanged",void 0)];case 15:return t.sent(),[4,this.store.set("params.isLastPermissionStatus",void 0)];case 16:return t.sent(),[4,this.store.set("params.isManualUnsubscribed",void 0)];case 17:return t.sent(),[4,this.store.set("params.isCommunicationDisabled",void 0)];case 18:return t.sent(),[4,this.store.set("params.isDropAllData",void 0)];case 19:return t.sent(),[4,this.store.set("params.sdkVersion",void 0)];case 20:return t.sent(),[4,this.store.set("params.serviceWorkerVersion",void 0)];case 21:return t.sent(),[4,this.store.set("params.serviceWorkerUrl",void 0)];case 22:return t.sent(),[4,this.store.set("params.serviceWorkerScope",void 0)];case 23:return t.sent(),[4,this.store.set("params.lastOpenMessage",void 0)];case 24:return t.sent(),[4,this.store.set("params.lastOpenApplicationTime",void 0)];case 25:return t.sent(),[4,this.store.set("params.features",void 0)];case 26:return t.sent(),[4,this.store.set("params.init",void 0)];case 27:return t.sent(),[4,this.store.set("API_PARAMS",void 0)];case 28:return t.sent(),[4,this.store.set("SENDER_ID",void 0)];case 29:return t.sent(),[4,this.store.set("COMMUNICATION_ENABLED",void 0)];case 30:return t.sent(),[4,this.store.set("DEVICE_DATA_REMOVED",void 0)];case 31:return t.sent(),[4,this.store.set("LAST_OPEN_MESSAGE",void 0)];case 32:return t.sent(),[4,this.store.set("DELAYED_EVENT",void 0)];case 33:return t.sent(),[2]}}))}))},t.prototype.setApplicationCode=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.applicationCode",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getApplicationCode=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.applicationCode")];case 1:return[2,t.sent()]}}))}))},t.prototype.setApiToken=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.apiToken",t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getApiToken=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.apiToken")];case 1:return[2,t.sent()]}}))}))},t.prototype.setHwid=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.hwid",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getHwid=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.hwid")];case 1:return[2,t.sent()]}}))}))},t.prototype.setDeviceType=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.deviceType",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getDeviceType=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.deviceType")];case 1:return[2,t.sent()]}}))}))},t.prototype.setDeviceModel=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.deviceModel",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getDeviceModel=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.deviceModel")];case 1:return[2,t.sent()]}}))}))},t.prototype.setLanguage=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.language",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getLanguage=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.language","en")];case 1:return[2,t.sent()]}}))}))},t.prototype.setApiEntrypoint=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.apiEntrypoint",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getApiEntrypoint=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.apiEntrypoint","https://cp.pushwoosh.com/json/1.3/")];case 1:return[2,t.sent()]}}))}))},t.prototype.setTokens=function(t){return s(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return[4,this.getHwid()];case 1:return e=r.sent(),[4,this.store.set("API_PARAMS",n({hwid:e},t))];case 2:return r.sent(),[4,this.store.set("params.tokens",t)];case 3:return r.sent(),[2]}}))}))},t.prototype.getTokens=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.store.get("API_PARAMS")];case 1:return t=n.sent(),[4,this.store.get("params.tokens")];case 2:return[2,void 0!==(e=n.sent())?e:t]}}))}))},t.prototype.setApplicationServerKey=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.applicationServerKey",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getApplicationServerKey=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.applicationServerKey")];case 1:return[2,t.sent()]}}))}))},t.prototype.setIsVapidChanged=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.isVapidChanged",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getIsVapidChanged=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.isVapidChanged",!1)];case 1:return[2,t.sent()]}}))}))},t.prototype.setWebSitePushId=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.webSitePushId",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getWebSitePushId=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.webSitePushId")];case 1:return[2,t.sent()]}}))}))},t.prototype.setDefaultNotificationImage=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.defaultNotificationImage",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getDefaultNotificationImage=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.defaultNotificationImage","https://cp.pushwoosh.com/img/logo-medium.png")];case 1:return[2,t.sent()]}}))}))},t.prototype.setDefaultNotificationTitle=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.defaultNotificationTitle",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getDefaultNotificationTitle=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.defaultNotificationTitle","Pushwoosh notification")];case 1:return[2,t.sent()]}}))}))},t.prototype.setUserId=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return t?[3,2]:[4,this.store.set("params.userId",void 0)];case 1:case 3:return e.sent(),[2];case 2:return[4,this.store.set("params.userId",t.toString())]}}))}))},t.prototype.getUserId=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.userId")];case 1:return[2,t.sent()]}}))}))},t.prototype.setStatusUserIdWasChanged=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.userIdWasChanged",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getStatusUserIdWasChanged=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.userIdWasChanged",!1)];case 1:return[2,t.sent()]}}))}))},t.prototype.setEmail=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return t?[3,2]:[4,this.store.set("params.email",void 0)];case 1:case 3:return e.sent(),[2];case 2:return[4,this.store.set("params.email",t.toString())]}}))}))},t.prototype.getEmail=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.email")];case 1:return[2,t.sent()]}}))}))},t.prototype.setStatusEmailWasChanged=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.emailWasChanged",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getStatusEmailWasChanged=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.emailWasChanged",!1)];case 1:return[2,t.sent()]}}))}))},t.prototype.setLastPermissionStatus=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.isLastPermissionStatus",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getLastPermissionStatus=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.isLastPermissionStatus")];case 1:return[2,t.sent()]}}))}))},t.prototype.setStatusManualUnsubscribed=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("MANUAL_UNSUBSCRIBE",t)];case 1:return e.sent(),[4,this.store.set("params.isManualUnsubscribed",t)];case 2:return e.sent(),[2]}}))}))},t.prototype.getStatusManualUnsubscribed=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.store.get("MANUAL_UNSUBSCRIBE",!1)];case 1:return t=n.sent(),[4,this.store.get("params.isManualUnsubscribed",!1)];case 2:return[2,void 0!==(e=n.sent())?e:t]}}))}))},t.prototype.setStatusCommunicationDisabled=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("COMMUNICATION_ENABLED",t?0:1)];case 1:return e.sent(),[4,this.store.set("params.isCommunicationDisabled",t)];case 2:return e.sent(),[2]}}))}))},t.prototype.getStatusCommunicationDisabled=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.store.get("COMMUNICATION_ENABLED")];case 1:return t=n.sent(),[4,this.store.get("params.isCommunicationDisabled",!1)];case 2:return[2,void 0!==(e=n.sent())?e:0==t]}}))}))},t.prototype.setStatusDropAllData=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("DEVICE_DATA_REMOVED",t)];case 1:return e.sent(),[4,this.store.set("params.isDropAllData",t)];case 2:return e.sent(),[2]}}))}))},t.prototype.getStatusDropAllData=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.store.get("DEVICE_DATA_REMOVED",!1)];case 1:return t=n.sent(),[4,this.store.get("params.isDropAllData",!1)];case 2:return[2,void 0!==(e=n.sent())?e:t]}}))}))},t.prototype.setSdkVersion=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.sdkVersion",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getSdkVersion=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.sdkVersion")];case 1:return[2,t.sent()]}}))}))},t.prototype.setServiceWorkerVersion=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("WORKER_VERSION",t)];case 1:return e.sent(),[4,this.store.set("params.serviceWorkerVersion",t)];case 2:return e.sent(),[2]}}))}))},t.prototype.getServiceWorkerVersion=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.store.get("WORKER_VERSION")];case 1:return t=n.sent(),[4,this.store.get("params.serviceWorkerVersion")];case 2:return[2,void 0!==(e=n.sent())?e:t]}}))}))},t.prototype.setServiceWorkerUrl=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return t?[4,this.store.set("params.serviceWorkerUrl",t)]:[2];case 1:return e.sent(),[2]}}))}))},t.prototype.getServiceWorkerUrl=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.serviceWorkerUrl","/pushwoosh-service-worker.js")];case 1:return[2,t.sent()]}}))}))},t.prototype.setServiceWorkerScope=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return t?[4,this.store.set("params.serviceWorkerScope",t)]:[2];case 1:return e.sent(),[2]}}))}))},t.prototype.getServiceWorkerScope=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.serviceWorkerScope")];case 1:return[2,t.sent()]}}))}))},t.prototype.setLastOpenMessage=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("LAST_OPEN_MESSAGE",t)];case 1:return e.sent(),[4,this.store.set("params.lastOpenMessage",t)];case 2:return e.sent(),[2]}}))}))},t.prototype.getLastOpenMessage=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.store.get("LAST_OPEN_MESSAGE")];case 1:return t=n.sent(),[4,this.store.get("params.lastOpenMessage")];case 2:return[2,void 0!==(e=n.sent())?e:t]}}))}))},t.prototype.setLastOpenApplicationTime=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.lastOpenApplicationTime",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getLastOpenApplicationTime=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.lastOpenApplicationTime")];case 1:return[2,t.sent()]}}))}))},t.prototype.setFeatures=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.features",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getFeatures=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.features")];case 1:return[2,t.sent()]}}))}))},t.prototype.setInitParams=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.init",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getInitParams=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.init")];case 1:return[2,t.sent()]}}))}))},t.prototype.setInboxLastRequestCode=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.inbox.lastRequestCode",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getInboxLastRequestCode=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.store.get("params.inbox.lastRequestCode","")];case 1:return[2,t.sent()]}}))}))},t.prototype.setInboxLastRequestTime=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.inbox.lastRequestTime",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getInboxLastRequestTime=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.store.get("params.inbox.lastRequestTime",0)]}))}))},t.prototype.setInboxNewMessagesCount=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.inbox.newMessagesCount",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getInboxNewMessagesCount=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.store.get("params.inbox.newMessagesCount",0)]}))}))},t.prototype.setDelayedEvent=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("DELAYED_EVENT",t)];case 1:return e.sent(),[4,this.store.set("params.delayedEvent",t)];case 2:return e.sent(),[2]}}))}))},t.prototype.getDelayedEvent=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.store.get("DELAYED_EVENT")];case 1:return t=n.sent(),[4,this.store.get("params.delayedEvent")];case 2:return[2,void 0!==(e=n.sent())?e:t]}}))}))},t.prototype.setPromptDisplayCount=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.promptDisplayCount",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getPromptDisplayCount=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.store.get("params.promptDisplayCount",0)]}))}))},t.prototype.setPromptLastSeenTime=function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.store.set("params.promptLastSeenTime",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getPromptLastSeenTime=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.store.get("params.promptLastSeenTime",0)]}))}))},t}(),lt=function(){function t(t,e,n){if(void 0===e&&(e=new dt),void 0===n&&(n=new L),"data"in t){var r=t;this.payload=r.data}else this.payload=t;this.data=e,this.code="notificationCode-".concat(Date.now(),"-").concat(Math.random().toString(16).slice(2,10)),this.dateModule=n}return t.prototype.getIcon=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return(t=this.payload.i)?[3,2]:[4,this.data.getDefaultNotificationImage()];case 1:t=e.sent(),e.label=2;case 2:return[2,t]}}))}))},t.prototype.getTitle=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return(t=this.payload.header)?[3,2]:[4,this.data.getDefaultNotificationTitle()];case 1:t=e.sent(),e.label=2;case 2:return[2,t]}}))}))},Object.defineProperty(t.prototype,"silent",{get:function(){return Boolean(this.payload.silent)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"body",{get:function(){return this.payload.body},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"messageHash",{get:function(){return this.payload.p||""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"metaData",{get:function(){return this.payload.md?b(this.payload.md):{}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"image",{get:function(){return this.payload.image||""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttons",{get:function(){return this.payload.buttons?b(this.payload.buttons):[]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"customData",{get:function(){return this.payload.u?b(this.payload.u):{}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"campaignCode",{get:function(){return this.payload.pwcid||""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"link",{get:function(){return this.payload.l?(t=this.payload.l)&&pt.test(t)?t.replace(ht,(function(t){return ct[t]})):t:"/";var t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"inboxId",{get:function(){return this.payload.pw_inbox||""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"inboxParams",{get:function(){return this.payload.inbox_params?b(this.payload.inbox_params):{}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"inboxRemovalTime",{get:function(){return this.inboxParams&&this.inboxParams.rt?this.inboxParams.rt:(this.dateModule.date=new Date,this.dateModule.addDays(1),this.dateModule.getUtcTimestamp().toString())},enumerable:!1,configurable:!0}),t.prototype.getInboxImage=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return this.inboxParams&&this.inboxParams.image?[2,this.inboxParams.image]:[2,""]}))}))},Object.defineProperty(t.prototype,"rootParams",{get:function(){var t=this.payload;t.body,t.p,t.header,t.i,t.u,t.l,t.pwcid,t.image,t.buttons,t.pw_inbox,t.inbox_params;return r(t,["body","p","header","i","u","l","pwcid","image","buttons","pw_inbox","inbox_params"])},enumerable:!1,configurable:!0}),t.prototype.getNotificationOptionsPayload=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(r){switch(r.label){case 0:return[4,this.getTitle()];case 1:return t=r.sent(),[4,this.getIcon()];case 2:return e=r.sent(),[2,n(n({},this.rootParams),{body:this.body,title:t,icon:e,image:this.image,buttons:this.buttons,customData:this.customData,metaData:this.metaData,campaignCode:this.campaignCode,openUrl:this.link,messageHash:this.messageHash})]}}))}))},t.prototype.getShowNotificationOptions=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(r){switch(r.label){case 0:return[4,this.getIcon()];case 1:return t=r.sent(),e=this.buttons.map((function(t,e){return t.action="action-".concat(e),t})),[2,n(n({renotify:!0},this.rootParams),{body:this.body,icon:t,tag:JSON.stringify({url:this.link,messageHash:this.messageHash,customData:this.customData,metaData:this.metaData}),data:{code:this.code,buttons:e,image:this.image,campaignCode:this.campaignCode,inboxId:this.inboxId},silent:this.silent,actions:e,image:this.image,buttons:e})]}}))}))},t.prototype.getInboxMessage=function(){return s(this,void 0,void 0,(function(){var t,e,n;return i(this,(function(r){switch(r.label){case 0:return this.dateModule.date=new Date,t=this.dateModule.getTimestamp().toString(),e=this.payload.header||"",[4,this.getInboxImage()];case 1:return n=r.sent(),[2,{title:e,image:n,status:1,order:this.dateModule.getInboxFakeOrder(),inbox_id:this.inboxId,send_date:t,rt:this.inboxRemovalTime,text:this.body,action_type:1,action_params:JSON.stringify({l:this.link})}]}}))}))},t}();const ft=lt;var vt=function(){function t(t,e){void 0===t&&(t=new dt),void 0===e&&(e=tt),this.data=t,this.logger=e}return t.prototype.checkDevice=function(t){return this.createRequest("checkDevice",t)},t.prototype.getConfig=function(t){return this.createRequest("getConfig",t,"",!0)},t.prototype.applicationOpen=function(t){return this.createRequest("applicationOpen",t)},t.prototype.registerDevice=function(t){return this.createRequest("registerDevice",t)},t.prototype.unregisterDevice=function(t){return this.createRequest("unregisterDevice",t)},t.prototype.deleteDevice=function(t){return this.createRequest("deleteDevice",t)},t.prototype.messageDeliveryEvent=function(t){return this.createRequest("messageDeliveryEvent",t)},t.prototype.pushStat=function(t){return this.createRequest("pushStat",t)},t.prototype.setTags=function(t){return this.createRequest("setTags",t)},t.prototype.getTags=function(t){return this.createRequest("getTags",t)},t.prototype.registerUser=function(t){return this.createRequest("registerUser",t)},t.prototype.registerEmail=function(t){return this.createRequest("registerEmail",t)},t.prototype.registerEmailUser=function(t){return this.createRequest("registerEmailUser",t)},t.prototype.setEmailTags=function(t){return this.createRequest("setEmailTags",t)},t.prototype.postEvent=function(t){return this.createRequest("postEvent",t)},t.prototype.getInboxMessages=function(t){return this.createRequest("getInboxMessages",t)},t.prototype.inboxStatus=function(t){return this.createRequest("inboxStatus",t)},t.prototype.pageVisit=function(t,e){return this.createRequest("pageVisit",t,e)},t.prototype.setPurchase=function(t){return this.createRequest("setPurchase",t)},t.prototype.createRequest=function(t,e,r,o){return s(this,void 0,void 0,(function(){var s,a,u,c,h,p,d;return i(this,(function(i){switch(i.label){case 0:return[4,this.data.getApiEntrypoint()];case 1:return s=i.sent(),o?(u="",[3,4]):[3,2];case 2:return[4,this.data.getApiToken()];case 3:u=i.sent(),i.label=4;case 4:return c=r||s+t,h=(a=u)?{headers:{Authorization:"Token ".concat(a),"Content-Type":"text/plain;charset=UTF-8",Origin:globalThis.location.origin},credentials:"include"}:{},[4,fetch(c,n({method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8"},body:JSON.stringify({request:e})},h))];case 5:return p=i.sent(),[4,this.checkResponse(p)];case 6:return(d=i.sent()).base_url?[4,this.data.setApiEntrypoint(d.base_url)]:[3,8];case 7:i.sent(),i.label=8;case 8:return[4,this.logger.write("apirequest","".concat(t," call with arguments: ").concat(JSON.stringify(e)," to Pushwoosh has been successful. Result: ").concat(JSON.stringify(d.response)))];case 9:return i.sent(),[2,d.response]}}))}))},t.prototype.checkResponse=function(t){return s(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:if(200!==t.status)throw new Error("Error code: ".concat(t.status,". Error text: ").concat(t.statusText));return[4,t.json()];case 1:if(200!==(e=n.sent()).status_code)throw new Error("Error code: ".concat(e.status_code,". Error text: ").concat(e.status_message));return[2,e]}}))}))},t}(),gt=function(){function t(t,e,n){void 0===e&&(e=new dt),void 0===n&&(n=new vt),this.eventBus=t,this.data=e,this.apiClient=n}return t.prototype.checkDevice=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this.getRequestParams()];case 1:return t=e.sent(),[4,this.apiClient.checkDevice(t)];case 2:return[2,e.sent()]}}))}))},t.prototype.checkDeviceSubscribeForPushNotifications=function(){return s(this,arguments,void 0,(function(t){var e,n,r,s;return void 0===t&&(t=!0),i(this,(function(i){switch(i.label){case 0:return void 0!==(e=localStorage.getItem(a))&&t?[3,2]:[4,this.checkDevice()];case 1:n=i.sent(),r=n.exist,s=n.push_token_exist,localStorage.setItem(a,r&&s?u:c),e=localStorage.getItem(a),i.label=2;case 2:return[2,e===u]}}))}))},t.prototype.getConfig=function(t){return s(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return[4,this.getRequestParams()];case 1:return e=r.sent(),[2,this.apiClient.getConfig(n(n({},e),{features:t}))]}}))}))},t.prototype.applicationOpen=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this.getRequestParams()];case 1:return t=e.sent(),[4,this.data.setLastOpenApplicationTime(Date.now())];case 2:return e.sent(),[2,this.apiClient.applicationOpen(t)]}}))}))},t.prototype.registerDevice=function(){return s(this,void 0,void 0,(function(){var t,e,r;return i(this,(function(s){switch(s.label){case 0:return[4,this.data.getStatusCommunicationDisabled()];case 1:if(s.sent())throw new Error("Can't register device: Communication is disabled!");return[4,this.getRequestParams()];case 2:return t=s.sent(),[4,this.data.getTokens()];case 3:if(!(e=s.sent()).pushToken)throw new Error("Can't register device: pushToken is not exist!");return[4,this.apiClient.registerDevice(n(n({},t),{push_token:e.pushToken,auth_token:e.authToken,public_key:e.publicKey}))];case 4:return r=s.sent(),[4,this.data.setStatusManualUnsubscribed(!1)];case 5:return s.sent(),localStorage.setItem(a,u),this.eventBus.dispatchEvent("register",{}),[2,r]}}))}))},t.prototype.unregisterDevice=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.getRequestParams()];case 1:return t=n.sent(),e=this.apiClient.unregisterDevice(t),localStorage.setItem(a,c),this.eventBus.dispatchEvent("unsubscribe",{}),[2,e]}}))}))},t.prototype.deleteDevice=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.getRequestParams()];case 1:return t=n.sent(),e=this.apiClient.deleteDevice(t),[4,this.data.setStatusManualUnsubscribed(!0)];case 2:return n.sent(),localStorage.setItem(a,c),this.eventBus.dispatchEvent("unsubscribe",{}),[2,e]}}))}))},t.prototype.messageDeliveryEvent=function(t,e){return s(this,arguments,void 0,(function(t,e,r){var s;return void 0===r&&(r={}),i(this,(function(e){switch(e.label){case 0:return[4,this.getRequestParams()];case 1:return s=e.sent(),[4,this.apiClient.messageDeliveryEvent(n(n({},s),{hash:t,metaData:r}))];case 2:return[2,e.sent()]}}))}))},t.prototype.pushStat=function(t,e){return s(this,arguments,void 0,(function(t,e,r){var s;return void 0===r&&(r={}),i(this,(function(e){switch(e.label){case 0:return[4,this.getRequestParams()];case 1:return s=e.sent(),[4,this.apiClient.pushStat(n(n({},s),{hash:t,metaData:r}))];case 2:return[2,e.sent()]}}))}))},t.prototype.setTags=function(t){return s(this,void 0,void 0,(function(){var e,s,o,a,u;return i(this,(function(i){switch(i.label){case 0:return[4,this.getRequestParams()];case 1:return e=i.sent(),s=e.hwid,o=e.device_type,a=r(e,["hwid","device_type"]),[4,this.data.getEmail()];case 2:return(u=i.sent())?[4,this.apiClient.setEmailTags(n(n({},a),{email:u,tags:t}))]:[3,4];case 3:i.sent(),i.label=4;case 4:return[2,this.apiClient.setTags(n(n({},a),{hwid:s,device_type:o,tags:t}))]}}))}))},t.prototype.getTags=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this.getRequestParams()];case 1:return t=e.sent(),[2,this.apiClient.getTags(t)]}}))}))},t.prototype.registerUser=function(t){return s(this,void 0,void 0,(function(){var e,s,o,a,u,c,h;return i(this,(function(i){switch(i.label){case 0:return[4,this.getRequestParams()];case 1:return e=i.sent(),s=e.hwid,e.device_type,o=r(e,["hwid","device_type"]),[4,this.data.getDeviceType()];case 2:return a=i.sent(),u="".concat(t),[4,this.data.getEmail()];case 3:return c=i.sent(),[4,this.apiClient.registerUser(n(n({},o),{hwid:s,userId:u,ts_offset:60*-(new Date).getTimezoneOffset(),device_type:a}))];case 4:return h=i.sent(),c?[4,this.apiClient.registerEmailUser(n(n({},o),{email:c,userId:u,ts_offset:60*-(new Date).getTimezoneOffset()}))]:[3,6];case 5:i.sent(),i.label=6;case 6:return[4,this.data.setUserId("".concat(t))];case 7:return i.sent(),[4,this.data.setStatusUserIdWasChanged(!0)];case 8:return i.sent(),[2,h]}}))}))},t.prototype.registerEmail=function(t){return s(this,void 0,void 0,(function(){var e,s,o;return i(this,(function(i){switch(i.label){case 0:return[4,this.getRequestParams()];case 1:return e=i.sent(),e.hwid,e.device_type,s=r(e,["hwid","device_type"]),[4,this.apiClient.registerEmail(n(n({},s),{email:t,ts_offset:60*-(new Date).getTimezoneOffset()}))];case 2:return o=i.sent(),[4,this.data.setEmail("".concat(t))];case 3:return i.sent(),[4,this.data.setStatusEmailWasChanged(!0)];case 4:return i.sent(),[2,o]}}))}))},t.prototype.postEvent=function(t,e){return s(this,void 0,void 0,(function(){var r,s,o,a,u,c,h;return i(this,(function(i){switch(i.label){case 0:return[4,this.getRequestParams()];case 1:return r=i.sent(),s=new Date,o=s.getTime(),a=Math.floor(o/1e3),u=a-s.getTimezoneOffset()/60*3600,[4,this.data.getLastOpenMessage()];case 2:if((c=i.sent())&&c.expiry>Date.now()){if(e.msgHash)return[2,Promise.reject("attribute msgHash already defined")];e=n(n({},e),{msgHash:c.messageHash})}return[4,this.data.setLastOpenMessage(void 0)];case 3:return i.sent(),[4,this.apiClient.postEvent(n(n({},r),{event:t,timestampUTC:a,timestampCurrent:u,attributes:e}))];case 4:return(h=i.sent())&&h.code&&this.eventBus.dispatchEvent("receive-in-app-code",{code:h.code}),[2,h]}}))}))},t.prototype.getInboxMessages=function(){return s(this,arguments,void 0,(function(t){var e,r,s;return void 0===t&&(t=0),i(this,(function(i){switch(i.label){case 0:return[4,this.getRequestParams()];case 1:return e=i.sent(),[4,this.data.getInboxLastRequestCode()];case 2:return r=i.sent(),[4,this.data.getInboxLastRequestTime()];case 3:return s=i.sent(),[2,this.apiClient.getInboxMessages(n(n({},e),{count:t,last_code:r,last_request_time:s}))]}}))}))},t.prototype.inboxStatus=function(t,e){return s(this,void 0,void 0,(function(){var r;return i(this,(function(s){switch(s.label){case 0:return[4,this.getRequestParams()];case 1:return r=s.sent(),[2,this.apiClient.inboxStatus(n(n({},r),{inbox_code:t,status:e,time:(new Date).getTime()}))]}}))}))},t.prototype.triggerEvent=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){throw new Error("Method has been deprecated, because we don't aggregate this statistics.")}))}))},t.prototype.pageVisit=function(t){return s(this,void 0,void 0,(function(){var e,r,s;return i(this,(function(i){switch(i.label){case 0:return[4,this.getRequestParams()];case 1:return e=i.sent(),[4,this.data.getFeatures()];case 2:return r=i.sent(),(s=r&&r.page_visit&&r.page_visit.entrypoint)?[2,this.apiClient.pageVisit(n(n({},e),t),s)]:[2]}}))}))},t.prototype.setPurchase=function(t){return s(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return[4,this.getRequestParams()];case 1:return e=r.sent(),[2,this.apiClient.setPurchase(n(n({},e),t))]}}))}))},t.prototype.getParams=function(){return s(this,void 0,void 0,(function(){var t,e,r,s;return i(this,(function(i){switch(i.label){case 0:return[4,this.data.getApplicationCode()];case 1:return t=i.sent(),[4,this.data.getHwid()];case 2:return e=i.sent(),[4,this.data.getTokens()];case 3:return r=i.sent(),[4,this.data.getInitParams()];case 4:return s=i.sent(),[2,n(n({applicationCode:t,hwid:e},r),s)]}}))}))},Object.defineProperty(t.prototype,"params",{get:function(){throw new Error('Property "Pushwoosh.api.params" have been deprecated. Use the async method "Pushwoosh.api.getParams()"')},enumerable:!1,configurable:!0}),t.prototype.getRequestParams=function(){return s(this,void 0,void 0,(function(){var t,e,n,r,s,o,a,u;return i(this,(function(i){switch(i.label){case 0:return[4,this.data.getApplicationCode()];case 1:return t=i.sent(),[4,this.data.getHwid()];case 2:return e=i.sent(),[4,this.data.getUserId()];case 3:return n=i.sent(),[4,this.data.getDeviceType()];case 4:return r=i.sent(),[4,this.data.getDeviceModel()];case 5:return s=i.sent(),[4,this.data.getLanguage()];case 6:return o=i.sent(),[4,this.data.getSdkVersion()];case 7:return a=i.sent(),u=60*-(new Date).getTimezoneOffset(),[2,{application:t,hwid:e,userId:n||e,device_type:r,device_model:s,timezone:u,language:o,v:a}]}}))}))},t}(),mt=function(){function t(t,e,n){this.api=t,this.data=e,this.config=n}return t.prototype.getPermission=function(){return Notification.permission},t.prototype.checkIsPermissionGranted=function(){return"granted"===this.getPermission()},t.prototype.checkIsPermissionDefault=function(){return"default"===this.getPermission()},t.prototype.checkIsManualUnsubscribed=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.data.getStatusManualUnsubscribed()]}))}))},t.prototype.askPermission=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,Notification.requestPermission()];case 1:return t.sent(),[2]}}))}))},t.prototype.getTokens=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.data.getTokens()]}))}))},t.prototype.subscribe=function(t){return s(this,void 0,void 0,(function(){var e,n,r,s,o,a,u;return i(this,(function(i){switch(i.label){case 0:return(n=t)?[3,2]:[4,this.trySubscribe()];case 1:n=i.sent(),i.label=2;case 2:if(e=n,!this.checkIsPermissionGranted())return tt.error("You must have permission granted before subscribe!"),[2];if(r=this.getPushToken(e),s=e.getKey("p256dh"),o=e.getKey("auth"),!s||!o)throw new Error("Can't get subscription keys!");return a=btoa(String.fromCharCode.apply(String,new Uint8Array(s))),u=btoa(String.fromCharCode.apply(String,new Uint8Array(o))),[4,this.data.setTokens({publicKey:a,pushToken:r,authToken:u,endpoint:e.endpoint})];case 3:return i.sent(),[4,this.api.registerDevice()];case 4:return i.sent(),[2]}}))}))},t.prototype.unsubscribe=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this.getServiceWorkerRegistration()];case 1:return[4,e.sent().pushManager.getSubscription()];case 2:return t=e.sent(),[4,this.data.setTokens({})];case 3:return e.sent(),[4,this.data.setStatusManualUnsubscribed(!0)];case 4:return e.sent(),[4,this.api.unregisterDevice()];case 5:return e.sent(),t?[4,t.unsubscribe()]:[2];case 6:return e.sent(),[2]}}))}))},t.prototype.checkIsRegister=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.api.checkDeviceSubscribeForPushNotifications()]}))}))},t.prototype.checkIsNeedResubscribe=function(){return s(this,void 0,void 0,(function(){var t,e,n,r,s,o,a,u;return i(this,(function(i){switch(i.label){case 0:return[4,this.data.getLastPermissionStatus()];case 1:return t=i.sent(),e=this.getPermission(),t===e?[3,3]:[4,this.data.setLastPermissionStatus(e)];case 2:return i.sent(),[2,!0];case 3:return[4,this.getCredentials()];case 4:return n=i.sent(),r=this.getPushToken(n),[4,this.data.getTokens()];case 5:return s=i.sent(),o=s&&s.pushToken||"",a=r===o,[4,this.data.getIsVapidChanged()];case 6:return u=i.sent(),[2,!a||u]}}))}))},t.prototype.getServiceWorkerRegistration=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return this.registration?[3,5]:[4,this.registerServiceWorker()];case 1:return n.sent(),[4,this.data.getServiceWorkerUrl()];case 2:return t=n.sent(),e=this,[4,navigator.serviceWorker.getRegistration(t)];case 3:return e.registration=n.sent(),[4,this.registration.update()];case 4:n.sent(),n.label=5;case 5:if(!this.registration)throw new Error("Internal Error: Can't register service worker!");return[2,this.registration]}}))}))},t.prototype.registerServiceWorker=function(){return s(this,void 0,void 0,(function(){var t,e,n,r,s;return i(this,(function(i){switch(i.label){case 0:return[4,this.data.getServiceWorkerUrl()];case 1:return t=i.sent(),[4,this.data.getServiceWorkerScope()];case 2:return e=i.sent(),[4,this.data.getSdkVersion()];case 3:return n=i.sent(),[4,this.data.getServiceWorkerVersion()];case 4:return r=i.sent(),s="",n!==r&&(s="?cache_clean=".concat(v())),[4,navigator.serviceWorker.register("".concat(t).concat(s),{scope:e})];case 5:return i.sent(),[2]}}))}))},t.prototype.trySubscribe=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,4]),[4,this.subscribePushManager()];case 1:return[2,e.sent()];case 2:return t=e.sent(),console.error(t),[4,this.unsubscribe()];case 3:return e.sent(),[2,this.subscribePushManager()];case 4:return[2]}}))}))},t.prototype.subscribePushManager=function(){return s(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.getServiceWorkerRegistration()];case 1:return t=n.sent(),[4,this.getApplicationServerKey()];case 2:return e=n.sent(),[2,t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:e?this.urlBase64ToUint8Array(e):null})]}}))}))},t.prototype.getCredentials=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.getServiceWorkerRegistration()];case 1:return[4,t.sent().pushManager.getSubscription()];case 2:return[2,t.sent()]}}))}))},t.prototype.getPushToken=function(t){return t?t.endpoint:""},t.prototype.getApplicationServerKey=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.data.getDeviceType()];case 1:return 11!==t.sent()?[2]:[4,this.data.getApplicationServerKey()];case 2:return[2,t.sent()]}}))}))},t.prototype.urlBase64ToUint8Array=function(t){for(var e=(t+"=".repeat((4-t.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/"),n=atob(e),r=new Uint8Array(n.length),s=0;s<n.length;++s)r[s]=n.charCodeAt(s);return r},t}(),yt=function(){function t(t,e,n){this._listeners={},this.eventBus=t,this.data=e,this.api=n}return t.prototype.push=function(t){Array.isArray(t)&&"onPush"===t[0]&&"function"==typeof t[1]&&(this._listeners[t[0]]||(this._listeners[t[0]]=[]),this._listeners[t[0]].push(t[1]))},t.prototype.getListeners=function(t){return this._listeners[t]||[]},t.prototype.initApi=function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){return[2,Promise.resolve()]}))}))},t}();const bt=yt;var wt=function(){function t(t,e,n){this._canceled=!1,this.showNotificationOptions=t,this.body=e,this.title=n}return t.prototype.show=function(){return s(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return this._canceled?[2]:(t=this.showNotificationOptions).silent?[3,2]:[4,self.registration.showNotification(this.title,t)];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.cancel=function(){this._canceled=!0},t}();const St=wt;var Et=new m,Mt=new dt,xt=new gt(Et,Mt),Pt=self.Pushwoosh=new bt(Et,Mt,xt),Dt=[];function Ct(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,self.clients.matchAll()];case 1:return e.sent().forEach((function(e){return e.postMessage(t)})),[2]}}))}))}function Tt(t){return s(this,void 0,void 0,(function(){var e,n,r,s,o,a;return i(this,(function(i){return e=t.notification,r=(n=void 0===e?{}:e).data,s=b(n.tag,{}),o="",t.action&&Array.isArray(r.buttons)?(a=r.buttons.find((function(e){return e.action===t.action}))||{},o=a.url):o=s.url,[2,{title:n.title,body:n.body,icon:n.icon,buttons:r.buttons,image:r.image,code:r.code,campaignCode:r.campaignCode,inboxId:r.inboxId,messageHash:s.messageHash,customData:s.customData,metaData:s.metaData,openUrl:s.url,tag:n.tag,url:o}]}))}))}function It(t){return s(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return[4,Pt.data.getApplicationCode()];case 1:return e=r.sent(),[4,Pt.data.getServiceWorkerVersion()];case 2:return n=r.sent(),[4,k({message:"Error in onInstallEventHandler",code:"FATAL-SW-001",error:t,applicationCode:e,workerVersion:n})];case 3:return r.sent(),[2]}}))}))}function kt(t){return s(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return[4,Pt.data.getApplicationCode()];case 1:return e=r.sent(),[4,Pt.data.getServiceWorkerVersion()];case 2:return n=r.sent(),[4,k({message:"Error in onActivateEventHandler",code:"FATAL-SW-002",error:t,applicationCode:e,workerVersion:n})];case 3:return r.sent(),[2]}}))}))}function At(t){return s(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return[4,Pt.data.getApplicationCode()];case 1:return e=r.sent(),[4,Pt.data.getServiceWorkerVersion()];case 2:return n=r.sent(),[4,k({message:"Error in onNotificationClickEventHandler",code:"FATAL-SW-004",error:t,applicationCode:e,workerVersion:n})];case 3:return r.sent(),[2]}}))}))}function Ot(t){return s(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return[4,Pt.data.getApplicationCode()];case 1:return e=r.sent(),[4,Pt.data.getServiceWorkerVersion()];case 2:return n=r.sent(),[4,k({message:"Error in onNotificationCloseEventHandler",code:"FATAL-SW-005",error:t,applicationCode:e,workerVersion:n})];case 3:return r.sent(),[2]}}))}))}function Rt(t){return s(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return[4,Pt.data.getApplicationCode()];case 1:return e=r.sent(),[4,Pt.data.getServiceWorkerVersion()];case 2:return n=r.sent(),[4,k({message:"Error in onPushSubscriptionChange",code:"FATAL-SW-006",error:t,applicationCode:e,workerVersion:n})];case 3:return r.sent(),[2]}}))}))}return self.addEventListener("install",(function(t){return t.waitUntil(function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,Promise.all([Pt.data.setServiceWorkerVersion("3.39.8"),tt.write("info","install")])];case 1:return t.sent(),[4,self.skipWaiting()];case 2:return t.sent(),[2]}}))}))}().catch(It))})),self.addEventListener("activate",(function(t){t.waitUntil(function(){return s(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,Promise.all([tt.write("info","activate")])];case 1:return t.sent(),[4,self.clients.claim()];case 2:return t.sent(),[2]}}))}))}().catch(kt))})),self.addEventListener("push",(function(t){t.waitUntil(function(t){return s(this,void 0,void 0,(function(){var e,n,r,s,o,a,u,c,h,p,d,l,f;return i(this,(function(i){switch(i.label){case 0:return[4,self.clients.claim()];case 1:return i.sent(),[4,t.data.json()];case 2:return e=i.sent(),[4,(n=new ft(e)).getNotificationOptionsPayload()];case 3:return r=i.sent(),[4,n.getShowNotificationOptions()];case 4:return s=i.sent(),o=n.messageHash,[4,tt.write("info",JSON.stringify(r),"onPush")];case 5:return i.sent(),u=St.bind,c=[void 0,s,n.body],[4,n.getTitle()];case 6:return a=new(u.apply(St,c.concat([i.sent()]))),[4,Pt.getListeners("onPush").reduce((function(t,e){return t.then((function(){return e(a)}))}),Promise.resolve())];case 7:return i.sent(),h=[a.show(),Q.add({payload:e,parsedPayload:r,showOptions:s}),Ct({type:"onPushDelivery",payload:r})],o&&h.push(Pt.initApi().then((function(){return Pt.api.messageDeliveryEvent(o,!0,r.metaData)}))),""===n.inboxId?[3,10]:(p=new ut(Pt.eventBus,Pt.data,Pt.api),d=new nt(Pt.data,Pt.api,p),[4,n.getInboxMessage()]);case 8:return l=i.sent(),[4,d.publicMessageBuilder(l)];case 9:f=i.sent(),h.push(p.putMessage(l),Ct({type:"onPutNewMessageToInboxStore",payload:f})),i.label=10;case 10:return[4,Promise.all(h)];case 11:return i.sent(),[2]}}))}))}(t).catch((function(e){return function(t,e){return s(this,void 0,void 0,(function(){var n,r;return i(this,(function(s){switch(s.label){case 0:return[4,Pt.data.getApplicationCode()];case 1:return n=s.sent(),[4,Pt.data.getServiceWorkerVersion()];case 2:return r=s.sent(),[4,k({message:"Error in onPushEventHandler",code:"FATAL-SW-003",error:t,applicationCode:n,workerVersion:r})];case 3:return s.sent(),t instanceof Error||(t=new Error(t)),[2,Q.add({error:"".concat(t),stack:t.stack,payload:e.data&&e.data.text()})]}}))}))}(e,t)})))})),self.addEventListener("notificationclick",(function(t){t.waitUntil(function(t){return s(this,void 0,void 0,(function(){var e,n,r,o,a,u,c,h,p;return i(this,(function(d){switch(d.label){case 0:return[4,self.clients.claim()];case 1:return d.sent(),[4,Tt(t)];case 2:return e=d.sent(),n=e.messageHash,r=e.metaData,o=e.url,a=e.code,u=e.inboxId,a&&Dt.push(a),""===u?[3,5]:[4,(c=new ut(Pt.eventBus,Pt.data,Pt.api)).getMessage(u)];case 3:return(h=d.sent()).status=3,[4,c.putMessage(h)];case 4:d.sent(),d.label=5;case 5:return t.notification.close(),p={type:"onNotificationClick",payload:e},o&&t.waitUntil(self.clients.matchAll({type:"window"}).then((function(t){return function(t,e){return s(this,void 0,void 0,(function(){var n,r,s,o;return i(this,(function(i){switch(i.label){case 0:return n=new URL(e,self.location.origin),r=n.hostname,s=n.pathname,o=t.find((function(t){var e=new URL(t.url),n=e.hostname,i=e.pathname;return n===r&&i===s})),o?[4,o.focus()]:[3,2];case 1:return i.sent(),[2,!1];case 2:return[4,self.clients.openWindow(e).then((function(t){t&&t.focus()}))];case 3:return i.sent(),[2,!0]}}))}))}(t,o)})).then((function(t){t&&Pt.data.setDelayedEvent(p)}))),[2,Promise.all([Pt.initApi().then((function(){return Pt.api.pushStat(n,!0,r)})),Pt.data.setLastOpenMessage({url:o,messageHash:n,expiry:Date.now()+864e5}),Ct(p)])]}}))}))}(t).catch(At))})),self.addEventListener("notificationclose",(function(t){t.waitUntil(function(t){return s(this,void 0,void 0,(function(){var e,n,r;return i(this,(function(s){switch(s.label){case 0:return[4,self.clients.claim()];case 1:return s.sent(),[4,Tt(t)];case 2:return e=s.sent(),n=e.code,t.notification.close(),n?(r=Dt.indexOf(n))>=0?(Dt.splice(r,1),[2]):[2,Ct({type:"onNotificationClose",payload:e})]:[2]}}))}))}(t).catch(Ot))})),self.addEventListener("pushsubscriptionchange",(function(t){return s(this,void 0,void 0,(function(){return i(this,(function(e){return t.waitUntil(function(t){return s(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return(e=t.newSubscription)?[3,2]:[4,self.registration.pushManager.getSubscription()];case 1:if(!(e=n.sent()))return[2];n.label=2;case 2:return[4,new mt(xt,Mt,{}).subscribe(e)];case 3:return n.sent(),[2]}}))}))}(t).catch(Rt)),[2]}))}))})),{}})()));
2
2
  //# sourceMappingURL=service-worker.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-push-notifications",
3
- "version": "3.39.6",
3
+ "version": "3.39.8",
4
4
  "description": "Pushwoosh web push notifications",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -33,12 +33,6 @@
33
33
  "url": "https://github.com/Pushwoosh/web-push-notifications/issues"
34
34
  },
35
35
  "homepage": "https://github.com/Pushwoosh/web-push-notifications#readme",
36
- "dependencies": {
37
- "uuid": "^11.1.0"
38
- },
39
- "peerDependencies": {
40
- "tslib": "^2.0.0"
41
- },
42
36
  "devDependencies": {
43
37
  "@babel/core": "^7.26.10",
44
38
  "@babel/preset-env": "^7.26.9",
@@ -64,6 +58,7 @@
64
58
  "tslib": "^2.8.1",
65
59
  "typescript": "^5.8.3",
66
60
  "typescript-eslint": "^8.31.1",
61
+ "uuid": "^11.1.0",
67
62
  "webpack": "^5.99.7",
68
63
  "webpack-cli": "^6.0.1",
69
64
  "webpack-dev-server": "^5.2.1",