!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,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(n,o,function(t){return e[t]}.bind(null,o));return n},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=30)}([function(e,t,i){"use strict";i.d(t,"a",function(){return n});function n(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){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,a)}c((n=n.apply(e,t||[])).next())})}},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,"w",function(){return p}),i.d(t,"c",function(){return m}),i.d(t,"q",function(){return b}),i.d(t,"y",function(){return f}),i.d(t,"j",function(){return S}),i.d(t,"s",function(){return v}),i.d(t,"r",function(){return O}),i.d(t,"b",function(){return y}),i.d(t,"e",function(){return w}),i.d(t,"a",function(){return E}),i.d(t,"v",function(){return I}),i.d(t,"o",function(){return P}),i.d(t,"k",function(){return C}),i.d(t,"i",function(){return T}),i.d(t,"t",function(){return M}),i.d(t,"x",function(){return A}),i.d(t,"f",function(){return N}),i.d(t,"z",function(){return x}),i.d(t,"u",function(){return k}),i.d(t,"n",function(){return j}),i.d(t,"d",function(){return _}),i.d(t,"p",function(){return D}),i.d(t,"m",function(){return R}),i.d(t,"l",function(){return U}),i.d(t,"h",function(){return W});var n=i(0),o=i(4),s=i(6),r=(i(3),i(1)),a=i(8),c=i(17),l=i(22),d=i(5),u=i(9),g=i.n(u);function h(e){return l.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 b(){return a.a.isUsingSubscriptionWorkaround()}function f(e=!1){return Object(n.a)(this,void 0,void 0,function*(){return c.a.triggerNotificationPermissionChanged(e)})}function S(e,...t){if(e)return e.apply(null,t)}function v(e,...t){return a.a.logMethodCall(e,...t)}function O(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 y(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 I(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 P(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 C(e){return d.a.getConsoleStyle(e)}function T(e){return new Promise(t=>{setTimeout(t,e)})}function M(){return Promise.resolve()}function A(e,t){return d.a.timeoutPromise(e,t)}function N(e,t){return d.a.contains(e,t)}function x(){return r.a.warn("OneSignal: Unsubscribing from push."),o.a.getWindowEnv()!==s.a.ServiceWorker?self.registration.pushManager.getSubscription().then(e=>{if(e)return e.unsubscribe();throw new Error("Cannot unsubscribe because not subscribed.")}):b()?new Promise((e,t)=>{r.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=>{r.a.debug("Unsubscribe from push succesfully remotely executed."),i.data===OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE?e():t("Failed to remotely unsubscribe from push.")})}):OneSignal.context.serviceWorkerManager.getRegistration().then(e=>e||Promise.resolve()).then(e=>e.pushManager).then(e=>e.getSubscription()).then(e=>e?e.unsubscribe():Promise.resolve())}function k(e,t,i,n=!1){if(t||r.a.error("Cannot call on() with no event: ",t),i||r.a.error("Cannot call on() with no task: ",i),"string"==typeof e){const n=document.querySelectorAll(e);if(n.length>0)for(let e=0;e{OneSignal.emitter.once(e,e=>{t(e)})})})}function D(){window.__oneSignalSdkLoadCount=j()+1}function R(e){return e?g.a.safari&&e.safari?e.safari:g.a.firefox&&e.firefox?e.firefox:e.chrome||e.firefox||e.safari||"default-icon":"default-icon"}function U(e){const t=document.querySelector(e);return t||(r.a.debug(`No instance of ${e} found. Returning stub.`),document.createElement("div"))}function W(e){return JSON.parse(JSON.stringify(e))}},function(e,t,i){"use strict";i.d(t,"a",function(){return v});var n=i(0),o=i(18),s=i(24);class r{}class a{}var c,l=i(25),d=i(21),u=i(6),g=i(19),h=i(13),p=i(4),m=i(8),b=i(5),f=i(1),S=i(20);!function(e){e[e.SET=0]="SET"}(c||(c={}));class v{constructor(e){this.databaseName=e,this.emitter=new o.a,this.database=new s.a(this.databaseName)}static resetInstance(){v.databaseInstance=null}static get singletonInstance(){return v.databaseInstanceName||(v.databaseInstanceName="ONE_SIGNAL_SDK_DB"),v.databaseInstance||(v.databaseInstance=new v(v.databaseInstanceName)),v.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}}shouldUsePostmam(){return p.a.getWindowEnv()!==u.a.ServiceWorker&&m.b.isUsingSubscriptionWorkaround()&&p.a.getTestEnv()===d.a.None}get(e,t){return Object(n.a)(this,void 0,void 0,function*(){if(this.shouldUsePostmam())return yield new Promise(i=>Object(n.a)(this,void 0,void 0,function*(){OneSignal.proxyFrameHost.message(OneSignal.POSTMAM_COMMANDS.REMOTE_DATABASE_GET,[{table:e,key:t}],e=>{const t=e.data[0];i(t)})}));{const i=yield this.database.get(e,t);return v.applyDbResultFilter(e,t,i)}})}getAll(e){return Object(n.a)(this,void 0,void 0,function*(){if(this.shouldUsePostmam())return yield new Promise(t=>Object(n.a)(this,void 0,void 0,function*(){OneSignal.proxyFrameHost.message(OneSignal.POSTMAM_COMMANDS.REMOTE_DATABASE_GET_ALL,{table:e},e=>{const i=e.data;t(i)})}));return yield this.database.getAll(e)})}put(e,t){return Object(n.a)(this,void 0,void 0,function*(){yield new Promise((i,o)=>Object(n.a)(this,void 0,void 0,function*(){p.a.getWindowEnv()!==u.a.ServiceWorker&&m.b.isUsingSubscriptionWorkaround()&&p.a.getTestEnv()===d.a.None?OneSignal.proxyFrameHost.message(OneSignal.POSTMAM_COMMANDS.REMOTE_DATABASE_PUT,[{table:e,keypath:t}],n=>{n.data===OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE?i():o(`(Database) Attempted remote IndexedDB put(${e}, ${t}),`+"but did not get success response.")}):(yield this.database.put(e,t),i())})),this.emitter.emit(v.EVENTS.SET,t)})}remove(e,t){return p.a.getWindowEnv()!==u.a.ServiceWorker&&m.b.isUsingSubscriptionWorkaround()&&p.a.getTestEnv()===d.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 Object(n.a)(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})}getExternalUserId(){return Object(n.a)(this,void 0,void 0,function*(){return yield this.get("Ids","externalUserId")})}getExternalUserIdAuthHash(){return Object(n.a)(this,void 0,void 0,function*(){return yield this.get("Ids","externalUserIdAuthHash")})}setExternalUserId(e,t){return Object(n.a)(this,void 0,void 0,function*(){const i=b.b.getValueOrDefault(e,""),n=b.b.getValueOrDefault(t,"");""===i?yield this.remove("Ids","externalUserId"):yield this.put("Ids",{type:"externalUserId",id:i}),""===n?yield this.remove("Ids","externalUserIdAuthHash"):yield this.put("Ids",{type:"externalUserIdAuthHash",id:n})})}setAppConfig(e){return Object(n.a)(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})),e.vapidPublicKey&&(yield this.put("Options",{key:"vapidPublicKey",value:e.vapidPublicKey}))})}getAppState(){return Object(n.a)(this,void 0,void 0,function*(){const e=new r;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 Object(n.a)(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(const 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 Object(n.a)(this,void 0,void 0,function*(){const e=new a;return e.workerVersion=yield this.get("Ids","WORKER1_ONE_SIGNAL_SW_VERSION"),e})}setServiceWorkerState(e){return Object(n.a)(this,void 0,void 0,function*(){e.workerVersion&&(yield this.put("Ids",{type:"WORKER1_ONE_SIGNAL_SW_VERSION",id:e.workerVersion}))})}getSubscription(){return Object(n.a)(this,void 0,void 0,function*(){const e=new l.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})}setDeviceId(e){return Object(n.a)(this,void 0,void 0,function*(){yield this.put("Ids",{type:"userId",id:e})})}setSubscription(e){return Object(n.a)(this,void 0,void 0,function*(){e.deviceId&&(yield this.setDeviceId(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 Object(n.a)(this,void 0,void 0,function*(){const e=yield this.get("Ids","emailProfile");return e?g.a.deserialize(e):new g.a})}setEmailProfile(e){return Object(n.a)(this,void 0,void 0,function*(){e&&(yield this.put("Ids",{type:"emailProfile",id:e.serialize()}))})}getSMSProfile(){return Object(n.a)(this,void 0,void 0,function*(){const e=yield this.get("Ids","smsProfile");return e?S.a.deserialize(e):new S.a})}setSMSProfile(e){return Object(n.a)(this,void 0,void 0,function*(){e&&(yield this.put("Ids",{type:"smsProfile",id:e.serialize()}))})}setProvideUserConsent(e){return Object(n.a)(this,void 0,void 0,function*(){yield this.put("Options",{key:"userConsent",value:e})})}getProvideUserConsent(){return Object(n.a)(this,void 0,void 0,function*(){return yield this.get("Options","userConsent")})}getSession(e){return Object(n.a)(this,void 0,void 0,function*(){return yield this.get("Sessions",e)})}setSession(e){return Object(n.a)(this,void 0,void 0,function*(){yield this.put("Sessions",e)})}removeSession(e){return Object(n.a)(this,void 0,void 0,function*(){yield this.remove("Sessions",e)})}getLastNotificationClicked(e){return Object(n.a)(this,void 0,void 0,function*(){let t=[];try{t=yield this.getAll("NotificationClicked")}catch(e){f.a.error("Database.getNotificationClickedByUrl",e)}return t.find(t=>t.appId===e)||null})}getNotificationClickedByUrl(e,t){return Object(n.a)(this,void 0,void 0,function*(){let i=[];try{i=yield this.getAll("NotificationClicked")}catch(e){f.a.error("Database.getNotificationClickedByUrl",e)}return i.find(i=>i.appId===t&&new URL(e).origin===new URL(i.url).origin)||null})}getNotificationClickedById(e){return Object(n.a)(this,void 0,void 0,function*(){return yield this.get("NotificationClicked",e)})}getNotificationReceivedById(e){return Object(n.a)(this,void 0,void 0,function*(){return yield this.get("NotificationReceived",e)})}removeNotificationClickedById(e){return Object(n.a)(this,void 0,void 0,function*(){yield this.remove("NotificationClicked",e)})}removeAllNotificationClicked(){return Object(n.a)(this,void 0,void 0,function*(){yield this.remove("NotificationClicked")})}resetSentUniqueOutcomes(){return Object(n.a)(this,void 0,void 0,function*(){const e=(yield this.getAll("SentUniqueOutcome")).map(e=>(e.sentDuringSession=null,v.put("SentUniqueOutcome",e)));yield Promise.all(e)})}static rebuild(){return Object(n.a)(this,void 0,void 0,function*(){return Promise.all([v.singletonInstance.remove("Ids"),v.singletonInstance.remove("NotificationOpened"),v.singletonInstance.remove("Options"),v.singletonInstance.remove("NotificationReceived"),v.singletonInstance.remove("NotificationClicked"),v.singletonInstance.remove("SentUniqueOutcome")])})}static on(...e){return Object(n.a)(this,void 0,void 0,function*(){return v.singletonInstance.emitter.on.apply(v.singletonInstance.emitter,e)})}static getCurrentSession(){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.getSession(h.a)})}static upsertSession(e){return Object(n.a)(this,void 0,void 0,function*(){yield v.singletonInstance.setSession(e)})}static cleanupCurrentSession(){return Object(n.a)(this,void 0,void 0,function*(){yield v.singletonInstance.removeSession(h.a)})}static setEmailProfile(e){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.setEmailProfile(e)})}static getEmailProfile(){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.getEmailProfile()})}static setSMSProfile(e){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.setSMSProfile(e)})}static getSMSProfile(){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.getSMSProfile()})}static setSubscription(e){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.setSubscription(e)})}static getSubscription(){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.getSubscription()})}static setProvideUserConsent(e){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.setProvideUserConsent(e)})}static getProvideUserConsent(){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.getProvideUserConsent()})}static setServiceWorkerState(e){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.setServiceWorkerState(e)})}static getServiceWorkerState(){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.getServiceWorkerState()})}static setAppState(e){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.setAppState(e)})}static getAppState(){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.getAppState()})}static setAppConfig(e){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.setAppConfig(e)})}static getAppConfig(){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.getAppConfig()})}static getExternalUserId(){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.getExternalUserId()})}static getExternalUserIdAuthHash(){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.getExternalUserIdAuthHash()})}static getLastNotificationClicked(e){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.getLastNotificationClicked(e)})}static removeNotificationClickedById(e){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.removeNotificationClickedById(e)})}static removeAllNotificationClicked(){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.removeAllNotificationClicked()})}static resetSentUniqueOutcomes(){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.resetSentUniqueOutcomes()})}static getNotificationClickedByUrl(e,t){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.getNotificationClickedByUrl(e,t)})}static getNotificationClickedById(e){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.getNotificationClickedById(e)})}static getNotificationReceivedById(e){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.getNotificationReceivedById(e)})}static setExternalUserId(e,t){return Object(n.a)(this,void 0,void 0,function*(){yield v.singletonInstance.setExternalUserId(e,t)})}static setDeviceId(e){return Object(n.a)(this,void 0,void 0,function*(){yield v.singletonInstance.setDeviceId(e)})}static remove(e,t){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.remove(e,t)})}static put(e,t){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.put(e,t)})}static get(e,t){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.get(e,t)})}static getAll(e){return Object(n.a)(this,void 0,void 0,function*(){return yield v.singletonInstance.getAll(e)})}}v.EVENTS=c},function(e,t,i){"use strict";i.d(t,"a",function(){return m});var n=i(0),o=i(14),s=i(21),r=i(6),a=i(11),c=i(15),l=i(10),d=i(8);const u=4e3,g=3001,h=18080,p=["outcomes","on_focus"];class m{static getBuildEnv(){return o.a.Production}static getApiEnv(){return o.a.Production}static getIntegration(e){return Object(n.a)(this,void 0,void 0,function*(){if(l.a.useSafariLegacyPush())return c.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 a.a("usingProxyOrigin",a.b.Empty);e=!!OneSignal.context.appConfig.subdomain}if(t)return i?e?c.a.SecureProxy:c.a.Secure:!d.b.isLocalhostAllowedAsSecureOrigin()||"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname?c.a.InsecureProxy:c.a.Secure;if(i){return(yield m.isFrameContextInsecure())?c.a.InsecureProxy:e?c.a.SecureProxy:c.a.Secure}return c.a.InsecureProxy})}static isFrameContextInsecure(){return Object(n.a)(this,void 0,void 0,function*(){if(window===window.top||!("serviceWorker"in navigator)||void 0===navigator.serviceWorker.getRegistration)return!1;return!(yield OneSignal.context.serviceWorkerManager.getRegistration())})}static isInsecureOrigin(){return"http:"===window.location.protocol}static getOrigin(){return l.a.isBrowser()?window.location.origin:"undefined"!=typeof self&&"undefined"!=typeof ServiceWorkerGlobalScope?self.location.origin:"Unknown"}static getWindowEnv(){return"undefined"==typeof window?"undefined"!=typeof self&&"undefined"!=typeof ServiceWorkerGlobalScope?r.a.ServiceWorker:r.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")&&m.getBuildEnv()===o.a.Development)?r.a.OneSignalSubscriptionPopup:r.a.Host:"/webPushIframe"===location.pathname?r.a.OneSignalProxyFrame:"/webPushModal"===location.pathname?r.a.OneSignalSubscriptionModal:r.a.CustomIframe}static getTestEnv(){return s.a.None}static getBuildEnvPrefix(e=m.getBuildEnv()){switch(e){case o.a.Development:return"Dev-";case o.a.Staging:return"Staging-";case o.a.Production:return"";default:throw new a.a("buildEnv",a.b.EnumOutOfRange)}}static getOneSignalApiUrl(e=m.getApiEnv(),t){switch(e){case o.a.Development:return m.isTurbineEndpoint(t)?new URL(`https://onesignal.com:${h}/api/v1`):new URL(`https://onesignal.com:${g}/api/v1`);case o.a.Staging:case o.a.Production:return new URL("https://onesignal.com/api/v1");default:throw new a.a("buildEnv",a.b.EnumOutOfRange)}}static getOneSignalStaticResourcesUrl(){return new URL("https://media.onesignal.com/web-sdk")}static getOneSignalResourceUrlPath(e=m.getBuildEnv()){let t;const i=u;switch(e){case o.a.Development:t=`http://localhost:${i}`;break;case o.a.Staging:t="https://localhost";break;case o.a.Production:t="https://onesignal.com";break;default:throw new a.a("buildEnv",a.b.EnumOutOfRange)}return new URL(`${t}/sdks`)}static getOneSignalCssFileName(e=m.getBuildEnv()){switch(e){case o.a.Development:return"Dev-OneSignalSDKStyles.css";case o.a.Staging:return"Staging-OneSignalSDKStyles.css";case o.a.Production:return"OneSignalSDKStyles.css";default:throw new a.a("buildEnv",a.b.EnumOutOfRange)}}static isTurbineEndpoint(e){return!!e&&p.some(t=>e.indexOf(t)>-1)}}},function(e,t,i){"use strict";i.d(t,"a",function(){return a});var n=i(0),o=i(12);class s extends o.a{constructor(e="The asynchronous operation has timed out."){super(e),this.message=e,Object.setPrototypeOf(this,s.prototype)}}var r=i(16);class a{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(const 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 isNullOrUndefined(e){return void 0===e||null===e}static valueOrDefault(e,t){return void 0===e||null===e?t:e}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(const 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 s)},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.length0&&a.contains(e.errors[0],"app_id not found")?new r.a(r.b.MissingAppId):e}})}static sortArrayOfObjects(e,t,i=!1,n=!0){const o=n?e:e.slice();return o.sort((e,n)=>{const o=t(e),s=t(n);return o>s?i?-1:1:o1&&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),d=/CrOS/.test(t),u=/silk/i.test(t),g=/sailfish/i.test(t),h=/tizen/i.test(t),p=/(web|hpw)os/i.test(t),m=/windows phone/i.test(t),b=(/SamsungBrowser/i.test(t),!m&&/windows/i.test(t)),f=!r&&!u&&/macintosh/i.test(t),S=!a&&!g&&!h&&!p&&/linux/i.test(t),v=i(/edge\/(\d+(\.\d+)?)/i),O=i(/version\/(\d+(\.\d+)?)/i),y=/tablet/i.test(t)&&!/tablet pc/i.test(t),w=!y&&/[^-]mobi/i.test(t),E=/xbox/i.test(t);/opera/i.test(t)?n={name:"Opera",opera:e,version:O||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)||O}:/SamsungBrowser/i.test(t)?n={name:"Samsung Internet for Android",samsungBrowser:e,version:O||i(/(?:SamsungBrowser)[\s\/](\d+(\.\d+)?)/i)}:/coast/i.test(t)?n={name:"Opera Coast",coast:e,version:O||i(/(?:coast)[\s\/](\d+(\.\d+)?)/i)}:/yabrowser/i.test(t)?n={name:"Yandex Browser",yandexbrowser:e,version:O||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)}:m?(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)}:d?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)||O}: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)):u?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:O||i(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:p?(n={name:"WebOS",webos:e,version:O||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)||O}:/qupzilla/i.test(t)?n={name:"QupZilla",qupzilla:e,version:i(/(?:qupzilla)[\s\/](\d+(?:\.\d+)+)/i)||O}:/chromium/i.test(t)?n={name:"Chromium",chromium:e,version:i(/(?:chromium)[\s\/](\d+(?:\.\d+)?)/i)||O}:/chrome|crios|crmo/i.test(t)?n={name:"Chrome",chrome:e,version:i(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:a?n={name:"Android",version:O}:/safari|applewebkit/i.test(t)?(n={name:"Safari",safari:e},O&&(n.version=O)):r?(n={name:"iphone"==r?"iPhone":"ipad"==r?"iPad":"iPod"},O&&(n.version=O)):n=/googlebot/i.test(t)?{name:"Googlebot",googlebot:e,version:i(/googlebot\/(\d+(\.\d+))/i)||O}:{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&&O&&(n.version=O)):!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?f?n.mac=e:E?n.xbox=e:b?n.windows=e:S&&(n.linux=e):(n[r]=e,n.ios=e):n.android=e;var I="";n.windows?I=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?I=i(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):n.mac?I=(I=i(/Mac OS X (\d+([_\.\s]\d+)*)/i)).replace(/[_\s]/g,"."):r?I=(I=i(/os (\d+([_\s]\d+)*) like mac os x/i)).replace(/[_\s]/g,"."):a?I=i(/android[ \/-](\d+(\.\d+)*)/i):n.webos?I=i(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):n.blackberry?I=i(/rim\stablet\sos\s(\d+(\.\d+)*)/i):n.bada?I=i(/bada\/(\d+(\.\d+)*)/i):n.tizen&&(I=i(/tizen[\/\s](\d+(\.\d+)*)/i)),I&&(n.osversion=I);var P=!n.windows&&I.split(".")[0];return y||l||"ipad"==r||a&&(3==P||P>=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{let i=void 0;try{i=indexedDB.open(e,a)}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 Object(n.a)(this,void 0,void 0,function*(){return this.openLock||(this.openLock=this.open(this.databaseName)),yield this.openLock})}onDatabaseOpenError(e){e.preventDefault();const t=e.target.error;r.b.contains(t.message,"The operation failed for reasons unrelated to the database itself and not covered by any other error code")||r.b.contains(t.message,"A mutation operation was attempted on a database that did not allow mutations")?s.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"):s.a.warn("OneSignal: Fatal error opening IndexedDb database:",t)}onDatabaseError(e){s.a.debug("IndexedDb: Generic database error",e.target.errorCode)}onDatabaseOpenBlocked(){s.a.debug("IndexedDb: Blocked event")}onDatabaseVersionChange(e){s.a.debug("IndexedDb: versionchange event")}onDatabaseUpgradeNeeded(e){s.a.debug("IndexedDb: Database is being rebuilt or upgraded (upgradeneeded event).");const t=e.target.result;e.oldVersion<1&&(t.createObjectStore("Ids",{keyPath:"type"}),t.createObjectStore("NotificationOpened",{keyPath:"url"}),t.createObjectStore("Options",{keyPath:"key"})),e.oldVersion<2&&(t.createObjectStore("Sessions",{keyPath:"sessionKey"}),t.createObjectStore("NotificationReceived",{keyPath:"notificationId"}),t.createObjectStore("NotificationClicked",{keyPath:"notificationId"})),e.oldVersion<3&&t.createObjectStore("SentUniqueOutcome",{keyPath:"outcomeName"}),"undefined"!=typeof OneSignal&&(OneSignal._isNewVisitor=!0)}get(e,t){return Object(n.a)(this,void 0,void 0,function*(){const i=yield this.ensureDatabaseOpen();return t?yield new Promise((n,o)=>{const s=i.transaction(e).objectStore(e).get(t);s.onsuccess=(()=>{n(s.result)}),s.onerror=(()=>{o(s.error)})}):yield new Promise((t,n)=>{const o={},s=i.transaction(e).objectStore(e).openCursor();s.onsuccess=(e=>{const i=e.target.result;if(i){const e=i.key;o[e]=i.value,i.continue()}else t(o)}),s.onerror=(()=>{n(s.error)})})})}getAll(e){return Object(n.a)(this,void 0,void 0,function*(){return yield new Promise((t,i)=>Object(n.a)(this,void 0,void 0,function*(){const n=(yield this.ensureDatabaseOpen()).transaction(e).objectStore(e).openCursor(),o=[];n.onsuccess=(e=>{const i=e.target.result;i?(o.push(i.value),i.continue()):t(o)}),n.onerror=(()=>{i(n.error)})}))})}put(e,t){return Object(n.a)(this,void 0,void 0,function*(){return yield this.ensureDatabaseOpen(),yield new Promise((i,n)=>{try{const o=this.database.transaction([e],"readwrite").objectStore(e).put(t);o.onsuccess=(()=>{i(t)}),o.onerror=(e=>{s.a.error("Database PUT Transaction Error:",e),n(e)})}catch(e){s.a.error("Database PUT Error:",e),n(e)}})})}remove(e,t){return Object(n.a)(this,void 0,void 0,function*(){const i=yield this.ensureDatabaseOpen();return new Promise((n,o)=>{try{const r=i.transaction([e],"readwrite").objectStore(e),a=t?r.delete(t):r.clear();a.onsuccess=(()=>{n(t)}),a.onerror=(e=>{s.a.error("Database REMOVE Transaction Error:",e),o(e)})}catch(e){s.a.error("Database REMOVE Error:",e),o(e)}})})}}},function(e,t,i){"use strict";i.d(t,"a",function(){return n});class n{serialize(){return{deviceId:this.deviceId,subscriptionToken:this.subscriptionToken,optedOut:this.optedOut,createdAt:this.createdAt,expirationTime:this.expirationTime}}static deserialize(e){const t=new n;return t.deviceId=e.deviceId,t.subscriptionToken=e.subscriptionToken,t.optedOut=e.optedOut,t.createdAt=e.createdAt,t.expirationTime=e.expirationTime,t}}},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",d=null!=t.timeout?t.timeout:6e4,u=encodeURIComponent,g=document.getElementsByTagName("script")[0]||document.head;d&&(r=setTimeout(function(){h(),o&&o(new Error("Timeout"))},d));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+"="+u(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){e.exports=function(){throw new Error("define cannot be used indirect")}},function(e,t){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(e){"object"==typeof window&&(i=window)}e.exports=i},function(e,t,i){"use strict";i.r(t),i.d(t,"default",function(){return Mi});var n,o,s,r,a=i(0),c=i(9),l=i.n(c),d=i(10),InvalidArgumentError=i(11),u=i(12);!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){e[e.MissingAppId=0]="MissingAppId",e[e.RedundantPermissionMessage=1]="RedundantPermissionMessage",e[e.PushPermissionAlreadyGranted=2]="PushPermissionAlreadyGranted",e[e.UnsupportedEnvironment=3]="UnsupportedEnvironment",e[e.MissingDomElement=4]="MissingDomElement",e[e.ServiceWorkerNotActivated=5]="ServiceWorkerNotActivated",e[e.NoProxyFrame=6]="NoProxyFrame"}(o||(o={}));class g extends u.a{constructor(e,t){let i;switch(e){case o.MissingAppId:i="Missing required app ID.";break;case o.RedundantPermissionMessage:let s="";t&&t.permissionPromptType&&(s=`(${n[t.permissionPromptType]})`),i=`Another permission message ${s} is being displayed.`;break;case o.PushPermissionAlreadyGranted:i="Push permission has already been granted.";break;case o.UnsupportedEnvironment:i="The current environment does not support this operation.";break;case o.ServiceWorkerNotActivated:i="The service worker must be activated first.";break;case o.NoProxyFrame:i="No proxy frame."}super(i),this.description=o[e],this.reason=e,Object.setPrototypeOf(this,g.prototype)}}!function(e){e[e.Unknown=0]="Unknown",e[e.NoDeviceId=1]="NoDeviceId",e[e.NoEmailSet=2]="NoEmailSet",e[e.NoSMSSet=3]="NoSMSSet",e[e.OptedOut=4]="OptedOut"}(s||(s={}));class h extends u.a{constructor(e){let t;switch(e){case s.Unknown||s.NoDeviceId:t="This operation can only be performed after the user is subscribed.";break;case s.NoEmailSet:t="No email is currently set.";break;case s.NoSMSSet:t="No sms is currently set.";break;case s.OptedOut:t="The user has manually opted out of receiving of notifications. This operation can only be performed after the user is fully resubscribed."}super(t),this.reason=s[e],Object.setPrototypeOf(this,h.prototype)}}!function(e){e[e.InvalidAppId=0]="InvalidAppId",e[e.AppNotConfiguredForWebPush=1]="AppNotConfiguredForWebPush",e[e.MissingSubdomain=2]="MissingSubdomain",e[e.WrongSiteUrl=3]="WrongSiteUrl",e[e.MultipleInitialization=4]="MultipleInitialization",e[e.MissingSafariWebId=5]="MissingSafariWebId",e[e.Unknown=6]="Unknown"}(r||(r={}));class p extends u.a{constructor(e,t){let i;switch(e){case r.InvalidAppId:i="OneSignal: This app ID does not match any existing app. Double check your app ID.";break;case r.AppNotConfiguredForWebPush:i="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://tinyurl.com/2x5jzk83).";break;case r.MissingSubdomain:i="Non-HTTPS pages require the subdomainName parameter within the label set within the OneSignal Web configuration (https://tinyurl.com/ry39x7mk).";break;case r.WrongSiteUrl:i=t&&t.siteUrl?`OneSignal: This web push config can only be used on ${new URL(t.siteUrl).origin}.`+` Your current origin is ${location.origin}.`:"OneSignal: This web push config can not be used on the current site.";break;case r.MultipleInitialization:i="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 r.MissingSafariWebId:i="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 r.Unknown:i="OneSignal: An unknown initialization error occurred."}super(i),this.reason=r[e],Object.setPrototypeOf(this,p.prototype)}}var m=i(7);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){const t=b.get(e);return null===t[0]&&null===t[1]}}b.store={},b.LIMIT=2;var f,S,v=i(3),O=i(1),y=i(8),w=i(22);!function(e){e.Native="native",e.Push="push",e.Category="category",e.Sms="sms",e.Email="email",e.SmsAndEmail="smsAndEmail"}(f||(f={}));class E{static isCategorySlidedownConfigured(e){if(!e)return!1;const t=E.getFirstSlidedownPromptOptionsWithType(e,f.Category);return!!t&&(!!t.categories&&t.categories.length>0)}static isCategorySlidedownConfiguredVersion1(e){var t,i;return((null===(i=null===(t=null===e||void 0===e?void 0:e.categories)||void 0===t?void 0:t.tags)||void 0===i?void 0:i.length)||0)>0}static getFirstSlidedownPromptOptionsWithType(e,t){return e?e.filter(e=>e.type===t)[0]:void 0}static isSlidedownAutoPromptConfigured(e){if(!e)return!1;for(let t=0;t{OneSignal.proxyFrameHost.message(OneSignal.POSTMAM_COMMANDS.REMOTE_NOTIFICATION_PERMISSION,{safariWebId:e},e=>{const i=e.data;t(i)})})})}isPermissionEnvironmentAmbiguous(e){return Object(a.a)(this,void 0,void 0,function*(){const t=y.b.redetectBrowserUserAgent();return!t.safari&&!t.firefox&&e===S.Denied&&(this.isCurrentFrameContextCrossOrigin()||(yield I.a.isFrameContextInsecure())||y.b.isUsingSubscriptionWorkaround())})}isCurrentFrameContextCrossOrigin(){let e;try{e=window.top.location.origin}catch(e){return!0}return window.top!==window&&e!==window.location.origin}getInterpretedAmbiguousPermission(e){return Object(a.a)(this,void 0,void 0,function*(){switch(e){case S.Denied:const t=this.getStoredPermission();return t||S.Default;default:return e}})}getStoredPermission(){return A.getStoredPermission()}setStoredPermission(e){A.setStoredPermission(e)}updateStoredPermission(){return Object(a.a)(this,void 0,void 0,function*(){const e=yield this.getNotificationPermission();return this.setStoredPermission(e)})}}const C="isOptedOut",T="isPushNotificationsEnabled",M="os_pageViews";class A{static getIsOptedOut(){return"true"===localStorage.getItem(C)}static getIsPushNotificationsEnabled(){return"true"===localStorage.getItem(T)}static setIsOptedOut(e){localStorage.setItem(C,e.toString())}static setIsPushNotificationsEnabled(e){localStorage.setItem(T,e.toString())}static setStoredPermission(e){localStorage.setItem(P.STORED_PERMISSION_KEY,e)}static getStoredPermission(){switch(localStorage.getItem(P.STORED_PERMISSION_KEY)||"default"){case"granted":return S.Granted;case"denied":return S.Denied;default:return S.Default}}static setLocalPageViewCount(e){localStorage.setItem(M,e.toString())}static getLocalPageViewCount(){return Number(localStorage.getItem(M))}}const N={allowButton:"onesignal-slidedown-allow-button",body:"slidedown-body",buttonIndicatorHolder:"onesignal-button-indicator-holder",cancelButton:"onesignal-slidedown-cancel-button",container:"onesignal-slidedown-container",dialog:"onesignal-slidedown-dialog",footer:"slidedown-footer",reset:"onesignal-reset",savingStateButton:"onesignal-saving-state-button",slideUp:"slide-up",slideDown:"slide-down",closeSlidedown:"close-slidedown",icon:"slidedown-body-icon",message:"slidedown-body-message",defaultIcon:"default-icon",loadingContainer:"onesignal-loading-container",clearfix:"clearfix"},x={toastText:"onesignal-toast-text"},k={toastText:"onesignal-toast-text"},j={allowButton:"onesignal-slidedown-allow-button",body:"slidedown-body",buttonIndicatorHolder:"onesignal-button-indicator-holder",cancelButton:"onesignal-slidedown-cancel-button",container:"onesignal-slidedown-container",dialog:"onesignal-slidedown-dialog",footer:"slidedown-footer",normalSlidedown:"normal-slidedown",loadingContainer:"onesignal-loading-container"},_={alignRight:"align-right",primary:"primary",secondary:"secondary",slidedownButton:"slidedown-button"},D={categoryLabelInput:"onesignal-category-label-input",categoryLabelText:"onesignal-category-label-text",categoryLabel:"onesignal-category-label",checkmark:"onesignal-checkmark",taggingContainer:"tagging-container",taggingContainerCol:"tagging-container-col",loadingMessage:"onesignal-loading-message"},R={taggingContainer:"tagging-container"},U="data:image/svg+xml,%3Csvg fill='none' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg clip-path='url(%23clip0)'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M33.232 28.434a2.5 2.5 0 001.768.733 1.667 1.667 0 010 3.333H5a1.667 1.667 0 110-3.333 2.5 2.5 0 002.5-2.5v-8.104A13.262 13.262 0 0118.333 5.122V1.667a1.666 1.666 0 113.334 0v3.455A13.262 13.262 0 0132.5 18.563v8.104a2.5 2.5 0 00.732 1.767zM16.273 35h7.454a.413.413 0 01.413.37 4.167 4.167 0 11-8.28 0 .417.417 0 01.413-.37z' fill='%23BDC4CB'/%3E%3C/g%3E%3Cdefs%3E%3CclipPath id='clip0'%3E%3Cpath fill='%23fff' d='M0 0h40v40H0z'/%3E%3C/clipPath%3E%3C/defs%3E%3C/svg%3E",W="data:image/svg+xml;charset=UTF-8,%3csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M7.98775 -0.00114406C5.85015 0.0338508 3.81219 0.908665 2.31442 2.43419C1.565 3.18031 0.973715 4.06987 0.575897 5.04969C0.17808 6.02952 -0.0180997 7.07949 -0.000914196 8.13686C-0.00214385 9.17005 0.200528 10.1933 0.595487 11.148C0.990446 12.1028 1.56993 12.9702 2.30072 13.7005C3.03151 14.4309 3.89925 15.0098 4.85421 15.4042C5.80916 15.7986 6.83256 16.0007 7.86575 15.9989H8.00842C10.1467 15.9769 12.1889 15.1075 13.6869 13.5816C15.185 12.0557 16.0165 9.99781 15.9991 7.85952C16.0015 6.8138 15.7949 5.77814 15.3913 4.81345C14.9876 3.84876 14.3952 2.97451 13.6488 2.24213C12.9023 1.50974 12.017 0.933994 11.0448 0.548751C10.0726 0.163508 9.03324 -0.0234551 7.98775 -0.00114406ZM6.99909 11.0269C6.99428 10.8961 7.01558 10.7658 7.06175 10.6434C7.10792 10.521 7.17803 10.4091 7.26797 10.3141C7.35792 10.2191 7.4659 10.143 7.58559 10.0903C7.70529 10.0375 7.8343 10.0092 7.96509 10.0069H7.98309C8.24616 10.0074 8.49882 10.1097 8.6881 10.2924C8.87739 10.4751 8.9886 10.724 8.99842 10.9869C9.00331 11.1176 8.98207 11.248 8.93594 11.3704C8.8898 11.4928 8.8197 11.6048 8.72974 11.6998C8.63978 11.7948 8.53176 11.8709 8.41202 11.9236C8.29229 11.9763 8.16323 12.0046 8.03242 12.0069H8.01442C7.75145 12.006 7.49897 11.9036 7.30976 11.721C7.12054 11.5383 7.00923 11.2896 6.99909 11.0269ZM7.33242 8.33219V4.33219C7.33242 4.15538 7.40266 3.98581 7.52768 3.86079C7.65271 3.73576 7.82227 3.66552 7.99909 3.66552C8.1759 3.66552 8.34547 3.73576 8.47049 3.86079C8.59551 3.98581 8.66575 4.15538 8.66575 4.33219V8.33219C8.66575 8.509 8.59551 8.67857 8.47049 8.80359C8.34547 8.92862 8.1759 8.99886 7.99909 8.99886C7.82227 8.99886 7.65271 8.92862 7.52768 8.80359C7.40266 8.67857 7.33242 8.509 7.33242 8.33219Z' fill='%23E54B4D'/%3e%3c/svg%3e",B={greyLoadingIndicator:"#95A1AC",whiteLoadingIndicator:"#FFFFFF"},L={fetchingPreferences:"Fetching your preferences"},V={channelCaptureContainer:"channel-capture-container",inputWithValidationElement:"input-with-validation-element",onesignalErrorInput:"onesignal-error-input",onesignalSmsInput:"iti-onesignal-sms-input",onesignalEmailInput:"onesignal-email-input",onesignalValidationElementHidden:"onesignal-validation-element-hidden",onesignalValidationElement:"onesignal-validation-element"},F={channelCaptureContainer:"channel-capture-container",smsInputWithValidationElement:"sms-input-with-validation-element",emailInputWithValidationElement:"email-input-with-validation-element",onesignalSmsInput:"iti-onesignal-sms-input",onesignalEmailInput:"onesignal-email-input",onesignalSmsValidationElement:"onesignal-sms-validation-element",onesignalEmailValidationElement:"onesignal-email-validation-element"},H={containerClass:"onesignal-customlink-container",subscribeClass:"onesignal-customlink-subscribe",explanationClass:"onesignal-customlink-explanation",resetClass:"onesignal-reset",hide:"hide",state:{subscribed:"state-subscribed",unsubscribed:"state-unsubscribed"}},$={containerSelector:`.${H.containerClass}`,subscribeSelector:`.${H.subscribeClass}`,explanationSelector:`.${H.explanationClass}`};var G=i(2);class z{constructor(e){this.config=e}initialize(){return Object(a.a)(this,void 0,void 0,function*(){var e,t;if((null===(e=this.config)||void 0===e?void 0:e.enabled)&&(yield this.loadSdkStyles()))if(O.a.info("OneSignal: initializing customlink"),(null===(t=this.config)||void 0===t?void 0:t.unsubscribeEnabled)||!z.isPushEnabled())for(let e=0;eObject(a.a)(this,void 0,void 0,function*(){O.a.info("CustomLink: subscribe clicked"),yield this.handleClick(t)})),e.appendChild(t)}}else O.a.error("CustomLink: required property 'text' is missing in the config")})}loadSdkStyles(){return Object(a.a)(this,void 0,void 0,function*(){return 0===(yield OneSignal.context.dynamicResourceLoader.loadSdkStylesheet())||(O.a.debug("Not initializing custom link button because styles failed to load."),!1)})}hideElement(e){Object(G.a)(e,H.hide)}hideCustomLinkContainers(){this.customlinkContainerElements.forEach(e=>{this.hideElement(e)})}handleClick(e){return Object(a.a)(this,void 0,void 0,function*(){var t,i;if(z.isPushEnabled())yield OneSignal.setSubscription(!1),yield this.setTextFromPushStatus(e);else{if(!z.isOptedOut()){const e={autoAccept:!OneSignal.environmentInfo.requiresUserInteraction};return yield OneSignal.registerForPushNotifications(e),void(!(null===(t=this.config)||void 0===t?void 0:t.unsubscribeEnabled)&&z.isPushEnabled()&&this.hideCustomLinkContainers())}yield OneSignal.setSubscription(!0),!(null===(i=this.config)||void 0===i?void 0:i.unsubscribeEnabled)&&z.isPushEnabled()&&this.hideCustomLinkContainers()}})}setTextFromPushStatus(e){return Object(a.a)(this,void 0,void 0,function*(){var t,i,n,o;(null===(i=null===(t=this.config)||void 0===t?void 0:t.text)||void 0===i?void 0:i.subscribe)&&(z.isPushEnabled()||(e.textContent=this.config.text.subscribe)),(null===(o=null===(n=this.config)||void 0===n?void 0:n.text)||void 0===o?void 0:o.unsubscribe)&&z.isPushEnabled()&&(e.textContent=this.config.text.unsubscribe)})}setCustomColors(e){var t,i,n,o,s,r,a;(null===(t=this.config)||void 0===t?void 0:t.color)&&this.config.color.text&&("button"===(null===(i=this.config)||void 0===i?void 0:i.style)&&(null===(n=this.config)||void 0===n?void 0:n.color.button)?(e.style.backgroundColor=null===(o=this.config)||void 0===o?void 0:o.color.button,e.style.color=null===(s=this.config)||void 0===s?void 0:s.color.text):"link"===(null===(r=this.config)||void 0===r?void 0:r.style)&&(e.style.color=null===(a=this.config)||void 0===a?void 0:a.color.text))}get customlinkContainerElements(){const e=document.querySelectorAll($.containerSelector);return Array.prototype.slice.call(e)}static isPushEnabled(){return A.getIsPushNotificationsEnabled()}static isOptedOut(){return A.getIsOptedOut()}}class q{static onNotificationPermissionChange(){q.checkAndTriggerSubscriptionChanged()}static onInternalSubscriptionSet(e){return Object(a.a)(this,void 0,void 0,function*(){b.put("subscription.optedOut",e)})}static checkAndTriggerSubscriptionChanged(){return Object(a.a)(this,void 0,void 0,function*(){y.a.logMethodCall("checkAndTriggerSubscriptionChanged");const e=yield OneSignal.context.subscriptionManager.getSubscriptionState(),t=yield OneSignal.privateIsPushNotificationsEnabled(),i=yield v.a.getAppState(),{lastKnownPushEnabled:n}=i;(null===n||t!==n)&&(O.a.info("The user's subscription state changed from "+`${null===n?"(not stored)":n} ⟶ ${e.subscribed}`),A.setIsPushNotificationsEnabled(t),i.lastKnownPushEnabled=t,yield v.a.setAppState(i),q.triggerSubscriptionChanged(t))})}static _onSubscriptionChanged(e){return Object(a.a)(this,void 0,void 0,function*(){q.onSubscriptionChanged_showWelcomeNotification(e),q.onSubscriptionChanged_sendCategorySlidedownTags(e),q.onSubscriptionChanged_evaluateNotifyButtonDisplayPredicate(),q.onSubscriptionChanged_updateCustomLink()})}static onSubscriptionChanged_sendCategorySlidedownTags(e){return Object(a.a)(this,void 0,void 0,function*(){var t,i;if(!0!==e)return;const n=null===(i=null===(t=OneSignal.context.appConfig.userConfig.promptOptions)||void 0===t?void 0:t.slidedown)||void 0===i?void 0:i.prompts;E.isCategorySlidedownConfigured(n)&&(yield OneSignal.context.tagManager.sendTags(!1))})}static onSubscriptionChanged_showWelcomeNotification(e){return Object(a.a)(this,void 0,void 0,function*(){if(OneSignal.__doNotShowWelcomeNotification)return void O.a.debug("Not showing welcome notification because user has previously subscribed.");const t=OneSignal.config.userConfig.welcomeNotification;if(void 0!==t&&!0===t.disable)return;if(!0!==e)return;if(q.sendingOrSentWelcomeNotification)return;q.sendingOrSentWelcomeNotification=!0;let i=void 0!==t&&void 0!==t.title&&null!==t.title?t.title:"",n=void 0!==t&&void 0!==t.message&&null!==t.message&&t.message.length>0?t.message:"Thanks for subscribing!";const o=new URL(location.href).origin+"?_osp=do_not_open",s=t&&t.url&&t.url.length>0?t.url:o;i=w.a.decodeHtmlEntities(i),n=w.a.decodeHtmlEntities(n),O.a.debug("Sending welcome notification."),OneSignal.sendSelfNotification(i,n,s,void 0,{__isOneSignalWelcomeNotification:!0},void 0),m.a.trigger(OneSignal.EVENTS.WELCOME_NOTIFICATION_SENT,{title:i,message:n,url:s})})}static onSubscriptionChanged_evaluateNotifyButtonDisplayPredicate(){return Object(a.a)(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())?(O.a.debug("Showing notify button because display predicate returned true."),OneSignal.notifyButton.launcher.show()):(O.a.debug("Hiding notify button because display predicate returned false."),OneSignal.notifyButton.launcher.hide())}})}static onSubscriptionChanged_updateCustomLink(){return Object(a.a)(this,void 0,void 0,function*(){OneSignal.config.userConfig.promptOptions&&new z(OneSignal.config.userConfig.promptOptions.customlink).initialize()})}static triggerSubscriptionChanged(e){m.a.trigger(OneSignal.EVENTS.SUBSCRIPTION_CHANGED,e)}static fireStoredNotificationClicks(e=document.URL){return Object(a.a)(this,void 0,void 0,function*(){function t(e){return Object(a.a)(this,void 0,void 0,function*(){const t=yield v.a.getAppState();t.clickedNotifications[e.url]=null,yield v.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 v.a.getAppState();if("origin"===(yield v.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))}}})}}q.sendingOrSentWelcomeNotification=!1;var K,Y,J=i(6);class Q{static promiseStub(){return{then:Q.promiseStub,catch:Q.promiseStub}}static ensureBackwardsCompatibility(e){Q.environmentPolyfill(e),Q.postmams(e),e.syncHashedEmail=Q.promiseStub}static environmentPolyfill(e){e.environment={},e.environment.getEnv=function(){return""},e.environment.isPopup=function(){return I.a.getWindowEnv()===J.a.OneSignalSubscriptionPopup},e.environment.isIframe=function(){return I.a.getWindowEnv()===J.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[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"}(K||(K={}));class Z extends u.a{constructor(){super("This code is not implemented yet."),Object.setPrototypeOf(this,Z.prototype)}}!function(e){e[e.ChromeLike=5]="ChromeLike",e[e.SafariLegacy=7]="SafariLegacy",e[e.Firefox=8]="Firefox",e[e.Email=11]="Email",e[e.Edge=12]="Edge",e[e.SMS=14]="SMS",e[e.SafariVapid=17]="SafariVapid"}(Y||(Y={}));class X{constructor(){this.language=d.a.getLanguage(),this.timezone=-60*(new Date).getTimezoneOffset(),this.timezoneId=Intl.DateTimeFormat().resolvedOptions().timeZone;const e=parseInt(String(l.a.version),10);this.browserVersion=isNaN(e)?-1:e,this.deviceModel=navigator.platform,this.sdkVersion=d.a.version().toString(),this.deliveryPlatform=this.getDeliveryPlatform()}getDeliveryPlatform(){const e=y.a.redetectBrowserUserAgent();return d.a.useSafariLegacyPush()?Y.SafariLegacy:d.a.useSafariVapidPush()?Y.SafariVapid:e.firefox?Y.Firefox:e.msedge?Y.Edge:Y.ChromeLike}serialize(){const e={device_type:this.deliveryPlatform,language:this.language,timezone:this.timezone,timezone_id:this.timezoneId,device_os:this.browserVersion,device_model:this.deviceModel,sdk:this.sdkVersion,notification_types:this.subscriptionState};return this.appId&&(e.app_id=this.appId),this.externalUserId&&(e.external_user_id=this.externalUserId),this.externalUserIdAuthHash&&(e.external_user_id_auth_hash=this.externalUserIdAuthHash),e}deserialize(e){throw new Z}}class ee extends X{constructor(e){super(),this.subscription=e}serialize(){const e=super.serialize();return this.subscription&&(e.identifier=d.a.useSafariLegacyPush()?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 ee(t);return n.appId=e,n.subscriptionState=t?K.Subscribed:K.NotSubscribed,i&&(n.subscriptionState=i),n}deserialize(e){throw new Z}}var te,ie=i(17),ne=i(5);!function(e){e[e.Blocked=0]="Blocked",e[e.Dismissed=1]="Dismissed",e[e.Default=2]="Default"}(te||(te={}));class oe extends u.a{constructor(e){let t;switch(e){case te.Dismissed:t="The user dismissed the permission prompt.";break;case te.Blocked:t="Notification permissions are blocked.";break;case te.Default:t="Notification permissions have not been granted yet."}super(t),this.reason=e,Object.setPrototypeOf(this,oe.prototype)}}class se{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 se;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){const e=btoa(String.fromCharCode.apply(null,new Uint8Array(i)));t.w3cP256dh=e}if(n){const 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 se;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=se.deserialize(e.existingW3cPushSubscription):e.existingPushSubscription&&(t.existingW3cPushSubscription=se.deserialize(e.existingPushSubscription)),t.safariDeviceToken=e.safariDeviceToken,t.existingSafariDeviceToken=e.existingSafariDeviceToken,t}}var re,ae=i(13);!function(e){e.Safari="safari",e.Firefox="firefox",e.Chrome="chrome",e.Opera="opera",e.Edge="edge",e.Other="other"}(re||(re={}));class ce{static registerForPush(){return Object(a.a)(this,void 0,void 0,function*(){const e=A.getIsPushNotificationsEnabled();return yield ce.internalRegisterForPush(e)})}static internalRegisterForPush(e){return Object(a.a)(this,void 0,void 0,function*(){const t=OneSignal.context;let i=null;if(e&&!t.pageViewManager.isFirstPageView()){O.a.debug("Not registering for push because the user is subscribed and this is not the first page view."),O.a.debug("But we want to rekindle their session.");const e=yield le.getDeviceId();if(e){const t=yield le.createDeviceRecord(OneSignal.config.appId,!0);yield OneSignal.context.sessionManager.upsertSession(e,t,ae.b.PageRefresh)}else O.a.error("Should have been impossible to have push as enabled but no device id.");return null}if("undefined"!=typeof OneSignal){if(OneSignal._isRegisteringForPush)return null;OneSignal._isRegisteringForPush=!0}switch(I.a.getWindowEnv()){case J.a.Host:case J.a.OneSignalSubscriptionModal:try{const e=yield t.subscriptionManager.subscribe(0);i=yield t.subscriptionManager.registerSubscription(e),t.pageViewManager.incrementPageViewCount(),yield ie.a.triggerNotificationPermissionChanged(),yield q.checkAndTriggerSubscriptionChanged()}catch(e){O.a.info(e)}break;case J.a.OneSignalSubscriptionPopup:const e=opener||parent;let n;yield t.permissionManager.updateStoredPermission();try{n=yield t.subscriptionManager.subscribe(1),yield t.permissionManager.updateStoredPermission()}catch(i){if(yield t.permissionManager.updateStoredPermission(),i instanceof oe)switch(i.reason){case te.Blocked:yield t.permissionManager.updateStoredPermission(),OneSignal.subscriptionPopup.message(OneSignal.POSTMAM_COMMANDS.REMOTE_NOTIFICATION_PERMISSION_CHANGED,{permission:S.Denied,forceUpdatePermission:!1});break;case te.Dismissed:OneSignal.subscriptionPopup.message(OneSignal.POSTMAM_COMMANDS.REMOTE_NOTIFICATION_PERMISSION_CHANGED,{permission:S.Default,forceUpdatePermission:!0})}if(e)return window.close(),null}OneSignal.subscriptionPopup.message(OneSignal.POSTMAM_COMMANDS.FINISH_REMOTE_REGISTRATION,{rawPushSubscription:n.serialize()},t=>{!0===t.data.progress?(O.a.debug("Got message from host page that remote reg. is in progress, closing popup."),e&&window.close()):O.a.debug("Got message from host page that remote reg. could not be finished.")});break;default:throw"undefined"!=typeof OneSignal&&(OneSignal._isRegisteringForPush=!1),new g(o.UnsupportedEnvironment)}return"undefined"!=typeof OneSignal&&(OneSignal._isRegisteringForPush=!1),i})}static getRawPushSubscriptionForSafari(e){const t=new se,{deviceToken:i}=window.safari.pushNotification.permission(e);return t.existingSafariDeviceToken=i,t}static getRawPushSubscriptionFromServiceWorkerRegistration(e){return Object(a.a)(this,void 0,void 0,function*(){if(!e)return null;const t=yield e.pushManager.getSubscription();return t?se.setFromW3cSubscription(t):null})}static getRawPushSubscriptionWhenUsingSubscriptionWorkaround(){return Object(a.a)(this,void 0,void 0,function*(){return null})}static getRawPushSubscription(e,t){return Object(a.a)(this,void 0,void 0,function*(){if(e.browserType===re.Safari)return ce.getRawPushSubscriptionForSafari(t);if(e.isUsingSubscriptionWorkaround)return ce.getRawPushSubscriptionWhenUsingSubscriptionWorkaround();if(e.isBrowserAndSupportsServiceWorkers){const e=yield OneSignal.context.serviceWorkerManager.getRegistration();return yield ce.getRawPushSubscriptionFromServiceWorkerRegistration(e)}return null})}}class le{static getCurrentNotificationType(){return Object(a.a)(this,void 0,void 0,function*(){const e=yield OneSignal.context.permissionManager.getNotificationPermission(OneSignal.context.appConfig.safariWebId);if(e===S.Default)return K.Default;if(e===S.Denied)return y.a.isUsingSubscriptionWorkaround()?K.Default:K.NotSubscribed;const t=yield OneSignal.context.subscriptionManager.isAlreadyRegisteredWithOneSignal();if(e===S.Granted&&t){return(yield OneSignal.privateIsPushNotificationsEnabled())?K.Subscribed:K.MutedByApi}return K.Default})}static getNotificationTypeFromOptIn(e){return 1==e||null==e?K.Subscribed:K.MutedByApi}static markHttpSlidedownShown(){sessionStorage.setItem("ONESIGNAL_HTTP_PROMPT_SHOWN","true")}static isHttpPromptAlreadyShown(){return"true"==sessionStorage.getItem("ONESIGNAL_HTTP_PROMPT_SHOWN")}static checkAndTriggerNotificationPermissionChanged(){return Object(a.a)(this,void 0,void 0,function*(){const e=yield v.a.get("Options","notificationPermission"),t=yield OneSignal.getNotificationPermission();e!==t&&(yield ie.a.triggerNotificationPermissionChanged(),yield v.a.put("Options",{key:"notificationPermission",value:t}))})}static getNotificationIcons(){return Object(a.a)(this,void 0,void 0,function*(){const e=yield le.getAppId();if(!e)throw new g(o.MissingAppId);const t=`${I.a.getOneSignalApiUrl().toString()}/apps/${e}/icon`,i=yield(yield fetch(t)).json();if(i.errors)throw O.a.error(`API call %c${t}`,ne.a.getConsoleStyle("code"),"failed with:",i.errors),new Error("Failed to get notification icons.");return i})}static getSlidedownOptions(e){return ne.a.getValueOrDefault(e.slidedown,{prompts:[]})}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,acceptButton:e.fullscreen.acceptButton,cancelButton:e.fullscreen.cancelButton}:e:null}static getPromptOptionsQueryString(){let e="";if(le.getFullscreenPermissionMessageOptions(OneSignal.config.userConfig.promptOptions)){const t=le.getPromptOptionsPostHash();for(const i of Object.keys(t)){e+="&"+i+"="+t[i]}}return e}static getPromptOptionsPostHash(){const e=le.getFullscreenPermissionMessageOptions(OneSignal.config.userConfig.promptOptions);if(e){var t={exampleNotificationTitleDesktop:"exampleNotificationTitle",exampleNotificationMessageDesktop:"exampleNotificationMessage",exampleNotificationTitleMobile:"exampleNotificationTitle",exampleNotificationMessageMobile:"exampleNotificationMessage"};for(const i of Object.keys(t)){const n=t[i];e[i]&&(e[n]=e[i])}for(var i=["autoAcceptTitle","siteName","autoAcceptTitle","subscribeText","showGraphic","actionMessage","exampleNotificationTitle","exampleNotificationMessage","exampleNotificationCaption","acceptButton","cancelButton","timeout"],n={},o=0;o=0;e--){i[e]===t&&i.splice(e,1)}}}class be{constructor(e,t=new me){this.context=e,this.replies=t}broadcast(e,t){return Object(a.a)(this,void 0,void 0,function*(){if(I.a.getWindowEnv()!==J.a.ServiceWorker)return;const i=yield self.clients.matchAll({type:"window",includeUncontrolled:!0});for(const n of i)O.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 Object(a.a)(this,void 0,void 0,function*(){if(I.a.getWindowEnv()===J.a.ServiceWorker){if(!i)throw new InvalidArgumentError.a("windowClient",InvalidArgumentError.b.Empty);O.a.debug(`[Worker Messenger] [SW -> Page] Unicasting '${e.toString()}' to window client ${i.url}.`),i.postMessage({command:e,payload:t})}else O.a.debug(`[Worker Messenger] [Page -> SW] Unicasting '${e.toString()}' to service worker.`),this.directPostMessageToSW(e,t)})}directPostMessageToSW(e,t){return Object(a.a)(this,void 0,void 0,function*(){O.a.debug(`[Worker Messenger] [Page -> SW] Direct command '${e.toString()}' to service worker.`);const i=yield this.context.serviceWorkerManager.getRegistration();if(!i)return void O.a.error("`[Worker Messenger] [Page -> SW] Could not get ServiceWorkerRegistration to postMessage!");const n=pe.getAvailableServiceWorker(i);n?n.postMessage({command:e,payload:t}):O.a.error("`[Worker Messenger] [Page -> SW] Could not get ServiceWorker to postMessage!")})}listen(){return Object(a.a)(this,void 0,void 0,function*(){if(!d.a.supportsServiceWorkers())return;I.a.getWindowEnv()===J.a.ServiceWorker?(self.addEventListener("message",this.onWorkerMessageReceivedFromPage.bind(this)),O.a.debug("[Worker Messenger] Service worker is now listening for messages.")):yield this.listenForPage()})}listenForPage(){return Object(a.a)(this,void 0,void 0,function*(){navigator.serviceWorker.addEventListener("message",this.onPageMessageReceivedFromServiceWorker.bind(this)),O.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=[];O.a.debug("[Worker Messenger] Service worker received message:",e.data);for(const 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(const 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=[];O.a.debug("[Worker Messenger] Page received message:",e.data);for(const 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(const 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()}}class fe{constructor(){this.cache={}}getCache(){return Object.assign({},this.cache)}loadSdkStylesheet(){return Object(a.a)(this,void 0,void 0,function*(){const e=I.a.getOneSignalResourceUrlPath(),t=I.a.getOneSignalCssFileName();return yield this.loadIfNew(0,new URL(`${e}/${t}?v=${d.a.getSdkStylesVersionHash()}`))})}loadFetchPolyfill(){return Object(a.a)(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 Object(a.a)(this,void 0,void 0,function*(){return this.cache[t.toString()]||(this.cache[t.toString()]=fe.load(e,t)),yield this.cache[t.toString()]})}static load(e,t){return Object(a.a)(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 Se,ve,Oe,ye=i(15),we=i(25);class Ee{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(Ee.EVENTS.SHOWING,this);const t=this.element;if(t?(this.hideClass&&Object(G.v)(t,this.hideClass),this.showClass&&Object(G.a)(t,this.showClass)):O.a.error(`(show) could not find animated element with selector ${this.selector}`),0==this.targetTransitionEvents.length)return e(this);var i=setTimeout(()=>{O.a.debug(`Element did not completely show (state: ${this.state}).`)},this.transitionCheckTimeout);Object(G.u)(this.element,"transitionend",(t,n)=>{if(t.target===this.element&&Object(G.f)(this.targetTransitionEvents,t.propertyName))return clearTimeout(i),n(),this.state="shown",m.a.trigger(Ee.EVENTS.SHOWN,this),e(this)},!0)}):Promise.resolve(this)}hide(){return this.shown?new Promise(e=>{this.state="hiding",m.a.trigger(Ee.EVENTS.HIDING,this);const t=this.element;if(t?(this.showClass&&Object(G.v)(t,this.showClass),this.hideClass&&Object(G.a)(t,this.hideClass)):O.a.error(`(hide) could not find animated element with selector ${this.selector}`),0==this.targetTransitionEvents.length)return e(this);Object(G.u)(this.element,"transitionend",(t,i)=>{var n=setTimeout(()=>{O.a.debug(`Element did not completely hide (state: ${this.state}).`)},this.transitionCheckTimeout);if(t.target===this.element&&Object(G.f)(this.targetTransitionEvents,t.propertyName))return clearTimeout(n),i(),this.state="hidden",m.a.trigger(Ee.EVENTS.HIDDEN,this),e(this)},!0)}):Promise.resolve(this)}waitUntilShown(){return"shown"===this.state?Promise.resolve(this):new Promise(e=>{Mi.emitter.once(Ee.EVENTS.SHOWN,t=>{if(t===this)return e(this)})})}waitUntilHidden(){return"hidden"===this.state?Promise.resolve(this):new Promise(e=>{Mi.emitter.once(Ee.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 Ie extends Ee{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(Ie.EVENTS.ACTIVATING,this);const t=this.element;if(t?(this.inactiveClass&&Object(G.v)(t,this.inactiveClass),this.activeClass&&Object(G.a)(t,this.activeClass)):O.a.error("Could not find active animated element"),!this.shown)return O.a.debug("Ending activate() transition (alternative)."),this.activeState="active",m.a.trigger(Ie.EVENTS.ACTIVE,this),e(this);if(0==this.targetTransitionEvents.length)return e(this);var i=setTimeout(()=>{O.a.debug(`Element did not completely activate (state: ${this.state}, activeState: ${this.activeState}).`)},this.transitionCheckTimeout);Object(G.u)(this.element,"transitionend",(t,n)=>{if(t.target===this.element&&Object(G.f)(this.targetTransitionEvents,t.propertyName))return clearTimeout(i),n(),this.activeState="active",m.a.trigger(Ie.EVENTS.ACTIVE,this),e(this)},!0)}):Promise.resolve(this)}inactivate(){return this.active?new Promise(e=>{this.activeState="inactivating",m.a.trigger(Ie.EVENTS.INACTIVATING,this);const t=this.element;if(t?(this.activeClass&&Object(G.v)(t,this.activeClass),this.inactiveClass&&Object(G.a)(t,this.inactiveClass)):O.a.error("Could not find active animated element"),!this.shown)return this.activeState="inactive",m.a.trigger(Ie.EVENTS.INACTIVE,this),e(this);if(0==this.targetTransitionEvents.length)return e(this);var i=setTimeout(()=>{O.a.debug(`Element did not completely inactivate (state: ${this.state}, activeState: ${this.activeState}).`)},this.transitionCheckTimeout);Object(G.u)(this.element,"transitionend",(t,n)=>{if(t.target===this.element&&Object(G.f)(this.targetTransitionEvents,t.propertyName))return clearTimeout(i),n(),this.activeState="inactive",m.a.trigger(Ie.EVENTS.INACTIVE,this),e(this)},!0)}):Promise.resolve(this)}waitUntilActive(){return this.active?Promise.resolve(this):new Promise(e=>{Mi.emitter.once(Ie.EVENTS.ACTIVE,t=>{if(t===this)return e(this)})})}waitUntilInactive(){return this.inactive?Promise.resolve(this):new Promise(e=>{Mi.emitter.once(Ie.EVENTS.INACTIVE,t=>{if(t===this)return e(this)})})}static get EVENTS(){return Object.assign(Object.assign({},Ee.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 Pe extends Ie{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 Ce extends Ee{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 O.a.debug(`Calling %cdisplay(${e}, ${t}, ${i}).`,Object(G.k)("code")),(this.shown?this.hide():Object(G.t)()).then(()=>{this.content=Object(G.g)(t),this.contentType=e}).then(()=>this.show()).then(()=>Object(G.i)(i)).then(()=>this.hide()).then(()=>{this.content=this.getTipForState(),this.contentType="tip"})}getTipForState(){return this.bell.state===Ue.STATES.UNSUBSCRIBED?this.bell.options.text["tip.state.unsubscribed"]:this.bell.state===Ue.STATES.SUBSCRIBED?this.bell.options.text["tip.state.subscribed"]:this.bell.state===Ue.STATES.BLOCKED?this.bell.options.text["tip.state.blocked"]:""}enqueue(e){return this.queued.push(Object(G.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){const 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 Te extends Ie{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(Ue.EVENTS.HOVERING),b.put(this.events.mouse,"over")}onHovered(){b.put(this.events.mouse,"out"),m.a.trigger(Ue.EVENTS.HOVERED)}onTap(){this.pulse(),this.activate(),this.bell.badge.activate()}onEndTap(){this.inactivate(),this.bell.badge.inactivate()}onClick(){if(m.a.trigger(Ue.EVENTS.BELL_CLICK),m.a.trigger(Ue.EVENTS.LAUNCHER_CLICK),!this.bell.message.shown||this.bell.message.contentType!=Ce.TYPES.MESSAGE){var e=b.getLast("subscription.optedOut");return this.bell.unsubscribed?e?this.bell.launcher.activateIfInactive().then(()=>{this.bell.showDialogProcedure()}):(Mi.registerForPushNotifications(),this.bell._ignoreSubscriptionState=!0,Mi.emitter.once(Mi.EVENTS.SUBSCRIPTION_CHANGED,()=>{this.bell.message.display(Ce.TYPES.MESSAGE,this.bell.options.text["message.action.subscribed"],Ce.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(G.q)()?Mi.registerForPushNotifications():this.bell.launcher.activateIfInactive().then(()=>{this.bell.showDialogProcedure()})),this.bell.message.hide()}}pulse(){Object(G.w)(".pulse-ring"),this.element&&Object(G.b)(this.element,"beforeend",'
'),this.bell.setCustomColorsIfSpecified()}}class Me extends Ee{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(G.e)(this.nestedContentSelector);let t="Nothing to show.";var i="";if(this.bell.options.showCredit&&(i='
Powered by OneSignal
'),this.bell.state===Ue.STATES.SUBSCRIBED&&!0===e||this.bell.state===Ue.STATES.UNSUBSCRIBED&&!1===e){let e="";const n=Object(G.m)(this.notificationIcons);e="default-icon"!=n?`
`:'
';let o="";o=this.bell.state!==Ue.STATES.SUBSCRIBED?``:``,t=`

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

${e}
${o}
${i}`}else if(this.bell.state===Ue.STATES.BLOCKED){let e=null;l.a.chrome?l.a.mobile||l.a.tablet||(e="/bell/chrome-unblock.jpg"):l.a.firefox?e="/bell/firefox-unblock.jpg":l.a.safari?e="/bell/safari-unblock.jpg":l.a.msedge&&(e="/bell/edge-unblock.png");let n="";e&&(n=``),(l.a.mobile||l.a.tablet)&&l.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(G.b)(this.nestedContentSelector,"beforeend",t),this.subscribeButton&&this.subscribeButton.addEventListener("click",()=>{OneSignal.__doNotShowWelcomeNotification=!1,m.a.trigger(Ue.EVENTS.SUBSCRIBE_CLICK)}),this.unsubscribeButton&&this.unsubscribeButton.addEventListener("click",()=>m.a.trigger(Ue.EVENTS.UNSUBSCRIBE_CLICK)),this.bell.setCustomColorsIfSpecified()})}}class Ae extends Ie{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 Object(a.a)(this,void 0,void 0,function*(){if(!this.element)throw new g(o.MissingDomElement);if("small"===e&&Object(G.o)(this.element,"onesignal-bell-launcher-sm")||"medium"===e&&Object(G.o)(this.element,"onesignal-bell-launcher-md")||"large"===e&&Object(G.o)(this.element,"onesignal-bell-launcher-lg"))return Promise.resolve(this);if(Object(G.v)(this.element,"onesignal-bell-launcher-sm"),Object(G.v)(this.element,"onesignal-bell-launcher-md"),Object(G.v)(this.element,"onesignal-bell-launcher-lg"),"small"===e)Object(G.a)(this.element,"onesignal-bell-launcher-sm");else if("medium"===e)Object(G.a)(this.element,"onesignal-bell-launcher-md");else{if("large"!==e)throw new Error("Invalid OneSignal bell size "+e);Object(G.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(()=>{O.a.debug(`Launcher did not completely resize (state: ${this.state}, activeState: ${this.activeState}).`)},this.transitionCheckTimeout);Object(G.u)(this.element,"transitionend",(i,n)=>{if(i.target===this.element&&Object(G.f)(this.targetTransitionEvents,i.propertyName))return clearTimeout(t),n(),e(this)},!0)}):this})}activateIfInactive(){return this.inactive?(this.wasInactive=!0,this.activate()):Object(G.t)()}inactivateIfWasInactive(){return this.wasInactive?(this.wasInactive=!1,this.inactivate()):Object(G.t)()}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)])}}class Ne{static isLocalStorageSupported(){try{return"undefined"!=typeof localStorage&&(localStorage.getItem("test"),!0)}catch(e){return!1}}static setItem(e,t,i){if(!Ne.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(!Ne.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(!Ne.isLocalStorageSupported())return null;localStorage.removeItem(e)}}!function(e){e.Push="push",e.NonPush="nonPush"}(Se||(Se={})),function(e){e.PromptDismissCount="promptDismissCount",e.NonPushPromptsDismissCount="nonPushPromptsDismissCount"}(ve||(ve={})),function(e){e.OneSignalNotificationPrompt="onesignal-notification-prompt",e.OneSignalNonPushPrompt="onesignal-non-push-prompt"}(Oe||(Oe={}));const xe={[Se.Push]:ve.PromptDismissCount,[Se.NonPush]:ve.NonPushPromptsDismissCount},ke={[Se.Push]:Oe.OneSignalNotificationPrompt,[Se.NonPush]:Oe.OneSignalNonPushPrompt};class je{static markPromptDismissedWithType(e){return Object(a.a)(this,void 0,void 0,function*(){if(Object(G.q)())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){O.a.debug("Proxy Frame possibly didn't not receive MARK_PROMPT_DISMISSED message",e||"")}const t=xe[e],i=ke[e];let n=yield v.a.get("Options",t);n||(n=0),Object(G.q)()||(n+=1);let o=3;2==n?o=7:n>2&&(o=30),O.a.debug(`(${I.a.getWindowEnv().toString()}) OneSignal: User dismissed the ${e} `+`notification prompt; reprompt after ${o} days.`),yield v.a.put("Options",{key:t,value:n});const s=24*o*60;return Ne.setItem(i,"dismissed",s)})}static wasPromptOfTypeDismissed(e){switch(e){case Se.Push:return"dismissed"===Ne.getItem(Oe.OneSignalNotificationPrompt);case Se.NonPush:return"dismissed"===Ne.getItem(Oe.OneSignalNonPushPrompt)}return!1}}var _e,De,Re='';class Ue{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"}}}constructor(e,t){this.state=Ue.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=Ue.STATES.UNINITIALIZED,this._ignoreSubscriptionState=!1,this.installEventHooks(),this.updateState())}showDialogProcedure(){this.dialog.shown||this.dialog.show().then(()=>{Object(G.u)(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(G.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(G.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(G.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(){Mi.emitter.on(Ue.EVENTS.SUBSCRIBE_CLICK,()=>{this.dialog.subscribeButton.disabled=!0,this._ignoreSubscriptionState=!0,Mi.setSubscription(!0).then(()=>(this.dialog.subscribeButton.disabled=!1,this.dialog.hide())).then(()=>this.message.display(Ce.TYPES.MESSAGE,this.options.text["message.action.resubscribed"],Ce.TIMEOUT)).then(()=>(this._ignoreSubscriptionState=!1,this.launcher.clearIfWasInactive(),this.launcher.inactivate())).then(()=>this.updateState())}),Mi.emitter.on(Ue.EVENTS.UNSUBSCRIBE_CLICK,()=>{this.dialog.unsubscribeButton.disabled=!0,Mi.setSubscription(!1).then(()=>(this.dialog.unsubscribeButton.disabled=!1,this.dialog.hide())).then(()=>(this.launcher.clearIfWasInactive(),this.launcher.activate())).then(()=>this.message.display(Ce.TYPES.MESSAGE,this.options.text["message.action.unsubscribed"],Ce.TIMEOUT)).then(()=>this.updateState())}),Mi.emitter.on(Ue.EVENTS.HOVERING,()=>{this.hovering=!0,this.launcher.activateIfInactive(),this.message.shown||this.dialog.shown?this.hovering=!1:this.message.contentType!==Ce.TYPES.MESSAGE?new Promise(e=>{if(this.message.queued.length>0)return this.message.dequeue().then(t=>{this.message.content=t,this.message.contentType=Ce.TYPES.QUEUED,e()});this.message.content=Object(G.g)(this.message.getTipForState()),this.message.contentType=Ce.TYPES.TIP,e()}).then(()=>this.message.show()).then(()=>{this.hovering=!1}):this.hovering=!1}),Mi.emitter.on(Ue.EVENTS.HOVERED,()=>{this.message.contentType!==Ce.TYPES.MESSAGE&&this.dialog.hidden&&(this.hovering&&(this.hovering=!1,this.message.waitUntilShown().then(()=>Object(G.i)(Ce.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)}))}),Mi.emitter.on(Mi.EVENTS.SUBSCRIPTION_CHANGED,e=>Object(a.a)(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 le.getNotificationIcons();this.dialog.notificationIcons=e}Mi.getNotificationPermission(t=>{let i;i=e?Ue.STATES.SUBSCRIBED:t===S.Denied?Ue.STATES.BLOCKED:Ue.STATES.UNSUBSCRIBED,this.setState(i,this._ignoreSubscriptionState)})})),Mi.emitter.on(Ue.EVENTS.STATE_CHANGED,e=>{this.launcher.element&&(e.to===Ue.STATES.SUBSCRIBED?this.launcher.inactivate():(e.to===Ue.STATES.UNSUBSCRIBED||Ue.STATES.BLOCKED)&&this.launcher.activate())}),Mi.emitter.on(Mi.EVENTS.NATIVE_PROMPT_PERMISSIONCHANGED,()=>{this.updateState()})}addDefaultClasses(){const e=this.container;if("bottom-left"===this.options.position)e&&Object(G.a)(e,"onesignal-bell-container-bottom-left"),Object(G.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(G.a)(e,"onesignal-bell-container-bottom-right"),Object(G.a)(this.launcher.selector,"onesignal-bell-launcher-bottom-right")}if("default"===this.options.theme)Object(G.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(G.a)(this.launcher.selector,"onesignal-bell-launcher-theme-inverse")}}create(){return Object(a.a)(this,void 0,void 0,function*(){if(!this.options.enable)return;if(0!==(yield Mi.context.dynamicResourceLoader.loadSdkStylesheet()))return void O.a.debug("Not showing notify button because styles failed to load.");this.container&&Object(G.w)("#onesignal-bell-container"),Object(G.b)("body","beforeend",'
'),this.container&&Object(G.b)(this.container,"beforeend",'
'),Object(G.b)(this.launcher.selector,"beforeend",'
'),Object(G.b)(this.launcher.selector,"beforeend",'
'),Object(G.b)(this.launcher.selector,"beforeend",'
'),Object(G.b)(this.message.selector,"beforeend",'
'),Object(G.b)(this.launcher.selector,"beforeend",'
'),Object(G.b)(this.dialog.selector,"beforeend",'
'),Object(G.b)(this.button.selector,"beforeend",Re);const e=yield Mi.isPushNotificationsEnabled(),t=yield Mi.getSubscription(),i=je.wasPromptOfTypeDismissed(Se.Push),n=e?"small":this.options.size||this.DEFAULT_SIZE;yield this.launcher.resize(n),this.addDefaultClasses(),this.applyOffsetIfSpecified(),this.setCustomColorsIfSpecified(),this.patchSafariSvgFilterBug(),O.a.info("Showing the notify button."),yield(e?this.launcher.inactivate():Object(G.t)()).then(()=>Mi.getSubscription()).then(t=>!e&&t||null!==this.dialog.notificationIcons?Object(G.t)():le.getNotificationIcons().then(e=>{this.dialog.notificationIcons=e})).then(()=>Object(G.i)(this.options.showLauncherAfter||0)).then(()=>Object(G.q)()&&t&&!0!==i&&!e&&!0===Mi.config.userConfig.promptOptions.autoPrompt&&!le.isHttpPromptAlreadyShown()?(O.a.debug("Not showing notify button because slidedown will be shown."),Object(G.t)()):this.launcher.show()).then(()=>Object(G.i)(this.options.showBadgeAfter||0)).then(()=>this.options.prenotify&&!e&&Mi._isNewVisitor?this.message.enqueue(this.options.text["message.prenotify"]).then(()=>this.badge.show()):Object(G.t)()).then(()=>this.initialized=!0)})}patchSafariSvgFilterBug(){if(!(l.a.safari&&Number(l.a.version)>=9.1)){const 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};`)}l.a.safari&&this.badge.element.setAttribute("style","display: none;")}applyOffsetIfSpecified(){const e=this.options.offset;if(e){const t=this.launcher.element;if(!t)return void O.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(){const e=this.dialog.element.querySelector("button.action"),t=this.button.element.querySelector(".pulse-ring");this.graphic.querySelector(".background").style.cssText="";const i=this.graphic.querySelectorAll(".foreground");for(let e=0;e{this.setState(e?Ue.STATES.SUBSCRIBED:Ue.STATES.UNSUBSCRIBED),t===S.Denied&&this.setState(Ue.STATES.BLOCKED)})}setState(e,t=!1){const i=this.state;this.state=e,i===e||t||m.a.trigger(Ue.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 Ae(this)),this._launcher}get button(){return this._button||(this._button=new Te(this)),this._button}get badge(){return this._badge||(this._badge=new Pe),this._badge}get message(){return this._message||(this._message=new Ce(this)),this._message}get dialog(){return this._dialog||(this._dialog=new Me(this)),this._dialog}get subscribed(){return this.state===Ue.STATES.SUBSCRIBED}get unsubscribed(){return this.state===Ue.STATES.UNSUBSCRIBED}get blocked(){return this.state===Ue.STATES.BLOCKED}}class We{constructor(e,t){this.url=e,this.url.pathname="subscribe",this.options=t||{}}load(){const e=Object.assign(Object.assign({},le.getPromptOptionsPostHash()),{promptType:"popup",parentHostname:encodeURIComponent(location.hostname)});return this.options.autoAccept&&(e.autoAccept=!0),O.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,d=r/2-c/2+o,u=a/2-l/2+s;i&&(i.childWidth&&(c=i.childWidth),i.childHeight&&(l=i.childHeight),i.left&&(d=i.left),i.top&&(u=i.top));const g=window.open("about:blank","onesignal-http-popup",`'scrollbars=yes, width=${c}, height=${l}, top=${u}, left=${d}`);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 ge(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 Object(a.a)(this,void 0,void 0,function*(){return O.a.debug(`(${I.a.getWindowEnv().toString()}) Successfully established cross-origin messaging with the popup window.`),this.messenger.connect(),!1})}onPopupLoaded(e){return Object(a.a)(this,void 0,void 0,function*(){this.loadPromise.resolver(),m.a.trigger("popupLoad")})}onPopupAccepted(e){return Object(a.a)(this,void 0,void 0,function*(){le.triggerCustomPromptClicked("granted")})}onPopupRejected(e){return Object(a.a)(this,void 0,void 0,function*(){le.triggerCustomPromptClicked("denied")})}onPopupClosing(e){return Object(a.a)(this,void 0,void 0,function*(){O.a.info("Popup window is closing, running cleanup events."),m.a.trigger(OneSignal.EVENTS.POPUP_CLOSING),this.dispose()})}onSetSessionCount(e){return Object(a.a)(this,void 0,void 0,function*(){O.a.debug(I.a.getWindowEnv().toString()+" Marking current session as a continuing browsing session.");const{sessionCount:t}=e.data;OneSignal.context.pageViewManager.setPageViewCount(t)})}onWindowTimeout(e){return Object(a.a)(this,void 0,void 0,function*(){O.a.debug(I.a.getWindowEnv().toString()+" Popup window timed out and was closed."),m.a.trigger(OneSignal.EVENTS.POPUP_WINDOW_TIMEOUT)})}onFinishingRegistrationRemotely(e){return Object(a.a)(this,void 0,void 0,function*(){O.a.debug(location.origin,I.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 q.checkAndTriggerSubscriptionChanged(),yield le.checkAndTriggerNotificationPermissionChanged()})}onRemoteRetriggerEvent(e){const{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 Be(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))}class Le{getPropertiesAsJson(){return{origin:location.origin,url:location.href,sdkVersion:d.a.version()}}}class Ve{}!function(e){e.HttpPermissionRequest="HttpPermissionRequest",e.SyncHashedEmail="SyncHashedEmail"}(_e||(_e={}));class Fe extends Le{constructor(e){super(),this.apiName=e}getEventName(){return"api-usage"}getPropertiesAsJson(){return Object.assign({api:this.apiName.toString()},super.getPropertiesAsJson())}}class He extends Ve{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 $e{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=Be(JSON.stringify(t)),n={method:"GET",headers:new Headers,cache:"no-cache"};return fetch(`${$e.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(Object.assign({},t),e.getOperationData());const i=Be(JSON.stringify(t)),n={method:"GET",headers:new Headers,cache:"no-cache"};return fetch(`${$e.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 He)}}!function(e){e[e.HttpPermissionRequest=0]="HttpPermissionRequest",e[e.SyncHashedEmail=1]="SyncHashedEmail"}(De||(De={}));class Ge extends u.a{constructor(e){let t,i;switch(e){case De.HttpPermissionRequest:t="The HTTP permission request has been deprecated. Please remove any custom popups from your code.",i=_e.HttpPermissionRequest;break;case De.SyncHashedEmail:t="API syncHashedEmail() has been deprecated and will be removed in a future SDK release. Please remove any usages from your code.",i=_e.SyncHashedEmail}super(t),this.reportUsage(i),Object.setPrototypeOf(this,Ge.prototype)}reportUsage(e){"undefined"!=typeof OneSignal&&OneSignal.context&&OneSignal.context.metricsManager&&OneSignal.context.metricsManager.reportEvent(new Fe(e))}}class ze{static internalInit(){return Object(a.a)(this,void 0,void 0,function*(){O.a.debug("Called %cinternalInit()",Object(G.k)("code")),yield OneSignal.context.serviceWorkerManager.installWorker();const e=OneSignal.context.sessionManager;OneSignal.emitter.on(OneSignal.EVENTS.SESSION_STARTED,e.sendOnSessionUpdateFromPage.bind(e)),OneSignal.context.pageViewManager.incrementPageViewCount(),"visible"===document.visibilityState?yield ze.sessionInit():ze.postponeSessionInitUntilPageIsInFocus()})}static postponeSessionInitUntilPageIsInFocus(){Object(G.u)(document,"visibilitychange",(e,t)=>{"visible"===document.visibilityState&&(t(),ze.sessionInit())},!0)}static sessionInit(){return Object(a.a)(this,void 0,void 0,function*(){if(O.a.debug("Called %csessionInit()",Object(G.k)("code")),OneSignal._sessionInitAlreadyRunning)return void O.a.debug("Returning from sessionInit because it has already been called.");OneSignal._sessionInitAlreadyRunning=!0;try{yield ze.doInitialize()}catch(e){if(e instanceof p)return;throw e}const e=yield OneSignal.internalIsOptedOut();A.setIsOptedOut(!!e),y.a.isUsingSubscriptionWorkaround()||(yield ze.handleAutoResubscribe(e));const t=yield OneSignal.privateIsPushNotificationsEnabled();A.setIsPushNotificationsEnabled(!!t),OneSignal.config.userConfig.promptOptions.autoPrompt&&!e&&OneSignal.context.promptsManager.spawnAutoPrompts(),OneSignal._sessionInitAlreadyRunning=!1,yield m.a.trigger(OneSignal.EVENTS.SDK_INITIALIZED)})}static registerForPushNotifications(e={}){return Object(a.a)(this,void 0,void 0,function*(){if(e&&e.modalPrompt)return OneSignal.subscriptionModalHost=new he(OneSignal.config.appId,e),void(yield OneSignal.subscriptionModalHost.load());if(y.a.isUsingSubscriptionWorkaround())return e.httpPermissionRequest?void O.a.error(new Ge(De.HttpPermissionRequest)):void(yield ze.loadSubscriptionPopup(e));A.getIsOptedOut()||(yield ce.registerForPush())})}static onSdkInitialized(){return Object(a.a)(this,void 0,void 0,function*(){const e=yield ze.processExpiringSubscriptions();(yield OneSignal.context.subscriptionManager.isAlreadyRegisteredWithOneSignal())?(OneSignal.context.sessionManager.setupSessionEventListeners(),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 Object(a.a)(this,void 0,void 0,function*(){OneSignal.subscriptionPopupHost=new We(OneSignal.proxyFrameHost.url,e),yield OneSignal.subscriptionPopupHost.load()})}static storeInitialValues(){return Object(a.a)(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 v.a.put("Options",{key:"isPushEnabled",value:e}),yield v.a.put("Options",{key:"notificationPermission",value:t})})}static setWelcomeNotificationFlag(){return Object(a.a)(this,void 0,void 0,function*(){(yield OneSignal.context.permissionManager.getNotificationPermission(OneSignal.context.appConfig.safariWebId))===S.Granted&&(OneSignal.__doNotShowWelcomeNotification=!0)})}static establishServiceWorkerChannel(){return Object(a.a)(this,void 0,void 0,function*(){if(navigator.serviceWorker&&"https:"===window.location.protocol&&!(yield I.a.isFrameContextInsecure()))try{yield OneSignal.context.serviceWorkerManager.establishServiceWorkerChannel()}catch(e){O.a.error(e)}})}static processExpiringSubscriptions(){return Object(a.a)(this,void 0,void 0,function*(){const e=OneSignal.context;if(O.a.debug("Checking subscription expiration..."),!(yield e.subscriptionManager.isSubscriptionExpiring()))return O.a.debug("Subscription is not considered expired."),!1;const t=yield I.a.getIntegration(),i=I.a.getWindowEnv();switch(O.a.debug("Subscription is considered expiring. Current Integration:",t),t){case ye.a.Secure:const n=yield e.subscriptionManager.subscribe(1);yield e.subscriptionManager.registerSubscription(n);break;case ye.a.SecureProxy:if(i===J.a.OneSignalProxyFrame)yield this.registerSubscriptionInProxyFrame(e);else{yield OneSignal.proxyFrameHost.runCommand(OneSignal.POSTMAM_COMMANDS.PROCESS_EXPIRING_SUBSCRIPTIONS)}break;case ye.a.InsecureProxy:yield v.a.remove("Ids","registrationId"),O.a.debug("Unsubscribed expiring HTTP subscription by removing registration ID.")}return!0})}static registerSubscriptionInProxyFrame(e){return Object(a.a)(this,void 0,void 0,function*(){const t=yield new Promise(t=>{e.workerMessenger.once(de.SubscribeNew,e=>{t(we.a.deserialize(e))}),e.workerMessenger.unicast(de.SubscribeNew,e.appConfig)});return O.a.debug("Finished registering brand new subscription:",t),t})}static doInitialize(){return Object(a.a)(this,void 0,void 0,function*(){const e=[];e.push(ze.storeInitialValues()),e.push(ze.installNativePromptPermissionChangedHook()),e.push(ze.setWelcomeNotificationFlag()),e.push(ze.establishServiceWorkerChannel()),e.push(ze.showNotifyButton()),e.push(ze.showPromptsFromWebConfigEditor());try{yield Promise.all(e)}catch(e){throw O.a.error(e),new p(r.Unknown)}})}static showNotifyButton(){return Object(a.a)(this,void 0,void 0,function*(){if(d.a.isBrowser()&&!OneSignal.notifyButton){OneSignal.config.userConfig.notifyButton=OneSignal.config.userConfig.notifyButton||{},OneSignal.config.userConfig.bell&&(OneSignal.config.userConfig.bell=Object.assign(Object.assign({},OneSignal.config.userConfig.bell),OneSignal.config.userConfig.notifyButton),OneSignal.config.userConfig.notifyButton=Object.assign(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,()=>Object(a.a)(this,void 0,void 0,function*(){!1!==(yield Promise.resolve(OneSignal.config.userConfig.notifyButton.displayPredicate()))?(OneSignal.notifyButton=new Ue(OneSignal.config.userConfig.notifyButton),OneSignal.notifyButton.create()):O.a.debug("Notify button display predicate returned false so not showing the notify button.")})):(OneSignal.notifyButton=new Ue(OneSignal.config.userConfig.notifyButton),OneSignal.notifyButton.create())}})}static showPromptsFromWebConfigEditor(){return Object(a.a)(this,void 0,void 0,function*(){const e=OneSignal.config;e.userConfig.promptOptions&&(yield new z(e.userConfig.promptOptions.customlink).initialize())})}static installNativePromptPermissionChangedHook(){return Object(a.a)(this,void 0,void 0,function*(){try{if(navigator.permissions){(yield navigator.permissions.query({name:"notifications"})).onchange=function(){Object(G.y)()}}}catch(e){O.a.warn(`Could not install native prompt permission change hook w/ error: ${e}`)}})}static saveInitOptions(){return Object(a.a)(this,void 0,void 0,function*(){const e=[],t=OneSignal.config.userConfig.persistNotification;e.push(v.a.put("Options",{key:"persistNotification",value:null==t||t}));const i=OneSignal.config.userConfig.webhooks;return["notification.displayed","notification.clicked","notification.dismissed"].forEach(t=>{i&&i[t]?e.push(v.a.put("Options",{key:`webhooks.${t}`,value:i[t]})):e.push(v.a.put("Options",{key:`webhooks.${t}`,value:!1}))}),i&&i.cors?e.push(v.a.put("Options",{key:"webhooks.cors",value:!0})):e.push(v.a.put("Options",{key:"webhooks.cors",value:!1})),OneSignal.config.userConfig.notificationClickHandlerMatch?e.push(v.a.put("Options",{key:"notificationClickHandlerMatch",value:OneSignal.config.userConfig.notificationClickHandlerMatch})):e.push(v.a.put("Options",{key:"notificationClickHandlerMatch",value:"exact"})),OneSignal.config.userConfig.notificationClickHandlerAction?e.push(v.a.put("Options",{key:"notificationClickHandlerAction",value:OneSignal.config.userConfig.notificationClickHandlerAction})):e.push(v.a.put("Options",{key:"notificationClickHandlerAction",value:"navigate"})),Promise.all(e)})}static initSaveState(e){return Object(a.a)(this,void 0,void 0,function*(){const t=yield le.getAppId(),i=OneSignal.config;yield v.a.put("Ids",{type:"appId",id:t});const n=e||i.siteName||document.title||"Notification";yield v.a.put("Options",{key:"pageTitle",value:n}),O.a.info(`OneSignal: Set pageTitle to be '${n}'.`)})}static handleAutoResubscribe(e){return Object(a.a)(this,void 0,void 0,function*(){if(O.a.info("handleAutoResubscribe",{autoResubscribe:OneSignal.config.userConfig.autoResubscribe,isOptedOut:e}),OneSignal.config.userConfig.autoResubscribe&&!e){(yield OneSignal.context.permissionManager.getNotificationPermission(OneSignal.context.appConfig.safariWebId))==S.Granted&&(yield ce.registerForPush())}})}static polyfillSafariFetch(){return Object(a.a)(this,void 0,void 0,function*(){if(l.a.safari&&void 0===window.fetch){O.a.debug("Loading fetch polyfill for Safari..");try{yield(new fe).loadFetchPolyfill(),O.a.debug("Done loading fetch polyfill.")}catch(e){O.a.debug("Error loading fetch polyfill:",e)}}})}static errorIfInitAlreadyCalled(){if(OneSignal._initCalled)throw new p(r.MultipleInitialization);OneSignal._initCalled=!0}}class qe{constructor(){this.incrementedPageViewCount=!1}getPageViewCount(){try{const e=sessionStorage.getItem(qe.SESSION_STORAGE_KEY_NAME),t=e?parseInt(e):0;return isNaN(t)?0:t}catch(e){return 0}}setPageViewCount(e){try{sessionStorage.setItem(qe.SESSION_STORAGE_KEY_NAME,e.toString()),I.a.getWindowEnv()===J.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,t=this.getLocalPageViewCount()+1;this.setPageViewCount(e),this.setLocalPageViewCount(t),this.incrementedPageViewCount=!0,O.a.debug(`Incremented page view count: newCountSingleTab: ${e},\n newCountAccrossTabs: ${t}.`)}simulatePageNavigationOrRefresh(){this.incrementedPageViewCount=!1}isFirstPageView(){return 1===this.getPageViewCount()}getLocalPageViewCount(){return A.getLocalPageViewCount()}setLocalPageViewCount(e){A.setLocalPageViewCount(e)}}qe.SESSION_STORAGE_KEY_NAME="onesignal-pageview-count";class Ke extends u.a{constructor(e,t){super("Registration of a Service Worker failed."),this.status=e,this.statusText=t,Object.setPrototypeOf(this,Ke.prototype)}}var Ye=Ke,Je=i(16);class Qe{static get(e,t,i){return Qe.call("GET",e,t,i)}static post(e,t,i){return Qe.call("POST",e,t,i)}static put(e,t,i){return Qe.call("PUT",e,t,i)}static delete(e,t,i){return Qe.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 Je.a(Je.b.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 Je.a(Je.b.MissingAppId));const o=new Headers;if(o.append("Origin",I.a.getOrigin()),o.append("SDK-Version",`onesignal/web/${d.a.version()}`),o.append("Content-Type","application/json;charset=UTF-8"),n)for(const e of Object.keys(n))o.append(e,n[e]);const s={method:e||"NO_METHOD_SPECIFIED",headers:o,cache:"no-cache"};let r;return i&&(s.body=JSON.stringify(i)),fetch(I.a.getOneSignalApiUrl(void 0,t).toString()+"/"+t,s).then(e=>(r=e.status,e.json())).then(e=>{if(r>=200&&r<300)return e;if("no-user-id-error"!==Qe.identifyError(e))return Promise.reject(e)}).catch(e=>(O.a.warn(`Could not complete request to /${t}`,e),Promise.reject(e)))}static identifyError(e){if(!e||!e.errors)return"no-error";const t=e.errors;return ne.a.contains(t,"No user with this id found")||ne.a.contains(t,"Could not find app_id for given player id.")?"no-user-id-error":"unknown-error"}}var Ze,Xe=Qe;!function(e){e[e.Direct=1]="Direct",e[e.Indirect=2]="Indirect",e[e.Unattributed=3]="Unattributed",e[e.NotSupported=4]="NotSupported"}(Ze||(Ze={}));class et{static downloadServerAppConfig(e){return Object(a.a)(this,void 0,void 0,function*(){return ne.a.enforceAppId(e),yield new Promise((t,i)=>{t(Qe.get(`sync/${e}/web`,null))})})}static getUserIdFromSubscriptionIdentifier(e,t,i){return ne.a.enforceAppId(e),Qe.post("players",{app_id:e,device_type:t,identifier:i,notification_types:K.TemporaryWebRecord}).then(e=>e&&e.id?e.id:null).catch(e=>(O.a.debug("Error getting user ID from subscription identifier:",e),null))}static updatePlayer(e,t,i){return Object(a.a)(this,void 0,void 0,function*(){return yield ne.a.enforceAppIdAndPlayerId(e,t,()=>Object(a.a)(this,void 0,void 0,function*(){yield Qe.put(`players/${t}`,Object.assign({app_id:e},i))}))})}static updateUserSession(e,t){return Object(a.a)(this,void 0,void 0,function*(){return yield ne.a.enforceAppIdAndPlayerId(t.app_id,e,()=>Object(a.a)(this,void 0,void 0,function*(){const i=yield Qe.post(`players/${e}/on_session`,t);return i.id?i.id:e}))})}static sendSessionDuration(e,t,i,n,o){return Object(a.a)(this,void 0,void 0,function*(){ne.a.enforceAppIdAndPlayerId(e,t,()=>Object(a.a)(this,void 0,void 0,function*(){const s={app_id:e,type:1,state:"ping",active_time:i,device_type:n};switch(o.type){case Ze.Direct:s.direct=!0,s.notification_ids=o.notificationIds;break;case Ze.Indirect:s.direct=!1,s.notification_ids=o.notificationIds}yield Qe.post(`players/${t}/on_focus`,s)}))})}}var tt=et;class it{static debug(...e){self.shouldLog&&console.debug(...e)}static trace(...e){self.shouldLog&&console.trace(...e)}static info(...e){self.shouldLog&&console.info(...e)}static warn(...e){self.shouldLog&&console.warn(...e)}static error(...e){self.shouldLog&&console.error(...e)}}const nt="sendOutcome",ot="sendUniqueOutcome";class st{constructor(e,t,i,n){this.outcomeName=i,this.config=t,this.appId=e,this.isUnique=n}getAttribution(){return Object(a.a)(this,void 0,void 0,function*(){return yield st.getAttribution(this.config)})}beforeOutcomeSend(){return Object(a.a)(this,void 0,void 0,function*(){const e=this.isUnique?ot:nt;return Object(G.s)(e,this.outcomeName),this.config?this.outcomeName?(yield Object(G.c)(),!!(yield OneSignal.privateIsPushNotificationsEnabled())||(O.a.warn("Reporting outcomes is supported only for subscribed users."),!1)):(O.a.error("Outcome name is required"),!1):(O.a.debug("Outcomes feature not supported by main application yet."),!1)})}getAttributedNotifsByUniqueOutcomeName(){return Object(a.a)(this,void 0,void 0,function*(){return(yield v.a.getAll("SentUniqueOutcome")).filter(e=>e.outcomeName===this.outcomeName).reduce((e,t)=>{const i=t.notificationIds||[];return[...e,...i]},[])})}getNotifsToAttributeWithUniqueOutcome(e){return Object(a.a)(this,void 0,void 0,function*(){const t=yield this.getAttributedNotifsByUniqueOutcomeName();return e.filter(e=>-1===t.indexOf(e))})}shouldSendUnique(e,t){return e.type===Ze.Unattributed||t.length>0}saveSentUniqueOutcome(e){return Object(a.a)(this,void 0,void 0,function*(){const t=this.outcomeName,i=yield v.a.get("SentUniqueOutcome",t),n=yield v.a.getCurrentSession(),o=[...i?i.notificationIds:[],...e],s=n?n.startTimestamp:null;yield v.a.put("SentUniqueOutcome",{outcomeName:t,notificationIds:o,sentDuringSession:s})})}wasSentDuringSession(){return Object(a.a)(this,void 0,void 0,function*(){const e=yield v.a.get("SentUniqueOutcome",this.outcomeName);if(!e)return!1;const t=yield v.a.getCurrentSession(),i=t&&e.sentDuringSession===t.startTimestamp,n=!t&&!!e.sentDuringSession;return i||n})}send(e){return Object(a.a)(this,void 0,void 0,function*(){const{type:t,notificationIds:i,weight:n}=e;switch(t){case Ze.Direct:return this.isUnique&&(yield this.saveSentUniqueOutcome(i)),void(yield OneSignal.context.updateManager.sendOutcomeDirect(this.appId,i,this.outcomeName,n));case Ze.Indirect:return this.isUnique&&(yield this.saveSentUniqueOutcome(i)),void(yield OneSignal.context.updateManager.sendOutcomeInfluenced(this.appId,i,this.outcomeName,n));case Ze.Unattributed:if(this.isUnique){if(yield this.wasSentDuringSession())return void O.a.warn("(Unattributed) unique outcome was already sent during this session");yield this.saveSentUniqueOutcome([])}return void(yield OneSignal.context.updateManager.sendOutcomeUnattributed(this.appId,this.outcomeName,n));default:return void O.a.warn("You are on a free plan. Please upgrade to use this functionality.")}})}static getAttribution(e){return Object(a.a)(this,void 0,void 0,function*(){if(e.direct&&e.direct.enabled){const e=yield v.a.getAll("NotificationClicked");if(e.length>0)return{type:Ze.Direct,notificationIds:[e[0].notificationId]}}if(e.indirect&&e.indirect.enabled){const t=60*e.indirect.influencedTimePeriodMin*1e3,i=new Date((new Date).getTime()-t).getTime(),n=yield v.a.getAll("NotificationReceived");if(O.a.debug(`\tFound total of ${n.length} received notifications`),n.length>0){const t=e.indirect.influencedNotificationsLimit,o=ne.a.sortArrayOfObjects(n,e=>e.timestamp,!0,!1),s=o.filter(e=>e.timestamp>=i).slice(0,t).map(e=>e.notificationId);O.a.debug(`\tTotal of ${s.length} received notifications are within reporting window.`);const r=o.filter(e=>-1===s.indexOf(e.notificationId)).map(e=>e.notificationId);if(r.forEach(e=>v.a.remove("NotificationReceived",e)),O.a.debug(`\t${r.length} received notifications will be deleted.`),s.length>0)return{type:Ze.Indirect,notificationIds:s}}}return e.unattributed&&e.unattributed.enabled?{type:Ze.Unattributed,notificationIds:[]}:{type:Ze.NotSupported,notificationIds:[]}})}}const rt=()=>{it.debug("Do nothing")};function at(e,t){const i=1e3*t;let n,o=void 0;const s=new Promise((t,s)=>{let r=!1;n=self.setTimeout(()=>Object(a.a)(this,void 0,void 0,function*(){r=!0;try{yield e(),t()}catch(e){it.error("Failed to execute callback",e),s()}}),i),o=(()=>{it.debug("Cancel called"),self.clearTimeout(n),r||t()})});return o?{promise:s,cancel:o}:(it.warn("clearTimeoutHandle was not assigned."),{promise:s,cancel:rt})}class ct{constructor(){this._channels=[]}registerChannel(e){this._channels.push(e)}onSession(){return Object(a.a)(this,void 0,void 0,function*(){yield Promise.all(this._channels.map(e=>e.onSession()))})}onFocus(e){return Object(a.a)(this,void 0,void 0,function*(){yield Promise.all(this._channels.map(t=>t.onFocus(e)))})}setTags(e){return Object(a.a)(this,void 0,void 0,function*(){yield Promise.all(this._channels.map(t=>t.setTags(e)))})}setExternalUserId(e,t){return Object(a.a)(this,void 0,void 0,function*(){yield Promise.all(this._channels.map(i=>i.setExternalUserId(e,t)))})}}var lt=i(19),dt=i(26),ut=i.n(dt);class gt{static getPlayer(e,t){return ne.b.enforceAppId(e),ne.b.enforcePlayerId(t),Xe.get(`players/${t}?app_id=${e}`)}static updatePlayer(e,t,i){return ne.b.enforceAppId(e),ne.b.enforcePlayerId(t),Xe.put(`players/${t}`,Object.assign({app_id:e},i))}static createUser(e){return Object(a.a)(this,void 0,void 0,function*(){const t=e.serialize();ne.b.enforceAppId(t.app_id);const i=yield Xe.post("players",t);return i&&i.success?i.id:null})}static logoutEmail(e,t,i){return Object(a.a)(this,void 0,void 0,function*(){ne.b.enforceAppId(e.appId),ne.b.enforcePlayerId(i);const n=yield Xe.post(`players/${i}/email_logout`,{app_id:e.appId,parent_player_id:t.subscriptionId,identifier_auth_hash:t.identifierAuthHash?t.identifierAuthHash:void 0});return!(!n||!n.success)})}static updateUserSession(e,t){return Object(a.a)(this,void 0,void 0,function*(){try{const i=t.serialize();ne.b.enforceAppId(i.app_id),ne.b.enforcePlayerId(e);const n=yield Xe.post(`players/${e}/on_session`,i);return n.id?n.id:e}catch(e){throw e&&Array.isArray(e.errors)&&e.errors.length>0&&ne.b.contains(e.errors[0],"app_id not found")?new Je.a(Je.b.MissingAppId):e}})}static sendOutcome(e){return Object(a.a)(this,void 0,void 0,function*(){O.a.info("Outcome payload:",e);try{yield Xe.post("outcomes/measure",e)}catch(e){O.a.error("sendOutcome",e)}})}}class ht{static getPlayer(e,t){return gt.getPlayer(e,t)}static updatePlayer(e,t,i){return gt.updatePlayer(e,t,i)}static jsonpLib(e,t){ut()(e,null,t)}static downloadServerAppConfig(e){return Object(a.a)(this,void 0,void 0,function*(){return I.a.getWindowEnv()!==J.a.ServiceWorker?yield new Promise((t,i)=>{ht.jsonpLib(`${I.a.getOneSignalApiUrl().toString()}/sync/${e}/web`,(e,n)=>{e?i(e):n.success?t(n):i(n)})}):yield tt.downloadServerAppConfig(e)})}static createUser(e){return Object(a.a)(this,void 0,void 0,function*(){return yield gt.createUser(e)})}static logoutEmail(e,t,i){return Object(a.a)(this,void 0,void 0,function*(){return yield gt.logoutEmail(e,t,i)})}static updateUserSession(e,t){return Object(a.a)(this,void 0,void 0,function*(){return yield gt.updateUserSession(e,t)})}}class pt{constructor(e,t,i,n,o){this.secondaryChannelIdentifierUpdater=e,this.secondaryChannelExternalUserIdUpdater=t,this.secondaryChannelTagsUpdater=i,this.secondaryChannelSessionUpdater=n,this.secondaryChannelFocusUpdater=o}logout(){return Object(a.a)(this,void 0,void 0,function*(){const e=yield v.a.getEmailProfile();if(!e.subscriptionId)return O.a.warn(new h(s.NoEmailSet)),!1;const{deviceId:t}=yield v.a.getSubscription();if(!t)return O.a.warn(new h(s.NoDeviceId)),!1;const i=yield v.a.getAppConfig();return(yield ht.logoutEmail(i,e,t))?(yield v.a.setEmailProfile(new lt.a),!0):(O.a.warn("Failed to logout email."),!1)})}setIdentifier(e,t){return Object(a.a)(this,void 0,void 0,function*(){const{profileProvider:i}=this.secondaryChannelIdentifierUpdater,n=yield i.getProfile(),o=yield this.secondaryChannelIdentifierUpdater.setIdentifier(e,t),s=o.subscriptionId;if(s){const t=i.newProfile(s,e);yield this.updatePushPlayersRelationToEmailPlayer(n,t)}return yield m.a.trigger(OneSignal.EVENTS.EMAIL_SUBSCRIPTION_CHANGED,{email:o.identifier}),s})}updatePushPlayersRelationToEmailPlayer(e,t){return Object(a.a)(this,void 0,void 0,function*(){const{deviceId:i}=yield v.a.getSubscription(),n=i,o=!!!e.subscriptionId||e.subscriptionId!==t.subscriptionId,s=!e.identifier||t.identifier!==e.identifier;if(i&&n&&(o||s)){const e=yield OneSignal.database.getExternalUserIdAuthHash(),n=yield v.a.getAppConfig();yield ht.updatePlayer(n.appId,i,{parent_player_id:t.subscriptionId,email:t.identifier,external_user_id_auth_hash:e})}})}onSession(){return Object(a.a)(this,void 0,void 0,function*(){yield this.secondaryChannelSessionUpdater.sendOnSession()})}onFocus(e){return Object(a.a)(this,void 0,void 0,function*(){yield this.secondaryChannelFocusUpdater.sendOnFocus(e)})}setTags(e){return Object(a.a)(this,void 0,void 0,function*(){yield this.secondaryChannelTagsUpdater.sendTags(e)})}setExternalUserId(e,t){return Object(a.a)(this,void 0,void 0,function*(){yield this.secondaryChannelExternalUserIdUpdater.setExternalUserId(e,t)})}}class mt{static addExternalUserIdToDeviceRecord(e){return Object(a.a)(this,void 0,void 0,function*(){const t=yield v.a.getExternalUserId();if(!t)return;e.externalUserId=t;const i=yield v.a.getExternalUserIdAuthHash();i&&(e.externalUserIdAuthHash=i)})}}class bt extends X{constructor(e,t,i,n){super(),this.deliveryPlatform=e,this.identifier=t,this.identifierAuthHash=i,this.pushDeviceRecordId=n}serialize(){const e=super.serialize();return this.identifier&&(e.identifier=this.identifier),this.identifierAuthHash&&(e.identifier_auth_hash=this.identifierAuthHash),this.pushDeviceRecordId&&(e.device_player_id=this.pushDeviceRecordId),e}deserialize(e){throw new Z}}class ft{constructor(e){this.profileProvider=e}setIdentifier(e,t){return Object(a.a)(this,void 0,void 0,function*(){const i=yield v.a.getAppConfig(),n=yield this.profileProvider.getProfile(),o=this.profileProvider.newProfile(n.subscriptionId,e,t);if(n.subscriptionId)yield ht.updatePlayer(i.appId,n.subscriptionId,{identifier:e,identifier_auth_hash:t});else{const{deviceId:e}=yield v.a.getSubscription(),t=new bt(this.profileProvider.deviceType,o.identifier,o.identifierAuthHash,e);t.appId=i.appId,yield mt.addExternalUserIdToDeviceRecord(t),o.subscriptionId=yield ht.createUser(t)}return o.subscriptionId&&(yield this.profileProvider.setProfile(o)),o})}}class St{constructor(e){this.profileProvider=e}sendTags(e){return Object(a.a)(this,void 0,void 0,function*(){const t=yield this.profileProvider.getSubscriptionId(),{appId:i}=yield v.a.getAppConfig(),n=(yield this.profileProvider.getProfile()).identifierAuthHash,o={tags:e,identifier_auth_hash:n};yield ht.updatePlayer(i,t,o)})}}class vt{constructor(e){this.profileProvider=e}setExternalUserId(e,t){return Object(a.a)(this,void 0,void 0,function*(){const i=yield this.profileProvider.getSubscriptionId(),{appId:n}=yield v.a.getAppConfig(),o={external_user_id:e,external_user_id_auth_hash:t};yield gt.updatePlayer(n,i,o)})}}class Ot{constructor(e){this.profileProvider=e}sendOnFocus(e){return Object(a.a)(this,void 0,void 0,function*(){const t=yield this.profileProvider.getProfile();if(!t.subscriptionId)return;const i={app_id:(yield v.a.getAppConfig()).appId,type:1,state:"ping",active_time:e,device_type:this.profileProvider.deviceType};yield Xe.post(`players/${t.subscriptionId}/on_focus`,i)})}}class yt{constructor(e){this.profileProvider=e}sendOnSession(){return Object(a.a)(this,void 0,void 0,function*(){const e=yield this.profileProvider.getProfile();if(!e.subscriptionId)return;const t=new bt(this.profileProvider.deviceType,e.identifier,e.identifierAuthHash),i=yield v.a.getAppConfig();t.appId=i.appId;const n=yield gt.updateUserSession(e.subscriptionId,t);n!==e.subscriptionId&&(e.subscriptionId=n,yield this.profileProvider.setProfile(e))})}}class wt{constructor(){this._pendingGetSubscriptionIdResolvers=[]}setProfile(e){return Object(a.a)(this,void 0,void 0,function*(){if(!e.subscriptionId)return;const t=e.subscriptionId;this._pendingGetSubscriptionIdResolvers.map(e=>{e(t)}),this._pendingGetSubscriptionIdResolvers=[]})}getSubscriptionId(){return Object(a.a)(this,void 0,void 0,function*(){const e=yield this.getProfile();return e.subscriptionId?e.subscriptionId:new Promise(e=>{this._pendingGetSubscriptionIdResolvers.push(e)})})}}class Et extends wt{constructor(){super(...arguments),this.deviceType=Y.Email}newProfile(e,t,i){return new lt.a(e,t,i)}getProfile(){return Object(a.a)(this,void 0,void 0,function*(){return yield v.a.getEmailProfile()})}setProfile(e){const t=Object.create(null,{setProfile:{get:()=>super.setProfile}});return Object(a.a)(this,void 0,void 0,function*(){yield v.a.setEmailProfile(e),yield t.setProfile.call(this,e)})}}var It,Pt,Ct=i(20);class Tt extends wt{constructor(){super(...arguments),this.deviceType=Y.SMS}newProfile(e,t,i){return new Ct.a(e,t,i)}getProfile(){return Object(a.a)(this,void 0,void 0,function*(){return yield v.a.getSMSProfile()})}setProfile(e){const t=Object.create(null,{setProfile:{get:()=>super.setProfile}});return Object(a.a)(this,void 0,void 0,function*(){yield v.a.setSMSProfile(e),yield t.setProfile.call(this,e)})}}class Mt{constructor(e,t,i,n,o){this.secondaryChannelIdentifierUpdater=e,this.secondaryChannelExternalUserIdUpdater=t,this.secondaryChannelTagsUpdater=i,this.secondaryChannelSessionUpdater=n,this.secondaryChannelFocusUpdater=o}logout(){return Object(a.a)(this,void 0,void 0,function*(){return(yield v.a.getSMSProfile()).subscriptionId?(yield v.a.setSMSProfile(new Ct.a),!0):(O.a.warn(new h(s.NoSMSSet)),!1)})}setIdentifier(e,t){return Object(a.a)(this,void 0,void 0,function*(){const i=yield this.secondaryChannelIdentifierUpdater.setIdentifier(e,t);return yield m.a.trigger(OneSignal.EVENTS.SMS_SUBSCRIPTION_CHANGED,{sms:i.identifier}),i.subscriptionId})}onSession(){return Object(a.a)(this,void 0,void 0,function*(){yield this.secondaryChannelSessionUpdater.sendOnSession()})}onFocus(e){return Object(a.a)(this,void 0,void 0,function*(){yield this.secondaryChannelFocusUpdater.sendOnFocus(e)})}setTags(e){return Object(a.a)(this,void 0,void 0,function*(){yield this.secondaryChannelTagsUpdater.sendTags(e)})}setExternalUserId(e,t){return Object(a.a)(this,void 0,void 0,function*(){yield this.secondaryChannelExternalUserIdUpdater.setExternalUserId(e,t)})}}class At{constructor(){this.synchronizer=new ct;const e=new Et,t=new pt(new ft(e),new vt(e),new St(e),new yt(e),new Ot(e));this.email=t,this.synchronizer.registerChannel(t);const i=new Tt,n=new Mt(new ft(i),new vt(i),new St(i),new yt(i),new Ot(i));this.sms=n,this.synchronizer.registerChannel(n)}}class Nt{static getServiceWorkerHref(e,t,i){return Nt.appendServiceWorkerParams(e.workerPath.getFullPath(),t,i)}static appendServiceWorkerParams(e,t,i){return`${new URL(e,y.a.getBaseUrl()).href}?${ne.b.encodeHashAsUriComponent({appId:t})}&${ne.b.encodeHashAsUriComponent({sdkVersion:i})}`}static upsertSession(e,t,i,n,o,s){return Object(a.a)(this,void 0,void 0,function*(){if(!n)return void it.error("No deviceId provided for new session.");if(!i.app_id)return void it.error("No appId provided for new session.");const r=yield v.a.getCurrentSession();if(!r){const e=i.app_id,t=Object(ae.d)({deviceId:n,appId:e,deviceType:i.device_type}),s=yield v.a.getLastNotificationClicked(e);return s&&(t.notificationId=s.notificationId),yield v.a.upsertSession(t),void(yield Nt.sendOnSessionCallIfNecessary(o,i,n,t))}if(r.status===ae.c.Active)return void it.debug("Session already active",r);if(!r.lastDeactivatedTimestamp)return void it.debug("Session is in invalid state",r);const a=(new Date).getTime();if(Nt.timeInSecondsBetweenTimestamps(a,r.lastDeactivatedTimestamp)<=e)return r.status=ae.c.Active,r.lastActivatedTimestamp=a,r.lastDeactivatedTimestamp=null,void(yield v.a.upsertSession(r));yield Nt.finalizeSession(r,t,s);const c=Object(ae.d)({deviceId:n,appId:i.app_id,deviceType:i.device_type});yield v.a.upsertSession(c),yield Nt.sendOnSessionCallIfNecessary(o,i,n,c)})}static deactivateSession(e,t,i){return Object(a.a)(this,void 0,void 0,function*(){const n=yield v.a.getCurrentSession();if(!n)return void it.debug("No active session found. Cannot deactivate.");if(n.status===ae.c.Inactive)return at(()=>Nt.finalizeSession(n,t,i),e);if(n.status!==ae.c.Active)return void it.warn(`Session in invalid state ${n.status}. Cannot deactivate.`);const o=(new Date).getTime(),s=Nt.timeInSecondsBetweenTimestamps(o,n.lastActivatedTimestamp);n.lastDeactivatedTimestamp=o,n.accumulatedDuration+=s,n.status=ae.c.Inactive;const r=at(()=>Nt.finalizeSession(n,t,i),e);return yield v.a.upsertSession(n),r})}static sendOnSessionCallIfNecessary(e,t,i,n){return Object(a.a)(this,void 0,void 0,function*(){if(e===ae.b.PlayerCreate)return;if(!t.identifier){const e=yield self.registration.pushManager.getSubscription();if(e){const i=se.setFromW3cSubscription(e),n=new ee(i).serialize();t.identifier=n.identifier}}const o=yield et.updateUserSession(i,t);o!==i&&(n.deviceId=o,yield Promise.all([v.a.setDeviceId(o),v.a.upsertSession(n),v.a.resetSentUniqueOutcomes()])),yield(new At).synchronizer.onSession()})}static finalizeSession(e,t,i){return Object(a.a)(this,void 0,void 0,function*(){if(it.debug("Finalize session",`started: ${new Date(e.startTimestamp)}`,`duration: ${e.accumulatedDuration}s`),t){it.debug(`send on_focus reporting session duration -> ${e.accumulatedDuration}s`);const t=yield st.getAttribution(i);it.debug("send on_focus with attribution",t),yield et.sendSessionDuration(e.appId,e.deviceId,e.accumulatedDuration,e.deviceType,t),yield(new At).synchronizer.onFocus(e.accumulatedDuration)}yield Promise.all([v.a.cleanupCurrentSession(),v.a.removeAllNotificationClicked()]),it.debug("Finalize session finished",`started: ${new Date(e.startTimestamp)}`)})}static timeInSecondsBetweenTimestamps(e,t){return e<=t?0:Math.floor((e-t)/1e3)}}!function(e){e.OneSignalWorker="OneSignal Worker",e.ThirdParty="3rd Party",e.None="None",e.Indeterminate="Indeterminate"}(It||(It={}));class xt{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(xt.QUERY_STRING)[0]}getFileName(){var e;return null===(e=this.getWithoutQueryString().split("\\").pop())||void 0===e?void 0:e.split("/").pop()}getFileNameWithQuery(){var e;return null===(e=this.path.split("\\").pop())||void 0===e?void 0:e.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(/[\\\/]$/,"")}}xt.QUERY_STRING="?";class kt{constructor(e,t){this.context=e,this.config=t}getRegistration(){return Object(a.a)(this,void 0,void 0,function*(){return yield pe.getRegistration(this.config.registrationOptions.scope)})}getActiveState(){return Object(a.a)(this,void 0,void 0,function*(){const e=yield I.a.getIntegration();if(e===ye.a.InsecureProxy)return It.Indeterminate;if(e===ye.a.SecureProxy){switch(I.a.getWindowEnv()){case J.a.Host:case J.a.CustomIframe:const e=OneSignal.proxyFrameHost;return e?yield e.runCommand(OneSignal.POSTMAM_COMMANDS.SERVICE_WORKER_STATE):It.Indeterminate;case J.a.OneSignalSubscriptionPopup:break;case J.a.OneSignalSubscriptionModal:throw new Z}}const t=yield this.context.serviceWorkerManager.getRegistration();if(!t)return It.None;const i=kt.activeSwFileName(t);return this.swActiveStateByFileName(i)})}static activeSwFileName(e){const t=pe.getAvailableServiceWorker(e);if(!t)return null;const i=new URL(t.scriptURL).pathname,n=new xt(i).getFileName();if("akam-sw.js"==n){const e=new URLSearchParams(new URL(t.scriptURL).search).get("othersw");if(e)return O.a.debug("Found a ServiceWorker under Akamai's akam-sw.js?othersw=",e),new xt(new URL(e).pathname).getFileName()}return n}swActiveStateByFileName(e){return e?e==this.config.workerPath.getFileName()?It.OneSignalWorker:It.ThirdParty:It.None}getWorkerVersion(){return Object(a.a)(this,void 0,void 0,function*(){return new Promise(e=>Object(a.a)(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(de.WorkerVersion,t=>{e(t)}),yield this.context.workerMessenger.unicast(de.WorkerVersion)}))})}shouldInstallWorker(){return Object(a.a)(this,void 0,void 0,function*(){if(!d.a.supportsServiceWorkers())return!1;if(!OneSignal.config)return!1;if(OneSignal.config.subdomain&&"safari"!==OneSignal.environmentInfo.browserType&&I.a.getWindowEnv()===J.a.Host)return!1;const e=yield this.getActiveState();if(O.a.debug("[shouldInstallWorker] workerState",e),e===It.None||e===It.ThirdParty){const e="granted"===(yield OneSignal.context.permissionManager.getNotificationPermission(OneSignal.config.safariWebId));return e&&O.a.info("[shouldInstallWorker] Notification Permissions enabled, will install ServiceWorker"),e}return!!(yield this.haveParamsChanged())||this.workerNeedsUpdate()})}haveParamsChanged(){return Object(a.a)(this,void 0,void 0,function*(){const e=yield this.context.serviceWorkerManager.getRegistration();if(!e)return O.a.info("[changedServiceWorkerParams] workerRegistration not found at scope",this.config.registrationOptions.scope),!0;const t=new URL(e.scope).pathname,i=this.config.registrationOptions.scope;if(t!=i)return O.a.info("[changedServiceWorkerParams] ServiceWorker scope changing",{a_old:t,b_new:i}),!0;const n=pe.getAvailableServiceWorker(e),o=Nt.getServiceWorkerHref(this.config,this.context.appConfig.appId,d.a.version());return null===n||void 0===n||!n.scriptURL||o!==n.scriptURL&&(O.a.info("[changedServiceWorkerParams] ServiceWorker href changing:",{a_old:null===n||void 0===n?void 0:n.scriptURL,b_new:o}),!0)})}workerNeedsUpdate(){return Object(a.a)(this,void 0,void 0,function*(){let e;O.a.info("[Service Worker Update] Checking service worker version...");try{e=yield ne.a.timeoutPromise(this.getWorkerVersion(),2e3)}catch(e){return O.a.info("[Service Worker Update] Worker did not reply to version query; assuming older version and updating."),!0}return e!==d.a.version()?(O.a.info(`[Service Worker Update] Updating service worker from ${e} --\x3e ${d.a.version()}.`),!0):(O.a.info(`[Service Worker Update] Service worker version is current at ${e} (no update required).`),!1)})}establishServiceWorkerChannel(){return Object(a.a)(this,void 0,void 0,function*(){O.a.debug("establishServiceWorkerChannel");const e=this.context.workerMessenger;e.off(),e.on(de.NotificationDisplayed,e=>Object(a.a)(this,void 0,void 0,function*(){O.a.debug(location.origin,"Received notification display event from service worker."),yield m.a.trigger(OneSignal.EVENTS.NOTIFICATION_DISPLAYED,e)})),e.on(de.NotificationClicked,e=>Object(a.a)(this,void 0,void 0,function*(){let t;if(0===(t=I.a.getWindowEnv()===J.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=>{const i=t.data;e(i)})}):OneSignal.emitter.numberOfListeners(OneSignal.EVENTS.NOTIFICATION_CLICKED))){O.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 v.a.put("NotificationOpened",{url:t,data:e,timestamp:Date.now()})}else yield m.a.trigger(OneSignal.EVENTS.NOTIFICATION_CLICKED,e)})),e.on(de.RedirectPage,e=>{O.a.debug(`${I.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(de.NotificationDismissed,e=>Object(a.a)(this,void 0,void 0,function*(){yield m.a.trigger(OneSignal.EVENTS.NOTIFICATION_DISMISSED,e)}));const t=y.b.isHttps(),i=y.b.isSafari();e.on(de.AreYouVisible,n=>Object(a.a)(this,void 0,void 0,function*(){if(t&&i){const t={timestamp:n.timestamp,focused:document.hasFocus()};yield e.directPostMessageToSW(de.AreYouVisibleResponse,t)}else{const e={timestamp:n.timestamp},t=OneSignal.proxyFrame;t&&t.messenger.message(OneSignal.POSTMAM_COMMANDS.ARE_YOU_VISIBLE_REQUEST,e)}}))})}installWorker(){return Object(a.a)(this,void 0,void 0,function*(){if(!(yield this.shouldInstallWorker()))return;O.a.info("Installing worker..."),(yield this.getActiveState())===It.ThirdParty&&O.a.info("[Service Worker Installation] 3rd party service worker detected.");const e=Nt.getServiceWorkerHref(this.config,this.context.appConfig.appId,d.a.version()),t=`${y.b.getBaseUrl()}${this.config.registrationOptions.scope}`;O.a.info(`[Service Worker Installation] Installing service worker ${e} ${t}.`);try{yield navigator.serviceWorker.register(e,{scope:t})}catch(t){if(O.a.error(`[Service Worker Installation] Installing service worker failed ${t}`),I.a.getWindowEnv()===J.a.OneSignalSubscriptionPopup)throw t;const i=yield fetch(e);if(403===i.status||404===i.status)throw new Ye(i.status,i.statusText);throw t}O.a.debug("[Service Worker Installation] Service worker installed."),yield this.establishServiceWorkerChannel()})}}!function(e){e[e.InvalidSafariSetup=0]="InvalidSafariSetup",e[e.Blocked=1]="Blocked",e[e.Dismissed=2]="Dismissed"}(Pt||(Pt={}));class jt extends u.a{constructor(e){let t;switch(e){case Pt.InvalidSafariSetup:t="The Safari site URL, icon size, or push certificate is invalid, or Safari is in a private session.";break;case Pt.Blocked:t="Notification permissions are blocked.";break;case Pt.Dismissed:t="The notification permission prompt was dismissed."}super(t),Object.setPrototypeOf(this,jt.prototype)}}class _t{constructor(e,t){this.safariPermissionPromptFailed=!1,this.context=e,this.config=t}subscribe(e){return Object(a.a)(this,void 0,void 0,function*(){const t=I.a.getWindowEnv();switch(t){case J.a.CustomIframe:case J.a.Unknown:case J.a.OneSignalProxyFrame:throw new g(o.UnsupportedEnvironment)}let i;switch(t){case J.a.ServiceWorker:i=yield this.subscribeFcmFromWorker(e);break;case J.a.Host:case J.a.OneSignalSubscriptionModal:case J.a.OneSignalSubscriptionPopup:if((yield OneSignal.privateGetNotificationPermission())===S.Denied)throw new oe(te.Blocked);if(d.a.useSafariLegacyPush()){i=yield this.subscribeSafari(),O.a.info("Installing SW on Safari");try{yield this.context.serviceWorkerManager.installWorker(),O.a.info("SW on Safari successfully installed")}catch(e){O.a.error("SW on Safari failed to install.")}}else i=yield this.subscribeFcmFromPage(e);break;default:throw new g(o.UnsupportedEnvironment)}return i})}registerSubscription(e,t){return Object(a.a)(this,void 0,void 0,function*(){e&&(e=se.deserialize(e));const i=ee.createFromPushSubscription(this.config.appId,e,t);let n=void 0;(yield this.isAlreadyRegisteredWithOneSignal())?yield this.context.updateManager.sendPushDeviceRecordUpdate(i):(n=yield this.context.updateManager.sendPlayerCreate(i))&&(yield this.associateSubscriptionWithEmail(n));const o=yield v.a.getSubscription();return o.deviceId=n,o.optedOut=!1,e?d.a.useSafariLegacyPush()?o.subscriptionToken=e.safariDeviceToken:o.subscriptionToken=e.w3cEndpoint?e.w3cEndpoint.toString():null:o.subscriptionToken=null,yield v.a.setSubscription(o),I.a.getWindowEnv()!==J.a.ServiceWorker&&m.a.trigger(OneSignal.EVENTS.REGISTERED),"undefined"!=typeof OneSignal&&(OneSignal._sessionInitAlreadyRunning=!1),o})}static requestPresubscribeNotificationPermission(){return Object(a.a)(this,void 0,void 0,function*(){return yield _t.requestNotificationPermission()})}unsubscribe(e){return Object(a.a)(this,void 0,void 0,function*(){if(0===e)throw new Z;if(1!==e)throw new Z;if(I.a.getWindowEnv()!==J.a.ServiceWorker)throw new Z;{const{deviceId:e}=yield v.a.getSubscription();yield gt.updatePlayer(this.context.appConfig.appId,e,{notification_types:K.MutedByApi}),yield v.a.put("Options",{key:"optedOut",value:!0})}})}static requestNotificationPermission(){return Object(a.a)(this,void 0,void 0,function*(){const e=yield window.Notification.requestPermission();return S[e]})}associateSubscriptionWithEmail(e){return Object(a.a)(this,void 0,void 0,function*(){const t=yield v.a.getEmailProfile();t.subscriptionId&&(yield gt.updatePlayer(this.config.appId,e,{parent_player_id:t.subscriptionId,email:t.identifier}))})}isAlreadyRegisteredWithOneSignal(){return Object(a.a)(this,void 0,void 0,function*(){const{deviceId:e}=yield v.a.getSubscription();return!!e})}subscribeSafariPromptPermission(){return Object(a.a)(this,void 0,void 0,function*(){const e=e=>new Promise(t=>{window.safari.pushNotification.requestPermission(e,this.config.safariWebId,{app_id:this.config.appId},e=>{e&&e.deviceToken?t(e.deviceToken.toLowerCase()):t(null)})});return this.safariPermissionPromptFailed?e(`${I.a.getOneSignalApiUrl().toString()}/safari`):e(`${I.a.getOneSignalApiUrl().toString()}/safari/apps/${this.config.appId}`)})}subscribeSafari(){return Object(a.a)(this,void 0,void 0,function*(){const e=new se;if(!this.config.safariWebId)throw new p(r.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(ie.a.triggerNotificationPermissionChanged(),!i)throw this.safariPermissionPromptFailed=!0,new jt(Pt.InvalidSafariSetup);return e.setFromSafariSubscription(i),e})}subscribeFcmFromPage(e){return Object(a.a)(this,void 0,void 0,function*(){if(I.a.getWindowEnv()!==J.a.ServiceWorker&&Notification.permission===S.Default){yield m.a.trigger(OneSignal.EVENTS.PERMISSION_PROMPT_DISPLAYED);const e=yield _t.requestPresubscribeNotificationPermission(),t=e===S.Default;switch(yield ie.a.triggerNotificationPermissionChanged(t),e){case S.Default:throw O.a.debug("Exiting subscription and not registering worker because the permission was dismissed."),OneSignal._sessionInitAlreadyRunning=!1,OneSignal._isRegisteringForPush=!1,new oe(te.Dismissed);case S.Denied:throw O.a.debug("Exiting subscription and not registering worker because the permission was blocked."),OneSignal._sessionInitAlreadyRunning=!1,OneSignal._isRegisteringForPush=!1,new oe(te.Blocked)}}try{yield this.context.serviceWorkerManager.installWorker()}catch(e){throw e instanceof Ye&&(403===e.status?yield this.context.subscriptionManager.registerFailedSubscription(K.ServiceWorkerStatus403,this.context):404===e.status&&(yield this.context.subscriptionManager.registerFailedSubscription(K.ServiceWorkerStatus404,this.context))),e}O.a.debug("[Subscription Manager] Getting OneSignal service Worker...");const t=yield this.context.serviceWorkerManager.getRegistration();if(!t)throw new Error("OneSignal service worker not found!");return O.a.debug("[Subscription Manager] Service worker is ready to continue subscribing."),yield this.subscribeWithVapidKey(t.pushManager,e)})}subscribeFcmFromWorker(e){return Object(a.a)(this,void 0,void 0,function*(){const t=self.registration;if(!t.active&&!l.a.firefox)throw new g(o.ServiceWorkerNotActivated);const i=yield t.pushManager.permissionState({userVisibleOnly:!0});if("denied"===i)throw new oe(te.Blocked);if("prompt"===i)throw new oe(te.Default);return yield this.subscribeWithVapidKey(t.pushManager,e)})}getVapidKeyForBrowser(){let e=void 0;return(e=l.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 Object(a.a)(this,void 0,void 0,function*(){if((yield this.context.serviceWorkerManager.getActiveState())!==It.OneSignalWorker)return!1;const e=yield this.context.serviceWorkerManager.getRegistration();if(!e)return!1;if(!e.pushManager)return!1;const t=yield e.pushManager.getSubscription();if(!t)return!1;if(!t.expirationTime)return!1;let{createdAt:i}=yield v.a.getSubscription();if(!i){const e=31536e6;i=(new Date).getTime()+e}const n=i+(t.expirationTime-i)/2;return!!t.expirationTime&&((new Date).getTime()>=t.expirationTime||(new Date).getTime()>=n)})}getSubscriptionState(){return Object(a.a)(this,void 0,void 0,function*(){if(d.a.useSafariLegacyPush())return this.getSubscriptionStateForSecure();const e=I.a.getWindowEnv();switch(e){case J.a.ServiceWorker:const t=yield self.registration.pushManager.getSubscription(),{optedOut:i}=yield v.a.getSubscription();return{subscribed:!!t,optedOut:!!i};default:switch(yield I.a.getIntegration()){case ye.a.Secure:return this.getSubscriptionStateForSecure();case ye.a.SecureProxy:switch(e){case J.a.OneSignalProxyFrame:case J.a.OneSignalSubscriptionPopup:case J.a.OneSignalSubscriptionModal:return this.getSubscriptionStateForSecure();default:return yield OneSignal.proxyFrameHost.runCommand(OneSignal.POSTMAM_COMMANDS.GET_SUBSCRIPTION_STATE)}case ye.a.InsecureProxy:return yield this.getSubscriptionStateForInsecure();default:throw new g(o.UnsupportedEnvironment)}}})}getSubscriptionStateForSecure(){return Object(a.a)(this,void 0,void 0,function*(){const{deviceId:e,optedOut:t}=yield v.a.getSubscription();if(d.a.useSafariLegacyPush()){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 this.context.serviceWorkerManager.getRegistration(),o=yield this.context.permissionManager.getNotificationPermission(this.context.appConfig.safariWebId),s=i===It.OneSignalWorker;return n?{subscribed:!(!e||o!==S.Granted||!s),optedOut:!!t}:{subscribed:!1,optedOut:!!t}})}getSubscriptionStateForInsecure(){return Object(a.a)(this,void 0,void 0,function*(){const{deviceId:e,subscriptionToken:t,optedOut:i}=yield v.a.getSubscription(),n=yield this.context.permissionManager.getNotificationPermission(this.context.appConfig.safariWebId);return{subscribed:!(!e||!t||n!==S.Granted),optedOut:!!i}})}registerFailedSubscription(e,t){return Object(a.a)(this,void 0,void 0,function*(){t.pageViewManager.isFirstPageView()&&(t.subscriptionManager.registerSubscription(new se,e),t.pageViewManager.incrementPageViewCount())})}}var Dt=class{static getServiceWorkerManager(e){const t=e.appConfig,i=I.a.getBuildEnvPrefix(),n={workerPath:new xt(`/${i}OneSignalSDKWorker.js`),registrationOptions:{scope:"/"}};return t.userConfig&&(t.userConfig.path&&(n.workerPath=new xt(`${t.userConfig.path}${t.userConfig.serviceWorkerPath}`)),t.userConfig.serviceWorkerParam&&(n.registrationOptions=t.userConfig.serviceWorkerParam)),new kt(e,n)}static getSubscriptionManager(e){const t=e.appConfig,i={safariWebId:t.safariWebId,appId:t.appId,vapidPublicKey:t.vapidPublicKey,onesignalVapidPublicKey:t.onesignalVapidPublicKey};return new _t(e,i)}};class Rt{constructor(e){this.context=e,this.onSessionSent=e.pageViewManager.getPageViewCount()>1}isDeviceIdAvailable(){return Object(a.a)(this,void 0,void 0,function*(){return null!=(yield v.a.getSubscription()).deviceId})}getDeviceId(){return Object(a.a)(this,void 0,void 0,function*(){const{deviceId:e}=yield v.a.getSubscription();if(!e)throw new h(s.NoDeviceId);return e})}createDeviceRecord(){return Object(a.a)(this,void 0,void 0,function*(){return le.createDeviceRecord(this.context.appConfig.appId)})}sendPushDeviceRecordUpdate(e){return Object(a.a)(this,void 0,void 0,function*(){if(!(yield this.context.subscriptionManager.isAlreadyRegisteredWithOneSignal()))return void O.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 gt.updatePlayer(this.context.appConfig.appId,t,Object.assign({notification_types:K.Subscribed},e.serialize())):yield this.sendOnSessionUpdate(e)})}sendOnSessionUpdate(e){return Object(a.a)(this,void 0,void 0,function*(){if(this.onSessionSent)return;if(!this.context.pageViewManager.isFirstPageView())return;if(!(yield this.context.subscriptionManager.isAlreadyRegisteredWithOneSignal()))return void O.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===K.Subscribed||!0===OneSignal.config.enableOnSession)try{this.context.sessionManager.upsertSession(t,e,ae.b.PlayerOnSession),this.onSessionSent=!0}catch(e){O.a.error(`Failed to update user session. Error "${e.message}" ${e.stack}`)}})}sendPlayerCreate(e){return Object(a.a)(this,void 0,void 0,function*(){yield mt.addExternalUserIdToDeviceRecord(e);try{const t=yield gt.createUser(e);return t?(O.a.info("Subscribed to web push and registered with OneSignal",e,t),this.onSessionSent=!0,this.context.sessionManager.upsertSession(t,e,ae.b.PlayerCreate),t):void O.a.error("Failed to create user.")}catch(e){return void O.a.error(`Failed to create user. Error "${e.message}" ${e.stack}`)}})}onSessionAlreadyCalled(){return this.onSessionSent}sendExternalUserIdUpdate(e,t){return Object(a.a)(this,void 0,void 0,function*(){t||(t=yield v.a.getExternalUserIdAuthHash());const i={external_user_id:ne.b.getValueOrDefault(e,""),external_user_id_auth_hash:ne.b.getValueOrDefault(t,void 0)};this.context.secondaryChannelManager.synchronizer.setExternalUserId(i.external_user_id,i.external_user_id_auth_hash);const n=this.sendPushPlayerUpdate(i);(yield this.isDeviceIdAvailable())&&(yield n)})}sendTagsUpdate(e){return Object(a.a)(this,void 0,void 0,function*(){this.context.secondaryChannelManager.synchronizer.setTags(e);const t={tags:e},i=yield v.a.getExternalUserIdAuthHash();i&&(t.external_user_id_auth_hash=i);const n=this.sendPushPlayerUpdate(t);(yield this.isDeviceIdAvailable())&&(yield n)})}sendPushPlayerUpdate(e){return Object(a.a)(this,void 0,void 0,function*(){let{deviceId:t}=yield v.a.getSubscription();if(t||(yield Object(G.d)(OneSignal.EVENTS.REGISTERED),({deviceId:t}=yield v.a.getSubscription())),t)return yield gt.updatePlayer(this.context.appConfig.appId,t,e)})}sendOutcomeDirect(e,t,i,n){return Object(a.a)(this,void 0,void 0,function*(){Object(G.s)("sendOutcomeDirect");const o=yield this.createDeviceRecord(),s={app_id:e,id:i,device_type:o.deliveryPlatform,notification_ids:t,direct:!0};void 0!==n&&(s.weight=n),yield gt.sendOutcome(s)})}sendOutcomeInfluenced(e,t,i,n){return Object(a.a)(this,void 0,void 0,function*(){Object(G.s)("sendOutcomeInfluenced");const o=yield this.createDeviceRecord(),s={app_id:e,id:i,device_type:o.deliveryPlatform,notification_ids:t,direct:!1};void 0!==n&&(s.weight=n),yield gt.sendOutcome(s)})}sendOutcomeUnattributed(e,t,i){return Object(a.a)(this,void 0,void 0,function*(){Object(G.s)("sendOutcomeUnattributed");const n=yield this.createDeviceRecord(),o={app_id:e,id:t,device_type:n.deliveryPlatform};void 0!==i&&(o.weight=i),yield gt.sendOutcome(o)})}}const Ut={reportingThreshold:30,enableOnSessionForUnsubcribed:!1,enableOnFocus:!0},Wt={pageViews:1,timeDelay:0},Bt={actionMessage:"We'd like to show you notifications for the latest news and updates.",acceptButton:"Allow",cancelButton:"Cancel",errorButton:"Try Again",categoryDefaults:{updateMessage:"Update your push notification subscription preferences.",positiveUpdateButton:"Save Preferences",negativeUpdateButton:"Cancel"},savingText:"Saving...",confirmMessage:"Thank You!"},Lt={type:f.Push,text:{actionMessage:Bt.actionMessage,acceptButton:Bt.acceptButton,cancelButton:Bt.cancelButton},autoPrompt:!1,delay:Wt};function Vt(e){return` `}var Ft,Ht,$t;!function(e){e.Stylesheet="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.12/css/intlTelInput.min.css",e.Main="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.12/js/intlTelInput.min.js",e.Utils="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.12/js/utils.js"}(Ft||(Ft={})),function(e){e.Stylesheet="sha512-yye/u0ehQsrVrfSd6biT17t39Rg9kNc+vENcCXZuMz2a+LWFGvXUnYuWUW6pbfYj1jcBb/C39UZw2ciQvwDDvg==",e.Main="sha512-OnkjbJ4TwPpgSmjXACCb5J4cJwi880VRe+vWpPDlr8M38/L3slN5uUAeOeWU2jN+4vN0gImCXFGdJmc0wO4Mig==",e.Utils="sha512-bUcJxlqkiGA3cmoYPuZaLRsyc5ChG9APG4ajom2AXKSlBtOmx4kLV3c8uv/6uSz43FMjI4Q2QI21+D223rT76w=="}(Ht||(Ht={}));class Gt{constructor(e){this.smsInputFieldIsValid=!0,this.emailInputFieldIsValid=!0,this.promptOptions=e}generateHtml(){const e=document.createElement("div");let t,i,n;switch(Object(G.a)(e,V.channelCaptureContainer),e.id=V.channelCaptureContainer,this.promptOptions.type){case f.Sms:t=this.promptOptions.text.smsLabel||"Phone Number",i=this.getInputWithValidationElement(f.Sms,t),e.appendChild(i);break;case f.Email:t=this.promptOptions.text.emailLabel||"Email",n=this.getInputWithValidationElement(f.Email,t),e.appendChild(n);break;case f.SmsAndEmail:t=this.promptOptions.text.emailLabel||"Email",n=this.getInputWithValidationElement(f.Email,t),e.appendChild(n),t=this.promptOptions.text.smsLabel||"Phone Number",i=this.getInputWithValidationElement(f.Sms,t),e.appendChild(i)}return e}getValidationElementWithMessage(e){const t=document.createElement("div"),i=document.createElement("img"),n=document.createElement("p");return n.innerText=e,i.setAttribute("src",W),t.appendChild(i),t.appendChild(n),t}getInputWithValidationElement(e,t){const i=this.getTypeSpecificVariablesForValidationElemGeneration(e),n=document.createElement("label"),o=document.createElement("input"),s=document.createElement("div"),r=document.createElement("div"),a=this.getValidationElementWithMessage(i.message),c=document.createElement("div");return s.setAttribute("style","clear:both"),r.setAttribute("style","clear:both"),Object(G.a)(a,V.onesignalValidationElementHidden),Object(G.a)(a,V.onesignalValidationElement),a.id=i.validationElementId,n.title=t,n.innerText=t,n.htmlFor=i.inputElementId,o.type=i.domElementType,o.id=i.inputElementId,o.tabIndex=i.tabIndex,Object(G.a)(o,i.inputClass),Object(G.a)(c,V.inputWithValidationElement),c.id=i.wrappingDivId,c.appendChild(n),c.appendChild(s),c.appendChild(o),c.appendChild(r),c.appendChild(a),c}getTypeSpecificVariablesForValidationElemGeneration(e){if(e===f.Email)return{message:"Please enter a valid email",domElementType:"email",validationElementId:F.onesignalEmailValidationElement,inputElementId:F.onesignalEmailInput,inputClass:V.onesignalEmailInput,wrappingDivId:F.emailInputWithValidationElement,tabIndex:1};if(e===f.Sms)return{message:"Please enter a valid phone number",domElementType:"tel",validationElementId:F.onesignalSmsValidationElement,inputElementId:F.onesignalSmsInput,inputClass:V.onesignalSmsInput,wrappingDivId:F.smsInputWithValidationElement,tabIndex:2};throw new Error("invalid channel type for input validation")}initializePhoneInputLibrary(){const e=Object(G.l)(`#${F.onesignalSmsInput}`);e&&window.intlTelInput?this.itiOneSignal=window.intlTelInput(e,{autoPlaceholder:"off",separateDialCode:!0}):O.a.error("OneSignal: there was a problem initializing International Telephone Input")}addSmsInputEventListeners(){const e=Object(G.l)(`#${F.onesignalSmsInput}`);e.addEventListener("keyup",t=>{var i;this.smsInputFieldIsValid=this.itiOneSignal.isValidNumber()||""===(null===e||void 0===e?void 0:e.value),"Enter"===t.key&&(null===(i=document.getElementById(j.allowButton))||void 0===i||i.click()),this.updateValidationOnSmsInputChange()}),e.addEventListener("blur",()=>{this.smsInputFieldIsValid=this.itiOneSignal.isValidNumber()||""===(null===e||void 0===e?void 0:e.value),this.updateValidationOnSmsInputChange()})}addEmailInputEventListeners(){const e=Object(G.l)(`#${F.onesignalEmailInput}`);e.addEventListener("keyup",t=>{var i;const n=null===e||void 0===e?void 0:e.value;this.emailInputFieldIsValid=Gt.validateEmailInputWithReturnVal(n),"Enter"===t.key&&(null===(i=document.getElementById(j.allowButton))||void 0===i||i.click()),this.updateValidationOnEmailInputChange()})}updateValidationOnSmsInputChange(){const e=Object(G.l)(`#${F.smsInputWithValidationElement}`),t=Object(G.l)(`#${F.onesignalSmsValidationElement}`);Object(G.v)(e,V.onesignalErrorInput),Object(G.a)(t,V.onesignalValidationElementHidden)}updateValidationOnEmailInputChange(){const e=Object(G.l)(`#${F.emailInputWithValidationElement}`),t=Object(G.l)(`#${F.onesignalEmailValidationElement}`);Object(G.v)(e,V.onesignalErrorInput),Object(G.a)(t,V.onesignalValidationElementHidden)}loadPhoneLibraryScripts(){return Object(a.a)(this,void 0,void 0,function*(){if(OneSignal._didLoadITILibrary)return;const e=document.createElement("script"),t=document.createElement("script"),i=document.createElement("link");e.src=Ft.Main,t.src=Ft.Utils,i.href=Ft.Stylesheet,i.rel="stylesheet",e.integrity=Ht.Main,t.integrity=Ht.Utils,i.integrity=Ht.Stylesheet,e.crossOrigin="anonymous",t.crossOrigin="anonymous",i.crossOrigin="anonymous",document.head.appendChild(e),document.head.appendChild(t),document.head.appendChild(i);const n=new Promise(t=>{e.onload=(()=>{t()})}),o=new Promise(e=>{t.onload=(()=>{e()})});yield Promise.all([n,o]),OneSignal._didLoadITILibrary=!0})}mount(){return Object(a.a)(this,void 0,void 0,function*(){const e=Gt.isUsingSmsInputField(this.promptOptions.type),t=Gt.isUsingEmailInputField(this.promptOptions.type);e&&(yield this.loadPhoneLibraryScripts());const i=this.generateHtml();Object(G.l)(`#${j.body}`).appendChild(i),e&&(this.initializePhoneInputLibrary(),this.addSmsInputEventListeners()),t&&this.addEmailInputEventListeners()})}isEmailInputFieldEmpty(){return""===this.getValueFromEmailInput()}isSmsInputFieldEmpty(){return""===this.getValueFromSmsInput()}getValueFromEmailInput(){const e=Object(G.l)(`#${F.onesignalEmailInput}`);return(null===e||void 0===e?void 0:e.value)||""}getValueFromSmsInput(){return this.itiOneSignal.getNumber(intlTelInputUtils.numberFormat.E164)||""}static showSmsInputError(e){const t=document.querySelector(`#${F.onesignalSmsValidationElement}`),i=document.querySelector(`#${F.smsInputWithValidationElement}`);t&&i?e?(t.classList.remove(V.onesignalValidationElementHidden),i.classList.add(V.onesignalErrorInput)):(t.classList.add(V.onesignalValidationElementHidden),i.classList.remove(V.onesignalErrorInput)):O.a.error("OneSignal: couldn't find slidedown validation element")}static showEmailInputError(e){const t=document.querySelector(`#${F.onesignalEmailValidationElement}`),i=document.querySelector(`#${F.emailInputWithValidationElement}`);t&&i?e?(t.classList.remove(V.onesignalValidationElementHidden),i.classList.add(V.onesignalErrorInput)):(t.classList.add(V.onesignalValidationElementHidden),i.classList.remove(V.onesignalErrorInput)):O.a.error("OneSignal: couldn't find slidedown validation element")}static resetInputErrorStates(e){switch(e){case f.Sms:Gt.showSmsInputError(!1);break;case f.Email:Gt.showEmailInputError(!1);break;case f.SmsAndEmail:Gt.showSmsInputError(!1),Gt.showEmailInputError(!1)}}static validateEmailInputWithReturnVal(e){return/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(e||"")||""===e}static isUsingSmsInputField(e){return e===f.Sms||e===f.SmsAndEmail}static isUsingEmailInputField(e){return e===f.Email||e===f.SmsAndEmail}}!function(e){e[e.InvalidSms=0]="InvalidSms",e[e.InvalidEmail=1]="InvalidEmail",e[e.InvalidEmailAndSms=2]="InvalidEmailAndSms"}($t||($t={}));class zt extends u.a{constructor(e){let t;switch(e){case $t.InvalidEmail:t="Invalid email";break;case $t.InvalidSms:t="Invalid sms";break;case $t.InvalidEmailAndSms:t="Invalid email & sms"}super(t),this.description=$t[e],this.reason=e,Object.setPrototypeOf(this,zt.prototype)}}class qt{constructor(e){var t,i,n;switch(this.savingButton=Bt.savingText,this.errorButton=Bt.errorButton,this.options=e,this.options.text.actionMessage=e.text.actionMessage.substring(0,90),this.options.text.acceptButton=e.text.acceptButton.substring(0,16),this.options.text.cancelButton=e.text.cancelButton.substring(0,16),this.notificationIcons=null,this.channelCaptureContainer=null,this.isShowingFailureState=!1,e.type){case f.Category:this.negativeUpdateButton=null===(t=this.options.text.negativeUpdateButton)||void 0===t?void 0:t.substring(0,16),this.positiveUpdateButton=null===(i=this.options.text.positiveUpdateButton)||void 0===i?void 0:i.substring(0,16),this.updateMessage=null===(n=this.options.text.updateMessage)||void 0===n?void 0:n.substring(0,90),this.tagCategories=e.categories,this.errorButton=ne.a.getValueOrDefault(this.options.text.positiveUpdateButton,Bt.errorButton);break;case f.Sms:case f.Email:case f.SmsAndEmail:this.errorButton=ne.a.getValueOrDefault(this.options.text.acceptButton,Bt.errorButton)}}create(e){return Object(a.a)(this,void 0,void 0,function*(){if(null===this.notificationIcons){const t=yield le.getNotificationIcons();this.notificationIcons=t,this.container.className.includes(N.container)&&Object(G.w)(`#${j.container}`);const i=e&&this.tagCategories?this.positiveUpdateButton:this.options.text.acceptButton,n=e&&this.tagCategories?this.negativeUpdateButton:this.options.text.cancelButton,o=function(e){const{icon:t,messageText:i,positiveButtonText:n,negativeButtonText:o}=e,s=t===N.defaultIcon?U:t,r=t===N.defaultIcon?N.defaultIcon:"",a=document.createElement("div"),c=document.createElement("div"),l=document.createElement("div"),d=document.createElement("div"),u=document.createElement("div"),g=document.createElement("div"),h=document.createElement("button"),p=document.createElement("button"),m=document.createElement("div"),b=document.createElement("div"),f=document.createElement("img");return Object(G.a)(c,N.body),Object(G.a)(d,N.icon),Object(G.a)(l,N.message),Object(G.a)(g,N.footer),Object(G.a)(m,N.clearfix),Object(G.a)(b,N.clearfix),Object(G.a)(h,_.alignRight),Object(G.a)(h,_.primary),Object(G.a)(h,_.slidedownButton),Object(G.a)(p,_.alignRight),Object(G.a)(p,_.secondary),Object(G.a)(p,_.slidedownButton),a.id=j.normalSlidedown,c.id=j.body,u.id=j.loadingContainer,h.id=j.allowButton,p.id=j.cancelButton,g.id=j.footer,r&&Object(G.a)(f,r),f.setAttribute("alt","notification icon"),f.setAttribute("src",s||""),l.innerText=i||"",h.innerText=n||"",p.innerText=o||"",d.appendChild(f),c.appendChild(d),c.appendChild(l),c.appendChild(m),c.appendChild(u),g.appendChild(h),g.appendChild(p),g.appendChild(b),a.appendChild(c),a.appendChild(g),a}({messageText:e&&this.tagCategories?this.updateMessage:this.options.text.actionMessage,icon:this.options.icon||this.getPlatformNotificationIcon(),positiveButtonText:i,negativeButtonText:n}),s=document.createElement("div"),r=document.createElement("div");s.id=j.container,Object(G.a)(s,N.container),Object(G.a)(s,N.reset),Object(G.l)("body").appendChild(s),r.id=j.dialog,Object(G.a)(r,N.dialog),r.appendChild(o),this.container.appendChild(r),Object(G.a)(this.container,l.a.mobile?N.slideUp:N.slideDown),this.allowButton.addEventListener("click",this.onSlidedownAllowed.bind(this)),this.cancelButton.addEventListener("click",this.onSlidedownCanceled.bind(this))}})}static triggerSlidedownEvent(e){return Object(a.a)(this,void 0,void 0,function*(){yield m.a.trigger(e)})}onSlidedownAllowed(e){return Object(a.a)(this,void 0,void 0,function*(){yield qt.triggerSlidedownEvent(qt.EVENTS.ALLOW_CLICK)})}onSlidedownCanceled(e){qt.triggerSlidedownEvent(qt.EVENTS.CANCEL_CLICK),this.close(),qt.triggerSlidedownEvent(qt.EVENTS.CLOSED)}close(){Object(G.a)(this.container,N.closeSlidedown),Object(G.u)(this.dialog,"animationend",(e,t)=>{e.target!==this.dialog||"slideDownExit"!==e.animationName&&"slideUpExit"!==e.animationName||(Object(G.w)(`#${j.container}`),t())},!0)}setSaveState(){this.allowButton.disabled=!0,this.allowButton.textContent=null,this.allowButton.insertAdjacentElement("beforeend",this.getTextSpan(this.savingButton)),this.allowButton.insertAdjacentElement("beforeend",this.getIndicatorHolder()),Object(G.b)(this.buttonIndicatorHolder,"beforeend",Vt(B.whiteLoadingIndicator)),Object(G.a)(this.allowButton,"disabled"),Object(G.a)(this.allowButton,N.savingStateButton)}removeSaveState(){this.allowButton.textContent=this.positiveUpdateButton,Object(G.w)(`#${N.buttonIndicatorHolder}`),this.allowButton.disabled=!1,Object(G.v)(this.allowButton,"disabled"),Object(G.v)(this.allowButton,N.savingStateButton)}setFailureState(){this.allowButton.textContent=null,this.allowButton.insertAdjacentElement("beforeend",this.getTextSpan(this.errorButton)),this.options.type===f.Category&&(this.allowButton.insertAdjacentElement("beforeend",this.getIndicatorHolder()),Object(G.b)(this.buttonIndicatorHolder,"beforeend",function(e="#FFFFFF"){return``}()),Object(G.a)(this.allowButton,"onesignal-error-state-button")),this.isShowingFailureState=!0}setFailureStateForInvalidChannelInput(e){switch(e){case $t.InvalidSms:Gt.showSmsInputError(!0);break;case $t.InvalidEmail:Gt.showEmailInputError(!0);break;case $t.InvalidEmailAndSms:Gt.showSmsInputError(!0),Gt.showEmailInputError(!0)}}removeFailureState(){Object(G.w)("#onesignal-button-indicator-holder"),Object(G.v)(this.allowButton,"onesignal-error-state-button"),E.isSlidedownPushDependent(this.options.type)||Gt.resetInputErrorStates(this.options.type),this.isShowingFailureState=!1}getPlatformNotificationIcon(){return Object(G.m)(this.notificationIcons)}getIndicatorHolder(){const e=document.createElement("div");return e.id=j.buttonIndicatorHolder,Object(G.a)(e,N.buttonIndicatorHolder),e}getTextSpan(e){const t=document.createElement("span");return t.textContent=e,t}get container(){return Object(G.l)(`#${j.container}`)}get dialog(){return Object(G.l)(`#${j.dialog}`)}get allowButton(){return Object(G.l)(`#${j.allowButton}`)}get cancelButton(){return Object(G.l)(`#${j.cancelButton}`)}get buttonIndicatorHolder(){return Object(G.l)(`#${j.buttonIndicatorHolder}`)}get slidedownFooter(){return Object(G.l)(`#${j.footer}`)}static get EVENTS(){return{ALLOW_CLICK:"popoverAllowClick",CANCEL_CLICK:"popoverCancelClick",SHOWN:"popoverShown",CLOSED:"popoverClosed",QUEUED:"popoverQueued"}}}var Kt,Yt,Jt,Qt,Zt=i(23);class Xt{static getEnvironmentInfo(){return{browserType:this.getBrowser(),browserVersion:this.getBrowserVersion(),isHttps:this.isHttps(),isUsingSubscriptionWorkaround:this.isUsingSubscriptionWorkaround(),isBrowserAndSupportsServiceWorkers:this.supportsServiceWorkers(),requiresUserInteraction:this.requiresUserInteraction(),osVersion:this.getOsVersion(),canTalkToServiceWorker:this.canTalkToServiceWorker()}}static getBrowser(){return l.a.chrome?re.Chrome:l.a.msedge?re.Edge:l.a.opera?re.Opera:l.a.firefox?re.Firefox:this.isMacOSSafari()?re.Safari:re.Other}static isMacOSSafari(){return void 0!==window.safari||Object(Zt.a)()}static getBrowserVersion(){return ne.b.parseVersionString(l.a.version)}static isHttps(){return!!window&&(window.location&&"https:"===window.location.protocol)}static isUsingSubscriptionWorkaround(){return y.a.isUsingSubscriptionWorkaround()}static supportsServiceWorkers(){return window.navigator&&"serviceWorker"in window.navigator}static requiresUserInteraction(){return"firefox"===this.getBrowser()&&this.getBrowserVersion()>=72||"safari"===this.getBrowser()&&this.getBrowserVersion()>=12.1}static getOsVersion(){return l.a.osversion}static canTalkToServiceWorker(){return!!window.isSecureContext}}function ei(e){return new Promise(t=>setTimeout(t,e))}class ti{constructor(e){this.isNativePromptShowing=!1,this.context=e,this.eventHooksInstalled=!1}shouldForceSlidedownOverNative(){const{environmentInfo:e}=OneSignal,{browserType:t,browserVersion:i,requiresUserInteraction:n}=e;return"chrome"===t&&Number(i)>=63&&(l.a.tablet||l.a.mobile)||n}spawnAutoPrompts(){return Object(a.a)(this,void 0,void 0,function*(){var e,t;const i=OneSignal.config.userConfig.promptOptions,n=this.shouldForceSlidedownOverNative(),o=this.getDelayedPromptOptions(i,f.Native),s=this.isPageViewConditionMet(o),r=o.enabled&&s,a=n&&r;if(r&&!a)return void this.internalShowDelayedPrompt(f.Native,o.timeDelay||0);const c=!!E.getFirstSlidedownPromptOptionsWithType(null===(e=i.slidedown)||void 0===e?void 0:e.prompts,f.Push);a&&!c&&this.internalShowDelayedPrompt(f.Push,o.timeDelay||0);const l=null===(t=i.slidedown)||void 0===t?void 0:t.prompts;if(l&&(null===l||void 0===l?void 0:l.length)>0)for(let e=0;e0&&(yield ei(1e3*t)),e){case f.Native:yield this.internalShowNativePrompt();break;case f.Push:yield this.internalShowSlidedownPrompt(i);break;case f.Category:yield this.internalShowCategorySlidedown(i);break;case f.Sms:yield this.internalShowSmsSlidedown(i);break;case f.Email:yield this.internalShowEmailSlidedown(i);break;case f.SmsAndEmail:yield this.internalShowSmsAndEmailSlidedown(i);break;default:O.a.error("Invalid Delayed Prompt type")}})}internalShowNativePrompt(){return Object(a.a)(this,void 0,void 0,function*(){y.b.logMethodCall("internalShowNativePrompt"),this.isNativePromptShowing?O.a.debug("Already showing autoprompt. Abort showing a native prompt."):(this.isNativePromptShowing=!0,le.markHttpSlidedownShown(),yield ze.registerForPushNotifications(),this.isNativePromptShowing=!1,je.markPromptDismissedWithType(Se.Push))})}internalShowSlidedownPrompt(e={force:!1}){return Object(a.a)(this,void 0,void 0,function*(){y.b.logMethodCall("internalShowSlidedownPrompt"),e.slidedownPromptOptions||(e.slidedownPromptOptions=Lt),le.markHttpSlidedownShown(),0===(yield this.context.dynamicResourceLoader.loadSdkStylesheet())?(this.eventHooksInstalled||this.installEventHooksForSlidedown(),yield this.context.slidedownManager.createSlidedown(e)):O.a.debug("Not showing slidedown permission message because styles failed to load.")})}internalShowCategorySlidedown(e){return Object(a.a)(this,void 0,void 0,function*(){y.b.logMethodCall("internalShowCategorySlidedown"),yield this.internalShowParticularSlidedown(f.Category,e)})}internalShowSmsSlidedown(e){return Object(a.a)(this,void 0,void 0,function*(){y.b.logMethodCall("internalShowSmsSlidedown"),yield this.internalShowParticularSlidedown(f.Sms,e)})}internalShowEmailSlidedown(e){return Object(a.a)(this,void 0,void 0,function*(){y.b.logMethodCall("internalShowEmailSlidedown"),yield this.internalShowParticularSlidedown(f.Email,e)})}internalShowSmsAndEmailSlidedown(e){return Object(a.a)(this,void 0,void 0,function*(){y.b.logMethodCall("internalShowSmsAndEmailSlidedown"),yield this.internalShowParticularSlidedown(f.SmsAndEmail,e)})}internalShowParticularSlidedown(e,t){return Object(a.a)(this,void 0,void 0,function*(){var i,n;const o=null===(n=null===(i=this.context.appConfig.userConfig.promptOptions)||void 0===i?void 0:i.slidedown)||void 0===n?void 0:n.prompts,s=(null===t||void 0===t?void 0:t.slidedownPromptOptions)||E.getFirstSlidedownPromptOptionsWithType(o,e);if(!s){if(e!==f.Push)return void O.a.error(`OneSignal: slidedown of type '${e}' couldn't be shown. Check your configuration`+" on the OneSignal dashboard or your custom code initialization.");O.a.warn("The OneSignal 'push' slidedown will be shown with default text settings. To customize, see the OneSignal documentation.")}yield this.internalShowSlidedownPrompt(Object.assign(Object.assign({},t),{slidedownPromptOptions:s}))})}installEventHooksForSlidedown(){this.eventHooksInstalled=!0,OneSignal.emitter.on(qt.EVENTS.SHOWN,()=>{this.context.slidedownManager.setIsSlidedownShowing(!0)}),OneSignal.emitter.on(qt.EVENTS.CLOSED,()=>{this.context.slidedownManager.setIsSlidedownShowing(!1),this.context.slidedownManager.showQueued()}),OneSignal.emitter.on(qt.EVENTS.ALLOW_CLICK,()=>Object(a.a)(this,void 0,void 0,function*(){yield this.context.slidedownManager.handleAllowClick(),m.a.trigger(OneSignal.EVENTS.TEST_FINISHED_ALLOW_CLICK_HANDLING)})),OneSignal.emitter.on(qt.EVENTS.CANCEL_CLICK,()=>{const{type:e}=OneSignal.slidedown.options;switch(e){case f.Push:case f.Category:O.a.debug("Setting flag to not show the slidedown to the user again."),je.markPromptDismissedWithType(Se.Push);break;default:O.a.debug("Setting flag to not show the slidedown to the user again."),je.markPromptDismissedWithType(Se.NonPush)}})}isPageViewConditionMet(e){if(!e||void 0===e.pageViews)return!1;if(!e.autoPrompt||!e.enabled)return!1;return this.context.pageViewManager.getLocalPageViewCount()>=e.pageViews}getDelayedPromptOptions(e,t){var i,n,o,s;const r={enabled:!1,autoPrompt:!1,timeDelay:Wt.timeDelay,pageViews:Wt.pageViews};if(!e||!e.native||!e.slidedown)return r;switch(t){case f.Native:const a=e.native;return{enabled:null===a||void 0===a?void 0:a.enabled,autoPrompt:null===a||void 0===a?void 0:a.autoPrompt,timeDelay:null===a||void 0===a?void 0:a.timeDelay,pageViews:null===a||void 0===a?void 0:a.pageViews};case f.Push:case f.Category:case f.Email:case f.Sms:case f.SmsAndEmail:const{userConfig:c}=this.context.appConfig,l=E.getFirstSlidedownPromptOptionsWithType((null===(n=null===(i=c.promptOptions)||void 0===i?void 0:i.slidedown)||void 0===n?void 0:n.prompts)||[],t);return{enabled:!!l,autoPrompt:!!(null===l||void 0===l?void 0:l.autoPrompt),timeDelay:null===(o=null===l||void 0===l?void 0:l.delay)||void 0===o?void 0:o.timeDelay,pageViews:null===(s=null===l||void 0===l?void 0:l.delay)||void 0===s?void 0:s.pageViews};default:return r}}}class ii{constructor(e){this.onSessionSent=!1,this.context=e}notifySWToUpsertSession(e,t,i){return Object(a.a)(this,void 0,void 0,function*(){const n=y.a.isHttps(),o={deviceId:e,deviceRecord:t.serialize(),sessionThreshold:this.context.appConfig.sessionThreshold||0,enableSessionDuration:!!this.context.appConfig.enableSessionDuration,sessionOrigin:i,isHttps:n,isSafari:y.a.isSafari(),outcomesConfig:this.context.appConfig.userConfig.outcomes};this.context.environmentInfo.isBrowserAndSupportsServiceWorkers&&!this.context.environmentInfo.isUsingSubscriptionWorkaround?(O.a.debug("Notify SW to upsert session"),yield this.context.workerMessenger.unicast(de.SessionUpsert,o)):this.context.environmentInfo.canTalkToServiceWorker&&this.context.environmentInfo.isUsingSubscriptionWorkaround?(O.a.debug("Notify iframe to notify SW to upsert session"),yield OneSignal.proxyFrameHost.runCommand(OneSignal.POSTMAM_COMMANDS.SESSION_UPSERT,o)):O.a.debug("Notify upsert: do nothing")})}notifySWToDeactivateSession(e,t,i){return Object(a.a)(this,void 0,void 0,function*(){const n=y.a.isHttps(),o={deviceId:e,deviceRecord:t?t.serialize():void 0,sessionThreshold:this.context.appConfig.sessionThreshold,enableSessionDuration:this.context.appConfig.enableSessionDuration,sessionOrigin:i,isHttps:n,isSafari:y.a.isSafari(),outcomesConfig:this.context.appConfig.userConfig.outcomes};this.context.environmentInfo.isBrowserAndSupportsServiceWorkers&&!this.context.environmentInfo.isUsingSubscriptionWorkaround?(O.a.debug("Notify SW to deactivate session"),yield this.context.workerMessenger.unicast(de.SessionDeactivate,o)):this.context.environmentInfo.canTalkToServiceWorker&&this.context.environmentInfo.isUsingSubscriptionWorkaround?(O.a.debug("Notify SW to deactivate session"),yield OneSignal.proxyFrameHost.runCommand(OneSignal.POSTMAM_COMMANDS.SESSION_DEACTIVATE,o)):O.a.debug("Notify deactivate: do nothing")})}handleVisibilityChange(){return Object(a.a)(this,void 0,void 0,function*(){const e=document.visibilityState,[t,i]=yield Promise.all([le.getDeviceId(),le.createDeviceRecord(this.context.appConfig.appId,!0)]);if("visible"===e)return this.setupOnFocusAndOnBlurForSession(),O.a.debug("handleVisibilityChange","visible",`hasFocus: ${document.hasFocus()}`),void(document.hasFocus()&&(yield this.notifySWToUpsertSession(t,i,ae.b.VisibilityVisible)));if("hidden"!==e)O.a.warn("Unhandled visibility state happened",e);else{O.a.debug("handleVisibilityChange","hidden"),OneSignal.cache.focusHandler&&OneSignal.cache.isFocusEventSetup&&(window.removeEventListener("focus",OneSignal.cache.focusHandler,!0),OneSignal.cache.isFocusEventSetup=!1),OneSignal.cache.blurHandler&&OneSignal.cache.isBlurEventSetup&&(window.removeEventListener("blur",OneSignal.cache.blurHandler,!0),OneSignal.cache.isBlurEventSetup=!1);const[e,t]=yield Promise.all([le.getDeviceId(),le.createDeviceRecord(this.context.appConfig.appId)]);yield this.notifySWToDeactivateSession(e,t,ae.b.VisibilityHidden)}})}handleOnBeforeUnload(){return Object(a.a)(this,void 0,void 0,function*(){const e=y.a.isHttps(),t={sessionThreshold:this.context.appConfig.sessionThreshold,enableSessionDuration:this.context.appConfig.enableSessionDuration,sessionOrigin:ae.b.BeforeUnload,isHttps:e,isSafari:y.a.isSafari(),outcomesConfig:this.context.appConfig.userConfig.outcomes};e?(O.a.debug("Notify SW to deactivate session (beforeunload)"),this.context.workerMessenger.directPostMessageToSW(de.SessionDeactivate,t)):(O.a.debug("Notify iframe to notify SW to deactivate session (beforeunload)"),yield OneSignal.proxyFrameHost.runCommand(OneSignal.POSTMAM_COMMANDS.SESSION_DEACTIVATE,t))})}handleOnFocus(e){return Object(a.a)(this,void 0,void 0,function*(){if(O.a.debug("handleOnFocus",e),e.target!==window)return;const[t,i]=yield Promise.all([le.getDeviceId(),le.createDeviceRecord(this.context.appConfig.appId,!0)]);yield this.notifySWToUpsertSession(t,i,ae.b.Focus)})}handleOnBlur(e){return Object(a.a)(this,void 0,void 0,function*(){if(O.a.debug("handleOnBlur",e),e.target!==window)return;const[t,i]=yield Promise.all([le.getDeviceId(),le.createDeviceRecord(this.context.appConfig.appId)]);yield this.notifySWToDeactivateSession(t,i,ae.b.Blur)})}upsertSession(e,t,i){return Object(a.a)(this,void 0,void 0,function*(){const n=this.notifySWToUpsertSession(e,t,i);this.context.environmentInfo.isBrowserAndSupportsServiceWorkers||this.context.environmentInfo.isUsingSubscriptionWorkaround?this.context.environmentInfo.canTalkToServiceWorker?this.setupSessionEventListeners():(this.onSessionSent=i===ae.b.PlayerCreate,OneSignal.emitter.emit(OneSignal.EVENTS.SESSION_STARTED)):this.context.environmentInfo.isBrowserAndSupportsServiceWorkers||this.context.environmentInfo.isUsingSubscriptionWorkaround||(this.onSessionSent=i===ae.b.PlayerCreate,OneSignal.emitter.emit(OneSignal.EVENTS.SESSION_STARTED)),yield n})}setupSessionEventListeners(){this.context.environmentInfo.isBrowserAndSupportsServiceWorkers||this.context.environmentInfo.isUsingSubscriptionWorkaround?this.context.environmentInfo.canTalkToServiceWorker?(this.setupOnFocusAndOnBlurForSession(),OneSignal.cache.isVisibilityChangeEventSetup||(document.addEventListener("visibilitychange",this.handleVisibilityChange.bind(this),!0),OneSignal.cache.isVisibilityChangeEventSetup=!0),OneSignal.cache.isBeforeUnloadEventSetup||(window.addEventListener("beforeunload",e=>{this.handleOnBeforeUnload(),delete e.returnValue},!0),OneSignal.cache.isBeforeUnloadEventSetup=!0)):O.a.debug("Not setting session event listeners. Can't talk to ServiceWorker due being hosted on an HTTP page."):O.a.debug("Not setting session event listeners. No service worker possible.")}setupOnFocusAndOnBlurForSession(){O.a.debug("setupOnFocusAndOnBlurForSession"),OneSignal.cache.focusHandler||(OneSignal.cache.focusHandler=this.handleOnFocus.bind(this)),OneSignal.cache.isFocusEventSetup||(window.addEventListener("focus",OneSignal.cache.focusHandler,!0),OneSignal.cache.isFocusEventSetup=!0),OneSignal.cache.blurHandler||(OneSignal.cache.blurHandler=this.handleOnBlur.bind(this)),OneSignal.cache.isBlurEventSetup||(window.addEventListener("blur",OneSignal.cache.blurHandler,!0),OneSignal.cache.isBlurEventSetup=!0)}static setupSessionEventListenersForHttp(){OneSignal.context&&OneSignal.context.sessionManager?OneSignal.context.sessionManager.setupSessionEventListeners():O.a.error("OneSignal.context not available for http to setup session event listeners.")}sendOnSessionUpdateFromPage(e){return Object(a.a)(this,void 0,void 0,function*(){if(this.onSessionSent)return;if(!this.context.pageViewManager.isFirstPageView())return;if(!(yield this.context.subscriptionManager.isAlreadyRegisteredWithOneSignal()))return void O.a.debug("Not sending the on session because user is not registered with OneSignal (no device id)");const t=yield le.getDeviceId();if(e||(e=yield le.createDeviceRecord(this.context.appConfig.appId)),e.subscriptionState===K.Subscribed||!0===OneSignal.config.enableOnSession){try{const i=yield gt.updateUserSession(t,e);if(this.onSessionSent=!0,i!==t){const e=yield v.a.getSubscription();e.deviceId=i,yield v.a.setSubscription(e)}}catch(e){O.a.error(`Failed to update user session. Error "${e.message}" ${e.stack}`)}yield this.context.secondaryChannelManager.synchronizer.onSession()}})}}class ni{static convertTagsApiToBooleans(e){const t={};return Object.keys(e).forEach(i=>{t[i]="1"===e[i]}),t}static convertTagsBooleansToApi(e){const t={};return Object.keys(e).forEach(i=>{t[i]=!0===e[i]?"1":"0"}),t}static getObjectDifference(e,t){const i={};return Object.keys(e).forEach(n=>{t[n]!==e[n]&&(i[n]=e[n])}),i}static markAllTagsAsSpecified(e,t){e.forEach(e=>{e.checked=t})}static isTagObjectEmpty(e){return 0===Object.keys(e).length}static getCheckedTagCategories(e,t){if(!t)return e;if(ni.isTagObjectEmpty(t)){const t=Object(G.h)(e);return ni.markAllTagsAsSpecified(t,!0),t}return Object(G.h)(e).map(e=>{const i=t[e.tag];return e.checked=ni.getCheckedStatusForTagValue(i),e})}static getCheckedStatusForTagValue(e){return void 0===e||e}static limitCategoriesToMaxCount(e,t){let i=Object(G.h)(e);return i=e.slice(0,t)}}class oi{constructor(e){this.tagsFromTaggingContainer={},this.remoteTags={},this.context=e}sendTags(){return Object(a.a)(this,void 0,void 0,function*(){O.a.info("Category Slidedown Local Tags:",this.tagsFromTaggingContainer);const e=ni.convertTagsBooleansToApi(this.tagsFromTaggingContainer),t=ni.getObjectDifference(e,this.remoteTags);return ni.isTagObjectEmpty(t)?(O.a.warn("OneSignal: no change detected in Category preferences. Skipping tag update."),t):yield OneSignal.sendTags(t)})}storeTagValuesToUpdate(e){this.tagsFromTaggingContainer=e}storeRemotePlayerTags(e){this.context.tagManager.remoteTags=e}}class si{mount(e,t){const i=this.generateHtml(e,t);Object(G.l)(`#${j.body}`).appendChild(i),this.taggingContainer&&this.taggingContainer.addEventListener("change",this.toggleCheckedTag);const n=Object(G.l)(`#${j.allowButton}`);n.disabled=!1,Object(G.v)(n,"disabled"),Object(G.w)(`#${j.loadingContainer}`)}load(){const e=Object(G.l)(`#${j.loadingContainer}`),t=Object(G.l)(`#${j.allowButton}`),i=document.createElement("div");Object(G.a)(e,`${N.loadingContainer}`),Object(G.a)(i,D.loadingMessage),Object(G.a)(t,"disabled"),Object(G.b)(e,"beforeend",Vt(B.greyLoadingIndicator)),i.innerText=L.fetchingPreferences,e.appendChild(i),t.disabled=!0}generateHtml(e,t){const i=ni.getCheckedTagCategories(e,t),n=i.filter(e=>i.indexOf(e)%2==0),o=i.filter(e=>i.indexOf(e)%2),s=document.createElement("div"),r=document.createElement("div"),a=document.createElement("div");return Object(G.a)(s,D.taggingContainerCol),Object(G.a)(r,D.taggingContainerCol),Object(G.a)(a,D.taggingContainer),a.id=R.taggingContainer,n.forEach(e=>{s.appendChild(this.getCategoryLabelElement(e))}),o.forEach(e=>{r.appendChild(this.getCategoryLabelElement(e))}),a.appendChild(s),a.appendChild(r),a}getCategoryLabelElement(e){const{label:t}=e,i=document.createElement("label"),n=document.createElement("span"),o=document.createElement("input"),s=document.createElement("span"),r=document.createElement("div"),a=document.createElement("div");return Object(G.a)(i,D.categoryLabel),Object(G.a)(n,D.categoryLabelText),Object(G.a)(o,D.categoryLabelInput),Object(G.a)(s,D.checkmark),i.title=t,n.innerText=t,o.type="checkbox",o.value=e.tag,o.checked=!!e.checked,i.appendChild(n),i.appendChild(o),i.appendChild(s),r.setAttribute("style","clear:both"),a.appendChild(i),a.appendChild(r),a}get taggingContainer(){const e=`#${j.body} > div.${D.taggingContainer}`;return Object(G.l)(e)}toggleCheckedTag(e){const t=e.target;if(t&&"checkbox"===t.getAttribute("type")){const e=t.checked;t.setAttribute("checked",e.toString())}}static getValuesFromTaggingContainer(){const e=`#${j.body} > div.${D.taggingContainer}`+"> div > div > label > input[type=checkbox]",t={};return document.querySelectorAll(e).forEach(e=>{t[e.value]=e.checked}),t}}class ri extends u.a{constructor(e){super(`The permission message of type ${e||"unknown"} was previously dismissed.`),Object.setPrototypeOf(this,ri.prototype)}}class ai{constructor(e){this.message=e}show(){return Object(a.a)(this,void 0,void 0,function*(){const e=document.createElement("div"),t=document.createElement("p");t.innerText=this.message,e.appendChild(t);const i=document.createElement("div"),n=document.createElement("div");i.id=j.container,e.id=k.toastText,Object(G.a)(e,x.toastText),Object(G.a)(i,N.container),Object(G.a)(i,N.reset),Object(G.l)("body").appendChild(i),n.id=j.dialog,Object(G.a)(n,N.dialog),n.appendChild(e),this.container.appendChild(n),Object(G.a)(this.container,l.a.mobile?N.slideUp:N.slideDown),ai.triggerSlidedownEvent(ai.EVENTS.SHOWN)})}static triggerSlidedownEvent(e){return Object(a.a)(this,void 0,void 0,function*(){yield m.a.trigger(e)})}close(){Object(G.a)(this.container,N.closeSlidedown),Object(G.u)(this.dialog,"animationend",(e,t)=>{e.target!==this.dialog||"slideDownExit"!==e.animationName&&"slideUpExit"!==e.animationName||(Object(G.w)(`#${j.container}`),t())},!0)}get container(){return Object(G.l)(`#${j.container}`)}get dialog(){return Object(G.l)(`#${j.dialog}`)}static get EVENTS(){return{SHOWN:"toastShown",CLOSED:"toastClosed"}}}class ci extends u.a{constructor(){super("This operation can only be performed when the user is not subscribed."),Object.setPrototypeOf(this,ci.prototype)}}class li extends u.a{constructor(e){super(`This operation can only be performed when the channel '${e}' does not yet exist.`),Object.setPrototypeOf(this,li.prototype)}}class di{constructor(e,t){this.secondaryChannelManager=t,this.context=e,this.slidedownQueue=[],this.isSlidedownShowing=!1}checkIfSlidedownShouldBeShown(e){return Object(a.a)(this,void 0,void 0,function*(){var t;const i=(yield OneSignal.privateGetNotificationPermission())===S.Denied,n=yield OneSignal.privateIsPushNotificationsEnabled(),o=yield OneSignal.privateGetSubscription();let r;const a=null===(t=e.slidedownPromptOptions)||void 0===t?void 0:t.type;let c=!1;if(a&&(c=E.isSlidedownPushDependent(a)),c){if(n)return!!e.isInUpdateMode||(O.a.info(new ci),!1);if(r=je.wasPromptOfTypeDismissed(Se.Push),!o)throw new h(s.OptedOut);if(i)return O.a.info(new oe(te.Blocked)),!1}else{if(!e.force){const e=!!(yield v.a.getSMSProfile()).subscriptionId,t=!!(yield v.a.getEmailProfile()).subscriptionId,i=e&&t;if(e&&a===f.Sms)return O.a.info(new li(f.Sms)),!1;if(t&&a===f.Email)return O.a.info(new li(f.Email)),!1;if(i&&a===f.SmsAndEmail)return O.a.info(new li(f.SmsAndEmail)),!1}r=je.wasPromptOfTypeDismissed(Se.NonPush)}return!(r&&!e.force&&!e.isInUpdateMode)||(O.a.info(new ri(a)),!1)})}registerForPush(){const e={autoAccept:!OneSignal.environmentInfo.requiresUserInteraction,slidedown:!0};ze.registerForPushNotifications(e)}handleAllowForCategoryType(){return Object(a.a)(this,void 0,void 0,function*(){const e=si.getValuesFromTaggingContainer();this.context.tagManager.storeTagValuesToUpdate(e),A.getIsPushNotificationsEnabled()?(OneSignal.slidedown.setSaveState(),yield this.context.tagManager.sendTags(!0)):this.registerForPush()})}handleAllowForEmailType(){return Object(a.a)(this,void 0,void 0,function*(){const e=OneSignal.slidedown.channelCaptureContainer.emailInputFieldIsValid,t=OneSignal.slidedown.channelCaptureContainer.isEmailInputFieldEmpty();if(!e||t)throw new zt($t.InvalidEmail);const i=OneSignal.slidedown.channelCaptureContainer.getValueFromEmailInput();this.updateEmail(i)})}handleAllowForSmsType(){return Object(a.a)(this,void 0,void 0,function*(){const e=OneSignal.slidedown.channelCaptureContainer.smsInputFieldIsValid,t=OneSignal.slidedown.channelCaptureContainer.isSmsInputFieldEmpty();if(!e||t)throw new zt($t.InvalidSms);const i=OneSignal.slidedown.channelCaptureContainer.getValueFromSmsInput();this.updateSMS(i)})}handleAllowForSmsAndEmailType(){return Object(a.a)(this,void 0,void 0,function*(){const e=OneSignal.slidedown.channelCaptureContainer.smsInputFieldIsValid,t=OneSignal.slidedown.channelCaptureContainer.emailInputFieldIsValid,i=OneSignal.slidedown.channelCaptureContainer.isEmailInputFieldEmpty(),n=OneSignal.slidedown.channelCaptureContainer.isSmsInputFieldEmpty();if(!e&&!t||i&&n)throw new zt($t.InvalidEmailAndSms);const o=OneSignal.slidedown.channelCaptureContainer.getValueFromEmailInput(),s=OneSignal.slidedown.channelCaptureContainer.getValueFromSmsInput();if(!t)throw new zt($t.InvalidEmail);if(i||this.updateEmail(o),!e)throw new zt($t.InvalidSms);n||this.updateSMS(s)})}updateEmail(e){this.secondaryChannelManager.email.setIdentifier(e)}updateSMS(e){this.secondaryChannelManager.sms.setIdentifier(e)}showConfirmationToast(){return Object(a.a)(this,void 0,void 0,function*(){const{confirmMessage:e}=OneSignal.slidedown.options.text;yield ei(1e3);const t=new ai(e);yield t.show(),yield ei(5e3),t.close(),ai.triggerSlidedownEvent(ai.EVENTS.CLOSED)})}mountAuxiliaryContainers(e){return Object(a.a)(this,void 0,void 0,function*(){var t;switch(null===(t=e.slidedownPromptOptions)||void 0===t?void 0:t.type){case f.Category:this.mountTaggingContainer(e);break;case f.Email:case f.Sms:case f.SmsAndEmail:yield this.mountChannelCaptureContainer(e)}})}mountTaggingContainer(e){return Object(a.a)(this,void 0,void 0,function*(){var t;y.a.logMethodCall("mountTaggingContainer");try{let i={};const n=new si,o=null===(t=e.slidedownPromptOptions)||void 0===t?void 0:t.categories;if(!o)throw new Error("Categories not defined");if(e.isInUpdateMode){n.load();const e=yield OneSignal.getTags();this.context.tagManager.storeRemotePlayerTags(e),i=ni.convertTagsApiToBooleans(e)}else ni.markAllTagsAsSpecified(o,!0);n.mount(o,i)}catch(e){O.a.error("OneSignal: Attempted to create tagging container with error",e)}})}mountChannelCaptureContainer(e){return Object(a.a)(this,void 0,void 0,function*(){y.a.logMethodCall("mountChannelCaptureContainer");try{if(e.slidedownPromptOptions){const t=new Gt(e.slidedownPromptOptions);t.mount(),OneSignal.slidedown.channelCaptureContainer=t}}catch(e){O.a.error("OneSignal: Attempted to create channel capture container with error",e)}})}handleAllowClick(){return Object(a.a)(this,void 0,void 0,function*(){const{slidedown:e}=OneSignal,t=e.options.type;e.isShowingFailureState&&e.removeFailureState();try{switch(t){case f.Push:this.registerForPush();break;case f.Category:yield this.handleAllowForCategoryType();break;case f.Email:yield this.handleAllowForEmailType();break;case f.Sms:yield this.handleAllowForSmsType();break;case f.SmsAndEmail:yield this.handleAllowForSmsAndEmailType()}}catch(t){return O.a.warn("OneSignal Slidedown failed to update:",t),e.removeSaveState(),e.setFailureState(),void(void 0!==t.reason&&e.setFailureStateForInvalidChannelInput(t.reason))}switch(e&&(e.close(),E.isSlidedownPushDependent(t)||(yield this.showConfirmationToast()),yield ei(1e3),qt.triggerSlidedownEvent(qt.EVENTS.CLOSED)),t){case f.Push:case f.Category:O.a.debug("Setting flag to not show the slidedown to the user again."),je.markPromptDismissedWithType(Se.Push);break;default:O.a.debug("Setting flag to not show the slidedown to the user again."),je.markPromptDismissedWithType(Se.NonPush)}})}setIsSlidedownShowing(e){this.isSlidedownShowing=e}showQueued(){return Object(a.a)(this,void 0,void 0,function*(){if(this.slidedownQueue.length>0){const e=this.dequeue();e&&(yield this.createSlidedown(e))}})}enqueue(e){this.slidedownQueue.push(e),qt.triggerSlidedownEvent(qt.EVENTS.QUEUED)}dequeue(){return this.slidedownQueue.shift()}createSlidedown(e){return Object(a.a)(this,void 0,void 0,function*(){y.a.logMethodCall("createSlidedown");try{if(!(yield this.checkIfSlidedownShouldBeShown(e)))return}catch(e){return void O.a.warn("checkIfSlidedownShouldBeShown returned an error",e)}if(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(qt.EVENTS.CLOSED,()=>{OneSignal.notifyButton&&OneSignal.notifyButton.options.enable&&OneSignal.notifyButton.launcher.show()})}(),this.isSlidedownShowing)this.enqueue(e);else try{this.setIsSlidedownShowing(!0);const t=e.slidedownPromptOptions||Lt;OneSignal.slidedown=new qt(t),yield OneSignal.slidedown.create(e.isInUpdateMode),yield this.mountAuxiliaryContainers(e),O.a.debug("Showing OneSignal Slidedown"),qt.triggerSlidedownEvent(qt.EVENTS.SHOWN)}catch(e){O.a.error("There was an error showing the OneSignal Slidedown:",e),this.setIsSlidedownShowing(!1),OneSignal.slidedown.close()}})}}class ui{constructor(e){this.appConfig=e,"undefined"!=typeof OneSignal&&OneSignal.environmentInfo&&(this.environmentInfo=OneSignal.environmentInfo),this.secondaryChannelManager=new At,this.subscriptionManager=Dt.getSubscriptionManager(this),this.serviceWorkerManager=Dt.getServiceWorkerManager(this),this.pageViewManager=new qe,this.permissionManager=new P,this.workerMessenger=new be(this),this.updateManager=new Rt(this),this.sessionManager=new ii(this),this.tagManager=new oi(this),this.slidedownManager=new di(this,this.secondaryChannelManager),this.promptsManager=new ti(this),this.dynamicResourceLoader=new fe,this.metricsManager=new $e(e.metrics.enable,e.metrics.mixpanelReportingToken)}}!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"}(Kt||(Kt={})),function(e){e.Exact="exact",e.Origin="origin"}(Yt||(Yt={})),function(e){e.Navigate="navigate",e.Focus="focus"}(Jt||(Jt={}));class gi{static upgradeConfigToVersionTwo(e){var t,i,n;gi.isPromptOptionsVersion0(e.promptOptions)&&(e.promptOptions=gi.convertConfigToVersionOne(e.promptOptions)),gi.isSlidedownConfigVersion1(null===(t=e.promptOptions)||void 0===t?void 0:t.slidedown)&&(null===(i=e.promptOptions)||void 0===i?void 0:i.slidedown)&&(e.promptOptions.slidedown=gi.convertConfigToVersionTwo(null===(n=e.promptOptions)||void 0===n?void 0:n.slidedown))}static convertConfigToVersionOne(e){e.slidedown||(e.slidedown={});const{acceptButtonText:t,cancelButtonText:i,actionMessage:n}=e.slidedown,o=e.acceptButtonText||e.acceptButton,s=e.cancelButtonText||e.cancelButton;return e.slidedown.acceptButtonText=t||o,e.slidedown.cancelButtonText=i||s,e.slidedown.actionMessage=n||e.actionMessage,e}static convertConfigToVersionTwo(e){var t,i,n,o;const s=E.isCategorySlidedownConfiguredVersion1(e)?f.Category:f.Push;let r,a;return s===f.Category&&(r=null===(t=e.categories)||void 0===t?void 0:t.positiveUpdateButton,a=null===(i=e.categories)||void 0===i?void 0:i.negativeUpdateButton),{prompts:[...e.prompts||[],{type:s,autoPrompt:e.autoPrompt,text:{actionMessage:e.actionMessage,acceptButton:e.acceptButton||e.acceptButtonText,cancelButton:e.cancelButton||e.cancelButtonText,positiveUpdateButton:r,negativeUpdateButton:a,updateMessage:null===(n=null===e||void 0===e?void 0:e.categories)||void 0===n?void 0:n.updateMessage},delay:{pageViews:e.pageViews,timeDelay:e.timeDelay},categories:null===(o=null===e||void 0===e?void 0:e.categories)||void 0===o?void 0:o.tags}]}}static isPromptOptionsVersion0(e){if(e){const t=["acceptButtonText","cancelButtonText","actionMessage"];for(let i=0;i{var t,i,n,o,s,r,a,c,l;if(e.type=ne.b.getValueOrDefault(e.type,f.Push),e.type===f.Category&&(e.text=Object.assign(Object.assign({},e.text),{positiveUpdateButton:ne.b.getValueOrDefault(null===(t=e.text)||void 0===t?void 0:t.positiveUpdateButton,Bt.categoryDefaults.positiveUpdateButton),negativeUpdateButton:ne.b.getValueOrDefault(null===(i=e.text)||void 0===i?void 0:i.negativeUpdateButton,Bt.categoryDefaults.negativeUpdateButton),updateMessage:ne.b.getValueOrDefault(null===(n=e.text)||void 0===n?void 0:n.updateMessage,Bt.categoryDefaults.updateMessage)})),e.text=Object.assign(Object.assign({},e.text),{actionMessage:ne.b.getValueOrDefault(null===(o=e.text)||void 0===o?void 0:o.actionMessage,Bt.actionMessage),acceptButton:ne.b.getValueOrDefault(null===(s=e.text)||void 0===s?void 0:s.acceptButton,Bt.acceptButton),cancelButton:ne.b.getValueOrDefault(null===(r=e.text)||void 0===r?void 0:r.cancelButton,Bt.cancelButton),confirmMessage:ne.b.getValueOrDefault(null===(a=e.text)||void 0===a?void 0:a.confirmMessage,Bt.confirmMessage)}),e.autoPrompt=ne.b.getValueOrDefault(e.autoPrompt,!0),e.delay={pageViews:ne.b.getValueOrDefault(null===(c=e.delay)||void 0===c?void 0:c.pageViews,Wt.pageViews),timeDelay:ne.b.getValueOrDefault(null===(l=e.delay)||void 0===l?void 0:l.timeDelay,Wt.timeDelay)},e.categories){const{categories:t}=e;e.categories=ni.limitCategoriesToMaxCount(t,hi)}return e}):(c.slidedown={prompts:[]},c.slidedown.prompts=[Lt]),c.native?(c.native.enabled=!!c.native.enabled,c.native.autoPrompt=c.native.hasOwnProperty("autoPrompt")?!!c.native.enabled&&!!c.native.autoPrompt:!!c.native.enabled,c.native.pageViews=ne.b.getValueOrDefault(c.native.pageViews,Wt.pageViews),c.native.timeDelay=ne.b.getValueOrDefault(c.native.timeDelay,Wt.timeDelay)):c.native={enabled:!1,autoPrompt:!1,pageViews:Wt.pageViews,timeDelay:Wt.timeDelay},!0===i.autoRegister)if(n){c.native.enabled=!1,c.native.autoPrompt=!1;const e={actionMessage:Bt.actionMessage,acceptButton:Bt.acceptButton,cancelButton:Bt.cancelButton};c.slidedown.prompts=[{type:f.Push,autoPrompt:!0,text:e}]}else c.native.enabled=!0,c.native.autoPrompt=!0;return c.autoPrompt=c.native.autoPrompt||E.isSlidedownAutoPromptConfigured(c.slidedown.prompts),c}static getPromptOptionsForDashboardConfiguration(e){const t=e.config.staticPrompts,i=t.native?{enabled:t.native.enabled,autoPrompt:t.native.enabled&&!1!==t.native.autoPrompt,pageViews:ne.b.getValueOrDefault(t.native.pageViews,Wt.pageViews),timeDelay:ne.b.getValueOrDefault(t.native.timeDelay,Wt.timeDelay)}:{enabled:!1,autoPrompt:!1,pageViews:Wt.pageViews,timeDelay:Wt.timeDelay},{prompts:n}=t.slidedown;return{autoPrompt:i.autoPrompt||E.isSlidedownAutoPromptConfigured(n),native:i,slidedown:{prompts: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 Qt.Dashboard:return{appId:i.app_id,autoRegister:!1,autoResubscribe:i.config.autoResubscribe,path:i.config.serviceWorker.path,serviceWorkerPath:i.config.serviceWorker.workerName,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,outcomes:{direct:i.config.outcomes.direct,indirect:{enabled:i.config.outcomes.indirect.enabled,influencedTimePeriodMin:i.config.outcomes.indirect.notification_attribution.minutes_since_displayed,influencedNotificationsLimit:i.config.outcomes.indirect.notification_attribution.limit},unattributed:i.config.outcomes.unattributed}};case Qt.JavaScript:const o="undefined"!=typeof OneSignal&&!!OneSignal.SERVICE_WORKER_PARAM,s="undefined"!=typeof OneSignal&&!!OneSignal.SERVICE_WORKER_PATH,r=o?OneSignal.SERVICE_WORKER_PARAM:{scope:"/"},a=s?OneSignal.SERVICE_WORKER_PATH:"OneSignalSDKWorker.js",c=Object.assign(Object.assign(Object.assign(Object.assign({},t),{promptOptions:this.injectDefaultsIntoPromptOptions(t.promptOptions,i.config.staticPrompts,t,n)}),{serviceWorkerParam:t.serviceWorkerParam?t.serviceWorkerParam:r,serviceWorkerPath:t.serviceWorkerPath?t.serviceWorkerPath:a,path:t.path?t.path:"/"}),{outcomes:{direct:i.config.outcomes.direct,indirect:{enabled:i.config.outcomes.indirect.enabled,influencedTimePeriodMin:i.config.outcomes.indirect.notification_attribution.minutes_since_displayed,influencedNotificationsLimit:i.config.outcomes.indirect.notification_attribution.limit},unattributed:i.config.outcomes.unattributed}});return t.hasOwnProperty("autoResubscribe")?c.autoResubscribe=!!t.autoResubscribe:t.hasOwnProperty("autoRegister")?c.autoResubscribe=!!t.autoRegister:c.autoResubscribe=!!i.config.autoResubscribe,c}}static getSubdomainForConfigIntegrationKind(e,t,i){const n=this.getIntegrationCapabilities(e),o=t.subdomainName;let s="";switch(n.configuration){case Qt.Dashboard:s=i.config.siteInfo.proxyOriginEnabled?i.config.siteInfo.proxyOrigin:void 0;break;case Qt.JavaScript:s=i.config.subdomain}return s&&!this.shouldUseServerConfigSubdomain(o,n)?void 0:s}static shouldUseServerConfigSubdomain(e,t){switch(t.configuration){case Qt.Dashboard:return!0;case Qt.JavaScript:switch(location.protocol){case"https:":return!!e;case"http:":return!0;default:return!1}}}}class mi{getAppConfig(e){return Object(a.a)(this,void 0,void 0,function*(){return yield pi.getAppConfig(e,ht.downloadServerAppConfig)})}getMergedConfig(e,t){return pi.getMergedConfig(e,t)}}class bi{constructor(e){this.options={appId:e.appId,subdomain:e.subdomainName,origin:e.origin,siteName:e.siteName,metrics:{enable:!1,mixpanelReportingToken:null},userConfig:{}}}initialize(){return Object(a.a)(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 mi).getAppConfig(e);return OneSignal.environmentInfo=Xt.getEnvironmentInfo(),OneSignal.context=new ui(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 Object(a.a)(this,void 0,void 0,function*(){const e=A.getIsPushNotificationsEnabled(),t=opener||parent;e?t&&window.close():ce.registerForPush()})}}class fi extends bi{initialize(){const e=super.initialize();return m.a.trigger("httpInitialize"),e}establishCrossOriginMessaging(){this.messenger&&this.messenger.destroy(),this.messenger=new ge(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_GET_ALL,this.onRemoteDatabaseGetAll.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.on(OneSignal.POSTMAM_COMMANDS.SESSION_UPSERT,this.onSessionUpsert.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.SESSION_DEACTIVATE,this.onSessionDeactivate.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.ARE_YOU_VISIBLE_REQUEST,this.onAreYouVisibleRequest.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.ARE_YOU_VISIBLE_RESPONSE,this.onAreYouVisibleResponse.bind(this)),this.messenger.listen()}retriggerRemoteEvent(e,t){this.messenger.message(OneSignal.POSTMAM_COMMANDS.REMOTE_RETRIGGER_EVENT,{eventName:e,eventData:t})}onMessengerConnect(e){return Object(a.a)(this,void 0,void 0,function*(){return O.a.debug(`(${I.a.getWindowEnv().toString()}) Successfully established cross-origin communication.`),this.finishInitialization(),!1})}onProxyFrameInitializing(e){return Object(a.a)(this,void 0,void 0,function*(){O.a.info(`(${I.a.getWindowEnv().toString()}) The iFrame has just received initOptions from the host page!`);const t=Object.assign(Object.assign(Object.assign({},e.data.hostInitOptions),OneSignal.config),{pageUrl:e.data.pageUrl});if(OneSignal.config=t,ze.installNativePromptPermissionChangedHook(),(yield v.a.get("Options","defaultUrl"))||(yield v.a.put("Options",{key:"defaultUrl",value:new URL(OneSignal.config.pageUrl).origin})),yield v.a.put("Options",{key:"lastKnownHostUrl",value:OneSignal.config.pageUrl}),yield ze.initSaveState(),yield ze.storeInitialValues(),yield ze.saveInitOptions(),navigator.serviceWorker&&"https:"===window.location.protocol)try{OneSignal.context.serviceWorkerManager.establishServiceWorkerChannel()}catch(e){O.a.error("Error interacting with Service Worker inside an HTTP-hosted iFrame:",e)}e.reply(OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE)})}onRemoteNotificationPermission(e){return Object(a.a)(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 Object(a.a)(this,void 0,void 0,function*(){const t=e.data,i=[];for(const e of t){const{table:t,key:n}=e;i.push(v.a.get(t,n))}const n=yield Promise.all(i);return e.reply(n),!1})}onRemoteDatabaseGetAll(e){return Object(a.a)(this,void 0,void 0,function*(){const t=e.data.table,i=yield v.a.getAll(t);return e.reply(i),!1})}onRemoteDatabasePut(e){return Object(a.a)(this,void 0,void 0,function*(){const t=e.data,i=[];for(const e of t){const{table:t,keypath:n}=e;i.push(v.a.put(t,n))}return yield Promise.all(i),e.reply(OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE),!1})}onRemoteDatabaseRemove(e){return Object(a.a)(this,void 0,void 0,function*(){const t=e.data,i=[];for(const e of t){const{table:t,keypath:n}=e;i.push(v.a.remove(t,n))}return yield Promise.all(i),e.reply(OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE),!1})}onUnsubscribeFromPush(e){return Object(a.a)(this,void 0,void 0,function*(){O.a.debug("(Reposted from iFrame -> Host) User unsubscribed but permission granted. Re-prompting the user for push.");try{yield Object(G.z)(),e.reply(OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE)}catch(e){O.a.debug("Failed to unsubscribe from push remotely:",e)}})}onMarkPromptDismissed(e){return Object(a.a)(this,void 0,void 0,function*(){return O.a.debug("(Reposted from iFrame -> Host) Marking prompt as dismissed."),yield je.markPromptDismissedWithType(Se.Push),e.reply(OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE),!1})}onIsSubscribed(e){return Object(a.a)(this,void 0,void 0,function*(){const t=yield OneSignal.isPushNotificationsEnabled();return e.reply(t),!1})}onUnsubscribeProxyFrame(e){return Object(a.a)(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 Object(a.a)(this,void 0,void 0,function*(){const t=yield OneSignal.context.serviceWorkerManager.getActiveState();return e.reply(t),!1})}onWorkerVersion(e){return Object(a.a)(this,void 0,void 0,function*(){const t=yield OneSignal.context.serviceWorkerManager.getWorkerVersion();return e.reply(t),!1})}onSubscriptionExpirationState(e){return Object(a.a)(this,void 0,void 0,function*(){const t=yield OneSignal.context.subscriptionManager.isSubscriptionExpiring();return e.reply(t),!1})}onProcessExpiringSubscriptions(e){return Object(a.a)(this,void 0,void 0,function*(){OneSignal.context,yield ze.processExpiringSubscriptions();return e.reply(OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE),!1})}onGetSubscriptionState(e){return Object(a.a)(this,void 0,void 0,function*(){const t=yield OneSignal.context.subscriptionManager.getSubscriptionState();return e.reply(t),!1})}onSessionUpsert(e){return Object(a.a)(this,void 0,void 0,function*(){const t=OneSignal.context,i=e.data;t.workerMessenger.directPostMessageToSW(de.SessionUpsert,i),e.reply(!0)})}onSessionDeactivate(e){return Object(a.a)(this,void 0,void 0,function*(){const t=OneSignal.context,i=e.data;t.workerMessenger.directPostMessageToSW(de.SessionDeactivate,i),e.reply(!0)})}onAreYouVisibleRequest(e){return Object(a.a)(this,void 0,void 0,function*(){O.a.debug("onAreYouVisibleRequest iframe",e)})}onAreYouVisibleResponse(e){return Object(a.a)(this,void 0,void 0,function*(){O.a.debug("onAreYouVisibleResponse iframe",e);const t=OneSignal.context,i=e.data;t.workerMessenger.directPostMessageToSW(de.AreYouVisibleResponse,i),e.reply(!0)})}}class Si extends bi{constructor(e){super(e)}establishCrossOriginMessaging(){this.messenger&&this.messenger.destroy(),this.messenger=new ge(window.parent,this.options.origin,this.options.origin)}}class vi extends bi{constructor(e){super(e)}establishCrossOriginMessaging(){this.messenger=new ge(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){O.a.debug(`(${I.a.getWindowEnv().toString()}) The host page is now ready to receive commands from the HTTP popup.`),this.finishInitialization()}}class Oi{static initHttp(e){return Object(a.a)(this,void 0,void 0,function*(){switch(O.a.debug(`Called %cinitHttp(${JSON.stringify(e,null,4)})`,Object(G.k)("code")),I.a.getWindowEnv()){case J.a.OneSignalProxyFrame:OneSignal.proxyFrame=new fi(e),yield OneSignal.proxyFrame.initialize(),Q.ensureBackwardsCompatibility(OneSignal);break;case J.a.OneSignalSubscriptionPopup:OneSignal.subscriptionPopup=new vi(e),yield OneSignal.subscriptionPopup.initialize(),Q.ensureBackwardsCompatibility(OneSignal),m.a.trigger("httpInitialize");break;case J.a.OneSignalSubscriptionModal:OneSignal.subscriptionModal=new Si(e),OneSignal.subscriptionModal.establishCrossOriginMessaging(),OneSignal.subscriptionModal.initialize(),Q.ensureBackwardsCompatibility(OneSignal),m.a.trigger("httpInitialize");break;default:O.a.error("Unsupported HTTP initialization branch.")}})}}var yi=i(14);class wi{static get LOAD_TIMEOUT_MS(){return 15e3}constructor(e){this.url=e,this.url.pathname="webPushIframe"}load(){return Object(a.a)(this,void 0,void 0,function*(){O.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(G.x)(this.loadPromise.promise,wi.LOAD_TIMEOUT_MS).catch(()=>{window===window.top&&O.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(!d.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 ge(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.on(OneSignal.POSTMAM_COMMANDS.ARE_YOU_VISIBLE_REQUEST,this.onAreYouVisibleRequest.bind(this)),this.messenger.connect()}dispose(){this.messenger&&this.messenger.destroy(),this.removeFrame()}onMessengerConnect(e){return Object(a.a)(this,void 0,void 0,function*(){O.a.debug(`Successfully established cross-origin communication for iFrame at ${this.url.toString()}`),this.messenger.message(OneSignal.POSTMAM_COMMANDS.IFRAME_POPUP_INITIALIZE,{hostInitOptions:Object(G.h)(OneSignal.config),pageUrl:window.location.href},e=>(e.data===OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE&&this.loadPromise.resolver(),!1))})}onRemoteRetriggerEvent(e){const{eventName:t,eventData:i}=e.data;return m.a.trigger(t,i,e.source),!1}onRemoteNotificationPermissionChanged(e){const{forceUpdatePermission:t}=e.data;return Object(G.y)(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 O.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,t=null){return Object(a.a)(this,void 0,void 0,function*(){return yield new Promise((i,n)=>{this.message(e,t,e=>{i(e.data)})})})}onAreYouVisibleRequest(e){O.a.debug("onAreYouVisibleRequest page",e);const t={timestamp:e.data.timestamp,focused:document.hasFocus()};this.message(OneSignal.POSTMAM_COMMANDS.ARE_YOU_VISIBLE_RESPONSE,t)}message(...e){this.messenger.message.apply(this.messenger,arguments)}}class Ei{constructor(){}static discoverAltOrigin(e){return Object(a.a)(this,void 0,void 0,function*(){const t=Ei.getOneSignalProxyIframeUrls(e),i=[];for(const e of t){const t=new wi(e);yield t.load(),i.push(t)}const n=yield Ei.subscribedProxyFrameHosts(i);let o;yield Ei.removeDuplicatedAltOriginSubscription(n),o=0===n.length?i[0]:n[0];for(const e of i)o!==e&&e.dispose();return o})}static subscribedProxyFrameHosts(e){return Object(a.a)(this,void 0,void 0,function*(){const t=[];for(const i of e)(yield i.isSubscribed())&&t.push(i);return t})}static removeDuplicatedAltOriginSubscription(e){return Object(a.a)(this,void 0,void 0,function*(){if(e.length<2)return;const t=e.slice(1);for(const e of t)yield e.unsubscribeFromPush()})}static getCanonicalSubscriptionUrls(e,t=I.a.getApiEnv()){const i=Ei.getWildcardLegacySubscriptionDomain(t),n=new URL(`https://${e.subdomain}.${i}`);if(t!==yi.a.Production)return[n];const o=[new URL(`https://${e.subdomain}.os.tc`)];return e.httpUseOneSignalCom&&o.push(n),o}static getWildcardLegacySubscriptionDomain(e){const t=I.a.getOneSignalApiUrl(e);let i=2;return e===yi.a.Staging&&(i=3),ne.a.lastParts(t.host,".",i)}static getOneSignalProxyIframeUrls(e){const t=Ei.getCanonicalSubscriptionUrls(e);for(const e of t)e.pathname="webPushIframe";return t}}var Ii=i(24);class Pi{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)}}class Ci{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)}}}}class Ti{static throwIfInvalidAuthHashOptions(e,t){if(!e)return;const i=t.filter(t=>e.hasOwnProperty(t));if(i.length>1)throw O.a.error("More than one key provided, please only provide one!",i),new InvalidArgumentError.a("options",InvalidArgumentError.b.Malformed);const n=i[0],o=e[n];return o?(Ti.throwIfInvalidAuthHash(o,`options.${n}`),o):void 0}static throwIfInvalidAuthHash(e,t){if(e&&e.length!==Ti.VALID_AUTH_HASH_LENGTH)throw new InvalidArgumentError.a(t,InvalidArgumentError.b.Malformed)}}Ti.VALID_AUTH_HASH_LENGTH=64;class Mi{static setDefaultNotificationUrl(e){return Object(a.a)(this,void 0,void 0,function*(){if(!Pi.isValidUrl(e,{allowNull:!0}))throw new InvalidArgumentError.a("url",InvalidArgumentError.b.Malformed);yield Object(G.c)(),Object(G.s)("setDefaultNotificationUrl",e);const t=yield v.a.getAppState();t.defaultNotificationUrl=e,yield v.a.setAppState(t)})}static setDefaultTitle(e){return Object(a.a)(this,void 0,void 0,function*(){yield Object(G.c)(),Object(G.s)("setDefaultTitle",e);const t=yield v.a.getAppState();t.defaultNotificationTitle=e,yield v.a.setAppState(t)})}static setEmail(e,t){return Object(a.a)(this,void 0,void 0,function*(){if(!e)throw new InvalidArgumentError.a("email",InvalidArgumentError.b.Empty);if(!Object(G.r)(e))throw new InvalidArgumentError.a("email",InvalidArgumentError.b.Malformed);const i=Ti.throwIfInvalidAuthHashOptions(t,["identifierAuthHash","emailAuthHash"]);return Object(G.s)("setEmail",e,t),yield Object(G.c)(),yield this.context.secondaryChannelManager.email.setIdentifier(e,i)})}static setSMSNumber(e,t){return Object(a.a)(this,void 0,void 0,function*(){if(!e)throw new InvalidArgumentError.a("smsNumber",InvalidArgumentError.b.Empty);const i=Ti.throwIfInvalidAuthHashOptions(t,["identifierAuthHash"]);return Object(G.s)("setSMSNumber",e,t),yield Object(G.c)(),yield this.context.secondaryChannelManager.sms.setIdentifier(e,i)})}static logoutEmail(){return Object(a.a)(this,void 0,void 0,function*(){return yield Object(G.c)(),yield this.context.secondaryChannelManager.email.logout()})}static logoutSMS(){return Object(a.a)(this,void 0,void 0,function*(){return yield Object(G.c)(),yield this.context.secondaryChannelManager.sms.logout()})}static isPushNotificationsSupported(){return Object(G.s)("isPushNotificationsSupported"),!0}static initializeConfig(e){return Object(a.a)(this,void 0,void 0,function*(){const t=yield(new mi).getAppConfig(e);O.a.debug(`OneSignal: Final web app config: %c${JSON.stringify(t,null,4)}`,Object(G.k)("code")),Mi.config=t,Mi.environmentInfo=Xt.getEnvironmentInfo(),Mi.context=new ui(t),Mi.config=Mi.context.appConfig})}static init(e){return Object(a.a)(this,void 0,void 0,function*(){if(Object(G.s)("init"),yield ze.polyfillSafariFetch(),ze.errorIfInitAlreadyCalled(),yield Mi.initializeConfig(e),!Mi.config)throw new Error("OneSignal config not initialized!");if(!l.a.safari||Mi.config.safariWebId){if(Mi.config.userConfig.requiresUserPrivacyConsent){if(!(yield v.a.getProvideUserConsent()))return void(Mi.pendingInit=!0)}yield Mi.delayedInit()}else O.a.warn(new p(r.MissingSafariWebId))})}static delayedInit(){return Object(a.a)(this,void 0,void 0,function*(){function e(){return Object(a.a)(this,void 0,void 0,function*(){if(!Mi.__initAlreadyCalled){if(Mi.__initAlreadyCalled=!0,Mi.emitter.on(Mi.EVENTS.NATIVE_PROMPT_PERMISSIONCHANGED,q.onNotificationPermissionChange),Mi.emitter.on(Mi.EVENTS.SUBSCRIPTION_CHANGED,q._onSubscriptionChanged),Mi.emitter.on(Mi.EVENTS.SDK_INITIALIZED,ze.onSdkInitialized),y.b.isUsingSubscriptionWorkaround()){if(!Mi.config||!Mi.config.subdomain)throw new p(r.MissingSubdomain);Mi.emitter.on(Mi.EVENTS.SESSION_STARTED,ii.setupSessionEventListenersForHttp),Mi.proxyFrameHost=yield Ei.discoverAltOrigin(Mi.config)}window.addEventListener("focus",()=>{le.checkAndTriggerNotificationPermissionChanged()}),yield ze.initSaveState(),yield ze.saveInitOptions(),I.a.getWindowEnv()===J.a.CustomIframe?yield m.a.trigger(Mi.EVENTS.SDK_INITIALIZED):yield ze.internalInit()}})}Mi.pendingInit=!1,Mi.context.workerMessenger.listen(),"complete"===document.readyState||"interactive"===document.readyState?yield e():(O.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 Object(a.a)(this,void 0,void 0,function*(){yield v.a.setProvideUserConsent(e),e&&Mi.pendingInit&&(yield Mi.delayedInit())})}static showHttpPermissionRequest(e){return Object(a.a)(this,void 0,void 0,function*(){O.a.debug("Called showHttpPermissionRequest(), redirecting to HTTP prompt."),Mi.showHttpPrompt(e).catch(e=>O.a.info(e))})}static showHttpPrompt(e){return Object(a.a)(this,void 0,void 0,function*(){yield Mi.showSlidedownPrompt(e)})}static showNativePrompt(){return Object(a.a)(this,void 0,void 0,function*(){yield Object(G.c)(),yield Mi.context.promptsManager.internalShowNativePrompt()})}static showSlidedownPrompt(e){return Object(a.a)(this,void 0,void 0,function*(){yield Object(G.c)(),yield Mi.context.promptsManager.internalShowParticularSlidedown(f.Push,e)})}static showCategorySlidedown(e){return Object(a.a)(this,void 0,void 0,function*(){yield Object(G.c)();const t=A.getIsPushNotificationsEnabled();yield Mi.context.promptsManager.internalShowCategorySlidedown(Object.assign(Object.assign({},e),{isInUpdateMode:t}))})}static showSmsSlidedown(e){return Object(a.a)(this,void 0,void 0,function*(){yield Object(G.c)(),yield Mi.context.promptsManager.internalShowSmsSlidedown(Object.assign({},e))})}static showEmailSlidedown(e){return Object(a.a)(this,void 0,void 0,function*(){yield Object(G.c)(),yield Mi.context.promptsManager.internalShowEmailSlidedown(Object.assign({},e))})}static showSmsAndEmailSlidedown(e){return Object(a.a)(this,void 0,void 0,function*(){yield Object(G.c)(),yield Mi.context.promptsManager.internalShowSmsAndEmailSlidedown(Object.assign({},e))})}static registerForPushNotifications(e){return Object(a.a)(this,void 0,void 0,function*(){if(Mi.initialized)return yield ze.registerForPushNotifications(e);yield new Promise((t,i)=>{Mi.emitter.once(Mi.EVENTS.SDK_INITIALIZED,()=>Object(a.a)(this,void 0,void 0,function*(){return yield ze.registerForPushNotifications(e),t()}))})})}static getNotificationPermission(e){return Object(a.a)(this,void 0,void 0,function*(){return yield Object(G.c)(),Mi.privateGetNotificationPermission(e)})}static privateGetNotificationPermission(e){return Object(a.a)(this,void 0,void 0,function*(){const t=yield Mi.context.permissionManager.getNotificationPermission(Mi.config.safariWebId);return e&&e(t),t})}static getTags(e){return Object(a.a)(this,void 0,void 0,function*(){yield Object(G.c)(),Object(G.s)("getTags",e);const{appId:t}=yield v.a.getAppConfig(),{deviceId:i}=yield v.a.getSubscription();if(!i)return O.a.info(new h(s.NoDeviceId)),null;const{tags:n}=yield ht.getPlayer(t,i);return Object(G.j)(e,n),n})}static sendTag(e,t,i){return Object(a.a)(this,void 0,void 0,function*(){const n={};return n[e]=t,yield Mi.sendTags(n,i)})}static sendTags(e,t){return Object(a.a)(this,void 0,void 0,function*(){return yield Object(G.c)(),Object(G.s)("sendTags",e,t),e&&0!==Object.keys(e).length?(Object.keys(e).forEach(t=>{!1===e[t]&&(e[t]="false")}),yield this.context.updateManager.sendTagsUpdate(e),Object(G.j)(t,e),e):(O.a.info(new InvalidArgumentError.a("tags",InvalidArgumentError.b.Empty)),null)})}static deleteTag(e){return Object(a.a)(this,void 0,void 0,function*(){return yield Mi.deleteTags([e])})}static deleteTags(e,t){return Object(a.a)(this,void 0,void 0,function*(){if(yield Object(G.c)(),Object(G.s)("deleteTags",e,t),!Pi.isValidArray(e))throw new InvalidArgumentError.a("tags",InvalidArgumentError.b.Malformed);0===e.length&&O.a.info(new InvalidArgumentError.a("tags",InvalidArgumentError.b.Empty));const i={};for(const t of e)i[t]="";const n=yield Mi.sendTags(i);if(n){const e=Object.keys(n);return Object(G.j)(t,e),e}return[]})}static setExternalUserId(e,t){return Object(a.a)(this,void 0,void 0,function*(){yield Object(G.c)(),Object(G.s)("setExternalUserId"),yield Mi.privateSetExternalUserId(e,t)})}static privateSetExternalUserId(e,t){return Object(a.a)(this,void 0,void 0,function*(){Ti.throwIfInvalidAuthHash(t,"authHash"),yield Mi.database.setExternalUserId(e,t),yield Mi.context.updateManager.sendExternalUserIdUpdate(e,t)})}static getExternalUserId(){return Object(a.a)(this,void 0,void 0,function*(){return yield Object(G.c)(),Object(G.s)("getExternalUserId"),yield Mi.database.getExternalUserId()})}static removeExternalUserId(){return Object(a.a)(this,void 0,void 0,function*(){yield Object(G.c)(),Object(G.s)("removeExternalUserId"),yield Mi.privateSetExternalUserId(void 0)})}static addListenerForNotificationOpened(e){return Object(a.a)(this,void 0,void 0,function*(){yield Object(G.c)(),Object(G.s)("addListenerForNotificationOpened",e),Mi.emitter.once(Mi.EVENTS.NOTIFICATION_CLICKED,t=>{Object(G.j)(e,t)}),Mi.config&&q.fireStoredNotificationClicks(Mi.config.pageUrl||Mi.config.userConfig.pageUrl)})}static getIdsAvailable(e){return Object(a.a)(this,void 0,void 0,function*(){yield Object(G.c)(),Object(G.s)("getIdsAvailable",e);const{deviceId:t,subscriptionToken:i}=yield v.a.getSubscription(),n={userId:t,registrationId:i};return Object(G.j)(e,n),n})}static isPushNotificationsEnabled(e){return Object(a.a)(this,void 0,void 0,function*(){return yield Object(G.c)(),Mi.privateIsPushNotificationsEnabled(e)})}static privateIsPushNotificationsEnabled(e){return Object(a.a)(this,void 0,void 0,function*(){Object(G.s)("isPushNotificationsEnabled",e);const t=yield Mi.context.subscriptionManager.getSubscriptionState();return Object(G.j)(e,t.subscribed&&!t.optedOut),t.subscribed&&!t.optedOut})}static setSubscription(e){return Object(a.a)(this,void 0,void 0,function*(){yield Object(G.c)(),Object(G.s)("setSubscription",e);const t=yield v.a.getAppConfig(),{appId:i}=t,n=yield v.a.getSubscription(),{deviceId:r}=n;if(!t.appId)throw new g(o.MissingAppId);if(!Pi.isValidBoolean(e))throw new InvalidArgumentError.a("newSubscription",InvalidArgumentError.b.Malformed);if(!r)return void O.a.info(new h(s.NoDeviceId));const a={notification_types:le.getNotificationTypeFromOptIn(e)},c=yield v.a.getExternalUserIdAuthHash();c&&(a.external_user_id_auth_hash=c),n.optedOut=!e,yield ht.updatePlayer(i,r,a),yield v.a.setSubscription(n),q.onInternalSubscriptionSet(n.optedOut),q.checkAndTriggerSubscriptionChanged()})}static isOptedOut(e){return Object(a.a)(this,void 0,void 0,function*(){return yield Object(G.c)(),Mi.internalIsOptedOut(e)})}static internalIsOptedOut(e){return Object(a.a)(this,void 0,void 0,function*(){Object(G.s)("isOptedOut",e);const{optedOut:t}=yield v.a.getSubscription();return Object(G.j)(e,t),t})}static optOut(e,t){return Object(a.a)(this,void 0,void 0,function*(){if(yield Object(G.c)(),Object(G.s)("optOut",e,t),!Pi.isValidBoolean(e))throw new InvalidArgumentError.a("doOptOut",InvalidArgumentError.b.Malformed);yield Mi.setSubscription(!e),Object(G.j)(t)})}static getEmailId(e){return Object(a.a)(this,void 0,void 0,function*(){yield Object(G.c)(),Object(G.s)("getEmailId",e);const t=(yield v.a.getEmailProfile()).subscriptionId;return Object(G.j)(e,t),t})}static getSMSId(e){return Object(a.a)(this,void 0,void 0,function*(){yield Object(G.c)(),Object(G.s)("getSMSId",e);const t=yield v.a.getSMSProfile(),{subscriptionId:i}=t;return Object(G.j)(e,i),i})}static getUserId(e){return Object(a.a)(this,void 0,void 0,function*(){yield Object(G.c)(),Object(G.s)("getUserId",e);const t=(yield v.a.getSubscription()).deviceId;return Object(G.j)(e,t),t})}static getRegistrationId(e){return Object(a.a)(this,void 0,void 0,function*(){yield Object(G.c)(),Object(G.s)("getRegistrationId",e);const t=(yield v.a.getSubscription()).subscriptionToken;return Object(G.j)(e,t),t})}static getSubscription(e){return Object(a.a)(this,void 0,void 0,function*(){return yield Object(G.c)(),yield Mi.privateGetSubscription(e)})}static privateGetSubscription(e){return Object(a.a)(this,void 0,void 0,function*(){Object(G.s)("getSubscription",e);const t=!(yield v.a.getSubscription()).optedOut;return Object(G.j)(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`,n,r,c){return Object(a.a)(this,void 0,void 0,function*(){if(yield Object(G.c)(),Object(G.s)("sendSelfNotification",e,t,i,n,r,c),!(yield v.a.getAppConfig()).appId)throw new g(o.MissingAppId);if(!(yield Mi.isPushNotificationsEnabled()))throw new h(s.NoDeviceId);if(!Pi.isValidUrl(i))throw new InvalidArgumentError.a("url",InvalidArgumentError.b.Malformed);if(!Pi.isValidUrl(n,{allowEmpty:!0,requireHttps:!0}))throw new InvalidArgumentError.a("icon",InvalidArgumentError.b.Malformed);if(!n){const e=yield le.getNotificationIcons();n=Object(G.m)(e)}const l=e=>{const t=[];for(let i=0;iObject(a.a)(this,void 0,void 0,function*(){if(!i)return void O.a.error("Service worker registration not available.");const o={body:t,data:d,icon:n,actions:c?l(c):[]};i.showNotification(e,o)}))})}static push(e){Ci.processItem(Mi,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)}static sendOutcome(e,t){return Object(a.a)(this,void 0,void 0,function*(){const i=Mi.config.userConfig.outcomes;if(!i)return void O.a.error(`Could not send ${e}. No outcomes config found.`);const n=new st(Mi.config.appId,i,e,!1);if(void 0!==t&&"number"!=typeof t)return void O.a.error("Outcome weight can only be a number if present.");if(!(yield n.beforeOutcomeSend()))return;const o=yield n.getAttribution();yield n.send({type:o.type,notificationIds:o.notificationIds,weight:t})})}static sendUniqueOutcome(e){return Object(a.a)(this,void 0,void 0,function*(){const t=Mi.config.userConfig.outcomes;if(!t)return void O.a.error(`Could not send ${e}. No outcomes config found.`);const i=new st(Mi.config.appId,t,e,!0);if(!(yield i.beforeOutcomeSend()))return;const n=yield i.getAttribution();if(n.type===Ze.NotSupported)return void O.a.warn("You are on a free plan. Please upgrade to use this functionality.");const{notificationIds:o}=n,s=yield i.getNotifsToAttributeWithUniqueOutcome(o);i.shouldSendUnique(n,s)?yield i.send({type:n.type,notificationIds:s}):O.a.warn(`'${e}' was already reported for all notifications.`)})}}Mi.VERSION=d.a.version(),Mi._VERSION=d.a.version(),Mi.sdkEnvironment=I.a,Mi._notificationOpenedCallbacks=[],Mi._idsAvailable_callback=[],Mi._defaultLaunchURL=null,Mi.config=null,Mi._sessionInitAlreadyRunning=!1,Mi._isNotificationEnabledCallback=[],Mi._subscriptionSet=!0,Mi.modalUrl=null,Mi._windowWidth=650,Mi._windowHeight=568,Mi._isNewVisitor=!1,Mi._channel=null,Mi.timedLocalStorage=Ne,Mi.initialized=!1,Mi._didLoadITILibrary=!1,Mi.notifyButton=null,Mi.store=b,Mi.environment=d.a,Mi.database=v.a,Mi.event=m.a,Mi.browser=l.a,Mi.slidedown=null,Mi.log=O.a,Mi.api=ht,Mi.indexedDb=Ii.a,Mi.mainHelper=le,Mi.subscriptionHelper=ce,Mi.httpHelper=Oi,Mi.eventHelper=q,Mi.initHelper=ze,Mi.pendingInit=!0,Mi.emitter=new ue.a,Mi.cache={},Mi.SERVICE_WORKER_PATH="OneSignalSDKWorker.js",Mi.SERVICE_WORKER_PARAM={scope:"/"},Mi._LOGGING=!1,Mi.LOGGING=!1,Mi._initCalled=!1,Mi.__initAlreadyCalled=!1,Mi.checkAndWipeUserSubscription=function(){},Mi.DeviceRecord=X,Mi.SecondaryChannelDeviceRecord=bt,Mi.notificationPermission=S,Mi._initHttp=Oi.initHttp,Mi._initPopup=(()=>Mi.subscriptionPopup.subscribe()),Mi.POSTMAM_COMMANDS={CONNECTED:"connect",REMOTE_NOTIFICATION_PERMISSION:"postmam.remoteNotificationPermission",REMOTE_DATABASE_GET:"postmam.remoteDatabaseGet",REMOTE_DATABASE_GET_ALL:"postmam.remoteDatabaseGetAll",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",SESSION_UPSERT:"postmam.sessionUpsert",SESSION_DEACTIVATE:"postmam.sessionDeactivate",ARE_YOU_VISIBLE_REQUEST:"postmam.areYouVisibleRequest",ARE_YOU_VISIBLE_RESPONSE:"postmam.areYouVisibleResponse"},Mi.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",EMAIL_SUBSCRIPTION_CHANGED:"emailSubscriptionChanged",SMS_SUBSCRIPTION_CHANGED:"smsSubscriptionChanged",TEST_INIT_OPTION_DISABLED:"testInitOptionDisabled",TEST_WOULD_DISPLAY:"testWouldDisplay",TEST_FINISHED_ALLOW_CLICK_HANDLING:"testFinishedAllowClickHandling",POPUP_WINDOW_TIMEOUT:"popupWindowTimeout",SESSION_STARTED:"os.sessionStarted"},Q.ensureBackwardsCompatibility(Mi),O.a.info(`%cOneSignal Web SDK loaded (version ${Mi._VERSION},\n ${I.a.getWindowEnv().toString()} environment).`,Object(G.k)("bold")),O.a.debug(`Current Page URL: ${"undefined"==typeof location?"NodeJS":location.href}`),O.a.debug(`Browser Environment: ${l.a.name} ${l.a.version}`)},function(e,t,i){"use strict";i.r(t);var n=i(1),o=i(2);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.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.p)(),Object(o.n)()>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.n)()} times.`);const e=window.OneSignal;window.OneSignal=i(29).default,s.doReplay(e)}()}]); //# sourceMappingURL=OneSignalPageSDKES6.js.map