/*! For license information please see pushengage-subscription.js.LICENSE.txt */ (()=>{"use strict";var e={9996:e=>{var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===i}(e)}(e)},i="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function o(e,t,i){return e.concat(t).map((function(e){return n(e,i)}))}function s(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function r(e,t){try{return t in e}catch(e){return!1}}function a(e,i,d){(d=d||{}).arrayMerge=d.arrayMerge||o,d.isMergeableObject=d.isMergeableObject||t,d.cloneUnlessOtherwiseSpecified=n;var c=Array.isArray(i);return c===Array.isArray(e)?c?d.arrayMerge(e,i,d):function(e,t,i){var o={};return i.isMergeableObject(e)&&s(e).forEach((function(t){o[t]=n(e[t],i)})),s(t).forEach((function(s){(function(e,t){return r(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,s)||(r(e,s)&&i.isMergeableObject(t[s])?o[s]=function(e,t){if(!t.customMerge)return a;var i=t.customMerge(e);return"function"==typeof i?i:a}(s,i)(e[s],t[s],i):o[s]=n(t[s],i))})),o}(e,i,d):n(i,d)}a.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,i){return a(e,i,t)}),{})};var d=a;e.exports=d},8637:(e,t,i)=>{i.r(t),i.d(t,{default:()=>c,detectIncognito:()=>l});var n={d:(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},o={};n.d(o,{A:()=>d,k:()=>a});var s=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},r=function(e,t){var i,n,o,s,r={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(d){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(r=0)),r;)try{if(i=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,n=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(!((o=(o=r.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){r=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]r(void 0,void 0,void 0,(function*(){c.default.debug("The alert is being added for the subscriber."),g.addAlert(e);const n=(0,l.detectBrowser)(),o=(0,u.addQueryParamsToUrl)(`${p.env.__SUBSCRIBER_API_ENDPOINT__}/alerts`,{swv:p.env.__WORKER_VERSION__,bv:n.version}),s=yield(0,d.sendHttpRequest)(o,{method:"POST",body:JSON.stringify(Object.assign(Object.assign({},e),{device_token_hash:t,site_id:i})),retries:2});s.ok||(yield(0,b.throwDexterAPIError)(s,"Couldn't add alert.")),c.default.debug("The alert has been added for the subscriber.")})),t.getAlerts=({subscriberId:e,siteId:t,options:i={}})=>r(void 0,void 0,void 0,(function*(){c.default.debug("The alert is being retrieved for the subscriber.");const n=(0,l.detectBrowser)(),o=(0,u.addQueryParamsToUrl)(`${p.env.__SUBSCRIBER_API_ENDPOINT__}/alerts`,{swv:p.env.__WORKER_VERSION__,bv:n.version,device_token_hash:e,site_id:t,type:i.type,product_id:i.productId,variant_id:i.variantId});try{const e=yield(0,d.sendHttpRequest)(o,{retries:2});if(!e.ok)return c.default.debug("Response not ok:",e),null;const t=yield e.json();return(null==t?void 0:t.error_code)||!1===Array.isArray(null==t?void 0:t.data)?(c.default.debug("Error retrieving the alert response.",t),null):t.data}catch(e){return c.default.debug("Error occurred:",e),null}finally{c.default.debug("The alert has been retrieved for the subscriber.")}}))},5021:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getGeoInfo=t.getAppData=void 0;const s=i(6405),r=o(i(3321)),a=i(4014),d=i(3241),c=i(9340);t.getAppData=({appId:e,source:t="sdk",version:i=1})=>n(void 0,void 0,void 0,(function*(){if(!e)throw new r.default({message:r.default.ERROR_MESSAGE.InvalidAppId,name:r.default.ERROR_NAME.InvalidAppId});const n=(0,d.addQueryParamsToUrl)(`${c.env.__CDN_SERVER_HOST__}/v${i}/sdk-app-data/${e}`,{source:t,sdkv:c.env.__SDK_VERSION__,swv:c.env.__WORKER_VERSION__}),o=yield(0,s.sendHttpRequest)(n,{retries:4});if(!o.ok){const e=yield o.json();throw new Error(`${e.message||"Something went wrong"}`)}const l=yield o.json();return(0,a.isObject)(l)?l:null})),t.getGeoInfo=(()=>{let e=null;return({isEu:t})=>n(void 0,void 0,void 0,(function*(){if(e)return e;const i=(0,d.addQueryParamsToUrl)(`${c.env.__SERVER_HOST__}/geo-details`,{sdkv:c.env.__SDK_VERSION__,swv:c.env.__WORKER_VERSION__});try{const n=yield(0,s.sendHttpRequest)(i,{retries:3});if(!n.ok)return{};const o=yield n.json(),r=(0,a.isObject)(o)?o:{};return(0,a.isEmptyObject)(r)||(r.ipaddress=(0,a.replaceLastNumberFromIpToZero)(t,r.ipaddress)),e=r,r}catch(e){return{}}}))})()},7423:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},r=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.removeAttributes=t.setAttributes=t.addAttributes=t.getAttributes=void 0;const d=i(1920),c=i(3241),l=i(6405),u=i(4014),g=s(i(4379)),p=i(5453),b=i(9892),f=i(9340),m=a(i(7607)),v=e=>r(void 0,void 0,void 0,(function*(){const t=yield(0,p.getSubscriberDataFromStorageOrAPI)(e);return(null==t?void 0:t.attributes)&&(0,u.isObject)(t.attributes)?t.attributes:{}}));t.getAttributes=e=>r(void 0,void 0,void 0,(function*(){m.default.debug("The attributes are being retrieved from the subscriber.");const t=yield v(e);return m.default.debug("The attributes has been retrieved for the subscriber."),t})),t.addAttributes=(e,t)=>r(void 0,void 0,void 0,(function*(){m.default.debug("The attributes are being added to the subscriber."),g.addAttributes(t);const i=yield v(e);if((({subscriberAttributes:e,attributes:t})=>{if((0,u.isEmptyObject)(e))return!1;let i=!0;for(const n in t)if(t[n]!==e[n]){i=!1;break}return i})({subscriberAttributes:i,attributes:t}))return;const n=(0,d.detectBrowser)(),o=(0,c.addQueryParamsToUrl)(`${f.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/${e}/attributes`,{swv:f.env.__WORKER_VERSION__,bv:n.version}),s=yield(0,l.sendHttpRequest)(o,{method:"PUT",body:JSON.stringify(t),retries:2});s.ok||(yield(0,p.throwDexterAPIError)(s,"Couldn't add attributes.")),m.default.debug("The attributes has been added to the subscriber."),(0,b.setSubscriberDataToStorage)({attributes:Object.assign({},i,t)})})),t.setAttributes=(e,t)=>r(void 0,void 0,void 0,(function*(){if(m.default.debug("The attributes are being set to the subscriber."),g.addAttributes(t),(({subscriberAttributes:e,attributes:t})=>{if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(e[i]!==t[i])return!1;return!0})({subscriberAttributes:yield v(e),attributes:t}))return;const i=(0,d.detectBrowser)(),n=(0,c.addQueryParamsToUrl)(`${f.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/${e}/attributes`,{swv:f.env.__WORKER_VERSION__,bv:i.version}),o=yield(0,l.sendHttpRequest)(n,{method:"POST",body:JSON.stringify(t),retries:2});o.ok||(yield(0,p.throwDexterAPIError)(o,"Couldn't set attributes.")),m.default.debug("The attributes has been set to the subscriber."),(0,b.setSubscriberDataToStorage)({attributes:t})})),t.removeAttributes=(e,t)=>r(void 0,void 0,void 0,(function*(){if(m.default.debug("The attributes are being removed from the subscriber."),!1===Array.isArray(t))throw new Error("The attribute names must be provided as an array.");const i=yield v(e);if(!(({attributeNames:e,subscriberAttributes:t})=>{if((0,u.isEmptyObject)(t))return!1;if(0===e.length)return!0;for(const i of e)if((0,u.hasOwn)(t,i))return!0;return!1})({subscriberAttributes:i,attributeNames:t}))return;const n=(0,d.detectBrowser)(),o=(0,c.addQueryParamsToUrl)(`${f.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/${e}/attributes`,{swv:f.env.__WORKER_VERSION__,bv:n.version}),s=yield(0,l.sendHttpRequest)(o,{method:"DELETE",body:JSON.stringify(t),retries:2});s.ok||(yield(0,p.throwDexterAPIError)(s,"Couldn't remove attributes."));let r={};t.length>0&&(r=(0,u.omit)(i,t)),m.default.debug("The attributes has been removed from the subscriber."),(0,b.setSubscriberDataToStorage)({attributes:r})}))},1791:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sendErrorLog=void 0;const s=i(6405),r=i(1920),a=o(i(7607)),d=i(9340),c=o(i(3321));t.sendErrorLog=(e="sdk",t,i)=>n(void 0,void 0,void 0,(function*(){var n,o;try{a.default.debug(t,t.details);const l=[c.default.ERROR_NAME.InvalidAppId,c.default.ERROR_NAME.UnsubscribedFailedFromWorker,c.default.ERROR_NAME.NotPushEngagePayload,c.default.ERROR_NAME.PayloadLessInvalidNotificationPayload,c.default.ERROR_NAME.InvalidNotificationPayload,c.default.ERROR_NAME.PushPayloadParseError,c.default.ERROR_NAME.OfflineError,c.default.ERROR_NAME.OpenNotificationUrlFailed,c.default.ERROR_NAME.SendOptInAnalyticsError,c.default.ERROR_NAME.QuotaExceededError,c.default.ERROR_NAME.DisabledPushSubscriptionError,c.default.ERROR_NAME.UnknownError,c.default.ERROR_NAME.SDKInitOptionsNotFound,"NS_ERROR_FILE_CORRUPTED","NS_ERROR_STORAGE_CONSTRAINT","NS_ERROR_FILE_NO_DEVICE_SPACE","NS_ERROR_STORAGE_IOERR","NS_ERROR_NOT_INITIALIZED",c.default.ERROR_NAME.LocalStorageNotAvailable,c.default.ERROR_NAME.SubscriptionAlreadyInitialized],u=[];if(l.includes(t.name)||u.includes(t.type||""))return;const g=`${d.env.__LOG_API_ENDPOINT__}/logs`,p=Object.assign({sdk:d.env.__SDK_VERSION__,bw:(0,r.detectBrowser)(),app:"service-worker"===e?"new-service-worker":"web-sdk",name:t.name,data:t.details||{},message:t.message,stacktrace:(null===(n=t.stack)||void 0===n?void 0:n.toString())||(null===(o=(new Error).stack)||void 0===o?void 0:o.toString()),type:t.type,url:location.href},i);yield(0,s.sendHttpRequest)(g,{method:"POST",body:JSON.stringify(p),mode:"no-cors"})}catch(e){a.default.error("Error occurred while sending error logs",e)}}))},7353:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sendGoal=void 0;const s=i(1920),r=i(3241),a=i(6405),d=i(4014),c=i(9340),l=i(5453),u=o(i(7607));t.sendGoal=({goal:e,siteId:t,subscriberId:i})=>n(void 0,void 0,void 0,(function*(){if(u.default.debug("The goal is being sent for the subscriber."),!(0,d.isObject)(e))throw new Error("Goal must be an object.");const n=(0,s.detectBrowser)(),o=(0,r.addQueryParamsToUrl)(`${c.env.__SUBSCRIBER_API_ENDPOINT__}/goals`,{swv:c.env.__WORKER_VERSION__,bv:n.version}),g=yield(0,a.sendHttpRequest)(o,{method:"POST",body:JSON.stringify(Object.assign(Object.assign({},e),{site_id:t,device_token_hash:i})),retries:3});g.ok||(yield(0,l.throwDexterAPIError)(g,"Couldn't send goal.")),u.default.debug("The goal has been sent for the subscriber.")}))},5453:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getSubscriberDataFromStorageOrAPI=t.throwDexterAPIError=void 0;const s=i(6405),r=o(i(7607)),a=i(1920),d=i(9892),c=i(3241),l=i(4014),u=i(9340),g=o(i(3321)),p=o(i(8267));t.throwDexterAPIError=(e,t)=>n(void 0,void 0,void 0,(function*(){var i,n;let o=t||"Something went wrong.",s={};try{const t=yield e.json();t&&t.error&&(o=`${(0,l.capitalizeFirstLetter)((null===(i=t.error)||void 0===i?void 0:i.message)||t.error_message)}.`,s=(null===(n=t.error)||void 0===n?void 0:n.details)||{})}catch(e){r.default.debug("Failed to parse json response",e)}throw new g.default({details:s,message:o,type:g.default.ERROR_TYPE.DexterServerError})})),t.getSubscriberDataFromStorageOrAPI=e=>n(void 0,void 0,void 0,(function*(){try{yield p.default.acquireLock("getSubscriberDataFromStorageOrAPI");const t=(0,d.getSubscriberDataFromStorage)();if(t)return t;const i=(0,a.detectBrowser)(),n=(0,c.addQueryParamsToUrl)(`${u.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/${e}`,{swv:u.env.__WORKER_VERSION__,bv:i.version}),o=yield(0,s.sendHttpRequest)(n,{retries:3});if(!o.ok)return r.default.debug("Response not ok:",o),null;const g=yield o.json();if(null==g?void 0:g.error_code)return r.default.debug("response of error:",g),null;if((0,l.isEmptyObject)(null==g?void 0:g.data))return null;const b=(e=>Object.assign(Object.assign({},e),{attributes:e.attributes||{},segments:e.segments||[],trigger_status:(0,l.isUndefined)(e.trigger_status)?1:e.trigger_status}))(null==g?void 0:g.data);return(0,d.addSubscriberDataToStorage)(b),r.default.debug("The subscriber data is stored in the storage."),b}catch(e){return r.default.debug("Error occurred:",e),null}finally{p.default.releaseLock("getSubscriberDataFromStorageOrAPI")}}))},7224:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fetchPayloadNotifications=t.sendNotificationViewedReferAnalytics=t.fetchPayloadLessNotifications=t.sendNotificationClickedAnalytics=t.sendNotificationViewedAnalytics=void 0;const s=i(3241),r=i(1920),a=i(2689),d=i(6405),c=o(i(3321)),l=i(9340),u=i(5453);t.sendNotificationViewedAnalytics=({tag:e})=>n(void 0,void 0,void 0,(function*(){const t=(0,r.detectBrowser)(),i=(0,s.addQueryParamsToUrl)(`${l.env.__ANALYTICS_API_ENDPOINT__}/notification/view`,{tag:e,swv:l.env.__WORKER_VERSION__,bv:t.version,tz:(0,a.getTimezoneOffset)()}),n=yield(0,d.sendHttpRequest)(i,{retries:3});n.ok||(yield(0,u.throwDexterAPIError)(n,"Couldn't send notification view analytics."))})),t.sendNotificationClickedAnalytics=({tag:e,action:t})=>n(void 0,void 0,void 0,(function*(){const i=(0,r.detectBrowser)(),n=(0,s.addQueryParamsToUrl)(`${l.env.__ANALYTICS_API_ENDPOINT__}/notification/click`,{tag:e,action:t,swv:l.env.__WORKER_VERSION__,bv:i.version,tz:(0,a.getTimezoneOffset)()}),o=yield(0,d.sendHttpRequest)(n,{retries:3});o.ok||(yield(0,u.throwDexterAPIError)(o,"Couldn't send notification click analytics to server."))})),t.fetchPayloadLessNotifications=e=>n(void 0,void 0,void 0,(function*(){const t=(0,r.detectBrowser)(),i=(0,s.addQueryParamsToUrl)(`${l.env.__ANALYTICS_API_ENDPOINT__}/notification`,{swv:l.env.__WORKER_VERSION__,device:e,bv:t.version}),n=yield(0,d.sendHttpRequest)(i,{retries:3});if(!n.ok)throw new c.default({message:`Failed to fetch push payload for device token ${e} with status ${n.status}.`,name:c.default.ERROR_NAME.PayloadLessFetchError,details:{status:n.status,url:n.url,origin:self.location.href}});let o;try{o=yield n.json()}catch(e){throw new c.default({message:`Parsing of the notification payload failed, ${e.message}`,name:c.default.ERROR_NAME.PayloadLessParseError,details:{status:n.status,url:n.url}})}if(Array.isArray(o)&&o.length)return o;throw new c.default({message:`Received empty/invalid payload less notification from device ${e}.`,name:c.default.ERROR_NAME.PayloadLessInvalidNotificationPayload,details:{responseData:o,url:n.url,status:n.status}})})),t.sendNotificationViewedReferAnalytics=({tag:e})=>n(void 0,void 0,void 0,(function*(){const t=(0,s.addQueryParamsToUrl)(`${l.env.__ANALYTICS_API_ENDPOINT__}/notification/view/refer`,{tag:e}),i=yield(0,d.sendHttpRequest)(t,{retries:2});i.ok||(yield(0,u.throwDexterAPIError)(i,"Couldn't send notification view refer analytics to server."))})),t.fetchPayloadNotifications=({tag:e,postback:t})=>n(void 0,void 0,void 0,(function*(){const i=(0,r.detectBrowser)(),n=(0,s.addQueryParamsToUrl)(`${l.env.__ANALYTICS_API_ENDPOINT__}/notification/fetch`,{tag:e,swv:l.env.__WORKER_VERSION__,bv:i.version}),o=yield(0,d.sendHttpRequest)(n,{method:"POST",body:JSON.stringify({tag:e,postback:t}),retries:3});if(!o.ok)throw new c.default({message:`Failed to fetch push payload for tag ${e} with status ${o.status}.`,name:c.default.ERROR_NAME.PushPayloadFetchError,details:{status:o.status,url:o.url,origin:self.location.href}});let a;try{a=yield o.json()}catch(e){throw new c.default({message:`Parsing of the notification payload failed, ${e.message}`,name:c.default.ERROR_NAME.NotificationParseError,details:{status:o.status,url:o.url}})}if(Array.isArray(null==a?void 0:a.data)&&a.data.length)return a.data;throw new c.default({message:`Received empty/invalid response from tag ${e}.`,name:c.default.ERROR_NAME.InvalidNotificationPayload,details:{responseData:a,url:o.url,status:o.status}})}))},6547:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sendOptInAnalytics=void 0;const s=i(6405),r=i(9340),a=o(i(3321));t.sendOptInAnalytics=e=>n(void 0,void 0,void 0,(function*(){const t={Data:e,PartitionKey:"optin_analytics"},i=r.env.__OPT_IN_ANALYTICS_API_ENDPOINT__;try{if(!(yield(0,s.sendHttpRequest)(i,{method:"PUT",body:JSON.stringify(t),retries:3})).ok)throw new Error("Couldn't send opt-in analytics event.")}catch(e){throw new a.default({message:e.message,name:a.default.ERROR_NAME.SendOptInAnalyticsError,details:{body:t,requestUrl:i}})}}))},3168:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},r=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setProfileIdToSubscriber=void 0;const d=i(6405),c=a(i(7607)),l=i(1920),u=i(9892),g=i(3241),p=s(i(5702)),b=i(5453),f=i(9340);t.setProfileIdToSubscriber=({profileId:e,siteId:t,subscriberId:i})=>r(void 0,void 0,void 0,(function*(){c.default.debug("The profile id is being set for the subscriber."),p.profileId(e);const n=yield(0,b.getSubscriberDataFromStorageOrAPI)(i);if((null==n?void 0:n.profile_id)===e)return void c.default.debug("The profile id is already set for the subscriber.");const o=(0,l.detectBrowser)(),s={device_token_hash:i,profile_id:e,site_id:t},r=(0,g.addQueryParamsToUrl)(`${f.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/profile-id/add`,{swv:f.env.__WORKER_VERSION__,bv:o.version}),a=yield(0,d.sendHttpRequest)(r,{method:"POST",body:JSON.stringify(s),retries:2});a.ok||(yield(0,b.throwDexterAPIError)(a,"Couldn't set profile id to subscriber.")),c.default.debug("The profile id has been set for the subscriber."),(0,u.setSubscriberDataToStorage)({profile_id:e})}))},953:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},r=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addSegmentWithDurationToSubscriber=t.removeSegmentFromSubscriber=t.addSegmentToSubscriber=void 0;const d=i(6405),c=a(i(7607)),l=i(1920),u=i(9892),g=i(3241),p=i(4014),b=s(i(3314)),f=i(5453),m=i(9340),v=(e,t)=>{let i=!0;for(let n=0;nr(void 0,void 0,void 0,(function*(){const t=yield(0,f.getSubscriberDataFromStorageOrAPI)(e);return(null==t?void 0:t.segments)&&Array.isArray(t.segments)?t.segments:[]}));t.addSegmentToSubscriber=({segment:e,siteId:t,subscriberId:i})=>r(void 0,void 0,void 0,(function*(){b.segment(e);const n=Array.isArray(e)?e:[e],o=yield _(i);if(v(o,n))return void c.default.debug(`The segment have already been added to the subscriber: ${n}.`);const s=(0,l.detectBrowser)(),r={device_token_hash:i,segment:(0,p.uniqueArray)(n),site_id:t},a=(0,g.addQueryParamsToUrl)(`${m.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/segments/add`,{swv:m.env.__WORKER_VERSION__,bv:s.version}),h=yield(0,d.sendHttpRequest)(a,{method:"POST",body:JSON.stringify(r),retries:2});h.ok||(yield(0,f.throwDexterAPIError)(h,"Couldn't add segment to subscriber.")),c.default.debug(`The segment has been added to the subscriber: ${n}.`),(0,u.setSubscriberDataToStorage)({segments:(0,p.uniqueArray)([...o,...n])})})),t.removeSegmentFromSubscriber=({segment:e,siteId:t,subscriberId:i})=>r(void 0,void 0,void 0,(function*(){b.segment(e);const n=Array.isArray(e)?e:[e],o=yield _(i);if(!v(o,n))return void c.default.debug(`The segment do not belong to the subscriber: ${n}.`);const s=(0,l.detectBrowser)(),r={device_token_hash:i,segment:(0,p.uniqueArray)(n),site_id:t},a=(0,g.addQueryParamsToUrl)(`${m.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/segments/remove`,{swv:m.env.__WORKER_VERSION__,bv:s.version}),h=yield(0,d.sendHttpRequest)(a,{method:"POST",body:JSON.stringify(r),retries:2});h.ok||(yield(0,f.throwDexterAPIError)(h,"Couldn't remove segment from subscriber."));const y=o.filter((e=>!n.includes(e)));c.default.debug(`The segment has been removed from the subscriber: ${n}.`),(0,u.setSubscriberDataToStorage)({segments:y})})),t.addSegmentWithDurationToSubscriber=({segment:e,siteId:t,subscriberId:i})=>r(void 0,void 0,void 0,(function*(){b.segmentWithDuration(e);const n=Array.isArray(e)?e:[e],o=n.map((e=>e.name)),s=yield _(i),r=(0,l.detectBrowser)(),a={device_token_hash:i,segments:n,site_id:t},v=(0,g.addQueryParamsToUrl)(`${m.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/dynamicSegments/add`,{swv:m.env.__WORKER_VERSION__,bv:r.version}),h=yield(0,d.sendHttpRequest)(v,{method:"POST",body:JSON.stringify(a),retries:2});h.ok||(yield(0,f.throwDexterAPIError)(h,"Couldn't add segment to subscriber.")),c.default.debug(`The segment, including its duration, has been added to the subscriber: ${o}.`),(0,u.setSubscriberDataToStorage)({segments:(0,p.uniqueArray)([...s,...o])})}))},7330:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getCartItems=t.getProductByTitle=t.isUrlReachable=void 0;const s=i(6405),r=o(i(7607)),a=i(4014);t.isUrlReachable=e=>n(void 0,void 0,void 0,(function*(){return!!(yield(0,s.sendHttpRequest)(e)).ok})),t.getProductByTitle=e=>n(void 0,void 0,void 0,(function*(){const t=yield(0,s.sendHttpRequest)(`/products/${e}.js`,{retries:1});if(!t.ok)return r.default.debug("Response not ok to get products:",t),null;try{const e=yield t.json();return(0,a.isObject)(e)?e:null}catch(e){return r.default.debug("Error occurred:",e),null}})),t.getCartItems=()=>n(void 0,void 0,void 0,(function*(){const e=yield(0,s.sendHttpRequest)("/cart.js",{retries:1});if(!e.ok)return r.default.debug("Response not ok to get cart items:",e),[];try{const t=yield e.json();if(!(0,a.isObject)(t))return[];const{items:i}=t;return Array.isArray(i)?i:[]}catch(e){return r.default.debug("Error occurred:",e),[]}}))},3502:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.updateAutomatedNotificationStatus=t.updateSubscriberStatus=t.syncSubscriberData=t.addSubscriberDataToSite=t.getSubscriberData=void 0;const s=i(6405),r=i(2689),a=o(i(7607)),d=i(9892),c=i(3241),l=i(4014),u=i(5453),g=i(1920),p=o(i(3321)),b=i(9340),f=e=>{const t={geobytestimezone:(null==e?void 0:e.timezone)||(0,r.getTimezoneName)()||(0,r.getTimezoneOffset)()};return e?(["country","internet","region","code","city","fqcn","ipaddress"].forEach((i=>{e[i]&&(t[`geobytes${i}`]=e[i])})),t):t},m=()=>n(void 0,void 0,void 0,(function*(){var e;const t=`${b.env.__TABOOLA_API_ENDPOINT__}/json/pushengage1-new/user.sync?app.type=web&app.apikey=${b.env.__TABOOLA_API_KEY__}`;try{const i=yield(0,s.sendHttpRequest)(t);if(i.ok&&200===i.status){const t=yield i.json();return(null===(e=null==t?void 0:t.user)||void 0===e?void 0:e.id)||null}return null}catch(e){return a.default.debug("Error occurred during getting taboola ads user id:",e),null}}));t.getSubscriberData=e=>n(void 0,void 0,void 0,(function*(){let t=null;try{t=yield(0,u.getSubscriberDataFromStorageOrAPI)(e)}catch(e){a.default.debug("Error occurred:",e)}return t})),t.addSubscriberDataToSite=({browserInfo:e,site:t,subscription:i,options:o={}})=>n(void 0,void 0,void 0,(function*(){var n,r;const d=f(o.geoInfo),l={subscription:i,site_id:t.site_id,browser_info:{device_type:e.name,browser_version:e.version.toString(),user_agent:e.userAgent,language:e.language,total_scr_width_height:e.screen,available_scr_width_height:e.availableScreen,colour_resolution:e.pixelDepth,host:e.host,device:e.device,pe_ref_url:e.referrer||e.href},geo_info:d,subscription_url:e.href,token_refresh:null!==(n=o.tokenRefresh)&&void 0!==n&&n};if(o.isPublisherSettingEnabled)try{const e=yield m();e&&(l.tid=e)}catch(e){a.default.debug("Couldn't get Taboola Ads User ID",e)}o.widgetOptInType?l.widget_optin_type=o.widgetOptInType:o.optInType&&(l.optin_type=o.optInType);const g=(0,c.addQueryParamsToUrl)(`${b.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/add`,{bv:e.version,swv:b.env.__WORKER_VERSION__}),v=yield(0,s.sendHttpRequest)(g,{method:"POST",body:JSON.stringify(l),retries:4});let _;v.ok||(yield(0,u.throwDexterAPIError)(v,"Couldn't add subscriber."));try{_=yield v.json()}catch(e){throw new p.default({message:"Error parsing response from add subscriber.",name:p.default.ERROR_NAME.SubscriberAdditionServerError})}if(_.error_code)throw new p.default({message:`Couldn't add subscriber. Error code: ${_.error_code}.`,name:p.default.ERROR_NAME.SubscriberAdditionServerError});if(!(null===(r=_.data)||void 0===r?void 0:r.subscriber_hash))throw new p.default({message:"Couldn't add subscriber. Subscriber hash is not available.",name:p.default.ERROR_NAME.SubscriberHashNotAvailableServerError});return _.data.subscriber_hash})),t.syncSubscriberData=({browserInfo:e,geoInfo:t,subscriberId:i,isPublisherSettingEnabled:o})=>n(void 0,void 0,void 0,(function*(){const n=yield(0,u.getSubscriberDataFromStorageOrAPI)(i);if(!n)return;const g=navigator.userAgent,p=(null==t?void 0:t.timezone)||(0,r.getTimezoneName)()||(0,r.getTimezoneOffset)(),v={};let _=!1;if(n.user_agent!==g&&(v.browser_info={user_agent:g,browser_version:e.version.toString(),device_type:e.name,language:e.language,total_scr_width_height:e.screen,available_scr_width_height:e.availableScreen,colour_resolution:e.pixelDepth,device:e.device}),!t||n.city===t.city&&n.timezone===p&&n.country===t.country&&n.state===t.state||(v.geo_info=f(t),_=!0),o&&(!n.tid||_)){const e=yield m();v.tid=e}if((0,l.isEmptyObject)(v))return void a.default.debug("The subscriber data is up to date.");const h=(0,c.addQueryParamsToUrl)(`${b.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/${i}`,{swv:b.env.__WORKER_VERSION__,bv:e.version});if((yield(0,s.sendHttpRequest)(h,{method:"PUT",body:JSON.stringify(v),retries:2})).ok){const i={timezone:p,city:null==t?void 0:t.city,country:null==t?void 0:t.country,state:null==t?void 0:t.region,user_agent:g,device_type:e.name,device:e.device};v.tid&&(i.tid=v.tid),(0,d.setSubscriberDataToStorage)(i),a.default.debug("The subscriber data has been updated in the storage.")}})),t.updateSubscriberStatus=({status:e,subscriberId:t,siteId:i})=>n(void 0,void 0,void 0,(function*(){const n=(0,g.detectBrowser)(),o=(0,c.addQueryParamsToUrl)(`${b.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/updatesubscriberstatus`,{swv:b.env.__WORKER_VERSION__,bv:n.version}),r=yield(0,s.sendHttpRequest)(o,{method:"POST",body:JSON.stringify({IsUnSubscribed:"unsubscribe"===e?1:0,device_token_hash:t,site_id:i}),retries:3});r.ok||(yield(0,u.throwDexterAPIError)(r,"Couldn't update subscriber status."))})),t.updateAutomatedNotificationStatus=({status:e,subscriberId:t,siteId:i})=>n(void 0,void 0,void 0,(function*(){const n="disabled"===e?0:1,o=yield(0,u.getSubscriberDataFromStorageOrAPI)(t);if((null==o?void 0:o.trigger_status)===n)return;const r=(0,g.detectBrowser)(),a=(0,c.addQueryParamsToUrl)(`${b.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/updatetriggerstatus`,{swv:b.env.__WORKER_VERSION__,bv:r.version}),l=yield(0,s.sendHttpRequest)(a,{method:"POST",body:JSON.stringify({triggerStatus:n,device_token_hash:t,site_id:i}),retries:2});l.ok||(yield(0,u.throwDexterAPIError)(l,"Couldn't update automated Notification status.")),(0,d.setSubscriberDataToStorage)({trigger_status:n})}))},6206:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},r=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sendTriggerEvent=void 0;const d=i(6405),c=s(i(2379)),l=i(9340),u=a(i(7607)),g=i(2689);t.sendTriggerEvent=({trigger:e,subscriberId:t,siteId:i})=>r(void 0,void 0,void 0,(function*(){u.default.debug("The trigger event is being sent for the subscriber."),c.sendTriggerEvent(e);const n=l.env.__TRIGGER_API_ENDPOINT__;if(!(yield(0,d.sendHttpRequest)(n,{method:"PUT",body:JSON.stringify({Data:Object.assign(Object.assign({},e),{site_id:i,device_token_hash:t,timezone:(0,g.getTimezoneOffset)()}),PartitionKey:t})})).ok)throw new Error("Couldn't send trigger event.");u.default.debug("The trigger event has been sent for the subscriber.")}))},1594:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addAlert=void 0;const n=i(4014);t.addAlert=e=>{if(!(0,n.isObject)(e))throw new Error("Alert must be an object.");if("inventory"!==e.type&&"price_drop"!==e.type)throw new Error("Alert type must be either inventory or price_drop.");if(!e.product_id)throw new Error("Product ID is required.");if(!e.price)throw new Error("Price is required.");if("number"!=typeof e.price&&"string"!=typeof e.price)throw new Error("Price must be a number.");if(e.alert_price&&"number"!=typeof e.alert_price&&"string"!=typeof e.alert_price)throw new Error("Alert price must be a number.");if(e.availability&&"inStock"!==e.availability&&"outOfStock"!==e.availability)throw new Error("Availability must be either inStock or outOfStock.")}},4379:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addAttributes=void 0;const n=i(4014);t.addAttributes=e=>{if(!(0,n.isObject)(e))throw new Error("Attributes must be an object.");if((0,n.isEmptyObject)(e))throw new Error("Attributes must not be empty.")}},5702:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.profileId=void 0,t.profileId=e=>{if(!e)throw new Error("Profile ID is required.");if("string"!=typeof e)throw new Error("Profile ID must be a string.")}},3314:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.segmentWithDuration=t.segment=void 0,t.segment=e=>{if(!e)throw new Error("Segment is required.");const t=Array.isArray(e)?e:[e];if(0===t.length)throw new Error("Segment is required.");for(let e=0;e{if(!e)throw new Error("Segment is required.");const t=Array.isArray(e)?e:[e];if(0===t.length)throw new Error("Segment is required.");for(let e=0;e{Object.defineProperty(t,"__esModule",{value:!0}),t.sendTriggerEvent=void 0;const n=i(4014);t.sendTriggerEvent=e=>{if(!(0,n.isObject)(e))throw new Error("Trigger event must be an object.");if(!e.campaign_name)throw new Error("Trigger event must have a campaign name.");if(!e.event_name)throw new Error("Trigger event must have a event name.")}},9851:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getSDKInitOptions=t.getAppData=t.setSDKInitOptions=t.setAppData=void 0;const i=new class{set appData(e){this._appData=e}get appData(){if(!this._appData)throw new Error("appData has not been set yet.");return this._appData}set sdkInitOptions(e){this._sdkInitOptions=e}get sdkInitOptions(){if(!this._sdkInitOptions)throw new Error("sdkInitOptions has not been set yet.");return this._sdkInitOptions}};t.setAppData=function(e){i.appData=e},t.setSDKInitOptions=function(e){i.sdkInitOptions=e},t.getAppData=function(){return i.appData},t.getSDKInitOptions=function(){return i.sdkInitOptions}},9340:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultSubscriptionManagementWidgetSetting=t.skipQueryParamsInWorkerPathSiteIds=t.brandName=t.quieterUIPermissionImage=t.env=t.workerMessengerCommand=t.database=t.defaultMinStorageDuration=t.poweredByReferralUrl=t.pushEngageHomePageUrl=t.defaultNotificationTitle=t.defaultNotificationTag=t.loadingIcon=t.bellPlusIcon=t.bellCheckIcon=t.bellCircleIcon=t.bellRingIcon=t.bellBadgeIcon=t.bellSettingIcon=t.closeIcon=t.bellIcon=t.defaultServiceWorkerSetting=t.widgetOptInType=t.optInTypes=t.storageName=void 0,t.storageName="PushEngageSDK",t.optInTypes={bell:3,floatingBar:2,largeSafari:6,largeSafariWithSegments:8,safari:1,singleStep:4,sleekOptInBox:9},t.widgetOptInType=127,t.defaultServiceWorkerSetting={scope:!0,workerStatus:!0,worker:"service-worker.js"},t.bellIcon='\n\n\n',t.closeIcon='\n\n',t.bellSettingIcon='',t.bellBadgeIcon='',t.bellRingIcon='',t.bellCircleIcon='',t.bellCheckIcon='',t.bellPlusIcon='',t.loadingIcon='',t.defaultNotificationTag="welcome_notification",t.defaultNotificationTitle="Click to see updates",t.pushEngageHomePageUrl="https://www.pushengage.com/",t.poweredByReferralUrl=`${t.pushEngageHomePageUrl}?utm_medium=referral&utm_campaign=powered_by&utm_source=pushengage_sdk`,t.defaultMinStorageDuration=7,t.database={name:"PushEngageSDK",stores:[{name:"ids",keyPath:"id"},{name:"failedViewedNotificationTags",keyPath:"id"},{name:"failedClickedNotificationTags",keyPath:"id"}],version:1},t.workerMessengerCommand={ampSubscriptionState:"amp-web-push-subscription-state",ampSubscribe:"amp-web-push-subscribe",ampUnsubscribe:"amp-web-push-unsubscribe"},t.env={__CDN_SERVER_HOST__:"https://clientcdn.pushengage.com",__SERVER_HOST__:"https://web-sdk.pushengage.com",__SAFARI_WEB_PUSH_PACKAGE_URL__:"https://safari.pushengage.com",__SUBSCRIBER_API_ENDPOINT__:"https://clients-api.pushengage.com/p/v1",__ANALYTICS_API_ENDPOINT__:"https://noti-analytics.pushengage.com/p/v1",__LOG_API_ENDPOINT__:"https://notify.pushengage.com/v1",__DOMAIN_NAME__:"pushengage.com",__OPT_IN_ANALYTICS_API_ENDPOINT__:"https://oeqepmcz7a.execute-api.us-east-1.amazonaws.com/beta/streams/optin/records",__SDK_VERSION__:"3.0.43",__WORKER_VERSION__:"3.0.43",__TABOOLA_API_ENDPOINT__:"https://api.taboola.com/1.2",__TABOOLA_API_KEY__:"a460a30141a022c6dc01526bba996da108798fd0",__TRIGGER_API_ENDPOINT__:"https://m4xrk918t5.execute-api.us-east-1.amazonaws.com/beta/streams/production_triggers/records",__STATIC_STORAGE_ENDPOINT__:"https://assetscdn.pushengage.com"},t.quieterUIPermissionImage={firefox:`${t.env.__STATIC_STORAGE_ENDPOINT__}/react-dashboard/design/reminder-firefox.png`,chrome:`${t.env.__STATIC_STORAGE_ENDPOINT__}/react-dashboard/design/reminder-chrome.png`},t.brandName="PushEngage",t.skipQueryParamsInWorkerPathSiteIds=[60413],t.defaultSubscriptionManagementWidgetSetting={enabled:!1,title:"Push Notification Settings",modal_background_color:"#ffffff",modal_text_color:"#0d0d0d",allow_text:"Show Notifications",on_switch_color:"#4642E5",off_switch_color:"#BFBFBF",trigger_button:{enabled:!0,size:"default",position_x:"right",position_y:"bottom",offset_top:100,offset_bottom:100,icon_background_color:"#ffffff",icon_color:"#4642E5",icon_type:"default",z_index:2147483640,rules:{enabled:!1,exclude_countries:[],exclude_devices:[],exclude:{},include_countries:[],include_devices:[],include:{}}},segment_preference:{enabled:!1,subscribed_title:"Subscribed Segments",exclude_subscribed_segments:[],show_all_subscribed_segment:!1,title:"Recommended Segments",segments:[],checkbox_background_color:"#ACB7C8",checkbox_tick_color:"#475FDE",default_segment_selection:!0},unsubscribe_options:{enabled:!1,confirm_message:"Are you sure? You will miss out on all our updates!",ok_text:"Yes",cancel_text:"No",ok_button_background_color:"#475FDE",ok_button_text_color:"#ffffff",cancel_button_background_color:"#ffffff",cancel_button_text_color:"#677489"},personal_notification_options:{enabled:!1,label:"Allow Personalized Notifications"}}},2121:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.transformSettings=t.transformServiceWorker=t.upgradeLegacyStorageData=t.validateRequiredSettings=void 0;const o=n(i(3321)),s=i(9340),r=i(4014),a=i(9892),d=i(9851),c=i(2471),l=i(606),u=i(2689),g=i(3110);t.validateRequiredSettings=({appData:e,sdkInitOptions:t})=>{const{optin_settings:i,vapid_key:n,gcm_options:s,privacy_settings:r,sub_analytics:a,service_worker:d,reset_notification_permission_popup:c}=e.siteSettings;if(!(i&&n&&d&&s&&r&&a&&c))throw new o.default({message:"Required setting are missing.",name:o.default.ERROR_NAME.RequiredSettingsMissing,details:{optInSetting:!!i,vapidSetting:!!n,serviceWorkerSetting:!!d,gcmSetting:!!s,privacySetting:!!r,optInAnalyticsSetting:!!a,resetNotificationPermissionPopupSetting:!!c,siteId:e.site.site_id}});if(!e.site)throw new o.default({message:"Site data is missing.",name:o.default.ERROR_NAME.SiteDataMissing,details:{appId:t.appId}})},t.upgradeLegacyStorageData=()=>{var e,t,i;const n=(0,d.getAppData)(),o=n.siteSettings.optin_settings,p=(0,l.getDataFromCookies)("peclosed"),b=(0,l.getDataFromCookies)("PushSubscriberStatus"),f=(0,l.getDataFromLocalStorage)("PushSubscriberHash"),m=(0,l.getDataFromLocalStorage)("PushSubscriberID"),v=["PushSubscriberHash","PushSubscriberID","PeSubData","PushSegments","PushBeforeSubData","PushSubscribeWidgetClosed","PushPersonalNotificationStatus","PushOptinReminder"];if((0,r.isNull)(p)&&!m&&!f&&!b)return;const _={},h=(0,g.getActiveOptInTypes)(o),y=(0,g.getSubscriptionOptIns)(o);let w=!0;for(let e=0;e{const e=(0,l.getDataFromLocalStorage)("PushBrowseStorageData"),t=(0,l.getDataFromLocalStorage)("PushCartStorageData"),i=(0,l.getDataFromLocalStorage)("pushPriceDropStorageData"),n=(0,l.getDataFromLocalStorage)("pushInventoryStorageData"),o={};if(e){const t=(0,r.convertStringToArray)(`${e}`).map((e=>(0,r.toInteger)(e)));o.browseVariantIds=t}if(t){const e=(0,r.convertStringToArray)(`${t}`).map((e=>(0,r.toInteger)(e)));o.cartVariantIds=e}if(i){const e=(0,r.convertStringToArray)(`${i}`).map((e=>(0,r.toInteger)(e)));o.priceDropVariantIds=e}if(n){const e=(0,r.convertStringToArray)(`${n}`).map((e=>(0,r.toInteger)(e)));o.backInStockVariantIds=e}return o})();return(0,r.isEmptyObject)(o)||(_.shopify=o),(0,l.setDataToLocalStorage)(s.storageName,_),(0,l.deleteDataFromLocalStorage)(v),void(0,l.deleteDataFromCookies)(["peclosed","PushSubscriberStatus"])}if("DENIED"===b){const e=(0,c.getNotificationPermission)({safariWebPushId:null===(i=n.siteSettings.safari_options)||void 0===i?void 0:i.push_id}),t=!(!w||"denied"!==e);return _.denied={data:{isSubDomain:!t,status:!0},expiresAt:(0,u.getUnixTime)(1)},(0,l.setDataToLocalStorage)(s.storageName,_),(0,l.deleteDataFromLocalStorage)(v),void(0,l.deleteDataFromCookies)(["peclosed"])}const S=(0,a.getParsedStorageData)("PushBeforeSubData"),I={};for(const e in S)if(e.includes("close_optin_id_")){const t=e.split("close_optin_id_")[1],i=S[e];I[t]={data:!0,expiresAt:i.max_age||(0,u.getUnixTime)(7)}}"CLOSED"===b&&h.length>0&&y.forEach((e=>{I[e.optin_type]={data:!0,expiresAt:(0,u.getUnixTime)(e.cookie_duration||7)}})),(0,r.isEmptyObject)(I)||(_.optInClosed=I,(0,l.setDataToLocalStorage)(s.storageName,_),(0,l.deleteDataFromLocalStorage)(v),(0,l.deleteDataFromCookies)(["peclosed","PushSubscriberStatus"]))},t.transformServiceWorker=({serviceWorkerSetting:e,sdkInitOptions:t,customSubDomainSetting:i,site:n})=>{const o=function(){var n,o,a,d,c,l,u,g,p,b,f,m;if(t.isSubscriptionOnSubDomain&&!i)return s.defaultServiceWorkerSetting;let{scope:v,workerStatus:_,worker:h}=e;return t.isShopifySite&&(h="/apps/pushengage/service-worker.js",v=!1),(0,r.isUndefined)(window.pathvars)||(h=null!==(o=null===(n=window.pathvars)||void 0===n?void 0:n.worker)&&void 0!==o?o:h,_=null!==(d=null===(a=window.pathvars)||void 0===a?void 0:a.workerStatus)&&void 0!==d?d:_,v=null!==(l=null===(c=window.pathvars)||void 0===c?void 0:c.scope)&&void 0!==l?l:v),(0,r.isObject)(t.serviceWorker)&&(h=null!==(g=null===(u=t.serviceWorker)||void 0===u?void 0:u.path)&&void 0!==g?g:h,_=null!==(b=null===(p=t.serviceWorker)||void 0===p?void 0:p.status)&&void 0!==b?b:_,v=null!==(m=null===(f=t.serviceWorker)||void 0===f?void 0:f.scope)&&void 0!==m?m:v),{scope:v,workerStatus:_,worker:h}}();if(!s.skipQueryParamsInWorkerPathSiteIds.includes(n.site_id)){const{worker:e}=o,i=`v=${s.env.__WORKER_VERSION__}&appId=${t.appId}`;o.worker=e.includes("?")?`${e}&${i}`:`${e}?${i}`}return o},t.transformSettings=({appData:e,sdkInitOptions:i})=>{e.siteSettings.service_worker=(0,t.transformServiceWorker)({sdkInitOptions:i,serviceWorkerSetting:e.siteSettings.service_worker,customSubDomainSetting:e.siteSettings.custom_url,site:e.site})}},5004:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(3609),r=o(i(7607)),a=i(1791),d=o(i(3321)),c=i(2326),l=i(1041),u=i(6496),g=i(2004),p=i(4963),b=i(2047),f=i(1919),m=i(8343),v=i(1860),_=i(7328),h=i(5021),y=i(4014),w=i(9851),S=i(2121),I=i(5544);n(void 0,void 0,void 0,(function*(){try{const e=window.__PushEngageSDKInitOptions;if(!e)throw new d.default({message:"Initialization options have not been provided.",name:d.default.ERROR_NAME.SDKInitOptionsNotFound,details:{url:location.href}});let t;(0,w.setSDKInitOptions)(e);try{t=yield(0,h.getAppData)({appId:e.appId})}catch(e){return void r.default.error(e.message)}if(!t||(0,y.isEmptyObject)(t)){const e="App data is not available.";return void r.default.error(e)}(0,S.validateRequiredSettings)({appData:t,sdkInitOptions:e}),(0,S.transformSettings)({appData:t,sdkInitOptions:e}),(0,w.setAppData)(t),yield(0,s.isDOMContentLoaded)(),(0,S.upgradeLegacyStorageData)(),(0,l.addClickEventListenerForHandleSubscription)(),(0,c.addMessageEventListener)(),(0,p.addEventListenerForUnsubscribeWidget)(),(0,b.addEventListenerForSubscriberRecoveryWidget)(),(0,f.addEventListenerForAddSegment)(),(0,m.addEventListenerForShopifyCampaign)(),(0,v.addEventListenerForSubscriptionManagementWidget)(),(0,_.processFailedAnalytics)(),(0,I.syncDatabase)();const i=window.PushEngage,n=window._peq;(0,u.initializeSDK)({commands:i,legacyCommands:n}),yield(0,g.initializeSubscription)({triggerFrom:"onInit"}),r.default.debug("The subscription process has been completed on page load.")}catch(e){r.default.error(e.message),(0,a.sendErrorLog)("sdk",e,{url:location.href})}}))},3321:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});class i extends Error{constructor({message:e,name:t="AppError",details:i={},type:n="Error"}){super(e),this.details=i,this.name=t,this.type=n}}i.ERROR_NAME={InvalidAppId:"InvalidAppId",UnsubscribedFailedFromWorker:"UnsubscribedFailedFromWorker",NotPushEngagePayload:"NotPushEngagePayload",PayloadLessInvalidNotificationPayload:"PayloadLessInvalidNotificationPayload",InvalidNotificationPayload:"InvalidNotificationPayload",PushPayloadParseError:"PushPayloadParseError",OfflineError:"OfflineError",OpenNotificationUrlFailed:"OpenNotificationUrlFailed",SendOptInAnalyticsError:"SendOptInAnalyticsError",QuotaExceededError:"QuotaExceededError",DisabledPushSubscriptionError:"DisabledPushSubscriptionError",IndexedDBOpenError:"IndexedDBOpenError",UnknownError:"UnknownError",PayloadLessFetchError:"PayloadLessFetchError",PayloadLessParseError:"PayloadLessParseError",PushPayloadFetchError:"PushPayloadFetchError",NotificationParseError:"NotificationParseError",RequiredSettingsMissing:"RequiredSettingsMissing",SiteDataMissing:"SiteDataMissing",HttpRequestError:"HttpRequestError",UserNotSubscribed:"UserNotSubscribed",ServiceWorkerNotFound:"ServiceWorkerNotFound",ServiceWorkerNotRegistering:"ServiceWorkerNotRegistering",SDKInitOptionsNotFound:"SDKInitOptionsNotFound",RequestPermissionNotSupported:"RequestPermissionNotSupported",SubscriberAdditionServerError:"SubscriberAdditionServerError",SubscriberHashNotAvailableServerError:"SubscriberHashNotAvailableServerError",LocalStorageNotAvailable:"LocalStorageNotAvailable",SubscriptionAlreadyInitialized:"SubscriptionAlreadyInitialized"},i.ERROR_TYPE={IndexedDBError:"IndexedDBError",DexterServerError:"DexterServerError"},i.ERROR_MESSAGE={InvalidAppId:"AppId is not defined.",UserNotSubscribed:"User is not subscribed."},t.default=i},3110:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.triggerCampaignTypesAvailability=t.isServiceWorkerAvailable=t.getSegmentNamesFromRules=t.isServiceWorkerAvailabilityEnabled=t.getSubDomainSubscriptionUrl=t.canSubscribeViaServiceWorker=t.filterSubscriptionOptInsByRules=t.isSatisfyingSubscriptionRules=t.getSubscriptionOptIns=t.getActiveOptInTypes=t.isDeviceSatisfyingDeviceRules=t.isCountrySatisfyingCountryRules=t.isUrlSatisfyingUrlRules=void 0;const r=i(1920),a=i(3241),d=s(i(4014)),c=i(8405),l=i(9340),u=i(5827),g=i(4014);t.isUrlSatisfyingUrlRules=(e,t=location.href)=>{const{include:i,exclude:n}=e;let o=!0;i&&(o=!!((0,g.isEmptyArray)(i.contains)&&(0,g.isEmptyArray)(i.start)&&(0,g.isEmptyArray)(i.exact))||(0,u.isUrlSatisfyingRules)(i,t));let s=!0;return n&&(s=!!((0,g.isEmptyArray)(n.contains)&&(0,g.isEmptyArray)(n.start)&&(0,g.isEmptyArray)(n.exact))||!(0,u.isUrlSatisfyingRules)(n,t)),o&&s},t.isCountrySatisfyingCountryRules=(e,t)=>{const{include_countries:i,exclude_countries:n}=e;let o=!0;(null==i?void 0:i.length)&&(o=i.some((e=>e.toLowerCase()===t.toLowerCase())));let s=!0;return(null==n?void 0:n.length)&&(s=!n.some((e=>e.toLowerCase()===t.toLowerCase()))),o&&s},t.isDeviceSatisfyingDeviceRules=(e,t)=>{const{include_devices:i,exclude_devices:n}=e;let o=!0;i&&i.length&&(o=i.some((e=>e.toLowerCase()===t.toLowerCase())));let s=!0;return n&&n.length&&(s=!n.some((e=>e.toLowerCase()===t.toLowerCase()))),o&&s},t.getActiveOptInTypes=e=>{const t=(0,a.detectSiteType)();return d.get(e,`activeOptin.${t}.types`)||[]},t.getSubscriptionOptIns=e=>{const t=e.optins;if(!t)return[];const i=(0,r.detectDeviceType)(),n=(0,a.detectSiteType)(),o=[];for(const e in t){const s=t[e],r=d.get(s,`${i}.${n}`);r&&o.push(r)}return o},t.isSatisfyingSubscriptionRules=(e,i)=>{if(!e)return!0;const n=i.country||"",o=(0,t.isCountrySatisfyingCountryRules)(e,n),s=(0,t.isUrlSatisfyingUrlRules)(e,location.href);return!(!o||!s)},t.filterSubscriptionOptInsByRules=(e,i,n)=>{const o=(0,t.getActiveOptInTypes)(e),s=(0,t.getSubscriptionOptIns)(e);if(!o.length||!s.length)return[];const r=i?[]:o;if(i)for(let e=0;e{const t=(0,a.detectSiteType)(),{name:i,version:n}=(0,r.detectBrowser)();return"Safari"===i&&n<=15||"http"!==t&&!!e},t.getSubDomainSubscriptionUrl=({customSubDomainSetting:e,siteSubDomain:t})=>e?{url:e.url,type:e.type}:{url:`https://${t}.${l.env.__DOMAIN_NAME__}/`,type:"window"},t.isServiceWorkerAvailabilityEnabled=e=>(0,t.getSubscriptionOptIns)(e).some((e=>e.optin_sw_support)),t.getSegmentNamesFromRules=e=>{const i=[];if(!e)return i;const n=location.href;return e.forEach((e=>{e.add_segment_on_page_load&&e.segment_criteria&&(0,t.isUrlSatisfyingUrlRules)({include:e.segment_criteria.include,exclude:e.segment_criteria.exclude},n)&&i.push(e.segment_name)})),i},t.isServiceWorkerAvailable=({optInSetting:e})=>{let i=!0;return(0,t.getSubscriptionOptIns)(e).length&&(i=(0,t.isServiceWorkerAvailabilityEnabled)(e)),i},t.triggerCampaignTypesAvailability=({browseAbandonments:e,cartAbandonments:t,priceDropAlerts:i,backInStockAlerts:n,customTriggerCampaigns:o})=>{const s=e.filter((e=>"active"===e.status)),r=t.filter((e=>"active"===e.status)),a=i.filter((e=>"active"===e.status)),d=n.filter((e=>"active"===e.status)),c=o.filter((e=>"active"===e.status));return{hasBrowseAbandonment:!!s.length,hasCartAbandonment:!!r.length,hasPriceDropAlert:!!a.length,hasBackInStockAlert:!!d.length,hasCustomTriggerCampaign:!!c.length}}},8648:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.processNotificationPermission=t.processNotificationPermissionClosedData=t.processNotificationPermissionDeniedData=t.processSubscriptionData=void 0;const s=i(3502),r=i(9892),a=o(i(7607)),d=i(1920),c=i(6547),l=i(9340),u=i(953),g=i(3241),p=i(4014),b=i(5021);t.processSubscriptionData=({site:e,subscription:t,siteSettings:i,options:o={}})=>n(void 0,void 0,void 0,(function*(){const{gcm_options:n,vapid_key:r,privacy_settings:c,publisher_settings:l,safari_options:g}=i;let p;p="deviceToken"in t?{endpoint:t.deviceToken,project_id:g.push_id}:Object.assign(Object.assign(Object.assign({},t),n),{vapid_public_key:r.public_key});const f=(0,d.getBrowserInfo)(),m=yield(0,b.getGeoInfo)({isEu:e.is_eu}),v=yield(0,s.addSubscriberDataToSite)({browserInfo:f,site:e,subscription:p,options:{geoInfo:c.geoLocationEnabled?m:void 0,optInType:o.optInType,tokenRefresh:o.tokenRefresh,isPublisherSettingEnabled:null==l?void 0:l.enabled,widgetOptInType:o.widgetOptInType}}),{segment:_}=o;if(_&&(Array.isArray(_)?_:[_]).length)try{yield(0,u.addSegmentToSubscriber)({segment:_,subscriberId:v,siteId:e.site_id})}catch(e){a.default.warn(e)}return v})),t.processNotificationPermissionDeniedData=({optInType:e,site:t})=>n(void 0,void 0,void 0,(function*(){const i={optin_type:e,site_id:t.site_id};e===l.optInTypes.singleStep?Object.assign(i,{block_1:!0,optin_1:!0}):Object.assign(i,{allow_1:!0,optin_1:!0,block_2:!0,optin_2:!0}),yield(0,c.sendOptInAnalytics)(i)})),t.processNotificationPermissionClosedData=({optInType:e,site:t})=>n(void 0,void 0,void 0,(function*(){const i={optin_type:e,site_id:t.site_id};e===l.optInTypes.singleStep?Object.assign(i,{close_1:!0,optin_1:!0}):Object.assign(i,{allow_1:!0,optin_1:!0,close_2:!0,optin_2:!0}),yield(0,c.sendOptInAnalytics)(i)})),t.processNotificationPermission=({siteSettings:e,permissionData:i,site:o,optInType:s,options:c={}})=>n(void 0,void 0,void 0,(function*(){var n;a.default.debug("Process notification permission.");const u=((e,t)=>{const i=(0,d.detectDeviceType)(),n=(0,g.detectSiteType)(),o=(0,p.get)(e,`optins.${t}.${i}.${n}`);return o?o.cookie_duration:l.defaultMinStorageDuration})(e.optin_settings,s),b=null!==(n=c.isSubDomain)&&void 0!==n&&n;if("granted"===i.permission&&i.subscription){const n=yield(0,t.processSubscriptionData)({siteSettings:e,site:o,subscription:i.subscription,options:{optInType:s,segment:c.segment,tokenRefresh:c.tokenRefresh,widgetOptInType:c.widgetOptInType}});(0,r.storeSubscriptionDataInStorage)({isSubDomain:b,subscriberId:n,subscription:i.subscription}),a.default.debug("The subscriber has been added to the site, and the subscriber data has been sent to PushEngage and stored in storage.")}else"denied"===i.permission?(yield(0,t.processNotificationPermissionDeniedData)({optInType:s,site:o}),(0,r.storeSubscriptionDeniedDataInStorage)({storageDuration:u,isSubDomain:b}),a.default.debug("The current permission status is denied, and the opt-in impression analytics have been sent to PushEngage and the status has been stored in storage.")):(yield(0,t.processNotificationPermissionClosedData)({optInType:s,site:o}),c.widgetOptInType||(0,r.storeOptInCloseDataInStorage)({optInType:s,storageDuration:u}),a.default.debug("The current permission status is default(clicked on X or, auto closed), and the opt-in impression analytics have been sent to PushEngage and the status has been stored in storage."))}))},1734:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.handleMessageUnsubscribeState=t.handleMessageSubscribeState=t.handleMessageSubscriptionState=t.handleNotificationOpenUrl=t.handleNotificationClick=t.showDefaultNotification=t.showNotification=t.formatNotifications=t.parseOrFetchNotifications=t.isValidPushPayload=t.getNotificationUrlAndUserAction=t.broadcastReply=t.checkAndUpdateNotificationInDbByKey=t.processFailedAnalytics=t.getAppId=void 0;const s=i(1920),r=i(2768),a=o(i(7607)),d=i(4014),c=i(5021),l=i(3502),u=i(9340),g=o(i(3321)),p=i(4318),b=i(3609),f=i(7224),m=i(1791),v=i(3241);t.getAppId=()=>n(void 0,void 0,void 0,(function*(){let e=(0,v.getValueFromUrlByKey)("appId",location.href)||null;if(e)return e;try{e=yield(0,p.getAppId)()}catch(t){e=null}return e||(e="undefined"!=typeof PUSHENGAGE_APP_ID?PUSHENGAGE_APP_ID:null,e)})),t.processFailedAnalytics=()=>n(void 0,void 0,void 0,(function*(){try{const e=yield(0,p.getFailedViewedNotificationTags)();for(let t=0;tn(void 0,void 0,void 0,(function*(){try{const i=yield(0,p.getNotificationTagsByKey)(t);if(i.length){const t=(0,b.removeSubscriberIdFromTag)(e);if(i.some((e=>t===(0,b.removeSubscriberIdFromTag)(e))))return!0}yield(0,p.updateNotificationTagByKey)(e,t)}catch(e){a.default.error(`Error while checking and updating notification tag in db, ${e.message}`)}return!1})),t.broadcastReply=(e,t)=>n(void 0,void 0,void 0,(function*(){const i=yield self.clients.matchAll();for(let n=0;n{let i="action3",n=(0,d.isObject)(e)?null==e?void 0:e.url:e,o=null;return t&&(o=(0,d.safeParse)(t)),"action1"==(null==o?void 0:o.action)?(i="action1",n=o.action_url||n):"action2"==(null==o?void 0:o.action)&&(i="action2",n=o.action_url||n),{userAction:i,notificationUrl:n||"/"}},t.isValidPushPayload=e=>!!(e&&Array.isArray(e)&&e.length&&e[0].options&&e[0].options.tag),t.parseOrFetchNotifications=(e,i)=>n(void 0,void 0,void 0,(function*(){var n,o,s;if(!(null==e?void 0:e.data))return yield(0,f.fetchPayloadLessNotifications)(i);let r;try{r=e.data.json()}catch(t){throw new g.default({message:`Parsing of the push payload failed, ${e.data.text()}.`,name:"PushPayloadParseError",details:{worker:self.location.href}})}if(!(0,t.isValidPushPayload)(r))throw new g.default({message:"Valid JSON but not PushEngage payload.",name:"NotPushEngagePayload",details:{payload:r,worker:self.location.href}});const a=r[0];return(null===(n=a.options)||void 0===n?void 0:n.tag)&&(d=a.options).customData&&d.customData.refetch?yield(0,f.fetchPayloadNotifications)({tag:a.options.tag,postback:(null===(s=null===(o=a.options)||void 0===o?void 0:o.customData)||void 0===s?void 0:s.postback)||""}):[a];var d})),t.formatNotifications=e=>e.map((e=>{const{tag:t,data:i,actions:n}=e.options||{},o=t?t.toString():"",s=[];return n&&Array.isArray(n)&&n.forEach((function(e){e.icon||s.push((0,d.omit)(e,["icon"]))})),Object.assign(Object.assign({},e),{options:Object.assign(Object.assign({},e.options),{tag:(0,b.removeSubscriberIdFromTag)(o),actions:s.length?s:void 0,data:{originalTag:o,url:i||""}})})})),t.showNotification=({title:e,subscription:i,notificationOptions:o})=>n(void 0,void 0,void 0,(function*(){var s;if("granted"===Notification.permission){if((null==o?void 0:o.tag)&&o.tag.includes(u.defaultNotificationTag))return self.registration.showNotification(e,o);if(yield self.registration.showNotification(e,o),(null==o?void 0:o.viewUrl)&&(null==o?void 0:o.tag))try{yield(0,f.sendNotificationViewedReferAnalytics)({tag:(null===(s=null==o?void 0:o.data)||void 0===s?void 0:s.originalTag)||o.tag}),a.default.info("Response from view refer analytics")}catch(e){a.default.info(`Failed response from view refer analytics, ${e.name}`)}if(null==o?void 0:o.tag)try{yield(({notificationOptions:e,subscription:i})=>n(void 0,void 0,void 0,(function*(){var n;if(yield(0,t.processFailedAnalytics)(),!(null==e?void 0:e.tag))return;const o=(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.originalTag)||(null==e?void 0:e.tag);if(!(yield(0,t.checkAndUpdateNotificationInDbByKey)(o,"viewedNotificationTags")))try{yield(0,f.sendNotificationViewedAnalytics)({tag:o}),a.default.info("Response from viewed analytics")}catch(e){if(a.default.info(`Failed response from viewed analytics, ${e.name}`),!1===navigator.onLine)try{yield(0,p.addFailedViewedNotificationTag)({tag:o})}catch(e){a.default.error(`Failed to add failed viewed notification tag to db, ${e.message}`)}else(0,m.sendErrorLog)("service-worker",e,{tag:o,name:"viewCountTrackingFailed",endpoint:i.endpoint,data:{tag:o}})}})))({notificationOptions:o,subscription:i})}catch(e){a.default.info(`Failed to handle notification view, ${e.name}`)}}})),t.showDefaultNotification=({subscription:e})=>n(void 0,void 0,void 0,(function*(){const i=yield(0,t.getAppId)(),n={subscription:e,notificationOptions:{data:{url:"/",originalTag:u.defaultNotificationTag},tag:u.defaultNotificationTag,requireInteraction:!1},title:u.defaultNotificationTitle};if(!i)return a.default.debug("AppId is not present in the service worker URL."),void(yield(0,t.showNotification)(n));let o=null;try{o=yield(0,c.getAppData)({source:"service-worker",appId:i})}catch(e){return a.default.info(`${e.message}`),void(yield(0,t.showNotification)(n))}if(!o)throw yield(0,t.showNotification)(n),new g.default({name:"AppDataEmpty",message:"App data is not available.",details:{appId:i,worker:self.location.href}});const s=o.siteSettings.default_notification;if(!s)throw yield(0,t.showNotification)(n),new g.default({name:"DefaultNotificationSettingNotFound",message:"Default notification setting is not available.",details:{appId:i,worker:self.location.href}});const r=o.site,d={body:s.default_notification_message,icon:r.site_image,tag:`${u.defaultNotificationTag}${r.site_id}`,data:{url:s.default_notification_url,originalTag:u.defaultNotificationTag},requireInteraction:!1};yield(0,t.showNotification)({subscription:e,notificationOptions:d,title:s.default_notification_title})})),t.handleNotificationClick=({notificationOptions:e,userAction:i,subscription:o})=>n(void 0,void 0,void 0,(function*(){var n;if(!e.tag||e.tag.includes(u.defaultNotificationTag)||"user_visible_auto_notification"===e.tag)return;const s=(null===(n=e.data)||void 0===n?void 0:n.originalTag)||e.tag;if(!(yield(0,t.checkAndUpdateNotificationInDbByKey)(s,"clickedNotificationTags")))try{yield(0,f.sendNotificationClickedAnalytics)({tag:s,action:i}),a.default.info("Response from clicked analytics")}catch(e){if(a.default.info(`Failed response from clicked analytics, ${e.name}`),!1===navigator.onLine)try{yield(0,p.addFailedClickedNotificationTag)({tag:s,action:i})}catch(e){a.default.error(`Failed to add failed clicked notification tag to db, ${e.message}`)}else(0,m.sendErrorLog)("service-worker",e,{tag:s,name:"clickCountTrackingFailed",endpoint:o.endpoint,action:i,data:{tag:s,action:i}})}})),t.handleNotificationOpenUrl=e=>n(void 0,void 0,void 0,(function*(){const t=yield self.clients.matchAll({type:"window"});for(let i=0;in(void 0,void 0,void 0,(function*(){const e=yield self.registration.pushManager.getSubscription();if(!e)return void(yield(0,t.broadcastReply)(u.workerMessengerCommand.ampSubscriptionState,!1));const i=yield self.registration.pushManager.permissionState(e.options);yield(0,t.broadcastReply)(u.workerMessengerCommand.ampSubscriptionState,"granted"===i)})),t.handleMessageSubscribeState=()=>n(void 0,void 0,void 0,(function*(){const e=yield(0,t.getAppId)();if(!e)throw new g.default({name:"AppIdNotFound",message:"AppId is not present in the service worker URL",details:{appId:e,worker:self.location.href}});let i;try{i=yield(0,c.getAppData)({appId:e,source:"service-worker-amp"})}catch(t){throw new g.default({name:"InvalidAppId",message:t.message,details:{appId:e,worker:self.location.href}})}if(!i)throw new g.default({name:"AppDataEmpty",message:"App data is not available.",details:{appId:e,worker:self.location.href}});const{gcm_options:n,privacy_settings:o,vapid_key:p}=i.siteSettings,b=i.site.site_id;if(!p)throw new g.default({name:"VAPIDSettingNotFound",message:"VAPID setting is not available.",details:{appId:e,siteId:b}});if(!n)throw new g.default({name:"GCMSettingNotFound",message:"GCM setting is not available.",details:{appId:e,siteId:b}});let f;try{f=yield(0,r.subscribeToPushNotificationFromWorker)(p.public_key)}catch(t){throw new g.default({name:"AMPSubscribeFailed",message:`Failed to subscribe to push notifications, ${t.message}`,details:{appId:e,siteId:b}})}let m,v="";try{v=yield self.clients.matchAll({includeUncontrolled:!0,type:"window"}).then((e=>0===e.length?"":e[0].url))}catch(e){(0,d.noop)()}o.geoLocationEnabled&&(m=yield(0,c.getGeoInfo)({isEu:i.site.is_eu}));const{name:_,version:h}=(0,s.detectBrowser)(),y={browserInfo:{name:_,version:h,device:(0,s.detectDeviceType)(),host:self.location.host,href:v,language:navigator.language,userAgent:navigator.userAgent,referrer:self.location.origin},site:i.site,subscription:Object.assign(Object.assign({},f),{project_id:n.project_id,vapid_public_key:p.public_key}),options:{geoInfo:m,optInType:u.optInTypes.singleStep}};try{yield(0,l.addSubscriberDataToSite)(y),a.default.debug("Subscription added."),yield(0,t.broadcastReply)(u.workerMessengerCommand.ampSubscribe,null)}catch(e){throw new g.default({name:"AddSubscriptionFailed",message:`Failed to adding subscription, ${e.message}`,details:{data:y}})}})),t.handleMessageUnsubscribeState=()=>n(void 0,void 0,void 0,(function*(){const e=yield self.registration.pushManager.getSubscription();if(e)try{yield e.unsubscribe(),a.default.debug("Subscription unsubscribed."),yield(0,t.broadcastReply)(u.workerMessengerCommand.ampUnsubscribe,null)}catch(e){throw new g.default({message:`Failed unsubscribe to push notifications, ${e.message}.`,name:"UnsubscribedFailedFromWorker",details:{worker:self.location.href}})}}))},9432:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.getLegacySDKShopifyCheckoutOrderIds=t.getImageUrlsFromCartItem=t.getImageUrlsFromProduct=t.getImageUrlsFromVariant=t.filterVariantFromVariantId=t.getSelectedVariantId=t.getPageType=t.convertPriceToFloat=void 0;const o=i(4014),s=i(606),r=i(7330),a=({imageUrl:e,width:t,height:i})=>n(void 0,void 0,void 0,(function*(){let n=(({url:e,width:t,height:i})=>{const n=[".png",".jpg",".jpeg",".gif",".webp"];if(!e.includes("cdn.shopify.com"))return e;for(const o of n)if(e.includes(o))return e.replace(o,`_${t}x${i}${o}`);return e})({width:t,height:i,url:e});var o;if(0!==(o=n).indexOf("https:")&&0!==o.indexOf("http:")&&(o="https:"+o),n=o,yield(0,r.isUrlReachable)(n))return n}));t.convertPriceToFloat=e=>parseFloat(""+e/100).toFixed(2),t.getPageType=()=>{var e,t,i;return null===(i=null===(t=null===(e=window.ShopifyAnalytics)||void 0===e?void 0:e.meta)||void 0===t?void 0:t.page)||void 0===i?void 0:i.pageType},t.getSelectedVariantId=()=>{var e,t;return null===(t=null===(e=window.ShopifyAnalytics)||void 0===e?void 0:e.meta)||void 0===t?void 0:t.selectedVariantId},t.filterVariantFromVariantId=(e,t)=>{var i,n;return t?null===(n=e.variants)||void 0===n?void 0:n.find((e=>e.id===(0,o.toInteger)(t))):null===(i=e.variants)||void 0===i?void 0:i[0]},t.getImageUrlsFromVariant=e=>n(void 0,void 0,void 0,(function*(){var t;const i=null===(t=null==e?void 0:e.featured_image)||void 0===t?void 0:t.src;if(!i||"string"!=typeof i)return{};const[n,o]=yield Promise.all([a({imageUrl:i,width:364,height:180}),a({imageUrl:i,width:192,height:192})]);return{largeImageUrl:n,imageUrl:o}})),t.getImageUrlsFromProduct=e=>n(void 0,void 0,void 0,(function*(){const t=e.featured_image;if(!t||"string"!=typeof t)return{};const[i,n]=yield Promise.all([a({imageUrl:t,width:364,height:180}),a({imageUrl:t,width:192,height:192})]);return{largeImageUrl:i,imageUrl:n}})),t.getImageUrlsFromCartItem=e=>n(void 0,void 0,void 0,(function*(){const t=e.image;if(!t||"string"!=typeof t)return{};const[i,n]=yield Promise.all([a({imageUrl:t,width:364,height:180}),a({imageUrl:t,width:192,height:192})]);return{largeImageUrl:i,imageUrl:n}})),t.getLegacySDKShopifyCheckoutOrderIds=()=>{const e=(0,s.getDataFromLocalStorage)("PushCheckoutStorageData");let t=[];return e&&(t=(0,o.convertStringToArray)(`${e}`).map((e=>String(e)))),t}},1730:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},r=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.unsubscribeSubscription=t.getUserSubscriptionState=t.evaluateUserSubscriptionState=t.isAllSubscriptionOptInClosed=t.subscriptionNeedToBeResubscribed=t.resubscribeSubscription=void 0;const d=s(i(9892)),c=s(i(2768)),l=i(2471),u=i(1920),g=i(9340),p=a(i(7607)),b=i(3502),f=i(9892),m=i(3110),v=({error:e,optInSetting:t})=>["ServiceWorkerNotRegistering","ServiceWorkerNotFound","DisabledPushSubscriptionError"].includes(e.name)&&(0,m.isServiceWorkerAvailable)({optInSetting:t});t.resubscribeSubscription=({vapidSetting:e,serviceWorkerSetting:t,safariWebPushPackageSetting:i})=>r(void 0,void 0,void 0,(function*(){if("granted"!==(0,l.getNotificationPermission)({safariWebPushId:null==i?void 0:i.push_id}))throw new Error("Notification permission is not granted, so it is not possible to obtain the subscription.");const{name:n}=(0,u.detectBrowser)(),o=(0,u.detectDeviceType)();if("Safari"===n&&!(0,l.hasSupportForPushApiInSafari)()){if(!i)throw new Error("Safari Web Push Package is not configured.");const e=c.getSafariSubscription(i.push_id);if("granted"===e.permission)return e;throw new Error("Safari Notification permission is not granted, so it is not possible to obtain the subscription.")}const s=d.getSubscriberIdFromStorage();let r;s&&(r=yield(0,b.getSubscriberData)(s));const a={vapidPublicKey:e.public_key};let g;if(t.workerStatus&&(a.options={scope:t.scope?"/":void 0},a.scriptURL=t.worker),"Firefox"===n&&"mobile"===o){if(r&&r.vapid_public_key!==e.public_key)throw new Error("The applicationServerKey has changed, so it's not possible to resubscribe.");const t=yield c.getPushSubscription({scriptURL:a.scriptURL,options:a.options});if(!t)throw new Error("Subscription not found.");g=t}else if(r&&r.vapid_public_key!==e.public_key)yield c.unsubscribeFromPushSubscription(),g=yield c.subscribeToPushNotification(a);else try{g=yield c.subscribeToPushNotification(a)}catch(e){if("InvalidStateError"!==e.name)throw e;yield c.unsubscribeFromPushSubscription(),g=yield c.subscribeToPushNotification(a)}return g})),t.subscriptionNeedToBeResubscribed=({vapidSetting:e,serviceWorkerSetting:i,safariWebPushPackageSetting:n})=>r(void 0,void 0,void 0,(function*(){if("granted"!==(0,l.getNotificationPermission)({safariWebPushId:null==n?void 0:n.push_id}))return;const o=d.getParsedStorageData(g.storageName),s=yield(0,t.resubscribeSubscription)({vapidSetting:e,serviceWorkerSetting:i,safariWebPushPackageSetting:n});return!s||o.id&&(s.endpoint||s.deviceToken)===o.endpoint?void 0:s})),t.isAllSubscriptionOptInClosed=e=>{const t=(0,m.getActiveOptInTypes)(e);return!(!t.length||!d.isSubscriptionOptInClosed(t))},t.evaluateUserSubscriptionState=({optInSetting:e,vapidSetting:i,serviceWorkerSetting:n,safariWebPushPackageSetting:o})=>r(void 0,void 0,void 0,(function*(){if(d.isSubscriptionUnsubscribed({notificationPermission:(0,l.getNotificationPermission)({safariWebPushId:null==o?void 0:o.push_id})}))return{state:"unsubscribed"};try{const e=yield(0,t.subscriptionNeedToBeResubscribed)({vapidSetting:i,serviceWorkerSetting:n,safariWebPushPackageSetting:o});if(e)return{subscription:e,state:"resubscribe"}}catch(t){if(v({error:t,optInSetting:e}))throw t;!1===d.isSubscriptionOnSubDomain()&&d.clearOldSubscriptionDataFromStorage(),p.default.debug(t)}if(d.isSubscriptionDenied({notificationPermission:(0,l.getNotificationPermission)({safariWebPushId:null==o?void 0:o.push_id})}))return{state:"denied"};if(d.hasSubscriptionDataInStorage({notificationPermission:(0,l.getNotificationPermission)({safariWebPushId:null==o?void 0:o.push_id})})){const s=d.getSubscriberIdFromStorage(),r=yield(0,b.getSubscriberData)(s);if(r&&1!==r.has_unsubscribed)return{state:"subscribed"};d.clearOldSubscriptionDataFromStorage();try{const e=yield(0,t.subscriptionNeedToBeResubscribed)({vapidSetting:i,serviceWorkerSetting:n,safariWebPushPackageSetting:o});if(e)return{subscription:e,state:"resubscribe"}}catch(t){if(v({error:t,optInSetting:e}))throw t;p.default.debug(t)}}return(0,t.isAllSubscriptionOptInClosed)(e)?{state:"closed"}:(d.clearOldSubscriptionDataFromStorage(),{state:"default"})})),t.getUserSubscriptionState=({optInSetting:e,safariWebPushPackageSetting:i})=>r(void 0,void 0,void 0,(function*(){if(d.isSubscriptionUnsubscribed({notificationPermission:(0,l.getNotificationPermission)({safariWebPushId:null==i?void 0:i.push_id})}))return"unsubscribed";if(d.isSubscriptionDenied({notificationPermission:(0,l.getNotificationPermission)({safariWebPushId:null==i?void 0:i.push_id})}))return"denied";if(d.hasSubscriptionDataInStorage({notificationPermission:(0,l.getNotificationPermission)({safariWebPushId:null==i?void 0:i.push_id})})){const e=d.getSubscriberIdFromStorage(),t=yield(0,b.getSubscriberData)(e);return t&&1!==t.has_unsubscribed?"subscribed":(d.clearOldSubscriptionDataFromStorage(),"default")}return(0,t.isAllSubscriptionOptInClosed)(e)?"closed":(d.clearOldSubscriptionDataFromStorage(),"default")})),t.unsubscribeSubscription=({siteId:e,subscriberId:t,serviceWorkerSetting:i})=>r(void 0,void 0,void 0,(function*(){var n;yield(0,b.updateSubscriberStatus)({siteId:e,subscriberId:t,status:"unsubscribe"});const o=d.getParsedStorageData(g.storageName);(0,f.storeSubscriptionUnsubscribedDataInStorage)(null===(n=o.isSubDomain)||void 0===n||n);const{name:s}=(0,u.detectBrowser)();if("Safari"===s&&!(0,l.hasSupportForPushApiInSafari)()||o.isSubDomain)return;const r={};i.workerStatus&&(r.options={scope:i.scope?"/":void 0},r.scriptURL=i.worker);try{yield c.unsubscribeFromPushSubscription()}catch(e){p.default.debug("Error occurred during unsubscription.",e)}}))},4014:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=t.replaceLastNumberFromIpToZero=t.keepLastMaxElements=t.convertStringToArray=t.delay=t.capitalizeFirstLetter=t.uniqueArray=t.isNull=t.isUndefined=t.isWorker=t.toInteger=t.addStyleToPage=t.addScriptToPage=t.isEmptyArray=t.isEmptyObject=t.omit=t.get=t.isObject=t.removeArrayItem=t.safeStringify=t.safeParse=t.hasOwn=t.noop=void 0;const n=i(5914);t.noop=()=>{},t.hasOwn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t.safeParse=e=>{let t=null;try{t=JSON.parse(e)}catch(e){(0,n.logDebug)(e)}return t},t.safeStringify=e=>{let t=null;try{t=JSON.stringify(e)}catch(e){(0,n.logDebug)(e)}return t},t.removeArrayItem=(e,t)=>{const i=e.indexOf(t);return i>-1&&e.splice(i,1),e},t.isObject=e=>"[object Object]"===Object.prototype.toString.call(e),t.get=(e,t,i)=>{const n=Array.isArray(t)?t:t.split(".");let o=e;for(const e of n){if(null==o)return i;o=o[e]}return void 0===o?i:o},t.omit=(e,t)=>{const i=Object.assign({},e);for(const e of t){const t=Array.isArray(e)?e:[e];let n=i,o=t[0];for(let e=0;e!(0,t.isObject)(e)||0===Object.keys(e).length,t.isEmptyArray=e=>!Array.isArray(e)||0===e.length,t.addScriptToPage=(...e)=>{e.forEach((e=>{try{const t=document.createElement("script");t.src=e,t.async=!0,t.type="text/javascript",document.head.appendChild(t)}catch(t){throw new Error(`Invalid script URL: ${e}`)}}))},t.addStyleToPage=(...e)=>{e.forEach((e=>{try{const t=document.createElement("link");t.rel="stylesheet",t.href=e,t.type="text/css",document.head.appendChild(t)}catch(t){throw new Error(`Invalid style URL: ${e}`)}}))},t.toInteger=e=>{if("string"!=typeof e&&"number"!=typeof e)return 0;e=String(e).trim();const t=parseInt(e,10);return isNaN(t)?0:t},t.isWorker=()=>self instanceof ServiceWorkerGlobalScope,t.isUndefined=e=>void 0===e,t.isNull=e=>null===e,t.uniqueArray=e=>Array.from(new Set(e)),t.capitalizeFirstLetter=e=>e?e.charAt(0).toUpperCase()+e.slice(1):e,t.delay=e=>new Promise((t=>setTimeout(t,e))),t.convertStringToArray=(e,t=",")=>e.split(t),t.keepLastMaxElements=(e,t)=>e.length>t?e.slice(-t):e,t.replaceLastNumberFromIpToZero=(e,t)=>{if(!e||!t)return t;const i=t.includes(".")?".":":",n=t.split(i);return n[n.length-1]="0",n.join(i)},t.debounce=function(e,t){let i=null;return(...n)=>{null!==i&&clearTimeout(i),i=setTimeout((()=>{i=null,e(...n)}),t)}}},1920:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getChromiumStatus=t.getBrowserInfo=t.detectDeviceType=t.isPrivateBrowser=t.detectBrowser=t.isBrowser=void 0;const n=i(8637);t.isBrowser=()=>"undefined"!=typeof window&&void 0!==window.document,t.detectBrowser=(e=navigator.userAgent)=>{var t,i,n,o,s,r,a,d,c,l,u;let g="Unknown",p="";return/Firefox\/\d/.test(e)?(g="Firefox",p=(null===(t=e.match(/Firefox\/(\d+)/))||void 0===t?void 0:t[1])||""):/OPR\/\d/.test(e)?(g="Opera",p=(null===(i=e.match(/OPR\/(\d+)/))||void 0===i?void 0:i[1])||""):/Edg\/\d/.test(e)?(g="Edge",p=(null===(n=e.match(/Edg\/(\d+)/))||void 0===n?void 0:n[1])||""):/Edge\/\d/.test(e)?(g="Edge",p=(null===(o=e.match(/Edge\/(\d+)/))||void 0===o?void 0:o[1])||""):/EdgA\/\d/.test(e)?(g="Edge",p=(null===(s=e.match(/EdgA\/(\d+)/))||void 0===s?void 0:s[1])||""):/UCBrowser\//.test(e)?(g="Ucbrowser",p=(null===(r=e.match(/UCBrowser\/(\d+)/))||void 0===r?void 0:r[1])||""):/SamsungBrowser\//.test(e)?(g="Samsung",p=(null===(a=e.match(/SamsungBrowser\/(\d+)/))||void 0===a?void 0:a[1])||""):/YaBrowser\//.test(e)?(g="Yandex",p=(null===(d=e.match(/YaBrowser\/(\d+)/))||void 0===d?void 0:d[1])||""):/Chrome\//.test(e)?(g="Chrome",p=(null===(c=e.match(/Chrome\/(\d+)/))||void 0===c?void 0:c[1])||""):/Version\//.test(e)?(g="Safari",p=(null===(l=e.match(/Version\/(\d+)/))||void 0===l?void 0:l[1])||""):/MSIE|Trident/.test(e)&&(g="IE",p=(null===(u=e.match(/(?:MSIE |rv:)(\d+)/))||void 0===u?void 0:u[1])||""),p=p.replace(/[^\d.]/g,"").split(".")[0],{name:g,version:Number(p)}},t.isPrivateBrowser=function(){return new Promise((e=>{(0,n.detectIncognito)().then((t=>{e(t.isPrivate)})).catch((t=>{console.debug(t),e(!1)}))}))},t.detectDeviceType=(e=navigator.userAgent)=>/Mobi/.test(e)?"mobile":"desktop",t.getBrowserInfo=()=>{const{name:e,version:i}=(0,t.detectBrowser)();return{name:e,version:i,availableScreen:`${screen.availWidth}*${screen.availHeight}`,device:(0,t.detectDeviceType)(),host:location.host,href:location.href,language:navigator.language,pixelDepth:screen.pixelDepth,referrer:document.referrer,screen:`${screen.width}*${screen.height}`,userAgent:navigator.userAgent}},t.getChromiumStatus=()=>{const e=Boolean(window.chrome),t=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);return e&&t?{isChromium:!0,version:Number(t[2])}:{isChromium:!1,version:0}}},606:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.deleteDataFromLocalStorage=t.getDataFromLocalStorage=t.setDataToLocalStorage=t.deleteDataFromCookies=t.setDataToCookies=t.getDataFromCookies=void 0;const o=i(5914),s=n(i(3321)),r="undefined"!=typeof document&&void 0!==document.cookie;function a(){try{return"localStorage"in window&&null!==window.localStorage&&"setItem"in localStorage&&"getItem"in localStorage&&"removeItem"in localStorage}catch(e){return!1}}t.getDataFromCookies=e=>{if(!r)return(0,o.logDebug)("Cookie storage is not available"),null;const t=document.cookie.split(";");for(let i=0;i{if(!r)return void(0,o.logDebug)("Cookie storage is not available");const n=new Date;n.setDate(n.getDate()+i);const s="object"==typeof t?JSON.stringify(t):t,a=encodeURIComponent(s)+"; expires="+n.toUTCString();document.cookie=e+"="+a+"; path=/"},t.deleteDataFromCookies=e=>{r?(Array.isArray(e)?e:[e]).forEach((e=>{(0,t.getDataFromCookies)(e)&&(document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`)})):(0,o.logDebug)("Cookie storage is not available")},t.setDataToLocalStorage=(e,t)=>{if(!a())throw new s.default({message:"Local storage is not available",name:s.default.ERROR_NAME.LocalStorageNotAvailable});const i="object"==typeof t?JSON.stringify(t):t;localStorage.setItem(e,i)},t.getDataFromLocalStorage=e=>{if(!a())throw new s.default({message:"Local storage is not available",name:s.default.ERROR_NAME.LocalStorageNotAvailable});return localStorage.getItem(e)||null},t.deleteDataFromLocalStorage=e=>{if(!a())throw new s.default({message:"Local storage is not available",name:s.default.ERROR_NAME.LocalStorageNotAvailable});Array.isArray(e)?e.forEach((e=>{localStorage.removeItem(e)})):localStorage.removeItem(e)}},2689:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getUnixTime=t.getTimezoneName=t.getTimezoneOffset=void 0,t.getTimezoneOffset=()=>{const e=(new Date).getTimezoneOffset(),t=e>0?"-":"+",i=Math.floor(Math.abs(e)/60),n=Math.abs(e)%60;return`${t}${("0"+i).slice(-2)}:${("0"+n).slice(-2)}`},t.getTimezoneName=()=>{var e;let t="";if("function"==typeof(null===(e=null===Intl||void 0===Intl?void 0:Intl.DateTimeFormat())||void 0===e?void 0:e.resolvedOptions)){const e=Intl.DateTimeFormat().resolvedOptions();t=(null==e?void 0:e.timeZone)||""}return t},t.getUnixTime=e=>(e?new Date(Date.now()+24*e*60*60*1e3):new Date).getTime()},3641:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.richEditorHasNoValue=t.stripTagsAndDecodeEntity=t.addCSSProperties=t.clearBodyContent=t.getElementById=t.getScrollPercentage=t.addContentAfterBody=t.removeElement=void 0,t.removeElement=e=>{var t;if("string"==typeof e){const i=document.getElementById(e);i&&(null===(t=i.parentNode)||void 0===t||t.removeChild(i))}else Array.isArray(e)&&e.forEach((e=>{var t;const i=document.getElementById(e);i&&(null===(t=i.parentNode)||void 0===t||t.removeChild(i))}))},t.addContentAfterBody=e=>{const t=document.querySelector("body");if(!t)throw new Error("Can't find body element");Array.isArray(e)?e.forEach((e=>{t.insertAdjacentHTML("beforeend",e)})):t.insertAdjacentHTML("beforeend",e)},t.getScrollPercentage=()=>{const e=document.documentElement,t=document.body||document.scrollingElement,i=e.scrollTop||t&&t.scrollTop||0,n=e.scrollHeight||t&&t.scrollHeight||0,o=e.clientHeight||0,s=n?(i+o)/n*100:0;return Math.round(s)},t.getElementById=e=>document.getElementById(e),t.clearBodyContent=()=>{const e=document.querySelector("body");e&&(e.innerHTML="")},t.addCSSProperties=(e,t)=>{const i=document.getElementById(e);i&&Object.assign(i.style,t)},t.stripTagsAndDecodeEntity=e=>{if(!e)return;const t=document.createElement("span");return t.innerHTML=e,t.textContent},t.richEditorHasNoValue=e=>{if(!e)return!0;const t=document.createElement("div");t.innerHTML=e;let i=t.textContent||t.innerText;return i=i.replace(/\s+/g,""),0===i.length}},4182:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=i(5914);t.default=(()=>{const e={},t=(t,i)=>{const n=e[t];n&&(e[t]=i?n.filter((e=>e.cb!==i)):[])};return{on:(t,i,n={})=>{e[t]||(e[t]=[]),e[t].push({cb:i,options:n})},trigger:(i,o)=>{const s=e[i];if(s)for(const e of s){try{const t=e.cb(o);t instanceof Promise&&t.catch((e=>{(0,n.logDebug)(e)}))}catch(e){(0,n.logDebug)(e)}e.options.once&&t(i,e.cb)}},remove:t}})()},5914:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.logDebug=void 0,t.logDebug=e=>{console.debug("PushEngage:",e)}},6405:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__rest||function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);onew Promise((t=>setTimeout(t,e)));t.sendHttpRequest=(e,t={})=>n(void 0,void 0,void 0,(function*(){const{retryDelay:i=1e3,retries:n=0,skipRetryStatusCodes:s=[400,404,403,422]}=t,d=o(t,["retryDelay","retries","skipRetryStatusCodes"]);let c;d.body&&(d.headers||(d.headers={"Content-Type":"application/json"}));let l=0;for(;l=n)break;if(s.includes(c.status))break;yield a(t)}catch(i){if(l>=n){if("TypeError"===i.name&&"Failed to fetch"===i.message&&!navigator.onLine)throw new r.default({message:"Browser is offline. Request not sent.",name:r.default.ERROR_NAME.OfflineError,details:{fetchOptions:d,requestUrl:e}});throw new r.default({message:i.message,name:i.name||r.default.ERROR_NAME.HttpRequestError,details:{fetchOptions:d,requestUrl:e}})}yield a(t)}l++}if(!c)throw new r.default({message:"Request failed and no response was received.",name:r.default.ERROR_NAME.HttpRequestError,details:{fetchOptions:d,requestUrl:e}});return c}))},1074:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.deleteObject=t.upsertObject=t.getObjects=t.getObject=t.openDB=void 0;const s=o(i(3321));t.openDB=(e,t,i)=>n(void 0,void 0,void 0,(function*(){if(!indexedDB)throw new Error("indexedDB is not supported");try{const n=indexedDB.open(e,t);n.onupgradeneeded=()=>{!function(e,t){t.forEach((t=>{var i;e.objectStoreNames.contains(t.name)||e.createObjectStore(t.name,{keyPath:t.keyPath,autoIncrement:null!==(i=t.autoIncrement)&&void 0!==i&&i})}))}(n.result,i)};const o=yield function(e){return new Promise(((t,i)=>{e.onerror=()=>i(e.error),e.onsuccess=()=>t(e.result)}))}(n);return o}catch(e){throw new s.default({message:`Failed to open indexedDB, ${e.message}`,name:e.message.includes("indexedDB.open")?s.default.ERROR_NAME.IndexedDBOpenError:void 0,type:s.default.ERROR_TYPE.IndexedDBError})}})),t.getObject=(e,t,i)=>n(void 0,void 0,void 0,(function*(){try{const n=new Promise(((n,o)=>{const s=e.transaction(t,"readonly");s.onerror=()=>o(s.error);const r=s.objectStore(t).get(i);r.onerror=()=>o(r.error),r.onsuccess=()=>n(r.result)}));return yield n}catch(e){throw new s.default({message:`Failed to retrieve the specified object, ${e.message}.`,type:s.default.ERROR_TYPE.IndexedDBError,details:{key:i,storeName:t}})}})),t.getObjects=(e,t)=>n(void 0,void 0,void 0,(function*(){try{const i=new Promise(((i,n)=>{const o=e.transaction(t,"readonly"),s=o.objectStore(t);if(o.onerror=()=>n(o.error),s.getAll){const e=s.getAll();e.onerror=()=>n(e.error),e.onsuccess=()=>i(e.result)}else{const e=[],t=s.openCursor();t.onerror=()=>n(t.error),t.onsuccess=t=>{const n=t.target.result;n?(e.push(n.value),n.continue()):i(e)}}}));return yield i}catch(e){throw new s.default({message:`Failed to retrieve the objects, ${e.message}.`,type:s.default.ERROR_TYPE.IndexedDBError,details:{storeName:t}})}})),t.upsertObject=(e,t,i)=>n(void 0,void 0,void 0,(function*(){try{const n=new Promise(((n,o)=>{const s=e.transaction(t,"readwrite");s.onerror=()=>o(s.error);const r=s.objectStore(t).put(i);r.onerror=()=>o(r.error),r.onsuccess=()=>n(void 0)}));yield n}catch(e){throw new s.default({message:`Failed to upsert object, ${e.message}.`,type:s.default.ERROR_TYPE.IndexedDBError,details:{object:i,storeName:t}})}})),t.deleteObject=(e,t,i)=>n(void 0,void 0,void 0,(function*(){try{const n=new Promise(((n,o)=>{const s=e.transaction(t,"readwrite");s.onerror=()=>o(s.error);const r=s.objectStore(t).delete(i);r.onerror=()=>o(r.error),r.onsuccess=()=>n(void 0)}));yield n}catch(e){throw new s.default({message:`Failed to delete object, ${e.message}.`,type:s.default.ERROR_TYPE.IndexedDBError,details:{storeName:t,key:i}})}}))},8267:function(e,t){var i=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const n=e=>new Promise((t=>setTimeout(t,e))),o=new class{constructor(){this._locks={}}acquireLock(e,t=200){return i(this,void 0,void 0,(function*(){for(;this._locks[e];)yield n(t);return this._locks[e]=!0,!0}))}releaseLock(e){delete this._locks[e]}isLocked(e){return!!this._locks[e]}};t.default=o},7607:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=i(9340),o={debug:(...e)=>{let t="undefined"==typeof window;"undefined"!=typeof window&&"undefined"!=typeof sessionStorage&&sessionStorage.getItem(`${n.storageName}Debug`)&&(t=!0),t&&console.debug("PushEngage:",...e)},info:(...e)=>{console.info("PushEngage:",...e)},warn:(...e)=>{console.warn("PushEngage:",...e)},error:(...e)=>{console.error("PushEngage:",...e)}};t.default=o},1625:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});const i=new class{constructor(){this._stores={}}_resolveKeyPath(e){return e.split(".").reduce(((e,t)=>null===e||void 0===e[t]?null:e[t]),this._stores)}get(e){return this._resolveKeyPath(e)}set(e,t){const i=e.split("."),n=i.pop();i.reduce(((e,t)=>(e[t]&&"object"==typeof e[t]||(e[t]={}),e[t])),this._stores)[n]=t}delete(e){const t=e.split("."),i=t.pop();i&&delete t.reduce(((e,t)=>e[t]?e[t]:{}),this._stores)[i]}clearStore(){this._stores={}}};t.default=i},3241:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getSubdomainFromUrl=t.detectSiteType=t.detectProtocol=t.isLocalhost=t.getQueryParamsFromUrl=t.addQueryParamsToUrl=t.safeDecodeURIComponent=t.getValueFromUrlByKey=t.getUrlObject=void 0,t.getUrlObject=e=>{var t;const i=e=>{if("function"!=typeof e||"URL"!==e.name)return!1;let t;try{t=new e("http://example.com")}catch(e){return!1}return"search"in t&&"searchParams"in t&&"origin"in t&&"host"in t};if(i(URL))try{return new URL(e)}catch(e){return null}else try{const n=document.createElement("iframe");document.body.appendChild(n);const o=null===(t=n.contentWindow)||void 0===t?void 0:t.URL;return document.body.removeChild(n),i(o)?new o(e):null}catch(e){return null}},t.getValueFromUrlByKey=(e,i)=>{try{const n=(0,t.getUrlObject)(i);if(!n)return;return new URLSearchParams(n.search).get(e)||void 0}catch(e){return}},t.safeDecodeURIComponent=(e,t=0)=>{const i=String(e).split(/(%(?:d0|d1)%.{2})/);let n="";for(let e=0,o=i.length;e{const n=(0,t.getUrlObject)(e);return n?(Object.keys(i).forEach((e=>{void 0!==i[e]&&n.searchParams.append(e,i[e])})),n.toString()):e},t.getQueryParamsFromUrl=e=>{const t={},i=e.indexOf("?");if(-1!==i){const n=e.substring(i+1).split("&");for(let e=0;e{const e=location.hostname;return Boolean("localhost"===e||"[::1]"===e||e.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/))},t.detectProtocol=e=>{if(!e)return location.protocol.slice(0,-1);const t=e.match(/^(\w+):\/\//);return t?t[1]:"http"},t.detectSiteType=()=>(0,t.isLocalhost)()?"https":(0,t.detectProtocol)(),t.getSubdomainFromUrl=e=>{try{const i=(0,t.getUrlObject)(e);if(!i)return null;const n=i.hostname.split(".");return n.length>=3?n[0]:null}catch(e){return null}}},1041:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addClickEventListenerForHandleSubscription=void 0;const s=o(i(7607)),r=i(1791),a=i(2004),d=i(3110),c=i(9851);t.addClickEventListenerForHandleSubscription=()=>{const e=(0,c.getAppData)(),t=e.siteSettings.optin_subscription_trigger;if(!t)return;let i=!1;document.body.addEventListener("click",(o=>n(void 0,void 0,void 0,(function*(){try{if(i)return;i=!0;const n=o.target;let r=t.selectors;if(r=r.map((e=>e.replace(/[ ]/gi,".").replace(/^[.#]/,""))),n&&"closest"in n)for(let t=0,i=r.length;t{const e=(0,u.getAppData)();window.addEventListener("message",(t=>n(void 0,void 0,void 0,(function*(){try{const i=t.data;if("PushEngage"!==i.source||i.siteId!==e.site.site_id)return;if(d.default.debug("The message has been received from the subdomain."),"error"in i)return void s.default.trigger("notificationPermissionReceivedFromSubDomain",{error:i.error});const n=g.default.get("subscriptionOnSubdomain")||{},o=n.optInType;if(!o)throw new a.default({message:"Opt-in type is not available.",type:"NotFoundException",details:{siteId:e.site.site_id}});if("prompt"in i)return void s.default.trigger("permissionPrompt",{optInType:n.widgetOptInType||o,prompt:"native",state:"displayed"});s.default.trigger("permissionPrompt",{optInType:n.widgetOptInType||o,prompt:"native",state:"granted"===i.permission?"allow":"close"}),yield(0,r.processNotificationPermission)({optInType:o,permissionData:{permission:i.permission,subscription:i.subscription},siteSettings:e.siteSettings,site:e.site,options:{isSubDomain:!0,tokenRefresh:i.tokenRefresh,segment:n.segment,widgetOptInType:n.widgetOptInType}}),s.default.trigger("notificationPermissionReceivedFromSubDomain",{permission:i.permission});const u="default"===i.permission&&(0,l.isAllSubscriptionOptInClosed)(e.siteSettings.optin_settings)?"denied":i.permission;s.default.trigger("notificationPermissionReceived",{permission:u,subscriberId:(0,c.getSubscriberIdFromStorage)()||void 0,isPermissionChanged:!0})}catch(e){d.default.debug(e),s.default.trigger("notificationPermissionReceivedFromSubDomain",{error:{message:e.message,name:e.name,type:e.type}})}}))))}},7328:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.processFailedAnalytics=void 0;const n=i(1734);t.processFailedAnalytics=()=>{(0,n.processFailedAnalytics)()}},7704:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isPushNotificationSupported=t.handlePushEvent=void 0;const o=n(i(7607)),s=i(2471),r=i(1920);t.handlePushEvent=(...e)=>{for(let t=0;tnew Promise((e=>{(0,s.isPushNotificationSupported)()&&(0,r.isBrowser)()||e(!1),(0,r.isPrivateBrowser)().then((t=>{e(!t)})).catch((()=>e(!0)))}))},6293:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addSdkEventListeners=void 0;const o=n(i(4182)),s=i(8405),r=i(4014),a=n(i(7607));t.addSdkEventListeners=()=>{o.default.on("notificationPermissionReceived",(e=>{try{const{subscriberId:t,isPermissionChanged:i}=e;if(i&&t){const e=new CustomEvent("PushEngage.onSubscriptionChange",{detail:{subscriber_id:t}});window.dispatchEvent(e)}}catch(e){a.default.error(e.message)}})),o.default.on("permissionPrompt",(e=>{try{const{prompt:t,optInType:i,state:n}=e,o=(0,s.getOptInNameByType)(i)||(0,s.getWidgetOptInNameByType)(i);switch(n){case"allow":{const e=new CustomEvent("PushEngage.permissionPrompt.allow",{detail:{prompt:t,name:o}});window.dispatchEvent(e);break}case"close":{const e=new CustomEvent("PushEngage.permissionPrompt.close",{detail:{prompt:t,name:o}});window.dispatchEvent(e);break}case"displayed":{const e=new CustomEvent("PushEngage.permissionPrompt.displayed",{detail:{prompt:t,name:o}});window.dispatchEvent(e);break}}}catch(e){a.default.error(e.message)}})),"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",(e=>{const t=e.data;if(t&&(0,r.isObject)(t))switch(t.eventName){case"PushEngage.notification.displayed":case"PushEngage.notification.click":case"PushEngage.notification.close":window.dispatchEvent(new CustomEvent(t.eventName,{detail:t.data}))}}))}},6259:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},r=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.updateAppConfig=t.debug=t.showPermissionPrompt=t.removeSubscriptionManagementWidget=t.showSubscriptionManagementWidget=t.automatedNotification=t.getPermission=t.unsubscribe=t.showNativePermissionPrompt=t.addAlert=t.sendTriggerEvent=t.sendGoal=t.removeAttributes=t.setAttributes=t.addAttributes=t.getAttributes=t.getSubscriber=t.getSubscriberId=t.setProfileId=t.removeSegment=t.addSegmentWithDuration=t.addSegment=void 0;const d=a(i(9996)),c=a(i(7607)),l=i(9892),u=s(i(3502)),g=s(i(2004)),p=s(i(7423)),b=s(i(953)),f=i(3168),m=s(i(7353)),v=s(i(6206)),_=s(i(5869)),h=a(i(4182)),y=i(3110),w=a(i(3321)),S=i(4014),I=i(1730),P=s(i(1860)),O=i(9851),E=i(5021),k=i(9340);function A(e){c.default.debug(`Initialize the ${e} method.`)}t.addSegment=e=>{A("addSegment");const t=(0,O.getAppData)();return new Promise(((i,n)=>{const o=(0,l.getSubscriberIdFromStorage)();if(!o)return n(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));b.addSegmentToSubscriber({segment:e,subscriberId:o,siteId:t.site.site_id}).then((()=>i({message:"Segment added successfully."}))).catch(n)}))},t.addSegmentWithDuration=e=>{A("addSegmentWithDuration");const t=(0,O.getAppData)();return new Promise(((i,n)=>{const o=(0,l.getSubscriberIdFromStorage)();if(!o)return n(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));b.addSegmentWithDurationToSubscriber({segment:e,subscriberId:o,siteId:t.site.site_id}).then((()=>i({message:"Segment added successfully."}))).catch(n)}))},t.removeSegment=e=>{A("removeSegment");const t=(0,O.getAppData)();return new Promise(((i,n)=>{const o=(0,l.getSubscriberIdFromStorage)();if(!o)return n(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));b.removeSegmentFromSubscriber({segment:e,subscriberId:o,siteId:t.site.site_id}).then((()=>i({message:"Segment removed successfully."}))).catch(n)}))},t.setProfileId=e=>{A("setProfileId");const t=(0,O.getAppData)();return new Promise(((i,n)=>{const o=(0,l.getSubscriberIdFromStorage)();if(!o)return n(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));(0,f.setProfileIdToSubscriber)({profileId:e,subscriberId:o,siteId:t.site.site_id}).then((()=>i({message:"Profile ID set successfully"}))).catch(n)}))},t.getSubscriberId=()=>(A("getSubscriberId"),new Promise((e=>{e((0,l.getSubscriberIdFromStorage)())}))),t.getSubscriber=()=>(A("getSubscriber"),new Promise(((e,t)=>{const i=(0,l.getSubscriberIdFromStorage)();if(!i)return t(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));const n={subscriber_id:i};u.getSubscriberData(i).then((t=>{e(Object.assign(Object.assign({},n),(e=>{if(!e)return{};const t=(0,S.omit)(e,["vapid_public_key","user_agent","device_type","trigger_status","ts_created","host","has_unsubscribed"]);return Object.assign(Object.assign({},t),{browser:e.device_type,automated_notification:!!e.trigger_status,subscription_at:e.ts_created,attributes:e.attributes||{},segments:e.segments||[]})})(t)))})).catch(t)}))),t.getAttributes=()=>(A("getAttributes"),new Promise(((e,t)=>{const i=(0,l.getSubscriberIdFromStorage)();if(!i)return t(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));p.getAttributes(i).then(e).catch(t)}))),t.addAttributes=e=>(A("addAttributes"),new Promise(((t,i)=>{const n=(0,l.getSubscriberIdFromStorage)();if(!n)return i(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));p.addAttributes(n,e).then((()=>t({message:"Attributes added successfully."}))).catch(i)}))),t.setAttributes=e=>(A("setAttributes"),new Promise(((t,i)=>{const n=(0,l.getSubscriberIdFromStorage)();if(!n)return i(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));p.setAttributes(n,e).then((()=>t({message:"Attributes replaced successfully."}))).catch(i)}))),t.removeAttributes=e=>(A("removeAttributes"),new Promise(((t,i)=>{const n=(0,l.getSubscriberIdFromStorage)();if(!n)return i(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));p.removeAttributes(n,e).then((()=>t({message:"Attribute removed successfully."}))).catch(i)}))),t.sendGoal=e=>{A("sendGoal");const t=(0,O.getAppData)();return new Promise(((i,n)=>{const o=(0,l.getSubscriberIdFromStorage)();if(!o)return n(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));m.sendGoal({goal:e,subscriberId:o,siteId:t.site.site_id}).then((()=>i({message:"Goal send successfully."}))).catch(n)}))},t.sendTriggerEvent=e=>{A("sendTriggerEvent");const t=(0,O.getAppData)(),i=(0,y.triggerCampaignTypesAvailability)({browseAbandonments:t.browseAbandonments,cartAbandonments:t.cartAbandonments,priceDropAlerts:t.priceDropAlerts,backInStockAlerts:t.backInStockAlerts,customTriggerCampaigns:t.customTriggerCampaigns});return new Promise(((n,o)=>{const s=(0,l.getSubscriberIdFromStorage)();if(!s)return o(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));if(!i.hasBrowseAbandonment&&!i.hasCartAbandonment&&!i.hasCustomTriggerCampaign)return o(new Error("Trigger campaign is not enabled in your site."));const r=[...t.browseAbandonments,...t.cartAbandonments,...t.customTriggerCampaigns].find((t=>"active"===t.status&&t.campaign_name===e.campaign_name));return r?e.event_name!==r.start_event&&e.event_name!==r.stop_event?o(new Error(`The event_name is invalid. It should be either '${r.start_event}' or '${r.stop_event}'.`)):void v.sendTriggerEvent({trigger:e,subscriberId:s,siteId:t.site.site_id}).then((()=>n({message:"Trigger event send successfully."}))).catch(o):o(new Error("The campaign_name is invalid. It cannot be found in our system."))}))},t.addAlert=e=>{A("addAlert");const t=(0,O.getAppData)(),i=(0,y.triggerCampaignTypesAvailability)({browseAbandonments:t.browseAbandonments,cartAbandonments:t.cartAbandonments,priceDropAlerts:t.priceDropAlerts,backInStockAlerts:t.backInStockAlerts,customTriggerCampaigns:t.customTriggerCampaigns});return new Promise(((n,o)=>{const s=(0,l.getSubscriberIdFromStorage)();return s?i.hasPriceDropAlert||i.hasBackInStockAlert?void _.addAlert({alert:e,subscriberId:s,siteId:t.site.site_id}).then((()=>n({message:("price_drop"===e.type?"Price Drop":"Back in Stock")+" alert send successfully."}))).catch(o):o(new Error("Alert campaign is not enabled in your site.")):o(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}))}))},t.showNativePermissionPrompt=e=>r(void 0,void 0,void 0,(function*(){A("showNativePermissionPrompt");const i=(0,O.getAppData)();return new Promise(((n,o)=>{const s=e=>r(void 0,void 0,void 0,(function*(){try{const{permission:i,subscriberId:o,isPermissionChanged:s}=e,r={is_permission_changed:s||!1,permission:i};if(o){const e=yield(0,t.getSubscriber)();r.subscriber_id=o,r.geo_info={city:e.city,country:e.country,state:e.state}}n(r),c.default.debug("The subscription process has been completed on button click.")}catch(e){c.default.error(e.message)}}));h.default.on("notificationPermissionReceived",s,{once:!0});let a=null==e?void 0:e.isServiceWorkerAvailable;const d=(0,y.getSubscriptionOptIns)(i.siteSettings.optin_settings);(0,S.isUndefined)(a)&&(a=!d.length||(0,y.isServiceWorkerAvailabilityEnabled)(i.siteSettings.optin_settings)),g.initializeSubscription({triggerFrom:"onClick",options:{clickOptions:Object.assign(Object.assign({},e),{isServiceWorkerAvailable:a})}}).then().catch((e=>{h.default.remove("notificationPermissionReceived",s),o(e),c.default.error(e)}))}))})),t.unsubscribe=()=>{A("unsubscribe");const e=(0,O.getAppData)();return new Promise(((t,i)=>{const n=(0,l.getSubscriberIdFromStorage)();if(!n)return i(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));(0,I.unsubscribeSubscription)({subscriberId:n,siteId:e.site.site_id,serviceWorkerSetting:e.siteSettings.service_worker}).then((()=>{h.default.trigger("notificationPermissionReceived",{permission:"denied",isPermissionChanged:!0}),t({message:"User is unsubscribed successfully."})})).catch(i)}))},t.getPermission=()=>r(void 0,void 0,void 0,(function*(){A("getPermission");const e=(0,O.getAppData)(),{optin_settings:t,safari_options:i}=e.siteSettings,n=yield(0,I.getUserSubscriptionState)({optInSetting:t,safariWebPushPackageSetting:i});return"subscribed"===n?Promise.resolve("granted"):"default"===n?Promise.resolve("default"):Promise.resolve("denied")})),t.automatedNotification=({status:e})=>{A("automatedNotification");const t=(0,O.getAppData)();return new Promise(((i,n)=>{const o=(0,l.getSubscriberIdFromStorage)();if(!o)return n(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));u.updateAutomatedNotificationStatus({status:e,subscriberId:o,siteId:t.site.site_id}).then((()=>i({message:`Automated notification ${e} successfully.`}))).catch(n)}))},t.showSubscriptionManagementWidget=()=>r(void 0,void 0,void 0,(function*(){return A("showSubscriptionManagementWidget"),new Promise(((e,t)=>{P.showSubscriptionManagementWidget().then((t=>e({message:t}))).catch(t)}))})),t.removeSubscriptionManagementWidget=()=>r(void 0,void 0,void 0,(function*(){return A("removeSubscriptionManagementWidget"),new Promise(((e,t)=>{P.removeSubscriptionManagementWidget().then((t=>e({message:t}))).catch(t)}))})),t.showPermissionPrompt=()=>r(void 0,void 0,void 0,(function*(){A("showPermissionPrompt");const e=(0,O.getAppData)(),t=yield(0,E.getGeoInfo)({isEu:e.site.is_eu});return new Promise(((e,i)=>{const n=i=>{try{const{permission:n,subscriberId:o,isPermissionChanged:s}=i,r={permission:n,is_permission_changed:s||!1};"granted"===n&&o&&(r.subscriber_id=o,r.geo_info={country:t.country,state:t.state,city:t.city}),e(r),c.default.debug("The subscription process has been completed by showPermissionPrompt.")}catch(e){c.default.error(e.message)}};h.default.on("notificationPermissionReceived",n,{once:!0}),g.initializeSubscription({triggerFrom:"onInit",options:{initOptions:{forceInit:!0}}}).then().catch((e=>{h.default.remove("notificationPermissionReceived",n),i(e),c.default.error(e)}))}))})),t.debug=e=>{const t=`${k.storageName}Debug`;e||void 0===e?sessionStorage.setItem(t,"true"):sessionStorage.removeItem(t)},t.updateAppConfig=e=>{A("updateAppConfig");const t=(0,O.getAppData)();if(!(0,S.isObject)(e))return;const i=e.subscription_management_widget||e.subscriptionManagementWidget;if(i&&(0,S.isObject)(i)){const e=t.siteSettings.subscription_management_widget;t.siteSettings.subscription_management_widget=d.default.all([k.defaultSubscriptionManagementWidgetSetting,e,i],{arrayMerge:(e,t)=>t})}}},2837:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getV1SDKMethods=void 0,t.getV1SDKMethods=()=>({subscribe:(e,t)=>{window._peq=window._peq||[],window._peq.push(["init",e,t])},isSubscribed:e=>{window._peq=window._peq||[],window._peq.push(["is-subscribed",e])},addSubscriberToSegment:(e,t)=>{window._peq=window._peq||[],window._peq.push(["add-to-segment",e,t])},removeSubscriberFromSegment:(e,t)=>{window._peq=window._peq||[],window._peq.push(["remove-to-segment",e,t])},addProfileId:(e,t)=>{window._peq=window._peq||[],window._peq.push(["add-to-profile",e,t])},addSubscriberToDynamicSegment:(e,t,i)=>{window._peq=window._peq||[],window._peq.push(["add-to-dynamic-segment",e,t,i])},addSegmentsInStorage:()=>{}})},2572:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},r=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.removeSubscriptionManagementWidget=t.showSubscriptionManagementWidget=t.isSubscribed=t.initializeSubscription=t.initializeSubscriptionCallback=t.getPermission=t.unsubscribe=t.showNativePermissionPrompt=t.getSubscriber=t.sendGoal=t.addAlert=t.sendTriggerEvent=t.removeAttributes=t.setAttributes=t.addAttributes=t.getAttributes=t.setProfileId=t.removeSegment=t.addSegmentWithDuration=t.addSegment=void 0;const d=s(i(6259)),c=a(i(7607)),l=i(9892),u=a(i(4182)),g=i(1730),p=i(3502),b=i(4014),f=i(3241),m=i(9851),v=e=>{const t={};if("UserNotSubscribed"===e.name)Object.assign(t,{statuscode:22,message:e.message});else{const i={statuscode:0,message:e.message};e.details&&Object.assign(i,{details:e.details}),Object.assign(t,i)}return t},_=e=>"function"==typeof e||(c.default.warn("Callback is not a function"),!1),h=(e,t)=>{const i={};if("granted"===e){const e=(0,l.getSubscriberIdFromStorage)(),n={};t.country&&(n.country=t.country),t.state&&(n.state=t.state),t.city&&(n.city=t.city);const o={subscriber_hash:e,subscriber_id:e};(0,b.isEmptyObject)(n)||Object.assign(o,{geoInfo:n,geo_info:n}),Object.assign(i,{statuscode:1,data:o,message:"User subscribed successfully.",status:"SUBSCRIBED",subscriber_hash:e})}else"denied"===e?Object.assign(i,{statuscode:2,status:"DENIED",message:"User denied push notification."}):"closed"===e?Object.assign(i,{statuscode:3,status:"CLOSED",message:"User closed subscription Opt-in."}):Object.assign(i,{statuscode:22,status:"DEFAULT",message:"User is not subscribed."});return i};function y(e){c.default.debug(`Initialize the ${e} v2 method.`)}t.addSegment=({segment:e,callback:t})=>r(void 0,void 0,void 0,(function*(){y("addSegment");const i={};try{const t=yield d.addSegment(e);Object.assign(i,Object.assign({statuscode:1},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)})),t.addSegmentWithDuration=({segment:e,callback:t})=>r(void 0,void 0,void 0,(function*(){y("addSegmentWithDuration");const i={};try{const t=yield d.addSegmentWithDuration(e);Object.assign(i,Object.assign({statuscode:1},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)})),t.removeSegment=({segment:e,callback:t})=>r(void 0,void 0,void 0,(function*(){y("removeSegment");const i={};try{const t=yield d.removeSegment(e);Object.assign(i,Object.assign({statuscode:1},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)})),t.setProfileId=({profileId:e,callback:t})=>r(void 0,void 0,void 0,(function*(){y("setProfileId");const i={};try{const t=yield d.setProfileId(e);Object.assign(i,Object.assign({statuscode:1},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)})),t.getAttributes=e=>r(void 0,void 0,void 0,(function*(){y("getAttributes");const t={};try{const e=yield d.getAttributes();Object.assign(t,{statuscode:1,data:e})}catch(e){Object.assign(t,v(e))}e&&_(e)&&e(t)})),t.addAttributes=({attributes:e,callback:t})=>r(void 0,void 0,void 0,(function*(){y("addAttributes");const i={};try{const t=yield d.addAttributes(e),n=(0,l.getSubscriberIdFromStorage)(),o=yield(0,p.getSubscriberData)(n);Object.assign(i,Object.assign({statuscode:1,data:(null==o?void 0:o.attributes)||{}},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)})),t.setAttributes=({attributes:e,callback:t})=>r(void 0,void 0,void 0,(function*(){y("setAttributes");const i={};try{const t=yield d.setAttributes(e),n=(0,l.getSubscriberIdFromStorage)(),o=yield(0,p.getSubscriberData)(n);Object.assign(i,Object.assign({statuscode:1,data:(null==o?void 0:o.attributes)||{}},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)})),t.removeAttributes=({attributeNames:e,callback:t})=>r(void 0,void 0,void 0,(function*(){y("removeAttributes");const i={};try{const t=yield d.removeAttributes(e),n=(0,l.getSubscriberIdFromStorage)(),o=yield(0,p.getSubscriberData)(n);Object.assign(i,Object.assign({statuscode:1,data:(null==o?void 0:o.attributes)||{}},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)})),t.sendTriggerEvent=({trigger:e,callback:t})=>r(void 0,void 0,void 0,(function*(){y("sendTriggerEvent");const i={};try{const t=yield d.sendTriggerEvent(e);Object.assign(i,Object.assign({statuscode:1},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)})),t.addAlert=({alert:e,callback:t})=>r(void 0,void 0,void 0,(function*(){y("addAlert");const i={};try{const t=yield d.addAlert(e);Object.assign(i,Object.assign({statuscode:1},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)})),t.sendGoal=({goal:e,callback:t})=>r(void 0,void 0,void 0,(function*(){y("sendGoal");const i={};try{const t=yield d.sendGoal(e);Object.assign(i,Object.assign({statuscode:1},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)})),t.getSubscriber=({options:e,callback:t})=>r(void 0,void 0,void 0,(function*(){var i;y("getSubscriber");const n={};try{const t=yield d.getSubscriber(),o=Object.assign(Object.assign({},t),{subscriber_hash:t.subscriber_id});if(o.device&&(o.device_type=o.browser),o.subscription_at&&(o.ts_created=o.subscription_at),o.subscription_url&&(o.host=null===(i=(0,f.getUrlObject)(o.subscription_url))||void 0===i?void 0:i.host),e&&(null==e?void 0:e.fields)&&Array.isArray(e.fields)&&e.fields.length>0){const t={};e.fields.forEach((e=>{o[e]&&(t[e]=o[e])})),Object.assign(n,{statuscode:1,data:t})}else Object.assign(n,{statuscode:1,data:o})}catch(e){Object.assign(n,v(e))}t&&_(t)&&t(n)})),t.showNativePermissionPrompt=({segment:e,callback:t})=>r(void 0,void 0,void 0,(function*(){y("showNativePermissionPrompt");const i={};try{const t=yield d.showNativePermissionPrompt({segment:e});let n={};t.subscriber_id&&(n=yield d.getSubscriber());const o=h(t.permission,{city:n.city,country:n.country,state:n.state});Object.assign(i,o)}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)})),t.unsubscribe=({callback:e})=>r(void 0,void 0,void 0,(function*(){y("unsubscribe");const t={};try{const e=yield d.unsubscribe();Object.assign(t,Object.assign({statuscode:1},e))}catch(e){Object.assign(t,v(e))}e&&_(e)&&e(t)})),t.getPermission=({callback:e})=>r(void 0,void 0,void 0,(function*(){y("getPermission");const t=(0,m.getAppData)(),i={};try{let e=yield d.getPermission();(0,g.isAllSubscriptionOptInClosed)(t.siteSettings.optin_settings)&&(e="closed");let n={};"granted"===e&&(n=yield d.getSubscriber());const o=h(e,{city:n.city,country:n.country,state:n.state});Object.assign(i,o)}catch(e){Object.assign(i,v(e))}e&&_(e)&&e(i)})),t.initializeSubscriptionCallback=({callback:e})=>{y("initializeSubscriptionCallback");const t=(0,m.getAppData)();e&&_(e)&&u.default.on("notificationPermissionReceived",(i=>r(void 0,void 0,void 0,(function*(){try{const{permission:n,isPermissionChanged:o,subscriberId:s}=i;if(!o)return;let r=n;(0,g.isAllSubscriptionOptInClosed)(t.siteSettings.optin_settings)&&(r="closed");let a={};s&&(a=yield d.getSubscriber());const c=h(r,{city:a.city,country:a.country,state:a.state});e(c)}catch(e){c.default.error(e.message)}}))),{once:!0})},t.initializeSubscription=({segment:e,callback:t})=>r(void 0,void 0,void 0,(function*(){y("initializeSubscription");const i=(0,m.getAppData)(),n={};try{const t=yield d.showPermissionPrompt(),{permission:o,is_permission_changed:s,subscriber_id:r}=t;if("granted"===o&&e&&(Array.isArray(e)||"string"==typeof e))try{yield d.addSegment(e)}catch(e){c.default.error(e.message)}if(!s)return;let a=o;(0,g.isAllSubscriptionOptInClosed)(i.siteSettings.optin_settings)&&(a="closed");let l={};r&&(l=yield d.getSubscriber());const u=h(a,{city:l.city,country:l.country,state:l.state});Object.assign(n,u)}catch(e){Object.assign(n,v(e))}t&&_(t)&&t(n)})),t.isSubscribed=({callback:e})=>r(void 0,void 0,void 0,(function*(){if(y("isSubscribed"),"function"==typeof e)try{const t=yield d.getPermission();e("granted"===t)}catch(e){c.default.error(e.message)}else c.default.warn("Callback is not a function")})),t.showSubscriptionManagementWidget=({callback:e})=>r(void 0,void 0,void 0,(function*(){y("showSubscriptionManagementWidget");const t={};try{const e=yield d.showSubscriptionManagementWidget();Object.assign(t,Object.assign({statuscode:1},e))}catch(e){Object.assign(t,v(e))}e&&_(e)&&e(t)})),t.removeSubscriptionManagementWidget=({callback:e})=>r(void 0,void 0,void 0,(function*(){y("removeSubscriptionManagementWidget");const t={};try{const e=yield d.removeSubscriptionManagementWidget();Object.assign(t,Object.assign({statuscode:1},e))}catch(e){Object.assign(t,v(e))}e&&_(e)&&e(t)}))},6496:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.initializeSDK=void 0;const a=r(i(7607)),d=s(i(6259)),c=s(i(2572)),l=i(6293),u=i(2837),g=i(4014),p=i(9851),b=i(7704),f=(e,...t)=>{for(let i=0;iObject.assign(Object.assign({},d),{push:b.handlePushEvent,isPushNotificationSupported:b.isPushNotificationSupported,getInitOptions:p.getSDKInitOptions,getAppConfig:p.getAppData});t.initializeSDK=({commands:e,legacyCommands:t})=>{const i=(0,p.getSDKInitOptions)(),n=m();window.PushEngage=Object.freeze(n),e&&Array.isArray(e)&&(0,b.handlePushEvent)(...e),window._peq=Object.freeze({push:f.bind(null,i)}),t&&Array.isArray(t)&&f(i,...t),(0,g.isUndefined)(window._pe)&&(window._pe=Object.freeze((0,u.getV1SDKMethods)())),(0,l.addSdkEventListeners)()}},1919:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addEventListenerForAddSegment=void 0;const s=o(i(4182)),r=o(i(7607)),a=i(1791),d=i(3110),c=i(953),l=i(9851);t.addEventListenerForAddSegment=()=>{const e=(0,l.getAppData)(),t=(0,l.getSDKInitOptions)();s.default.on("notificationPermissionReceived",(i=>n(void 0,void 0,void 0,(function*(){try{const{permission:n,subscriberId:o}=i;if("granted"!==n)return;if(!o)throw new Error("The subscriber ID is not available when the notification permission is granted.");let s=(0,d.getSegmentNamesFromRules)(e.segments);if(Array.isArray(t.segment)?s=[...s,...t.segment]:t.segment&&(s=[...s,t.segment]),0===s.length)return;try{yield(0,c.addSegmentToSubscriber)({subscriberId:o,segment:s,siteId:e.site.site_id})}catch(e){r.default.error(e.message)}}catch(t){r.default.error(t.message),(0,a.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}}))))}},8343:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},r=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addEventListenerForShopifyCampaign=void 0;const d=a(i(4182)),c=a(i(7607)),l=i(1791),u=s(i(9432)),g=i(5827),p=i(7330),b=i(9892),f=i(3641),m=i(6206),v=i(9838),_=i(5869),h=i(2689),y=i(4014),w=i(9851),S=i(3110);t.addEventListenerForShopifyCampaign=()=>{const e=(0,w.getAppData)(),t=(0,w.getSDKInitOptions)(),i=(0,S.triggerCampaignTypesAvailability)({browseAbandonments:e.browseAbandonments,cartAbandonments:e.cartAbandonments,priceDropAlerts:e.priceDropAlerts,backInStockAlerts:e.backInStockAlerts,customTriggerCampaigns:e.customTriggerCampaigns});if(!t.isShopifySite)return;const n="pushengage-campaign-alert-widget";let o=!1;const s=t=>r(void 0,void 0,void 0,(function*(){var i,n,o;if(!(null===(i=window.Shopify)||void 0===i?void 0:i.shop))return;const s=(0,b.getShopifyCampaignDataFromStorage)(),r=yield(0,p.getCartItems)();if(0===r.length)return void(0!==(null===(n=null==s?void 0:s.cartVariantIds)||void 0===n?void 0:n.length)&&(yield Promise.all([(0,m.sendTriggerEvent)({subscriberId:t,trigger:{campaign_name:`browseabandonment${e.site.site_id}`,event_name:"add-to-cart"},siteId:e.site.site_id}),(0,m.sendTriggerEvent)({subscriberId:t,trigger:{campaign_name:`cartabandonment${e.site.site_id}`,event_name:"checkout"},siteId:e.site.site_id})]),(0,b.setShopifyCampaignDataToStorage)({cartVariantIds:[],browseVariantIds:[]})));const a=[],d=[];for(let i=0;ir(void 0,void 0,void 0,(function*(){try{const{permission:a,subscriberId:d}=t;if("granted"!==a)return void(0,f.removeElement)(n);if(!d)throw new Error("The subscriber ID is not available when the notification permission is granted.");i.hasCartAbandonment&&(yield(t=>r(void 0,void 0,void 0,(function*(){var i,n;const o=null===(i=window.Shopify)||void 0===i?void 0:i.checkout;if(!(o&&o.total_price&&o.order_id))return;const s=String(o.order_id),r=(0,b.getShopifyCampaignDataFromStorage)();let a=[...(null==r?void 0:r.checkoutOrderIds)||[]];if(void 0===(null==r?void 0:r.checkoutOrderIds)&&(a=u.getLegacySDKShopifyCheckoutOrderIds()),a.includes(s))c.default.debug(`Cart Abandonment campaign checkout event has already been processed for order id ${s}.`);else if(0!==(null===(n=null==r?void 0:r.cartVariantIds)||void 0===n?void 0:n.length)){yield Promise.all([(0,m.sendTriggerEvent)({subscriberId:t,trigger:{campaign_name:`browseabandonment${e.site.site_id}`,event_name:"add-to-cart"},siteId:e.site.site_id}),(0,m.sendTriggerEvent)({subscriberId:t,trigger:{campaign_name:`cartabandonment${e.site.site_id}`,event_name:"checkout",data:{revenue:o.total_price}},siteId:e.site.site_id})]);const i=200;(0,b.setShopifyCampaignDataToStorage)({cartVariantIds:[],browseVariantIds:[],checkoutOrderIds:(0,y.keepLastMaxElements)([...a,s],i)}),c.default.debug("Cart and Browse Abandonment campaigns cancelled successfully.")}})))(d),yield s(d),(t=>{if(o)return;if(o=!0,"product"!==u.getPageType())return;let i=!1;const n=setInterval((()=>r(void 0,void 0,void 0,(function*(){if(!i){i=!0;try{yield s(t)}catch(t){c.default.error(t.message),(0,l.sendErrorLog)("sdk",t,{siteId:e.site.site_id}),clearInterval(n)}i=!1}}))),2e4)})(d)),i.hasBrowseAbandonment&&(yield(t=>r(void 0,void 0,void 0,(function*(){var i,n;if("product"!==u.getPageType())return;const o=(0,g.getProductTitleFromUrl)();if(!o)return;const s=yield(0,p.getProductByTitle)(o);if(!s)return;const r=u.getSelectedVariantId(),a=u.filterVariantFromVariantId(s,r);if(!a)return;const d=(0,b.getShopifyCampaignDataFromStorage)();if(d&&((null===(i=d.browseVariantIds)||void 0===i?void 0:i.includes(a.id))||(null===(n=d.cartVariantIds)||void 0===n?void 0:n.includes(a.id))))return void c.default.debug(`Browse Abandonment campaign has already been processed for variant id ${a.id}.`);const l=yield u.getImageUrlsFromVariant(a);let v=l.largeImageUrl,_=l.imageUrl;if(!v){const e=yield u.getImageUrlsFromProduct(s);v=e.largeImageUrl,_=e.imageUrl}const h={campaign_name:`browseabandonment${e.site.site_id}`,event_name:"browse",title:{productname:(0,f.stripTagsAndDecodeEntity)(a.name)},message:{price:u.convertPriceToFloat(a.price)},notification_url:{notificationurl:location.href},notification_image:{imageurl:e.site.site_image||_||""},big_image:{bigimageurl:v||""}};yield(0,m.sendTriggerEvent)({subscriberId:t,trigger:h,siteId:e.site.site_id}),(0,b.setShopifyCampaignDataToStorage)({browseVariantIds:[...(null==d?void 0:d.browseVariantIds)||[],a.id]}),c.default.debug(`Browse Abandonment campaign triggered successfully with variant id ${a.id}.`)})))(d)),(i.hasPriceDropAlert||i.hasBackInStockAlert)&&(yield(t=>r(void 0,void 0,void 0,(function*(){if(!e.siteSettings.shopify_options)return;if((0,f.getElementById)(n))return;if("product"!==u.getPageType())return;const o=(0,g.getProductTitleFromUrl)();if(!o)return;const s=yield(0,p.getProductByTitle)(o);if(!s)return;const a=u.getSelectedVariantId(),d=u.filterVariantFromVariantId(s,a);if(!d)return;yield(t=>r(void 0,void 0,void 0,(function*(){const i=(0,b.getShopifyCampaignDataFromStorage)();if(i&&i.nextAlertSyncTime&&i.nextAlertSyncTime>(0,h.getUnixTime)())return void c.default.debug("Syncing alerts from server is not required.");const n=yield(0,_.getAlerts)({subscriberId:t,siteId:e.site.site_id});if(!n)return;const o=[],s=[];n.forEach((e=>{"price_drop"===e.type?o.push((0,y.toInteger)(e.variant_id)):"inventory"===e.type&&s.push((0,y.toInteger)(e.variant_id))})),(0,b.setShopifyCampaignDataToStorage)({priceDropVariantIds:o,backInStockVariantIds:s,nextAlertSyncTime:(0,h.getUnixTime)(1)})})))(t);const m=s.available?"price_drop":"inventory";if(i.hasPriceDropAlert&&"price_drop"===m){(0,v.addCampaignAlertWidget)({alertType:m,alert:e.siteSettings.shopify_options.alert_campaign,site:e.site,variantId:d.id});const i=document.getElementById(`${n}-allow-button`);null==i||i.addEventListener("click",(()=>r(void 0,void 0,void 0,(function*(){try{yield(({variant:t,product:i,subscriberId:n})=>r(void 0,void 0,void 0,(function*(){var o;const s=(0,b.getShopifyCampaignDataFromStorage)();if(null===(o=null==s?void 0:s.priceDropVariantIds)||void 0===o?void 0:o.includes(t.id))return void c.default.debug(`Price Drop Alert campaign has already been processed for variant id ${t.id}.`);const r=yield u.getImageUrlsFromVariant(t);let a=r.largeImageUrl,d=r.imageUrl;if(!a){const e=yield u.getImageUrlsFromProduct(i);a=e.largeImageUrl,d=e.imageUrl}const l={type:"price_drop",product_id:`${i.id}`,link:location.href,price:u.convertPriceToFloat(t.price),variant_id:`${t.id}`,alert_price:u.convertPriceToFloat(t.price),availability:"inStock",title:(0,f.stripTagsAndDecodeEntity)(t.name),image_link:e.site.site_image||d||"",big_image_link:a||""};yield(0,_.addAlert)({subscriberId:n,alert:l,siteId:e.site.site_id}),(0,b.setShopifyCampaignDataToStorage)({priceDropVariantIds:[...(null==s?void 0:s.priceDropVariantIds)||[],t.id]}),c.default.debug(`Price drop alert triggered successfully with variant ids ${t.id}.`)})))({variant:d,product:s,subscriberId:t})}catch(t){c.default.error(t.message),(0,l.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}}))))}else if(i.hasBackInStockAlert&&"inventory"===m){(0,v.addCampaignAlertWidget)({alertType:m,alert:e.siteSettings.shopify_options.alert_campaign,site:e.site,variantId:d.id});const i=document.getElementById(`${n}-allow-button`);null==i||i.addEventListener("click",(()=>r(void 0,void 0,void 0,(function*(){try{yield(({variant:t,product:i,subscriberId:n})=>r(void 0,void 0,void 0,(function*(){var o;const s=(0,b.getShopifyCampaignDataFromStorage)();if(null===(o=null==s?void 0:s.backInStockVariantIds)||void 0===o?void 0:o.includes(t.id))return void c.default.debug(`Back in Stock Alert campaign has already been processed for variant id ${t.id}.`);const r=yield u.getImageUrlsFromVariant(t);let a=r.largeImageUrl,d=r.imageUrl;if(!a){const e=yield u.getImageUrlsFromProduct(i);a=e.largeImageUrl,d=e.imageUrl}const l={type:"inventory",product_id:`${i.id}`,link:location.href,price:u.convertPriceToFloat(t.price),variant_id:`${t.id}`,alert_price:u.convertPriceToFloat(t.price),availability:"outOfStock",title:(0,f.stripTagsAndDecodeEntity)(t.name),image_link:e.site.site_image||d||"",big_image_link:a||""};yield(0,_.addAlert)({subscriberId:n,alert:l,siteId:e.site.site_id}),(0,b.setShopifyCampaignDataToStorage)({backInStockVariantIds:[...(null==s?void 0:s.backInStockVariantIds)||[],t.id]}),c.default.debug(`Back in Stock alert triggered successfully with variant ids ${t.id}.`)})))({variant:d,product:s,subscriberId:t})}catch(t){c.default.error(t.message),(0,l.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}}))))}})))(d))}catch(t){c.default.error(t.message),(0,l.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}}))))}},2047:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addEventListenerForSubscriberRecoveryWidget=void 0;const s=o(i(4182)),r=i(3641),a=o(i(7607)),d=i(1791),c=i(9288),l=i(4014),u=i(2004),g=i(3110),p=i(9340),b=i(9851);t.addEventListenerForSubscriberRecoveryWidget=()=>{const e=(0,b.getAppData)(),t="pushengage-subscriber-recovery-widget",{chicklet_settings:i}=e.siteSettings;if(!i)return;const o=()=>n(void 0,void 0,void 0,(function*(){try{(0,r.removeElement)(t),yield(0,u.initializeSubscription)({triggerFrom:"onClick",options:{clickOptions:{widgetOptInType:p.widgetOptInType,isServiceWorkerAvailable:(0,g.isServiceWorkerAvailable)({optInSetting:e.siteSettings.optin_settings})}}}),a.default.debug("The subscription process was completed using the subscriber recovery widget.")}catch(t){a.default.error(t.message),(0,d.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}}));s.default.on("notificationPermissionReceived",(s=>n(void 0,void 0,void 0,(function*(){try{const{permission:a}=s,d=(0,r.getElementById)(t);if("denied"!==a)return void(0,r.removeElement)(t);if(d)return;i.bell?(yield(0,l.delay)(1e3*i.settings.delay),(i=>{(0,c.addSubscriberRecoveryBellWidgetToPage)({widget:i,site:e.site});const s=(0,r.getElementById)(`${t}-bell`);null==s||s.addEventListener("click",(()=>n(void 0,void 0,void 0,(function*(){yield o()}))))})(i.bell)):i.button&&(yield(0,l.delay)(1e3*i.settings.delay),(i=>{(0,c.addSubscriberRecoveryButtonWidgetToPage)({widget:i,site:e.site});const s=(0,r.getElementById)(`${t}-button`),a=(0,r.getElementById)(`${t}-close-button`);null==s||s.addEventListener("click",(()=>n(void 0,void 0,void 0,(function*(){yield o()})))),null==a||a.addEventListener("click",(()=>{(0,r.removeElement)(t)}))})(i.button))}catch(t){a.default.error(t.message),(0,d.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}}))))}},1860:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.removeSubscriptionManagementWidget=t.showSubscriptionManagementWidget=t.addEventListenerForSubscriptionManagementWidget=void 0;const s=o(i(4182)),r=i(3641),a=o(i(7607)),d=i(1791),c=i(6086),l=i(3110),u=i(1920),g=i(953),p=i(3502),b=i(2004),f=i(9892),m=i(1730),v=i(9340),_=i(9851),h=i(5021),y=o(i(8267));let w=!1;const S=({widget:e,permission:t})=>{var i,n,o;return!(!e||"granted"===t&&!((null===(i=e.segment_preference)||void 0===i?void 0:i.enabled)||(null===(n=e.unsubscribe_options)||void 0===n?void 0:n.enabled)||(null===(o=e.personal_notification_options)||void 0===o?void 0:o.enabled)))},I=({permission:e,subscriberId:t,widgetId:i,initFrom:o})=>n(void 0,void 0,void 0,(function*(){const u=(0,_.getAppData)();if("granted"===e&&!t)throw new Error("The subscriber ID is not available when the notification permission is granted.");let f=null;"granted"===e&&t&&(f=yield(0,p.getSubscriberData)(t)),(0,c.refreshSubscriptionManagementWidgetView)({widgetId:i,subscriberData:f,initFrom:o,notificationPermission:e}),n(void 0,void 0,void 0,(function*(){const e=()=>{const e=[];return document.querySelectorAll(`#${i}-opt-in-segment input[type="checkbox"]`).forEach((t=>{const i=t;i.checked&&e.push(i.value)})),e},t=`${i}-opt-in-subscribe`,o=(0,r.getElementById)(t),s=document.querySelector(`#${t} input[type="checkbox"]`);null==s||s.addEventListener("click",(t=>n(void 0,void 0,void 0,(function*(){const i=t.target;try{i.disabled=!0,i.checked=!1,null==o||o.classList.add("pushengage-opt-in__switch--spin"),yield(0,b.initializeSubscription)({triggerFrom:"onClick",options:{clickOptions:{widgetOptInType:v.widgetOptInType,segment:e(),isServiceWorkerAvailable:(0,l.isServiceWorkerAvailable)({optInSetting:u.siteSettings.optin_settings})}}}),a.default.debug("The subscription process was completed using the subscription management widget.")}catch(e){a.default.error(e.message),(0,d.sendErrorLog)("sdk",e,{siteId:u.site.site_id})}}))))})),"granted"===e&&t&&((e=>{n(void 0,void 0,void 0,(function*(){const t=document.querySelectorAll(`#${i}-opt-in-segment input[type="checkbox"]`),o=document.querySelectorAll(`#${i}-opt-in-subscribed-segment input[type="checkbox"]`);Array.from(t).concat(Array.from(o)).forEach((t=>{t.addEventListener("click",(t=>n(void 0,void 0,void 0,(function*(){const i=t.target;i.disabled=!0,yield y.default.acquireLock("handleAddOrRemoveSegmentThroughWidget");try{i.checked?(yield(0,g.addSegmentToSubscriber)({subscriberId:e,segment:i.value,siteId:u.site.site_id}),a.default.debug(`This ${i.value} segment added successfully.`)):(yield(0,g.removeSegmentFromSubscriber)({subscriberId:e,segment:i.value,siteId:u.site.site_id}),a.default.debug(`This ${i.value} segment removed successfully.`))}catch(e){a.default.error(e.message),(0,d.sendErrorLog)("sdk",e,{siteId:u.site.site_id})}y.default.releaseLock("handleAddOrRemoveSegmentThroughWidget"),i.disabled=!1}))))}))}))})(t),(e=>{n(void 0,void 0,void 0,(function*(){const t=document.querySelector(`#${i}-opt-in-auto-notification input[type="checkbox"]`);null==t||t.addEventListener("click",(t=>n(void 0,void 0,void 0,(function*(){const n=t.target,o=n.checked?"enabled":"disabled",s="pushengage-opt-in__switch--spin",c=(0,r.getElementById)(`${i}-opt-in-auto-notification`);n.disabled=!0,n.checked=!n.checked,null==c||c.classList.add(s);try{yield(0,p.updateAutomatedNotificationStatus)({status:o,subscriberId:e,siteId:u.site.site_id}),a.default.debug(`Automated notification ${o} successfully.`)}catch(e){a.default.error(e.message),(0,d.sendErrorLog)("sdk",e,{siteId:u.site.site_id})}n.disabled=!1,n.checked=!n.checked,null==c||c.classList.remove(s)}))))}))})(t),(e=>{n(void 0,void 0,void 0,(function*(){const t=`${i}-opt-in-unsubscribe`,o=(0,r.getElementById)(t),c=(0,r.getElementById)(`${i}-unsubscribe-allow-button`),l=(0,r.getElementById)(`${i}-unsubscribe-close-button`),g=document.querySelector(`#${t} input[type="checkbox"]`),p=(0,r.getElementById)(`${i}-unsubscribe-popover`),b="pushengage-opt-in__switch--spin",f="pushengage-opt-in__popover--opened";g&&(g.addEventListener("click",(e=>n(void 0,void 0,void 0,(function*(){const t=e.target;t.disabled=!0,t.checked=!0,null==o||o.classList.add(b)})))),null==c||c.addEventListener("click",(()=>n(void 0,void 0,void 0,(function*(){try{null==p||p.classList.remove(f),yield(0,m.unsubscribeSubscription)({subscriberId:e,siteId:u.site.site_id,serviceWorkerSetting:u.siteSettings.service_worker}),a.default.debug("The subscription was unsubscribed through the subscription management widget."),s.default.trigger("notificationPermissionReceived",{permission:"denied",isPermissionChanged:!0})}catch(e){a.default.error(e.message),(0,d.sendErrorLog)("sdk",e,{siteId:u.site.site_id})}})))),null==l||l.addEventListener("click",(()=>n(void 0,void 0,void 0,(function*(){null==p||p.classList.remove(f),g&&(g.disabled=!1),null==o||o.classList.remove(b)})))))}))})(t))})),P=({widgetId:e,initFrom:t})=>n(void 0,void 0,void 0,(function*(){const i=(0,_.getAppData)(),{subscription_management_widget:n}=i.siteSettings,o=(0,f.getSubscriberIdFromStorage)(),s=(0,r.getElementById)(e);if(!1===S({widget:n,permission:o?"granted":"denied"}))return(0,r.removeElement)(e),void a.default.debug("The subscription management widget view is removed because the widget has empty content. id = ",e);s&&(yield I({widgetId:e,initFrom:t,permission:o?"granted":"denied",subscriberId:o||void 0}),a.default.debug("The subscription management widget view is being updated. id = ",e))}));t.addEventListenerForSubscriptionManagementWidget=()=>{const e="pushengage-subscription-management-widget",t=(0,u.detectDeviceType)();s.default.on("notificationPermissionReceived",(i=>n(void 0,void 0,void 0,(function*(){const n=(0,_.getAppData)();try{const{subscription_management_widget:o}=n.siteSettings,s=yield(0,h.getGeoInfo)({isEu:n.site.is_eu}),{permission:d,subscriberId:c}=i;if("denied"!==d&&"granted"!==d)return(0,r.removeElement)(e),void a.default.debug(`The subscription management widget view is removed because the notification permission ${d}.`);if(!1===S({widget:o,permission:d}))return(0,r.removeElement)(e),void a.default.debug("The subscription management widget view is removed because the widget has empty content.");if(!1===(({widgetSettings:e,geoInfo:i})=>{var n;if(!e)return!1;if(!e.trigger_button)return!1;if(!(null===(n=e.trigger_button)||void 0===n?void 0:n.rules))return!0;const o=e.trigger_button.rules;return!!(0,l.isCountrySatisfyingCountryRules)({include_countries:o.include_countries,exclude_countries:o.exclude_countries},i.country||"")&&!!(0,l.isUrlSatisfyingUrlRules)({include:o.include,exclude:o.exclude},location.href)&&!!(0,l.isDeviceSatisfyingDeviceRules)({include_devices:o.include_devices,exclude_devices:o.exclude_devices},t)})({geoInfo:s,widgetSettings:o}))return(0,r.removeElement)(e),void a.default.debug("The subscription management widget view is removed because the display rules.");yield I({permission:d,subscriberId:c,widgetId:e})}catch(e){a.default.error(e.message),(0,d.sendErrorLog)("sdk",e,{siteId:n.site.site_id})}})))),s.default.on("updateSubscriptionManagementWidgetView",(()=>n(void 0,void 0,void 0,(function*(){const t=(0,_.getAppData)();try{yield P({widgetId:e})}catch(e){a.default.error(e.message),(0,d.sendErrorLog)("sdk",e,{siteId:t.site.site_id})}}))))},t.showSubscriptionManagementWidget=()=>n(void 0,void 0,void 0,(function*(){const e=(0,_.getAppData)(),t="pushengage-subscription-management-widget-api-triggered",{optin_settings:i,safari_options:o,subscription_management_widget:c}=e.siteSettings;if(!(null==c?void 0:c.enabled))throw new Error("Subscription management widget is not enabled.");const l=yield(0,m.getUserSubscriptionState)({optInSetting:i,safariWebPushPackageSetting:o});if("default"===l)throw new Error("Your current notification permission is not granted or denied because the opt-in was not shown.");const u="subscribed"===l?"granted":"denied";if((0,r.getElementById)(t))throw new Error("Opt-in already showing on page.");if(!1===S({widget:c,permission:u}))throw new Error("Opt-in is not applicable to show on the page.");const g=()=>n(void 0,void 0,void 0,(function*(){try{yield P({widgetId:t,initFrom:"api"})}catch(t){a.default.error(t.message),(0,d.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}}));return yield I({widgetId:t,permission:u,initFrom:"api",subscriberId:(0,f.getSubscriberIdFromStorage)()||void 0}),w||(s.default.on("updateSubscriptionManagementWidgetView",g),s.default.on("notificationPermissionReceived",g),w=!0),"Opt-in shown successfully on the page."})),t.removeSubscriptionManagementWidget=()=>n(void 0,void 0,void 0,(function*(){const e=(0,_.getAppData)(),{subscription_management_widget:t}=e.siteSettings,i="pushengage-subscription-management-widget-api-triggered";if(!(null==t?void 0:t.enabled))throw new Error("Subscription management widget is not enabled.");if(!(0,r.getElementById)(i))throw new Error("Opt-in not showing on page.");return(0,r.removeElement)(i),"Opt-in removed successfully on the page."}))},9291:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.handleResubscribeSubscription=void 0;const o=i(8648),s=i(9892),r=i(9851);t.handleResubscribeSubscription=({subscription:e})=>n(void 0,void 0,void 0,(function*(){const t=(0,r.getAppData)(),i=yield(0,o.processSubscriptionData)({subscription:e,siteSettings:t.siteSettings,site:t.site,options:{tokenRefresh:!0}});(0,s.storeSubscriptionDataInStorage)({subscription:e,subscriberId:i,isSubDomain:!1})}))},1154:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.notifyPermissionPromptAndGetSubscription=void 0;const s=o(i(7607)),r=i(2768),a=i(1920),d=i(2471),c=i(9798),l=i(3395),u=i(9340);t.notifyPermissionPromptAndGetSubscription=({siteSettings:e,site:t})=>n(void 0,void 0,void 0,(function*(){s.default.debug("Requesting the notification permission prompt.");const{service_worker:i,safari_options:o,vapid_key:g,overlay_settings:p,optin_subscription_reminder:b}=e,f={},m=yield n(void 0,void 0,void 0,(function*(){try{"default"===(0,d.getNotificationPermission)({safariWebPushId:null==o?void 0:o.push_id})&&((0,c.addSubscriptionOverlayToPage)({site:t,overlay:p}),(0,l.addSubscriptionReminderPromptToPage)({site:t,reminderPrompt:b,overlay:p}));const{name:e}=(0,a.detectBrowser)();let i;return i="Safari"!==e||(0,d.hasSupportForPushApiInSafari)()?{permission:yield(0,r.requestNotificationPermission)()}:yield(0,r.requestSafariNotificationPermission)(o.push_id,u.env.__SAFARI_WEB_PUSH_PACKAGE_URL__,{app_id:t.site_key}),i}finally{(0,c.removeSubscriptionOverlay)(),(0,l.removeSubscriptionReminderPrompt)()}}));let v;if(s.default.debug(`User permission has been ${m.permission}.`),Object.assign(f,m),"granted"===m.permission){if(m.deviceToken)v=m;else{const e={vapidPublicKey:g.public_key};i.workerStatus&&(e.options={scope:i.scope?"/":void 0},e.scriptURL=i.worker);try{v=yield(0,r.subscribeToPushNotification)(e)}catch(t){if("InvalidStateError"!==t.name)throw t;yield(0,r.unsubscribeFromPushSubscription)(),v=yield(0,r.subscribeToPushNotification)(e)}}f.subscription=v}return f}))},226:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.addResetNotificationPermissionPopupToPage=void 0;const o=i(3641),s=i(7913),r=i(2471),a=i(9851);t.addResetNotificationPermissionPopupToPage=e=>n(void 0,void 0,void 0,(function*(){const t=(0,a.getAppData)();(0,s.addResetNotificationPermissionPopupViewToPage)(e);const i="pushengage-reset-notification-permission-popup";return new Promise(((e,s)=>{const a=(0,o.getElementById)(`${i}-retry`),d=(0,o.getElementById)(`${i}-close`);if(!d||!a)return s(new Error("Could not find reset notification permission popup buttons"));null==a||a.addEventListener("click",(()=>n(void 0,void 0,void 0,(function*(){var n;const s=(0,r.getNotificationPermission)({safariWebPushId:null===(n=t.siteSettings.safari_options)||void 0===n?void 0:n.push_id});if("denied"!==s)(0,o.removeElement)(i),e(s);else{const e=(0,o.getElementById)(`${i}-retry-loading`);e&&!e.classList.contains("disabled")&&(e.style.display="block",e.classList.add("disabled"),setTimeout((()=>{e.style.display="none",e.classList.remove("disabled")}),2e3))}})))),null==d||d.addEventListener("click",(()=>n(void 0,void 0,void 0,(function*(){var n;(0,o.removeElement)(i);const s=(0,r.getNotificationPermission)({safariWebPushId:null===(n=t.siteSettings.safari_options)||void 0===n?void 0:n.push_id});e(s)}))))}))}))},9798:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.removeSubscriptionOverlay=t.addSubscriptionOverlayToPage=void 0;const n=i(3641),o=i(1920),s=i(7643),r="pushengage-subscription-overlay";t.addSubscriptionOverlayToPage=({overlay:e,site:t})=>{e&&"mobile"!==(0,o.detectDeviceType)()&&((0,n.getElementById)(r)||(0,s.addSubscriptionOverlayViewToPage)({site:t,overlay:e}))},t.removeSubscriptionOverlay=()=>{(0,n.removeElement)(r)}},3395:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.removeSubscriptionReminderPrompt=t.addSubscriptionReminderPromptToPage=void 0;const n=i(3641),o=i(1920),s=i(8312),r=i(2471),a=i(9892),d=i(2689),c=i(4014),l="pushengage-subscription-reminder-prompt";let u;t.addSubscriptionReminderPromptToPage=({reminderPrompt:e,overlay:t,site:i})=>{const g=(0,o.detectDeviceType)();if(t&&"desktop"===g)return;if(!e)return;if((0,n.getElementById)(l))return;if(!(0,r.isSupportQuieterUI)()||"desktop"!==g)return;const{count:p}=(0,a.getReminderPromptDataFromStorage)()||{};p&&p>=e.max_prompt||(u=setTimeout((()=>{(0,s.addSubscriptionReminderPromptViewToPage)({reminderPrompt:e,site:i}),(0,a.setReminderPromptDataToStorage)();const t=(0,n.getElementById)(`${l}-button`);null==t||t.addEventListener("click",(()=>{(0,n.removeElement)(l),clearTimeout(u)}))}),1e3*(e=>{const{lastShownTime:t}=(0,a.getReminderPromptDataFromStorage)()||{};if(!t)return e.show_after_initial_delay;const i=((0,d.getUnixTime)()-t)/1e3;return(0,c.toInteger)(Math.max(e.show_again_after-i,0).toFixed(0))})(e)))},t.removeSubscriptionReminderPrompt=()=>{(0,n.removeElement)(l),clearTimeout(u)}},8911:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},r=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.initializeSubscriptionOptInOnClick=t.initializeSubscriptionOptInForSubDomain=t.initializeSubscriptionOptIn=t.handleNotificationPermission=void 0;const d=a(i(3321)),c=i(8648),l=i(7888),u=s(i(3641)),g=s(i(9892)),p=a(i(4182)),b=i(3110),f=a(i(7607)),m=i(2471),v=i(9340),_=i(1730),h=i(6547),y=i(4014),w=i(1154),S=i(226),I=i(9851),P=a(i(8267)),O=a(i(1625));t.handleNotificationPermission=({optInType:e,options:t={}})=>r(void 0,void 0,void 0,(function*(){var i,n,o,s;if(!P.default.isLocked("isNotificationPermissionPending"))try{yield P.default.acquireLock("isNotificationPermissionPending");const r=(0,I.getAppData)(),a=(0,m.isTokenRefresh)({safariWebPushId:null===(i=r.siteSettings.safari_options)||void 0===i?void 0:i.push_id});let d;"denied"===(0,m.getNotificationPermission)({safariWebPushId:null===(n=r.siteSettings.safari_options)||void 0===n?void 0:n.push_id})&&"denied"===(yield(0,S.addResetNotificationPermissionPopupToPage)(r.siteSettings.reset_notification_permission_popup))&&(d={permission:"denied"}),d||("default"===(0,m.getNotificationPermission)({safariWebPushId:null===(o=r.siteSettings.safari_options)||void 0===o?void 0:o.push_id})&&p.default.trigger("permissionPrompt",{optInType:t.widgetOptInType||e,state:"displayed",prompt:"native"}),d=yield(0,w.notifyPermissionPromptAndGetSubscription)({siteSettings:r.siteSettings,site:r.site})),p.default.trigger("permissionPrompt",{optInType:t.widgetOptInType||e,prompt:"native",state:"granted"===(0,m.getNotificationPermission)({safariWebPushId:null===(s=r.siteSettings.safari_options)||void 0===s?void 0:s.push_id})?"allow":"close"}),yield(0,c.processNotificationPermission)({permissionData:d,optInType:e,siteSettings:r.siteSettings,site:r.site,options:{tokenRefresh:a,segment:t.segment,widgetOptInType:t.widgetOptInType}});const l="default"===d.permission&&(0,_.isAllSubscriptionOptInClosed)(r.siteSettings.optin_settings)?"denied":d.permission;p.default.trigger("notificationPermissionReceived",{permission:l,subscriberId:g.getSubscriberIdFromStorage()||void 0,isPermissionChanged:!0})}finally{P.default.releaseLock("isNotificationPermissionPending")}}));const E=()=>r(void 0,void 0,void 0,(function*(){const e=(0,I.getAppData)(),t=(0,b.getSubDomainSubscriptionUrl)({customSubDomainSetting:e.siteSettings.custom_url,siteSubDomain:e.site.site_subdomain});"tab"===t.type?window.open(t.url,"_blank"):window.open(t.url,"_blank","width=800, height=600")}));t.initializeSubscriptionOptIn=({activeSubscriptionOptIns:e})=>r(void 0,void 0,void 0,(function*(){var i;const n=(0,I.getAppData)();f.default.debug("The initialization of the subscription opt-in has begun.");const o=e=>{const i=e.optin_type,o=`pushengage-opt-in-${i}`,s=`pushengage-opt-in-${i}-tooltip`,a=u.getElementById(`pushengage-opt-in-${i}-allow`),c=u.getElementById(`pushengage-opt-in-${i}-close`),l=u.getElementById(`pushengage-opt-in-${i}-powered-by`);return new Promise(((m,y)=>{try{if(!a)return void y(new d.default({message:"Allow button not found",type:"NotFoundException",details:{site:n.site.site_id}}));a.addEventListener("click",(()=>r(void 0,void 0,void 0,(function*(){try{yield new Promise(((r,a)=>{f.default.debug('The user clicked on the "Allow" button.'),p.default.trigger("permissionPrompt",{optInType:i,state:"allow",prompt:"html"});const c=(()=>{const e=[];return document.querySelectorAll(`#pushengage-opt-in-${i}__segments input[type="checkbox"]`).forEach((t=>{const i=t;i.checked&&e.push(i.value)})),e})();u.removeElement(o),u.removeElement(s),(0,b.canSubscribeViaServiceWorker)({isServiceWorkerAvailable:!!e.optin_sw_support})?(0,t.handleNotificationPermission)({optInType:i,options:{segment:c}}).then((()=>r())).catch((e=>a(e))):(O.default.set("subscriptionOnSubdomain",Object.assign(Object.assign({},O.default.get("subscriptionOnSubdomain")),{optInType:i,segment:c})),E(),p.default.on("notificationPermissionReceivedFromSubDomain",(e=>{try{const t=e;"error"in t?a(new d.default(Object.assign(Object.assign({},t.error),{details:{site_id:n.site.site_id}}))):r()}catch(e){a(e)}}),{once:!0}))})),m()}catch(e){y(e)}})))),c&&c.addEventListener("click",(()=>r(void 0,void 0,void 0,(function*(){try{yield r(void 0,void 0,void 0,(function*(){f.default.debug('The user clicked on the "Close" button.'),p.default.trigger("permissionPrompt",{optInType:i,state:"close",prompt:"html"}),u.removeElement(o),u.removeElement(s),g.storeOptInCloseDataInStorage({optInType:i,storageDuration:e.cookie_duration}),(0,_.isAllSubscriptionOptInClosed)(n.siteSettings.optin_settings)&&p.default.trigger("notificationPermissionReceived",{permission:"denied",isPermissionChanged:!0}),n.siteSettings.sub_analytics.enabled&&(yield(0,h.sendOptInAnalytics)({optin_type:e.optin_type,site_id:n.site.site_id,block_1:!0,optin_1:!0}))})),m()}catch(e){y(e)}})))),l&&l.addEventListener("click",(()=>r(void 0,void 0,void 0,(function*(){window.open(v.poweredByReferralUrl,"_blank")}))))}catch(e){y(e)}}))},s=({optIn:e,isHtmlView:i})=>{const s=()=>r(void 0,void 0,void 0,(function*(){f.default.debug(`Initialized the ${e.optin_name} subscription opt-in.`),i?(p.default.trigger("permissionPrompt",{state:"displayed",prompt:"html",optInType:e.optin_type}),(0,l.addOptInViewToPage)({optIn:e,site:n.site}),yield o(e)):yield(0,t.handleNotificationPermission)({optInType:e.optin_type})}));return new Promise(((t,i)=>{const n=()=>r(void 0,void 0,void 0,(function*(){if(!(u.getScrollPercentage()r(void 0,void 0,void 0,(function*(){try{yield s(),t()}catch(e){i(e)}}))),1e3*e.optin_delay)):"scroll"===e.optin_category&&(f.default.debug(`Initializing the ${e.optin_name} subscription opt-in with a scroll(${e.optin_scroll}%).`),u.getScrollPercentage()>=e.optin_scroll?s().then((()=>t())).catch((e=>i(e))):window.addEventListener("scroll",n));const a=()=>{const t=`pushengage-opt-in-${e.optin_type}`,i=`pushengage-opt-in-${e.optin_type}-tooltip`;u.removeElement(t),u.removeElement(i),window.removeEventListener("scroll",n),o&&clearTimeout(o)};p.default.on("subscriptionInitializedFromClickManager",(()=>{try{a(),t()}catch(e){i(e)}}),{once:!0});const d=n=>{try{const{optInType:i,state:o,prompt:s}=n;if(P.default.isLocked("isNotificationPermissionPending")&&e.optin_type===v.optInTypes.singleStep)return;("allow"===o||"close"===o&&"native"===s)&&i!==e.optin_type&&(a(),t(),p.default.remove("permissionPrompt",d))}catch(e){i(e)}};p.default.on("permissionPrompt",d)}))},a=[],c=e.map((e=>e.optin_type));for(const t of e){if(g.isSubscriptionOptInClosed(t.optin_type))continue;f.default.debug(`Initializing the ${t.optin_name} subscription opt-in.`);const e={};switch(t.optin_type){case v.optInTypes.safari:case v.optInTypes.floatingBar:case v.optInTypes.bell:Object.assign(e,{optIn:t,isHtmlView:!0});break;case v.optInTypes.singleStep:if("denied"===(0,m.getNotificationPermission)({safariWebPushId:null===(i=n.siteSettings.safari_options)||void 0===i?void 0:i.push_id})){const i=1;c.length===i&&Object.assign(e,{optIn:t,isHtmlView:!0})}else(0,m.isUserGestureRequiredForPermissionPrompt)()?c.includes(v.optInTypes.bell)||Object.assign(e,{optIn:t,isHtmlView:!0}):Object.assign(e,{optIn:t});break;case v.optInTypes.largeSafari:case v.optInTypes.largeSafariWithSegments:case v.optInTypes.sleekOptInBox:Object.assign(e,{optIn:t,isHtmlView:!0});break;default:throw new d.default({message:"Opt-in type doesn't exist.",type:"NotFoundException",details:{site:n.site.site_id}})}(0,y.isEmptyObject)(e)||a.push(s(Object.assign({},e)))}yield Promise.all(a)})),t.initializeSubscriptionOptInForSubDomain=()=>{var e;const t=(0,I.getAppData)();if(!window.opener)return f.default.error("Window opener not found."),Promise.resolve();const i=document.referrer||"*",n=(0,m.isTokenRefresh)({safariWebPushId:null===(e=t.siteSettings.safari_options)||void 0===e?void 0:e.push_id}),o=()=>{window.opener.postMessage({source:"PushEngage",prompt:!0,siteId:t.site.site_id},i)},s=()=>new Promise(((e,i)=>{if((0,m.isUserGestureRequiredForPermissionPrompt)()){const n="pushengage-opt-in-intermediate-button",s=u.getElementById(n);if(!s)return void i(new d.default({message:"intermediate allow button not found",type:"NotFoundException",details:{site:t.site.site_id}}));s.style.visibility="visible",s.addEventListener("click",(()=>r(void 0,void 0,void 0,(function*(){o(),(0,w.notifyPermissionPromptAndGetSubscription)({siteSettings:t.siteSettings,site:t.site}).then((t=>e(t))).catch((e=>i(e))),s.style.visibility="hidden"}))))}else o(),(0,w.notifyPermissionPromptAndGetSubscription)({siteSettings:t.siteSettings,site:t.site}).then((t=>e(t))).catch((e=>i(e)))}));return new Promise((e=>{const a={permission:"default"};let d=!1;window.addEventListener("beforeunload",(function(){return d||(window.opener.postMessage(Object.assign(Object.assign({},a),{source:"PushEngage",siteId:t.site.site_id}),i),d=!0),e()})),r(void 0,void 0,void 0,(function*(){var e;switch((0,m.getNotificationPermission)({safariWebPushId:null===(e=t.siteSettings.safari_options)||void 0===e?void 0:e.push_id})){case"granted":try{return{permission:"granted",subscription:yield(0,_.resubscribeSubscription)({vapidSetting:t.siteSettings.vapid_key,serviceWorkerSetting:v.defaultServiceWorkerSetting,safariWebPushPackageSetting:t.siteSettings.safari_options})}}catch(e){return yield s()}case"denied":{const e=yield(0,S.addResetNotificationPermissionPopupToPage)(t.siteSettings.reset_notification_permission_popup);return"denied"===e?{permission:"denied"}:("default"===e&&o(),yield(0,w.notifyPermissionPromptAndGetSubscription)({siteSettings:t.siteSettings,site:t.site}))}default:return yield s()}})).then((e=>{Object.assign(a,e,{tokenRefresh:n}),window.close()})).catch((e=>{Object.assign(a,{error:{message:e.message,name:e.name,type:e.type}}),window.close()}))}))},t.initializeSubscriptionOptInOnClick=({options:e})=>{const i=(0,I.getAppData)();return new Promise(((n,o)=>{var s;const r=v.optInTypes.singleStep;(0,b.canSubscribeViaServiceWorker)({isServiceWorkerAvailable:null===(s=null==e?void 0:e.isServiceWorkerAvailable)||void 0===s||s})?(0,t.handleNotificationPermission)({optInType:r,options:{segment:null==e?void 0:e.segment,widgetOptInType:null==e?void 0:e.widgetOptInType}}).then(n).catch(o):(O.default.set("subscriptionOnSubdomain",Object.assign(Object.assign({},O.default.get("subscriptionOnSubdomain")),{optInType:r,segment:null==e?void 0:e.segment,widgetOptInType:null==e?void 0:e.widgetOptInType})),E(),p.default.on("notificationPermissionReceivedFromSubDomain",(e=>{try{const t=e;"error"in t?o(new d.default(Object.assign(Object.assign({},t.error),{details:{site_id:i.site.site_id}}))):n()}catch(e){o(e)}}),{once:!0}))}))}},2004:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.initializeSubscription=void 0;const s=i(3110),r=i(1730),a=o(i(7607)),d=i(1920),c=i(9291),l=i(8911),u=o(i(4182)),g=i(3502),p=i(9892),b=i(2471),f=i(9851),m=i(5021),v=o(i(8267)),_=o(i(1625)),h=o(i(3321));t.initializeSubscription=({triggerFrom:e,options:t})=>n(void 0,void 0,void 0,(function*(){const i=(0,f.getAppData)(),o=Object.assign({},(0,f.getSDKInitOptions)());if(o.isSubscriptionOnSubDomain)yield(0,l.initializeSubscriptionOptInForSubDomain)();else{const{optin_settings:f,vapid_key:y,safari_options:w,service_worker:S}=i.siteSettings,{name:I}=(0,d.detectBrowser)();if("Safari"===I&&!(0,b.hasSupportForPushApiInSafari)()&&!w)return void a.default.warn("The Safari web push settings are not configured, Please configure them through the PushEngage app dashboard.");const P=yield(0,r.evaluateUserSubscriptionState)({optInSetting:f,safariWebPushPackageSetting:w,serviceWorkerSetting:S,vapidSetting:y});"onClick"===e?yield(e=>n(void 0,void 0,void 0,(function*(){if(v.default.isLocked("isNotificationPermissionPending"))throw new Error("Notification permission is pending, which means the permission prompt is already being displayed on the screen.");u.default.trigger("subscriptionInitializedFromClickManager",void 0);const{state:n,subscription:o}=e,{privacy_settings:s,publisher_settings:r}=i.siteSettings,b=yield(0,m.getGeoInfo)({isEu:i.site.is_eu});switch(n){case"subscribed":{a.default.debug("User subscription state is subscribed.");const e=(0,p.getSubscriberIdFromStorage)();yield(0,g.syncSubscriberData)({subscriberId:e,browserInfo:(0,d.getBrowserInfo)(),geoInfo:s.geoLocationEnabled?b:void 0,isPublisherSettingEnabled:null==r?void 0:r.enabled}),u.default.trigger("notificationPermissionReceived",{subscriberId:e,permission:"granted"});break}case"resubscribe":{a.default.debug("User subscription state is resubscribe."),yield(0,c.handleResubscribeSubscription)({subscription:o});const e=(0,p.getSubscriberIdFromStorage)();u.default.trigger("notificationPermissionReceived",{subscriberId:e,permission:"granted",isPermissionChanged:!0});break}default:a.default.debug(`User subscription state is ${n}, showing opt-in.`),yield(0,l.initializeSubscriptionOptInOnClick)({options:null==t?void 0:t.clickOptions})}})))(P):yield(e=>n(void 0,void 0,void 0,(function*(){var n;const{state:r,subscription:b}=e,{optin_settings:f,optin_management_settings:v,optin_subscription_rule:y,privacy_settings:w,publisher_settings:S}=i.siteSettings;switch(r){case"subscribed":{a.default.debug("User subscription state is subscribed.");const e=(0,p.getSubscriberIdFromStorage)(),t=yield(0,m.getGeoInfo)({isEu:i.site.is_eu});yield(0,g.syncSubscriberData)({subscriberId:e,browserInfo:(0,d.getBrowserInfo)(),geoInfo:w.geoLocationEnabled?t:void 0,isPublisherSettingEnabled:null==S?void 0:S.enabled}),u.default.trigger("notificationPermissionReceived",{subscriberId:e,permission:"granted"});break}case"resubscribe":{a.default.debug("User subscription state is resubscribe."),yield(0,c.handleResubscribeSubscription)({subscription:b});const e=(0,p.getSubscriberIdFromStorage)();u.default.trigger("notificationPermissionReceived",{subscriberId:e,permission:"granted",isPermissionChanged:!0});break}case"unsubscribed":a.default.debug("User subscription state is unsubscribed."),u.default.trigger("notificationPermissionReceived",{permission:"denied"});break;case"denied":a.default.debug("User subscription state is denied."),u.default.trigger("notificationPermissionReceived",{permission:"denied"});break;case"closed":a.default.debug("Subscription closed: All opt-ins have been closed by the user."),u.default.trigger("notificationPermissionReceived",{permission:"denied"});break;default:{if(a.default.debug("User subscription state is default, showing opt-in."),!0!==(null===(n=null==t?void 0:t.initOptions)||void 0===n?void 0:n.forceInit)&&o.disabledDefaultPrompt)return void a.default.debug("Default prompt is disabled.");const e=yield(0,m.getGeoInfo)({isEu:i.site.is_eu});if(!(0,s.isSatisfyingSubscriptionRules)(v,e))return void a.default.info("No active subscription opt-in is available. Filtering by global rules.");const r=(0,s.filterSubscriptionOptInsByRules)(f,y,e);if(!r.length)return void a.default.info("No active subscription opt-in is available. Filtering by opt-in rules.");if(_.default.get("isSubscriptionInitialized"))throw new h.default({message:"Subscription is already initialized.",name:h.default.ERROR_NAME.SubscriptionAlreadyInitialized});_.default.set("isSubscriptionInitialized",!0),yield(0,l.initializeSubscriptionOptIn)({activeSubscriptionOptIns:r})}}})))(P)}a.default.debug("Subscription initialization completed.")}))},5544:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.syncDatabase=void 0;const s=i(9851),r=o(i(7607)),a=i(4318);t.syncDatabase=()=>{const e=(0,s.getAppData)();n(void 0,void 0,void 0,(function*(){try{yield(0,a.syncAppId)(e.site.site_key)}catch(e){r.default.error(`Error during sync appId to database, ${e.message}`)}}))}},4963:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addEventListenerForUnsubscribeWidget=void 0;const s=o(i(4182)),r=i(3641),a=i(5569),d=i(1730),c=o(i(7607)),l=i(1791),u=i(3502),g=i(3110),p=i(4014),b=i(9851);t.addEventListenerForUnsubscribeWidget=()=>{const e=(0,b.getAppData)(),t="pushengage-unsubscribe-widget",{sub_management_settings:i}=e.siteSettings;if(!i)return;const o=i=>n(void 0,void 0,void 0,(function*(){yield(0,d.unsubscribeSubscription)({subscriberId:i,siteId:e.site.site_id,serviceWorkerSetting:e.siteSettings.service_worker}),c.default.debug("The subscription was unsubscribed through the unsubscribe widget."),yield(0,p.delay)(2e3),(0,r.removeElement)(t),s.default.trigger("notificationPermissionReceived",{permission:"denied",isPermissionChanged:!0})}));s.default.on("notificationPermissionReceived",(s=>n(void 0,void 0,void 0,(function*(){try{const{permission:d,subscriberId:p}=s,b=(0,r.getElementById)(t);if("granted"!==d)return void(0,r.removeElement)(t);if(!p)throw new Error("The subscriber ID is not available when the notification permission is granted.");if(b)return;if(!(0,g.isUrlSatisfyingUrlRules)({include:i.settings.rules.include,exclude:i.settings.rules.exclude},location.href))return;if(i.bell){const s=yield(0,u.getSubscriberData)(p);(({widget:i,subscriberId:s,automatedNotification:d})=>{(0,a.addUnsubscribeWidgetBellViewToPage)({widget:i,automatedNotification:d,site:e.site});const g=(0,r.getElementById)(`${t}-unsubscribe-button`),p=(0,r.getElementById)(`${t}-automated-notification`);null==g||g.addEventListener("click",(()=>n(void 0,void 0,void 0,(function*(){try{const e=(0,r.getElementById)(t);null==e||e.classList.add("pushengage-unsubscribe-widget--hidden"),yield o(s)}catch(t){c.default.error(t.message),(0,l.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}})))),null==p||p.addEventListener("change",(i=>n(void 0,void 0,void 0,(function*(){try{const n=(0,r.getElementById)(t),o=i.target,a=o.checked,d="pushengage-unsubscribe-widget--automated-notification-enabled";o.disabled=!0,a?null==n||n.classList.add(d):null==n||n.classList.remove(d),yield(0,u.updateAutomatedNotificationStatus)({subscriberId:s,siteId:e.site.site_id,status:a?"enabled":"disabled"}),o.disabled=!1}catch(t){c.default.error(t.message),(0,l.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}}))))})({subscriberId:p,widget:i.bell,automatedNotification:!!(null==s?void 0:s.trigger_status)})}else i.button&&(({widget:i,subscriberId:s})=>{(0,a.addUnsubscribeWidgetButtonViewToPage)({widget:i,site:e.site});const d=(0,r.getElementById)(`${t}-unsubscribe-title`),u=(0,r.getElementById)(`${t}-action-yes`),g=(0,r.getElementById)(`${t}-action-no`),p=(0,r.getElementById)(`${t}-close-button`);null==d||d.addEventListener("click",(()=>{const e=(0,r.getElementById)(t);null==e||e.classList.remove("pushengage-unsubscribe-widget--initial-state"),null==e||e.classList.add("pushengage-unsubscribe-widget--action-state")})),null==g||g.addEventListener("click",(()=>{const e=(0,r.getElementById)(t);null==e||e.classList.remove("pushengage-unsubscribe-widget--action-state"),null==e||e.classList.add("pushengage-unsubscribe-widget--initial-state")})),null==u||u.addEventListener("click",(()=>n(void 0,void 0,void 0,(function*(){try{const e=(0,r.getElementById)(t);null==e||e.classList.add("pushengage-unsubscribe-widget--final-state"),yield o(s)}catch(t){c.default.error(t.message),(0,l.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}})))),null==p||p.addEventListener("click",(()=>{(0,r.removeElement)(t)}))})({subscriberId:p,widget:i.button})}catch(t){c.default.error(t.message),(0,l.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}}))))}},3609:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sleep=t.removeSubscriberIdFromTag=t.getColorTheme=t.isHostPushEngageSubDomain=t.getSDKInitOptions=t.isDOMContentLoaded=t.getSDKLoadCount=void 0;const n=i(4014),o=i(9340);t.getSDKLoadCount=()=>{const e=window.__PushEngageSdkLoadCount||0;return window.__PushEngageSdkLoadCount=e+1},t.isDOMContentLoaded=()=>new Promise((e=>{"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>e())):e()})),t.getSDKInitOptions=(e,t=[])=>{if(!e||!Array.isArray(e))return;let i;for(let t=0;t0){const[e,t]=n;if("init"===e&&"object"==typeof t){i=t;break}}}if(!i)return;if((0,n.isUndefined)(window.dialog_box)||(i.isSubscriptionOnSubDomain=!0),!i.isLegacySDK)return i;if(!Array.isArray(t))return i;let o=!1;for(let e=0;e0){const[e,t]=s;if("init"===e&&(o=!0,("string"==typeof t||Array.isArray(t))&&(i.segment=t)),"config"===e&&"object"==typeof t){const e={};(0,n.isUndefined)(t.worker)||(e.path=t.worker),(0,n.isUndefined)(t.scope)||(e.scope=t.scope),(0,n.isUndefined)(t.workerStatus)||(e.status=t.workerStatus),(0,n.isEmptyObject)(e)||(i.serviceWorker=e)}}}return o?i:Object.assign(Object.assign({},i),{disabledDefaultPrompt:!0})},t.isHostPushEngageSubDomain=e=>`${e}.${o.env.__DOMAIN_NAME__}`===location.host,t.getColorTheme=e=>{const t=e.replace("#","");return(.299*parseInt(t.substring(0,2),16)+.587*parseInt(t.substring(2,4),16)+.114*parseInt(t.substring(4,6),16))/255>.5?"light":"dark"},t.removeSubscriberIdFromTag=e=>{if(!e.includes("-"))return e;const t=e.lastIndexOf("-");return e.substring(0,t)},t.sleep=e=>new Promise((t=>setTimeout(t,e)))},8405:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getWidgetOptInNameByType=t.getOptInNameByType=t.getOptInRuleNameByType=t.getOptInTypeByName=void 0;const i=[{type:1,name:"safari",displayName:"Safari Style Box"},{type:2,name:"floating_bar",displayName:"Floating Bar"},{type:3,name:"bell",displayName:"Bell Placed Bar"},{type:4,name:"single_step",displayName:"Push Single Step Opt-in"},{type:6,name:"large_safari",displayName:"Large Safari Style Box"},{type:8,name:"large_safari_with_segment",displayName:"Large Safari Style with Segment"},{type:9,name:"sleek_opt_in_box",displayName:"Sleek Opt-in Box"}],n=[{type:127,name:"subscription_management_widget",displayName:"Subscriber Recovery/Subscription Management Widget"}];t.getOptInTypeByName=e=>{var t;return null===(t=i.find((t=>t.name===e)))||void 0===t?void 0:t.type},t.getOptInRuleNameByType=e=>{var t;return null===(t=i.find((t=>t.type===e)))||void 0===t?void 0:t.name},t.getOptInNameByType=e=>{var t;return null===(t=i.find((t=>t.type===e)))||void 0===t?void 0:t.displayName},t.getWidgetOptInNameByType=e=>{var t;return null===(t=n.find((t=>t.type===e)))||void 0===t?void 0:t.displayName}},9892:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSubscriptionOnSubDomain=t.setReminderPromptDataToStorage=t.getReminderPromptDataFromStorage=t.setShopifyCampaignDataToStorage=t.getShopifyCampaignDataFromStorage=t.deleteSubscriberDataFromStorage=t.setSubscriberDataToStorage=t.addSubscriberDataToStorage=t.getSubscriberDataFromStorage=t.getSubscriberIdFromStorage=t.storeSubscriptionUnsubscribedDataInStorage=t.storeSubscriptionDeniedDataInStorage=t.storeOptInCloseDataInStorage=t.storeSubscriptionDataInStorage=t.isSubscriptionDenied=t.isSubscriptionUnsubscribed=t.hasSubscriptionDataInStorage=t.isSubscriptionOptInClosed=t.clearSubscriptionUnsubscribedDataFromStorage=t.clearOldSubscriptionDataFromStorage=t.clearSubscriptionDeniedDataFromStorage=t.getParsedStorageData=void 0;const n=i(606),o=i(9340),s=i(4014),r=i(2689);t.getParsedStorageData=e=>{const t=(0,n.getDataFromLocalStorage)(e);return t&&(0,s.safeParse)(t)||{}},t.clearSubscriptionDeniedDataFromStorage=()=>{const e=(0,t.getParsedStorageData)(o.storageName),i=(0,s.omit)(e,["denied"]);(0,s.isEmptyObject)(i)?(0,n.deleteDataFromLocalStorage)(o.storageName):(0,n.setDataToLocalStorage)(o.storageName,i)},t.clearOldSubscriptionDataFromStorage=()=>{let e=(0,t.getParsedStorageData)(o.storageName);e=(0,s.omit)(e,["id","isSubDomain","endpoint","subscriber"]),(0,s.isEmptyObject)(e)?(0,n.deleteDataFromLocalStorage)(o.storageName):(0,n.setDataToLocalStorage)(o.storageName,e)},t.clearSubscriptionUnsubscribedDataFromStorage=()=>{let e=(0,t.getParsedStorageData)(o.storageName);e=(0,s.omit)(e,["unsubscribed"]),(0,s.isEmptyObject)(e)?(0,n.deleteDataFromLocalStorage)(o.storageName):(0,n.setDataToLocalStorage)(o.storageName,e),(0,n.deleteDataFromCookies)("PushSubscriberStatus")},t.isSubscriptionOptInClosed=e=>{const i=(0,t.getParsedStorageData)(o.storageName);if(!i.optInClosed)return!1;const n=i.optInClosed,a=Array.isArray(e)?e:[e];for(let e=0;e{const i=(0,t.getParsedStorageData)(o.storageName),n=i.isSubDomain||"granted"===e;return!!(i.endpoint&&i.id&&n)},t.isSubscriptionUnsubscribed=({notificationPermission:e})=>{const i=(0,t.getParsedStorageData)(o.storageName);if(!i.unsubscribed)return!1;const{data:n,expiresAt:s}=i.unsubscribed;return!(s<=(0,r.getUnixTime)()||(!1===n.isSubDomain&&"granted"!==e?((0,t.clearSubscriptionUnsubscribedDataFromStorage)(),1):!0!==n.status))},t.isSubscriptionDenied=({notificationPermission:e})=>{const i=(0,t.getParsedStorageData)(o.storageName);if(!i.denied)return!1;const{data:n,expiresAt:s}=i.denied;return!(s<=(0,r.getUnixTime)()||(!1===n.isSubDomain&&"denied"!==e?((0,t.clearSubscriptionDeniedDataFromStorage)(),1):!0!==n.status))},t.storeSubscriptionDataInStorage=({subscriberId:e,subscription:t,isSubDomain:i})=>{const s={isSubDomain:i,id:e,endpoint:t.endpoint||t.deviceToken};(0,n.setDataToLocalStorage)(o.storageName,s),(0,n.deleteDataFromCookies)(["PushSubscriberStatus","peclosed"])},t.storeOptInCloseDataInStorage=({optInType:e,storageDuration:i})=>{const s=(0,t.getParsedStorageData)(o.storageName),a={optInClosed:Object.assign(Object.assign({},s.optInClosed),{[e]:{data:!0,expiresAt:(0,r.getUnixTime)(i)}})};(null==s?void 0:s.reminderPrompt)&&(a.reminderPrompt=s.reminderPrompt),(0,n.setDataToLocalStorage)(o.storageName,a)},t.storeSubscriptionDeniedDataInStorage=({isSubDomain:e,storageDuration:i})=>{const s=(0,t.getParsedStorageData)(o.storageName),a={denied:{data:{status:!0,isSubDomain:e},expiresAt:(0,r.getUnixTime)(i)}};s.reminderPrompt&&(a.reminderPrompt=s.reminderPrompt),(0,n.setDataToLocalStorage)(o.storageName,a),(0,n.deleteDataFromCookies)(["PushSubscriberStatus","peclosed"])},t.storeSubscriptionUnsubscribedDataInStorage=e=>{const i=(0,t.getParsedStorageData)(o.storageName),s={unsubscribed:{data:{status:!0,isSubDomain:e},expiresAt:(0,r.getUnixTime)(365)}};i.reminderPrompt&&(s.reminderPrompt=i.reminderPrompt),(0,n.setDataToLocalStorage)(o.storageName,s),(0,n.deleteDataFromCookies)(["PushSubscriberStatus","peclosed"])},t.getSubscriberIdFromStorage=()=>{const e=(0,t.getParsedStorageData)(o.storageName);return e.id?e.id:null},t.getSubscriberDataFromStorage=e=>{const i=(0,t.getParsedStorageData)(o.storageName).subscriber;return!i||i.expiresAt<=(0,r.getUnixTime)()?null:e?i.data[e]||null:i.data},t.addSubscriberDataToStorage=e=>{const i=(0,t.getParsedStorageData)(o.storageName),s=Object.assign(Object.assign({},i),{subscriber:{expiresAt:(0,r.getUnixTime)(1),data:e}});(0,n.setDataToLocalStorage)(o.storageName,s)},t.setSubscriberDataToStorage=e=>{var i,s;const a=(0,t.getParsedStorageData)(o.storageName),d=(null===(i=a.subscriber)||void 0===i?void 0:i.expiresAt)||(0,r.getUnixTime)(1),c=Object.assign(Object.assign({},a),{subscriber:{expiresAt:d,data:Object.assign(Object.assign({},null===(s=null==a?void 0:a.subscriber)||void 0===s?void 0:s.data),e)}});(0,n.setDataToLocalStorage)(o.storageName,c)},t.deleteSubscriberDataFromStorage=()=>{const e=(0,t.getParsedStorageData)(o.storageName);if(!e.subscriber)return;const i=(0,s.omit)(e,["subscriber"]);(0,s.isEmptyObject)(e)?(0,n.deleteDataFromLocalStorage)(o.storageName):(0,n.setDataToLocalStorage)(o.storageName,i)},t.getShopifyCampaignDataFromStorage=()=>{const e=(0,t.getParsedStorageData)(o.storageName);return e.shopify?e.shopify:null},t.setShopifyCampaignDataToStorage=e=>{const i=(0,t.getParsedStorageData)(o.storageName),s=Object.assign(Object.assign({},i),{shopify:Object.assign(Object.assign({},null==i?void 0:i.shopify),e)});(0,n.setDataToLocalStorage)(o.storageName,s)},t.getReminderPromptDataFromStorage=()=>{const e=(0,t.getParsedStorageData)(o.storageName);return e.reminderPrompt?e.reminderPrompt:null},t.setReminderPromptDataToStorage=()=>{var e;const i=(0,t.getParsedStorageData)(o.storageName),a={reminderPrompt:{count:(0,s.toInteger)(null===(e=i.reminderPrompt)||void 0===e?void 0:e.count)+1,lastShownTime:(0,r.getUnixTime)()}};(null==i?void 0:i.denied)&&(a.denied=i.denied),(null==i?void 0:i.unsubscribed)&&(a.unsubscribed=i.unsubscribed),(null==i?void 0:i.optInClosed)&&(a.optInClosed=i.optInClosed),(0,n.setDataToLocalStorage)(o.storageName,a)},t.isSubscriptionOnSubDomain=()=>(0,t.getParsedStorageData)(o.storageName).isSubDomain},4318:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},r=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.deleteFailedClickedNotificationTag=t.getFailedClickedNotificationTags=t.addFailedClickedNotificationTag=t.deleteFailedViewedNotificationTag=t.getFailedViewedNotificationTags=t.addFailedViewedNotificationTag=t.getNotificationTagsByKey=t.updateNotificationTagByKey=t.syncAppId=t.getAppId=void 0;const a=i(9340),d=s(i(1074)),c=i(4014);t.getAppId=()=>r(void 0,void 0,void 0,(function*(){const e=yield d.openDB(a.database.name,a.database.version,a.database.stores),t=yield d.getObject(e,"ids","appId");return(null==t?void 0:t.appId)||null})),t.syncAppId=e=>r(void 0,void 0,void 0,(function*(){const t=yield d.openDB(a.database.name,a.database.version,a.database.stores);yield d.upsertObject(t,"ids",{id:"appId",appId:e})})),t.updateNotificationTagByKey=(e,t)=>r(void 0,void 0,void 0,(function*(){const i=yield d.openDB(a.database.name,a.database.version,a.database.stores),n=yield d.getObject(i,"ids",t),o=(null==n?void 0:n.notificationTags)||[];yield d.upsertObject(i,"ids",{id:t,notificationTags:(0,c.keepLastMaxElements)([...o,e],5)})})),t.getNotificationTagsByKey=e=>r(void 0,void 0,void 0,(function*(){const t=yield d.openDB(a.database.name,a.database.version,a.database.stores),i=yield d.getObject(t,"ids",e);return i&&i.notificationTags||[]})),t.addFailedViewedNotificationTag=({tag:e})=>r(void 0,void 0,void 0,(function*(){const t="failedViewedNotificationTags",i=yield d.openDB(a.database.name,a.database.version,a.database.stores);(yield d.getObject(i,t,e))||(yield d.upsertObject(i,t,{id:e}))})),t.getFailedViewedNotificationTags=()=>r(void 0,void 0,void 0,(function*(){const e=yield d.openDB(a.database.name,a.database.version,a.database.stores);return yield d.getObjects(e,"failedViewedNotificationTags")})),t.deleteFailedViewedNotificationTag=e=>r(void 0,void 0,void 0,(function*(){const t=yield d.openDB(a.database.name,a.database.version,a.database.stores);yield d.deleteObject(t,"failedViewedNotificationTags",e)})),t.addFailedClickedNotificationTag=({tag:e,action:t})=>r(void 0,void 0,void 0,(function*(){const i="failedClickedNotificationTags",n=yield d.openDB(a.database.name,a.database.version,a.database.stores);(yield d.getObject(n,i,e))||(yield d.upsertObject(n,i,{action:t,id:e}))})),t.getFailedClickedNotificationTags=()=>r(void 0,void 0,void 0,(function*(){const e=yield d.openDB(a.database.name,a.database.version,a.database.stores);return yield d.getObjects(e,"failedClickedNotificationTags")})),t.deleteFailedClickedNotificationTag=e=>r(void 0,void 0,void 0,(function*(){const t=yield d.openDB(a.database.name,a.database.version,a.database.stores);yield d.deleteObject(t,"failedClickedNotificationTags",e)}))},2768:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{d(n.next(e))}catch(e){s(e)}}function a(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.subscribeToPushNotificationFromWorker=t.getSubscriptionFromWorker=t.getDeviceTokenFromEndpoint=t.unregisterServiceWorker=t.unsubscribeFromPushSubscription=t.getSafariSubscription=t.getPushSubscription=t.subscribeToPushNotification=t.isServiceWorkerRegistered=t.requestSafariNotificationPermission=t.requestNotificationPermission=void 0;const s=o(i(3321)),r=i(4014),a=o(i(8267)),d=e=>{const t=(e+"=".repeat((4-e.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/"),i=("undefined"!=typeof window?window:self).atob(t),n=new Uint8Array(i.length);for(let e=0;en(void 0,void 0,void 0,(function*(){var i;const n=Object.assign({},t);let o=e;if(!e){const e=yield navigator.serviceWorker.getRegistrations();if(0===e.length)throw new s.default({message:"The service worker is not registered and tries to get a subscription.",name:s.default.ERROR_NAME.ServiceWorkerNotFound});const[t]=e;if(o=null===(i=t.active)||void 0===i?void 0:i.scriptURL,!o)throw new s.default({message:"The service worker scriptURL is missing in the registration object.",name:s.default.ERROR_NAME.ServiceWorkerNotFound});t.scope===`${location.origin}/`&&(n.scope="/")}try{const e=yield navigator.serviceWorker.register(o,n);return(null==n?void 0:n.scope)?yield navigator.serviceWorker.ready:yield(0,r.delay)(500),e}catch(e){throw new s.default({message:e.message,name:s.default.ERROR_NAME.ServiceWorkerNotRegistering})}}));t.requestNotificationPermission=()=>n(void 0,void 0,void 0,(function*(){if(!("Notification"in window))throw new Error("This browser does not support notifications.");if(!("requestPermission"in Notification))throw new s.default({message:"This browser does not support requestPermission.",name:s.default.ERROR_NAME.RequestPermissionNotSupported});const e=yield Notification.requestPermission();return"default"===e&&"denied"===Notification.permission?"denied":e})),t.requestSafariNotificationPermission=(e,t,i)=>new Promise((function(n,o){if(!("safari"in window)||!("pushNotification"in window.safari))return void o(new Error("Safari push notifications are not supported."));const s=window.safari.pushNotification.permission(e);"default"===s.permission?window.safari.pushNotification.requestPermission(t,e,i,(function(e){n(JSON.parse(JSON.stringify(e)))})):n(JSON.parse(JSON.stringify(s)))})),t.isServiceWorkerRegistered=()=>n(void 0,void 0,void 0,(function*(){return"serviceWorker"in navigator&&(yield navigator.serviceWorker.getRegistrations()).length>0})),t.subscribeToPushNotification=({vapidPublicKey:e,scriptURL:t,options:i})=>n(void 0,void 0,void 0,(function*(){try{yield a.default.acquireLock("subscribeToPushNotification");const n={userVisibleOnly:!0,applicationServerKey:d(e)},o=yield c({scriptURL:t,options:i}),s=yield o.pushManager.subscribe(n);return JSON.parse(JSON.stringify(s))}catch(e){if("AbortError"===e.name||"NotAllowedError"===e.name)throw new s.default({message:e.message,name:s.default.ERROR_NAME.DisabledPushSubscriptionError});throw e}finally{a.default.releaseLock("subscribeToPushNotification")}})),t.getPushSubscription=({scriptURL:e,options:t})=>n(void 0,void 0,void 0,(function*(){const i=yield c({scriptURL:e,options:t}),n=yield i.pushManager.getSubscription();return n?JSON.parse(JSON.stringify(n)):null})),t.getSafariSubscription=e=>{const t=window.safari.pushNotification.permission(e);return JSON.parse(JSON.stringify(t))},t.unsubscribeFromPushSubscription=()=>n(void 0,void 0,void 0,(function*(){const e=yield navigator.serviceWorker.getRegistrations();for(let t=0;tn(void 0,void 0,void 0,(function*(){const e=yield navigator.serviceWorker.getRegistrations();for(let t=0;t{let t="";return t=e.indexOf("token=")>-1?e.slice(e.search("token=")+6):e.split("/")[e.split("/").length-1],t},t.getSubscriptionFromWorker=()=>n(void 0,void 0,void 0,(function*(){try{const e=yield self.registration.pushManager.getSubscription(),t=JSON.parse(JSON.stringify(e));return t.endpoint?t:null}catch(e){return null}})),t.subscribeToPushNotificationFromWorker=e=>n(void 0,void 0,void 0,(function*(){const t={userVisibleOnly:!0,applicationServerKey:d(e)},i=yield self.registration.pushManager.subscribe(t);return JSON.parse(JSON.stringify(i))}))},5827:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getProductTitleFromUrl=t.isUrlSatisfyingRules=void 0;const n=i(3241);t.isUrlSatisfyingRules=(e,t=location.href)=>{const i=new Set([t,`${t}/`,encodeURI(t),(0,n.safeDecodeURIComponent)(t)]);for(const[o,s]of Object.entries(e)){const e=new Set([...s,...s.map((e=>`${e}/`))]);switch(s.forEach((t=>{e.add(`http://${t}`),e.add(`https://${t}`),e.add(`http://${t}/`),e.add(`https://${t}/`),e.add(encodeURI(t)),e.add((0,n.safeDecodeURIComponent)(t))})),o){case"exact":if(Array.from(e).some((e=>i.has(e))))return!0;break;case"contains":if(Array.from(e).some((e=>i.has(e)||t.includes(e))))return!0;break;case"start":if(Array.from(e).some((e=>i.has(e)||t.startsWith(e))))return!0}}return!1},t.getProductTitleFromUrl=(e=location.href)=>{const t=e.split("/products/");if(t.length<2)return;const i=t.pop();return i?i.split("?")[0]:void 0}},2471:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isTokenRefresh=t.getNotificationPermission=t.isUserGestureRequiredForPermissionPrompt=t.isSupportQuieterUI=t.isPushNotificationSupported=t.supportsVapidPush=t.safariWebPushSupported=t.hasSupportForPushApiInSafari=void 0;const n=i(1920),o=i(3241),s=i(4014);t.hasSupportForPushApiInSafari=()=>{const{name:e}=(0,n.detectBrowser)();return"Safari"===e&&"serviceWorker"in navigator&&"Notification"in window&&"PushManager"in window},t.safariWebPushSupported=()=>{const{name:e,version:t}=(0,n.detectBrowser)();return"Safari"===e&&t>=11&&"Notification"in window&&"safari"in window&&"pushNotification"in window.safari},t.supportsVapidPush=()=>{const{name:e,version:t}=(0,n.detectBrowser)(),i=(0,n.detectDeviceType)(),r=(0,o.detectSiteType)();return!("Ucbrowser"===e||"Firefox"===e&&(48===t||49===t)||"Opera"===e&&41===t||"Yandex"===e&&"mobile"===i)&&(!!("http"===r&&"Firefox"===e&&t>=50)||"Notification"in window&&"PushManager"in window&&"undefined"!=typeof PushSubscriptionOptions&&(0,s.hasOwn)(PushSubscriptionOptions.prototype,"applicationServerKey"))},t.isPushNotificationSupported=()=>(0,t.supportsVapidPush)()||(0,t.safariWebPushSupported)(),t.isSupportQuieterUI=()=>{const{name:e,version:t}=(0,n.detectBrowser)(),i=(0,n.detectDeviceType)(),o=(0,n.getChromiumStatus)();return o.isChromium&&o.version>=80||"desktop"===i&&"Firefox"===e&&t>=72},t.isUserGestureRequiredForPermissionPrompt=()=>{const{name:e,version:t}=(0,n.detectBrowser)();return"Firefox"===e&&t>=72||"Safari"===e||"Yandex"===e},t.getNotificationPermission=({safariWebPushId:e})=>{const{name:i}=(0,n.detectBrowser)();return e&&"Safari"===i&&window.safari&&!(0,t.hasSupportForPushApiInSafari)()?window.safari.pushNotification.permission(e).permission:Notification.permission},t.isTokenRefresh=({safariWebPushId:e})=>"granted"===(0,t.getNotificationPermission)({safariWebPushId:e})},3425:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getOptInSegmentView=t.getPoweredByView=t.showPopoverView=t.getStyleForHtmlElement=t.showTooltipView=void 0;const n=i(3641),o=i(9340),s=i(4014);t.showTooltipView=({targetId:e,tooltipId:t})=>{const i=(0,n.getElementById)(e),o=(0,n.getElementById)(t);if(!i||!o)return;(0,n.addCSSProperties)(t,{inset:"unset"});const s=i.getBoundingClientRect(),r=window.innerWidth,a=window.innerHeight,d={},c=o.offsetHeight>s.height?s.height/2:o.offsetHeight/2;let l="",u="";const g=s.height>o.offsetHeight?(s.height-o.offsetHeight)/2:0;s.bottom>o.offsetHeight||s.bottom>a-s.bottom?(d.bottom=`${a-s.bottom+g}px`,u="pushengage-opt-in__tooltip__arrow--bottom",s.bottomo.offsetWidth?(d.right=r-(r-document.documentElement.clientWidth)-s.left+14+"px",l="pushengage-opt-in__tooltip__arrow--right"):(d.left=`${s.right+14}px`,l="pushengage-opt-in__tooltip__arrow--left"),(0,n.addCSSProperties)(t,d),o.classList.add("pushengage-opt-in__tooltip--opened",l,u),o.style.setProperty("--tooltip-arrow-offset",`${c}px`)},t.getStyleForHtmlElement=e=>e.replace(/\s+/g," ").trim(),t.showPopoverView=({targetId:e,popoverId:t})=>{const i=(0,n.getElementById)(e),o=(0,n.getElementById)(t);if(!i||!o)return;(0,n.addCSSProperties)(t,{inset:"unset"});const s=i.getBoundingClientRect(),r=12,a=window.innerHeight,d=window.innerWidth,c={};o.classList.contains("pushengage-opt-in__popover--beside")?(s.left-r>d-s.right?c.right=`${s.width+r}px`:c.left=`${s.width+r}px`,s.bottom>o.offsetHeight||s.bottom>a-s.bottom?(c.bottom=a-s.bottom+"px",s.bottomd-s.right?c.right=d-s.right+"px":c.left=`${s.left}px`,s.top>a-s.bottom||s.top>o.offsetHeight?(c.bottom=`${a-s.top+r}px`,s.top+re?`
\n Powered by ${o.brandName}\n
`:"",t.getOptInSegmentView=({optIn:e,getCheckboxBodyStyle:t,className:i})=>{let n="";if(Array.isArray(e.optin_segments)&&e.optin_segments.length){const o=e.default_segment_selection?"checked":"";e.optin_segments.forEach(((i,r)=>{n+=`\n
\n \n
\n `})),n=`\n
\n ${n}\n
\n `}return n}},9838:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addCampaignAlertWidget=void 0;const n=i(3425),o=i(9340),s=i(3641),r=i(9892);t.addCampaignAlertWidget=({alert:e,alertType:t,site:i,variantId:a})=>{const d=(({alert:e,alertType:t,site:i,variantId:s})=>{var a,d;const c=(0,r.getShopifyCampaignDataFromStorage)();let l="";("price_drop"===t&&(null===(a=null==c?void 0:c.priceDropVariantIds)||void 0===a?void 0:a.includes(s))||"inventory"===t&&(null===(d=null==c?void 0:c.backInStockVariantIds)||void 0===d?void 0:d.includes(s)))&&(l="pushengage-campaign-alert-widget--alert-sent");const u=`visibility: hidden;\n --bell-background-color: ${e.bell_background};\n --bell-color: ${e.bell_color};\n --bell-height: 50px;\n --bell-width: 50px;\n --bell-right: 30px;\n --bell-left: 30px;\n --bell-bottom:50px;\n --text-color: ${e.text_color};\n --allow-button-color: ${"#ffffff"===e.bell_color?e.bell_background:e.bell_color};\n --popover-background-color: #ffffff;\n --popover-color: #0d0d0d;\n`;return`\n \n \n
\n ${o.bellIcon}\n
\n \n\n \n
\n ${e.message[t].before_subscription}\n
\n\n \n ${e.message[t].after_subscription}\n \n\n \n ${e.message[t].allow_btn_txt}\n \n\n ${(0,n.getPoweredByView)({enabled:!i.is_whitelabel,id:"pushengage-campaign-alert-widget-powered-by",className:"pushengage-campaign-alert-widget__powered-by"})}\n \n \n `})({alert:e,alertType:t,site:i,variantId:a});(0,s.addContentAfterBody)(d),(()=>{const e="pushengage-campaign-alert-widget",t=`${e}-opt-in`,i=`${e}-bell`,s=document.getElementById(e),r=document.getElementById(`${e}-bell`),a=document.getElementById(`${e}-allow-button`),d=document.getElementById(`${e}-powered-by`),c=document.getElementById(t);if(!s||!c)return;const l="pushengage-opt-in__popover--opened",u=`${e}--alert-sent`;null==d||d.addEventListener("click",(()=>{window.open(o.poweredByReferralUrl,"_blank")})),null==a||a.addEventListener("click",(()=>{s.classList.add(u),setTimeout((()=>{c.classList.remove(l)}),3e3)})),null==r||r.addEventListener("click",(()=>{c.classList.contains(l)?c.classList.remove(l):(0,n.showPopoverView)({targetId:i,popoverId:t})}))})()}},2797:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.attachTooltipEventToBell=t.getBellPlacedBarView=void 0;const n=i(9340),o=i(3641),s=i(3425),r=i(1920);t.getBellPlacedBarView=({optIn:e,site:t})=>{const i="pe-bottom-left"===e.placement?"left":"right",o=`visibility: hidden;\n --bell-background-color: ${e.bg};\n --bell-color: ${e.allowBtnBg};\n --bell-height: 50px;\n --bell-width: 50px;\n --bell-right:30px;\n --bell-left:30px;\n --bell-bottom:50px;\n`,r=Array.isArray(e.optin_segments)&&e.optin_segments.length?"":`id="pushengage-opt-in-${e.optin_type}-allow"`;return`\n
\n \n
${n.bellIcon}
\n
\n ${(({optIn:e,site:t})=>{let i="";Array.isArray(e.optin_segments)&&e.optin_segments.length&&(i=`\n \n ${e.optin_allow_btn_txt}\n \n `);const n=`--checkbox-checked-tick-color: ${e.checkbox_tick_color};\n --checkbox-unchecked--color: ${e.checkbox_bg};\n --checkbox-checked-background-color: #ffffff;\n `,o=(0,s.getPoweredByView)({enabled:!t.is_whitelabel,className:"pushengage-opt-in__bell__tooltip__powered-by",id:`pushengage-opt-in-${e.optin_type}-powered-by`});return`\n \n
${e.optin_title}
\n ${(0,s.getOptInSegmentView)({optIn:e,getCheckboxBodyStyle:e=>"margin-top:"+(e>=1?"8px":"0px"),className:"pushengage-opt-in__bell__tooltip__segments"})}\n ${i} ${o}\n \n `})({optIn:e,site:t})}\n \n `},t.attachTooltipEventToBell=({optIn:e,site:t})=>{const i=`pushengage-opt-in-${e.optin_type}-bell`,n=`pushengage-opt-in-${e.optin_type}-tooltip`,a=Array.isArray(e.optin_segments)&&e.optin_segments.length||!t.is_whitelabel,d=(0,o.getElementById)(i),c=(0,o.getElementById)(n);if(!d||!c)return;const l=(0,r.detectDeviceType)(),u="pushengage-opt-in__tooltip--opened";if("desktop"===l){let e=!1,t=!1;d.addEventListener("mouseover",(()=>{t=!0,(0,s.showTooltipView)({tooltipId:n,targetId:i})})),d.addEventListener("mouseleave",(()=>{t=!1,setTimeout((()=>{e||c.classList.remove(u)}),500)})),a&&(d.addEventListener("click",(()=>{c.classList.contains(u)?c.classList.remove(u):(0,s.showTooltipView)({tooltipId:n,targetId:i})})),c.addEventListener("mouseover",(()=>{e=!0})),c.addEventListener("mouseleave",(()=>{setTimeout((()=>{e=!1,t||c.classList.remove(u)}),300)})))}else d.addEventListener("click",(()=>{c.classList.contains(u)?c.classList.remove(u):((0,s.showTooltipView)({tooltipId:n,targetId:i}),a||setTimeout((()=>{c.classList.remove(u)}),1e3))}),{passive:!0})}},3468:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getFloatingBarView=void 0;const n=i(1920),o=i(3609),s=i(3425),r=i(9340);t.getFloatingBarView=({optIn:e,site:t})=>{const i=(0,o.getColorTheme)(e.bg);let a=(0,n.detectDeviceType)();window.innerWidth<=650&&(a="mobile");const d=`pushengage-opt-in__floating-bar pushengage-opt-in__floating-bar--${e.placement} pushengage-opt-in__floating-bar--${a} pushengage-opt-in__floating-bar--${i}`,c="#ffffff"===e.closeBtnBg?"1px solid #d8d8d8":`1px solid ${e.closeBtnBg}`,l=`visibility: hidden;\n --opt-in-background-color: ${e.bg};\n --allow-btn-background-color: ${e.allowBtnBg};\n --close-btn-background-color: ${e.closeBtnBg};\n --close-btn-border: ${c};\n --opt-in-icon-url: url('${t.site_image}');\n --checkbox-checked-tick-color: ${e.checkbox_tick_color};\n --checkbox-unchecked--color: ${e.checkbox_bg};\n --checkbox-checked-background-color: ${e.bg};\n --opt-in-width: 100%;\n`;return`\n \n ${"desktop"===a?`\n
\n ${t.site_image?'
\n
\n
':`\n ${r.bellIcon}\n
`}\n\n
\n
${e.optin_title}
\n\n ${(0,s.getOptInSegmentView)({optIn:e,getCheckboxBodyStyle:()=>"margin: 14px 17px 0 0",className:"pushengage-opt-in__floating-bar__segments"})}\n
\n \n\n
\n \n ${e.optin_allow_btn_txt}\n
\n \n ${e.optin_close_btn_txt}\n \n \n `:`\n
\n ${t.site_image?'
\n
\n
':`\n ${r.bellIcon}\n
`}\n\n
${e.optin_title}
\n \n\n ${(0,s.getOptInSegmentView)({optIn:e,getCheckboxBodyStyle:e=>"margin-top:"+(e>=2?"10px":"0px"),className:"pushengage-opt-in__floating-bar__segments"})}\n\n
\n \n ${e.optin_allow_btn_txt}\n
\n \n ${e.optin_close_btn_txt}\n \n \n `}\n ${(0,s.getPoweredByView)({enabled:!t.is_whitelabel,className:"pushengage-opt-in__floating-bar__powered-by",id:`pushengage-opt-in-${e.optin_type}-powered-by`})}\n \n `}},6001:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getLargeSafariStyleView=void 0;const n=i(1920),o=i(3609),s=i(3425),r=i(9340);t.getLargeSafariStyleView=({optIn:e,site:t})=>{const i=(0,n.detectDeviceType)(),a=`pushengage-opt-in__large-safari-style pushengage-opt-in__large-safari-style--${i} pushengage-opt-in__large-safari-style--${(0,o.getColorTheme)(e.bg)}`;let d;d="desktop"===i&&window.innerWidth>390?"390px":"mobile"===i&&window.innerWidth>360?"360px":`${window.innerWidth}px`;const c="#ffffff"===e.closeBtnBg?"1px solid #d8d8d8":`1px solid ${e.closeBtnBg}`,l=e.checkbox_tick_color===e.bg?e.checkbox_bg:e.checkbox_tick_color,u=`visibility: hidden;\n --opt-in-width: ${d};\n --opt-in-background-color: ${e.bg};\n --allow-btn-background-color: ${e.allowBtnBg};\n --close-btn-background-color: ${e.closeBtnBg};\n --close-btn-border: ${c};\n --opt-in-icon-url: url('${t.site_image}');\n --checkbox-checked-tick-color: ${l};\n --checkbox-unchecked--color: ${e.checkbox_bg};\n --checkbox-checked-background-color: ${e.bg};\n`;return`\n \n
\n ${t.site_image?'
\n
\n
':`\n ${r.bellIcon}\n
`}\n\n
${e.optin_title}
\n \n\n ${(0,s.getOptInSegmentView)({optIn:e,getCheckboxBodyStyle:e=>"margin-top:"+(e>=2?"10px":"0px"),className:"pushengage-opt-in__large-safari-style__segments"})}\n\n
\n \n ${e.optin_allow_btn_txt}\n
\n \n ${e.optin_close_btn_txt}\n \n \n\n ${(0,s.getPoweredByView)({enabled:!t.is_whitelabel,className:"pushengage-opt-in__large-safari-style__powered-by",id:`pushengage-opt-in-${e.optin_type}-powered-by`})}\n \n `}},7535:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getSafariStyleView=void 0;const n=i(3609),o=i(3425),s=i(9340);t.getSafariStyleView=({optIn:e,site:t})=>{const i=(0,n.getColorTheme)(e.bg),r=`pushengage-opt-in__safari-style pushengage-opt-in__safari-style--${e.placement} pushengage-opt-in__safari-style--${i}`,a="#ffffff"===e.closeBtnBg?"1px solid #d8d8d8":`1px solid ${e.closeBtnBg}`,d=`visibility: hidden;\n --opt-in-width: ${window.innerWidth>370?370:window.innerWidth}px;\n --opt-in-background-color: ${e.bg};\n --allow-btn-background-color: ${e.allowBtnBg};\n --close-btn-background-color: ${e.closeBtnBg};\n --close-btn-border: ${a};\n --opt-in-icon-url: url('${t.site_image}');\n --checkbox-checked-tick-color: ${e.checkbox_tick_color};\n --checkbox-unchecked--color: ${e.checkbox_bg};\n --checkbox-checked-background-color: ${e.bg};\n`;return`\n \n
\n ${t.site_image?'
\n
\n
':`\n ${s.bellIcon}\n
`}\n\n
${e.optin_title}
\n \n\n ${(0,o.getOptInSegmentView)({optIn:e,getCheckboxBodyStyle:e=>"margin-top:"+(e>=2?"10px":"0px"),className:"pushengage-opt-in__safari-style__segments"})}\n\n
\n \n ${e.optin_allow_btn_txt}\n
\n \n ${e.optin_close_btn_txt}\n \n \n\n ${(0,o.getPoweredByView)({enabled:!t.is_whitelabel,className:"pushengage-opt-in__safari-style__powered-by",id:`pushengage-opt-in-${e.optin_type}-powered-by`})}\n \n `}},9107:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getSleekOptInBox=void 0;const n=i(9340),o=i(3609),s=i(3425);t.getSleekOptInBox=({optIn:e,site:t})=>{const i=(0,o.getColorTheme)(e.bg),r=`pushengage-opt-in__sleek-opt-in-box pushengage-opt-in__sleek-opt-in-box--${e.placement} pushengage-opt-in__sleek-opt-in-box--${i}`,a=`visibility: hidden;\n --opt-in-width: ${window.innerWidth>370?370:window.innerWidth}px;\n --opt-in-background-color: ${e.bg};\n --allow-btn-background-color: ${e.allowBtnBg};\n --close-btn-background-color: ${e.closeBtnBg};\n --opt-in-icon-url: url('${t.site_image}');\n --checkbox-checked-tick-color: ${e.checkbox_tick_color};\n --checkbox-unchecked--color: ${e.checkbox_bg};\n --checkbox-checked-background-color: ${e.bg};\n`;return`\n \n
\n
\n
\n
${n.bellIcon}
\n
${e.site_name}
\n
\n \n ${n.closeIcon}\n
\n
\n\n
\n
${e.optin_title}
\n ${t.site_image?'
\n
\n
':`\n ${n.bellIcon}\n
`}\n \n\n ${(0,s.getOptInSegmentView)({optIn:e,getCheckboxBodyStyle:e=>"margin-top:"+(e>=2?"10px":"0px"),className:"pushengage-opt-in__sleek-opt-in-box__segments"})}\n\n
\n \n ${e.optin_allow_btn_txt}\n
\n \n\n ${(0,s.getPoweredByView)({enabled:!t.is_whitelabel,className:"pushengage-opt-in__sleek-opt-in-box__powered-by",id:`pushengage-opt-in-${e.optin_type}-powered-by`})}\n \n \n `}},7888:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addOptInViewToPage=void 0;const n=i(7535),o=i(6001),s=i(3468),r=i(9107),a=i(2797),d=i(9340),c=i(3641),l=i(1920);t.addOptInViewToPage=({optIn:e,site:t})=>{let i;switch(e.optin_type){case d.optInTypes.safari:i=(0,n.getSafariStyleView)({optIn:e,site:t});break;case d.optInTypes.floatingBar:i=(0,s.getFloatingBarView)({optIn:e,site:t});break;case d.optInTypes.bell:i=(0,a.getBellPlacedBarView)({optIn:e,site:t});break;case d.optInTypes.singleStep:i=(0,a.getBellPlacedBarView)({site:t,optIn:Object.assign(e,e.bell)});break;case d.optInTypes.largeSafari:case d.optInTypes.largeSafariWithSegments:i=(0,o.getLargeSafariStyleView)({optIn:e,site:t});break;case d.optInTypes.sleekOptInBox:i=(0,r.getSleekOptInBox)({optIn:e,site:t})}if(i&&(0,c.addContentAfterBody)(i),e.optin_type!==d.optInTypes.bell&&e.optin_type!==d.optInTypes.singleStep||(0,a.attachTooltipEventToBell)({optIn:e,site:t}),"mobile"===(0,l.detectDeviceType)()&&(e.optin_type===d.optInTypes.largeSafari||e.optin_type===d.optInTypes.largeSafariWithSegments)){const t=document.getElementById(`pushengage-opt-in-${e.optin_type}`);if(t){const{offsetWidth:e,offsetHeight:i}=t,n=(window.innerWidth-e)/2,o=(window.innerHeight-i)/2;n>0?t.style.left=`${n}px`:(t.style.left="0",t.style.right="0"),o>0?t.style.top=`${o}px`:(t.style.top="0",t.style.bottom="0")}}}},7913:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addResetNotificationPermissionPopupViewToPage=void 0;const n=i(3609),o=i(1920),s=i(3641),r=i(3425),a=i(9340);t.addResetNotificationPermissionPopupViewToPage=e=>{const t=(e=>{const t=(0,n.getColorTheme)(e.background_color),{name:i}=(0,o.detectBrowser)(),d=(0,o.detectDeviceType)(),c="#ffffff"===e.close_button_background_color?"1px solid #d8d8d8":`1px solid ${e.close_button_background_color}`,l=`visibility: hidden;\n --popup-width: ${window.innerWidth>620?580:window.innerWidth-20}px;\n --popup-background-color: ${e.background_color};\n --retry-btn-background-color: ${e.retry_button_background_color};\n --close-btn-background-color: ${e.close_button_background_color};\n --close-btn-border: ${c};\n --instruction-url: url('${(({variants:e,deviceType:t,browserName:i})=>{const n=e.find((e=>e.platform===`${t}-${i.toLowerCase()}`));if(!n){const i=e.find((e=>e.platform===`${t}-chrome`));return null==i?void 0:i.url}return n.url})({deviceType:d,browserName:i,variants:e.variants})}');\n `;return`\n
\n ${(({message:e,variants:t,deviceType:i,browserName:n})=>{const o=t.find((e=>e.platform===`${i}-${n.toLowerCase()}`));let r=e;return(null==o?void 0:o.message)&&(r=(0,s.richEditorHasNoValue)(o.message)?e:o.message),r})({deviceType:d,browserName:i,message:e.message,variants:e.variants})}\n
\n\n
\n
\n
\n\n
\n \n ${a.loadingIcon}\n ${e.retry_button_label}\n
\n \n ${e.close_button_label}\n \n \n `})(e);(0,s.addContentAfterBody)(t)}},9288:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addSubscriberRecoveryBellWidgetToPage=t.addSubscriberRecoveryButtonWidgetToPage=void 0;const n=i(3425),o=i(3641),s=i(9340),r=i(3609),a=i(1920);t.addSubscriberRecoveryButtonWidgetToPage=({widget:e,site:t})=>{const i=(({widget:e,site:t})=>{const i=(0,r.getColorTheme)(e.bg),o=(0,a.detectDeviceType)(),d="desktop"===o?e.desktop_position:e.mobile_position,c="desktop"===o?e.desktop_placement:e.mobile_placement,l=`visibility: hidden;\n --widget-background-color: ${e.bg};\n --widget-color: ${e.color};`;return`\n \n
\n
${s.bellIcon}
\n \n ${e.label}\n
\n\n ${(0,n.getPoweredByView)({enabled:!t.is_whitelabel,id:"pushengage-subscriber-recovery-widget-powered-by",className:"pushengage-subscriber-recovery-widget__powered-by"})}\n \n\n \n ${s.closeIcon}\n \n \n `})({widget:e,site:t});(0,o.addContentAfterBody)(i),(()=>{const e="pushengage-subscriber-recovery-widget",t=(0,o.getElementById)(e),i=(0,o.getElementById)(`${e}-powered-by`);t&&t.style.setProperty("--widget-width",`${t.offsetWidth}px`),null==i||i.addEventListener("click",(()=>{window.open(s.poweredByReferralUrl,"_blank")}))})()},t.addSubscriberRecoveryBellWidgetToPage=({widget:e,site:t})=>{const i=(({widget:e,site:t})=>{const i="bl"===e.position?"left":"right",o=`visibility: hidden;\n --bell-background-color: ${e.bg};\n --bell-color: ${e.color};\n --bell-height: 50px;\n --bell-width: 50px;\n --bell-right:30px;\n --bell-left:30px;\n --bell-bottom:50px;\n`;return`\n \n \n
${s.bellIcon}
\n \n\n \n
${e.label}
\n\n ${(0,n.getPoweredByView)({enabled:!t.is_whitelabel,id:"pushengage-subscriber-recovery-widget-powered-by",className:"pushengage-subscriber-recovery-widget__tooltip__powered-by"})}\n \n \n `})({widget:e,site:t});(0,o.addContentAfterBody)(i),(e=>{const t="pushengage-subscriber-recovery-widget",i=`${t}-bell`,r=`${t}-tooltip`,d=(0,o.getElementById)(i),c=(0,o.getElementById)(r),l=(0,o.getElementById)(t),u=(0,o.getElementById)(`${t}-powered-by`);if(!d||!c||!l)return;const g=(0,a.detectDeviceType)(),p="pushengage-opt-in__tooltip--opened",b=!e.is_whitelabel;if("desktop"===g){let e=!1,t=!1;d.addEventListener("mouseover",(()=>{t=!0,(0,n.showTooltipView)({targetId:i,tooltipId:r})})),d.addEventListener("mouseleave",(()=>{t=!1,setTimeout((()=>{e||c.classList.remove(p)}),500)})),b&&(c.addEventListener("mouseleave",(()=>{setTimeout((()=>{e=!1,t||c.classList.remove(p)}),300)})),c.addEventListener("mouseover",(()=>{e=!0})))}else d.addEventListener("click",(()=>{(0,n.showTooltipView)({targetId:i,tooltipId:r}),b||setTimeout((()=>{c.classList.remove(p)}),1e3)}));null==u||u.addEventListener("click",(()=>{window.open(s.poweredByReferralUrl,"_blank")}))})(t)}},6086:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.refreshSubscriptionManagementWidgetView=void 0;const o=i(3641),s=i(3609),r=i(9340),a=i(3425),d=i(1920),c=i(4014),l=n(i(4182)),u=i(9851);t.refreshSubscriptionManagementWidgetView=({widgetId:e,notificationPermission:t,subscriberData:i,initFrom:n})=>{const g=(0,u.getAppData)(),p=g.siteSettings.subscription_management_widget;if(!p)return;let b=p;"api"===n&&(b=(0,c.omit)(p,["trigger_button"]));const f=`${e}-opt-in`,m="pushengage-opt-in__popover--opened",v=(0,o.getElementById)(e),_=(({widget:e,notificationPermission:t,subscriberData:i,site:n,widgetId:o})=>{var d,l,u,g,p,b,f,m,v,_,h,y,w;const S=(0,s.getColorTheme)(e.modal_background_color),I="trigger_button"in e?e.trigger_button:void 0,P=(null==I?void 0:I.z_index)||2147483640;let O=46,E=48;if(null==I?void 0:I.size)switch(I.size){case"small":O=36,E=38;break;case"large":O=56,E=58;break;default:O=46,E=48}const k=`\n --bell-background-color: ${null==I?void 0:I.icon_background_color};\n --bell-color: ${null==I?void 0:I.icon_color};\n --bell-bottom: ${Math.min((null==I?void 0:I.offset_bottom)||0,window.innerHeight-O)}px;\n --bell-top: ${Math.min((null==I?void 0:I.offset_top)||0,window.innerHeight-O)}px;\n --z-index: ${P};\n --bell-height: ${O}px;\n --bell-width: ${E}px;\n`,A=`\n --popover-background-color: ${e.modal_background_color};\n --popover-color: ${e.modal_text_color};\n --opt-in-close-icon-color: ${e.modal_text_color};\n --switch-checked-background-color: ${e.on_switch_color};\n --switch-unchecked-background-color:${e.off_switch_color};\n --z-index: ${P+1};\n`,D="#ffffff"===(null===(d=e.unsubscribe_options)||void 0===d?void 0:d.cancel_button_background_color)?"1px solid #d8d8d8":`1px solid ${null===(l=e.unsubscribe_options)||void 0===l?void 0:l.cancel_button_background_color}`,T=`\n --popover-background-color: ${e.modal_background_color};\n --popover-color: ${e.modal_text_color};\n --allow-btn-background-color: ${null===(u=e.unsubscribe_options)||void 0===u?void 0:u.ok_button_background_color};\n --close-btn-background-color: ${null===(g=e.unsubscribe_options)||void 0===g?void 0:g.cancel_button_background_color};\n --allow-btn-color: ${null===(p=e.unsubscribe_options)||void 0===p?void 0:p.ok_button_text_color};\n --close-btn-color: ${null===(b=e.unsubscribe_options)||void 0===b?void 0:b.cancel_button_text_color};\n --close-btn-border: ${D};\n --z-index: ${P+2};\n`,N=I?"":"pushengage-subscription-management-widget__opt-in--center pushengage-opt-in__popover--opened",R=(null==i?void 0:i.segments)||[],$=(null===(f=e.segment_preference)||void 0===f?void 0:f.exclude_subscribed_segments)||[],x=(null===(m=e.segment_preference)||void 0===m?void 0:m.segments)||[];let C="";if(null===(v=e.segment_preference)||void 0===v?void 0:v.enabled){const i="#ecebee"===e.segment_preference.checkbox_background_color&&"#ffffff"===e.modal_background_color?"#ACB7C8":e.segment_preference.checkbox_background_color,n=`\n --checkbox-checked-tick-color: ${e.segment_preference.checkbox_tick_color};\n --checkbox-unchecked--color: ${i};\n --checkbox-checked-background-color: ${e.modal_background_color};\n `;let s="";if(Array.isArray(R)&&R.length){const t=R.filter((t=>!($.includes(t)||!e.segment_preference.show_all_subscribed_segment&&!x.includes(t)))),i=1==t.length?"flex-basis: 100%;":"";t.forEach(((e,t)=>{s+=`\n =2?"7px":"0px")}"\n >\n \n