web-push-notifications 3.28.0 → 3.29.0

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,4 +1,4 @@
1
- !function(root,factory){if("object"==typeof exports&&"object"==typeof module)module.exports=factory();else if("function"==typeof define&&define.amd)define([],factory);else{var a=factory();for(var i in a)("object"==typeof exports?exports:root)[i]=a[i]}}(this,function(){return function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.r=function(exports){Object.defineProperty(exports,"__esModule",{value:!0})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=155)}({1:function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SUBSCRIPTION_PROMPT_WIDGET_DEFAULT_CONFIG=exports.SUBSCRIPTION_WIDGET_USE_CASE_TOPIC_BASED=exports.SUBSCRIPTION_WIDGET_USE_CASE_DEFAULT=exports.SUBSCRIPTION_WIDGET_USE_CASE_NOT_SET=exports.SUBSCRIPTION_SEGMENT_EVENT=exports.PAGE_VISITED_URL=exports.MANUAL_UNSUBSCRIBE=exports.EVENT_PW_SITE_OPENED=exports.EVENT_GDPR_DELETE=exports.EVENT_GDPR_CONSENT=exports.EVENT_CLICK_SUBSCRIBE_BUTTON=exports.EVENT_SHOW_SUBSCRIBE_BUTTON=exports.EVENT_ON_HIDE_SUBSCRIPTION_WIDGET=exports.EVENT_ON_SHOW_SUBSCRIPTION_WIDGET=exports.EVENT_ON_HIDE_NOTIFICATION_PERMISSION_DIALOG=exports.EVENT_ON_SHOW_NOTIFICATION_PERMISSION_DIALOG=exports.EVENT_ON_UPDATE_INBOX_MESSAGES=exports.EVENT_ON_PUT_NEW_MESSAGE_TO_INBOX_STORE=exports.EVENT_ON_CHANGE_COMMUNICATION_ENABLED=exports.EVENT_ON_NOTIFICATION_CLOSE=exports.EVENT_ON_NOTIFICATION_CLICK=exports.EVENT_ON_PUSH_DELIVERY=exports.EVENT_ON_SW_INIT_ERROR=exports.EVENT_ON_PERMISSION_GRANTED=exports.EVENT_ON_PERMISSION_DENIED=exports.EVENT_ON_PERMISSION_PROMPT=exports.EVENT_ON_REGISTER=exports.EVENT_ON_UNSUBSCRIBE=exports.EVENT_ON_SUBSCRIBE=exports.EVENT_ON_READY=exports.EVENT_ON_LOAD=exports.PERMISSION_PROMPT=exports.PERMISSION_GRANTED=exports.PERMISSION_DENIED=exports.DEVICE_REGISTRATION_STATUS_UNREGISTERED=exports.DEVICE_REGISTRATION_STATUS_REGISTERED=exports.MANUAL_SET_LOGGER_LEVEL=exports.KEY_SAFARI_PREVIOUS_PERMISSION=exports.KEY_DEVICE_REGISTRATION_STATUS=exports.KEY_CLICK_SUBSCRIBE_WIDGET=exports.KEY_SHOW_SUBSCRIBE_WIDGET=exports.DEFAULT_NOTIFICATION_IMAGE=exports.DEFAULT_NOTIFICATION_TITLE=exports.WAKE_UP_SERVICE_WORKER_INTERVAL=exports.MAX_NOTIFICATION_DURATION=exports.MIN_NOTIFICATION_DURATION=exports.DEFAULT_NOTIFICATION_DURATION=exports.PERIOD_GOAL_EVENT=exports.PERIOD_SEND_APP_OPEN=exports.FACEBOOK_HWID_KEY=exports.FACEBOOK_APP_ID=exports.DEFAULT_API_URL=exports.DEFAULT_SERVICE_WORKER_URL=void 0,exports.DEFAULT_SERVICE_WORKER_URL="/pushwoosh-service-worker.js",exports.DEFAULT_API_URL="https://cp.pushwoosh.com/json/1.3/",exports.FACEBOOK_APP_ID="436711767081797",exports.FACEBOOK_HWID_KEY="FACEBOOK_HWID_KEY",exports.PERIOD_SEND_APP_OPEN=36e5,exports.PERIOD_GOAL_EVENT=864e5,exports.DEFAULT_NOTIFICATION_DURATION=10,exports.MIN_NOTIFICATION_DURATION=10,exports.MAX_NOTIFICATION_DURATION=55,exports.WAKE_UP_SERVICE_WORKER_INTERVAL=20,exports.DEFAULT_NOTIFICATION_TITLE="Pushwoosh notification",exports.DEFAULT_NOTIFICATION_IMAGE="https://cp.pushwoosh.com/img/logo-medium.png",exports.KEY_SHOW_SUBSCRIBE_WIDGET="WIDGET_SHOWED",exports.KEY_CLICK_SUBSCRIBE_WIDGET="WIDGET_CLICKED",exports.KEY_DEVICE_REGISTRATION_STATUS="deviceRegistrationStatus",exports.KEY_SAFARI_PREVIOUS_PERMISSION="safariPreviousPermission",exports.MANUAL_SET_LOGGER_LEVEL="PW_SET_LOGGER_LEVEL",exports.DEVICE_REGISTRATION_STATUS_REGISTERED="registered",exports.DEVICE_REGISTRATION_STATUS_UNREGISTERED="unregistered",exports.PERMISSION_DENIED="denied",exports.PERMISSION_GRANTED="granted",exports.PERMISSION_PROMPT="default",exports.EVENT_ON_LOAD="onLoad",exports.EVENT_ON_READY="onReady",exports.EVENT_ON_SUBSCRIBE="onSubscribe",exports.EVENT_ON_UNSUBSCRIBE="onUnsubscribe",exports.EVENT_ON_REGISTER="onRegister",exports.EVENT_ON_PERMISSION_PROMPT="onPermissionPrompt",exports.EVENT_ON_PERMISSION_DENIED="onPermissionDenied",exports.EVENT_ON_PERMISSION_GRANTED="onPermissionGranted",exports.EVENT_ON_SW_INIT_ERROR="onSWInitError",exports.EVENT_ON_PUSH_DELIVERY="onPushDelivery",exports.EVENT_ON_NOTIFICATION_CLICK="onNotificationClick",exports.EVENT_ON_NOTIFICATION_CLOSE="onNotificationClose",exports.EVENT_ON_CHANGE_COMMUNICATION_ENABLED="onChangeCommunicationEnabled",exports.EVENT_ON_PUT_NEW_MESSAGE_TO_INBOX_STORE="onPutNewMessageToInboxStore",exports.EVENT_ON_UPDATE_INBOX_MESSAGES="onUpdateInboxMessages",exports.EVENT_ON_SHOW_NOTIFICATION_PERMISSION_DIALOG="onShowNotificationPermissionDialog",exports.EVENT_ON_HIDE_NOTIFICATION_PERMISSION_DIALOG="onHideNotificationPermissionDialog",exports.EVENT_ON_SHOW_SUBSCRIPTION_WIDGET="onShowSubscriptionWidget",exports.EVENT_ON_HIDE_SUBSCRIPTION_WIDGET="onHideSubscriptionWidget",exports.EVENT_SHOW_SUBSCRIBE_BUTTON="showSubscribeButton",exports.EVENT_CLICK_SUBSCRIBE_BUTTON="clickSubscribeButton",exports.EVENT_GDPR_CONSENT="GDPRConsent",exports.EVENT_GDPR_DELETE="GDPRDelete",exports.EVENT_PW_SITE_OPENED="PW_SiteOpened",exports.MANUAL_UNSUBSCRIBE="MANUAL_UNSUBSCRIBE",exports.PAGE_VISITED_URL="PAGE_VISITED_URL",exports.SUBSCRIPTION_SEGMENT_EVENT="Subscription Segments",exports.SUBSCRIPTION_WIDGET_USE_CASE_NOT_SET="not-set",exports.SUBSCRIPTION_WIDGET_USE_CASE_DEFAULT="default",exports.SUBSCRIPTION_WIDGET_USE_CASE_TOPIC_BASED="topic-based",exports.SUBSCRIPTION_PROMPT_WIDGET_DEFAULT_CONFIG={headerText:"Subscribe to our news",headerTextColor:"#000000",subheaderText:"Don't miss out on the latest news and updates!",subheaderTextColor:"#000000",buttonAcceptText:"Agree",buttonAcceptTextColor:"#1A72E8",buttonAcceptRound:"4px",buttonAcceptBackgroundColor:"#FFFFFF",buttonAcceptBorderColor:"#E3E4E8",buttonCancelText:"Deny",buttonCancelTextColor:"#1A72E8",buttonCancelRound:"4px",buttonCancelBackgroundColor:"#FFFFFF",buttonCancelBorderColor:"#E3E4E8",cappingCount:3,cappingDelay:144e5,backgroundColor:"#FFFFFF"}},10:function(module,exports,__webpack_require__){"use strict";function getGlobal(){return"undefined"!=typeof globalThis?globalThis:Function("return this")()}Object.defineProperty(exports,"__esModule",{value:!0}),exports.generateUUID=exports.clearLocationHash=exports.patchConsole=exports.parseSerializedNotificationParams=exports.getVersion=exports.getGlobal=void 0,exports.getGlobal=getGlobal,exports.getVersion=function(){return"3.28.0"},exports.parseSerializedNotificationParams=function(param,defaultValue){if("string"==typeof param)try{return JSON.parse(param)}catch(e){console.log(e)}return void 0===param&&void 0!==defaultValue?defaultValue:param},exports.patchConsole=function(){for(var method,noop=function(){},methods=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],len=methods.length,global=getGlobal(),console=global.console=global.console||{};len--;)console[method=methods[len]]||(console[method]=noop)},exports.clearLocationHash=function(){"history"in getGlobal()&&history.pushState?history.pushState(null,"","#"):location.hash="#"},exports.generateUUID=function(){var d=(new Date).getTime();return"undefined"!=typeof performance&&"function"==typeof performance.now&&(d+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(c){var r=(d+16*Math.random())%16|0;return d=Math.floor(d/16),("x"===c?r:3&r|8).toString(16)})}},13:function(module,exports,__webpack_require__){var v1=__webpack_require__(30),v4=__webpack_require__(31),uuid=v4;uuid.v1=v1,uuid.v4=v4,module.exports=uuid},155:function(module,exports,__webpack_require__){"use strict";var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):function(value){return value instanceof P?value:new P(function(resolve){resolve(value)})}(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})},__generator=this&&this.__generator||function(thisArg,body){var f,y,t,g,_={label:0,sent:function(){if(1&t[0])throw t[1];return t[1]},trys:[],ops:[]};return g={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return function(op){if(f)throw new TypeError("Generator is already executing.");for(;_;)try{if(f=1,y&&(t=2&op[0]?y.return:op[0]?y.throw||((t=y.return)&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;switch(y=0,t&&(op=[2&op[0],t.value]),op[0]){case 0:case 1:t=op;break;case 4:return _.label++,{value:op[1],done:!1};case 5:_.label++,y=op[1],op=[0];continue;case 7:op=_.ops.pop(),_.trys.pop();continue;default:if(!(t=(t=_.trys).length>0&&t[t.length-1])&&(6===op[0]||2===op[0])){_=0;continue}if(3===op[0]&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(6===op[0]&&_.label<t[1]){_.label=t[1],t=op;break}if(t&&_.label<t[2]){_.label=t[2],_.ops.push(op);break}t[2]&&_.ops.pop(),_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e],y=0}finally{f=t=0}if(5&op[0])throw op[1];return{value:op[0]?op[1]:void 0,done:!0}}([n,v])}}};Object.defineProperty(exports,"__esModule",{value:!0});var EventBus_1=__webpack_require__(32),Data_1=__webpack_require__(4),Api_1=__webpack_require__(34),PushServiceDefault_1=__webpack_require__(38),logger_1=__webpack_require__(156),storage_1=__webpack_require__(5),constants_1=__webpack_require__(1),functions_1=__webpack_require__(10),logger_2=__webpack_require__(3),global_1=__webpack_require__(158),notification_1=__webpack_require__(159),NotificationPayload_1=__webpack_require__(160),InboxMessages_1=__webpack_require__(45),InboxMessagesPublic_1=__webpack_require__(25),eventBus=new EventBus_1.EventBus,data=new Data_1.Data,api=new Api_1.Api(eventBus,data),Pushwoosh=self.Pushwoosh=new global_1.default(eventBus,data,api),clickedNotifications=[];function broadcastClients(msg){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:return[4,self.clients.matchAll()];case 1:return _a.sent().forEach(function(client){return client.postMessage(msg)}),[2]}})})}function parseNotificationEvent(event){return __awaiter(this,void 0,void 0,function(){var _a,notification,notificationData,notificationTag,url,button;return __generator(this,function(_b){return _a=event.notification,notificationData=(notification=void 0===_a?{}:_a).data,notificationTag=functions_1.parseSerializedNotificationParams(notification.tag,{}),url="",event.action&&Array.isArray(notificationData.buttons)?(button=notificationData.buttons.find(function(button){return button.action===event.action})||{},url=button.url):url=notificationTag.url,[2,{requireInteraction:notification.requireInteraction,title:notification.title,body:notification.body,icon:notification.icon,buttons:notificationData.buttons,duration:notificationData.duration,image:notificationData.image,code:notificationData.code,campaignCode:notificationData.campaignCode,inboxId:notificationData.inboxId,messageHash:notificationTag.messageHash,customData:notificationTag.customData,metaData:notificationTag.metaData,openUrl:notificationTag.url,tag:notification.tag,url:url}]})})}function onInstallFailure(error){return __awaiter(this,void 0,void 0,function(){var applicationCode,workerVersion;return __generator(this,function(_a){switch(_a.label){case 0:return[4,Pushwoosh.data.getApplicationCode()];case 1:return applicationCode=_a.sent(),[4,Pushwoosh.data.getServiceWorkerVersion()];case 2:return workerVersion=_a.sent(),[4,logger_1.sendFatalLogToRemoteServer({message:"Error in onInstallEventHandler",code:"FATAL-SW-001",error:error,applicationCode:applicationCode,workerVersion:workerVersion})];case 3:return _a.sent(),[2]}})})}function onActivateFailure(error){return __awaiter(this,void 0,void 0,function(){var applicationCode,workerVersion;return __generator(this,function(_a){switch(_a.label){case 0:return[4,Pushwoosh.data.getApplicationCode()];case 1:return applicationCode=_a.sent(),[4,Pushwoosh.data.getServiceWorkerVersion()];case 2:return workerVersion=_a.sent(),[4,logger_1.sendFatalLogToRemoteServer({message:"Error in onActivateEventHandler",code:"FATAL-SW-002",error:error,applicationCode:applicationCode,workerVersion:workerVersion})];case 3:return _a.sent(),[2]}})})}function onClickNotificationFailure(error){return __awaiter(this,void 0,void 0,function(){var applicationCode,workerVersion;return __generator(this,function(_a){switch(_a.label){case 0:return[4,Pushwoosh.data.getApplicationCode()];case 1:return applicationCode=_a.sent(),[4,Pushwoosh.data.getServiceWorkerVersion()];case 2:return workerVersion=_a.sent(),[4,logger_1.sendFatalLogToRemoteServer({message:"Error in onNotificationClickEventHandler",code:"FATAL-SW-004",error:error,applicationCode:applicationCode,workerVersion:workerVersion})];case 3:return _a.sent(),[2]}})})}function closeNotificationFailure(error){return __awaiter(this,void 0,void 0,function(){var applicationCode,workerVersion;return __generator(this,function(_a){switch(_a.label){case 0:return[4,Pushwoosh.data.getApplicationCode()];case 1:return applicationCode=_a.sent(),[4,Pushwoosh.data.getServiceWorkerVersion()];case 2:return workerVersion=_a.sent(),[4,logger_1.sendFatalLogToRemoteServer({message:"Error in onNotificationCloseEventHandler",code:"FATAL-SW-005",error:error,applicationCode:applicationCode,workerVersion:workerVersion})];case 3:return _a.sent(),[2]}})})}function pushSubscriptionChangeFailure(error){return __awaiter(this,void 0,void 0,function(){var applicationCode,workerVersion;return __generator(this,function(_a){switch(_a.label){case 0:return[4,Pushwoosh.data.getApplicationCode()];case 1:return applicationCode=_a.sent(),[4,Pushwoosh.data.getServiceWorkerVersion()];case 2:return workerVersion=_a.sent(),[4,logger_1.sendFatalLogToRemoteServer({message:"Error in onPushSubscriptionChange",code:"FATAL-SW-006",error:error,applicationCode:applicationCode,workerVersion:workerVersion})];case 3:return _a.sent(),[2]}})})}self.addEventListener("install",function(event){return event.waitUntil(function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:return[4,Promise.all([Pushwoosh.data.setServiceWorkerVersion("3.28.0"),logger_2.Logger.write("info","install")])];case 1:return _a.sent(),[4,self.skipWaiting()];case 2:return _a.sent(),[2]}})})}().catch(onInstallFailure))}),self.addEventListener("activate",function(event){event.waitUntil(function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:return[4,Promise.all([logger_2.Logger.write("info","activate")])];case 1:return _a.sent(),[4,self.clients.claim()];case 2:return _a.sent(),[2]}})})}().catch(onActivateFailure))}),self.addEventListener("push",function(event){event.waitUntil(function(event){return __awaiter(this,void 0,void 0,function(){var payload,notificationPayload,notificationOptions,notificationShowOptions,messageHash,notification,_a,_b,onPushActions,inboxMessages,inboxMessagesPublic,inboxMessagePayload,payload_1;return __generator(this,function(_c){switch(_c.label){case 0:return[4,self.clients.claim()];case 1:return _c.sent(),[4,event.data.json()];case 2:return payload=_c.sent(),[4,(notificationPayload=new NotificationPayload_1.default(payload)).getNotificationOptionsPayload()];case 3:return notificationOptions=_c.sent(),[4,notificationPayload.getShowNotificationOptions()];case 4:return notificationShowOptions=_c.sent(),messageHash=notificationPayload.messageHash,[4,logger_2.Logger.write("info",JSON.stringify(notificationOptions),"onPush")];case 5:return _c.sent(),_a=notification_1.default.bind,_b=[void 0,notificationShowOptions,notificationPayload.duration,notificationPayload.body],[4,notificationPayload.getTitle()];case 6:return notification=new(_a.apply(notification_1.default,_b.concat([_c.sent()]))),[4,Pushwoosh.getListeners("onPush").reduce(function(pr,fun){return pr.then(function(){return fun(notification)})},Promise.resolve())];case 7:return _c.sent(),onPushActions=[notification.show(),storage_1.message.add({payload:payload,parsedPayload:notificationOptions,showOptions:notificationShowOptions}),broadcastClients({type:constants_1.EVENT_ON_PUSH_DELIVERY,payload:notificationOptions})],messageHash&&onPushActions.push(Pushwoosh.initApi().then(function(){return Pushwoosh.api.messageDeliveryEvent(messageHash,!0,notificationOptions.metaData)})),""===notificationPayload.inboxId?[3,10]:(inboxMessages=new InboxMessages_1.default(Pushwoosh.eventBus,Pushwoosh.data,Pushwoosh.api),inboxMessagesPublic=new InboxMessagesPublic_1.default(Pushwoosh.data,Pushwoosh.api,inboxMessages),[4,notificationPayload.getInboxMessage()]);case 8:return inboxMessagePayload=_c.sent(),[4,inboxMessagesPublic.publicMessageBuilder(inboxMessagePayload)];case 9:payload_1=_c.sent(),onPushActions.push(inboxMessages.putMessage(inboxMessagePayload),broadcastClients({type:constants_1.EVENT_ON_PUT_NEW_MESSAGE_TO_INBOX_STORE,payload:payload_1})),_c.label=10;case 10:return[4,Promise.all(onPushActions)];case 11:return _c.sent(),[2]}})})}(event).catch(function(error){return function(error,event){return __awaiter(this,void 0,void 0,function(){var applicationCode,workerVersion;return __generator(this,function(_a){switch(_a.label){case 0:return[4,Pushwoosh.data.getApplicationCode()];case 1:return applicationCode=_a.sent(),[4,Pushwoosh.data.getServiceWorkerVersion()];case 2:return workerVersion=_a.sent(),[4,logger_1.sendFatalLogToRemoteServer({message:"Error in onPushEventHandler",code:"FATAL-SW-003",error:error,applicationCode:applicationCode,workerVersion:workerVersion})];case 3:return _a.sent(),error instanceof Error||(error=new Error(error)),[2,storage_1.message.add({error:""+error,stack:error.stack,payload:event.data&&event.data.text()})]}})})}(error,event)}))}),self.addEventListener("notificationclick",function(event){event.waitUntil(function(event){return __awaiter(this,void 0,void 0,function(){var notificationOptions,messageHash,metaData,url,code,inboxId,inboxMessages,message_1,message;return __generator(this,function(_a){switch(_a.label){case 0:return[4,self.clients.claim()];case 1:return _a.sent(),[4,parseNotificationEvent(event)];case 2:return notificationOptions=_a.sent(),messageHash=notificationOptions.messageHash,metaData=notificationOptions.metaData,url=notificationOptions.url,code=notificationOptions.code,inboxId=notificationOptions.inboxId,code&&clickedNotifications.push(code),""===inboxId?[3,5]:[4,(inboxMessages=new InboxMessages_1.default(Pushwoosh.eventBus,Pushwoosh.data,Pushwoosh.api)).getMessage(inboxId)];case 3:return(message_1=_a.sent()).status=3,[4,inboxMessages.putMessage(message_1)];case 4:_a.sent(),_a.label=5;case 5:return event.notification.close(),message={type:constants_1.EVENT_ON_NOTIFICATION_CLICK,payload:notificationOptions},url&&event.waitUntil(self.clients.matchAll({type:"window"}).then(function(windowClients){return function(windowClients,url){return __awaiter(this,void 0,void 0,function(){var _a,openedHostname,openedPathname,clientWithSameAddress;return __generator(this,function(_b){switch(_b.label){case 0:return _a=new URL(url,self.location.origin),openedHostname=_a.hostname,openedPathname=_a.pathname,(clientWithSameAddress=windowClients.find(function(windowClient){var _a=new URL(windowClient.url),windowClientHostname=_a.hostname,windowClientPathname=_a.pathname;return windowClientHostname===openedHostname&&windowClientPathname===openedPathname}))?[4,clientWithSameAddress.focus()]:[3,2];case 1:return _b.sent(),[2,!1];case 2:return[4,self.clients.openWindow(url).then(function(newClientWindow){newClientWindow&&newClientWindow.focus()})];case 3:return _b.sent(),[2,!0]}})})}(windowClients,url)}).then(function(isFocusOnNewWindowClient){isFocusOnNewWindowClient&&Pushwoosh.data.setDelayedEvent(message)})),[2,Promise.all([Pushwoosh.initApi().then(function(){return Pushwoosh.api.pushStat(messageHash,!0,metaData)}),Pushwoosh.data.setLastOpenMessage({url:url,messageHash:messageHash,expiry:Date.now()+constants_1.PERIOD_GOAL_EVENT}),broadcastClients(message)])]}})})}(event).catch(onClickNotificationFailure))}),self.addEventListener("notificationclose",function(event){event.waitUntil(function(event){return __awaiter(this,void 0,void 0,function(){var notificationOptions,code,index;return __generator(this,function(_a){switch(_a.label){case 0:return[4,self.clients.claim()];case 1:return _a.sent(),[4,parseNotificationEvent(event)];case 2:return notificationOptions=_a.sent(),code=notificationOptions.code,event.notification.close(),code?(index=clickedNotifications.indexOf(code))>=0?(clickedNotifications.splice(index,1),[2]):[2,broadcastClients({type:constants_1.EVENT_ON_NOTIFICATION_CLOSE,payload:notificationOptions})]:[2]}})})}(event).catch(closeNotificationFailure))}),self.addEventListener("pushsubscriptionchange",function(event){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){return event.waitUntil(function(event){return __awaiter(this,void 0,void 0,function(){var subscription;return __generator(this,function(_a){switch(_a.label){case 0:return(subscription=event.newSubscription)?[3,2]:[4,self.registration.pushManager.getSubscription()];case 1:if(!(subscription=_a.sent()))return[2];_a.label=2;case 2:return[4,new PushServiceDefault_1.PushServiceDefault(api,data,{}).subscribe(subscription)];case 3:return _a.sent(),[2]}})})}(event).catch(pushSubscriptionChangeFailure)),[2]})})})},156:function(module,exports,__webpack_require__){"use strict";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++)for(var p in s=arguments[i])Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p]);return t}).apply(this,arguments)},__awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):function(value){return value instanceof P?value:new P(function(resolve){resolve(value)})}(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})},__generator=this&&this.__generator||function(thisArg,body){var f,y,t,g,_={label:0,sent:function(){if(1&t[0])throw t[1];return t[1]},trys:[],ops:[]};return g={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return function(op){if(f)throw new TypeError("Generator is already executing.");for(;_;)try{if(f=1,y&&(t=2&op[0]?y.return:op[0]?y.throw||((t=y.return)&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;switch(y=0,t&&(op=[2&op[0],t.value]),op[0]){case 0:case 1:t=op;break;case 4:return _.label++,{value:op[1],done:!1};case 5:_.label++,y=op[1],op=[0];continue;case 7:op=_.ops.pop(),_.trys.pop();continue;default:if(!(t=(t=_.trys).length>0&&t[t.length-1])&&(6===op[0]||2===op[0])){_=0;continue}if(3===op[0]&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(6===op[0]&&_.label<t[1]){_.label=t[1],t=op;break}if(t&&_.label<t[2]){_.label=t[2],_.ops.push(op);break}t[2]&&_.ops.pop(),_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e],y=0}finally{f=t=0}if(5&op[0])throw op[1];return{value:op[0]?op[1]:void 0,done:!0}}([n,v])}}},__rest=this&&this.__rest||function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(null!=s&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]])}return t};Object.defineProperty(exports,"__esModule",{value:!0}),exports.sendErrorLogToRemoteServer=exports.sendFatalLogToRemoteServer=exports.logger=void 0;var logger_1=__webpack_require__(157),logger=new logger_1.Logger({level:"error",subscribers:[{level:"fatal",handler:logger_1.handlerSematext},{level:"error",handler:logger_1.handlerSematext}]});function makeMessage(params){var message=params.message,code=params.code,error=params.error,data=__rest(params,["message","code","error"]),cleanError=function(error){var cleanError=new Error("unknown error");"string"!=typeof error&&"number"!=typeof error&&"boolean"!=typeof error||(cleanError.message=error.toString());error instanceof Error&&(cleanError=error);return cleanError}(error);return{text:message,code:code,options:__assign(__assign({},data),{errorText:cleanError.message,errorStack:cleanError.stack})}}exports.logger=logger,exports.sendFatalLogToRemoteServer=function(params){return __awaiter(this,void 0,void 0,function(){var message;return __generator(this,function(_a){return message=makeMessage(params),[2,logger.fatal(message.text,message.code,message.options)]})})},exports.sendErrorLogToRemoteServer=function(params){return __awaiter(this,void 0,void 0,function(){var message;return __generator(this,function(_a){return message=makeMessage(params),[2,logger.error(message.text,message.code,message.options)]})})}},157:function(module,exports){module.exports=function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{enumerable:!0,get:getter})},__webpack_require__.r=function(exports){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(exports,"__esModule",{value:!0})},__webpack_require__.t=function(value,mode){if(1&mode&&(value=__webpack_require__(value)),8&mode)return value;if(4&mode&&"object"==typeof value&&value&&value.__esModule)return value;var ns=Object.create(null);if(__webpack_require__.r(ns),Object.defineProperty(ns,"default",{enumerable:!0,value:value}),2&mode&&"string"!=typeof value)for(var key in value)__webpack_require__.d(ns,key,function(key){return value[key]}.bind(null,key));return ns},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=4)}([function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,"__extends",function(){return __extends}),__webpack_require__.d(__webpack_exports__,"__assign",function(){return __assign}),__webpack_require__.d(__webpack_exports__,"__rest",function(){return __rest}),__webpack_require__.d(__webpack_exports__,"__decorate",function(){return __decorate}),__webpack_require__.d(__webpack_exports__,"__param",function(){return __param}),__webpack_require__.d(__webpack_exports__,"__metadata",function(){return __metadata}),__webpack_require__.d(__webpack_exports__,"__awaiter",function(){return __awaiter}),__webpack_require__.d(__webpack_exports__,"__generator",function(){return __generator}),__webpack_require__.d(__webpack_exports__,"__exportStar",function(){return __exportStar}),__webpack_require__.d(__webpack_exports__,"__values",function(){return __values}),__webpack_require__.d(__webpack_exports__,"__read",function(){return __read}),__webpack_require__.d(__webpack_exports__,"__spread",function(){return __spread}),__webpack_require__.d(__webpack_exports__,"__await",function(){return __await}),__webpack_require__.d(__webpack_exports__,"__asyncGenerator",function(){return __asyncGenerator}),__webpack_require__.d(__webpack_exports__,"__asyncDelegator",function(){return __asyncDelegator}),__webpack_require__.d(__webpack_exports__,"__asyncValues",function(){return __asyncValues}),__webpack_require__.d(__webpack_exports__,"__makeTemplateObject",function(){return __makeTemplateObject}),__webpack_require__.d(__webpack_exports__,"__importStar",function(){return __importStar}),__webpack_require__.d(__webpack_exports__,"__importDefault",function(){return __importDefault});
1
+ !function(root,factory){if("object"==typeof exports&&"object"==typeof module)module.exports=factory();else if("function"==typeof define&&define.amd)define([],factory);else{var a=factory();for(var i in a)("object"==typeof exports?exports:root)[i]=a[i]}}(this,function(){return function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.r=function(exports){Object.defineProperty(exports,"__esModule",{value:!0})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=155)}({1:function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SUBSCRIPTION_PROMPT_WIDGET_DEFAULT_CONFIG=exports.SUBSCRIPTION_WIDGET_USE_CASE_TOPIC_BASED=exports.SUBSCRIPTION_WIDGET_USE_CASE_DEFAULT=exports.SUBSCRIPTION_WIDGET_USE_CASE_NOT_SET=exports.SUBSCRIPTION_SEGMENT_EVENT=exports.PAGE_VISITED_URL=exports.MANUAL_UNSUBSCRIBE=exports.EVENT_PW_SITE_OPENED=exports.EVENT_GDPR_DELETE=exports.EVENT_GDPR_CONSENT=exports.EVENT_CLICK_SUBSCRIBE_BUTTON=exports.EVENT_SHOW_SUBSCRIBE_BUTTON=exports.EVENT_ON_HIDE_SUBSCRIPTION_WIDGET=exports.EVENT_ON_SHOW_SUBSCRIPTION_WIDGET=exports.EVENT_ON_HIDE_NOTIFICATION_PERMISSION_DIALOG=exports.EVENT_ON_SHOW_NOTIFICATION_PERMISSION_DIALOG=exports.EVENT_ON_UPDATE_INBOX_MESSAGES=exports.EVENT_ON_PUT_NEW_MESSAGE_TO_INBOX_STORE=exports.EVENT_ON_CHANGE_COMMUNICATION_ENABLED=exports.EVENT_ON_NOTIFICATION_CLOSE=exports.EVENT_ON_NOTIFICATION_CLICK=exports.EVENT_ON_PUSH_DELIVERY=exports.EVENT_ON_SW_INIT_ERROR=exports.EVENT_ON_PERMISSION_GRANTED=exports.EVENT_ON_PERMISSION_DENIED=exports.EVENT_ON_PERMISSION_PROMPT=exports.EVENT_ON_REGISTER=exports.EVENT_ON_UNSUBSCRIBE=exports.EVENT_ON_SUBSCRIBE=exports.EVENT_ON_READY=exports.EVENT_ON_LOAD=exports.PERMISSION_PROMPT=exports.PERMISSION_GRANTED=exports.PERMISSION_DENIED=exports.DEVICE_REGISTRATION_STATUS_UNREGISTERED=exports.DEVICE_REGISTRATION_STATUS_REGISTERED=exports.MANUAL_SET_LOGGER_LEVEL=exports.KEY_SAFARI_PREVIOUS_PERMISSION=exports.KEY_DEVICE_REGISTRATION_STATUS=exports.KEY_CLICK_SUBSCRIBE_WIDGET=exports.KEY_SHOW_SUBSCRIBE_WIDGET=exports.DEFAULT_NOTIFICATION_IMAGE=exports.DEFAULT_NOTIFICATION_TITLE=exports.WAKE_UP_SERVICE_WORKER_INTERVAL=exports.MAX_NOTIFICATION_DURATION=exports.MIN_NOTIFICATION_DURATION=exports.DEFAULT_NOTIFICATION_DURATION=exports.PERIOD_GOAL_EVENT=exports.PERIOD_SEND_APP_OPEN=exports.FACEBOOK_HWID_KEY=exports.FACEBOOK_APP_ID=exports.DEFAULT_API_URL=exports.DEFAULT_SERVICE_WORKER_URL=void 0,exports.DEFAULT_SERVICE_WORKER_URL="/pushwoosh-service-worker.js",exports.DEFAULT_API_URL="https://cp.pushwoosh.com/json/1.3/",exports.FACEBOOK_APP_ID="436711767081797",exports.FACEBOOK_HWID_KEY="FACEBOOK_HWID_KEY",exports.PERIOD_SEND_APP_OPEN=36e5,exports.PERIOD_GOAL_EVENT=864e5,exports.DEFAULT_NOTIFICATION_DURATION=10,exports.MIN_NOTIFICATION_DURATION=10,exports.MAX_NOTIFICATION_DURATION=55,exports.WAKE_UP_SERVICE_WORKER_INTERVAL=20,exports.DEFAULT_NOTIFICATION_TITLE="Pushwoosh notification",exports.DEFAULT_NOTIFICATION_IMAGE="https://cp.pushwoosh.com/img/logo-medium.png",exports.KEY_SHOW_SUBSCRIBE_WIDGET="WIDGET_SHOWED",exports.KEY_CLICK_SUBSCRIBE_WIDGET="WIDGET_CLICKED",exports.KEY_DEVICE_REGISTRATION_STATUS="deviceRegistrationStatus",exports.KEY_SAFARI_PREVIOUS_PERMISSION="safariPreviousPermission",exports.MANUAL_SET_LOGGER_LEVEL="PW_SET_LOGGER_LEVEL",exports.DEVICE_REGISTRATION_STATUS_REGISTERED="registered",exports.DEVICE_REGISTRATION_STATUS_UNREGISTERED="unregistered",exports.PERMISSION_DENIED="denied",exports.PERMISSION_GRANTED="granted",exports.PERMISSION_PROMPT="default",exports.EVENT_ON_LOAD="onLoad",exports.EVENT_ON_READY="onReady",exports.EVENT_ON_SUBSCRIBE="onSubscribe",exports.EVENT_ON_UNSUBSCRIBE="onUnsubscribe",exports.EVENT_ON_REGISTER="onRegister",exports.EVENT_ON_PERMISSION_PROMPT="onPermissionPrompt",exports.EVENT_ON_PERMISSION_DENIED="onPermissionDenied",exports.EVENT_ON_PERMISSION_GRANTED="onPermissionGranted",exports.EVENT_ON_SW_INIT_ERROR="onSWInitError",exports.EVENT_ON_PUSH_DELIVERY="onPushDelivery",exports.EVENT_ON_NOTIFICATION_CLICK="onNotificationClick",exports.EVENT_ON_NOTIFICATION_CLOSE="onNotificationClose",exports.EVENT_ON_CHANGE_COMMUNICATION_ENABLED="onChangeCommunicationEnabled",exports.EVENT_ON_PUT_NEW_MESSAGE_TO_INBOX_STORE="onPutNewMessageToInboxStore",exports.EVENT_ON_UPDATE_INBOX_MESSAGES="onUpdateInboxMessages",exports.EVENT_ON_SHOW_NOTIFICATION_PERMISSION_DIALOG="onShowNotificationPermissionDialog",exports.EVENT_ON_HIDE_NOTIFICATION_PERMISSION_DIALOG="onHideNotificationPermissionDialog",exports.EVENT_ON_SHOW_SUBSCRIPTION_WIDGET="onShowSubscriptionWidget",exports.EVENT_ON_HIDE_SUBSCRIPTION_WIDGET="onHideSubscriptionWidget",exports.EVENT_SHOW_SUBSCRIBE_BUTTON="showSubscribeButton",exports.EVENT_CLICK_SUBSCRIBE_BUTTON="clickSubscribeButton",exports.EVENT_GDPR_CONSENT="GDPRConsent",exports.EVENT_GDPR_DELETE="GDPRDelete",exports.EVENT_PW_SITE_OPENED="PW_SiteOpened",exports.MANUAL_UNSUBSCRIBE="MANUAL_UNSUBSCRIBE",exports.PAGE_VISITED_URL="PAGE_VISITED_URL",exports.SUBSCRIPTION_SEGMENT_EVENT="Subscription Segments",exports.SUBSCRIPTION_WIDGET_USE_CASE_NOT_SET="not-set",exports.SUBSCRIPTION_WIDGET_USE_CASE_DEFAULT="default",exports.SUBSCRIPTION_WIDGET_USE_CASE_TOPIC_BASED="topic-based",exports.SUBSCRIPTION_PROMPT_WIDGET_DEFAULT_CONFIG={headerText:"Subscribe to our news",headerTextColor:"#000000",subheaderText:"Don't miss out on the latest news and updates!",subheaderTextColor:"#000000",buttonAcceptText:"Agree",buttonAcceptTextColor:"#1A72E8",buttonAcceptRound:"4px",buttonAcceptBackgroundColor:"#FFFFFF",buttonAcceptBorderColor:"#E3E4E8",buttonCancelText:"Deny",buttonCancelTextColor:"#1A72E8",buttonCancelRound:"4px",buttonCancelBackgroundColor:"#FFFFFF",buttonCancelBorderColor:"#E3E4E8",cappingCount:3,cappingDelay:144e5,backgroundColor:"#FFFFFF"}},10:function(module,exports,__webpack_require__){"use strict";function getGlobal(){return"undefined"!=typeof globalThis?globalThis:Function("return this")()}Object.defineProperty(exports,"__esModule",{value:!0}),exports.generateUUID=exports.clearLocationHash=exports.patchConsole=exports.parseSerializedNotificationParams=exports.getVersion=exports.getGlobal=void 0,exports.getGlobal=getGlobal,exports.getVersion=function(){return"3.29.0"},exports.parseSerializedNotificationParams=function(param,defaultValue){if("string"==typeof param)try{return JSON.parse(param)}catch(e){console.log(e)}return void 0===param&&void 0!==defaultValue?defaultValue:param},exports.patchConsole=function(){for(var method,noop=function(){},methods=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],len=methods.length,global=getGlobal(),console=global.console=global.console||{};len--;)console[method=methods[len]]||(console[method]=noop)},exports.clearLocationHash=function(){"history"in getGlobal()&&history.pushState?history.pushState(null,"","#"):location.hash="#"},exports.generateUUID=function(){var d=(new Date).getTime();return"undefined"!=typeof performance&&"function"==typeof performance.now&&(d+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(c){var r=(d+16*Math.random())%16|0;return d=Math.floor(d/16),("x"===c?r:3&r|8).toString(16)})}},13:function(module,exports,__webpack_require__){var v1=__webpack_require__(30),v4=__webpack_require__(31),uuid=v4;uuid.v1=v1,uuid.v4=v4,module.exports=uuid},155:function(module,exports,__webpack_require__){"use strict";var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):function(value){return value instanceof P?value:new P(function(resolve){resolve(value)})}(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})},__generator=this&&this.__generator||function(thisArg,body){var f,y,t,g,_={label:0,sent:function(){if(1&t[0])throw t[1];return t[1]},trys:[],ops:[]};return g={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return function(op){if(f)throw new TypeError("Generator is already executing.");for(;_;)try{if(f=1,y&&(t=2&op[0]?y.return:op[0]?y.throw||((t=y.return)&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;switch(y=0,t&&(op=[2&op[0],t.value]),op[0]){case 0:case 1:t=op;break;case 4:return _.label++,{value:op[1],done:!1};case 5:_.label++,y=op[1],op=[0];continue;case 7:op=_.ops.pop(),_.trys.pop();continue;default:if(!(t=(t=_.trys).length>0&&t[t.length-1])&&(6===op[0]||2===op[0])){_=0;continue}if(3===op[0]&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(6===op[0]&&_.label<t[1]){_.label=t[1],t=op;break}if(t&&_.label<t[2]){_.label=t[2],_.ops.push(op);break}t[2]&&_.ops.pop(),_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e],y=0}finally{f=t=0}if(5&op[0])throw op[1];return{value:op[0]?op[1]:void 0,done:!0}}([n,v])}}};Object.defineProperty(exports,"__esModule",{value:!0});var EventBus_1=__webpack_require__(32),Data_1=__webpack_require__(4),Api_1=__webpack_require__(34),PushServiceDefault_1=__webpack_require__(38),logger_1=__webpack_require__(156),storage_1=__webpack_require__(5),constants_1=__webpack_require__(1),functions_1=__webpack_require__(10),logger_2=__webpack_require__(3),global_1=__webpack_require__(158),notification_1=__webpack_require__(159),NotificationPayload_1=__webpack_require__(160),InboxMessages_1=__webpack_require__(45),InboxMessagesPublic_1=__webpack_require__(25),eventBus=new EventBus_1.EventBus,data=new Data_1.Data,api=new Api_1.Api(eventBus,data),Pushwoosh=self.Pushwoosh=new global_1.default(eventBus,data,api),clickedNotifications=[];function broadcastClients(msg){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:return[4,self.clients.matchAll()];case 1:return _a.sent().forEach(function(client){return client.postMessage(msg)}),[2]}})})}function parseNotificationEvent(event){return __awaiter(this,void 0,void 0,function(){var _a,notification,notificationData,notificationTag,url,button;return __generator(this,function(_b){return _a=event.notification,notificationData=(notification=void 0===_a?{}:_a).data,notificationTag=functions_1.parseSerializedNotificationParams(notification.tag,{}),url="",event.action&&Array.isArray(notificationData.buttons)?(button=notificationData.buttons.find(function(button){return button.action===event.action})||{},url=button.url):url=notificationTag.url,[2,{requireInteraction:notification.requireInteraction,title:notification.title,body:notification.body,icon:notification.icon,buttons:notificationData.buttons,duration:notificationData.duration,image:notificationData.image,code:notificationData.code,campaignCode:notificationData.campaignCode,inboxId:notificationData.inboxId,messageHash:notificationTag.messageHash,customData:notificationTag.customData,metaData:notificationTag.metaData,openUrl:notificationTag.url,tag:notification.tag,url:url}]})})}function onInstallFailure(error){return __awaiter(this,void 0,void 0,function(){var applicationCode,workerVersion;return __generator(this,function(_a){switch(_a.label){case 0:return[4,Pushwoosh.data.getApplicationCode()];case 1:return applicationCode=_a.sent(),[4,Pushwoosh.data.getServiceWorkerVersion()];case 2:return workerVersion=_a.sent(),[4,logger_1.sendFatalLogToRemoteServer({message:"Error in onInstallEventHandler",code:"FATAL-SW-001",error:error,applicationCode:applicationCode,workerVersion:workerVersion})];case 3:return _a.sent(),[2]}})})}function onActivateFailure(error){return __awaiter(this,void 0,void 0,function(){var applicationCode,workerVersion;return __generator(this,function(_a){switch(_a.label){case 0:return[4,Pushwoosh.data.getApplicationCode()];case 1:return applicationCode=_a.sent(),[4,Pushwoosh.data.getServiceWorkerVersion()];case 2:return workerVersion=_a.sent(),[4,logger_1.sendFatalLogToRemoteServer({message:"Error in onActivateEventHandler",code:"FATAL-SW-002",error:error,applicationCode:applicationCode,workerVersion:workerVersion})];case 3:return _a.sent(),[2]}})})}function onClickNotificationFailure(error){return __awaiter(this,void 0,void 0,function(){var applicationCode,workerVersion;return __generator(this,function(_a){switch(_a.label){case 0:return[4,Pushwoosh.data.getApplicationCode()];case 1:return applicationCode=_a.sent(),[4,Pushwoosh.data.getServiceWorkerVersion()];case 2:return workerVersion=_a.sent(),[4,logger_1.sendFatalLogToRemoteServer({message:"Error in onNotificationClickEventHandler",code:"FATAL-SW-004",error:error,applicationCode:applicationCode,workerVersion:workerVersion})];case 3:return _a.sent(),[2]}})})}function closeNotificationFailure(error){return __awaiter(this,void 0,void 0,function(){var applicationCode,workerVersion;return __generator(this,function(_a){switch(_a.label){case 0:return[4,Pushwoosh.data.getApplicationCode()];case 1:return applicationCode=_a.sent(),[4,Pushwoosh.data.getServiceWorkerVersion()];case 2:return workerVersion=_a.sent(),[4,logger_1.sendFatalLogToRemoteServer({message:"Error in onNotificationCloseEventHandler",code:"FATAL-SW-005",error:error,applicationCode:applicationCode,workerVersion:workerVersion})];case 3:return _a.sent(),[2]}})})}function pushSubscriptionChangeFailure(error){return __awaiter(this,void 0,void 0,function(){var applicationCode,workerVersion;return __generator(this,function(_a){switch(_a.label){case 0:return[4,Pushwoosh.data.getApplicationCode()];case 1:return applicationCode=_a.sent(),[4,Pushwoosh.data.getServiceWorkerVersion()];case 2:return workerVersion=_a.sent(),[4,logger_1.sendFatalLogToRemoteServer({message:"Error in onPushSubscriptionChange",code:"FATAL-SW-006",error:error,applicationCode:applicationCode,workerVersion:workerVersion})];case 3:return _a.sent(),[2]}})})}self.addEventListener("install",function(event){return event.waitUntil(function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:return[4,Promise.all([Pushwoosh.data.setServiceWorkerVersion("3.29.0"),logger_2.Logger.write("info","install")])];case 1:return _a.sent(),[4,self.skipWaiting()];case 2:return _a.sent(),[2]}})})}().catch(onInstallFailure))}),self.addEventListener("activate",function(event){event.waitUntil(function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:return[4,Promise.all([logger_2.Logger.write("info","activate")])];case 1:return _a.sent(),[4,self.clients.claim()];case 2:return _a.sent(),[2]}})})}().catch(onActivateFailure))}),self.addEventListener("push",function(event){event.waitUntil(function(event){return __awaiter(this,void 0,void 0,function(){var payload,notificationPayload,notificationOptions,notificationShowOptions,messageHash,notification,_a,_b,onPushActions,inboxMessages,inboxMessagesPublic,inboxMessagePayload,payload_1;return __generator(this,function(_c){switch(_c.label){case 0:return[4,self.clients.claim()];case 1:return _c.sent(),[4,event.data.json()];case 2:return payload=_c.sent(),[4,(notificationPayload=new NotificationPayload_1.default(payload)).getNotificationOptionsPayload()];case 3:return notificationOptions=_c.sent(),[4,notificationPayload.getShowNotificationOptions()];case 4:return notificationShowOptions=_c.sent(),messageHash=notificationPayload.messageHash,[4,logger_2.Logger.write("info",JSON.stringify(notificationOptions),"onPush")];case 5:return _c.sent(),_a=notification_1.default.bind,_b=[void 0,notificationShowOptions,notificationPayload.duration,notificationPayload.body],[4,notificationPayload.getTitle()];case 6:return notification=new(_a.apply(notification_1.default,_b.concat([_c.sent()]))),[4,Pushwoosh.getListeners("onPush").reduce(function(pr,fun){return pr.then(function(){return fun(notification)})},Promise.resolve())];case 7:return _c.sent(),onPushActions=[notification.show(),storage_1.message.add({payload:payload,parsedPayload:notificationOptions,showOptions:notificationShowOptions}),broadcastClients({type:constants_1.EVENT_ON_PUSH_DELIVERY,payload:notificationOptions})],messageHash&&onPushActions.push(Pushwoosh.initApi().then(function(){return Pushwoosh.api.messageDeliveryEvent(messageHash,!0,notificationOptions.metaData)})),""===notificationPayload.inboxId?[3,10]:(inboxMessages=new InboxMessages_1.default(Pushwoosh.eventBus,Pushwoosh.data,Pushwoosh.api),inboxMessagesPublic=new InboxMessagesPublic_1.default(Pushwoosh.data,Pushwoosh.api,inboxMessages),[4,notificationPayload.getInboxMessage()]);case 8:return inboxMessagePayload=_c.sent(),[4,inboxMessagesPublic.publicMessageBuilder(inboxMessagePayload)];case 9:payload_1=_c.sent(),onPushActions.push(inboxMessages.putMessage(inboxMessagePayload),broadcastClients({type:constants_1.EVENT_ON_PUT_NEW_MESSAGE_TO_INBOX_STORE,payload:payload_1})),_c.label=10;case 10:return[4,Promise.all(onPushActions)];case 11:return _c.sent(),[2]}})})}(event).catch(function(error){return function(error,event){return __awaiter(this,void 0,void 0,function(){var applicationCode,workerVersion;return __generator(this,function(_a){switch(_a.label){case 0:return[4,Pushwoosh.data.getApplicationCode()];case 1:return applicationCode=_a.sent(),[4,Pushwoosh.data.getServiceWorkerVersion()];case 2:return workerVersion=_a.sent(),[4,logger_1.sendFatalLogToRemoteServer({message:"Error in onPushEventHandler",code:"FATAL-SW-003",error:error,applicationCode:applicationCode,workerVersion:workerVersion})];case 3:return _a.sent(),error instanceof Error||(error=new Error(error)),[2,storage_1.message.add({error:""+error,stack:error.stack,payload:event.data&&event.data.text()})]}})})}(error,event)}))}),self.addEventListener("notificationclick",function(event){event.waitUntil(function(event){return __awaiter(this,void 0,void 0,function(){var notificationOptions,messageHash,metaData,url,code,inboxId,inboxMessages,message_1,message;return __generator(this,function(_a){switch(_a.label){case 0:return[4,self.clients.claim()];case 1:return _a.sent(),[4,parseNotificationEvent(event)];case 2:return notificationOptions=_a.sent(),messageHash=notificationOptions.messageHash,metaData=notificationOptions.metaData,url=notificationOptions.url,code=notificationOptions.code,inboxId=notificationOptions.inboxId,code&&clickedNotifications.push(code),""===inboxId?[3,5]:[4,(inboxMessages=new InboxMessages_1.default(Pushwoosh.eventBus,Pushwoosh.data,Pushwoosh.api)).getMessage(inboxId)];case 3:return(message_1=_a.sent()).status=3,[4,inboxMessages.putMessage(message_1)];case 4:_a.sent(),_a.label=5;case 5:return event.notification.close(),message={type:constants_1.EVENT_ON_NOTIFICATION_CLICK,payload:notificationOptions},url&&event.waitUntil(self.clients.matchAll({type:"window"}).then(function(windowClients){return function(windowClients,url){return __awaiter(this,void 0,void 0,function(){var _a,openedHostname,openedPathname,clientWithSameAddress;return __generator(this,function(_b){switch(_b.label){case 0:return _a=new URL(url,self.location.origin),openedHostname=_a.hostname,openedPathname=_a.pathname,(clientWithSameAddress=windowClients.find(function(windowClient){var _a=new URL(windowClient.url),windowClientHostname=_a.hostname,windowClientPathname=_a.pathname;return windowClientHostname===openedHostname&&windowClientPathname===openedPathname}))?[4,clientWithSameAddress.focus()]:[3,2];case 1:return _b.sent(),[2,!1];case 2:return[4,self.clients.openWindow(url).then(function(newClientWindow){newClientWindow&&newClientWindow.focus()})];case 3:return _b.sent(),[2,!0]}})})}(windowClients,url)}).then(function(isFocusOnNewWindowClient){isFocusOnNewWindowClient&&Pushwoosh.data.setDelayedEvent(message)})),[2,Promise.all([Pushwoosh.initApi().then(function(){return Pushwoosh.api.pushStat(messageHash,!0,metaData)}),Pushwoosh.data.setLastOpenMessage({url:url,messageHash:messageHash,expiry:Date.now()+constants_1.PERIOD_GOAL_EVENT}),broadcastClients(message)])]}})})}(event).catch(onClickNotificationFailure))}),self.addEventListener("notificationclose",function(event){event.waitUntil(function(event){return __awaiter(this,void 0,void 0,function(){var notificationOptions,code,index;return __generator(this,function(_a){switch(_a.label){case 0:return[4,self.clients.claim()];case 1:return _a.sent(),[4,parseNotificationEvent(event)];case 2:return notificationOptions=_a.sent(),code=notificationOptions.code,event.notification.close(),code?(index=clickedNotifications.indexOf(code))>=0?(clickedNotifications.splice(index,1),[2]):[2,broadcastClients({type:constants_1.EVENT_ON_NOTIFICATION_CLOSE,payload:notificationOptions})]:[2]}})})}(event).catch(closeNotificationFailure))}),self.addEventListener("pushsubscriptionchange",function(event){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){return event.waitUntil(function(event){return __awaiter(this,void 0,void 0,function(){var subscription;return __generator(this,function(_a){switch(_a.label){case 0:return(subscription=event.newSubscription)?[3,2]:[4,self.registration.pushManager.getSubscription()];case 1:if(!(subscription=_a.sent()))return[2];_a.label=2;case 2:return[4,new PushServiceDefault_1.PushServiceDefault(api,data,{}).subscribe(subscription)];case 3:return _a.sent(),[2]}})})}(event).catch(pushSubscriptionChangeFailure)),[2]})})})},156:function(module,exports,__webpack_require__){"use strict";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++)for(var p in s=arguments[i])Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p]);return t}).apply(this,arguments)},__awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):function(value){return value instanceof P?value:new P(function(resolve){resolve(value)})}(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})},__generator=this&&this.__generator||function(thisArg,body){var f,y,t,g,_={label:0,sent:function(){if(1&t[0])throw t[1];return t[1]},trys:[],ops:[]};return g={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return function(op){if(f)throw new TypeError("Generator is already executing.");for(;_;)try{if(f=1,y&&(t=2&op[0]?y.return:op[0]?y.throw||((t=y.return)&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;switch(y=0,t&&(op=[2&op[0],t.value]),op[0]){case 0:case 1:t=op;break;case 4:return _.label++,{value:op[1],done:!1};case 5:_.label++,y=op[1],op=[0];continue;case 7:op=_.ops.pop(),_.trys.pop();continue;default:if(!(t=(t=_.trys).length>0&&t[t.length-1])&&(6===op[0]||2===op[0])){_=0;continue}if(3===op[0]&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(6===op[0]&&_.label<t[1]){_.label=t[1],t=op;break}if(t&&_.label<t[2]){_.label=t[2],_.ops.push(op);break}t[2]&&_.ops.pop(),_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e],y=0}finally{f=t=0}if(5&op[0])throw op[1];return{value:op[0]?op[1]:void 0,done:!0}}([n,v])}}},__rest=this&&this.__rest||function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(null!=s&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]])}return t};Object.defineProperty(exports,"__esModule",{value:!0}),exports.sendErrorLogToRemoteServer=exports.sendFatalLogToRemoteServer=exports.logger=void 0;var logger_1=__webpack_require__(157),logger=new logger_1.Logger({level:"error",subscribers:[{level:"fatal",handler:logger_1.handlerSematext},{level:"error",handler:logger_1.handlerSematext}]});function makeMessage(params){var message=params.message,code=params.code,error=params.error,data=__rest(params,["message","code","error"]),cleanError=function(error){var cleanError=new Error("unknown error");"string"!=typeof error&&"number"!=typeof error&&"boolean"!=typeof error||(cleanError.message=error.toString());error instanceof Error&&(cleanError=error);return cleanError}(error);return{text:message,code:code,options:__assign(__assign({},data),{errorText:cleanError.message,errorStack:cleanError.stack})}}exports.logger=logger,exports.sendFatalLogToRemoteServer=function(params){return __awaiter(this,void 0,void 0,function(){var message;return __generator(this,function(_a){return message=makeMessage(params),[2,logger.fatal(message.text,message.code,message.options)]})})},exports.sendErrorLogToRemoteServer=function(params){return __awaiter(this,void 0,void 0,function(){var message;return __generator(this,function(_a){return message=makeMessage(params),[2,logger.error(message.text,message.code,message.options)]})})}},157:function(module,exports){module.exports=function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{enumerable:!0,get:getter})},__webpack_require__.r=function(exports){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(exports,"__esModule",{value:!0})},__webpack_require__.t=function(value,mode){if(1&mode&&(value=__webpack_require__(value)),8&mode)return value;if(4&mode&&"object"==typeof value&&value&&value.__esModule)return value;var ns=Object.create(null);if(__webpack_require__.r(ns),Object.defineProperty(ns,"default",{enumerable:!0,value:value}),2&mode&&"string"!=typeof value)for(var key in value)__webpack_require__.d(ns,key,function(key){return value[key]}.bind(null,key));return ns},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=4)}([function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,"__extends",function(){return __extends}),__webpack_require__.d(__webpack_exports__,"__assign",function(){return __assign}),__webpack_require__.d(__webpack_exports__,"__rest",function(){return __rest}),__webpack_require__.d(__webpack_exports__,"__decorate",function(){return __decorate}),__webpack_require__.d(__webpack_exports__,"__param",function(){return __param}),__webpack_require__.d(__webpack_exports__,"__metadata",function(){return __metadata}),__webpack_require__.d(__webpack_exports__,"__awaiter",function(){return __awaiter}),__webpack_require__.d(__webpack_exports__,"__generator",function(){return __generator}),__webpack_require__.d(__webpack_exports__,"__exportStar",function(){return __exportStar}),__webpack_require__.d(__webpack_exports__,"__values",function(){return __values}),__webpack_require__.d(__webpack_exports__,"__read",function(){return __read}),__webpack_require__.d(__webpack_exports__,"__spread",function(){return __spread}),__webpack_require__.d(__webpack_exports__,"__await",function(){return __await}),__webpack_require__.d(__webpack_exports__,"__asyncGenerator",function(){return __asyncGenerator}),__webpack_require__.d(__webpack_exports__,"__asyncDelegator",function(){return __asyncDelegator}),__webpack_require__.d(__webpack_exports__,"__asyncValues",function(){return __asyncValues}),__webpack_require__.d(__webpack_exports__,"__makeTemplateObject",function(){return __makeTemplateObject}),__webpack_require__.d(__webpack_exports__,"__importStar",function(){return __importStar}),__webpack_require__.d(__webpack_exports__,"__importDefault",function(){return __importDefault});
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation. All rights reserved.
4
4
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-push-notifications",
3
- "version": "3.28.0",
3
+ "version": "3.29.0",
4
4
  "description": "Pushwoosh web push notifications",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",