!function(e){var t={};function i(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},i.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=25)}([function(e,t,i){"use strict";i.d(t,"a",function(){return n});class n{static shouldLog(){try{if("undefined"==typeof window||void 0===window.localStorage)return!1;const e=window.localStorage.getItem("loglevel");return!(!e||"trace"!==e.toLowerCase())}catch(e){return!1}}static setLevel(e){if("undefined"!=typeof window&&void 0!==window.localStorage)try{window.localStorage.setItem("loglevel",e),n.proxyMethodsCreated=void 0,n.createProxyMethods()}catch(e){return}}static createProxyMethods(){if(void 0!==n.proxyMethodsCreated)return;n.proxyMethodsCreated=!0;const e={log:"debug",trace:"trace",info:"info",warn:"warn",error:"error"};for(const t of Object.keys(e)){const i=void 0!==console[t],o=e[t],s=i&&(n.shouldLog()||"error"===o);n[o]=s?console[t].bind(console):function(){}}}}n.createProxyMethods()},function(e,t,i){"use strict";i.d(t,"g",function(){return h}),i.d(t,"u",function(){return p}),i.d(t,"c",function(){return f}),i.d(t,"o",function(){return m}),i.d(t,"w",function(){return b}),i.d(t,"i",function(){return S}),i.d(t,"q",function(){return v}),i.d(t,"p",function(){return y}),i.d(t,"b",function(){return O}),i.d(t,"e",function(){return w}),i.d(t,"a",function(){return E}),i.d(t,"t",function(){return P}),i.d(t,"m",function(){return I}),i.d(t,"j",function(){return T}),i.d(t,"h",function(){return C}),i.d(t,"r",function(){return A}),i.d(t,"v",function(){return N}),i.d(t,"f",function(){return M}),i.d(t,"x",function(){return k}),i.d(t,"s",function(){return x}),i.d(t,"l",function(){return _}),i.d(t,"d",function(){return R}),i.d(t,"n",function(){return D}),i.d(t,"k",function(){return W});var n=i(2),o=i(4),s=(i(3),i(0)),r=i(9),a=i(16),c=i(21),l=i(5),u=i(7),d=i.n(u),g=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};function h(e){return c.a.decodeHtmlEntities(e)}function p(e){var t=document.querySelectorAll(e);if(t.length>0)for(let e=0;e{OneSignal.initialized?e():OneSignal.emitter.once(OneSignal.EVENTS.SDK_INITIALIZED,e)})})}function m(){return r.a.isUsingSubscriptionWorkaround()}function b(e=!1){return g(this,void 0,void 0,function*(){return a.a.triggerNotificationPermissionChanged(e)})}function S(e,...t){if(e)return e.apply(null,t)}function v(e,...t){return r.a.logMethodCall(e,...t)}function y(e){return!!e&&!!e.match(/(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/)}function O(e,t,i){let n;if(!(n="string"==typeof e?document.querySelector(e):e))throw new Error(`${e} must be a CSS selector string or DOM Element object.`);n.insertAdjacentHTML(t,i)}function w(e){if("string"==typeof e){const t=document.querySelector(e);if(null===t)throw new Error(`Cannot find element with selector "${e}"`);for(;t.firstChild;)t.removeChild(t.firstChild)}else{if("object"!=typeof e)throw new Error(`${e} must be a CSS selector string or DOM Element object.`);for(;e.firstChild;)e.removeChild(e.firstChild)}}function E(e,t){if("string"==typeof e){const i=document.querySelector(e);if(null===i)throw new Error(`Cannot find element with selector "${e}"`);i.classList.add(t)}else{if("object"!=typeof e)throw new Error(`${e} must be a CSS selector string or DOM Element object.`);e.classList.add(t)}}function P(e,t){if("string"==typeof e){const i=document.querySelector(e);if(null===i)throw new Error(`Cannot find element with selector "${e}"`);i.classList.remove(t)}else{if("object"!=typeof e)throw new Error(`${e} must be a CSS selector string or DOM Element object.`);e.classList.remove(t)}}function I(e,t){if("string"==typeof e){const i=document.querySelector(e);if(null===i)throw new Error(`Cannot find element with selector "${e}"`);return i.classList.contains(t)}if("object"==typeof e)return e.classList.contains(t);throw new Error(`${e} must be a CSS selector string or DOM Element object.`)}function T(e){return l.a.getConsoleStyle(e)}function C(e){return new Promise(t=>{setTimeout(t,e)})}function A(){return Promise.resolve()}function N(e,t){return l.a.timeoutPromise(e,t)}function M(e,t){return l.a.contains(e,t)}function k(){return s.a.warn("OneSignal: Unsubscribing from push."),n.a.getWindowEnv()!==o.a.ServiceWorker?self.registration.pushManager.getSubscription().then(e=>{if(e)return e.unsubscribe();throw new Error("Cannot unsubscribe because not subscribed.")}):m()?new Promise((e,t)=>{s.a.debug("Unsubscribe from push got called, and we're going to remotely execute it in HTTPS iFrame."),OneSignal.proxyFrameHost.message(OneSignal.POSTMAM_COMMANDS.UNSUBSCRIBE_FROM_PUSH,null,i=>{s.a.debug("Unsubscribe from push succesfully remotely executed."),i.data===OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE?e():t("Failed to remotely unsubscribe from push.")})}):navigator.serviceWorker&&navigator.serviceWorker.controller?navigator.serviceWorker.ready.then(e=>e.pushManager).then(e=>e.getSubscription()).then(e=>e?e.unsubscribe():Promise.resolve()):Promise.resolve()}function x(e,t,i,n=!1){if(t||s.a.error("Cannot call on() with no event: ",t),i||s.a.error("Cannot call on() with no task: ",i),"string"==typeof e){let n=document.querySelectorAll(e);if(n.length>0)for(let e=0;e{OneSignal.emitter.once(e,e=>{if(t){t(e)&&i(e)}else i(e)})})})}function D(){window.__oneSignalSdkLoadCount=_()+1}function W(e){return e?d.a.safari&&e.safari?e.safari:d.a.firefox&&e.firefox?e.firefox:e.chrome||e.firefox||e.safari||"default-icon":"default-icon"}},function(e,t,i){"use strict";i.d(t,"a",function(){return g});var n=i(14),o=i(20),s=i(4),r=i(8),a=i(15),c=i(11),l=i(10),u=i(9),d=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class g{static getBuildEnv(){return n.a.Production}static getApiEnv(){return n.a.Production}static getIntegration(e){return d(this,void 0,void 0,function*(){if(l.a.isSafari())return a.a.Secure;const t=window===window.top,i="https:"===window.location.protocol;if(void 0===e){if("undefined"==typeof OneSignal||!OneSignal.context||!OneSignal.context.appConfig)throw new r.a("usingProxyOrigin",r.b.Empty);e=!!OneSignal.context.appConfig.subdomain}if(t)return i?e?a.a.SecureProxy:a.a.Secure:!u.b.isLocalhostAllowedAsSecureOrigin()||"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname?a.a.InsecureProxy:a.a.Secure;if(i){return(yield g.isFrameContextInsecure())?a.a.InsecureProxy:e?a.a.SecureProxy:a.a.Secure}return a.a.InsecureProxy})}static isFrameContextInsecure(){return d(this,void 0,void 0,function*(){if(window===window.top||!("serviceWorker"in navigator)||void 0===navigator.serviceWorker.getRegistration)return!1;return!(yield c.b.getRegistration())})}static isInsecureOrigin(){return"http:"===window.location.protocol}static getWindowEnv(){return"undefined"==typeof window?"undefined"!=typeof self&&void 0!==self.registration?s.a.ServiceWorker:s.a.Unknown:window===window.top?-1!==location.href.indexOf("initOneSignal")||"/subscribe"===location.pathname&&""===location.search&&(location.hostname.endsWith(".onesignal.com")||location.hostname.endsWith(".os.tc")||-1!==location.hostname.indexOf(".localhost")&&g.getBuildEnv()===n.a.Development)?s.a.OneSignalSubscriptionPopup:s.a.Host:"/webPushIframe"===location.pathname?s.a.OneSignalProxyFrame:"/webPushModal"===location.pathname?s.a.OneSignalSubscriptionModal:s.a.CustomIframe}static getTestEnv(){return o.a.None}static getBuildEnvPrefix(e=g.getBuildEnv()){switch(e){case n.a.Development:return"Dev-";case n.a.Staging:return"Staging-";case n.a.Production:return"";default:throw new r.a("buildEnv",r.b.EnumOutOfRange)}}static getOneSignalApiUrl(e=g.getApiEnv()){switch(e){case n.a.Development:return new URL("https://onesignal.com:3001/api/v1");case n.a.Staging:return new URL(`https://${window.location.host}/api/v1`);case n.a.Production:return new URL("https://onesignal.com/api/v1");default:throw new r.a("buildEnv",r.b.EnumOutOfRange)}}static getOneSignalResourceUrlPath(e=g.getBuildEnv()){let t;switch(e){case n.a.Development:t="https://localhost:4001";break;case n.a.Staging:t=`https://${window.location.host}`;break;case n.a.Production:t="https://onesignal.com";break;default:throw new r.a("buildEnv",r.b.EnumOutOfRange)}return new URL(t+"/sdks")}static getOneSignalCssFileName(e=g.getBuildEnv()){switch(e){case n.a.Development:return"Dev-OneSignalSDKStyles.css";case n.a.Staging:return"Staging-OneSignalSDKStyles.css";case n.a.Production:return"OneSignalSDKStyles.css";default:throw new r.a("buildEnv",r.b.EnumOutOfRange)}}}},function(e,t,i){"use strict";var n=i(17),o=i(22);class s{}class r{}var a=i(18),c=i(20),l=i(4),u=i(19),d=i(2),g=i(9),h=i(5);i.d(t,"a",function(){return b});var p,f,m=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};(f=p||(p={}))[f.SET=0]="SET";class b{constructor(e){this.databaseName=e,this.emitter=new n.a,this.database=new o.a(this.databaseName)}static resetInstance(){b.databaseInstance=null}static get singletonInstance(){return b.databaseInstanceName||(b.databaseInstanceName="ONE_SIGNAL_SDK_DB"),b.databaseInstance||(b.databaseInstance=new b(b.databaseInstanceName)),b.databaseInstance}static applyDbResultFilter(e,t,i){switch(e){case"Options":return i&&t?i.value:i&&!t?i:null;case"Ids":return i&&t?i.id:i&&!t?i:null;case"NotificationOpened":return i&&t?{data:i.data,timestamp:i.timestamp}:i&&!t?i:null;default:return i||null}}get(e,t){return m(this,void 0,void 0,function*(){if(d.a.getWindowEnv()!==l.a.ServiceWorker&&g.b.isUsingSubscriptionWorkaround()&&d.a.getTestEnv()===c.a.None)return yield new Promise(i=>m(this,void 0,void 0,function*(){OneSignal.proxyFrameHost.message(OneSignal.POSTMAM_COMMANDS.REMOTE_DATABASE_GET,[{table:e,key:t}],e=>{let t=e.data[0];i(t)})}));{const i=yield this.database.get(e,t);return b.applyDbResultFilter(e,t,i)}})}put(e,t){return m(this,void 0,void 0,function*(){yield new Promise((i,n)=>m(this,void 0,void 0,function*(){d.a.getWindowEnv()!==l.a.ServiceWorker&&g.b.isUsingSubscriptionWorkaround()&&d.a.getTestEnv()===c.a.None?OneSignal.proxyFrameHost.message(OneSignal.POSTMAM_COMMANDS.REMOTE_DATABASE_PUT,[{table:e,keypath:t}],o=>{o.data===OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE?i():n(`(Database) Attempted remote IndexedDB put(${e}, ${t}), but did not get success response.`)}):(yield this.database.put(e,t),i())})),this.emitter.emit(b.EVENTS.SET,t)})}remove(e,t){return d.a.getWindowEnv()!==l.a.ServiceWorker&&g.b.isUsingSubscriptionWorkaround()&&d.a.getTestEnv()===c.a.None?new Promise((i,n)=>{OneSignal.proxyFrameHost.message(OneSignal.POSTMAM_COMMANDS.REMOTE_DATABASE_REMOVE,[{table:e,keypath:t}],o=>{o.data===OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE?i():n(`(Database) Attempted remote IndexedDB remove(${e}, ${t}), but did not get success response.`)})}):this.database.remove(e,t)}getAppConfig(){return m(this,void 0,void 0,function*(){const e={},t=yield this.get("Ids","appId");return e.appId=t,e.subdomain=yield this.get("Options","subdomain"),e.vapidPublicKey=yield this.get("Options","vapidPublicKey"),e.emailAuthRequired=yield this.get("Options","emailAuthRequired"),e})}getExternalUserId(){return m(this,void 0,void 0,function*(){return yield this.get("Ids","externalUserId")})}setExternalUserId(e){return m(this,void 0,void 0,function*(){const t=h.b.getValueOrDefault(e,"");""===t?yield this.remove("Ids","externalUserId"):yield this.put("Ids",{type:"externalUserId",id:t})})}setAppConfig(e){return m(this,void 0,void 0,function*(){e.appId&&(yield this.put("Ids",{type:"appId",id:e.appId})),e.subdomain&&(yield this.put("Options",{key:"subdomain",value:e.subdomain})),!0===e.httpUseOneSignalCom?yield this.put("Options",{key:"httpUseOneSignalCom",value:!0}):!1===e.httpUseOneSignalCom&&(yield this.put("Options",{key:"httpUseOneSignalCom",value:!1})),!0===e.emailAuthRequired?yield this.put("Options",{key:"emailAuthRequired",value:!0}):!1===e.emailAuthRequired&&(yield this.put("Options",{key:"emailAuthRequired",value:!1})),e.vapidPublicKey&&(yield this.put("Options",{key:"vapidPublicKey",value:e.vapidPublicKey}))})}getAppState(){return m(this,void 0,void 0,function*(){const e=new s;return e.defaultNotificationUrl=yield this.get("Options","defaultUrl"),e.defaultNotificationTitle=yield this.get("Options","defaultTitle"),e.lastKnownPushEnabled=yield this.get("Options","isPushEnabled"),e.clickedNotifications=yield this.get("NotificationOpened"),e})}setAppState(e){return m(this,void 0,void 0,function*(){if(e.defaultNotificationUrl&&(yield this.put("Options",{key:"defaultUrl",value:e.defaultNotificationUrl})),(e.defaultNotificationTitle||""===e.defaultNotificationTitle)&&(yield this.put("Options",{key:"defaultTitle",value:e.defaultNotificationTitle})),null!=e.lastKnownPushEnabled&&(yield this.put("Options",{key:"isPushEnabled",value:e.lastKnownPushEnabled})),e.clickedNotifications){const t=Object.keys(e.clickedNotifications);for(let i of t){const t=e.clickedNotifications[i];t?yield this.put("NotificationOpened",{url:i,data:t.data,timestamp:t.timestamp}):null===t&&(yield this.remove("NotificationOpened",i))}}})}getServiceWorkerState(){return m(this,void 0,void 0,function*(){const e=new r;return e.workerVersion=yield this.get("Ids","WORKER1_ONE_SIGNAL_SW_VERSION"),e.updaterWorkerVersion=yield this.get("Ids","WORKER2_ONE_SIGNAL_SW_VERSION"),e.backupNotification=yield this.get("Ids","backupNotification"),e})}setServiceWorkerState(e){return m(this,void 0,void 0,function*(){e.workerVersion&&(yield this.put("Ids",{type:"WORKER1_ONE_SIGNAL_SW_VERSION",id:e.workerVersion})),e.updaterWorkerVersion&&(yield this.put("Ids",{type:"WORKER2_ONE_SIGNAL_SW_VERSION",id:e.updaterWorkerVersion})),e.backupNotification&&(yield this.put("Ids",{type:"backupNotification",id:e.backupNotification}))})}getSubscription(){return m(this,void 0,void 0,function*(){const e=new a.a;e.deviceId=yield this.get("Ids","userId"),e.subscriptionToken=yield this.get("Ids","registrationId");const t=yield this.get("Options","optedOut"),i=yield this.get("Options","subscription"),n=yield this.get("Options","subscriptionCreatedAt"),o=yield this.get("Options","subscriptionExpirationTime");return e.optedOut=null!=t?t:null!=i&&!i,e.createdAt=n,e.expirationTime=o,e})}setSubscription(e){return m(this,void 0,void 0,function*(){e.deviceId&&(yield this.put("Ids",{type:"userId",id:e.deviceId})),void 0!==e.subscriptionToken&&(yield this.put("Ids",{type:"registrationId",id:e.subscriptionToken})),null!=e.optedOut&&(yield this.put("Options",{key:"optedOut",value:e.optedOut})),null!=e.createdAt&&(yield this.put("Options",{key:"subscriptionCreatedAt",value:e.createdAt})),null!=e.expirationTime?yield this.put("Options",{key:"subscriptionExpirationTime",value:e.expirationTime}):yield this.remove("Options","subscriptionExpirationTime")})}getEmailProfile(){return m(this,void 0,void 0,function*(){const e=yield this.get("Ids","emailProfile");return e?u.a.deserialize(e):new u.a})}setEmailProfile(e){return m(this,void 0,void 0,function*(){e&&(yield this.put("Ids",{type:"emailProfile",id:e.serialize()}))})}setProvideUserConsent(e){return m(this,void 0,void 0,function*(){yield this.put("Options",{key:"userConsent",value:e})})}getProvideUserConsent(){return m(this,void 0,void 0,function*(){return yield this.get("Options","userConsent")})}static rebuild(){return m(this,void 0,void 0,function*(){return Promise.all([b.singletonInstance.remove("Ids"),b.singletonInstance.remove("NotificationOpened"),b.singletonInstance.remove("Options")])})}static on(...e){return m(this,void 0,void 0,function*(){return b.singletonInstance.emitter.on.apply(b.singletonInstance.emitter,e)})}static setEmailProfile(e){return m(this,void 0,void 0,function*(){return yield b.singletonInstance.setEmailProfile(e)})}static getEmailProfile(){return m(this,void 0,void 0,function*(){return yield b.singletonInstance.getEmailProfile()})}static setSubscription(e){return m(this,void 0,void 0,function*(){return yield b.singletonInstance.setSubscription(e)})}static getSubscription(){return m(this,void 0,void 0,function*(){return yield b.singletonInstance.getSubscription()})}static setProvideUserConsent(e){return m(this,void 0,void 0,function*(){return yield b.singletonInstance.setProvideUserConsent(e)})}static getProvideUserConsent(){return m(this,void 0,void 0,function*(){return yield b.singletonInstance.getProvideUserConsent()})}static setServiceWorkerState(e){return m(this,void 0,void 0,function*(){return yield b.singletonInstance.setServiceWorkerState(e)})}static getServiceWorkerState(){return m(this,void 0,void 0,function*(){return yield b.singletonInstance.getServiceWorkerState()})}static setAppState(e){return m(this,void 0,void 0,function*(){return yield b.singletonInstance.setAppState(e)})}static getAppState(){return m(this,void 0,void 0,function*(){return yield b.singletonInstance.getAppState()})}static setAppConfig(e){return m(this,void 0,void 0,function*(){return yield b.singletonInstance.setAppConfig(e)})}static getAppConfig(){return m(this,void 0,void 0,function*(){return yield b.singletonInstance.getAppConfig()})}static getExternalUserId(){return m(this,void 0,void 0,function*(){return yield b.singletonInstance.getExternalUserId()})}static setExternalUserId(e){return m(this,void 0,void 0,function*(){yield b.singletonInstance.setExternalUserId(e)})}static remove(e,t){return m(this,void 0,void 0,function*(){return yield b.singletonInstance.remove(e,t)})}static put(e,t){return m(this,void 0,void 0,function*(){return yield b.singletonInstance.put(e,t)})}static get(e,t){return m(this,void 0,void 0,function*(){return yield b.singletonInstance.get(e,t)})}}b.EVENTS=p},function(e,t,i){"use strict";var n;i.d(t,"a",function(){return n}),function(e){e.ServiceWorker="ServiceWorker",e.Host="Host",e.OneSignalSubscriptionPopup="Popup",e.OneSignalSubscriptionModal="Modal",e.OneSignalProxyFrame="ProxyFrame",e.CustomIframe="CustomFrame",e.Unknown="Unknown"}(n||(n={}))},function(e,t,i){"use strict";var n=i(13);class o extends n.a{constructor(e="The asynchronous operation has timed out."){super(e),this.message=e,Object.setPrototypeOf(this,o.prototype)}}i.d(t,"a",function(){return s});class s{static contains(e,t){return!!e&&-1!==e.indexOf(t)}static getConsoleStyle(e){return"code"==e?'padding: 0 1px 1px 5px;border: 1px solid #ddd;border-radius: 3px;font-family: Monaco,"DejaVu Sans Mono","Courier New",monospace;color: #444;':"bold"==e?"font-weight: 600;color: rgb(51, 51, 51);":"alert"==e?"font-weight: 600;color: red;":"event"==e?"color: green;":"postmessage"==e?"color: orange;":"serviceworkermessage"==e?"color: purple;":""}static trimUndefined(e){for(var t in e)e.hasOwnProperty(t)&&void 0===e[t]&&delete e[t];return e}static capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}static stringify(e){return JSON.stringify(e,(e,t)=>"function"==typeof t?"[Function]":t,4)}static encodeHashAsUriComponent(e){let t="";const i=Object.keys(e);for(var n of i){const i=e[n];t+=`${encodeURIComponent(n)}=${encodeURIComponent(i)}`}return t}static timeoutPromise(e,t){const i=new Promise((e,i)=>{setTimeout(()=>{i(new o)},t)});return Promise.race([e,i])}static getValueOrDefault(e,t){return void 0!==e&&null!==e?e:t}static padStart(e,t,i){let n=e;for(;n.length=t}static enforceAppId(e){if(!e)throw new Error("App id cannot be empty")}static enforcePlayerId(e){if(!e)throw new Error("Player id cannot be empty")}}t.b=s},function(e,t,i){"use strict";i.d(t,"a",function(){return g});var n=i(10),o=i(2),s=i(4),r=i(0),a=i(5),c=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};const l=["notifyButtonHovering","notifyButtonHover","notifyButtonButtonClick","notifyButtonLauncherClick","animatedElementHiding","animatedElementHidden","animatedElementShowing","animatedElementShown","activeAnimatedElementActivating","activeAnimatedElementActive","activeAnimatedElementInactivating","activeAnimatedElementInactive","dbRetrieved","dbSet","testEvent"],u=["onesignal.prompt.custom.clicked","onesignal.prompt.native.permissionchanged","onesignal.subscription.changed","onesignal.internal.subscriptionset","dbRebuilt","initialize","subscriptionSet","sendWelcomeNotification","subscriptionChange","notificationPermissionChange","dbSet","register","notificationDisplay","notificationDismiss","notificationClick","permissionPromptDisplay","testWouldDisplay","testInitOptionDisabled","popupWindowTimeout"],d={notificationPermissionChange:"onesignal.prompt.native.permissionchanged",subscriptionChange:"onesignal.subscription.changed",customPromptClick:"onesignal.prompt.custom.clicked"};class g{static trigger(e,t,i=null){return c(this,void 0,void 0,function*(){if(!a.b.contains(l,e)){let n=t,s=a.b.capitalize(o.a.getWindowEnv().toString());i&&(s=`${s} ⬸ ${a.b.capitalize(i)}`),n||!1===n?r.a.debug(`(${s}) » %c${e}:`,a.b.getConsoleStyle("event"),n):r.a.debug(`(${s}) » %c${e}`,a.b.getConsoleStyle("event"))}if(n.a.isBrowser()){if(e===OneSignal.EVENTS.SDK_INITIALIZED){if(OneSignal.initialized)return;OneSignal.initialized=!0}yield OneSignal.emitter.emit(e,t)}if(d.hasOwnProperty(e)){let i=d[e];g._triggerLegacy(i,t)}if(n.a.isBrowser()&&(o.a.getWindowEnv()===s.a.OneSignalSubscriptionPopup||o.a.getWindowEnv()===s.a.OneSignalProxyFrame)){opener||parent?a.b.contains(u,e)&&(o.a.getWindowEnv()===s.a.OneSignalSubscriptionPopup?OneSignal.subscriptionPopup.message(OneSignal.POSTMAM_COMMANDS.REMOTE_RETRIGGER_EVENT,{eventName:e,eventData:t}):OneSignal.proxyFrame.retriggerRemoteEvent(e,t)):r.a.error(`Could not send event '${e}' back to host page because no creator (opener or parent) found!`)}})}static _triggerLegacy(e,t){const i=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:t});window.dispatchEvent(i)}}},function(e,t,i){var n;n=function(){var e=!0;function t(t){function i(e){var i=t.match(e);return i&&i.length>1&&i[1]||""}var n,o,s,r=i(/(ipod|iphone|ipad)/i).toLowerCase(),a=!/like android/i.test(t)&&/android/i.test(t),c=/nexus\s*[0-6]\s*/i.test(t),l=!c&&/nexus\s*[0-9]+/i.test(t),u=/CrOS/.test(t),d=/silk/i.test(t),g=/sailfish/i.test(t),h=/tizen/i.test(t),p=/(web|hpw)os/i.test(t),f=/windows phone/i.test(t),m=(/SamsungBrowser/i.test(t),!f&&/windows/i.test(t)),b=!r&&!d&&/macintosh/i.test(t),S=!a&&!g&&!h&&!p&&/linux/i.test(t),v=i(/edge\/(\d+(\.\d+)?)/i),y=i(/version\/(\d+(\.\d+)?)/i),O=/tablet/i.test(t)&&!/tablet pc/i.test(t),w=!O&&/[^-]mobi/i.test(t),E=/xbox/i.test(t);/opera/i.test(t)?n={name:"Opera",opera:e,version:y||i(/(?:opera|opr|opios)[\s\/](\d+(\.\d+)?)/i)}:/opr\/|opios/i.test(t)?n={name:"Opera",opera:e,version:i(/(?:opr|opios)[\s\/](\d+(\.\d+)?)/i)||y}:/SamsungBrowser/i.test(t)?n={name:"Samsung Internet for Android",samsungBrowser:e,version:y||i(/(?:SamsungBrowser)[\s\/](\d+(\.\d+)?)/i)}:/coast/i.test(t)?n={name:"Opera Coast",coast:e,version:y||i(/(?:coast)[\s\/](\d+(\.\d+)?)/i)}:/yabrowser/i.test(t)?n={name:"Yandex Browser",yandexbrowser:e,version:y||i(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)}:/ucbrowser/i.test(t)?n={name:"UC Browser",ucbrowser:e,version:i(/(?:ucbrowser)[\s\/](\d+(?:\.\d+)+)/i)}:/mxios/i.test(t)?n={name:"Maxthon",maxthon:e,version:i(/(?:mxios)[\s\/](\d+(?:\.\d+)+)/i)}:/epiphany/i.test(t)?n={name:"Epiphany",epiphany:e,version:i(/(?:epiphany)[\s\/](\d+(?:\.\d+)+)/i)}:/puffin/i.test(t)?n={name:"Puffin",puffin:e,version:i(/(?:puffin)[\s\/](\d+(?:\.\d+)?)/i)}:/sleipnir/i.test(t)?n={name:"Sleipnir",sleipnir:e,version:i(/(?:sleipnir)[\s\/](\d+(?:\.\d+)+)/i)}:/k-meleon/i.test(t)?n={name:"K-Meleon",kMeleon:e,version:i(/(?:k-meleon)[\s\/](\d+(?:\.\d+)+)/i)}:f?(n={name:"Windows Phone",windowsphone:e},v?(n.msedge=e,n.version=v):(n.msie=e,n.version=i(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(t)?n={name:"Internet Explorer",msie:e,version:i(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:u?n={name:"Chrome",chromeos:e,chromeBook:e,chrome:e,version:i(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:/chrome.+? edge/i.test(t)?n={name:"Microsoft Edge",msedge:e,version:v}:/vivaldi/i.test(t)?n={name:"Vivaldi",vivaldi:e,version:i(/vivaldi\/(\d+(\.\d+)?)/i)||y}:g?n={name:"Sailfish",sailfish:e,version:i(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(t)?n={name:"SeaMonkey",seamonkey:e,version:i(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel|fxios/i.test(t)?(n={name:"Firefox",firefox:e,version:i(/(?:firefox|iceweasel|fxios)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(t)&&(n.firefoxos=e)):d?n={name:"Amazon Silk",silk:e,version:i(/silk\/(\d+(\.\d+)?)/i)}:/phantom/i.test(t)?n={name:"PhantomJS",phantom:e,version:i(/phantomjs\/(\d+(\.\d+)?)/i)}:/slimerjs/i.test(t)?n={name:"SlimerJS",slimer:e,version:i(/slimerjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(t)||/rim\stablet/i.test(t)?n={name:"BlackBerry",blackberry:e,version:y||i(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:p?(n={name:"WebOS",webos:e,version:y||i(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(t)&&(n.touchpad=e)):/bada/i.test(t)?n={name:"Bada",bada:e,version:i(/dolfin\/(\d+(\.\d+)?)/i)}:h?n={name:"Tizen",tizen:e,version:i(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||y}:/qupzilla/i.test(t)?n={name:"QupZilla",qupzilla:e,version:i(/(?:qupzilla)[\s\/](\d+(?:\.\d+)+)/i)||y}:/chromium/i.test(t)?n={name:"Chromium",chromium:e,version:i(/(?:chromium)[\s\/](\d+(?:\.\d+)?)/i)||y}:/chrome|crios|crmo/i.test(t)?n={name:"Chrome",chrome:e,version:i(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:a?n={name:"Android",version:y}:/safari|applewebkit/i.test(t)?(n={name:"Safari",safari:e},y&&(n.version=y)):r?(n={name:"iphone"==r?"iPhone":"ipad"==r?"iPad":"iPod"},y&&(n.version=y)):n=/googlebot/i.test(t)?{name:"Googlebot",googlebot:e,version:i(/googlebot\/(\d+(\.\d+))/i)||y}:{name:i(/^(.*)\/(.*) /),version:(o=/^(.*)\/(.*) /,s=t.match(o),s&&s.length>1&&s[2]||"")},!n.msedge&&/(apple)?webkit/i.test(t)?(/(apple)?webkit\/537\.36/i.test(t)?(n.name=n.name||"Blink",n.blink=e):(n.name=n.name||"Webkit",n.webkit=e),!n.version&&y&&(n.version=y)):!n.opera&&/gecko\//i.test(t)&&(n.name=n.name||"Gecko",n.gecko=e,n.version=n.version||i(/gecko\/(\d+(\.\d+)?)/i)),n.windowsphone||n.msedge||!a&&!n.silk?n.windowsphone||n.msedge||!r?b?n.mac=e:E?n.xbox=e:m?n.windows=e:S&&(n.linux=e):(n[r]=e,n.ios=e):n.android=e;var P="";n.windows?P=function(e){switch(e){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}}(i(/Windows ((NT|XP)( \d\d?.\d)?)/i)):n.windowsphone?P=i(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):n.mac?P=(P=i(/Mac OS X (\d+([_\.\s]\d+)*)/i)).replace(/[_\s]/g,"."):r?P=(P=i(/os (\d+([_\s]\d+)*) like mac os x/i)).replace(/[_\s]/g,"."):a?P=i(/android[ \/-](\d+(\.\d+)*)/i):n.webos?P=i(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):n.blackberry?P=i(/rim\stablet\sos\s(\d+(\.\d+)*)/i):n.bada?P=i(/bada\/(\d+(\.\d+)*)/i):n.tizen&&(P=i(/tizen[\/\s](\d+(\.\d+)*)/i)),P&&(n.osversion=P);var I=!n.windows&&P.split(".")[0];return O||l||"ipad"==r||a&&(3==I||I>=4&&!w)||n.silk?n.tablet=e:(w||"iphone"==r||"ipod"==r||a||c||n.blackberry||n.webos||n.bada)&&(n.mobile=e),n.msedge||n.msie&&n.version>=10||n.yandexbrowser&&n.version>=15||n.vivaldi&&n.version>=1||n.chrome&&n.version>=20||n.samsungBrowser&&n.version>=4||n.firefox&&n.version>=20||n.safari&&n.version>=6||n.opera&&n.version>=10||n.ios&&n.osversion&&n.osversion.split(".")[0]>=6||n.blackberry&&n.version>=10.1||n.chromium&&n.version>=20?n.a=e:n.msie&&n.version<10||n.chrome&&n.version<20||n.firefox&&n.version<20||n.safari&&n.version<6||n.opera&&n.version<10||n.ios&&n.osversion&&n.osversion.split(".")[0]<6||n.chromium&&n.version<20?n.c=e:n.x=e,n}var i=t("undefined"!=typeof navigator&&navigator.userAgent||"");function n(e){return e.split(".").length}function o(e,t){var i,n=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(i=0;i=0;){if(i[0][t]>i[1][t])return 1;if(i[0][t]!==i[1][t])return-1;if(0===t)return 0}}function r(e,n,o){var r=i;"string"==typeof n&&(o=n,n=void 0),void 0===n&&(n=!1),o&&(r=t(o));var a=""+r.version;for(var c in e)if(e.hasOwnProperty(c)&&r[c]){if("string"!=typeof e[c])throw new Error("Browser version in the minVersion map should be a string: "+c+": "+String(e));return s([a,e[c]])<0}return n}return i.test=function(e){for(var t=0;t{try{var i=indexedDB.open(e,1)}catch(e){}if(!i)return null;i.onerror=this.onDatabaseOpenError,i.onblocked=this.onDatabaseOpenBlocked,i.onupgradeneeded=this.onDatabaseUpgradeNeeded,i.onsuccess=(()=>{this.database=i.result,this.database.onerror=this.onDatabaseError,this.database.onversionchange=this.onDatabaseVersionChange,t(this.database)})})}ensureDatabaseOpen(){return r(this,void 0,void 0,function*(){return this.openLock||(this.openLock=this.open(this.databaseName)),yield this.openLock,this.database})}onDatabaseOpenError(e){e.preventDefault();const t=e.target.error;s.b.contains(t.message,"The operation failed for reasons unrelated to the database itself and not covered by any other error code")||s.b.contains(t.message,"A mutation operation was attempted on a database that did not allow mutations")?o.a.warn("OneSignal: IndexedDb web storage is not available on this origin since this profile's IndexedDb schema has been upgraded in a newer version of Firefox. See: https://bugzilla.mozilla.org/show_bug.cgi?id=1236557#c6"):o.a.warn("OneSignal: Fatal error opening IndexedDb database:",t)}onDatabaseError(e){o.a.debug("IndexedDb: Generic database error",e.target.errorCode)}onDatabaseOpenBlocked(){o.a.debug("IndexedDb: Blocked event")}onDatabaseVersionChange(e){o.a.debug("IndexedDb: versionchange event")}onDatabaseUpgradeNeeded(e){o.a.debug("IndexedDb: Database is being rebuilt or upgraded (upgradeneeded event).");const t=e.target.result;t.createObjectStore("Ids",{keyPath:"type"}),t.createObjectStore("NotificationOpened",{keyPath:"url"}),t.createObjectStore("Options",{keyPath:"key"}),"undefined"!=typeof OneSignal&&(OneSignal._isNewVisitor=!0)}get(e,t){return r(this,void 0,void 0,function*(){return yield this.ensureDatabaseOpen(),t?yield new Promise((i,n)=>{var o=this.database.transaction(e).objectStore(e).get(t);o.onsuccess=(()=>{i(o.result)}),o.onerror=(()=>{n(o.error)})}):yield new Promise((t,i)=>{let n={},o=this.database.transaction(e).objectStore(e).openCursor();o.onsuccess=(e=>{var i=e.target.result;if(i){let e=i.key;n[e]=i.value,i.continue()}else t(n)}),o.onerror=(()=>{i(o.error)})})})}put(e,t){return r(this,void 0,void 0,function*(){return yield this.ensureDatabaseOpen(),yield new Promise((i,n)=>{try{let s=this.database.transaction([e],"readwrite").objectStore(e).put(t);s.onsuccess=(()=>{i(t)}),s.onerror=(e=>{o.a.error("Database PUT Transaction Error:",e),n(e)})}catch(e){o.a.error("Database PUT Error:",e),n(e)}})})}remove(e,t){if(t)var i="delete";else i="clear";return new Promise((n,s)=>{try{let r=this.database.transaction([e],"readwrite").objectStore(e)[i](t);r.onsuccess=(()=>{n(t)}),r.onerror=(e=>{o.a.error("Database REMOVE Transaction Error:",e),s(e)})}catch(e){o.a.error("Database REMOVE Error:",e),s(e)}})}}},function(e,t,i){"use strict";var n;i.d(t,"a",function(){return n}),function(e){e[e.HttpsPermissionRequest="HTTPS permission request"]="HttpsPermissionRequest",e[e.FullscreenHttpPermissionMessage="fullscreen HTTP permission message"]="FullscreenHttpPermissionMessage",e[e.FullscreenHttpsPermissionMessage="fullscreen HTTPS permission message"]="FullscreenHttpsPermissionMessage",e[e.SlidedownPermissionMessage="slidedown permission message"]="SlidedownPermissionMessage",e[e.SubscriptionBell="subscription bell"]="SubscriptionBell"}(n||(n={}))},function(e,t){e.exports=function(e,t,o){"function"==typeof t&&(o=t,t={});t||(t={});var s,r,a=t.prefix||"__jp",c=t.name||a+i++,l=t.param||"callback",u=null!=t.timeout?t.timeout:6e4,d=encodeURIComponent,g=document.getElementsByTagName("script")[0]||document.head;u&&(r=setTimeout(function(){h(),o&&o(new Error("Timeout"))},u));function h(){s.parentNode&&s.parentNode.removeChild(s),window[c]=n,r&&clearTimeout(r)}return window[c]=function(e){h(),o&&o(null,e)},e=(e+=(~e.indexOf("?")?"&":"?")+l+"="+d(c)).replace("?&","?"),(s=document.createElement("script")).src=e,g.parentNode.insertBefore(s,g),function(){window[c]&&h()}};var i=0;function n(){}},function(e,t,i){"use strict";i.r(t);var n=i(0),o=i(1);class s{static doReplay(e){e&&(Array.isArray(e)?s.processAsArray(e):e.constructor&&"OneSignalStubES6"===e.constructor.name?s.processAsES6Stub(e):n.a.error("window.OneSignal is an unexpected type! Should be an Array, OneSignalStubES6, or undefined."))}static processAsArray(e){for(const t of e)try{OneSignal.push(t)}catch(e){n.a.error(e)}}static processAsES6Stub(e){e.SERVICE_WORKER_PATH&&(OneSignal.SERVICE_WORKER_PATH=e.SERVICE_WORKER_PATH),e.SERVICE_WORKER_UPDATER_PATH&&(OneSignal.SERVICE_WORKER_UPDATER_PATH=e.SERVICE_WORKER_UPDATER_PATH),e.currentLogLevel&&OneSignal.log.setLevel(e.currentLogLevel),e.SERVICE_WORKER_PARAM&&(OneSignal.SERVICE_WORKER_PARAM=e.SERVICE_WORKER_PARAM),e.preExistingArray&&s.processAsArray(e.preExistingArray);for(const t of e.directFunctionCallsArray){const e=OneSignal[t.functionName].apply(OneSignal,t.args);t.delayedPromise&&e instanceof Promise&&e.then(function(...e){t.delayedPromise&&t.delayedPromise.resolve&&t.delayedPromise.resolve.apply(null,e)}).catch(function(...e){t.delayedPromise&&t.delayedPromise.reject&&t.delayedPromise.reject.apply(null,e)})}}}"undefined"!=typeof window&&function(){if(Object(o.n)(),Object(o.l)()>1)return n.a.warn("OneSignal: The web push SDK is included more than once. For optimal performance, please include our SDK only once on your page."),void n.a.debug("OneSignal: Exiting from SDK initialization to prevent double-initialization errors. "+`Occurred ${Object(o.l)()} times.`);const e=window.OneSignal;window.OneSignal=i(26).default,s.doReplay(e)}()},function(e,t,i){"use strict";i.r(t);var n,o,s,r,a=i(7),c=i.n(a),l=i(10),InvalidArgumentError=i(8),InvalidStateError=i(12),u=i(13);(o=n||(n={}))[o.Unknown=0]="Unknown",o[o.NoDeviceId=1]="NoDeviceId",o[o.NoEmailSet=2]="NoEmailSet",o[o.OptedOut=3]="OptedOut";class d extends u.a{constructor(e){switch(e){case n.Unknown||n.NoDeviceId:super("This operation can only be performed after the user is subscribed.");break;case n.NoEmailSet:super("No email is currently set.");break;case n.OptedOut:super("The user has manually opted out of receiving of notifications. This operation can only be performed after the user is fully resubscribed.")}this.reason=n[e],Object.setPrototypeOf(this,d.prototype)}}(r=s||(s={}))[r.InvalidAppId=0]="InvalidAppId",r[r.AppNotConfiguredForWebPush=1]="AppNotConfiguredForWebPush",r[r.MissingSubdomain=2]="MissingSubdomain",r[r.WrongSiteUrl=3]="WrongSiteUrl",r[r.MultipleInitialization=4]="MultipleInitialization",r[r.MissingSafariWebId=5]="MissingSafariWebId",r[r.Unknown=6]="Unknown";class g extends u.a{constructor(e,t){switch(e){case s.InvalidAppId:super("OneSignal: This app ID does not match any existing app. Double check your app ID.");break;case s.AppNotConfiguredForWebPush:super("OneSignal: This app ID does not have any web platforms enabled. Double check your app ID, or see step 1 on our setup guide (https://goo.gl/01h7fZ).");break;case s.MissingSubdomain:super("OneSignal: Non-HTTPS pages require a subdomain of OneSignal to be chosen on your dashboard. See step 1.4 on our setup guide (https://goo.gl/xip6JB).");break;case s.WrongSiteUrl:t&&t.siteUrl?super(`OneSignal: This web push config can only be used on ${new URL(t.siteUrl).origin}. Your current origin is ${location.origin}.`):super("OneSignal: This web push config can not be used on the current site.");break;case s.MultipleInitialization:super("OneSignal: The OneSignal web SDK can only be initialized once. Extra initializations are ignored. Please remove calls initializing the SDK more than once.");break;case s.MissingSafariWebId:super("OneSignal: Safari browser support on Mac OS X requires the Safari web platform to be enabled. Please see the Safari Support steps in our web setup guide.");break;case s.Unknown:super("OneSignal: An unknown initialization error occurred.")}this.reason=s[e],Object.setPrototypeOf(this,g.prototype)}}var h,p,f,m=i(6);class b{static put(e,t){return void 0===b.store[e]&&(b.store[e]=[null,null]),b.store[e].push(t),b.store[e].length==b.LIMIT+1&&b.store[e].shift(),b.store[e]}static get(e){return void 0===b.store[e]&&(b.store[e]=[null,null]),b.store[e]}static getFirst(e){return b.get(e)[0]}static getLast(e){return b.get(e)[1]}static remove(e){delete b.store[e]}static isEmpty(e){let t=b.get(e);return null===t[0]&&null===t[1]}}b.store={},b.LIMIT=2,(p=h||(h={}))[p.MissingAppId=0]="MissingAppId";class S extends u.a{constructor(e){switch(e){case h.MissingAppId:super("The API call is missing an app ID.")}Object.setPrototypeOf(this,S.prototype)}}class v extends u.a{constructor(){super("This code is not implemented yet."),Object.setPrototypeOf(this,v.prototype)}}!function(e){e[e.ChromeLike=5]="ChromeLike",e[e.Safari=7]="Safari",e[e.Firefox=8]="Firefox",e[e.Edge=12]="Edge",e[e.Email=11]="Email"}(f||(f={}));var y=i(9);class O{constructor(){this.language=l.a.getLanguage(),this.timezone=-60*(new Date).getTimezoneOffset();const e=parseInt(String(c.a.version),10);this.browserVersion=isNaN(e)?-1:e,this.deviceModel=navigator.platform,this.sdkVersion=l.a.version().toString(),this.deliveryPlatform=this.getDeliveryPlatform()}isSafari(){return c.a.safari&&void 0!==window.safari&&void 0!==window.safari.pushNotification}getDeliveryPlatform(){const e=y.a.redetectBrowserUserAgent();return this.isSafari()?f.Safari:e.firefox?f.Firefox:e.msedge?f.Edge:f.ChromeLike}serialize(){const e={device_type:this.deliveryPlatform,language:this.language,timezone:this.timezone,device_os:this.browserVersion,device_model:this.deviceModel,sdk:this.sdkVersion,notification_types:this.subscriptionState};return this.appId&&(e.app_id=this.appId),e}deserialize(e){throw new v}}class w extends O{constructor(e,t,i){super(),this.email=e,this.emailAuthHash=t,this.pushDeviceRecordId=i,this.deliveryPlatform=f.Email}serialize(){const e=super.serialize();return this.email&&(e.identifier=this.email),this.emailAuthHash&&(e.email_auth_hash=this.emailAuthHash),this.pushDeviceRecordId&&(e.device_player_id=this.pushDeviceRecordId),e}deserialize(e){throw new v}}var E=i(2),P=i(5);class I{static get(e,t,i){return I.call("GET",e,t,i)}static post(e,t,i){return I.call("POST",e,t,i)}static put(e,t,i){return I.call("PUT",e,t,i)}static delete(e,t,i){return I.call("DELETE",e,t,i)}static call(e,t,i,n){if("GET"===e){if(t.indexOf("players")>-1&&-1===t.indexOf("app_id="))return console.error("Calls to player api are not permitted without app_id"),Promise.reject(new S(h.MissingAppId))}else if(t.indexOf("players")>-1&&(!i||!i.app_id))return console.error("Calls to player api are not permitted without app_id"),Promise.reject(new S(h.MissingAppId));let o=new Headers;if(o.append("SDK-Version",`onesignal/web/${l.a.version()}`),o.append("Content-Type","application/json;charset=UTF-8"),n)for(let e of Object.keys(n))o.append(e,n[e]);let s,r={method:e||"NO_METHOD_SPECIFIED",headers:o,cache:"no-cache"};return i&&(r.body=JSON.stringify(i)),fetch(E.a.getOneSignalApiUrl().toString()+"/"+t,r).then(e=>(s=e.status,e.json())).then(e=>{if(s>=200&&s<300)return e;if("no-user-id-error"!==I.identifyError(e))return Promise.reject(e)})}static identifyError(e){if(!e||!e.errors)return"no-error";let t=e.errors;return P.a.contains(t,"No user with this id found")||P.a.contains(t,"Could not find app_id for given player id.")?"no-user-id-error":"unknown-error"}}var T=I,C=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class A{static getPlayer(e,t){return P.b.enforceAppId(e),P.b.enforcePlayerId(t),T.get(`players/${t}?app_id=${e}`)}static updatePlayer(e,t,i){return P.b.enforceAppId(e),P.b.enforcePlayerId(t),T.put(`players/${t}`,Object.assign({app_id:e},i))}static sendNotification(e,t,i,n,o,s,r,a){var c={app_id:e,contents:n,include_player_ids:t,isAnyWeb:!0,data:r,web_buttons:a};return i&&(c.headings=i),o&&(c.url=o),s&&(c.chrome_web_icon=s,c.firefox_icon=s),P.b.trimUndefined(c),T.post("notifications",c)}static createUser(e){return C(this,void 0,void 0,function*(){const t=e.serialize();P.b.enforceAppId(t.app_id);const i=yield T.post("players",t);return i&&i.success?i.id:null})}static createEmailRecord(e,t,i){return C(this,void 0,void 0,function*(){P.b.enforceAppId(e.appId);const n=new w(t.emailAddress,t.emailAuthHash,i);n.appId=e.appId;const o=yield T.post("players",n.serialize());return o&&o.success?o.id:null})}static updateEmailRecord(e,t,i){return C(this,void 0,void 0,function*(){P.b.enforceAppId(e.appId),P.b.enforcePlayerId(t.emailId);const n=new w(t.emailAddress,t.emailAuthHash,i);n.appId=e.appId;const o=yield T.put(`players/${t.emailId}`,n.serialize());return o&&o.success?o.id:null})}static logoutEmail(e,t,i){return C(this,void 0,void 0,function*(){P.b.enforceAppId(e.appId),P.b.enforcePlayerId(i);const n=yield T.post(`players/${i}/email_logout`,{app_id:e.appId,parent_player_id:t.emailId,email_auth_hash:t.emailAuthHash?t.emailAuthHash:void 0});return!(!n||!n.success)})}static updateUserSession(e,t){return C(this,void 0,void 0,function*(){try{const i=t.serialize();P.b.enforceAppId(i.app_id),P.b.enforcePlayerId(e);const n=yield T.post(`players/${e}/on_session`,i);return n.id?n.id:e}catch(e){throw e&&Array.isArray(e.errors)&&e.errors.length>0&&P.b.contains(e.errors[0],"app_id not found")?new S(h.MissingAppId):e}})}}var N=i(3),M=i(0),k=i(1),x=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class _{static initialize(e){return x(this,void 0,void 0,function*(){if(!e||!e.enabled)return;if(M.a.info("Inititalize CustomLink"),0!==(yield OneSignal.context.dynamicResourceLoader.loadSdkStylesheet()))return void M.a.debug("Not initializing custom link button because styles failed to load.");document.querySelectorAll(_.containerSelector).forEach(t=>{_.isInitialized(t)||_.injectMarkup(t,e)});const t=yield OneSignal.privateIsPushNotificationsEnabled(),i=yield OneSignal.internalIsOptedOut();document.querySelectorAll(_.subscribeSelector).forEach(n=>_.initSubscribeElement(n,e,t,i)),document.querySelectorAll(_.explanationSelector).forEach(i=>_.initExplanationElement(i,e,t))})}static injectMarkup(e,t){if(t.text){if(e.innerHTML="",t.text.explanation){const t=document.createElement("p");Object(k.a)(t,_.explanationClass),e.appendChild(t)}if(t.text.subscribe){const t=document.createElement("button");Object(k.a)(t,_.subscribeClass),e.appendChild(t)}_.markAsInitialized(e)}else M.a.error("CustomLink: required property 'text' is missing in the config")}static initSubscribeElement(e,t,i,n){t.text&&t.text.subscribe&&(i||(e.textContent=t.text.subscribe)),t.text&&t.text.unsubscribe&&i&&(e.textContent=t.text.unsubscribe),_.setResetClass(e),_.setStateClass(e,i),_.setStyleClass(e,t),_.setSizeClass(e,t),_.setCustomColors(e,t),!0!==t.unsubscribeEnabled&&Object(k.a)(e,"hide"),e.setAttribute(_.subscriptionStateAttribute,i.toString()),e.setAttribute(_.optedOutAttribute,n.toString()),_.isInitialized(e)||(e.addEventListener("click",()=>{M.a.info("CustomLink: subscribe clicked"),_.handleClick(e)}),_.markAsInitialized(e))}static handleClick(e){return x(this,void 0,void 0,function*(){const t="true"===e.getAttribute(_.subscriptionStateAttribute),i="true"===e.getAttribute(_.optedOutAttribute);if(t){(yield OneSignal.privateIsPushNotificationsEnabled())&&(yield OneSignal.setSubscription(!1))}else if(i)yield OneSignal.setSubscription(!0);else{const e={autoAccept:!0};yield OneSignal.registerForPushNotifications(e)}})}static initExplanationElement(e,t,i){t.text&&t.text.explanation&&(e.textContent=t.text.explanation),_.setResetClass(e),_.setStateClass(e,i),_.setSizeClass(e,t),!0!==t.unsubscribeEnabled&&Object(k.a)(e,"hide")}static setCustomColors(e,t){"button"===t.style&&t.color&&t.color.button&&t.color.text?(e.style.backgroundColor=t.color.button,e.style.color=t.color.text):"link"===t.style&&t.color&&t.color.text&&(e.style.color=t.color.text)}static setStateClass(e,t){const i=t?"state-unsubscribed":"state-subscribed",n=t?"state-subscribed":"state-unsubscribed";Object(k.m)(e,i)&&Object(k.t)(e,i),Object(k.m)(e,n)||Object(k.a)(e,n)}static setStyleClass(e,t){if(!t||!t.style)return;const i=t.style;Object(k.m)(e,i)||Object(k.a)(e,i)}static setSizeClass(e,t){if(!t||!t.size)return;const i=t.size;Object(k.m)(e,i)||Object(k.a)(e,i)}static setResetClass(e){const t=_.resetClass;Object(k.m)(e,t)||Object(k.a)(e,t)}static markAsInitialized(e){e.setAttribute(_.initializedAttribute,"true")}static isInitialized(e){return"true"===e.getAttribute(_.initializedAttribute)}}_.initializedAttribute="data-cl-initialized",_.subscriptionStateAttribute="data-cl-state",_.optedOutAttribute="data-cl-optedout",_.containerClass="onesignal-customlink-container",_.containerSelector=`.${_.containerClass}`,_.subscribeClass="onesignal-customlink-subscribe",_.subscribeSelector=`.${_.subscribeClass}`,_.explanationClass="onesignal-customlink-explanation",_.explanationSelector=`.${_.explanationClass}`,_.resetClass="onesignal-reset";var R=i(21),D=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class W{static onNotificationPermissionChange(){W.checkAndTriggerSubscriptionChanged()}static onInternalSubscriptionSet(e){return D(this,void 0,void 0,function*(){b.put("subscription.optedOut",e)})}static checkAndTriggerSubscriptionChanged(){return D(this,void 0,void 0,function*(){y.a.logMethodCall("checkAndTriggerSubscriptionChanged");const e=yield OneSignal.context.subscriptionManager.getSubscriptionState(),t=yield OneSignal.privateIsPushNotificationsEnabled(),i=yield N.a.getAppState(),{lastKnownPushEnabled:n}=i;(null===n||t!==n)&&(M.a.info("The user's subscription state changed from "+`${null===n?"(not stored)":n} ⟶ ${e.subscribed}`),i.lastKnownPushEnabled=t,yield N.a.setAppState(i),W.triggerSubscriptionChanged(t))})}static _onSubscriptionChanged(e){return D(this,void 0,void 0,function*(){W.onSubscriptionChanged_showWelcomeNotification(e),W.onSubscriptionChanged_evaluateNotifyButtonDisplayPredicate(),W.onSubscriptionChanged_updateCustomLink()})}static onSubscriptionChanged_showWelcomeNotification(e){return D(this,void 0,void 0,function*(){if(OneSignal.__doNotShowWelcomeNotification)M.a.debug("Not showing welcome notification because user has previously subscribed.");else if(!0===e){const{deviceId:e}=yield N.a.getSubscription(),{appId:t}=yield N.a.getAppConfig();let i=OneSignal.config.userConfig.welcomeNotification,n=void 0!==i&&!0===i.disable,o=void 0!==i&&void 0!==i.title&&null!==i.title?i.title:"",s=void 0!==i&&void 0!==i.message&&null!==i.message&&i.message.length>0?i.message:"Thanks for subscribing!",r=new URL(location.href).origin+"?_osp=do_not_open",a=i&&i.url&&i.url.length>0?i.url:r;o=R.a.decodeHtmlEntities(o),s=R.a.decodeHtmlEntities(s),n||(M.a.debug("Sending welcome notification."),A.sendNotification(t,[e],{en:o},{en:s},a,null,{__isOneSignalWelcomeNotification:!0},void 0),m.a.trigger(OneSignal.EVENTS.WELCOME_NOTIFICATION_SENT,{title:o,message:s,url:a}))}})}static onSubscriptionChanged_evaluateNotifyButtonDisplayPredicate(){return D(this,void 0,void 0,function*(){if(!OneSignal.config.userConfig.notifyButton)return;const e=OneSignal.config.userConfig.notifyButton.displayPredicate;if(e&&"function"==typeof e&&OneSignal.notifyButton){!1!==(yield e())?(M.a.debug("Showing notify button because display predicate returned true."),OneSignal.notifyButton.launcher.show()):(M.a.debug("Hiding notify button because display predicate returned false."),OneSignal.notifyButton.launcher.hide())}})}static onSubscriptionChanged_updateCustomLink(){return D(this,void 0,void 0,function*(){OneSignal.config.userConfig.promptOptions&&(yield _.initialize(OneSignal.config.userConfig.promptOptions.customlink))})}static triggerSubscriptionChanged(e){m.a.trigger(OneSignal.EVENTS.SUBSCRIPTION_CHANGED,e)}static fireStoredNotificationClicks(e=document.URL){return D(this,void 0,void 0,function*(){function t(e){return D(this,void 0,void 0,function*(){const t=yield N.a.getAppState();t.clickedNotifications[e.url]=null,yield N.a.setAppState(t);const{data:i,timestamp:n}=e;if(n){if((Date.now()-n)/1e3/60>5)return}m.a.trigger(OneSignal.EVENTS.NOTIFICATION_CLICKED,i)})}const i=yield N.a.getAppState();if("origin"===(yield N.a.get("Options","notificationClickHandlerMatch"))){for(const e of Object.keys(i.clickedNotifications))if(new URL(e).origin===location.origin){yield t(i.clickedNotifications[e])}}else{var n=i.clickedNotifications[e];if(n)yield t(n);else if(!n&&e.endsWith("/")){var o=e.substring(0,e.length-1);(n=i.clickedNotifications[o])&&(yield t(n))}}})}}var U,B,L=i(4);class j{static promiseStub(){return{then:j.promiseStub,catch:j.promiseStub}}static ensureBackwardsCompatibility(e){j.environmentPolyfill(e),j.postmams(e),e.syncHashedEmail=j.promiseStub}static environmentPolyfill(e){e.environment={},e.environment.getEnv=function(){return""},e.environment.isPopup=function(){return E.a.getWindowEnv()===L.a.OneSignalSubscriptionPopup},e.environment.isIframe=function(){return E.a.getWindowEnv()===L.a.OneSignalProxyFrame}}static postmams(e){const t=function(){this.messenger.message.apply(this.messenger,arguments)},i=function(){this.messenger.postMessage.apply(this.messenger,arguments)};function n(e){e.message=t,e.postMessage=i}e.proxyFrame&&(e.iframePostmam=e.proxyFrame,n(e.iframePostmam)),e.subscriptionPopup&&(e.popupPostmam=e.subscriptionPopup,n(e.popupPostmam)),e.subscriptionModal&&(e.modalPostmam=e.subscriptionModal,n(e.modalPostmam))}}!function(e){e.Default="default",e.Granted="granted",e.Denied="denied"}(U||(U={}));class F{static isLocalStorageSupported(){try{return"undefined"!=typeof localStorage&&(localStorage.getItem("test"),!0)}catch(e){return!1}}static setItem(e,t,i){if(!F.isLocalStorageSupported())return;const n=void 0!==i?60*i*1e3:0,o={value:JSON.stringify(t),timestamp:void 0!==i?(new Date).getTime()+n:void 0};localStorage.setItem(e,JSON.stringify(o))}static getItem(e){if(!F.isLocalStorageSupported())return null;const t=localStorage.getItem(e);let i;try{i=JSON.parse(t)}catch(e){return null}if(null===i)return null;if(i.timestamp&&(new Date).getTime()>=i.timestamp)return localStorage.removeItem(e),null;let n=i.value;try{n=JSON.parse(i.value)}catch(e){return n}return n}static removeItem(e){if(!F.isLocalStorageSupported())return null;localStorage.removeItem(e)}}!function(e){e[e.Default=0]="Default",e[e.Subscribed=1]="Subscribed",e[e.MutedByApi=-2]="MutedByApi",e[e.NotSubscribed=-10]="NotSubscribed",e[e.TemporaryWebRecord=-20]="TemporaryWebRecord",e[e.PermissionRevoked=-21]="PermissionRevoked",e[e.PushSubscriptionRevoked=-22]="PushSubscriptionRevoked",e[e.ServiceWorkerStatus403=-23]="ServiceWorkerStatus403",e[e.ServiceWorkerStatus404=-24]="ServiceWorkerStatus404"}(B||(B={}));var H,V,$=i(16),z=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class G{static getCurrentNotificationType(){return z(this,void 0,void 0,function*(){const e=yield OneSignal.context.permissionManager.getNotificationPermission(OneSignal.context.appConfig.safariWebId);if(e===U.Default)return B.Default;if(e===U.Denied)return y.a.isUsingSubscriptionWorkaround()?B.Default:B.NotSubscribed;const t=yield OneSignal.context.subscriptionManager.isAlreadyRegisteredWithOneSignal();if(e===U.Granted&&t){return(yield OneSignal.privateIsPushNotificationsEnabled())?B.Subscribed:B.MutedByApi}return B.Default})}static getNotificationTypeFromOptIn(e){return 1==e||null==e?B.Subscribed:B.MutedByApi}static wasHttpsNativePromptDismissed(){return"dismissed"===F.getItem("onesignal-notification-prompt")}static markHttpPopoverShown(){sessionStorage.setItem("ONESIGNAL_HTTP_PROMPT_SHOWN","true")}static isHttpPromptAlreadyShown(){return"true"==sessionStorage.getItem("ONESIGNAL_HTTP_PROMPT_SHOWN")}static checkAndTriggerNotificationPermissionChanged(){return z(this,void 0,void 0,function*(){const e=yield N.a.get("Options","notificationPermission"),t=yield OneSignal.getNotificationPermission();e!==t&&(yield $.a.triggerNotificationPermissionChanged(),yield N.a.put("Options",{key:"notificationPermission",value:t}))})}static getNotificationIcons(){return z(this,void 0,void 0,function*(){const e=yield G.getAppId();if(!e)throw new InvalidStateError.a(InvalidStateError.b.MissingAppId);var t=`${E.a.getOneSignalApiUrl().toString()}/apps/${e}/icon`;const i=yield(yield fetch(t)).json();if(i.errors)throw M.a.error(`API call %c${t}`,P.a.getConsoleStyle("code"),"failed with:",i.errors),new Error("Failed to get notification icons.");return i})}static getSlidedownPermissionMessageOptions(e){const t="We'd like to show you notifications for the latest news and updates.";return e?e.slidedown?{enabled:e.slidedown.enabled,autoPrompt:e.slidedown.autoPrompt,actionMessage:e.slidedown.actionMessage||t,acceptButtonText:e.slidedown.acceptButtonText||"Allow",cancelButtonText:e.slidedown.cancelButtonText||"No Thanks"}:{enabled:!1,autoPrompt:!1,actionMessage:e.actionMessage||t,acceptButtonText:e.acceptButtonText||"Allow",cancelButtonText:e.cancelButtonText||"No Thanks"}:{enabled:!1,autoPrompt:!1,actionMessage:t,acceptButtonText:"Allow",cancelButtonText:"No Thanks"}}static getFullscreenPermissionMessageOptions(e){return e?e.fullscreen?{autoAcceptTitle:e.fullscreen.autoAcceptTitle,actionMessage:e.fullscreen.actionMessage,exampleNotificationTitleDesktop:e.fullscreen.title,exampleNotificationTitleMobile:e.fullscreen.title,exampleNotificationMessageDesktop:e.fullscreen.message,exampleNotificationMessageMobile:e.fullscreen.message,exampleNotificationCaption:e.fullscreen.caption,acceptButtonText:e.fullscreen.acceptButton,cancelButtonText:e.fullscreen.cancelButton}:e:null}static getPromptOptionsQueryString(){let e="";if(G.getFullscreenPermissionMessageOptions(OneSignal.config.userConfig.promptOptions)){let t=G.getPromptOptionsPostHash();for(let i of Object.keys(t)){e+="&"+i+"="+t[i]}}return e}static getPromptOptionsPostHash(){let e=G.getFullscreenPermissionMessageOptions(OneSignal.config.userConfig.promptOptions);if(e){var t={exampleNotificationTitleDesktop:"exampleNotificationTitle",exampleNotificationMessageDesktop:"exampleNotificationMessage",exampleNotificationTitleMobile:"exampleNotificationTitle",exampleNotificationMessageMobile:"exampleNotificationMessage"};for(let i of Object.keys(t)){let n=t[i];e[i]&&(e[n]=e[i])}for(var i=["autoAcceptTitle","siteName","autoAcceptTitle","subscribeText","showGraphic","actionMessage","exampleNotificationTitle","exampleNotificationMessage","exampleNotificationCaption","acceptButtonText","cancelButtonText","timeout"],n={},o=0;o{!0===t.data.progress?(M.a.debug("Got message from host page that remote reg. is in progress, closing popup."),e&&window.close()):M.a.debug("Got message from host page that remote reg. could not be finished.")});break;default:throw"undefined"!=typeof OneSignal&&(OneSignal._isRegisteringForPush=!1),new InvalidStateError.a(InvalidStateError.b.UnsupportedEnvironment)}return"undefined"!=typeof OneSignal&&(OneSignal._isRegisteringForPush=!1),i})}}var J=i(17),Z=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class X{constructor(e,t,i){if(this.windowReference=e,this.sendToOrigin=t,this.receiveFromOrigin=i,!window||!window.postMessage)throw new Error("Must pass in a valid window reference supporting postMessage():"+e);if(!t||!i)throw new Error("Invalid origin. Must be set.");this.emitter=new J.a,this.channel=new MessageChannel,this.messagePort=null,this.isListening=!1,this.isConnected=!1,this.replies={}}static get HANDSHAKE_MESSAGE(){return"onesignal.postmam.handshake"}static get CONNECTED_MESSAGE(){return"onesignal.postmam.connected"}listen(){M.a.debug("(Postmam) Called listen()."),this.isListening?M.a.debug("(Postmam) Already listening for Postmam connections."):l.a.isBrowser()&&(this.isListening=!0,M.a.debug("(Postmam) Listening for Postmam connections.",this),window.addEventListener("message",this.onWindowMessagePostmanConnectReceived.bind(this)))}startPostMessageReceive(){window.addEventListener("message",this.onWindowPostMessageReceived.bind(this))}stopPostMessageReceive(){window.removeEventListener("message",this.onWindowPostMessageReceived)}destroy(){this.stopPostMessageReceive(),this.emitter.removeAllListeners()}onWindowPostMessageReceived(e){if(!this.isSafeOrigin(e.origin))return;let{id:t,command:i,data:n,source:o}=e.data;if(i===X.CONNECTED_MESSAGE)return this.emitter.emit("connect"),void(this.isConnected=!0);let s={id:t,command:i,data:n,source:o},r=Object.assign({reply:this.reply.bind(this,s)},s);if(this.replies.hasOwnProperty(t)){M.a.info("(Postmam) This message is a reply."),!1===this.replies[t].bind(window)(r)&&delete this.replies[t]}else this.emitter.emit(i,r)}onWindowMessagePostmanConnectReceived(e){const t=E.a.getWindowEnv().toString();if(M.a.debug(`(Postmam) (${t}) Window postmessage for Postman connect received:`,e),this.isSafeOrigin(e.origin)){var{handshake:i}=e.data;i===X.HANDSHAKE_MESSAGE?(M.a.info("(Postmam) Got our expected Postmam handshake message (and connecting...):",e.data),window.removeEventListener("message",this.onWindowMessagePostmanConnectReceived),this.messagePort=e.ports[0],this.messagePort.addEventListener("message",this.onMessageReceived.bind(this),!1),M.a.info("(Postmam) Removed previous message event listener for handshakes, replaced with main message listener."),this.messagePort.start(),this.isConnected=!0,M.a.info(`(Postmam) (${t}) Connected.`),this.message(X.CONNECTED_MESSAGE),this.emitter.emit("connect")):M.a.info("(Postmam) Got a postmam message, but not our expected handshake:",e.data)}}connect(){M.a.info(`(Postmam) (${E.a.getWindowEnv().toString()}) Establishing a connection to ${this.sendToOrigin}.`),this.messagePort=this.channel.port1,this.messagePort.addEventListener("message",this.onMessageReceived.bind(this),!1),this.messagePort.start(),this.windowReference.postMessage({handshake:X.HANDSHAKE_MESSAGE},this.sendToOrigin,[this.channel.port2])}onMessageReceived(e){if(!e.data)return void M.a.debug(`(${E.a.getWindowEnv().toString()}) Received an empty Postmam message:`,e);let{id:t,command:i,data:n,source:o}=e.data;if(i===X.CONNECTED_MESSAGE)return this.emitter.emit("connect"),void(this.isConnected=!0);let s={id:t,command:i,data:n,source:o},r=Object.assign({reply:this.reply.bind(this,s)},s);if(this.replies.hasOwnProperty(t)){!1===this.replies[t].bind(window)(r)&&delete this.replies[t]}else this.emitter.emit(i,r)}reply(e,t,i){const n={id:e.id,command:e.command,data:t,source:E.a.getWindowEnv().toString(),isReply:!0};"function"==typeof i&&(this.replies[n.id]=i),this.messagePort.postMessage(n)}postMessage(e,t,i){if(!e||""==e)throw new Error("(Postmam) Postmam command must not be empty.");if("function"==typeof t)return void M.a.debug("You passed a function to data, did you mean to pass null?");const n={id:y.a.getRandomUuid(),command:e,data:t,source:E.a.getWindowEnv().toString()};"function"==typeof i&&(this.replies[n.id]=i),this.windowReference.postMessage(n,"*")}message(e,t,i){if(!e||""==e)throw new Error("(Postmam) Postmam command must not be empty.");if("function"==typeof t)return void M.a.debug("You passed a function to data, did you mean to pass null?");const n={id:y.a.getRandomUuid(),command:e,data:t,source:E.a.getWindowEnv().toString()};"function"==typeof i&&(this.replies[n.id]=i),this.messagePort.postMessage(n)}generateSafeOrigins(e){const t=[];try{const i=new URL(e);let n=i.host;0===i.host.indexOf("www.")&&(n=i.host.replace("www.","")),"https:"===i.protocol?(t.push(`https://${n}`),t.push(`https://www.${n}`)):"http:"===i.protocol&&(t.push(`http://${n}`),t.push(`http://www.${n}`),t.push(`https://${n}`),t.push(`https://www.${n}`))}catch(e){}return t}isSafeOrigin(e){if(OneSignal.config)t=OneSignal.config.subdomain;else var t="x";const i=this.generateSafeOrigins(this.receiveFromOrigin);return"https://onesignal.com"===e||e===`https://${t||""}.onesignal.com`||e===`https://${t||""}.os.tc`||e===`https://${t||""}.os.tc:3001`||e===E.a.getOneSignalApiUrl().origin||"*"===this.receiveFromOrigin||P.a.contains(i,e)}on(...e){return Z(this,void 0,void 0,function*(){return this.emitter.on.apply(this.emitter,e)})}off(...e){return Z(this,void 0,void 0,function*(){return this.emitter.off.apply(this.emitter,e)})}once(...e){return Z(this,void 0,void 0,function*(){return this.emitter.once.apply(this.emitter,e)})}}var Q=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class ee{constructor(e,t){this.appId=e,this.registrationOptions=t}load(){return Q(this,void 0,void 0,function*(){const e=yield OneSignal.isPushNotificationsEnabled(),t=yield OneSignal.getNotificationPermission();this.url=E.a.getOneSignalApiUrl(),this.url.pathname="webPushModal",this.url.search=`${G.getPromptOptionsQueryString()}&id=${this.appId}&httpsPrompt=true&pushEnabled=${e}&permissionBlocked=${"denied"===t}&promptType=modal`,M.a.info(`Loading iFrame for HTTPS subscription modal at ${this.url.toString()}`),this.modal=this.createHiddenSubscriptionDomModal(this.url.toString()),this.establishCrossOriginMessaging()})}createHiddenSubscriptionDomModal(e){let t=document.createElement("div");t.setAttribute("id","OneSignal-iframe-modal"),t.setAttribute("style","display:none !important"),t.innerHTML='
',document.body.appendChild(t);let i=document.createElement("style");i.innerHTML="@media (max-width: 560px) { .OneSignal-permission-iframe { width: 100%; height: 100%;} }",document.getElementsByTagName("head")[0].appendChild(i);let n=document.createElement("iframe");return n.className="OneSignal-permission-iframe",n.setAttribute("frameborder","0"),n.width=OneSignal._windowWidth.toString(),n.height=OneSignal._windowHeight.toString(),n.src=e,document.getElementById("notif-permission").appendChild(n),n}removeFrame(){const e=document.querySelector("#OneSignal-iframe-modal");e&&e.remove()}showSubscriptionDomModal(){document.getElementById("OneSignal-iframe-modal").setAttribute("style","")}establishCrossOriginMessaging(){this.messenger=new X(this.modal,this.url.origin,this.url.origin),this.messenger.startPostMessageReceive(),this.messenger.once(OneSignal.POSTMAM_COMMANDS.MODAL_LOADED,this.onModalLoaded.bind(this)),this.messenger.once(OneSignal.POSTMAM_COMMANDS.MODAL_PROMPT_ACCEPTED,this.onModalAccepted.bind(this)),this.messenger.once(OneSignal.POSTMAM_COMMANDS.MODAL_PROMPT_REJECTED,this.onModalRejected.bind(this)),this.messenger.once(OneSignal.POSTMAM_COMMANDS.POPUP_CLOSING,this.onModalClosing.bind(this))}onModalLoaded(e){this.showSubscriptionDomModal(),m.a.trigger("modalLoaded")}onModalAccepted(e){return Q(this,void 0,void 0,function*(){M.a.debug("User accepted the HTTPS modal prompt.",location.origin),OneSignal._sessionInitAlreadyRunning=!1,this.dispose(),G.triggerCustomPromptClicked("granted"),M.a.debug("Calling setSubscription(true)"),yield Y.registerForPush(),yield OneSignal.setSubscription(!0)})}onModalRejected(e){M.a.debug("User rejected the HTTPS modal prompt."),OneSignal._sessionInitAlreadyRunning=!1,this.dispose(),G.triggerCustomPromptClicked("denied")}onModalClosing(e){M.a.info("Detected modal is closing."),this.dispose()}dispose(){this.messenger&&this.messenger.destroy(),this.removeFrame()}message(){this.messenger.message.apply(this.messenger,arguments)}}var te,ie,ne=i(11),oe=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};(ie=te||(te={})).WorkerVersion="GetWorkerVersion",ie.Subscribe="Subscribe",ie.SubscribeNew="SubscribeNew",ie.AmpSubscriptionState="amp-web-push-subscription-state",ie.AmpSubscribe="amp-web-push-subscribe",ie.AmpUnsubscribe="amp-web-push-unsubscribe",ie.NotificationDisplayed="notification.displayed",ie.NotificationClicked="notification.clicked",ie.NotificationDismissed="notification.dismissed",ie.RedirectPage="command.redirect";class se{constructor(){this.replies={}}addListener(e,t,i){const n={callback:t,onceListenerOnly:i},o=this.replies[e.toString()];o?o.push(n):this.replies[e.toString()]=[n]}findListenersForMessage(e){return this.replies[e.toString()]||[]}deleteListenerRecords(e){this.replies[e.toString()]=null}deleteAllListenerRecords(){this.replies={}}deleteListenerRecord(e,t){const i=this.replies[e.toString()];if(null!=i)for(let e=i.length-1;e>=0;e--){i[e]===t&&i.splice(e,1)}}}class re{constructor(e,t=new se){this.context=e,this.replies=t}broadcast(e,t){return oe(this,void 0,void 0,function*(){if(E.a.getWindowEnv()===L.a.ServiceWorker){const i=yield self.clients.matchAll({type:"window",includeUncontrolled:!0});for(let n of i)M.a.debug(`[Worker Messenger] [SW -> Page] Broadcasting '${e.toString()}' to window client ${n.url}.`),n.postMessage({command:e,payload:t})}})}unicast(e,t,i){return oe(this,void 0,void 0,function*(){if(E.a.getWindowEnv()===L.a.ServiceWorker){if(!i)throw new InvalidArgumentError.a("windowClient",InvalidArgumentError.b.Empty);M.a.debug(`[Worker Messenger] [SW -> Page] Unicasting '${e.toString()}' to window client ${i.url}.`),i.postMessage({command:e,payload:t})}else(yield this.isWorkerControllingPage())||M.a.debug("[Worker Messenger] The page is not controlled by the service worker yet. Waiting...",self.registration),yield this.waitUntilWorkerControlsPage(),M.a.debug(`[Worker Messenger] [Page -> SW] Unicasting '${e.toString()}' to service worker.`),navigator.serviceWorker.controller.postMessage({command:e,payload:t})})}listen(e){return oe(this,void 0,void 0,function*(){if(!l.a.supportsServiceWorkers())return;E.a.getWindowEnv()===L.a.ServiceWorker?(self.addEventListener("message",this.onWorkerMessageReceivedFromPage.bind(this)),M.a.debug("[Worker Messenger] Service worker is now listening for messages.")):yield this.listenForPage(e)})}listenForPage(e){return oe(this,void 0,void 0,function*(){e||((yield this.isWorkerControllingPage())||M.a.debug(`(${location.origin}) [Worker Messenger] The page is not controlled by the service worker yet. Waiting...`,self.registration),yield this.waitUntilWorkerControlsPage(),M.a.debug(`(${location.origin}) [Worker Messenger] The page is now controlled by the service worker.`)),navigator.serviceWorker.addEventListener("message",this.onPageMessageReceivedFromServiceWorker.bind(this)),M.a.debug(`(${location.origin}) [Worker Messenger] Page is now listening for messages.`)})}onWorkerMessageReceivedFromPage(e){const t=e.data;if(!t||!t.command)return;const i=this.replies.findListenersForMessage(t.command),n=[],o=[];M.a.debug("[Worker Messenger] Service worker received message:",e.data);for(let e of i)e.onceListenerOnly&&n.push(e),o.push(e);for(let e=n.length-1;e>=0;e--){const i=n[e];this.replies.deleteListenerRecord(t.command,i)}for(let e of o)e.callback.apply(null,[t.payload])}onPageMessageReceivedFromServiceWorker(e){const t=e.data;if(!t||!t.command)return;const i=this.replies.findListenersForMessage(t.command),n=[],o=[];M.a.debug("[Worker Messenger] Page received message:",e.data);for(let e of i)e.onceListenerOnly&&n.push(e),o.push(e);for(let e=n.length-1;e>=0;e--){const i=n[e];this.replies.deleteListenerRecord(t.command,i)}for(let e of o)e.callback.apply(null,[t.payload])}on(e,t){this.replies.addListener(e,t,!1)}once(e,t){this.replies.addListener(e,t,!0)}off(e){e?this.replies.deleteListenerRecords(e):this.replies.deleteAllListenerRecords()}isWorkerControllingPage(){return oe(this,void 0,void 0,function*(){if(E.a.getWindowEnv()===L.a.ServiceWorker)return!!self.registration.active;{const e=yield this.context.serviceWorkerManager.getActiveState();return e===ne.a.WorkerA||e===ne.a.WorkerB}})}waitUntilWorkerControlsPage(){return oe(this,void 0,void 0,function*(){return new Promise(e=>oe(this,void 0,void 0,function*(){if(yield this.isWorkerControllingPage())e();else{E.a.getWindowEnv()===L.a.ServiceWorker?self.addEventListener("activate",t=>oe(this,void 0,void 0,function*(){(yield this.isWorkerControllingPage())&&e()})):navigator.serviceWorker.addEventListener("controllerchange",t=>oe(this,void 0,void 0,function*(){(yield this.isWorkerControllingPage())&&e()}))}}))})}}var ae=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class ce{constructor(){this.cache={}}getCache(){return Object.assign({},this.cache)}loadSdkStylesheet(){return ae(this,void 0,void 0,function*(){const e=E.a.getOneSignalResourceUrlPath(),t=E.a.getOneSignalCssFileName();return yield this.loadIfNew(0,new URL(`${e}/${t}?v=${l.a.getSdkStylesVersionHash()}`))})}loadFetchPolyfill(){return ae(this,void 0,void 0,function*(){return yield this.loadIfNew(1,new URL("https://cdnjs.cloudflare.com/ajax/libs/fetch/2.0.3/fetch.min.js"))})}loadIfNew(e,t){return ae(this,void 0,void 0,function*(){return this.cache[t.toString()]||(this.cache[t.toString()]=ce.load(e,t)),yield this.cache[t.toString()]})}static load(e,t){return ae(this,void 0,void 0,function*(){try{return yield new Promise((i,n)=>{switch(e){case 1:(o=document.createElement("script")).setAttribute("type","text/javascript"),o.setAttribute("async","async"),o.setAttribute("src",t.toString());break;case 0:var o;(o=document.createElement("link")).setAttribute("rel","stylesheet"),o.setAttribute("href",t.toString())}o.onerror=n,o.onload=i,document.querySelector("head").appendChild(o)}),0}catch(e){return 1}})}}var le=i(15),ue=i(18);class de{constructor(e,t,i,n="shown",o=["opacity","transform"],s,r=500){this.selector=e,this.showClass=t,this.hideClass=i,this.state=n,this.targetTransitionEvents=o,this.nestedContentSelector=s,this.transitionCheckTimeout=r}show(){return this.hidden?new Promise(e=>{this.state="showing",m.a.trigger(de.EVENTS.SHOWING,this);const t=this.element;if(t?(this.hideClass&&Object(k.t)(t,this.hideClass),this.showClass&&Object(k.a)(t,this.showClass)):M.a.error(`(show) could not find animated element with selector ${this.selector}`),0==this.targetTransitionEvents.length)return e(this);var i=setTimeout(()=>{M.a.debug(`Element did not completely show (state: ${this.state}).`)},this.transitionCheckTimeout);Object(k.s)(this.element,"transitionend",(t,n)=>{if(t.target===this.element&&Object(k.f)(this.targetTransitionEvents,t.propertyName))return clearTimeout(i),n(),this.state="shown",m.a.trigger(de.EVENTS.SHOWN,this),e(this)},!0)}):Promise.resolve(this)}hide(){return this.shown?new Promise(e=>{this.state="hiding",m.a.trigger(de.EVENTS.HIDING,this);const t=this.element;if(t?(this.showClass&&Object(k.t)(t,this.showClass),this.hideClass&&Object(k.a)(t,this.hideClass)):M.a.error(`(hide) could not find animated element with selector ${this.selector}`),0==this.targetTransitionEvents.length)return e(this);Object(k.s)(this.element,"transitionend",(t,i)=>{var n=setTimeout(()=>{M.a.debug(`Element did not completely hide (state: ${this.state}).`)},this.transitionCheckTimeout);if(t.target===this.element&&Object(k.f)(this.targetTransitionEvents,t.propertyName))return clearTimeout(n),i(),this.state="hidden",m.a.trigger(de.EVENTS.HIDDEN,this),e(this)},!0)}):Promise.resolve(this)}waitUntilShown(){return"shown"===this.state?Promise.resolve(this):new Promise(e=>{Gt.emitter.once(de.EVENTS.SHOWN,t=>{if(t===this)return e(this)})})}waitUntilHidden(){return"hidden"===this.state?Promise.resolve(this):new Promise(e=>{Gt.emitter.once(de.EVENTS.HIDDEN,t=>{if(t===this)return e(this)})})}static get EVENTS(){return{SHOWING:"animatedElementShowing",SHOWN:"animatedElementShown",HIDING:"animatedElementHiding",HIDDEN:"animatedElementHidden"}}get content(){if(!this.element)return"";if(this.nestedContentSelector){const e=this.element.querySelector(this.nestedContentSelector);return e?e.innerHTML:""}return this.element.innerHTML}set content(e){if(this.element)if(this.nestedContentSelector){const t=this.element.querySelector(this.nestedContentSelector);t&&(t.innerHTML=e)}else this.element.innerHTML=e}get element(){return document.querySelector(this.selector)}get showing(){return"showing"===this.state}get shown(){return"shown"===this.state}get hiding(){return"hiding"===this.state}get hidden(){return"hidden"===this.state}}class ge extends de{constructor(e,t,i,n,o,s="shown",r="active",a=["opacity","transform"],c){super(e,t,i,s,a),this.selector=e,this.showClass=t,this.hideClass=i,this.activeClass=n,this.inactiveClass=o,this.state=s,this.activeState=r,this.targetTransitionEvents=a,this.nestedContentSelector=c}activate(){return this.inactive&&this.shown?new Promise(e=>{this.activeState="activating",m.a.trigger(ge.EVENTS.ACTIVATING,this);const t=this.element;if(t?(this.inactiveClass&&Object(k.t)(t,this.inactiveClass),this.activeClass&&Object(k.a)(t,this.activeClass)):M.a.error("Could not find active animated element"),!this.shown)return M.a.debug("Ending activate() transition (alternative)."),this.activeState="active",m.a.trigger(ge.EVENTS.ACTIVE,this),e(this);if(0==this.targetTransitionEvents.length)return e(this);var i=setTimeout(()=>{M.a.debug(`Element did not completely activate (state: ${this.state}, activeState: ${this.activeState}).`)},this.transitionCheckTimeout);Object(k.s)(this.element,"transitionend",(t,n)=>{if(t.target===this.element&&Object(k.f)(this.targetTransitionEvents,t.propertyName))return clearTimeout(i),n(),this.activeState="active",m.a.trigger(ge.EVENTS.ACTIVE,this),e(this)},!0)}):Promise.resolve(this)}inactivate(){return this.active?new Promise(e=>{this.activeState="inactivating",m.a.trigger(ge.EVENTS.INACTIVATING,this);const t=this.element;if(t?(this.activeClass&&Object(k.t)(t,this.activeClass),this.inactiveClass&&Object(k.a)(t,this.inactiveClass)):M.a.error("Could not find active animated element"),!this.shown)return this.activeState="inactive",m.a.trigger(ge.EVENTS.INACTIVE,this),e(this);if(0==this.targetTransitionEvents.length)return e(this);var i=setTimeout(()=>{M.a.debug(`Element did not completely inactivate (state: ${this.state}, activeState: ${this.activeState}).`)},this.transitionCheckTimeout);Object(k.s)(this.element,"transitionend",(t,n)=>{if(t.target===this.element&&Object(k.f)(this.targetTransitionEvents,t.propertyName))return clearTimeout(i),n(),this.activeState="inactive",m.a.trigger(ge.EVENTS.INACTIVE,this),e(this)},!0)}):Promise.resolve(this)}waitUntilActive(){return this.active?Promise.resolve(this):new Promise(e=>{Gt.emitter.once(ge.EVENTS.ACTIVE,t=>{if(t===this)return e(this)})})}waitUntilInactive(){return this.inactive?Promise.resolve(this):new Promise(e=>{Gt.emitter.once(ge.EVENTS.INACTIVE,t=>{if(t===this)return e(this)})})}static get EVENTS(){return Object.assign({},de.EVENTS,{ACTIVATING:"activeAnimatedElementActivating",ACTIVE:"activeAnimatedElementActive",INACTIVATING:"activeAnimatedElementInactivating",INACTIVE:"activeAnimatedElementInactive"})}get activating(){return"activating"===this.activeState}get active(){return"active"===this.activeState}get inactivating(){return"inactivating"===this.activeState}get inactive(){return"inactive"===this.activeState}}class he extends ge{constructor(){super(".onesignal-bell-launcher-badge","onesignal-bell-launcher-badge-opened",null,"onesignal-bell-launcher-badge-active",null,"hidden")}increment(){if(!isNaN(this.content)){let e=+this.content;e+=1,this.content=e.toString()}}show(){const e=super.show();return OneSignal.notifyButton.setCustomColorsIfSpecified(),e}decrement(){if(!isNaN(this.content)){let e=+this.content;e-=1,this.content=e>0?e.toString():""}}}class pe extends de{constructor(e){super(".onesignal-bell-launcher-message","onesignal-bell-launcher-message-opened",void 0,"hidden",["opacity","transform"],".onesignal-bell-launcher-message-body"),this.bell=e,this.contentType="",this.queued=[]}static get TIMEOUT(){return 2500}static get TYPES(){return{TIP:"tip",MESSAGE:"message",QUEUED:"queued"}}display(e,t,i=0){return M.a.debug(`Calling %cdisplay(${e}, ${t}, ${i}).`,Object(k.j)("code")),(this.shown?this.hide():Object(k.r)()).then(()=>{this.content=Object(k.g)(t),this.contentType=e}).then(()=>this.show()).then(()=>Object(k.h)(i)).then(()=>this.hide()).then(()=>{this.content=this.getTipForState(),this.contentType="tip"})}getTipForState(){return this.bell.state===Oe.STATES.UNSUBSCRIBED?this.bell.options.text["tip.state.unsubscribed"]:this.bell.state===Oe.STATES.SUBSCRIBED?this.bell.options.text["tip.state.subscribed"]:this.bell.state===Oe.STATES.BLOCKED?this.bell.options.text["tip.state.blocked"]:""}enqueue(e){return this.queued.push(Object(k.g)(e)),new Promise(e=>{this.bell.badge.shown?this.bell.badge.hide().then(()=>this.bell.badge.increment()).then(()=>this.bell.badge.show()).then(e):(this.bell.badge.increment(),this.bell.initialized?this.bell.badge.show().then(e):e())})}dequeue(e){let t=this.queued.pop(e);return new Promise(e=>{this.bell.badge.shown?this.bell.badge.hide().then(()=>this.bell.badge.decrement()).then(e=>e>0?this.bell.badge.show():Promise.resolve(this)).then(e(t)):(this.bell.badge.decrement(),e(t))})}}class fe extends ge{constructor(e){super(".onesignal-bell-launcher-button",void 0,void 0,"onesignal-bell-launcher-button-active",void 0,"shown",""),this.bell=e,this.events={mouse:"bell.launcher.button.mouse"};const t=this.element;t&&(t.addEventListener("touchstart",()=>{this.onHovering(),this.onTap()},{passive:!0}),t.addEventListener("mouseenter",()=>{this.onHovering()}),t.addEventListener("mouseleave",()=>{this.onHovered()}),t.addEventListener("touchmove",()=>{this.onHovered()},{passive:!0}),t.addEventListener("mousedown",()=>{this.onTap()}),t.addEventListener("mouseup",()=>{this.onEndTap()}),t.addEventListener("click",()=>{this.onHovered(),this.onClick()}))}onHovering(){(b.isEmpty(this.events.mouse)||"out"===b.getLast(this.events.mouse))&&m.a.trigger(Oe.EVENTS.HOVERING),b.put(this.events.mouse,"over")}onHovered(){b.put(this.events.mouse,"out"),m.a.trigger(Oe.EVENTS.HOVERED)}onTap(){this.pulse(),this.activate(),this.bell.badge.activate()}onEndTap(){this.inactivate(),this.bell.badge.inactivate()}onClick(){if(m.a.trigger(Oe.EVENTS.BELL_CLICK),m.a.trigger(Oe.EVENTS.LAUNCHER_CLICK),!this.bell.message.shown||this.bell.message.contentType!=pe.TYPES.MESSAGE){var e=b.getLast("subscription.optedOut");return this.bell.unsubscribed?e?this.bell.launcher.activateIfInactive().then(()=>{this.bell.showDialogProcedure()}):(Gt.registerForPushNotifications(),this.bell._ignoreSubscriptionState=!0,Gt.emitter.once(Gt.EVENTS.SUBSCRIPTION_CHANGED,()=>{this.bell.message.display(pe.TYPES.MESSAGE,this.bell.options.text["message.action.subscribed"],pe.TIMEOUT).then(()=>{this.bell._ignoreSubscriptionState=!1,this.bell.launcher.inactivate()})})):this.bell.subscribed?this.bell.launcher.activateIfInactive().then(()=>{this.bell.showDialogProcedure()}):this.bell.blocked&&(Object(k.o)()?Gt.registerForPushNotifications():this.bell.launcher.activateIfInactive().then(()=>{this.bell.showDialogProcedure()})),this.bell.message.hide()}}pulse(){Object(k.u)(".pulse-ring"),this.element&&Object(k.b)(this.element,"beforeend",'
'),this.bell.setCustomColorsIfSpecified()}}class me extends de{constructor(e){super(".onesignal-bell-launcher-dialog","onesignal-bell-launcher-dialog-opened",void 0,"hidden",["opacity","transform"],".onesignal-bell-launcher-dialog-body"),this.bell=e,this.subscribeButtonId="#onesignal-bell-container .onesignal-bell-launcher #subscribe-button",this.unsubscribeButtonId="#onesignal-bell-container .onesignal-bell-launcher #unsubscribe-button",this.notificationIcons=null}show(){return this.updateBellLauncherDialogBody().then(()=>super.show())}get subscribeButtonSelectorId(){return"subscribe-button"}get unsubscribeButtonSelectorId(){return"unsubscribe-button"}get subscribeButton(){return this.element?this.element.querySelector("#"+this.subscribeButtonSelectorId):null}get unsubscribeButton(){return this.element?this.element.querySelector("#"+this.unsubscribeButtonSelectorId):null}updateBellLauncherDialogBody(){return OneSignal.getSubscription().then(e=>{this.nestedContentSelector&&Object(k.e)(this.nestedContentSelector);let t="Nothing to show.";var i="";if(this.bell.options.showCredit&&(i='
Powered by OneSignal
'),this.bell.state===Oe.STATES.SUBSCRIBED&&!0===e||this.bell.state===Oe.STATES.UNSUBSCRIBED&&!1===e){let e="",n=Object(k.k)(this.notificationIcons);e=n?`
`:'
';let o="";o=this.bell.state!==Oe.STATES.SUBSCRIBED?``:``,t=`

${this.bell.options.text["dialog.main.title"]}

${e}
${o}
${i}`}else if(this.bell.state===Oe.STATES.BLOCKED){let e=null;c.a.chrome?c.a.mobile||c.a.tablet||(e="/bell/chrome-unblock.jpg"):c.a.firefox?e="/bell/firefox-unblock.jpg":c.a.safari?e="/bell/safari-unblock.jpg":c.a.msedge&&(e="/bell/edge-unblock.png");let n="";e&&(n=``),(c.a.mobile||c.a.tablet)&&c.a.chrome&&(n="
  1. Access Settings by tapping the three menu dots
  2. Click Site settings under Advanced.
  3. Click Notifications.
  4. Find and click this entry for this website.
  5. Click Notifications and set it to Allow.
"),t=`

${this.bell.options.text["dialog.blocked.title"]}

${this.bell.options.text["dialog.blocked.message"]}

${n}
${i}`}this.nestedContentSelector&&Object(k.b)(this.nestedContentSelector,"beforeend",t),this.subscribeButton&&this.subscribeButton.addEventListener("click",()=>{OneSignal.__doNotShowWelcomeNotification=!1,m.a.trigger(Oe.EVENTS.SUBSCRIBE_CLICK)}),this.unsubscribeButton&&this.unsubscribeButton.addEventListener("click",()=>m.a.trigger(Oe.EVENTS.UNSUBSCRIBE_CLICK)),this.bell.setCustomColorsIfSpecified()})}}var be=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class Se extends ge{constructor(e){super(".onesignal-bell-launcher","onesignal-bell-launcher-active",void 0,void 0,"onesignal-bell-launcher-inactive","hidden","active"),this.bell=e,this.wasInactive=!1}resize(e){return be(this,void 0,void 0,function*(){if(!this.element)throw new InvalidStateError.a(InvalidStateError.b.MissingDomElement);if("small"===e&&Object(k.m)(this.element,"onesignal-bell-launcher-sm")||"medium"===e&&Object(k.m)(this.element,"onesignal-bell-launcher-md")||"large"===e&&Object(k.m)(this.element,"onesignal-bell-launcher-lg"))return Promise.resolve(this);if(Object(k.t)(this.element,"onesignal-bell-launcher-sm"),Object(k.t)(this.element,"onesignal-bell-launcher-md"),Object(k.t)(this.element,"onesignal-bell-launcher-lg"),"small"===e)Object(k.a)(this.element,"onesignal-bell-launcher-sm");else if("medium"===e)Object(k.a)(this.element,"onesignal-bell-launcher-md");else{if("large"!==e)throw new Error("Invalid OneSignal bell size "+e);Object(k.a)(this.element,"onesignal-bell-launcher-lg")}return this.shown?yield new Promise(e=>{if(0==this.targetTransitionEvents.length)return e(this);var t=setTimeout(()=>{M.a.debug(`Launcher did not completely resize (state: ${this.state}, activeState: ${this.activeState}).`)},this.transitionCheckTimeout);Object(k.s)(this.element,"transitionend",(i,n)=>{if(i.target===this.element&&Object(k.f)(this.targetTransitionEvents,i.propertyName))return clearTimeout(t),n(),e(this)},!0)}):this})}activateIfInactive(){return this.inactive?(this.wasInactive=!0,this.activate()):Object(k.r)()}inactivateIfWasInactive(){return this.wasInactive?(this.wasInactive=!1,this.inactivate()):Object(k.r)()}clearIfWasInactive(){this.wasInactive=!1}inactivate(){return this.bell.message.hide().then(()=>this.bell.badge.content.length>0?this.bell.badge.hide().then(()=>Promise.all([super.inactivate(),this.resize("small")])).then(()=>this.bell.badge.show()):Promise.all([super.inactivate(),this.resize("small")]))}activate(){return this.bell.badge.content.length>0?this.bell.badge.hide().then(()=>Promise.all([super.activate(),this.resize(this.bell.options.size)])):Promise.all([super.activate(),this.resize(this.bell.options.size)])}}var ve=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})},ye='';class Oe{constructor(e,t){this.state=Oe.STATES.UNINITIALIZED,this._ignoreSubscriptionState=!1,this.hovering=!1,this.initialized=!1,this.DEFAULT_SIZE="medium",this.DEFAULT_POSITION="bottom-right",this.DEFAULT_THEME="default",this.options={enable:e.enable||!1,size:e.size||this.DEFAULT_SIZE,position:e.position||this.DEFAULT_POSITION,theme:e.theme||this.DEFAULT_THEME,showLauncherAfter:e.showLauncherAfter||10,showBadgeAfter:e.showBadgeAfter||300,text:this.setDefaultTextOptions(e.text||{}),prenotify:e.prenotify,showCredit:e.showCredit,colors:e.colors,offset:e.offset},t&&(this._launcher=t),this.options.enable&&(this.validateOptions(this.options),this.state=Oe.STATES.UNINITIALIZED,this._ignoreSubscriptionState=!1,this.installEventHooks(),this.updateState())}static get EVENTS(){return{STATE_CHANGED:"notifyButtonStateChange",LAUNCHER_CLICK:"notifyButtonLauncherClick",BELL_CLICK:"notifyButtonButtonClick",SUBSCRIBE_CLICK:"notifyButtonSubscribeClick",UNSUBSCRIBE_CLICK:"notifyButtonUnsubscribeClick",HOVERING:"notifyButtonHovering",HOVERED:"notifyButtonHover"}}static get STATES(){return{UNINITIALIZED:"uninitialized",SUBSCRIBED:"subscribed",UNSUBSCRIBED:"unsubscribed",BLOCKED:"blocked"}}static get TEXT_SUBS(){return{"prompt.native.grant":{default:"Allow",chrome:"Allow",firefox:"Always Receive Notifications",safari:"Allow"}}}showDialogProcedure(){this.dialog.shown||this.dialog.show().then(()=>{Object(k.s)(document,"click",(e,t)=>{this.dialog.element.contains(e.target)||(t(),this.dialog.shown&&this.dialog.hide().then(()=>{this.launcher.inactivateIfWasInactive()}))},!0)})}validateOptions(e){if(!e.size||!Object(k.f)(["small","medium","large"],e.size))throw new Error(`Invalid size ${e.size} for notify button. Choose among 'small', 'medium', or 'large'.`);if(!e.position||!Object(k.f)(["bottom-left","bottom-right"],e.position))throw new Error(`Invalid position ${e.position} for notify button. Choose either 'bottom-left', or 'bottom-right'.`);if(!e.theme||!Object(k.f)(["default","inverse"],e.theme))throw new Error(`Invalid theme ${e.theme} for notify button. Choose either 'default', or 'inverse'.`);if(!e.showLauncherAfter||e.showLauncherAfter<0)throw new Error(`Invalid delay duration of ${this.options.showLauncherAfter} for showing the notify button. Choose a value above 0.`);if(!e.showBadgeAfter||e.showBadgeAfter<0)throw new Error(`Invalid delay duration of ${this.options.showBadgeAfter} for showing the notify button's badge. Choose a value above 0.`)}setDefaultTextOptions(e){return{"tip.state.unsubscribed":e["tip.state.unsubscribed"]||"Subscribe to notifications","tip.state.subscribed":e["tip.state.subscribed"]||"You're subscribed to notifications","tip.state.blocked":e["tip.state.blocked"]||"You've blocked notifications","message.prenotify":e["message.prenotify"]||"Click to subscribe to notifications","message.action.subscribed":e["message.action.subscribed"]||"Thanks for subscribing!","message.action.resubscribed":e["message.action.resubscribed"]||"You're subscribed to notifications","message.action.subscribing":e["message.action.subscribing"]||"Click {{prompt.native.grant}} to receive notifications","message.action.unsubscribed":e["message.action.unsubscribed"]||"You won't receive notifications again","dialog.main.title":e["dialog.main.title"]||"Manage Site Notifications","dialog.main.button.subscribe":e["dialog.main.button.subscribe"]||"SUBSCRIBE","dialog.main.button.unsubscribe":e["dialog.main.button.unsubscribe"]||"UNSUBSCRIBE","dialog.blocked.title":e["dialog.blocked.title"]||"Unblock Notifications","dialog.blocked.message":e["dialog.blocked.message"]||"Follow these instructions to allow notifications:"}}installEventHooks(){Gt.emitter.on(Oe.EVENTS.SUBSCRIBE_CLICK,()=>{this.dialog.subscribeButton.disabled=!0,this._ignoreSubscriptionState=!0,Gt.setSubscription(!0).then(()=>(this.dialog.subscribeButton.disabled=!1,this.dialog.hide())).then(()=>this.message.display(pe.TYPES.MESSAGE,this.options.text["message.action.resubscribed"],pe.TIMEOUT)).then(()=>(this._ignoreSubscriptionState=!1,this.launcher.clearIfWasInactive(),this.launcher.inactivate())).then(()=>this.updateState())}),Gt.emitter.on(Oe.EVENTS.UNSUBSCRIBE_CLICK,()=>{this.dialog.unsubscribeButton.disabled=!0,Gt.setSubscription(!1).then(()=>(this.dialog.unsubscribeButton.disabled=!1,this.dialog.hide())).then(()=>(this.launcher.clearIfWasInactive(),this.launcher.activate())).then(()=>this.message.display(pe.TYPES.MESSAGE,this.options.text["message.action.unsubscribed"],pe.TIMEOUT)).then(()=>this.updateState())}),Gt.emitter.on(Oe.EVENTS.HOVERING,()=>{this.hovering=!0,this.launcher.activateIfInactive(),this.message.shown||this.dialog.shown?this.hovering=!1:this.message.contentType!==pe.TYPES.MESSAGE?new Promise(e=>{if(this.message.queued.length>0)return this.message.dequeue().then(t=>{this.message.content=t,this.message.contentType=pe.TYPES.QUEUED,e()});this.message.content=Object(k.g)(this.message.getTipForState()),this.message.contentType=pe.TYPES.TIP,e()}).then(()=>this.message.show()).then(()=>{this.hovering=!1}):this.hovering=!1}),Gt.emitter.on(Oe.EVENTS.HOVERED,()=>{this.message.contentType!==pe.TYPES.MESSAGE&&this.dialog.hidden&&(this.hovering&&(this.hovering=!1,this.message.waitUntilShown().then(()=>Object(k.h)(pe.TIMEOUT)).then(()=>this.message.hide()).then(()=>{this.launcher.wasInactive&&this.dialog.hidden&&(this.launcher.inactivate(),this.launcher.wasInactive=!1)})),this.message.shown&&this.message.hide().then(()=>{this.launcher.wasInactive&&this.dialog.hidden&&(this.launcher.inactivate(),this.launcher.wasInactive=!1)}))}),Gt.emitter.on(Gt.EVENTS.SUBSCRIPTION_CHANGED,e=>ve(this,void 0,void 0,function*(){if(1==e&&(this.badge.shown&&this.options.prenotify&&this.badge.hide(),null===this.dialog.notificationIcons)){const e=yield G.getNotificationIcons();this.dialog.notificationIcons=e}Gt.getNotificationPermission(t=>{let i;i=e?Oe.STATES.SUBSCRIBED:t===U.Denied?Oe.STATES.BLOCKED:Oe.STATES.UNSUBSCRIBED,this.setState(i,this._ignoreSubscriptionState)})})),Gt.emitter.on(Oe.EVENTS.STATE_CHANGED,e=>{this.launcher.element&&(e.to===Oe.STATES.SUBSCRIBED?this.launcher.inactivate():(e.to===Oe.STATES.UNSUBSCRIBED||Oe.STATES.BLOCKED)&&this.launcher.activate())}),Gt.emitter.on(Gt.EVENTS.NATIVE_PROMPT_PERMISSIONCHANGED,()=>{this.updateState()})}addDefaultClasses(){const e=this.container;if("bottom-left"===this.options.position)e&&Object(k.a)(e,"onesignal-bell-container-bottom-left"),Object(k.a)(this.launcher.selector,"onesignal-bell-launcher-bottom-left");else{if("bottom-right"!==this.options.position)throw new Error("Invalid OneSignal notify button position "+this.options.position);e&&Object(k.a)(e,"onesignal-bell-container-bottom-right"),Object(k.a)(this.launcher.selector,"onesignal-bell-launcher-bottom-right")}if("default"===this.options.theme)Object(k.a)(this.launcher.selector,"onesignal-bell-launcher-theme-default");else{if("inverse"!==this.options.theme)throw new Error("Invalid OneSignal notify button theme "+this.options.theme);Object(k.a)(this.launcher.selector,"onesignal-bell-launcher-theme-inverse")}}create(){return ve(this,void 0,void 0,function*(){if(!this.options.enable)return;if(0!==(yield Gt.context.dynamicResourceLoader.loadSdkStylesheet()))return void M.a.debug("Not showing notify button because styles failed to load.");this.container&&Object(k.u)("#onesignal-bell-container"),Object(k.b)("body","beforeend",'
'),this.container&&Object(k.b)(this.container,"beforeend",'
'),Object(k.b)(this.launcher.selector,"beforeend",'
'),Object(k.b)(this.launcher.selector,"beforeend",'
'),Object(k.b)(this.launcher.selector,"beforeend",'
'),Object(k.b)(this.message.selector,"beforeend",'
'),Object(k.b)(this.launcher.selector,"beforeend",'
'),Object(k.b)(this.dialog.selector,"beforeend",'
'),Object(k.b)(this.button.selector,"beforeend",ye);const e=yield Gt.isPushNotificationsEnabled(),t=yield Gt.getSubscription(),i=yield G.wasHttpsNativePromptDismissed();let n=e?"small":this.options.size||this.DEFAULT_SIZE;yield this.launcher.resize(n),this.addDefaultClasses(),this.applyOffsetIfSpecified(),this.setCustomColorsIfSpecified(),this.patchSafariSvgFilterBug(),M.a.info("Showing the notify button."),yield(e?this.launcher.inactivate():Object(k.r)()).then(()=>Gt.getSubscription()).then(t=>!e&&t||null!==this.dialog.notificationIcons?Object(k.r)():G.getNotificationIcons().then(e=>{this.dialog.notificationIcons=e})).then(()=>Object(k.h)(this.options.showLauncherAfter||0)).then(()=>Object(k.o)()&&t&&!0!==i&&!e&&!0===Gt.config.userConfig.promptOptions.autoPrompt&&!G.isHttpPromptAlreadyShown()?(M.a.debug("Not showing notify button because popover will be shown."),Object(k.r)()):this.launcher.show()).then(()=>Object(k.h)(this.options.showBadgeAfter||0)).then(()=>this.options.prenotify&&!e&&Gt._isNewVisitor?this.message.enqueue(this.options.text["message.prenotify"]).then(()=>this.badge.show()):Object(k.r)()).then(()=>this.initialized=!0)})}patchSafariSvgFilterBug(){if(!(c.a.safari&&Number(c.a.version)>=9.1)){let e="drop-shadow(0 2px 4px rgba(34,36,38,0.35));",t="drop-shadow(0 2px 4px rgba(34,36,38,0));",i="drop-shadow(0px 2px 2px rgba(34,36,38,.15));";this.graphic.setAttribute("style",`filter: ${e}; -webkit-filter: ${e};`),this.badge.element.setAttribute("style",`filter: ${t}; -webkit-filter: ${t};`),this.dialog.element.setAttribute("style",`filter: ${i}; -webkit-filter: ${i};`)}c.a.safari&&this.badge.element.setAttribute("style","display: none;")}applyOffsetIfSpecified(){let e=this.options.offset;if(e){const t=this.launcher.element;if(!t)return void M.a.error("Could not find bell dom element");t.style.cssText="",e.bottom&&(t.style.cssText+=`bottom: ${e.bottom};`),"bottom-right"===this.options.position?e.right&&(t.style.cssText+=`right: ${e.right};`):"bottom-left"===this.options.position&&e.left&&(t.style.cssText+=`left: ${e.left};`)}}setCustomColorsIfSpecified(){let e=this.dialog.element.querySelector("button.action"),t=this.button.element.querySelector(".pulse-ring");this.graphic.querySelector(".background").style.cssText="";let i=this.graphic.querySelectorAll(".foreground");for(let e=0;e{this.setState(e?Oe.STATES.SUBSCRIBED:Oe.STATES.UNSUBSCRIBED),t===U.Denied&&this.setState(Oe.STATES.BLOCKED)})}setState(e,t=!1){let i=this.state;this.state=e,i===e||t||m.a.trigger(Oe.EVENTS.STATE_CHANGED,{from:i,to:e})}get container(){return document.querySelector("#onesignal-bell-container")}get graphic(){return this.button.element.querySelector("svg")}get launcher(){return this._launcher||(this._launcher=new Se(this)),this._launcher}get button(){return this._button||(this._button=new fe(this)),this._button}get badge(){return this._badge||(this._badge=new he),this._badge}get message(){return this._message||(this._message=new pe(this)),this._message}get dialog(){return this._dialog||(this._dialog=new me(this)),this._dialog}get subscribed(){return this.state===Oe.STATES.SUBSCRIBED}get unsubscribed(){return this.state===Oe.STATES.UNSUBSCRIBED}get blocked(){return this.state===Oe.STATES.BLOCKED}}class we{constructor(e){if(!e)throw new InvalidArgumentError.a("path",InvalidArgumentError.b.Empty);this.path=e.trim()}getQueryString(){const e=this.path.indexOf("?");return-1===e?null:this.path.length>e?this.path.substring(e+1):null}getWithoutQueryString(){return this.path.split(we.QUERY_STRING)[0]}getFileName(){return this.getWithoutQueryString().split("\\").pop().split("/").pop()}getFileNameWithQuery(){return this.path.split("\\").pop().split("/").pop()}getFullPath(){return this.path}getPathWithoutFileName(){const e=this.getWithoutQueryString(),t=e.lastIndexOf(this.getFileName());let i=e.substring(0,t);return i=i.replace(/[\\\/]$/,"")}}we.QUERY_STRING="?";class Ee extends u.a{constructor(e,t){super("Registration of a Service Worker failed."),this.status=e,this.statusText=t,Object.setPrototypeOf(this,Ee.prototype)}}var Pe=Ee,Ie=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class Te{constructor(e,t){this.context=e,this.config=t}static getRegistration(){return Ie(this,void 0,void 0,function*(){return yield ne.b.getRegistration()})}getActiveState(){return Ie(this,void 0,void 0,function*(){const e=yield E.a.getIntegration();if(e===le.a.InsecureProxy)return ne.a.Indeterminate;if(e===le.a.SecureProxy){switch(E.a.getWindowEnv()){case L.a.Host:case L.a.CustomIframe:const e=OneSignal.proxyFrameHost;return e?yield e.runCommand(OneSignal.POSTMAM_COMMANDS.SERVICE_WORKER_STATE):ne.a.Indeterminate;case L.a.OneSignalSubscriptionPopup:break;case L.a.OneSignalSubscriptionModal:throw new v}}const t=yield Te.getRegistration();if(!t)return ne.a.None;if(t.installing)return ne.a.Installing;if(!t.active)return ne.a.ThirdParty;const i=Te.activeSwFileName(t),n=this.swActiveStateByFileName(i);return navigator.serviceWorker.controller||n!==ne.a.WorkerA&&n!==ne.a.WorkerB?n:ne.a.Bypassed})}static activeSwFileName(e){if(!e.active)return null;const t=new URL(e.active.scriptURL).pathname,i=new we(t).getFileName();if("akam-sw.js"==i){const t=new URLSearchParams(new URL(e.active.scriptURL).search).get("othersw");if(t)return M.a.debug("Found a ServiceWorker under Akamai's akam-sw.js?othersw=",t),new we(new URL(t).pathname).getFileName()}return i}swActiveStateByFileName(e){return e?e==this.config.workerAPath.getFileName()?ne.a.WorkerA:e==this.config.workerBPath.getFileName()?ne.a.WorkerB:ne.a.ThirdParty:ne.a.None}getWorkerVersion(){return Ie(this,void 0,void 0,function*(){return new Promise(e=>Ie(this,void 0,void 0,function*(){if(y.b.isUsingSubscriptionWorkaround()){const t=OneSignal.proxyFrameHost;if(t){const i=yield t.runCommand(OneSignal.POSTMAM_COMMANDS.GET_WORKER_VERSION);e(i)}else e(NaN)}else this.context.workerMessenger.once(te.WorkerVersion,t=>{e(t)}),this.context.workerMessenger.unicast(te.WorkerVersion)}))})}shouldInstallWorker(){return Ie(this,void 0,void 0,function*(){const e=yield this.getActiveState();return e!==ne.a.WorkerA&&e!==ne.a.WorkerB})}subscribeForPushNotifications(){return Ie(this,void 0,void 0,function*(){const e=yield this.getActiveState();if(e!==ne.a.WorkerA&&e!==ne.a.WorkerB)throw new InvalidStateError.a(InvalidStateError.b.ServiceWorkerNotActivated);return new Promise(e=>{this.context.workerMessenger.once(te.Subscribe,t=>{e(ue.a.deserialize(t))}),this.context.workerMessenger.unicast(te.Subscribe,this.context.appConfig)})})}updateWorker(){return Ie(this,void 0,void 0,function*(){if(!l.a.supportsServiceWorkers())return;const e=yield this.getActiveState();let t;M.a.info("[Service Worker Update] Checking service worker version...");try{t=yield P.a.timeoutPromise(this.getWorkerVersion(),2e3)}catch(e){M.a.info("[Service Worker Update] Worker did not reply to version query; assuming older version."),t=1}e===ne.a.WorkerA||e===ne.a.WorkerB?t!==l.a.version()?(M.a.info(`[Service Worker Update] Updating service worker from v${t} --\x3e v${l.a.version()}.`),yield this.installWorker()):M.a.info(`[Service Worker Update] Service worker version is current at v${t} (no update required).`):M.a.debug(`[Service Worker Update] Not updating service worker, current active worker state is ${e}.`)})}installWorker(){return Ie(this,void 0,void 0,function*(){if(!l.a.supportsServiceWorkers())return;const e=yield this.getActiveState();yield this.installAlternatingWorker(),yield new Promise(t=>Ie(this,void 0,void 0,function*(){const i=yield this.getActiveState();M.a.debug("installWorker - Comparing pre and post states",e,i),e!==i&&i!==ne.a.Installing?t():(M.a.debug("installWorker - Awaiting on navigator.serviceWorker's 'controllerchange' event"),navigator.serviceWorker.addEventListener("controllerchange",i=>Ie(this,void 0,void 0,function*(){const i=yield this.getActiveState();i!==e&&i!==ne.a.Installing?t():M.a.error("installWorker - SW's 'controllerchange' fired but no state change!")})))})),(yield this.getActiveState())===ne.a.WorkerB&&(yield this.installAlternatingWorker()),yield this.establishServiceWorkerChannel()})}establishServiceWorkerChannel(){return Ie(this,void 0,void 0,function*(){const e=this.context.workerMessenger;e.off(),e.on(te.NotificationDisplayed,e=>{M.a.debug(location.origin,"Received notification display event from service worker."),m.a.trigger(OneSignal.EVENTS.NOTIFICATION_DISPLAYED,e)}),e.on(te.NotificationClicked,e=>Ie(this,void 0,void 0,function*(){let t;if(0===(t=E.a.getWindowEnv()===L.a.OneSignalProxyFrame?yield new Promise(e=>{const t=OneSignal.proxyFrame;t&&t.messenger.message(OneSignal.POSTMAM_COMMANDS.GET_EVENT_LISTENER_COUNT,OneSignal.EVENTS.NOTIFICATION_CLICKED,t=>{let i=t.data;e(i)})}):OneSignal.emitter.numberOfListeners(OneSignal.EVENTS.NOTIFICATION_CLICKED))){M.a.debug("notification.clicked event received, but no event listeners; storing event in IndexedDb for later retrieval.");let t=e.url;e.url||(t=location.href),yield N.a.put("NotificationOpened",{url:t,data:e,timestamp:Date.now()})}else m.a.trigger(OneSignal.EVENTS.NOTIFICATION_CLICKED,e)})),e.on(te.RedirectPage,e=>{M.a.debug(`${E.a.getWindowEnv().toString()} Picked up command.redirect to ${e}, forwarding to host page.`);const t=OneSignal.proxyFrame;t&&t.messenger.message(OneSignal.POSTMAM_COMMANDS.SERVICEWORKER_COMMAND_REDIRECT,e)}),e.on(te.NotificationDismissed,e=>{m.a.trigger(OneSignal.EVENTS.NOTIFICATION_DISMISSED,e)})})}installAlternatingWorker(){return Ie(this,void 0,void 0,function*(){const e=yield this.getActiveState();e===ne.a.ThirdParty&&M.a.info("[Service Worker Installation] 3rd party service worker detected.");const t=`${ne.b.getServiceWorkerHref(e,this.config)}?${P.a.encodeHashAsUriComponent({appId:this.context.appConfig.appId})}`;M.a.info(`[Service Worker Installation] Installing service worker ${t}.`);try{yield navigator.serviceWorker.register(t,{scope:`${y.b.getBaseUrl()}${this.config.registrationOptions.scope}`})}catch(e){if(M.a.error(`[Service Worker Installation] Installing service worker failed ${e}`),E.a.getWindowEnv()===L.a.OneSignalSubscriptionPopup)throw e;const i=yield fetch(t);if(403===i.status||404===i.status)throw new Pe(i.status,i.statusText);throw e}M.a.debug("[Service Worker Installation] Service worker installed.")})}}var Ce,Ae,Ne,Me,ke=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class xe{constructor(e,t){this.url=e,this.url.pathname="subscribe",this.options=t||{}}load(){const e=Object.assign({},G.getPromptOptionsPostHash(),{promptType:"popup",parentHostname:encodeURIComponent(location.hostname)});return this.options.autoAccept&&(e.autoAccept=!0),M.a.info(`Opening a popup to ${this.url.toString()} with POST data:`,e),this.popupWindow=this.openWindowViaPost(this.url.toString(),e,null),this.establishCrossOriginMessaging(),this.loadPromise={},this.loadPromise.promise=new Promise((e,t)=>{this.loadPromise.resolver=e,this.loadPromise.rejector=t}),this.loadPromise.promise}openWindowViaPost(e,t,i){var n=document.createElement("form");n.action=e,n.method="POST",n.target="onesignal-http-popup";var o=void 0!=window.screenLeft?window.screenLeft:screen.left,s=void 0!=window.screenTop?window.screenTop:screen.top,r=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,a=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height,c=OneSignal._windowWidth,l=OneSignal._windowHeight,u=r/2-c/2+o,d=a/2-l/2+s;i&&(i.childWidth&&(c=i.childWidth),i.childHeight&&(l=i.childHeight),i.left&&(u=i.left),i.top&&(d=i.top));const g=window.open("about:blank","onesignal-http-popup",`'scrollbars=yes, width=${c}, height=${l}, top=${d}, left=${u}`);if(t)for(var h in t){var p=document.createElement("textarea");p.name=h,p.value="object"==typeof t[h]?JSON.stringify(t[h]):t[h],n.appendChild(p)}return n.style.display="none",document.body.appendChild(n),n.submit(),document.body.removeChild(n),g}establishCrossOriginMessaging(){this.messenger=new X(this.popupWindow,this.url.toString(),this.url.toString()),this.messenger.on(OneSignal.POSTMAM_COMMANDS.POPUP_BEGIN_MESSAGEPORT_COMMS,this.onBeginMessagePortCommunications.bind(this)),this.messenger.once(OneSignal.POSTMAM_COMMANDS.POPUP_LOADED,this.onPopupLoaded.bind(this)),this.messenger.once(OneSignal.POSTMAM_COMMANDS.POPUP_ACCEPTED,this.onPopupAccepted.bind(this)),this.messenger.once(OneSignal.POSTMAM_COMMANDS.POPUP_REJECTED,this.onPopupRejected.bind(this)),this.messenger.once(OneSignal.POSTMAM_COMMANDS.POPUP_CLOSING,this.onPopupClosing.bind(this)),this.messenger.once(OneSignal.POSTMAM_COMMANDS.SET_SESSION_COUNT,this.onSetSessionCount.bind(this)),this.messenger.once(OneSignal.POSTMAM_COMMANDS.WINDOW_TIMEOUT,this.onWindowTimeout.bind(this)),this.messenger.once(OneSignal.POSTMAM_COMMANDS.FINISH_REMOTE_REGISTRATION,this.onFinishingRegistrationRemotely.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.REMOTE_RETRIGGER_EVENT,this.onRemoteRetriggerEvent.bind(this)),this.messenger.startPostMessageReceive()}dispose(){this.messenger.destroy()}onBeginMessagePortCommunications(e){return ke(this,void 0,void 0,function*(){return M.a.debug(`(${E.a.getWindowEnv().toString()}) Successfully established cross-origin messaging with the popup window.`),this.messenger.connect(),!1})}onPopupLoaded(e){return ke(this,void 0,void 0,function*(){this.loadPromise.resolver(),m.a.trigger("popupLoad")})}onPopupAccepted(e){return ke(this,void 0,void 0,function*(){G.triggerCustomPromptClicked("granted")})}onPopupRejected(e){return ke(this,void 0,void 0,function*(){G.triggerCustomPromptClicked("denied")})}onPopupClosing(e){return ke(this,void 0,void 0,function*(){M.a.info("Popup window is closing, running cleanup events."),m.a.trigger(OneSignal.EVENTS.POPUP_CLOSING),this.dispose()})}onSetSessionCount(e){return ke(this,void 0,void 0,function*(){M.a.debug(E.a.getWindowEnv().toString()+" Marking current session as a continuing browsing session.");const{sessionCount:t}=e.data;OneSignal.context.sessionManager.setPageViewCount(t)})}onWindowTimeout(e){return ke(this,void 0,void 0,function*(){M.a.debug(E.a.getWindowEnv().toString()+" Popup window timed out and was closed."),m.a.trigger(OneSignal.EVENTS.POPUP_WINDOW_TIMEOUT)})}onFinishingRegistrationRemotely(e){return ke(this,void 0,void 0,function*(){M.a.debug(location.origin,E.a.getWindowEnv().toString()+" Finishing HTTP popup registration inside the iFrame, sent from popup."),e.reply({progress:!0});const{rawPushSubscription:t}=e.data;this.messenger&&this.messenger.stopPostMessageReceive(),yield OneSignal.context.subscriptionManager.registerSubscription(t),yield W.checkAndTriggerSubscriptionChanged(),yield G.checkAndTriggerNotificationPermissionChanged()})}onRemoteRetriggerEvent(e){let{eventName:t,eventData:i}=e.data;return m.a.trigger(t,i,e.source),!1}message(){this.messenger&&this.messenger.message.apply(this.messenger,arguments)}}function _e(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))}class Re{getPropertiesAsJson(){return{origin:location.origin,url:location.href,sdkVersion:l.a.version()}}}class De{}(Ae=Ce||(Ce={})).HttpPermissionRequest="HttpPermissionRequest",Ae.SyncHashedEmail="SyncHashedEmail";class We extends Re{constructor(e){super(),this.apiName=e}getEventName(){return"api-usage"}getPropertiesAsJson(){return Object.assign({api:this.apiName.toString()},super.getPropertiesAsJson())}}class Ue extends De{constructor(){super()}getProfileName(){return"all_websites"}getDateUtc(){const e=new Date;return`${e.getUTCMonth()+1}_${e.getUTCDate()}_${e.getUTCFullYear()}`}getOperationData(){const e={$add:{},$ignore_time:!0};return e.$add[`pageview_${this.getDateUtc()}`]=1,e}}class Be{constructor(e,t){this.isFeatureEnabled=e,this.mixpanelReportingToken=t}static get MIXPANEL_REPORTING_URL(){return"https://api.mixpanel.com"}isEnabled(){return this.isFeatureEnabled&&!!this.mixpanelReportingToken}reportEvent(e){if(!this.isEnabled())return Promise.resolve(null);const t={event:e.getEventName(),properties:Object.assign({token:this.mixpanelReportingToken},e.getPropertiesAsJson())},i=_e(JSON.stringify(t)),n={method:"GET",headers:new Headers,cache:"no-cache"};return fetch(`${Be.MIXPANEL_REPORTING_URL}/track/?data=${i}`,n)}reportEngagement(e){if(!this.isEnabled())return Promise.resolve(null);let t={$token:this.mixpanelReportingToken,$distinct_id:e.getProfileName()};t=Object.assign({},t,e.getOperationData());const i=_e(JSON.stringify(t)),n={method:"GET",headers:new Headers,cache:"no-cache"};return fetch(`${Be.MIXPANEL_REPORTING_URL}/engage/?data=${i}`,n)}shouldCollectPageView(){const e=new Date;return e.getUTCMonth()+1<=2&&e.getUTCDate()<=10&&e.getUTCFullYear()<=2018&&e.getUTCMonth()+1>=2&&e.getUTCDate()>=8&&e.getUTCFullYear()>=2018}reportPageView(){this.shouldCollectPageView()&&this.reportEngagement(new Ue)}}(Me=Ne||(Ne={}))[Me.HttpPermissionRequest=0]="HttpPermissionRequest",Me[Me.SyncHashedEmail=1]="SyncHashedEmail";class Le extends u.a{constructor(e){switch(e){case Ne.HttpPermissionRequest:super("The HTTP permission request has been deprecated. Please remove any custom popups from your code."),this.reportUsage(Ce.HttpPermissionRequest);break;case Ne.SyncHashedEmail:super("API syncHashedEmail() has been deprecated and will be removed in a future SDK release. Please remove any usages from your code."),this.reportUsage(Ce.SyncHashedEmail)}Object.setPrototypeOf(this,Le.prototype)}reportUsage(e){"undefined"!=typeof OneSignal&&OneSignal.context&&OneSignal.context.metricsManager&&OneSignal.context.metricsManager.reportEvent(new We(e))}}var je=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class Fe{static internalInit(){return je(this,void 0,void 0,function*(){M.a.debug("Called %cinternalInit()",Object(k.j)("code")),yield OneSignal.context.serviceWorkerManager.updateWorker(),OneSignal.context.sessionManager.incrementPageViewCount(),"visible"===document.visibilityState?yield Fe.sessionInit():Object(k.s)(document,"visibilitychange",(e,t)=>{"visible"===document.visibilityState&&(t(),Fe.sessionInit())},!0)})}static sessionInit(){return je(this,void 0,void 0,function*(){if(M.a.debug("Called %csessionInit()",Object(k.j)("code")),OneSignal._sessionInitAlreadyRunning)return void M.a.debug("Returning from sessionInit because it has already been called.");OneSignal._sessionInitAlreadyRunning=!0;try{yield Fe.doInitialize()}catch(e){if(e instanceof g)return;throw e}const e=yield OneSignal.internalIsOptedOut();y.a.isUsingSubscriptionWorkaround()||(yield Fe.handleAutoResubscribe(e));const t=yield OneSignal.privateIsPushNotificationsEnabled();if(OneSignal.config.userConfig.promptOptions.autoPrompt&&!e&&!t){c.a.chrome&&Number(c.a.version)>=63&&(c.a.tablet||c.a.mobile)||c.a.safari&&Number(c.a.version)>=12.1?(OneSignal.config.userConfig.promptOptions.slidedown.enabled=!0,yield OneSignal.context.promptsManager.internalShowSlidedownPrompt()):yield OneSignal.context.promptsManager.internalShowAutoPrompt()}OneSignal._sessionInitAlreadyRunning=!1,yield m.a.trigger(OneSignal.EVENTS.SDK_INITIALIZED)})}static registerForPushNotifications(e={}){return je(this,void 0,void 0,function*(){if(e&&e.modalPrompt)return OneSignal.subscriptionModalHost=new ee(OneSignal.config.appId,e),void(yield OneSignal.subscriptionModalHost.load());if(y.a.isUsingSubscriptionWorkaround())return e.httpPermissionRequest?void M.a.error(new Le(Ne.HttpPermissionRequest)):void(yield Fe.loadSubscriptionPopup(e));if(c.a.safari&&Number(c.a.version)>=12.1)return void(yield Y.internalRegisterForPush(!1));(yield OneSignal.internalIsOptedOut())||(yield Y.registerForPush())})}static onSdkInitialized(){return je(this,void 0,void 0,function*(){const e=yield Fe.processExpiringSubscriptions();(yield OneSignal.context.subscriptionManager.isAlreadyRegisteredWithOneSignal())?e||(yield OneSignal.context.updateManager.sendOnSessionUpdate()):OneSignal.config.userConfig.promptOptions.autoPrompt||OneSignal.config.userConfig.autoResubscribe||(yield OneSignal.context.updateManager.sendOnSessionUpdate()),yield m.a.trigger(OneSignal.EVENTS.SDK_INITIALIZED_PUBLIC)})}static loadSubscriptionPopup(e){return je(this,void 0,void 0,function*(){OneSignal.subscriptionPopupHost=new xe(OneSignal.proxyFrameHost.url,e),yield OneSignal.subscriptionPopupHost.load()})}static storeInitialValues(){return je(this,void 0,void 0,function*(){const e=yield OneSignal.privateIsPushNotificationsEnabled(),t=yield OneSignal.privateGetNotificationPermission(),i=yield OneSignal.internalIsOptedOut();b.put("subscription.optedOut",i),yield N.a.put("Options",{key:"isPushEnabled",value:e}),yield N.a.put("Options",{key:"notificationPermission",value:t})})}static setWelcomeNotificationFlag(){return je(this,void 0,void 0,function*(){(yield OneSignal.context.permissionManager.getNotificationPermission(OneSignal.context.appConfig.safariWebId))===U.Granted&&(OneSignal.__doNotShowWelcomeNotification=!0)})}static establishServiceWorkerChannel(){return je(this,void 0,void 0,function*(){if(navigator.serviceWorker&&"https:"===window.location.protocol&&!(yield E.a.isFrameContextInsecure()))try{const e=yield Te.getRegistration();e&&e.active&&(yield OneSignal.context.serviceWorkerManager.establishServiceWorkerChannel())}catch(e){M.a.error(e)}})}static processExpiringSubscriptions(){return je(this,void 0,void 0,function*(){const e=OneSignal.context;if(M.a.debug("Checking subscription expiration..."),!(yield e.subscriptionManager.isSubscriptionExpiring()))return M.a.debug("Subscription is not considered expired."),!1;const t=yield E.a.getIntegration(),i=E.a.getWindowEnv();switch(M.a.debug("Subscription is considered expiring. Current Integration:",t),t){case le.a.Secure:const n=yield e.subscriptionManager.subscribe(1);yield e.subscriptionManager.registerSubscription(n);break;case le.a.SecureProxy:if(i===L.a.OneSignalProxyFrame)yield this.registerSubscriptionInProxyFrame(e);else{yield OneSignal.proxyFrameHost.runCommand(OneSignal.POSTMAM_COMMANDS.PROCESS_EXPIRING_SUBSCRIPTIONS)}break;case le.a.InsecureProxy:yield N.a.remove("Ids","registrationId"),M.a.debug("Unsubscribed expiring HTTP subscription by removing registration ID.")}return!0})}static registerSubscriptionInProxyFrame(e){return je(this,void 0,void 0,function*(){const t=yield new Promise(t=>{e.workerMessenger.once(te.SubscribeNew,e=>{t(ue.a.deserialize(e))}),e.workerMessenger.unicast(te.SubscribeNew,e.appConfig)});return M.a.debug("Finished registering brand new subscription:",t),t})}static doInitialize(){return je(this,void 0,void 0,function*(){const e=[];e.push(Fe.storeInitialValues()),e.push(Fe.installNativePromptPermissionChangedHook()),e.push(Fe.setWelcomeNotificationFlag()),e.push(Fe.establishServiceWorkerChannel()),e.push(Fe.showNotifyButton()),e.push(Fe.showPromptsFromWebConfigEditor()),OneSignal.context.cookieSyncer.install();try{yield Promise.all(e)}catch(e){throw M.a.error(e),new g(s.Unknown)}})}static showNotifyButton(){return je(this,void 0,void 0,function*(){if(l.a.isBrowser()&&!OneSignal.notifyButton){OneSignal.config.userConfig.notifyButton=OneSignal.config.userConfig.notifyButton||{},OneSignal.config.userConfig.bell&&(OneSignal.config.userConfig.bell=Object.assign({},OneSignal.config.userConfig.bell,OneSignal.config.userConfig.notifyButton),OneSignal.config.userConfig.notifyButton=Object.assign({},OneSignal.config.userConfig.notifyButton,OneSignal.config.userConfig.bell));const e=OneSignal.config.userConfig.notifyButton.displayPredicate;e&&"function"==typeof e?OneSignal.emitter.once(OneSignal.EVENTS.SDK_INITIALIZED,()=>je(this,void 0,void 0,function*(){!1!==(yield Promise.resolve(OneSignal.config.userConfig.notifyButton.displayPredicate()))?(OneSignal.notifyButton=new Oe(OneSignal.config.userConfig.notifyButton),OneSignal.notifyButton.create()):M.a.debug("Notify button display predicate returned false so not showing the notify button.")})):(OneSignal.notifyButton=new Oe(OneSignal.config.userConfig.notifyButton),OneSignal.notifyButton.create())}})}static updateEmailSessionCount(){return je(this,void 0,void 0,function*(){const e=OneSignal.context;if(e.sessionManager.isFirstPageView()){const t=yield N.a.getEmailProfile();if(t.emailId){const i=new w(t.emailAddress,t.emailAuthHash);i.appId=e.appConfig.appId,yield A.updateUserSession(t.emailId,i)}}})}static showPromptsFromWebConfigEditor(){return je(this,void 0,void 0,function*(){const e=OneSignal.config;e.userConfig.promptOptions&&(yield _.initialize(e.userConfig.promptOptions.customlink))})}static installNativePromptPermissionChangedHook(){return je(this,void 0,void 0,function*(){if(navigator.permissions&&!(c.a.firefox&&Number(c.a.version)<=45)){OneSignal._usingNativePermissionHook=!0,(yield navigator.permissions.query({name:"notifications"})).onchange=function(){Object(k.w)()}}})}static saveInitOptions(){return je(this,void 0,void 0,function*(){let e=[];const t=OneSignal.config.userConfig.persistNotification;e.push(N.a.put("Options",{key:"persistNotification",value:null==t||t}));let i=OneSignal.config.userConfig.webhooks;return["notification.displayed","notification.clicked","notification.dismissed"].forEach(t=>{i&&i[t]?e.push(N.a.put("Options",{key:`webhooks.${t}`,value:i[t]})):e.push(N.a.put("Options",{key:`webhooks.${t}`,value:!1}))}),i&&i.cors?e.push(N.a.put("Options",{key:"webhooks.cors",value:!0})):e.push(N.a.put("Options",{key:"webhooks.cors",value:!1})),OneSignal.config.userConfig.notificationClickHandlerMatch?e.push(N.a.put("Options",{key:"notificationClickHandlerMatch",value:OneSignal.config.userConfig.notificationClickHandlerMatch})):e.push(N.a.put("Options",{key:"notificationClickHandlerMatch",value:"exact"})),OneSignal.config.userConfig.notificationClickHandlerAction?e.push(N.a.put("Options",{key:"notificationClickHandlerAction",value:OneSignal.config.userConfig.notificationClickHandlerAction})):e.push(N.a.put("Options",{key:"notificationClickHandlerAction",value:"navigate"})),Promise.all(e)})}static initSaveState(e){return je(this,void 0,void 0,function*(){const t=yield G.getAppId();yield N.a.put("Ids",{type:"appId",id:t});const i=e||document.title||"Notification";yield N.a.put("Options",{key:"pageTitle",value:i}),M.a.info(`OneSignal: Set pageTitle to be '${i}'.`);const n=OneSignal.config;yield N.a.put("Options",{key:"emailAuthRequired",value:!!n.emailAuthRequired})})}static handleAutoResubscribe(e){return je(this,void 0,void 0,function*(){if(M.a.info("handleAutoResubscribe",{autoResubscribe:OneSignal.config.userConfig.autoResubscribe,isOptedOut:e}),OneSignal.config.userConfig.autoResubscribe&&!e){(yield OneSignal.context.permissionManager.getNotificationPermission(OneSignal.context.appConfig.safariWebId))==U.Granted&&(yield Y.registerForPush())}})}static polyfillSafariFetch(){return je(this,void 0,void 0,function*(){if(c.a.safari&&void 0===window.fetch){M.a.debug("Loading fetch polyfill for Safari..");try{yield(new ce).loadFetchPolyfill(),M.a.debug("Done loading fetch polyfill.")}catch(e){M.a.debug("Error loading fetch polyfill:",e)}}})}static errorIfInitAlreadyCalled(){if(OneSignal._initCalled)throw new g(s.MultipleInitialization);OneSignal._initCalled=!0}}var He=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class Ve{static markHttpsNativePromptDismissed(){return He(this,void 0,void 0,function*(){if(Object(k.o)())try{yield new Promise((e,t)=>{OneSignal.proxyFrameHost.message(OneSignal.POSTMAM_COMMANDS.MARK_PROMPT_DISMISSED,{},i=>{i.data===OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE?e():t()})})}catch(e){M.a.debug("Proxy Frame possibly didn't not receive MARK_PROMPT_DISMISSED message",e||"")}let e=yield N.a.get("Options","promptDismissCount");e||(e=0),Object(k.o)()||(e+=1);let t=3;2==e?t=7:e>2&&(t=30),M.a.debug(`(${E.a.getWindowEnv().toString()}) OneSignal: User dismissed the native notification prompt; reprompt after ${t} days.`),yield N.a.put("Options",{key:"promptDismissCount",value:e});const i=24*t*60;return F.setItem("onesignal-notification-prompt","dismissed",i)})}}var $e=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class ze{constructor(e,t=!1){this.context=e,this.isFeatureEnabled=t}get PUBLISHER_ID(){try{return`os!${this.context.appConfig.appId.replace(/-/g,"").substr(0,15).toLowerCase()}`}catch(e){return"os!os"}}getFrameOrigin(){return!!this.context.appConfig.subdomain?new URL(`https://${this.context.appConfig.subdomain}.os.tc`):new URL(E.a.getOneSignalApiUrl().origin)}install(){return $e(this,void 0,void 0,function*(){if(window.top!==window)return;const e=this.getFrameOrigin();this.isFeatureEnabled?(e.pathname="/webPushAnalytics",e.search=`sync=true&appId=${this.PUBLISHER_ID}`):e.pathname="/webPushAnalytics";const t=document.createElement("iframe");t.style.display="none",t.src=e.href;const i={promise:void 0,resolver:void 0,rejector:void 0};return i.promise=new Promise((e,t)=>{i.resolver=e,i.rejector=t}),document.body.appendChild(t),t.onload=i.resolver,t.onerror=i.rejector,i.promise})}}class Ge{constructor(){this.incrementedPageViewCount=!1}getPageViewCount(){try{const e=sessionStorage.getItem(Ge.SESSION_STORAGE_KEY_NAME),t=e?parseInt(e):0;return isNaN(t)?0:t}catch(e){return 0}}setPageViewCount(e){try{sessionStorage.setItem(Ge.SESSION_STORAGE_KEY_NAME,e.toString()),E.a.getWindowEnv()===L.a.OneSignalSubscriptionPopup&&OneSignal.subscriptionPopup&&OneSignal.subscriptionPopup.message(OneSignal.POSTMAM_COMMANDS.SET_SESSION_COUNT)}catch(e){}}incrementPageViewCount(){if(this.incrementedPageViewCount)return;const e=this.getPageViewCount()+1;this.setPageViewCount(e),M.a.debug(`Incremented page view count to ${e}.`),this.incrementedPageViewCount=!0}simulatePageNavigationOrRefresh(){this.incrementedPageViewCount=!1}isFirstPageView(){return 1===this.getPageViewCount()}}Ge.SESSION_STORAGE_KEY_NAME="onesignal-pageview-count";var Ke,qe,Ye=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class Je{static get STORED_PERMISSION_KEY(){return"storedNotificationPermission"}getNotificationPermission(e){return Ye(this,void 0,void 0,function*(){const t=yield this.getReportedNotificationPermission(e);return(yield this.isPermissionEnvironmentAmbiguous(t))?yield this.getInterpretedAmbiguousPermission(t):t})}getReportedNotificationPermission(e){return Ye(this,void 0,void 0,function*(){return c.a.safari?Je.getSafariNotificationPermission(e):y.b.isUsingSubscriptionWorkaround()?yield this.getOneSignalSubdomainNotificationPermission(e):this.getW3cNotificationPermission()})}static getSafariNotificationPermission(e){if(e)return window.safari.pushNotification.permission(e).permission;throw new InvalidArgumentError.a("safariWebId",InvalidArgumentError.b.Empty)}getW3cNotificationPermission(){return window.Notification.permission}getOneSignalSubdomainNotificationPermission(e){return Ye(this,void 0,void 0,function*(){return new Promise(t=>{OneSignal.proxyFrameHost.message(OneSignal.POSTMAM_COMMANDS.REMOTE_NOTIFICATION_PERMISSION,{safariWebId:e},e=>{let i=e.data;t(i)})})})}isPermissionEnvironmentAmbiguous(e){return Ye(this,void 0,void 0,function*(){const t=y.b.redetectBrowserUserAgent();return!t.safari&&!t.firefox&&e===U.Denied&&(this.isCurrentFrameContextCrossOrigin()||(yield E.a.isFrameContextInsecure())||y.b.isUsingSubscriptionWorkaround()||E.a.isInsecureOrigin())})}isCurrentFrameContextCrossOrigin(){let e;try{e=window.top.location.origin}catch(e){return!0}return window.top!==window&&e!==window.location.origin}getInterpretedAmbiguousPermission(e){return Ye(this,void 0,void 0,function*(){switch(e){case U.Denied:const t=yield this.getStoredPermission();return t||U.Default;default:return e}})}getStoredPermission(){return Ye(this,void 0,void 0,function*(){return yield N.a.get("Options",Je.STORED_PERMISSION_KEY)})}setStoredPermission(e){return Ye(this,void 0,void 0,function*(){yield N.a.put("Options",{key:Je.STORED_PERMISSION_KEY,value:e})})}updateStoredPermission(){return Ye(this,void 0,void 0,function*(){const e=yield this.getNotificationPermission();return yield this.setStoredPermission(e)})}}class Ze{isNewSubscription(){return this.existingW3cPushSubscription?!!this.existingW3cPushSubscription.w3cEndpoint!=!!this.w3cEndpoint||(!(!this.existingW3cPushSubscription.w3cEndpoint||!this.w3cEndpoint||this.existingW3cPushSubscription.w3cEndpoint.toString()===this.w3cEndpoint.toString())||(this.existingW3cPushSubscription.w3cP256dh!==this.w3cP256dh||this.existingW3cPushSubscription.w3cAuth!==this.w3cAuth)):!this.existingSafariDeviceToken||this.existingSafariDeviceToken!==this.safariDeviceToken}static setFromW3cSubscription(e){const t=new Ze;if(e&&(t.w3cEndpoint=new URL(e.endpoint),e.getKey)){let i=null;try{i=e.getKey("p256dh")}catch(e){}let n=null;try{n=e.getKey("auth")}catch(e){}if(i){let e=btoa(String.fromCharCode.apply(null,new Uint8Array(i)));t.w3cP256dh=e}if(n){let e=btoa(String.fromCharCode.apply(null,new Uint8Array(n)));t.w3cAuth=e}}return t}setFromSafariSubscription(e){this.safariDeviceToken=e}serialize(){return{w3cEndpoint:this.w3cEndpoint?this.w3cEndpoint.toString():null,w3cP256dh:this.w3cP256dh,w3cAuth:this.w3cAuth,safariDeviceToken:this.safariDeviceToken,existingPushSubscription:this.existingW3cPushSubscription?this.existingW3cPushSubscription.serialize():null,existingSafariDeviceToken:this.existingSafariDeviceToken}}static deserialize(e){const t=new Ze;if(!e)return t;try{t.w3cEndpoint=new URL(e.w3cEndpoint)}catch(e){}return t.w3cP256dh=e.w3cP256dh,t.w3cAuth=e.w3cAuth,t.existingW3cPushSubscription=void 0,e.existingW3cPushSubscription?t.existingW3cPushSubscription=Ze.deserialize(e.existingW3cPushSubscription):e.existingPushSubscription&&(t.existingW3cPushSubscription=Ze.deserialize(e.existingPushSubscription)),t.safariDeviceToken=e.safariDeviceToken,t.existingSafariDeviceToken=e.existingSafariDeviceToken,t}}class Xe extends O{constructor(e){super(),this.subscription=e}serialize(){const e=super.serialize();return this.subscription&&(e.identifier=c.a.safari?this.subscription.safariDeviceToken:this.subscription.w3cEndpoint?this.subscription.w3cEndpoint.toString():null,e.web_auth=this.subscription.w3cAuth,e.web_p256=this.subscription.w3cP256dh),e}static createFromPushSubscription(e,t,i){const n=new Xe(t);return n.appId=e,n.subscriptionState=t?B.Subscribed:B.NotSubscribed,i&&(n.subscriptionState=i),n}deserialize(e){throw new v}}(qe=Ke||(Ke={}))[qe.InvalidSafariSetup=0]="InvalidSafariSetup",qe[qe.Blocked=1]="Blocked",qe[qe.Dismissed=2]="Dismissed";class Qe extends u.a{constructor(e){switch(e){case Ke.InvalidSafariSetup:super("The Safari site URL, icon size, or push certificate is invalid, or Safari is in a private session.");break;case Ke.Blocked:super("Notification permissions are blocked.");break;case Ke.Dismissed:super("The notification permission prompt was dismissed.")}Object.setPrototypeOf(this,Qe.prototype)}}var et=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class tt{constructor(e,t){this.context=e,this.config=t}static isSafari(){return l.a.isSafari()}subscribe(e){return et(this,void 0,void 0,function*(){const t=E.a.getWindowEnv();switch(t){case L.a.CustomIframe:case L.a.Unknown:case L.a.OneSignalProxyFrame:throw new InvalidStateError.a(InvalidStateError.b.UnsupportedEnvironment)}let i;switch(t){case L.a.ServiceWorker:i=yield this.subscribeFcmFromWorker(e);break;case L.a.Host:case L.a.OneSignalSubscriptionModal:case L.a.OneSignalSubscriptionPopup:if((yield OneSignal.privateGetNotificationPermission())===U.Denied)throw new K(H.Blocked);i=tt.isSafari()?yield this.subscribeSafari():yield this.subscribeFcmFromPage(e);break;default:throw new InvalidStateError.a(InvalidStateError.b.UnsupportedEnvironment)}return i})}registerSubscription(e,t){return et(this,void 0,void 0,function*(){e&&(e=Ze.deserialize(e));const i=Xe.createFromPushSubscription(this.config.appId,e,t);let n=void 0;(yield this.isAlreadyRegisteredWithOneSignal())?yield this.context.updateManager.sendPlayerUpdate(i):(n=yield this.context.updateManager.sendPlayerCreate(i))&&(yield this.associateSubscriptionWithEmail(n));const o=yield N.a.getSubscription();return o.deviceId=n,o.optedOut=!1,e?tt.isSafari()?o.subscriptionToken=e.safariDeviceToken:o.subscriptionToken=e.w3cEndpoint?e.w3cEndpoint.toString():null:o.subscriptionToken=null,yield N.a.setSubscription(o),E.a.getWindowEnv()!==L.a.ServiceWorker&&m.a.trigger(OneSignal.EVENTS.REGISTERED),"undefined"!=typeof OneSignal&&(OneSignal._sessionInitAlreadyRunning=!1),o})}static requestPresubscribeNotificationPermission(){return et(this,void 0,void 0,function*(){return yield tt.requestNotificationPermission()})}unsubscribe(e){return et(this,void 0,void 0,function*(){if(0===e)throw new v;if(1!==e)throw new v;if(E.a.getWindowEnv()!==L.a.ServiceWorker)throw new v;{const{deviceId:e}=yield N.a.getSubscription();yield A.updatePlayer(this.context.appConfig.appId,e,{notification_types:B.MutedByApi}),yield N.a.put("Options",{key:"optedOut",value:!0})}})}static requestNotificationPermission(){return new Promise(e=>window.Notification.requestPermission(e))}associateSubscriptionWithEmail(e){return et(this,void 0,void 0,function*(){const t=yield N.a.getEmailProfile();t.emailId&&(yield A.updatePlayer(this.config.appId,e,{parent_player_id:t.emailId,email:t.emailAddress}))})}isAlreadyRegisteredWithOneSignal(){return et(this,void 0,void 0,function*(){const{deviceId:e}=yield N.a.getSubscription();return!!e})}subscribeSafariPromptPermission(){return new Promise(e=>{window.safari.pushNotification.requestPermission(`${E.a.getOneSignalApiUrl().toString()}/safari`,this.config.safariWebId,{app_id:this.config.appId},t=>{t.deviceToken?e(t.deviceToken.toLowerCase()):e(null)})})}subscribeSafari(){return et(this,void 0,void 0,function*(){const e=new Ze;if(!this.config.safariWebId)throw new g(s.MissingSafariWebId);const{deviceToken:t}=window.safari.pushNotification.permission(this.config.safariWebId);e.existingSafariDeviceToken=t,t||m.a.trigger(OneSignal.EVENTS.PERMISSION_PROMPT_DISPLAYED);const i=yield this.subscribeSafariPromptPermission();if($.a.triggerNotificationPermissionChanged(),!i)throw new Qe(Ke.InvalidSafariSetup);return e.setFromSafariSubscription(i),e})}subscribeFcmFromPage(e){return et(this,void 0,void 0,function*(){if(E.a.getWindowEnv()!==L.a.ServiceWorker&&window.Notification.permission===U.Default){yield m.a.trigger(OneSignal.EVENTS.PERMISSION_PROMPT_DISPLAYED);const e=yield tt.requestPresubscribeNotificationPermission();switch(e===U.Default&&(yield $.a.triggerNotificationPermissionChanged(!0)),e){case U.Default:throw M.a.debug("Exiting subscription and not registering worker because the permission was dismissed."),OneSignal._sessionInitAlreadyRunning=!1,OneSignal._isRegisteringForPush=!1,new K(H.Dismissed);case U.Denied:throw M.a.debug("Exiting subscription and not registering worker because the permission was blocked."),OneSignal._sessionInitAlreadyRunning=!1,OneSignal._isRegisteringForPush=!1,new K(H.Blocked)}}if(yield this.context.serviceWorkerManager.shouldInstallWorker())try{yield this.context.serviceWorkerManager.installWorker()}catch(e){throw e instanceof Pe&&(403===e.status?yield this.context.subscriptionManager.registerFailedSubscription(B.ServiceWorkerStatus403,this.context):404===e.status&&(yield this.context.subscriptionManager.registerFailedSubscription(B.ServiceWorkerStatus404,this.context))),e}M.a.debug("Waiting for the service worker to activate...");const t=yield navigator.serviceWorker.ready;return M.a.debug("Service worker is ready to continue subscribing."),yield this.subscribeWithVapidKey(t.pushManager,e)})}subscribeFcmFromWorker(e){return et(this,void 0,void 0,function*(){if(!self.registration.active&&!c.a.firefox)throw new InvalidStateError.a(InvalidStateError.b.ServiceWorkerNotActivated);const t=yield self.registration.pushManager.permissionState({userVisibleOnly:!0});if("denied"===t)throw new K(H.Blocked);if("prompt"===t)throw new K(H.Default);return yield this.subscribeWithVapidKey(self.registration.pushManager,e)})}getVapidKeyForBrowser(){let e=void 0;return(e=c.a.firefox?this.config.onesignalVapidPublicKey:this.config.vapidPublicKey)?function(e){const t=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),i=atob(t),n=new Uint8Array(i.length);for(let e=0;e=i}})}isSubscriptionExpiringForSecureIntegration(){return et(this,void 0,void 0,function*(){const e=yield this.context.serviceWorkerManager.getActiveState();if(e!==ne.a.WorkerA&&e!==ne.a.WorkerB)return!1;const t=yield Te.getRegistration();if(!t)return!1;if(!t.pushManager)return!1;const i=yield t.pushManager.getSubscription();if(!i)return!1;if(!i.expirationTime)return!1;let{createdAt:n}=yield N.a.getSubscription();if(!n){const e=31536e6;n=(new Date).getTime()+e}const o=n+(i.expirationTime-n)/2;return!!i.expirationTime&&((new Date).getTime()>=i.expirationTime||(new Date).getTime()>=o)})}getSubscriptionState(){return et(this,void 0,void 0,function*(){if(tt.isSafari())return this.getSubscriptionStateForSecure();const e=E.a.getWindowEnv();switch(e){case L.a.ServiceWorker:const t=yield self.registration.pushManager.getSubscription(),{optedOut:i}=yield N.a.getSubscription();return{subscribed:!!t,optedOut:!!i};default:switch(yield E.a.getIntegration()){case le.a.Secure:return this.getSubscriptionStateForSecure();case le.a.SecureProxy:switch(e){case L.a.OneSignalProxyFrame:case L.a.OneSignalSubscriptionPopup:case L.a.OneSignalSubscriptionModal:return this.getSubscriptionStateForSecure();default:return yield OneSignal.proxyFrameHost.runCommand(OneSignal.POSTMAM_COMMANDS.GET_SUBSCRIPTION_STATE)}case le.a.InsecureProxy:return yield this.getSubscriptionStateForInsecure();default:throw new InvalidStateError.a(InvalidStateError.b.UnsupportedEnvironment)}}})}getSubscriptionStateForSecure(){return et(this,void 0,void 0,function*(){const{deviceId:e,optedOut:t}=yield N.a.getSubscription();if(tt.isSafari()){const i=window.safari.pushNotification.permission(this.config.safariWebId);return{subscribed:!("granted"!==i.permission||!i.deviceToken||!e),optedOut:!!t}}const i=yield this.context.serviceWorkerManager.getActiveState(),n=yield Te.getRegistration(),o=yield this.context.permissionManager.getNotificationPermission(this.context.appConfig.safariWebId),s=i===ne.a.WorkerA||i===ne.a.WorkerB;return n?{subscribed:!(!e||o!==U.Granted||!s),optedOut:!!t}:{subscribed:!1,optedOut:!!t}})}getSubscriptionStateForInsecure(){return et(this,void 0,void 0,function*(){const{deviceId:e,subscriptionToken:t,optedOut:i}=yield N.a.getSubscription(),n=yield this.context.permissionManager.getNotificationPermission(this.context.appConfig.safariWebId);return{subscribed:!(!e||!t||n!==U.Granted),optedOut:!!i}})}registerFailedSubscription(e,t){return et(this,void 0,void 0,function*(){t.sessionManager.isFirstPageView()&&(t.subscriptionManager.registerSubscription(new Ze,e),t.sessionManager.incrementPageViewCount())})}}var it=class{static getServiceWorkerManager(e){const t=e.appConfig,i=E.a.getBuildEnvPrefix(),n={workerAPath:new we(`/${i}OneSignalSDKWorker.js`),workerBPath:new we(`/${i}OneSignalSDKUpdaterWorker.js`),registrationOptions:{scope:"/"}};return t.userConfig&&(t.userConfig.path&&(n.workerAPath=new we(`${t.userConfig.path}${i}${t.userConfig.serviceWorkerPath}`),n.workerBPath=new we(`${t.userConfig.path}${i}${t.userConfig.serviceWorkerUpdaterPath}`)),t.userConfig.serviceWorkerParam&&(n.registrationOptions=t.userConfig.serviceWorkerParam)),new Te(e,n)}static getSubscriptionManager(e){const t=e.appConfig,i={safariWebId:t.safariWebId,appId:t.appId,vapidPublicKey:t.vapidPublicKey,onesignalVapidPublicKey:t.onesignalVapidPublicKey};return new tt(e,i)}},nt=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class ot{constructor(e){this.context=e,this.onSessionSent=e.sessionManager.getPageViewCount()>1}getDeviceId(){return nt(this,void 0,void 0,function*(){const{deviceId:e}=yield N.a.getSubscription();if(!e)throw new d(n.NoDeviceId);return e})}createDeviceRecord(){return nt(this,void 0,void 0,function*(){const e=new Xe;return e.appId=this.context.appConfig.appId,e.subscriptionState=yield G.getCurrentNotificationType(),e})}sendPlayerUpdate(e){return nt(this,void 0,void 0,function*(){if(!(yield this.context.subscriptionManager.isAlreadyRegisteredWithOneSignal()))return void M.a.debug("Not sending the update because user is not registered with OneSignal (no device id)");const t=yield this.getDeviceId();e||(e=yield this.createDeviceRecord()),this.onSessionSent?yield A.updatePlayer(this.context.appConfig.appId,t,Object.assign({notification_types:B.Subscribed},e.serialize())):yield this.sendOnSessionUpdate(e)})}sendOnSessionUpdate(e){return nt(this,void 0,void 0,function*(){if(this.onSessionSent)return;if(!this.context.sessionManager.isFirstPageView())return;if(!(yield this.context.subscriptionManager.isAlreadyRegisteredWithOneSignal()))return void M.a.debug("Not sending the on session because user is not registered with OneSignal (no device id)");const t=yield this.getDeviceId();if(e||(e=yield this.createDeviceRecord()),e.subscriptionState===B.Subscribed||!0===OneSignal.config.enableOnSession)try{yield A.updateUserSession(t,e),this.onSessionSent=!0}catch(e){M.a.error(`Failed to update user session. Error "${e.message}" ${e.stack}`)}})}sendPlayerCreate(e){return nt(this,void 0,void 0,function*(){try{const t=yield A.createUser(e);return t?(M.a.info("Subscribed to web push and registered with OneSignal",e,t),this.onSessionSent=!0,t):void M.a.error("Failed to create user.")}catch(e){return void M.a.error(`Failed to create user. Error "${e.message}" ${e.stack}`)}})}onSessionAlreadyCalled(){return this.onSessionSent}sendExternalUserIdUpdate(e){return nt(this,void 0,void 0,function*(){const t=yield this.getDeviceId();yield A.updatePlayer(this.context.appConfig.appId,t,{external_user_id:P.b.getValueOrDefault(e,"")})})}}class st extends u.a{constructor(){super("This operation can only be performed when the user is not subscribed."),Object.setPrototypeOf(this,st.prototype)}}class rt extends u.a{constructor(){super("The permission message was previously dismissed."),Object.setPrototypeOf(this,rt.prototype)}}var at=i(23),ct=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class lt{static get EVENTS(){return{ALLOW_CLICK:"popoverAllowClick",CANCEL_CLICK:"popoverCancelClick",SHOWN:"popoverShown",CLOSED:"popoverClosed"}}constructor(e){e||(e=G.getSlidedownPermissionMessageOptions(OneSignal.config.userConfig.promptOptions)),this.options=e,this.options.actionMessage=e.actionMessage.substring(0,90),this.options.acceptButtonText=e.acceptButtonText.substring(0,15),this.options.cancelButtonText=e.cancelButtonText.substring(0,15),this.notificationIcons=null}create(){return ct(this,void 0,void 0,function*(){if(null===this.notificationIcons){const e=yield G.getNotificationIcons();this.notificationIcons=e,this.container&&Object(k.u)("#onesignal-popover-container");let t=this.getPlatformNotificationIcon(),i=`
notification icon
${this.options.actionMessage}
`;Object(k.b)("body","beforeend",'
'),Object(k.b)(this.container,"beforeend",`
${i}
`),Object(k.a)(this.container,c.a.mobile?"slide-up":"slide-down"),this.allowButton.addEventListener("click",this.onPopoverAllowed.bind(this)),this.cancelButton.addEventListener("click",this.onPopoverCanceled.bind(this)),m.a.trigger(lt.EVENTS.SHOWN)}})}onPopoverAllowed(e){return ct(this,void 0,void 0,function*(){yield m.a.trigger(lt.EVENTS.ALLOW_CLICK)})}onPopoverCanceled(e){m.a.trigger(lt.EVENTS.CANCEL_CLICK),this.close()}close(){Object(k.a)(this.container,"close-popover"),Object(k.s)(this.dialog,"animationend",(e,t)=>{e.target!==this.dialog||"slideDownExit"!==e.animationName&&"slideUpExit"!==e.animationName||(Object(k.u)("#onesignal-popover-container"),t(),m.a.trigger(lt.EVENTS.CLOSED))},!0)}getPlatformNotificationIcon(){return Object(k.k)(this.notificationIcons)}get container(){return document.querySelector("#onesignal-popover-container")}get dialog(){return document.querySelector("#onesignal-popover-dialog")}get allowButton(){return document.querySelector("#onesignal-popover-allow-button")}get cancelButton(){return document.querySelector("#onesignal-popover-cancel-button")}}var ut=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class dt{constructor(e){this.isAutoPromptShowing=!1}checkIfAutoPromptShouldBeShown(e={force:!1}){return ut(this,void 0,void 0,function*(){if(this.isAutoPromptShowing)throw new InvalidStateError.a(InvalidStateError.b.RedundantPermissionMessage,{permissionPromptType:at.a.SlidedownPermissionMessage});if(G.wasHttpsNativePromptDismissed()&&!e.force)return M.a.info(new rt),!1;if((yield OneSignal.privateGetNotificationPermission())===U.Denied)return M.a.info(new K(H.Blocked)),!1;if(yield OneSignal.privateIsPushNotificationsEnabled())throw new st;if(!(yield OneSignal.privateGetSubscription()))throw new d(n.OptedOut);return!0})}internalShowAutoPrompt(e={force:!1}){return ut(this,void 0,void 0,function*(){if(y.b.logMethodCall("internalShowAutoPrompt",e),!OneSignal.config||!OneSignal.config.userConfig||!OneSignal.config.userConfig.promptOptions)return void M.a.error("OneSignal config was not initialized correctly. Aborting.");const t=OneSignal.config.userConfig.promptOptions;t.native.enabled||t.slidedown.enabled?t.native&&t.native.enabled&&t.native.autoPrompt?yield this.internalShowNativePrompt():t.slidedown&&t.slidedown.enabled&&t.slidedown.autoPrompt&&(yield this.internalShowSlidedownPrompt(e)):M.a.error("No suitable prompt type enabled.")})}internalShowNativePrompt(){return ut(this,void 0,void 0,function*(){y.b.logMethodCall("internalShowNativePrompt"),this.isAutoPromptShowing?M.a.debug("Already showing autopromt. Abort showing a native prompt."):(this.isAutoPromptShowing=!0,G.markHttpPopoverShown(),yield Fe.registerForPushNotifications(),this.isAutoPromptShowing=!1,Ve.markHttpsNativePromptDismissed())})}internalShowSlidedownPrompt(e={force:!1}){return ut(this,void 0,void 0,function*(){if(y.b.logMethodCall("internalShowSlidedownPrompt"),this.isAutoPromptShowing)return void M.a.debug("Already showing autopromt. Abort showing a slidedown.");try{if(!(yield this.checkIfAutoPromptShouldBeShown(e)))return}catch(e){return void M.a.warn("checkIfAutoPromptShouldBeShown returned an error",e)}if(G.markHttpPopoverShown(),0!==(yield OneSignal.context.dynamicResourceLoader.loadSdkStylesheet()))return void M.a.debug("Not showing slidedown permission message because styles failed to load.");const t=G.getSlidedownPermissionMessageOptions(OneSignal.config.userConfig.promptOptions);this.installEventHooksForPopover(),OneSignal.popover=new lt(t),yield OneSignal.popover.create(),M.a.debug("Showing Slidedown(Popover).")})}installEventHooksForPopover(){!function(){const e=OneSignal.notifyButton;e&&e.options.enable&&"hidden"!==OneSignal.notifyButton.launcher.state&&OneSignal.notifyButton.launcher.waitUntilShown().then(()=>{OneSignal.notifyButton.launcher.hide()}),OneSignal.emitter.once(lt.EVENTS.CLOSED,()=>{OneSignal.notifyButton&&OneSignal.notifyButton.options.enable&&OneSignal.notifyButton.launcher.show()})}(),OneSignal.emitter.once(lt.EVENTS.SHOWN,()=>{this.isAutoPromptShowing=!0}),OneSignal.emitter.once(lt.EVENTS.CLOSED,()=>{this.isAutoPromptShowing=!1}),OneSignal.emitter.once(lt.EVENTS.ALLOW_CLICK,()=>{OneSignal.popover&&OneSignal.popover.close(),M.a.debug("Setting flag to not show the popover to the user again."),Ve.markHttpsNativePromptDismissed();Fe.registerForPushNotifications({autoAccept:!0})}),OneSignal.emitter.once(lt.EVENTS.CANCEL_CLICK,()=>{M.a.debug("Setting flag to not show the popover to the user again."),Ve.markHttpsNativePromptDismissed()})}}class gt{constructor(e){this.appConfig=e,this.subscriptionManager=it.getSubscriptionManager(this),this.serviceWorkerManager=it.getServiceWorkerManager(this),this.sessionManager=new Ge,this.permissionManager=new Je,this.workerMessenger=new re(this),this.updateManager=new ot(this),this.promptsManager=new dt(this),this.cookieSyncer=new ze(this,e.cookieSyncEnabled),this.dynamicResourceLoader=new ce,this.metricsManager=new Be(e.metrics.enable,e.metrics.mixpanelReportingToken)}}var ht=i(24),pt=i.n(ht),ft=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};var mt,bt,St,vt=class{static downloadServerAppConfig(e){return ft(this,void 0,void 0,function*(){return P.a.enforceAppId(e),yield new Promise((t,i)=>{t(I.get(`sync/${e}/web`,null))})})}static getUserIdFromSubscriptionIdentifier(e,t,i){return P.a.enforceAppId(e),I.post("players",{app_id:e,device_type:t,identifier:i,notification_types:B.TemporaryWebRecord}).then(e=>e&&e.id?e.id:null).catch(e=>(M.a.debug("Error getting user ID from subscription identifier:",e),null))}static updatePlayer(e,t,i){return P.a.enforceAppId(e),P.a.enforcePlayerId(t),I.put(`players/${t}`,Object.assign({app_id:e},i))}},yt=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class Ot{static getPlayer(e,t){return A.getPlayer(e,t)}static updatePlayer(e,t,i){return A.updatePlayer(e,t,i)}static sendNotification(e,t,i,n,o,s,r,a){return A.sendNotification(e,t,i,n,o,s,r,a)}static jsonpLib(e,t){pt()(e,null,t)}static downloadServerAppConfig(e){return yt(this,void 0,void 0,function*(){return E.a.getWindowEnv()!==L.a.ServiceWorker?yield new Promise((t,i)=>{Ot.jsonpLib(`${E.a.getOneSignalApiUrl().toString()}/sync/${e}/web`,(e,n)=>{e?i(e):n.success?t(n):i(n)})}):yield vt.downloadServerAppConfig(e)})}static createUser(e){return yt(this,void 0,void 0,function*(){return yield A.createUser(e)})}static createEmailRecord(e,t,i){return yt(this,void 0,void 0,function*(){return yield A.createEmailRecord(e,t,i)})}static updateEmailRecord(e,t,i){return yt(this,void 0,void 0,function*(){return yield A.updateEmailRecord(e,t,i)})}static logoutEmail(e,t,i){return yt(this,void 0,void 0,function*(){return yield A.logoutEmail(e,t,i)})}static updateUserSession(e,t){return yt(this,void 0,void 0,function*(){return yield A.updateUserSession(e,t)})}}!function(e){e.TypicalSite="typical",e.WordPress="wordpress",e.Shopify="shopify",e.Blogger="blogger",e.Magento="magento",e.Drupal="drupal",e.SquareSpace="squarespace",e.Joomla="joomla",e.Weebly="weebly",e.Wix="wix",e.Custom="custom"}(mt||(mt={})),function(e){e.Exact="exact",e.Origin="origin"}(bt||(bt={})),function(e){e.Navigate="navigate",e.Focus="focus"}(St||(St={}));var wt,Et,Pt=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};(Et=wt||(wt={}))[Et.Dashboard=0]="Dashboard",Et[Et.JavaScript=1]="JavaScript";class It{static getAppConfig(e,t){return Pt(this,void 0,void 0,function*(){try{if(!e||!e.appId||!y.b.isValidUuid(e.appId))throw new g(s.InvalidAppId);const i=yield t(e.appId),n=this.getMergedConfig(e,i);return this.checkRestrictedOrigin(n),n}catch(e){if(e){if(1===e.code)throw new g(s.InvalidAppId);if(2===e.code)throw new g(s.AppNotConfiguredForWebPush)}throw e}})}static checkRestrictedOrigin(e){if(e.restrictedOriginEnabled&&E.a.getWindowEnv()!==L.a.ServiceWorker&&window.top===window&&!P.b.contains(window.location.hostname,".os.tc")&&!P.b.contains(window.location.hostname,".onesignal.com")&&!this.doesCurrentOriginMatchConfigOrigin(e.origin))throw new g(s.WrongSiteUrl,{siteUrl:e.origin})}static doesCurrentOriginMatchConfigOrigin(e){try{return location.origin===new URL(e).origin}catch(e){return!1}}static getIntegrationCapabilities(e){switch(e){case mt.Custom:case mt.WordPress:return{configuration:wt.JavaScript};default:return{configuration:wt.Dashboard}}}static getMergedConfig(e,t){const i=this.getConfigIntegrationKind(t),n=this.getSubdomainForConfigIntegrationKind(i,e,t),o=t.config.setupBehavior?t.config.setupBehavior.allowLocalhostAsSecureOrigin:e.allowLocalhostAsSecureOrigin,s=y.b.internalIsUsingSubscriptionWorkaround(n,o),r=this.getUserConfigForConfigIntegrationKind(i,e,t,s);return{appId:t.app_id,subdomain:n,origin:t.config.origin,httpUseOneSignalCom:t.config.http_use_onesignal_com,cookieSyncEnabled:t.features.cookie_sync.enable,restrictedOriginEnabled:t.features.restrict_origin&&t.features.restrict_origin.enable,metrics:{enable:t.features.metrics.enable,mixpanelReportingToken:t.features.metrics.mixpanel_reporting_token},safariWebId:t.config.safari_web_id,vapidPublicKey:t.config.vapid_public_key,onesignalVapidPublicKey:t.config.onesignal_vapid_public_key,emailAuthRequired:t.features.email&&t.features.email.require_auth,userConfig:r,enableOnSession:t.features.enable_on_session||!1}}static getConfigIntegrationKind(e){return e.config.integration?e.config.integration.kind:mt.Custom}static getCustomLinkConfig(e){const t={enabled:!1,style:"button",size:"medium",unsubscribeEnabled:!1,text:{explanation:"",subscribe:"",unsubscribe:""},color:{button:"",text:""}};if(!(e&&e.config&&e.config.staticPrompts&&e.config.staticPrompts.customlink&&e.config.staticPrompts.customlink.enabled))return t;const i=e.config.staticPrompts.customlink;return{enabled:i.enabled,style:i.style,size:i.size,unsubscribeEnabled:i.unsubscribeEnabled,text:i.text?{subscribe:i.text.subscribe,unsubscribe:i.text.unsubscribe,explanation:i.text.explanation}:t.text,color:i.color?{button:i.color.button,text:i.color.text}:t.color}}static injectDefaultsIntoPromptOptions(e,t,i,n=!1){let o={enabled:!1};e&&e.customlink&&(o=e.customlink);const s=t.customlink,r=Object.assign({},e,{customlink:{enabled:P.b.getValueOrDefault(o.enabled,s.enabled),style:P.b.getValueOrDefault(o.style,s.style),size:P.b.getValueOrDefault(o.size,s.size),unsubscribeEnabled:P.b.getValueOrDefault(o.unsubscribeEnabled,s.unsubscribeEnabled),text:{subscribe:P.b.getValueOrDefault(o.text?o.text.subscribe:void 0,s.text.subscribe),unsubscribe:P.b.getValueOrDefault(o.text?o.text.unsubscribe:void 0,s.text.unsubscribe),explanation:P.b.getValueOrDefault(o.text?o.text.explanation:void 0,s.text.explanation)},color:{button:P.b.getValueOrDefault(o.color?o.color.button:void 0,s.color.button),text:P.b.getValueOrDefault(o.color?o.color.text:void 0,s.color.text)}}});return r.slidedown?(r.slidedown.enabled=!!r.slidedown.enabled,r.slidedown.autoPrompt=r.slidedown.hasOwnProperty("autoPrompt")?!!r.slidedown.enabled&&!!r.slidedown.autoPrompt:!!r.slidedown.enabled):(r.slidedown=G.getSlidedownPermissionMessageOptions(r),r.slidedown.enabled=!1,r.slidedown.autoPrompt=!1),r.native?(r.native.enabled=!!r.native.enabled,r.native.autoPrompt=r.native.hasOwnProperty("autoPrompt")?!!r.native.enabled&&!!r.native.autoPrompt:!!r.native.enabled):r.native={enabled:!1,autoPrompt:!1},!0===i.autoRegister&&(n?(r.native.enabled=!1,r.native.autoPrompt=!1,r.slidedown.enabled=!0,r.slidedown.autoPrompt=!0):(r.native.enabled=!0,r.native.autoPrompt=!0)),r.autoPrompt=r.native.autoPrompt||r.slidedown.autoPrompt,r}static getPromptOptionsForDashboardConfiguration(e){const t=e.config.staticPrompts,i=t.native?{enabled:t.native.enabled,autoPrompt:t.native.enabled&&!1!==t.native.autoPrompt}:{enabled:!1,autoPrompt:!1},n={enabled:t.slidedown.enabled,autoPrompt:t.slidedown.enabled&&!1!==t.slidedown.autoPrompt,actionMessage:t.slidedown.actionMessage,acceptButtonText:t.slidedown.acceptButton,cancelButtonText:t.slidedown.cancelButton};return{autoPrompt:i.autoPrompt||n.autoPrompt,native:i,slidedown:n,fullscreen:{enabled:t.fullscreen.enabled,actionMessage:t.fullscreen.actionMessage,acceptButton:t.fullscreen.acceptButton,cancelButton:t.fullscreen.cancelButton,title:t.fullscreen.title,message:t.fullscreen.message,caption:t.fullscreen.caption,autoAcceptTitle:t.fullscreen.autoAcceptTitle},customlink:this.getCustomLinkConfig(e)}}static getUserConfigForConfigIntegrationKind(e,t,i,n=!1){switch(this.getIntegrationCapabilities(e).configuration){case wt.Dashboard:return{appId:i.app_id,autoRegister:!1,autoResubscribe:i.config.autoResubscribe,path:i.config.serviceWorker.path,serviceWorkerPath:i.config.serviceWorker.workerName,serviceWorkerUpdaterPath:i.config.serviceWorker.updaterWorkerName,serviceWorkerParam:{scope:i.config.serviceWorker.registrationScope},subdomainName:i.config.siteInfo.proxyOrigin,promptOptions:this.getPromptOptionsForDashboardConfiguration(i),welcomeNotification:{disable:!i.config.welcomeNotification.enable,title:i.config.welcomeNotification.title,message:i.config.welcomeNotification.message,url:i.config.welcomeNotification.url},notifyButton:{enable:i.config.staticPrompts.bell.enabled,displayPredicate:i.config.staticPrompts.bell.hideWhenSubscribed?()=>OneSignal.isPushNotificationsEnabled().then(e=>!e):null,size:i.config.staticPrompts.bell.size,position:i.config.staticPrompts.bell.location,showCredit:!1,offset:{bottom:i.config.staticPrompts.bell.offset.bottom+"px",left:i.config.staticPrompts.bell.offset.left+"px",right:i.config.staticPrompts.bell.offset.right+"px"},colors:{"circle.background":i.config.staticPrompts.bell.color.main,"circle.foreground":i.config.staticPrompts.bell.color.accent,"badge.background":"black","badge.foreground":"white","badge.bordercolor":"black","pulse.color":i.config.staticPrompts.bell.color.accent,"dialog.button.background.hovering":i.config.staticPrompts.bell.color.main,"dialog.button.background.active":i.config.staticPrompts.bell.color.main,"dialog.button.background":i.config.staticPrompts.bell.color.main,"dialog.button.foreground":"white"},text:{"tip.state.unsubscribed":i.config.staticPrompts.bell.tooltip.unsubscribed,"tip.state.subscribed":i.config.staticPrompts.bell.tooltip.subscribed,"tip.state.blocked":i.config.staticPrompts.bell.tooltip.blocked,"message.prenotify":i.config.staticPrompts.bell.tooltip.unsubscribed,"message.action.subscribing":i.config.staticPrompts.bell.message.subscribing,"message.action.subscribed":i.config.staticPrompts.bell.message.subscribing,"message.action.resubscribed":i.config.staticPrompts.bell.message.subscribing,"message.action.unsubscribed":i.config.staticPrompts.bell.message.unsubscribing,"dialog.main.title":i.config.staticPrompts.bell.dialog.main.title,"dialog.main.button.subscribe":i.config.staticPrompts.bell.dialog.main.subscribeButton,"dialog.main.button.unsubscribe":i.config.staticPrompts.bell.dialog.main.unsubscribeButton,"dialog.blocked.title":i.config.staticPrompts.bell.dialog.blocked.title,"dialog.blocked.message":i.config.staticPrompts.bell.dialog.blocked.message}},persistNotification:i.config.notificationBehavior?i.config.notificationBehavior.display.persist:void 0,webhooks:{cors:i.config.webhooks.corsEnable,"notification.displayed":i.config.webhooks.notificationDisplayedHook,"notification.clicked":i.config.webhooks.notificationClickedHook,"notification.dismissed":i.config.webhooks.notificationDismissedHook},notificationClickHandlerMatch:i.config.notificationBehavior?i.config.notificationBehavior.click.match:void 0,notificationClickHandlerAction:i.config.notificationBehavior?i.config.notificationBehavior.click.action:void 0,allowLocalhostAsSecureOrigin:i.config.setupBehavior?i.config.setupBehavior.allowLocalhostAsSecureOrigin:void 0,requiresUserPrivacyConsent:t.requiresUserPrivacyConsent};case wt.JavaScript:const o=Object.assign({},t,{promptOptions:this.injectDefaultsIntoPromptOptions(t.promptOptions,i.config.staticPrompts,t,n)},{serviceWorkerParam:"undefined"!=typeof OneSignal&&OneSignal.SERVICE_WORKER_PARAM?OneSignal.SERVICE_WORKER_PARAM:{scope:"/"},serviceWorkerPath:"undefined"!=typeof OneSignal&&OneSignal.SERVICE_WORKER_PATH?OneSignal.SERVICE_WORKER_PATH:"OneSignalSDKWorker.js",serviceWorkerUpdaterPath:"undefined"!=typeof OneSignal&&OneSignal.SERVICE_WORKER_UPDATER_PATH?OneSignal.SERVICE_WORKER_UPDATER_PATH:"OneSignalSDUpdaterKWorker.js",path:t.path?t.path:"/"});return t.hasOwnProperty("autoResubscribe")?o.autoResubscribe=!!t.autoResubscribe:t.hasOwnProperty("autoRegister")?o.autoResubscribe=!!t.autoRegister:o.autoResubscribe=!!i.config.autoResubscribe,o}}static getSubdomainForConfigIntegrationKind(e,t,i){const n=this.getIntegrationCapabilities(e);let o=t.subdomainName,s="";switch(n.configuration){case wt.Dashboard:s=i.config.siteInfo.proxyOriginEnabled?i.config.siteInfo.proxyOrigin:void 0;break;case wt.JavaScript:s=i.config.subdomain}return s&&!this.shouldUseServerConfigSubdomain(o,n)?void 0:s}static shouldUseServerConfigSubdomain(e,t){switch(t.configuration){case wt.Dashboard:return!0;case wt.JavaScript:switch(location.protocol){case"https:":return!!e;case"http:":return!0;default:return!1}}}}var Tt=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class Ct{getAppConfig(e){return Tt(this,void 0,void 0,function*(){return yield It.getAppConfig(e,Ot.downloadServerAppConfig)})}getMergedConfig(e,t){return It.getMergedConfig(e,t)}}var At=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class Nt{constructor(e){this.options={appId:e.appId,subdomain:e.subdomainName,origin:e.origin,metrics:{enable:!1,mixpanelReportingToken:null},userConfig:{}}}initialize(){return At(this,void 0,void 0,function*(){if((window.opener||window.parent)==window)return document.write("OneSignal: This page cannot be directly opened, and must be opened as a result of a subscription call."),Promise.resolve();const e=Object.assign({},this.options);e.appId=e.appId,e.subdomainName=e.subdomain,e.origin=e.origin,OneSignal.config=e||{};const t=yield(new Ct).getAppConfig(e);return OneSignal.context=new gt(t),OneSignal.context.workerMessenger.listen(!0),OneSignal.initialized=!0,this.loadPromise={},this.loadPromise.promise=new Promise((e,t)=>{this.loadPromise.resolver=e,this.loadPromise.rejector=t}),this.establishCrossOriginMessaging(),this.loadPromise.promise})}establishCrossOriginMessaging(){}dispose(){this.messenger.destroy()}finishInitialization(){this.loadPromise.resolver()}subscribe(){return At(this,void 0,void 0,function*(){const e=yield OneSignal.isPushNotificationsEnabled(),t=opener||parent;e?t&&window.close():Y.registerForPush()})}}var Mt=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class kt extends Nt{initialize(){const e=super.initialize();return m.a.trigger("httpInitialize"),e}establishCrossOriginMessaging(){this.messenger&&this.messenger.destroy(),this.messenger=new X(window,this.options.origin,this.options.origin),this.messenger.on(OneSignal.POSTMAM_COMMANDS.CONNECTED,this.onMessengerConnect.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.IFRAME_POPUP_INITIALIZE,this.onProxyFrameInitializing.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.REMOTE_NOTIFICATION_PERMISSION,this.onRemoteNotificationPermission.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.REMOTE_DATABASE_GET,this.onRemoteDatabaseGet.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.REMOTE_DATABASE_PUT,this.onRemoteDatabasePut.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.REMOTE_DATABASE_REMOVE,this.onRemoteDatabaseRemove.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.UNSUBSCRIBE_FROM_PUSH,this.onUnsubscribeFromPush.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.MARK_PROMPT_DISMISSED,this.onMarkPromptDismissed.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.IS_SUBSCRIBED,this.onIsSubscribed.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.UNSUBSCRIBE_PROXY_FRAME,this.onUnsubscribeProxyFrame.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.SERVICE_WORKER_STATE,this.onServiceWorkerState.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.GET_WORKER_VERSION,this.onWorkerVersion.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.SUBSCRIPTION_EXPIRATION_STATE,this.onSubscriptionExpirationState.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.PROCESS_EXPIRING_SUBSCRIPTIONS,this.onProcessExpiringSubscriptions.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.GET_SUBSCRIPTION_STATE,this.onGetSubscriptionState.bind(this)),this.messenger.listen()}retriggerRemoteEvent(e,t){this.messenger.message(OneSignal.POSTMAM_COMMANDS.REMOTE_RETRIGGER_EVENT,{eventName:e,eventData:t})}onMessengerConnect(e){return Mt(this,void 0,void 0,function*(){return M.a.debug(`(${E.a.getWindowEnv().toString()}) Successfully established cross-origin communication.`),this.finishInitialization(),!1})}onProxyFrameInitializing(e){return Mt(this,void 0,void 0,function*(){if(M.a.info(`(${E.a.getWindowEnv().toString()}) The iFrame has just received initOptions from the host page!`),OneSignal.config=Object.assign({},e.data.hostInitOptions,OneSignal.config,{pageUrl:e.data.pageUrl,pageTitle:e.data.pageTitle}),Fe.installNativePromptPermissionChangedHook(),(yield N.a.get("Options","defaultUrl"))||(yield N.a.put("Options",{key:"defaultUrl",value:new URL(OneSignal.config.pageUrl).origin})),yield N.a.put("Options",{key:"lastKnownHostUrl",value:OneSignal.config.pageUrl}),yield Fe.initSaveState(OneSignal.config.pageTitle),yield Fe.storeInitialValues(),yield Fe.saveInitOptions(),navigator.serviceWorker&&"https:"===window.location.protocol)try{OneSignal.context.serviceWorkerManager.establishServiceWorkerChannel()}catch(e){M.a.error("Error interacting with Service Worker inside an HTTP-hosted iFrame:",e)}e.reply(OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE)})}onRemoteNotificationPermission(e){return Mt(this,void 0,void 0,function*(){const t=OneSignal.context,i=yield t.permissionManager.getReportedNotificationPermission(t.appConfig.safariWebId);return e.reply(i),!1})}onRemoteDatabaseGet(e){return Mt(this,void 0,void 0,function*(){const t=e.data,i=[];for(let e of t){const{table:t,key:n}=e;i.push(N.a.get(t,n))}const n=yield Promise.all(i);return e.reply(n),!1})}onRemoteDatabasePut(e){return Mt(this,void 0,void 0,function*(){const t=e.data;let i=[];for(let e of t){let{table:t,keypath:n}=e;i.push(N.a.put(t,n))}return yield Promise.all(i),e.reply(OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE),!1})}onRemoteDatabaseRemove(e){return Mt(this,void 0,void 0,function*(){const t=e.data;let i=[];for(let e of t){let{table:t,keypath:n}=e;i.push(N.a.remove(t,n))}return yield Promise.all(i),e.reply(OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE),!1})}onUnsubscribeFromPush(e){return Mt(this,void 0,void 0,function*(){M.a.debug("(Reposted from iFrame -> Host) User unsubscribed but permission granted. Re-prompting the user for push.");try{yield Object(k.x)(),e.reply(OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE)}catch(e){M.a.debug("Failed to unsubscribe from push remotely:",e)}})}onMarkPromptDismissed(e){return Mt(this,void 0,void 0,function*(){return M.a.debug("(Reposted from iFrame -> Host) Marking prompt as dismissed."),yield Ve.markHttpsNativePromptDismissed(),e.reply(OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE),!1})}onIsSubscribed(e){return Mt(this,void 0,void 0,function*(){const t=yield OneSignal.isPushNotificationsEnabled();return e.reply(t),!1})}onUnsubscribeProxyFrame(e){return Mt(this,void 0,void 0,function*(){return(yield OneSignal.isPushNotificationsEnabled())&&(yield OneSignal.setSubscription(!1),yield OneSignal.database.rebuild()),e.reply(OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE),!1})}onServiceWorkerState(e){return Mt(this,void 0,void 0,function*(){const t=yield OneSignal.context.serviceWorkerManager.getActiveState();return e.reply(t),!1})}onWorkerVersion(e){return Mt(this,void 0,void 0,function*(){const t=yield OneSignal.context.serviceWorkerManager.getWorkerVersion();return e.reply(t),!1})}onSubscriptionExpirationState(e){return Mt(this,void 0,void 0,function*(){const t=yield OneSignal.context.subscriptionManager.isSubscriptionExpiring();return e.reply(t),!1})}onProcessExpiringSubscriptions(e){return Mt(this,void 0,void 0,function*(){OneSignal.context,yield Fe.processExpiringSubscriptions();return e.reply(OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE),!1})}onGetSubscriptionState(e){return Mt(this,void 0,void 0,function*(){const t=yield OneSignal.context.subscriptionManager.getSubscriptionState();return e.reply(t),!1})}}class xt extends Nt{constructor(e){super(e)}establishCrossOriginMessaging(){this.messenger&&this.messenger.destroy(),this.messenger=new X(window.parent,this.options.origin,this.options.origin)}}class _t extends Nt{constructor(e){super(e)}establishCrossOriginMessaging(){this.messenger=new X(window.opener,this.options.origin,this.options.origin),this.messenger.once(OneSignal.POSTMAM_COMMANDS.CONNECTED,this.onMessengerConnected.bind(this)),this.messenger.postMessage(OneSignal.POSTMAM_COMMANDS.POPUP_BEGIN_MESSAGEPORT_COMMS,null),this.messenger.listen()}onMessengerConnected(e){M.a.debug(`(${E.a.getWindowEnv().toString()}) The host page is now ready to receive commands from the HTTP popup.`),this.finishInitialization()}}var Rt=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class Dt{static initHttp(e){return Rt(this,void 0,void 0,function*(){switch(M.a.debug(`Called %cinitHttp(${JSON.stringify(e,null,4)})`,Object(k.j)("code")),E.a.getWindowEnv()){case L.a.OneSignalProxyFrame:OneSignal.proxyFrame=new kt(e),yield OneSignal.proxyFrame.initialize(),j.ensureBackwardsCompatibility(OneSignal);break;case L.a.OneSignalSubscriptionPopup:OneSignal.subscriptionPopup=new _t(e),yield OneSignal.subscriptionPopup.initialize(),j.ensureBackwardsCompatibility(OneSignal),m.a.trigger("httpInitialize");break;case L.a.OneSignalSubscriptionModal:OneSignal.subscriptionModal=new xt(e),OneSignal.subscriptionModal.establishCrossOriginMessaging(),OneSignal.subscriptionModal.initialize(),j.ensureBackwardsCompatibility(OneSignal),m.a.trigger("httpInitialize");break;default:M.a.error("Unsupported HTTP initialization branch.")}})}}var Wt=i(14),Ut=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class Bt{static get LOAD_TIMEOUT_MS(){return 15e3}constructor(e){this.url=e,this.url.pathname="webPushIframe"}load(){return Ut(this,void 0,void 0,function*(){M.a.debug("Opening an iFrame to",this.url.toString()),this.removeFrame();const e=document.createElement("iframe");return e.style.display="none",e.src=this.url.toString(),e.sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation",this.loadPromise={},this.loadPromise.promise=new Promise((e,t)=>{this.loadPromise.resolver=e,this.loadPromise.rejector=t}),document.body.appendChild(e),e.onload=this.onFrameLoad.bind(this),this.element=e,Object(k.v)(this.loadPromise.promise,Bt.LOAD_TIMEOUT_MS).catch(()=>{window===window.top&&M.a.warn(`OneSignal: Loading the required iFrame ${this.url.toString()} timed out. Check that the Site URL onesignal.com dashboard web config is ${location.origin}. Only the Site URL specified there is allowed to use load the iFrame.`)}),this.loadPromise.promise})}removeFrame(){if(!l.a.isBrowser())return;const e=document.querySelector(`iframe[src='${this.url.toString()}']`);e&&e.remove()}onFrameLoad(e){this.establishCrossOriginMessaging()}establishCrossOriginMessaging(){this.messenger&&this.messenger.destroy(),this.messenger=new X(this.element.contentWindow,this.url.toString(),this.url.toString()),this.messenger.on(OneSignal.POSTMAM_COMMANDS.CONNECTED,this.onMessengerConnect.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.REMOTE_RETRIGGER_EVENT,this.onRemoteRetriggerEvent.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.REMOTE_NOTIFICATION_PERMISSION_CHANGED,this.onRemoteNotificationPermissionChanged.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.REQUEST_HOST_URL,this.onRequestHostUrl.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.SERVICEWORKER_COMMAND_REDIRECT,this.onServiceWorkerCommandRedirect.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.GET_EVENT_LISTENER_COUNT,this.onGetEventListenerCount.bind(this)),this.messenger.connect()}dispose(){this.messenger&&this.messenger.destroy(),this.removeFrame()}onMessengerConnect(e){return Ut(this,void 0,void 0,function*(){M.a.debug(`Successfully established cross-origin communication for iFrame at ${this.url.toString()}`),this.messenger.message(OneSignal.POSTMAM_COMMANDS.IFRAME_POPUP_INITIALIZE,{hostInitOptions:JSON.parse(JSON.stringify(OneSignal.config)),pageUrl:window.location.href,pageTitle:document.title},e=>(e.data===OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE&&this.loadPromise.resolver(),!1))})}onRemoteRetriggerEvent(e){let{eventName:t,eventData:i}=e.data;return m.a.trigger(t,i,e.source),!1}onRemoteNotificationPermissionChanged(e){let{forceUpdatePermission:t}=e.data;return Object(k.w)(t),!1}onRequestHostUrl(e){return e.reply(location.href),!1}onServiceWorkerCommandRedirect(e){const t=e.data;return t&&t.startsWith("http")&&(window.location.href=t),!1}onGetEventListenerCount(e){const t=e.data;return M.a.debug("(Reposted from iFrame -> Host) Getting event listener count for ",t),e.reply(OneSignal.emitter.numberOfListeners(t)),!1}isSubscribed(){return new Promise(e=>{this.messenger.message(OneSignal.POSTMAM_COMMANDS.IS_SUBSCRIBED,null,t=>{e(t.data)})})}unsubscribeFromPush(){return new Promise(e=>{this.messenger.message(OneSignal.POSTMAM_COMMANDS.UNSUBSCRIBE_PROXY_FRAME,null,t=>{e()})})}getProxyServiceWorkerActiveState(){return new Promise((e,t)=>{this.message(OneSignal.POSTMAM_COMMANDS.SERVICE_WORKER_STATE,null,t=>{e(t.data)})})}runCommand(e){return Ut(this,void 0,void 0,function*(){return yield new Promise((t,i)=>{this.message(e,null,e=>{t(e.data)})})})}message(...e){this.messenger.message.apply(this.messenger,arguments)}}var Lt=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class jt{constructor(){}static discoverAltOrigin(e){return Lt(this,void 0,void 0,function*(){const t=jt.getOneSignalProxyIframeUrls(e),i=[];let n;for(const e of t){const t=new Bt(e);yield t.load(),i.push(t)}const o=yield jt.removeDuplicatedAltOriginSubscription(i);if(o)n=o[0];else for(const e of i)if(yield e.isSubscribed())n=e;else{if(!Object(k.f)(e.url.host,".os.tc")){e.dispose();continue}n?e.dispose():n=e}return n})}static removeDuplicatedAltOriginSubscription(e){return Lt(this,void 0,void 0,function*(){const t=[];for(const i of e)(yield i.isSubscribed())&&t.push(i);if(t.length<2)return null;if(E.a.getBuildEnv()==Wt.a.Development)var i=".localhost:3001";else if(E.a.getBuildEnv()==Wt.a.Production)i=".onesignal.com";var n=t.find(e=>Object(k.f)(e.url.host,i));if(n){yield n.unsubscribeFromPush(),n.dispose();const t=e.indexOf(n);return e.splice(t,1),e}return null})}static getCanonicalSubscriptionUrls(e,t=E.a.getApiEnv()){let i=[];if(e.httpUseOneSignalCom){let n=E.a.getOneSignalApiUrl(t);n.host=[e.subdomain,n.host].join("."),i.push(n)}let n=E.a.getOneSignalApiUrl(t);n.host=[e.subdomain,"os.tc"].join("."),i.push(n);for(const e of i)e.pathname="";return i}static getOneSignalProxyIframeUrls(e){const t=jt.getCanonicalSubscriptionUrls(e);for(const e of t)e.pathname="webPushIframe";return t}static getOneSignalSubscriptionPopupUrls(e){const t=jt.getCanonicalSubscriptionUrls(e);for(const e of t)e.pathname="subscribe";return t}}var Ft=i(22);class Ht{static isValidUrl(e,t){if(t&&t.allowNull&&null===e)return!0;if(t&&t.allowEmpty&&(null===e||void 0===e))return!0;try{const i=new URL(e);return!t||!t.requireHttps||"https:"===i.protocol}catch(e){return!1}}static isValidBoolean(e,t){return!(!t||!t.allowNull||null!==e)||(!0===e||!1===e)}static isValidArray(e,t){return!(!t||!t.allowNull||null!==e)||(!(!t||!t.allowEmpty||null!==e&&void 0!==e)||e instanceof Array)}}var Vt=i(19);class $t{static processItem(e,t){if("function"==typeof t)t();else{if(!Array.isArray(t))throw new u.a("Only accepts function and Array types!");{if(0==t.length)throw new u.a("Empty array is not valid!");const i=t.shift();if(null==i||void 0===i)throw new u.a("First element in array must be the OneSignal function name");const n=e[i.toString()];if("function"!=typeof n)throw new u.a(`No OneSignal function with the name '${i}'`);n.apply(e,t)}}}}i.d(t,"default",function(){return Gt});var zt=function(e,t,i,n){return new(i||(i=Promise))(function(o,s){function r(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,a)}c((n=n.apply(e,t||[])).next())})};class Gt{static setDefaultNotificationUrl(e){return zt(this,void 0,void 0,function*(){if(!Ht.isValidUrl(e,{allowNull:!0}))throw new InvalidArgumentError.a("url",InvalidArgumentError.b.Malformed);yield Object(k.c)(),Object(k.q)("setDefaultNotificationUrl",e);const t=yield N.a.getAppState();t.defaultNotificationUrl=e,yield N.a.setAppState(t)})}static setDefaultTitle(e){return zt(this,void 0,void 0,function*(){yield Object(k.c)(),Object(k.q)("setDefaultTitle",e);const t=yield N.a.getAppState();t.defaultNotificationTitle=e,yield N.a.setAppState(t)})}static setEmail(e,t){return zt(this,void 0,void 0,function*(){if(!e)throw new InvalidArgumentError.a("email",InvalidArgumentError.b.Empty);if(!Object(k.p)(e))throw new InvalidArgumentError.a("email",InvalidArgumentError.b.Malformed);if(t&&t.emailAuthHash&&64!==t.emailAuthHash.length)throw new InvalidArgumentError.a("options.emailAuthHash",InvalidArgumentError.b.Malformed);yield Object(k.c)(),Object(k.q)("setEmail",e,t);const i=yield N.a.getAppConfig(),{deviceId:n}=yield N.a.getSubscription(),o=yield N.a.getEmailProfile();if(i.emailAuthRequired&&(!t||!t.emailAuthHash))throw new InvalidArgumentError.a("options.emailAuthHash",InvalidArgumentError.b.Empty);const s=new Vt.a(o.emailId,e);t&&t.emailAuthHash&&(s.emailAuthHash=t.emailAuthHash);const r=!!o.emailId;return r&&i.emailAuthRequired?s.emailId=yield Ot.updateEmailRecord(i,s,n):s.emailId=yield Ot.createEmailRecord(i,s,n),!n||r&&o.emailId===s.emailId&&o.emailAddress&&s.emailAddress===o.emailAddress||(yield Ot.updatePlayer(i.appId,n,{parent_player_id:s.emailId,email:s.emailAddress})),yield N.a.setEmailProfile(s),s.emailId})}static logoutEmail(){return zt(this,void 0,void 0,function*(){yield Object(k.c)();const e=yield N.a.getAppConfig(),t=yield N.a.getEmailProfile(),{deviceId:i}=yield N.a.getSubscription();t.emailId?i?(yield Ot.logoutEmail(e,t,i))?yield N.a.setEmailProfile(new Vt.a):M.a.warn("Failed to logout email."):M.a.warn(new d(n.NoDeviceId)):M.a.warn(new d(n.NoEmailSet))})}static isPushNotificationsSupported(){return Object(k.q)("isPushNotificationsSupported"),!0}static initializeConfig(e){return zt(this,void 0,void 0,function*(){const t=yield(new Ct).getAppConfig(e);M.a.debug(`OneSignal: Final web app config: %c${JSON.stringify(t,null,4)}`,Object(k.j)("code")),Gt.context=new gt(t),Gt.config=Gt.context.appConfig})}static init(e){return zt(this,void 0,void 0,function*(){if(Object(k.q)("init"),yield Fe.polyfillSafariFetch(),Fe.errorIfInitAlreadyCalled(),yield Gt.initializeConfig(e),!Gt.config)throw new Error("OneSignal config not initialized!");if(!c.a.safari||Gt.config.safariWebId){if(Gt.config.userConfig.requiresUserPrivacyConsent){if(!(yield N.a.getProvideUserConsent()))return void(Gt.pendingInit=!0)}yield Gt.delayedInit()}else M.a.warn(new g(s.MissingSafariWebId))})}static delayedInit(){return zt(this,void 0,void 0,function*(){function e(){return zt(this,void 0,void 0,function*(){if(!Gt.__initAlreadyCalled){if(Gt.__initAlreadyCalled=!0,Gt.emitter.on(Gt.EVENTS.NATIVE_PROMPT_PERMISSIONCHANGED,W.onNotificationPermissionChange),Gt.emitter.on(Gt.EVENTS.SUBSCRIPTION_CHANGED,W._onSubscriptionChanged),Gt.emitter.on(Gt.EVENTS.SDK_INITIALIZED,Fe.onSdkInitialized),y.b.isUsingSubscriptionWorkaround()){if(!Gt.config||!Gt.config.subdomain)throw new g(s.MissingSubdomain);Gt.proxyFrameHost=yield jt.discoverAltOrigin(Gt.config)}window.addEventListener("focus",()=>{G.checkAndTriggerNotificationPermissionChanged()}),yield Fe.initSaveState(document.title),yield Fe.saveInitOptions(),E.a.getWindowEnv()===L.a.CustomIframe?yield m.a.trigger(Gt.EVENTS.SDK_INITIALIZED):yield Fe.internalInit()}})}Gt.pendingInit=!1,Gt.context.workerMessenger.listen(),"complete"===document.readyState||"interactive"===document.readyState?yield e():(M.a.debug("OneSignal: Waiting for DOMContentLoaded or readyStateChange event before continuing initialization..."),window.addEventListener("DOMContentLoaded",()=>{e()}),document.onreadystatechange=(()=>{"complete"!==document.readyState&&"interactive"!==document.readyState||e()}))})}static provideUserConsent(e){return zt(this,void 0,void 0,function*(){yield N.a.setProvideUserConsent(e),e&&Gt.pendingInit&&(yield Gt.delayedInit())})}static showHttpPermissionRequest(e){return zt(this,void 0,void 0,function*(){M.a.debug("Called showHttpPermissionRequest(), redirecting to HTTP prompt."),Gt.showHttpPrompt(e).catch(e=>M.a.info(e))})}static showHttpPrompt(e){return zt(this,void 0,void 0,function*(){yield Object(k.c)(),yield Gt.context.promptsManager.internalShowSlidedownPrompt(e)})}static showNativePrompt(){return zt(this,void 0,void 0,function*(){yield Object(k.c)(),yield Gt.context.promptsManager.internalShowNativePrompt()})}static showSlidedownPrompt(e){return zt(this,void 0,void 0,function*(){yield Object(k.c)(),yield Gt.context.promptsManager.internalShowSlidedownPrompt(e)})}static registerForPushNotifications(e){return zt(this,void 0,void 0,function*(){if(Gt.initialized)return yield Fe.registerForPushNotifications(e);yield new Promise((t,i)=>{Gt.emitter.once(Gt.EVENTS.SDK_INITIALIZED,()=>zt(this,void 0,void 0,function*(){return yield Fe.registerForPushNotifications(e),t()}))})})}static getNotificationPermission(e){return zt(this,void 0,void 0,function*(){return yield Object(k.c)(),Gt.privateGetNotificationPermission(e)})}static privateGetNotificationPermission(e){return zt(this,void 0,void 0,function*(){const t=yield Gt.context.permissionManager.getNotificationPermission(Gt.config.safariWebId);return e&&e(t),t})}static getTags(e){return zt(this,void 0,void 0,function*(){yield Object(k.c)(),Object(k.q)("getTags",e);const{appId:t}=yield N.a.getAppConfig(),{deviceId:i}=yield N.a.getSubscription();if(!i)return M.a.info(new d(n.NoDeviceId)),null;const{tags:o}=yield Ot.getPlayer(t,i);return Object(k.i)(e,o),o})}static sendTag(e,t,i){return zt(this,void 0,void 0,function*(){const n={};return n[e]=t,yield Gt.sendTags(n,i)})}static sendTags(e,t){return zt(this,void 0,void 0,function*(){if(yield Object(k.c)(),Object(k.q)("sendTags",e,t),!e||0===Object.keys(e).length)return M.a.info(new InvalidArgumentError.a("tags",InvalidArgumentError.b.Empty)),null;Object.keys(e).forEach(t=>{!1===e[t]&&(e[t]="false")});const{appId:i}=yield N.a.getAppConfig(),n=yield N.a.getEmailProfile();n.emailId&&(yield Ot.updatePlayer(i,n.emailId,{tags:e,email_auth_hash:n.emailAuthHash}));var{deviceId:o}=yield N.a.getSubscription();o||(yield Object(k.d)(Gt.EVENTS.REGISTERED));var{deviceId:s}=yield N.a.getSubscription();return yield Ot.updatePlayer(i,s,{tags:e}),Object(k.i)(t,e),e})}static deleteTag(e){return zt(this,void 0,void 0,function*(){return yield Gt.deleteTags([e])})}static deleteTags(e,t){return zt(this,void 0,void 0,function*(){if(yield Object(k.c)(),Object(k.q)("deleteTags",e,t),!Ht.isValidArray(e))throw new InvalidArgumentError.a("tags",InvalidArgumentError.b.Malformed);0===e.length&&M.a.info(new InvalidArgumentError.a("tags",InvalidArgumentError.b.Empty));const i={};for(let t of e)i[t]="";const n=yield Gt.sendTags(i);if(n){const e=Object.keys(n);return Object(k.i)(t,e),e}return[]})}static setExternalUserId(e){return zt(this,void 0,void 0,function*(){yield Object(k.c)(),Object(k.q)("setExternalUserId"),(yield this.context.subscriptionManager.isAlreadyRegisteredWithOneSignal())||(yield Object(k.d)(Gt.EVENTS.REGISTERED)),yield Promise.all([Gt.database.setExternalUserId(e),Gt.context.updateManager.sendExternalUserIdUpdate(e)])})}static getExternalUserId(){return zt(this,void 0,void 0,function*(){return yield Object(k.c)(),Object(k.q)("getExternalUserId"),yield Gt.database.getExternalUserId()})}static removeExternalUserId(){return zt(this,void 0,void 0,function*(){yield Object(k.c)(),Object(k.q)("removeExternalUserId"),(yield this.context.subscriptionManager.isAlreadyRegisteredWithOneSignal())?yield Promise.all([Gt.database.setExternalUserId(void 0),Gt.context.updateManager.sendExternalUserIdUpdate(void 0)]):M.a.warn("User is not subscribed, cannot remove external user id.")})}static addListenerForNotificationOpened(e){return zt(this,void 0,void 0,function*(){yield Object(k.c)(),Object(k.q)("addListenerForNotificationOpened",e),Gt.emitter.once(Gt.EVENTS.NOTIFICATION_CLICKED,t=>{Object(k.i)(e,t)}),Gt.config&&W.fireStoredNotificationClicks(Gt.config.pageUrl||Gt.config.userConfig.pageUrl)})}static getIdsAvailable(e){return zt(this,void 0,void 0,function*(){yield Object(k.c)(),Object(k.q)("getIdsAvailable",e);const{deviceId:t,subscriptionToken:i}=yield N.a.getSubscription(),n={userId:t,registrationId:i};return Object(k.i)(e,n),n})}static isPushNotificationsEnabled(e){return zt(this,void 0,void 0,function*(){return yield Object(k.c)(),Gt.privateIsPushNotificationsEnabled(e)})}static privateIsPushNotificationsEnabled(e){return zt(this,void 0,void 0,function*(){Object(k.q)("isPushNotificationsEnabled",e);const t=yield Gt.context.subscriptionManager.getSubscriptionState();return Object(k.i)(e,t.subscribed&&!t.optedOut),t.subscribed&&!t.optedOut})}static setSubscription(e){return zt(this,void 0,void 0,function*(){yield Object(k.c)(),Object(k.q)("setSubscription",e);const t=yield N.a.getAppConfig(),{appId:i}=t,o=yield N.a.getSubscription(),{deviceId:s}=o;if(!t.appId)throw new InvalidStateError.a(InvalidStateError.b.MissingAppId);if(!Ht.isValidBoolean(e))throw new InvalidArgumentError.a("newSubscription",InvalidArgumentError.b.Malformed);s?(o.optedOut=!e,yield Ot.updatePlayer(i,s,{notification_types:G.getNotificationTypeFromOptIn(e)}),yield N.a.setSubscription(o),W.onInternalSubscriptionSet(o.optedOut),W.checkAndTriggerSubscriptionChanged()):M.a.info(new d(n.NoDeviceId))})}static isOptedOut(e){return zt(this,void 0,void 0,function*(){return yield Object(k.c)(),Gt.internalIsOptedOut(e)})}static internalIsOptedOut(e){return zt(this,void 0,void 0,function*(){Object(k.q)("isOptedOut",e);const{optedOut:t}=yield N.a.getSubscription();return Object(k.i)(e,t),t})}static optOut(e,t){return zt(this,void 0,void 0,function*(){if(yield Object(k.c)(),Object(k.q)("optOut",e,t),!Ht.isValidBoolean(e))throw new InvalidArgumentError.a("doOptOut",InvalidArgumentError.b.Malformed);yield Gt.setSubscription(!e),Object(k.i)(t)})}static getEmailId(e){return zt(this,void 0,void 0,function*(){yield Object(k.c)(),Object(k.q)("getEmailId",e);const t=(yield N.a.getEmailProfile()).emailId;return Object(k.i)(e,t),t})}static getUserId(e){return zt(this,void 0,void 0,function*(){yield Object(k.c)(),Object(k.q)("getUserId",e);const t=(yield N.a.getSubscription()).deviceId;return Object(k.i)(e,t),t})}static getRegistrationId(e){return zt(this,void 0,void 0,function*(){yield Object(k.c)(),Object(k.q)("getRegistrationId",e);const t=(yield N.a.getSubscription()).subscriptionToken;return Object(k.i)(e,t),t})}static getSubscription(e){return zt(this,void 0,void 0,function*(){return yield Object(k.c)(),yield Gt.privateGetSubscription(e)})}static privateGetSubscription(e){return zt(this,void 0,void 0,function*(){Object(k.q)("getSubscription",e);const t=!(yield N.a.getSubscription()).optedOut;return Object(k.i)(e,t),t})}static sendSelfNotification(e="OneSignal Test Message",t="This is an example notification.",i=new URL(location.href).origin+"?_osp=do_not_open",o,s,r){return zt(this,void 0,void 0,function*(){yield Object(k.c)(),Object(k.q)("sendSelfNotification",e,t,i,o,s,r);const a=yield N.a.getAppConfig(),c=yield N.a.getSubscription();if(!a.appId)throw new InvalidStateError.a(InvalidStateError.b.MissingAppId);if(!(yield Gt.isPushNotificationsEnabled()))throw new d(n.NoDeviceId);if(!Ht.isValidUrl(i))throw new InvalidArgumentError.a("url",InvalidArgumentError.b.Malformed);if(!Ht.isValidUrl(o,{allowEmpty:!0,requireHttps:!0}))throw new InvalidArgumentError.a("icon",InvalidArgumentError.b.Malformed);c.deviceId&&(yield Ot.sendNotification(a.appId,[c.deviceId],{en:e},{en:t},i,o,s,r))})}static push(e){$t.processItem(Gt,e)}static on(e,t){return this.emitter.on(e,t)}static off(e,t){return this.emitter.off(e,t)}static once(e,t){return this.emitter.once(e,t)}}Gt.VERSION=l.a.version(),Gt._VERSION=l.a.version(),Gt.sdkEnvironment=E.a,Gt._notificationOpenedCallbacks=[],Gt._idsAvailable_callback=[],Gt._defaultLaunchURL=null,Gt.config=null,Gt._sessionInitAlreadyRunning=!1,Gt._isNotificationEnabledCallback=[],Gt._subscriptionSet=!0,Gt.modalUrl=null,Gt._windowWidth=650,Gt._windowHeight=568,Gt._isNewVisitor=!1,Gt._channel=null,Gt.timedLocalStorage=F,Gt.initialized=!1,Gt.notifyButton=null,Gt.store=b,Gt.environment=l.a,Gt.database=N.a,Gt.event=m.a,Gt.browser=c.a,Gt.popover=null,Gt.log=M.a,Gt.api=Ot,Gt.indexedDb=Ft.a,Gt.mainHelper=G,Gt.subscriptionHelper=Y,Gt.httpHelper=Dt,Gt.eventHelper=W,Gt.initHelper=Fe,Gt.testHelper=Ve,Gt.pendingInit=!0,Gt.emitter=new J.a,Gt.SERVICE_WORKER_UPDATER_PATH="OneSignalSDKUpdaterWorker.js",Gt.SERVICE_WORKER_PATH="OneSignalSDKWorker.js",Gt.SERVICE_WORKER_PARAM={scope:"/"},Gt._LOGGING=!1,Gt.LOGGING=!1,Gt._usingNativePermissionHook=!1,Gt._initCalled=!1,Gt.__initAlreadyCalled=!1,Gt.checkAndWipeUserSubscription=function(){},Gt.DeviceRecord=O,Gt.EmailDeviceRecord=w,Gt.notificationPermission=U,Gt._initHttp=Dt.initHttp,Gt._initPopup=(()=>Gt.subscriptionPopup.subscribe()),Gt.POSTMAM_COMMANDS={CONNECTED:"connect",REMOTE_NOTIFICATION_PERMISSION:"postmam.remoteNotificationPermission",REMOTE_DATABASE_GET:"postmam.remoteDatabaseGet",REMOTE_DATABASE_PUT:"postmam.remoteDatabasePut",REMOTE_DATABASE_REMOVE:"postmam.remoteDatabaseRemove",REMOTE_OPERATION_COMPLETE:"postman.operationComplete",REMOTE_RETRIGGER_EVENT:"postmam.remoteRetriggerEvent",MODAL_LOADED:"postmam.modalPrompt.loaded",MODAL_PROMPT_ACCEPTED:"postmam.modalPrompt.accepted",MODAL_PROMPT_REJECTED:"postmam.modalPrompt.canceled",POPUP_LOADED:"postmam.popup.loaded",POPUP_ACCEPTED:"postmam.popup.accepted",POPUP_REJECTED:"postmam.popup.canceled",POPUP_CLOSING:"postman.popup.closing",REMOTE_NOTIFICATION_PERMISSION_CHANGED:"postmam.remoteNotificationPermissionChanged",IFRAME_POPUP_INITIALIZE:"postmam.iframePopupInitialize",UNSUBSCRIBE_FROM_PUSH:"postmam.unsubscribeFromPush",SET_SESSION_COUNT:"postmam.setSessionCount",REQUEST_HOST_URL:"postmam.requestHostUrl",WINDOW_TIMEOUT:"postmam.windowTimeout",FINISH_REMOTE_REGISTRATION:"postmam.finishRemoteRegistration",FINISH_REMOTE_REGISTRATION_IN_PROGRESS:"postmam.finishRemoteRegistrationInProgress",POPUP_BEGIN_MESSAGEPORT_COMMS:"postmam.beginMessagePortComms",SERVICEWORKER_COMMAND_REDIRECT:"postmam.command.redirect",MARK_PROMPT_DISMISSED:"postmam.markPromptDismissed",IS_SUBSCRIBED:"postmam.isSubscribed",UNSUBSCRIBE_PROXY_FRAME:"postman.unsubscribeProxyFrame",GET_EVENT_LISTENER_COUNT:"postmam.getEventListenerCount",SERVICE_WORKER_STATE:"postmam.serviceWorkerState",GET_WORKER_VERSION:"postmam.getWorkerVersion",SUBSCRIPTION_EXPIRATION_STATE:"postmam.subscriptionExpirationState",PROCESS_EXPIRING_SUBSCRIPTIONS:"postmam.processExpiringSubscriptions",GET_SUBSCRIPTION_STATE:"postmam.getSubscriptionState"},Gt.EVENTS={CUSTOM_PROMPT_CLICKED:"customPromptClick",NATIVE_PROMPT_PERMISSIONCHANGED:"notificationPermissionChange",SUBSCRIPTION_CHANGED:"subscriptionChange",WELCOME_NOTIFICATION_SENT:"sendWelcomeNotification",NOTIFICATION_DISPLAYED:"notificationDisplay",NOTIFICATION_DISMISSED:"notificationDismiss",NOTIFICATION_CLICKED:"notificationClick",SDK_INITIALIZED:"initializeInternal",SDK_INITIALIZED_PUBLIC:"initialize",REGISTERED:"register",POPUP_CLOSING:"popupClose",PERMISSION_PROMPT_DISPLAYED:"permissionPromptDisplay",TEST_INIT_OPTION_DISABLED:"testInitOptionDisabled",TEST_WOULD_DISPLAY:"testWouldDisplay",POPUP_WINDOW_TIMEOUT:"popupWindowTimeout"},j.ensureBackwardsCompatibility(Gt),M.a.info(`%cOneSignal Web SDK loaded (version ${Gt._VERSION}, ${E.a.getWindowEnv().toString()} environment).`,Object(k.j)("bold")),M.a.debug(`Current Page URL: ${"undefined"==typeof location?"NodeJS":location.href}`),M.a.debug(`Browser Environment: ${c.a.name} ${c.a.version}`)},function(e,t){e.exports=function(){throw new Error("define cannot be used indirect")}},function(e,t){var i;i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(i=window)}e.exports=i}]); //# sourceMappingURL=OneSignalPageSDKES6.js.map