var e,t;!function(e){e.CHROME="chrome",e.FIREFOX="firefox",e.SAFARI="safari",e.OTHER="other"}(e||(e={})),function(e){e.ONE_STEP="oneStep",e.TWO_STEP="twoStep",e.OFF="off"}(t||(t={}));var i,n,o,r,s,a;!function(e){e.CUSTOM_BUTTONS="custom-buttons",e.FLYOUT_WIDGET="flyout-widget",e.PARTNER_JS_API="partner-js-api"}(i||(i={})),function(e){e.NOT_SHOPIFY="not_shopify",e.STORAGE_NOT_DEFINED="storage_not_defined",e.LOCALSTORAGE_NOT_AVAILABLE="localstorage_not_available",e.IN_COMAPTIBLE_BROWSER="incompatible_browser",e.NO_SERVICE_WORKER="no_service_worker",e.NO_SUBDOMAIN="no_subdomain",e.OLD_IOS_DEVICE="old_ios_device",e.MICROSOFT_EDGE="microsoft_edge",e.NOT_ADDED_TO_HOME_SCREEN="not_added_to_home_screen",e.INCOGNITO="incognito",e.NOTIFICATION_NOT_DEFINED="notification_not_defined",e.NO_FILE_SYSTEM="no_file_system",e.DISABLED_RESYNC="disable_resync"}(n||(n={})),function(e){e.NO_SUBSCRIBER_TOKEN="no_subsriber_token",e.INVALID_SUBSCRIBER_TOKEN="invalid_subscriber_token",e.PERMISSION_DENIED="permission_denied",e.PERMISSION_NOT_GRANTED="permission_not_granted",e.INVALID_STATE_ERROR="InvalidStateError",e.UNKNOWN_EVENT="unknown_event"}(o||(o={})),function(e){e.BACK_IN_STOCK="back_in_stock",e.PRICE_DROP="price_drop"}(r||(r={})),function(e){e.SILENT="silent",e.DEBUG="debug"}(s||(s={})),function(e){e.CART_DELETED="cart_deleted",e.CART_UPDATED="cart_updated",e.PRODUCT_VIEWED="product_viewed"}(a||(a={}));const c=[{name:"track"},{name:"identify"},{name:"trackLink"},{name:"page"},{name:"viewProduct",isEcommerce:!0},{name:"viewCategory",isEcommerce:!0},{name:"search",isEcommerce:!0}],u=Object.prototype.toString,d=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Load failed","Network request failed","fetch failed","terminated"]);function l(e){var t;return!(!e||(t=e,"[object Error]"!==u.call(t))||"TypeError"!==e.name||"string"!=typeof e.message)&&("Load failed"===e.message?void 0===e.stack:d.has(e.message))}function p(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}function h(e){return new Promise((function(t,i){e.oncomplete=e.onsuccess=function(){return t(e.result)},e.onabort=e.onerror=function(){return i(e.error)}}))}var b;function w(){return b||(b=function(e,t){var i=indexedDB.open(e);i.onupgradeneeded=function(){return i.result.createObjectStore(t)};var n=h(i);return function(e,i){return n.then((function(n){return i(n.transaction(t,e).objectStore(t))}))}}("keyval-store","keyval")),b}const m={WIDGET_CONFIG_KEY:{HOME:"home",PRICE_DROP:"price_drop",BACK_IN_STOCK:"back_in_stock"},EVENT_API_PATH:{PRICE_DROP:"price-drop",BACK_IN_STOCK:"back-in-stock"},ENVIRONMENT:{staging:"staging",production:"production"},STORAGE_KEYS:{NETWORK_REQUEST_QUEUE:"pushowl_network_request_queue",VISITOR_TOKEN:"pushowl_visitor_token",SESSION_TOKEN:"pushowl_session_token",SUBSCRIBER_TOKEN:"pushowl_subscriber_token",SUBSCRIPTION:"pushowl_subscription",SW_SUBSCRIPTION:"pushowl_sw_subscription",SW_SUBSCRIBER_TOKEN:"pushowl_sw_subscriber_token",EMAIL:"pushowl_email",BACK_IN_STOCK_SUBSCRIPTIONS:"pushowl_back_in_stock_subscriptions",PRICE_DROP_SUBSCRIPTIONS:"pushowl_price_drop_subscriptions",SYNCED_CART_JSON:"pushowl_synced_cart_json",SYNCED_CUSTOMER_ID:"pushowl_synced_customer_id",SYNCED_AC_EVENTS:"pushowl_ac_events",SESSION_PAGEVIEW_COUNT:"pushowl_session_pageview_count",SESSION_SUBSCRIBER_CHECK:"pushowl_session_subscriber_check",OPTIN_DEFERRED_UNTIL:"pushowl_optin_deferred_until",LOG_LEVEL:"pushowl_log_level",HAS_RAISED_UNSUBSCRIPTION_EVENT:"pushowl_has_raised_unsubscription_event",IS_PERMISSION_GRANTED:"pushowl_is_permission_granted",REFERRER:"pushowl_referrer",LANDING_PAGE_URL:"pushowl_landing_page_url",LANDING_PAGE_URL_PARAMS:"pushowl_landing_page_url_params",ORIGINAL_URL_PARAMS:"pushowl_original_url_params",IOS_STANDALONE_MODE_LOG:"pushowl_ios_standalone_mode_log",INSTALL_PROMPT_SEEN_COUNT:"pushowl_install_prompt_seen_count",INSTALL_PROMPT_DISMISSED:"pushowl_install_prompt_dismissed",CONSENT:"pushowl_channels_consent",PUSHOWL_SUBDOMAIN:"pushowl_subdomain",PUSHOWL_ENVIRONMENT:"pushowl_environment",CURRENT_CONFIG_KEY:"pushowl_current_config_key"},NOTIFICATION_PERMISSION:{DEFAULT:"default",GRANTED:"granted",DENIED:"denied",DISMISSED:"dismissed",SERVICE_WORKER_FAILURE:"service_worker_failure"},DEFAULT_TIMEOUT:{DEFAULT:0,MOBILE:10}},g={EVENTS:{CLICK:"click",ANIMATION_END:"animationend",TRANSITION_END:"transitionend"},WIDGET_CLASSES:{MINIMIZE:"minimize",MAXIMIZE:"maximize"}},_={[m.ENVIRONMENT.staging]:"https://api-staging.pushowl.com",[m.ENVIRONMENT.production]:"https://api.pushowl.com"},f={[m.ENVIRONMENT.staging]:"https://cdn-staging.pushowl.com/config",[m.ENVIRONMENT.production]:"https://cdn.pushowl.com/config"},S={[m.ENVIRONMENT.staging]:"web.com.pushowl.staging",[m.ENVIRONMENT.production]:"web.com.pushowl.prod"},v={HOME:"home",COLLECTION:"collection",PRODUCT:"product",CART:"cart",CHECKOUT:"checkout",ORDER:"order",ORDERS:"orders",THANK_YOU:"thank_you"},E={CART:"cart",ACCOUNT:"account",ORDERS:"orders"},I="subscribe",y="unsubscribe",O="debug",T="disabled",P="browser-prompt",N="custom-prompt",R="optin-flyout",C="price-drop-flyout",k="back-in-stock-flyout",A="wordpress",D="prestashop";class U{constructor(e){this.key=e,window.localStorage.getItem(e)?this.subscriptions=window.localStorage.getItem(this.key).split(","):this.subscriptions=[]}subscribe(e){this.isSubscribed(e)||(this.subscriptions.push(e.id.toString()),window.localStorage[this.key]=this.subscriptions)}isSubscribed(e){return this.subscriptions.indexOf(e.id.toString())>-1}}class L{constructor(){this.back_in_stock=new U(m.STORAGE_KEYS.BACK_IN_STOCK_SUBSCRIPTIONS),this.price_drop=new U(m.STORAGE_KEYS.PRICE_DROP_SUBSCRIPTIONS),Promise.all([X.get(m.STORAGE_KEYS.SW_SUBSCRIPTION),X.get(m.STORAGE_KEYS.SW_SUBSCRIBER_TOKEN)]).then((e=>{var[t,i]=e;t&&i&&(this.sw_subscription_data=t,this.sw_subscriber_token=i)})).catch((e=>{be("Error while fetching subscription data",e)}))}static getOrCreateToken(e,t){var i=e.getItem(t);if(i)return i;var n=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)},o="".concat(n()+n(),"-").concat(n(),"-4").concat(n().substr(0,3),"-").concat(n(),"-").concat(n()).concat(n()).concat(n()).toLowerCase();return e.setItem(t,o),o}static get queue(){try{var e=localStorage.getItem(m.STORAGE_KEYS.NETWORK_REQUEST_QUEUE);return e?JSON.parse(e):[]}catch(e){return[]}}static set queue(e){e?localStorage.setItem(m.STORAGE_KEYS.NETWORK_REQUEST_QUEUE,JSON.stringify(e)):localStorage.removeItem(m.STORAGE_KEYS.NETWORK_REQUEST_QUEUE)}static get email(){return localStorage.getItem(m.STORAGE_KEYS.EMAIL)}static set email(e){localStorage.setItem(m.STORAGE_KEYS.EMAIL,e)}static set pushowlEnvironment(e){localStorage.setItem(m.STORAGE_KEYS.PUSHOWL_ENVIRONMENT,e)}static get consent(){var e=localStorage.getItem(m.STORAGE_KEYS.CONSENT);if(e)try{return JSON.parse(e)}catch(e){return[]}return[]}static set consent(e){localStorage.setItem(m.STORAGE_KEYS.CONSENT,JSON.stringify(e))}static get subscriberToken(){return this.sw_subscriber_token||localStorage.getItem(m.STORAGE_KEYS.SUBSCRIBER_TOKEN)}static set subscriberToken(e){e?(localStorage.setItem(m.STORAGE_KEYS.SUBSCRIBER_TOKEN,e),X.set(m.STORAGE_KEYS.SUBSCRIBER_TOKEN,e)):(localStorage.removeItem(m.STORAGE_KEYS.SUBSCRIBER_TOKEN),X.del(m.STORAGE_KEYS.SUBSCRIBER_TOKEN))}static get installPromptDismissed(){return Boolean(localStorage.getItem(m.STORAGE_KEYS.INSTALL_PROMPT_DISMISSED))}static set installPromptDismissed(e){localStorage.setItem(m.STORAGE_KEYS.INSTALL_PROMPT_DISMISSED,"".concat(e))}static get hasLoggediOSStandaloneMode(){return localStorage.getItem(m.STORAGE_KEYS.IOS_STANDALONE_MODE_LOG)}static set hasLoggediOSStandaloneMode(e){localStorage.setItem(m.STORAGE_KEYS.IOS_STANDALONE_MODE_LOG,e)}static get originalURLParams(){return localStorage.getItem(m.STORAGE_KEYS.ORIGINAL_URL_PARAMS)}static set originalURLParams(e){localStorage.setItem(m.STORAGE_KEYS.ORIGINAL_URL_PARAMS,e)}static get visitorToken(){return W()?this.getOrCreateToken(localStorage,m.STORAGE_KEYS.VISITOR_TOKEN):(localStorage.removeItem(m.STORAGE_KEYS.VISITOR_TOKEN),null)}static get sessionToken(){return this.getOrCreateToken(sessionStorage,m.STORAGE_KEYS.SESSION_TOKEN)}static get syncedCustomerId(){return localStorage.getItem(m.STORAGE_KEYS.SYNCED_CUSTOMER_ID)}static set syncedCustomerId(e){localStorage.setItem(m.STORAGE_KEYS.SYNCED_CUSTOMER_ID,e.toString())}static get synced_cart_json(){var e=localStorage.getItem(m.STORAGE_KEYS.SYNCED_CART_JSON);return e?JSON.parse(e):void 0}static set synced_cart_json(e){e&&("[object String]"!==Object.prototype.toString.call(e)&&(e=JSON.stringify(e)),localStorage.setItem(m.STORAGE_KEYS.SYNCED_CART_JSON,e))}static get ac_events(){try{return JSON.parse(localStorage.getItem(m.STORAGE_KEYS.SYNCED_AC_EVENTS))||[]}catch(e){return[]}}static set ac_events(e){var t="string"==typeof e?e:JSON.stringify(e);localStorage.setItem(m.STORAGE_KEYS.SYNCED_AC_EVENTS,t)}static get subscription(){var e=this.sw_subscription_data||localStorage.getItem(m.STORAGE_KEYS.SUBSCRIPTION),t=null;if(e)try{t=JSON.parse(e)}catch(i){t=e}return t}static set subscription(e){var t="string"==typeof e?e:JSON.stringify(e);localStorage.setItem(m.STORAGE_KEYS.SUBSCRIPTION,t),X.set(m.STORAGE_KEYS.SW_SUBSCRIPTION,t)}static get optinDeferredUntil(){return parseInt(localStorage.getItem(m.STORAGE_KEYS.OPTIN_DEFERRED_UNTIL)||0,10)}static set optinDeferredUntil(e){null===e?localStorage.removeItem(m.STORAGE_KEYS.OPTIN_DEFERRED_UNTIL):localStorage.setItem(m.STORAGE_KEYS.OPTIN_DEFERRED_UNTIL,e)}static get logLevel(){return localStorage.getItem(m.STORAGE_KEYS.LOG_LEVEL)}static set logLevel(e){localStorage.setItem(m.STORAGE_KEYS.LOG_LEVEL,e)}static get hasRaisedUnsubscriptionEvent(){return localStorage.getItem(m.STORAGE_KEYS.HAS_RAISED_UNSUBSCRIPTION_EVENT)}static set hasRaisedUnsubscriptionEvent(e){localStorage.setItem(m.STORAGE_KEYS.HAS_RAISED_UNSUBSCRIPTION_EVENT,e)}static get isPermissionGranted(){return"true"===localStorage.getItem(m.STORAGE_KEYS.IS_PERMISSION_GRANTED)}static set isPermissionGranted(e){e?localStorage.setItem(m.STORAGE_KEYS.IS_PERMISSION_GRANTED,e):localStorage.removeItem(m.STORAGE_KEYS.IS_PERMISSION_GRANTED)}static handlePostSubscription(e,t){L.subscription=e,L.subscriberToken=t,L.hasRaisedUnsubscriptionEvent=""}}const B=()=>{const e=new Error("network error");return e.name="TypeError",e},x=({path:e,method:t,appendPlatform:i=!0,url:n=null,payload:o=null,contentType:r="application/json",acceptType:s="application/json",retryCount:a=null})=>p(void 0,void 0,void 0,(function*(){const c=n?new URL(n):new URL(`${(()=>{const{subdomain:e}=Y;return`${Y.apiEndpoint}/api/v1/${e}`})()}${e}`);return i&&c.searchParams.append("platform",Y.platform),a&&c.searchParams.append("retry_count",`${a}`),new Promise(((e,i)=>{let n=new XMLHttpRequest;n.open(t,c.href,!0),n.setRequestHeader("Content-Type",r),n.setRequestHeader("Accept",s),o?n.send(r.match(/json/)?JSON.stringify(o):o):n.send(),n.onload=function(){let t=n.responseText;if(429===n.status&&i(B()),n.status>=200&&n.status<400){const i=s.match(/json/)?JSON.parse(t):t;e(i)}else i(t)},n.onerror=function(){i(B())},n.onabort=function(){i("Request Aborted")}}))}));class G{static run(){(L.queue||[]).forEach((e=>{setTimeout((()=>{this._request(e)}),1e3*e.retryCount)}))}static _enqueue(e){let t=e;return void 0===e.id&&(t=Object.assign({id:ae()},e)),L.queue=[...L.queue.slice(0,5),t],t}static _retryRequest(e){return p(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},e),{retryCount:((null==e?void 0:e.retryCount)||0)+1});if(t.retryCount>5){return ge("APIRequestEventually",{request:t,connectionType:navigator.connection?navigator.connection.effectiveType:"NA"}),Promise.reject()}const i=this._enqueue(t);setTimeout((()=>{this._request(i)}),1e3*i.retryCount)}))}static _dequeue(e){L.queue=L.queue.filter((t=>t.id!==e.id))}static _request(e){return p(this,void 0,void 0,(function*(){try{this._dequeue(e);return yield x(e)}catch(t){return l(t)?this._retryRequest(e):(ge("APIRequestEventuallyError",{error:t,request:e}),Promise.reject(t))}}))}static get(e){const t=this._enqueue(e);return this._request(Object.assign(Object.assign({},t),{method:"GET"}))}static post(e){const t=this._enqueue(e);return this._request(Object.assign(Object.assign({},t),{method:"POST"}))}static put(e){const t=this._enqueue(e);return this._request(Object.assign(Object.assign({},t),{method:"PUT"}))}}class K{constructor(){this.configKey="pushowl_shopify_config-".concat(1.5,"-").concat(Y.guid),this.permissionKey="pushowl_permission_not_granted-".concat(1.5,"-").concat(Y.guid),this.subscriptionVerifiedKey="pushowl_subscription_verified-".concat(1.5,"-").concat(Y.guid),this.optinSeenCountKey="pushowl_optin_seen_count",window.sessionStorage.setItem(m.STORAGE_KEYS.CURRENT_CONFIG_KEY,this.configKey)}get config(){var e=window.sessionStorage.getItem(this.configKey),t=null;if(e)try{t=JSON.parse(e)}catch(e){t=null}return t}set config(e){var t="string"==typeof e?e:JSON.stringify(e);window.sessionStorage.setItem(this.configKey,t)}get isPermissionNotGranted(){return"true"===window.sessionStorage.getItem(this.permissionKey)}set isPermissionNotGranted(e){window.sessionStorage.setItem(this.permissionKey,e),window.localStorage.setItem(this.permissionKey,e)}get subscriptionVerified(){return!!window.sessionStorage.getItem(this.subscriptionVerifiedKey)}set subscriptionVerified(e){window.sessionStorage.setItem(this.subscriptionVerifiedKey,e)}get optinSeenCount(){return parseInt(window.sessionStorage.getItem(this.optinSeenCountKey)||0,10)}set optinSeenCount(e){window.sessionStorage.setItem(this.optinSeenCountKey,e)}static get installPromptSeenCount(){return parseInt(window.sessionStorage.getItem(m.STORAGE_KEYS.INSTALL_PROMPT_SEEN_COUNT)||0,10)}static set installPromptSeenCount(e){window.sessionStorage.setItem(m.STORAGE_KEYS.INSTALL_PROMPT_SEEN_COUNT,e)}static get landingPageURL(){return sessionStorage.getItem(m.STORAGE_KEYS.LANDING_PAGE_URL)}static set landingPageURL(e){sessionStorage.setItem(m.STORAGE_KEYS.LANDING_PAGE_URL,e)}static get referrer(){return sessionStorage.getItem(m.STORAGE_KEYS.REFERRER)}static set referrer(e){sessionStorage.setItem(m.STORAGE_KEYS.REFERRER,e)}static get landingPageURLParams(){return sessionStorage.getItem(m.STORAGE_KEYS.LANDING_PAGE_URL_PARAMS)}static set landingPageURLParams(e){sessionStorage.setItem(m.STORAGE_KEYS.LANDING_PAGE_URL_PARAMS,e)}static set windowVariablesForOwly(e){sessionStorage.setItem(m.STORAGE_KEYS.PUSHOWL_SUBDOMAIN,e)}}const j=e=>e.startsWith("https://")?e:e.replace("//cdn.shopify.com","https://cdn.shopify.com"),H=e=>"object"==typeof e&&null!==e&&"src"in e?j(e.src):"string"==typeof e?j(e):null;class M extends class{constructor(){}}{constructor(e){super(),this.id=e.id,this.name=e.name,this.price=e.price/100,this.available=e.available,this.featured_image=H(e.featured_image)}}class F extends class{constructor(){}currentVariant(){}}{constructor(e){super(),this.id=e.id,this.title=e.title,this.featured_image=H(e.featured_image),this.price=_e(e.price);const t=e.variants;this.variants=t.map((e=>new M(e)))}getVariant(e){return e=parseInt(e),this.variants.find((t=>t.id==e))}currentVariant(){const e=ne("variant");if(!e){for(const e of this.variants)if(e.available)return e;return this.variants[0]}return this.getVariant(e)}}const V=/checkouts\/c\/([^\/]*)\/thank_you/;class q extends class{constructor(){this.product=null}static get section(){return"home"}static get productAlias(){return"all"}static get customerId(){}static getCart(){}getProductDetails(e=!1,t){}getRawCurrentProductDetails(){}}{constructor(){super(),this.productCache={}}static get section(){try{let{pageType:e}=window.ShopifyAnalytics.meta.page;if(e)return e!==v.PRODUCT&&/\/products\/(\S)/.test(location.pathname)&&(e=v.PRODUCT),e}catch(e){}if(void 0!==window.Shopify&&window.Shopify.Checkout&&("thank_you"===window.Shopify.Checkout.page||"checkout_one_thank_you"===window.Shopify.Checkout.page))return v.THANK_YOU;const{hostname:e}=location,t=location.pathname,i=t.split("/")[0],n=t.split("/")[1];if(V.test(t))return v.THANK_YOU;if(""===i)return v.HOME;if(i===E.CART)return v.CART;if(i===E.ACCOUNT&&n===E.ORDERS)return v.ORDER;if("account"===i&&!i)return v.ORDERS;if("checkout.shopify.com"===e||"checkouts"===n||t.indexOf("checkouts")>=0)return v.CHECKOUT;if(void 0!==window.__st&&window.__st.s){const e=window.__st.s.split("-")[0];if("collections"===e)return v.COLLECTION;if("products"===e)return v.PRODUCT}}static get productAlias(){let e=location.pathname.split("/");e=e.filter((e=>e));const t=e.map((e=>e.toLocaleLowerCase())).lastIndexOf("products");return-1===t?"":e[t+1]}static get customerId(){if("headless"===Y.mode)return window.pushowl?window.pushowl.customerId:"";let e=null;return void 0!==window.__st&&window.__st.cid?e=window.__st.cid:void 0!==window.Shopify&&void 0!==window.Shopify.checkout&&window.Shopify.checkout.customer_id&&(e=window.Shopify.checkout.customer_id.toString()),e}static getCart(){return se({url:`/cart.js?random=${Date.now()}`}).then((e=>(e.updated_at=(new Date).toISOString(),e)),(()=>"Cart API failed"))}static get pageName(){const e=window.location.pathname.match(/\/pages\/([a-z0-9_-]+)$/);return e?e[1]:void 0}static get collectionName(){const e=window.location.pathname.match(/collections\/([a-z0-9_-]+)$/);return e?e[1]:void 0}static get collectionId(){return window.ShopifyAnalytics&&window.ShopifyAnalytics.meta&&window.ShopifyAnalytics.meta.page?window.ShopifyAnalytics.meta.page.resourceId:null}getProductDetails(e=!1,t){const i=t||q.productAlias;return this.productCache[i]&&!e?Promise.resolve(this.productCache[i]):se({url:`/products/${i}.js`}).then((e=>this.productCache[i]=new F(e)))}getRawCurrentProductDetails(){return Promise.resolve(window.ShopifyAnalytics.meta.product)}}class Y{static get scriptUrl(){let e=document.getElementsByTagName("script");for(let t=0;t{const t=((new K).config||{}).flags,i=Y.serviceWorkerUrl(t),n="enabled"===t.sw_get_request;fetch(i,{method:n?"GET":"HEAD"}).then((t=>{if(t.status>=200&&t.status<300)return e(!0);e(!1)}))}))}static get webPushId(){return S[this.environment]||S[m.ENVIRONMENT.production]}static getServiceWorkerUrlWithIntergrations(e,t={}){const i=Object.keys(t).filter((e=>"enabled"===t[e].status));if(!i.length)return e;return`${e}${new URL(e).search?"&":"?"}integrations=${i.join(",")}`}static logToServer({message:e,subdomain:t,sessionHash:i="session",data:n}){return G.post({url:`${Y.apiEndpoint}/logs/v1/`,acceptType:"text/plain",payload:[{level:"warn",subscriber_token:window.localStorage&&window.localStorage.getItem("pushowl_subscriber_token"),subdomain:t,message:e,session_hash:i,timestamp:(new Date).toISOString(),data:Object.assign({release:"3650a20"},n)}]})}static getPreviewLib(e){const t=Y.getPreviewBranch();return sessionStorage.setItem("pushowl_branch",t),"local"===t?`https://localhost:3008/latest/sdks/${e}?environment=staging&platform=${Y.platform}`:null}static loadPreviewLib(e){const t=document.createElement("script"),i=this.getPreviewLib(e);t.onload=()=>{},i&&(t.src=i,t.setAttribute("async",""),document.head.appendChild(t),window.pushowlPreviewLoaded=!0)}static getPreviewBranch(){const e=new URLSearchParams(window.location.search).get("pushowl_branch")||sessionStorage.getItem("pushowl_branch");return window.pushowlPreviewLoaded?null:e}static isDisabled(){const e=new URLSearchParams(window.location.search).get("poTaskType")||sessionStorage.getItem("poTaskType");sessionStorage.setItem("pushowl_task_type",e);return e===T}}const W=()=>"shopify"!==Y.platform||!Y.guid||!!window.Shopify.customerPrivacy&&window.Shopify.customerPrivacy.userCanBeTracked(),$=({eventName:e,eventData:t})=>{try{const i=new K;if("enabled"===i.config.flags.brevo_email&&window.sendinblue){const n={};i.config.privacy&&q.customerId&&(n.customerId=q.customerId),L.email&&(n.email=L.email),window.sendinblue.track(e,n,t)}}catch(e){be("Error in brevoTrack",e)}},J=()=>!!window.indexedDB;class X{static set(e,t){return p(this,void 0,void 0,(function*(){if(J())try{!function(e,t){(arguments.length>2&&void 0!==arguments[2]?arguments[2]:w())("readwrite",(function(i){return i.put(t,e),h(i.transaction)}))}(e,t)}catch(e){be("error in indexedDBUtil",e)}}))}static get(e){return p(this,void 0,void 0,(function*(){if(J())try{return function(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:w())("readonly",(function(t){return h(t.get(e))}))}(e)}catch(e){return be("error in indexedDBUtil",e),Promise.reject(e)}}))}static del(e){return p(this,void 0,void 0,(function*(){if(J())try{!function(e){(arguments.length>1&&void 0!==arguments[1]?arguments[1]:w())("readwrite",(function(t){return t.delete(e),h(t.transaction)}))}(e)}catch(e){be("error in indexedDBUtil",e)}}))}}const z=function(){function e(e){e=e||{};const t={url:location.href,headers:{"User-Agent":navigator.userAgent}};return{event_id:"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})),platform:"javascript",release:"3650a20",extra:e,request:t}}function t(e){return Math.random()<.95?Promise.resolve():fetch("https://o79286.ingest.sentry.io/api/1527936/store/?sentry_version=7&sentry_key=8f53de1cdf86490fb8e55518e1a5d035",{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}function i(i,n){const o=e(n);return o.message=i,t(o)}return{log:i,logException:function(n,o){if(n)try{(o=o||{}).errorDump={str:String(n),stack:n&&n.stack};const i=e(o);return i.exception=function(e){const t=e.stack||"";if(!t)return;const i=t.split("\n").map((e=>e.trim())).filter((e=>e.startsWith("at"))).map((function(e){let t="",i=0,n=0,o="";const r=e.split(/[ ]+/);if("at"===r[0].trim()&&r.length>1){let e="";r.length>2?(t=r[1],e=r[2]):e=r[1],e=e.replace("(","").replace(")","");const s=e.split(":");s.length>1&&(i=parseInt(s[s.length-1],0),n=parseInt(s[s.length-2],0),o=s.slice(0,s.length-2).join(":"))}return{in_app:!0,function:t,colno:Number(i)||i,lineno:Number(n)||n,filename:o}}));return i.reverse(),{values:[{type:e.name||"Error",value:e.message||String(e),stacktrace:{frames:i}}]}}(n),t(i)}catch(e){i(String(e),e),i(String(n),n)}}}}();function Q({position:e,device:t,customConfig:i,isExpanded:n}){if("desktop"===t){const t="15px",o="15px",r="15px",s="15px",a=68,c=`calc(50% - ${568}px / 2)`,u=`calc(50% - ${a}px / 2)`,d=`calc(50% - ${a}px / 2)`;if(i.hasOwnProperty("bottom")&&25===i.bottom&&15===i.left&&"auto"===i.right)switch(e){case"bottom-left":return{bottom:o,left:r};case"bottom-right":return{bottom:o,right:s};case"bottom-center":return n?{bottom:o,left:c}:{bottom:o,left:u};case"top-left":return{top:t,left:r};case"top-right":return{top:t,right:s};case"top-center":return n?{top:t,left:c}:{top:t,left:u};case"center-left":return{top:d,left:r};case"center-right":return{top:d,right:s};default:return i}let l={left:r};for(let e in i)l[e]=`${i[e]}px`;return l}if("mobile"===t){const t="8px",n="8px",o="8px",r="8px",s=`calc(50% - ${48}px / 2)`;if(i.hasOwnProperty("bottom")&&i.hasOwnProperty("left")&&15===i.bottom&&15===i.left)switch(e){case"bottom-left":return{bottom:n,left:o};case"bottom-right":return{bottom:n,right:r};case"top-left":return{top:t,left:o};case"top-right":return{top:t,right:r};case"center-left":return{top:s,left:o};case"center-right":return{top:s,right:r};default:return i}let a={isCustomConfig:!0};for(let e in i)a[e]=`${i[e]}px`;return a}}function Z(e){let t=document.implementation.createHTMLDocument();return t.body.innerHTML=e,t.body.children[0]}function ee(){let e=navigator.userAgent;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(e)}function te(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return null}}function ie(e){return[...new URLSearchParams(e).entries()].reduce(((e,[t,i])=>Object.assign(Object.assign({},e),{[t]:i})),{})}function ne(e,t=null){t||(t=window.location.href);return ie(new URL(t).search)[e]}function oe(){let t=navigator.userAgent,i=t.search("Firefox")>=0,n=!!window.chrome;const o=void 0!==window.PushManager,r=(({ua:e,maxTouchPoints:t})=>{if(!(/iPad|iPhone|iPod|Mac OS X/.test(e)&&t>0))return!1;const i=e.match(/EdgiOS\/(\d+\.\d+)/);if(i&&i.length>=2)return parseFloat(i[1])>=112;const n=e.match(/Version\/(\d+\.\d+)/);if(n&&n.length>=2)return parseFloat(n[1])>=16.4;const o=e.match(/CPU iPhone OS (\d+_\d+)/);if(o&&o.length>=2)return parseFloat(o[1].replace("_","."))>=16.4;return!1})({ua:t,maxTouchPoints:navigator.maxTouchPoints});let s=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream&&!r,a=!!window.safari;return{isiOS:r,isSafari:a,isApnsSafari:a&&!o,isFirefox:i,isChrome:n,isOldIOS:s,name:n?e.CHROME:a?e.SAFARI:i?e.FIREFOX:e.OTHER}}function re(e){const t=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),i=window.atob(t),n=new Uint8Array(i.length);for(let e=0;e{let a=new XMLHttpRequest;a.open(e,t,!0),a.setRequestHeader("Content-Type",i),a.setRequestHeader("Accept",n),o?a.send(i.match(/json/)?JSON.stringify(o):o):a.send(),a.onload=function(){let e=a.responseText;if(a.status>=200&&a.status<400){const t=n.match(/json/)?JSON.parse(e):e;r(t)}else s(e)}}))}function ae(e=7){for(var t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-",i="",n=e;n--;)i+=t[~~(Math.random()*t.length)];return i}function ce({name:e,value:t}){document.cookie=`${e}=${encodeURIComponent(t)};domain=${window.location.hostname}`}function ue({name:e,value:t,days:i=1,path:n="/"}){const o=new Date(Date.now()+864e5*i).toUTCString();document.cookie=e+"="+encodeURIComponent(t)+"; expires="+o+"; path="+n}function de(e){return document.cookie.split("; ").reduce(((t,i)=>{const n=i.split("=");return n[0]===e?decodeURIComponent(n[1]):t}),"")}function le(e,t){ue({name:e,value:"",days:-1,path:t})}function pe(){const e=document.createElement("div");return document.body.appendChild(e),"rtl"===window.getComputedStyle(e).direction}const he=[];function be(...e){const t=console;he.push(e),(localStorage.getItem("pushowl_log_level")===s.DEBUG||location.href.match(/poTaskType=debug/))&&t.log("%c🦉PushOwl","background: #fb446a; color: white; padding: 2px 0.5em; border-radius: 0.5em;",...e)}function we(e,t){const i=console;he.push([e,t]),(localStorage.getItem("pushowl_log_level")===s.DEBUG||location.href.match(/poTaskType=debug/))&&(e&&be(e),i.table(t))}function me(){const[e,t]=navigator.language.split("-");return{language:e,region:t}}function ge(e,t={}){if(navigator.userAgent.match(/Instagram|FBAN/))return;if(l(e))return;if([n.NOTIFICATION_NOT_DEFINED,n.OLD_IOS_DEVICE,n.MICROSOFT_EDGE,n.NO_SERVICE_WORKER,n.INCOGNITO,n.NO_FILE_SYSTEM,n.LOCALSTORAGE_NOT_AVAILABLE].includes(e))return;let i="";window.pushowl&&(i=window.pushowl.getSubdomain?window.pushowl.getSubdomain():window.pushowl.subdomain),z.logException("string"==typeof e?new Error(e):e,Object.assign({breadcrumbs:he,subdomain:i,url:window.location.href},t))}const _e=e=>"number"==typeof e?e/100:e,fe=e=>{const t=(e=>2===Object.keys(e).length&&e.hasOwnProperty("items")&&(e.hasOwnProperty("token")||e.hasOwnProperty("checkout_token")))(e),i={id:void 0,data:void 0},n=0===e.item_count?a.CART_DELETED:a.CART_UPDATED,o=!t&&e.id?e.id:e.token||e.checkout_token;o&&(i.id=`cart:${o}`,i.data=e.id&&!t?e:(e=>({affiliation:Y.subdomain,currency:_e(e.currency),discount:_e(e.total_discount),total:_e(e.total_price),discount_taxinc:"",items:e.items.map((e=>({available_now:!0,category:null,description_short:e.product_description,disc_amount:_e(e.discounted_price),disc_amount_taxinc:"",disc_rate:"",id:e.id,image:e.image,name:e.title,price:_e(e.price),price_predisc:"",price_predisc_taxinc:"",price_taxinc:"",quantity:e.quantity,size:"",sku:e.sku,tax_amount:"",tax_name:"",tax_rate:"",url:`${window.location.origin}${e.url}`,variant_id:e.variant_id,variant_id_name:e.variant_title}))),shipping:"",shipping_taxinc:"",subtotal:"",subtotal_predisc:"",subtotal_predisc_taxinc:"",subtotal_taxinc:"",tax:"",total_before_tax:"",url:`${window.location.origin}/cart`}))(e)),$({eventName:n,eventData:i})};function Se(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function ve(e){for(var t=1;t=0||(o[i]=e[i]);return o}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,i)&&(o[i]=e[i])}return o}class Pe{static _request(e){return p(this,void 0,void 0,(function*(){return yield x(e)}))}static get(e){return this._request(Object.assign(Object.assign({},e),{method:"GET"}))}static post(e){return this._request(Object.assign(Object.assign({},e),{method:"POST"}))}static put(e){return this._request(Object.assign(Object.assign({},e),{method:"PUT"}))}}class Ne{static createRequestObj(e){let t=e;return void 0===e.id&&(t=Object.assign({id:ae()},e)),t}static _retryRequest(e){return p(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},e),{retryCount:((null==e?void 0:e.retryCount)||0)+1});if(t.retryCount>5){return ge("APIRequestSimpleRetry",{request:t,connectionType:navigator.connection?navigator.connection.effectiveType:"NA"}),Promise.reject()}const i=this.createRequestObj(t);setTimeout((()=>{this._request(i)}),1e3*i.retryCount)}))}static _request(e){return p(this,void 0,void 0,(function*(){try{return yield x(e)}catch(t){if(l(t))return this._retryRequest(e);ge("APIRequestSimpleRetryError",{error:t,request:e}),Promise.reject(t)}}))}static get(e){return this._request(Object.assign(Object.assign({},e),{method:"GET"}))}static post(e){return this._request(Object.assign(Object.assign({},e),{method:"POST"}))}static put(e){return this._request(Object.assign(Object.assign({},e),{method:"PUT"}))}}class Re{constructor(){var{subdomain:e}=Y;this.endpoint=Y.apiEndpoint,this.subscriber_refresh_endpoint="".concat(this.endpoint,"/api/v1/accounts/").concat(e,"/subscriber/refresh/"),this.checkout_sync_endpoint="".concat(this.endpoint,"/api/v1/").concat(e,"/subscriber/event/checkout-sync/"),X.set("subscriber_refresh_endpoint",this.subscriber_refresh_endpoint),K.landingPageURL||(K.landingPageURL=document.URL),K.referrer||(K.referrer=document.referrer),K.landingPageURLParams||(K.landingPageURLParams=window.location.search),L.originalURLParams||(L.originalURLParams=window.location.search)}config(){return"headless"===Y.mode?Pe.get({path:"/subscriber/config/widget/?guid=".concat(Y.guid)}):Ne.get({url:"".concat(Y.configApiEndpoint,"/api/v1/").concat(Y.subdomain,"/subscriber/config/widget/?guid=").concat(Y.guid)})}sendSubscription(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2?arguments[2]:void 0,o=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0,s=new K;if(s.config&&s.config.flags&&"enabled"===s.config.flags.disable_resync&&t)return Promise.reject(n.DISABLED_RESYNC);var a={};K.landingPageURLParams.slice(1).split("&").filter((e=>e.includes("utm_"))).forEach((e=>{var[t,i]=e.split("=");a[t]=i}));var c={};L.originalURLParams.slice(1).split("&").filter((e=>e.includes("po_"))).forEach((e=>{var[t,i]=e.split("=");c[t]=i}));var u=window.location.href,d=new URLSearchParams(window.location.search),l=!0;if(d.get("po_url")&&(l=!1,u=d.get("po_url")),oe().isOldIOS)return be("PushOwl does not support iOS before 16.4","platform: ".concat(navigator.platform),"Browser: ".concat(oe().name)),Promise.reject(n.OLD_IOS_DEVICE);var p={subscription:e,browser:oe().name,previous_token:L.subscriberToken,website_push_id:i||Y.webPushId,customer_id:s.config.privacy?q.customerId:null,language:window.navigator.language,timezone:te(),dispatch_method:oe().isApnsSafari?"apns":"vapid",user_agent:navigator.userAgent,guid:Y.guid,optin_seen_count:s.optinSeenCount,context:ve(ve({isPushowlThemeAppExtentionEnabled:!!window.isPushowlThemeAppExtentionEnabled,isiOS:oe().isiOS,is_resync:t,subscribe_url:u,session_token:L.sessionToken,visitor_token:L.visitorToken,sib_visitor_id:Y.visitorId,widget_source:window.poSubscriptionSource,worker_available:l},a),{},{permanent:ve({},c),temporary:{referrer:K.referrer,landing_url:K.landingPageURL}}),source:o,source_id:r};return Ne.post({url:"".concat(Y.apiEndpoint,"/api/v2/accounts/").concat(Y.subdomain,"/subscribers/webpush/"),payload:p}).then((e=>(e&&e.result||be("Invalid /subscribe response. response:",e),e.result.token))).catch((()=>Promise.reject("Send Subscription API Failed")))}refreshSubscription(e,t,i){var o={previous_token:e,previous_subscription:t,current_subscription:i};return o.context={subscribe_url:window.location.href,session_token:L.sessionToken,visitor_token:L.visitorToken,sib_visitor_id:Y.visitorId},oe().isOldIOS?(be("PushOwl does not support iOS before 16.4","platform: ".concat(navigator.platform),"Browser: ".concat(oe().name)),Promise.reject(n.OLD_IOS_DEVICE)):Pe.post({url:this.subscriber_refresh_endpoint,payload:o}).then((e=>e.result.token)).catch((()=>Promise.reject("Refresh Subscription API Failed")))}syncSubscriber(){var e={data:[{key:"customer_id",value:q.customerId}],token:L.subscriberToken,context:{subscribe_url:window.location.href,session_token:L.sessionToken,visitor_token:L.visitorToken}};return Ne.put({url:"".concat(Y.apiEndpoint,"/api/v1/accounts/").concat(Y.subdomain,"/subscriber/"),payload:e})}syncCart(e,t){var i=new K,n={subscriber_token:L.subscriberToken,customer_id:i.config.privacy?t||q.customerId:null,browser:oe().name,cart_json:e,origin:window.location.origin,store_root:((window.Shopify||{}).routes||{}).root||"/"};return Pe.post({path:"/subscriber/event/cart-sync/",payload:n})}syncProductView(e){var t={subscriber_token:L.subscriberToken,session:L.sessionToken,viewed_time:~~(Date.now()/1e3),product_data:e,store_root:((window.Shopify||{}).routes||{}).root||"/"};return Pe.post({path:"/subscriber/event/product-view/",payload:t})}sendEvent(e,t){return ye((function*(){return Ne.post({path:"/subscriber/event/".concat(e,"/"),payload:t}).catch((e=>Promise.reject("Event Update failed")))}))()}unsubscribe(e){return G.post({url:"".concat(Y.apiEndpoint,"/api/v1/accounts/").concat(Y.subdomain,"/subscriber/unsubscribe/"),payload:{token:e,sib_visitor_id:Y.visitorId}})}syncSubscriberTokenAndCheckoutId(e){var t=JSON.stringify({subscriber_token:L.subscriberToken,checkout_token:e});navigator.sendBeacon(this.checkout_sync_endpoint,t)}debugLog(e){return G.post({path:"/subscriber/debug/",payload:e})}subscribeThroughPopup(e){var{subscriptionData:t,flowId:i,nodeId:n}=e,o={subscription_data:t,token:L.subscriberToken,source:"optin_flows",source_id:n};return Pe.post({path:"/dashboard/optin-flows/".concat(i,"/subscribers/"),payload:o})}identifyBrevoContactThroughPhoneNumber(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=(new K).config.brevo_ma_key,n=de("sib_cuid");if(i&&n&&e)return Pe.post({url:"https://in-automate.brevo.com/p",appendPlatform:!1,payload:{key:i,sib_type:"identify",cuid:n,ma_url:document.location.href,contact:ve(ve({},t),{},{sms:e}),email_id:"".concat(e.replace(/\D/g,""),"@mailin-sms.com")}})}}class Ce{constructor(e){this.inclusions=e.inclusions,this.exclusions=e.exclusions}}class ke{constructor(e){this.url=new Ce(e.url)}processCondition(e,t){var i=t.inclusions,n=t.exclusions;return i.some((t=>new RegExp(t).test(e)))&&!n.some((t=>new RegExp(t).test(e)))}processUrlActivationRule(){try{var e=this.url,t=window.location.href,i=this.processCondition(t,e);return be("[Checking page url condition]","Condition: ",this.url," / Result: ".concat(i?"✅":"❌")),i}catch(e){return!0}}}class Ae{constructor(e){this.flyout=new Fe(e.flyout)}}class De{constructor(e){this.type=e.type,e.config&&(this.config=e.config,this.config.overlay=new Ue(this.config.overlay))}}class Ue{constructor(e){this.enabled=e.enabled,this.title=e.title,this.subtitle=e.description||e.subtitle,this.branding=e.branding}}class Le{constructor(e){this.money_format=e.money_format}}class Be{constructor(e){this.enabled=e.enabled,this.text=e.text}}class xe{constructor(e){this.unsubscribe=new Be(e.unsubscribe),this.access_data=new Be(e.access_data),this.delete_data=new Be(e.delete_data)}}class Ge{constructor(e){this.enabled=e.enabled,this.message=e.message,this.actions=new xe(e.actions)}}class Ke{constructor(e){this.notification_preference=new Ge(e.notification_preference),this.customer_id=e.customer_id}}class je{constructor(e){this.bottom=e.bottom||15,this.diameter=e.diameter||68,this.left=e.left||15,this.right=e.right||"auto"}}class He{constructor(e){this.bottom=e.bottom||15,this.left=e.left||15,this.diameter=e.diameter||48}}class Me{constructor(e){this.desktop=new je(e.desktop),this.mobile=new He(e.mobile),this.color=e.color||"rgb(51, 51, 51)",this.overlay=e.overlay}}class Fe{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.enabled=e.enabled,this.title=e.title,this.buttonText=e.button_text||e.buttonText,this.postSubscriptionTitle=e.post_subscription_message||e.postSubscriptionTitle,this.theme=e.theme,this.position=e.position,this.overlay=e.overlay}static create_instance(e){var t=new Fe;t.enabled=e.enabled;var i=e.metadata;return t.metadata=i,t.title=e.title||i.title,t.buttonText=e.buttonText||i.yes_button.text,t.postSubscriptionTitle=e.postSubscriptionTitle||i.post_subscription.post_subscription_widget.title,t}}class Ve{constructor(e){e=this.preProcess(e),this.home=new Ae(e.home),this.optin=e.optin?new De(e.optin):null,this.brevo_ma_key=e.brevo_ma_key,this.price_drop=Fe.create_instance(e.price_drop),this.back_in_stock=Fe.create_instance(e.back_in_stock),this.shop=new Le(e.shop),this.abandoned_cart_enabled=e.abandoned_cart_enabled,this.browse_abandonment_enabled=e.browse_abandonment_enabled,this.optin_report_enabled=e.optin_report_enabled,this.is_beta=e.is_beta||!1,this.privacy=new Ke(e.privacy),this.vapid_public_key=e.vapid_public_key,this.activation_rule=e.activation_rule&&new ke(e.activation_rule),this.flyout_config=e.flyout_config&&new Me(e.flyout_config),this.branding=void 0===e.branding||e.branding,this.logo=e.logo,this.flags=e.flags,this.wid=e.wid,this.integrations=e.integrations,this.website_push_id=e.website_push_id,this.service_worker=e.service_worker,this.ios_prompt=e.ios_prompt,this.optin_flows=e.optin_flows}preProcess(e){var t=void 0===e.branding||e.branding;return e.optin&&e.optin.config&&e.optin.config.overlay&&(e.optin.config.overlay.branding=t),e}}var qe={get(e){var t=new K,i=new Re;return new Promise((n=>{var o=e?null:t.config,r=()=>i.config().then((e=>{var i=new Ve(e.result);t.config=i,n(i),be("Config fetched: from backend.",i)})).catch((e=>{be("Error on fetching config",e),ge(e)}));if(o){be("Config fetched: from local cache.",o);try{n(new Ve(o))}catch(e){r()}}else r()}))}};function Ye(e){var{subdomain:t}=e;return new Promise(((e,i)=>{"undefined"==typeof Storage&&i(n.STORAGE_NOT_DEFINED),!0!==function(){let e="test";try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return!1}}()&&i(n.LOCALSTORAGE_NOT_AVAILABLE),/Edge/.test(navigator.userAgent)&&i(n.MICROSOFT_EDGE),t||i(n.NO_SUBDOMAIN),e()}))}var We=()=>void 0===window.Notification?(be(n.NOTIFICATION_NOT_DEFINED),!1):oe().isOldIOS||oe().isApnsSafari||"serviceWorker"in navigator?oe().isOldIOS?(be(n.OLD_IOS_DEVICE),!1):!(oe().isiOS&&!navigator.standalone)||(be(n.NOT_ADDED_TO_HOME_SCREEN),!1):(be(n.NO_SERVICE_WORKER),!1);function $e(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,r=new Re;return new Promise(((s,a)=>{r.sendSubscription(e,t,i,n,o).then((t=>{L.handlePostSubscription(e,t),ce({name:m.STORAGE_KEYS.SUBSCRIBER_TOKEN,value:t}),s(t)})).catch((e=>{be("🔴 Send Subscription Failed",e),a(e)}))}))}var Je={validateOrSyncSubscription(e){var{subscription:t,websitePushId:i}=e;return new Promise(((e,n)=>{var o=L.subscription;if(o)if(t.endpoint===o.endpoint)e();else{var r=new Re;be("Refreshing old subscription on server..."),r.refreshSubscription(L.subscriberToken,o,t).then((i=>{L.handlePostSubscription(t,i),ce({name:m.STORAGE_KEYS.SUBSCRIBER_TOKEN,value:i}),e()})).catch((e=>{n(e)}))}else be("Syncing new subscription to server"),$e(t,!1,i).then(e)}))},verifySubscriber(e){var{browserHandler:t}=e,i=new K;return be("Verifying subscriber..."),new Promise(((e,n)=>{L.subscriberToken?L.subscriberToken.match(/failed/i)?(be("🔴 Subscriber could not be verified. Reason: ",o.INVALID_SUBSCRIBER_TOKEN),n(o.INVALID_SUBSCRIBER_TOKEN)):i.subscriptionVerified?e():oe().isApnsSafari?t.isPermissionGranted?e():n():Y.isWorkerAvailable.then((i=>{i?t.getSubscription().then((t=>{this.validateOrSyncSubscription({subscription:t}).then((()=>{e(),be("🟢 Subscriber verified.")})).catch((()=>{n(),be("🔴 Subscriber could not be verified.")}))})).catch(((e,t)=>{n(e,t),be("🔴 Subscription could not be fetched.",e,t)})):t.isPermissionGranted?e():n()})):(n(o.NO_SUBSCRIBER_TOKEN),be("🔴 Subscriber could not be verified. Reason: ",o.NO_SUBSCRIBER_TOKEN))}))},handleSubscription(e){var{browserHandler:t,resolve:i,reject:n,areWeResyncing:o,websitePushId:r,showHintScreenOnError:s,hintscreenHandler:a,enableHintScreen:c,source:u,source_id:d}=e,l=new K,p=new Date;t.getSubscription().then((e=>{c&&a.purge(),$e(e,o,r,u,d).then((()=>{var{subscriberToken:e}=L;i({subscriberToken:e}),new BroadcastChannel("pushowl").postMessage({subscriberToken:e,subdomain:Y.subdomain})})).catch(n),o?be("🟢 Resync-subscription successfull. (bcoz permission was granted but didn't have a valid subscription)",e):(be("🟢 Subscription successfull",e),document.dispatchEvent(new Event("SubscribedToPushOwl")),this.trackBrowserPromptAnalytics(new Date-p,"allowed"))})).catch((e=>{a&&a.purge(),s&&a.show(),l.isPermissionNotGranted=!0,be("🔴 Subscription failed",e),o||this.trackBrowserPromptAnalytics(new Date-p,e),n(e)}))},subscribe(e){var{enableHintScreen:t=!1,hintScreenData:i=null,showHintScreenOnError:n=!1,websitePushId:o,browserHandler:r,source:s,source_id:a}=e,c=new K,u=r.isPermissionGranted;return new Promise(((e,d)=>{var l;t?import("./PushowlHintScreenHandler-44447230.js").then((p=>{var{PushowlHintScreenHandler:h}=p;(l=new h({onDismiss:()=>{c.isPermissionNotGranted=!0,c.config.optin_report_enabled&&window.poAnalytics.track("BrowserPromptOverlayDismissed",{optinSeenCount:c.optinSeenCount})}})).show(i),this.handleSubscription({browserHandler:r,resolve:e,reject:d,areWeResyncing:u,websitePushId:o,showHintScreenOnError:n,hintscreenHandler:l,enableHintScreen:t,source:s,source_id:a})})):this.handleSubscription({browserHandler:r,resolve:e,reject:d,areWeResyncing:u,websitePushId:o,showHintScreenOnError:n,hintscreenHandler:null,enableHintScreen:t,source:s,source_id:a})})).catch((e=>{be("Error encountered in loading Pushowl Hint Screen: ".concat(e.message))}))},subscribeIfNotAlready(e){var{enableHintScreen:t=!1,showHintScreenOnError:i=!0,websitePushId:n,browserHandler:o,hintScreenData:r=null}=e;return new Promise(((e,s)=>{o.isPermissionGranted?L.subscriberToken?e(!0):this.subscribe({enableHintScreen:!1,showHintScreenOnError:!1,websitePushId:n,browserHandler:o,hintScreenData:r}).then((()=>e(!0))).catch((e=>s(e))):this.subscribe({enableHintScreen:t,showHintScreenOnError:i,websitePushId:n,browserHandler:o,hintScreenData:r}).then((()=>e(!0))).catch((e=>s(e)))}))},update(e,t){var i=new Re;return t.subscriber_token=L.subscriberToken,i.sendEvent(e,t)},subscribeProduct(e){var{context:t,automation:i,product:n,variant:o,source:r}=e;return this.subscribeIfNotAlready({enableHintScreen:!0,websitePushId:t.config.website_push_id,browserHandler:t.browserHandler}).then((()=>this.update(i,{product_id:n.id,product:n,variant:o,source:r,permission:window.Notification&&window.Notification.permission}).then((e=>{var{token:t}=e.result;t&&(L.subscriberToken=t),be("Product subscribed for ".concat(i,". Product ").concat(n.id,". Variant ").concat(o.id,". Source: ").concat(r))})).catch(ge)))},unsubscribe(e){var t=new Re;e.isPermissionGranted?t.unsubscribe(L.subscriberToken).then((()=>{be("🟢 Unsubscription successfull")})).catch((e=>{be("🔴 Unsubscription failed",e)})):be("🟢 Unsubscription successfull")},trackBrowserPromptAnalytics(e,t){var i=new K;if(i.config.optin_report_enabled){window.poAnalytics.track("BrowserPromptShown",{delay:e,optinSeenCount:i.optinSeenCount});var n={allowed:"BrowserPromptAllowClicked",denied:"BrowserPromptDenyClicked",default:"BrowserPromptCloseClicked"};n[t]&&window.poAnalytics.track(n[t],{delay:e,optinSeenCount:i.optinSeenCount})}}},Xe=["type"];var ze={isSubscribed(e){var{context:t,product:i,featureStorageManager:n}=e;if(!i)return t.browserHandler.isPermissionGranted;if(n){var o=i.currentVariant();return t.browserHandler.isPermissionGranted&&n.isSubscribed(o)}return!1},handlePushOwlButtons(e){var{buttons:t,onClick:i,isSubscribed:n}=e;if(!(oe().isiOS&&!navigator.standalone||oe().isOldIOS))for(var o of Array.from(t)){var r=o.dataset.pushowlPreDisplay,s=o.dataset.pushowlPreVisibility,a=o.dataset.pushowlPostDisplay,c=o.dataset.pushowlPostVisibility,u=o.dataset.pushowlPostSubscriptionMessage;n?(a&&(o.style.display=a),c&&(o.style.visibility=c),u&&(o.innerText=u)):("none"===o.style.display&&(o.style.display=r||"block"),"hidden"===o.style.visibility&&(o.style.visibility=s||"visible")),o.addEventListener("click",i)}},subscribeButtons(e){var{context:t}=e,i=document.querySelectorAll(".js-pushowl--subscribe");be("".concat(i.length," custom subscribe button(s) detected."),i),document.addEventListener("SubscribedToPushOwl",(()=>{i.forEach((e=>{var t=e.dataset.pushowlPostSubscriptionMessage;t&&(e.innerText=t)}))})),this.handlePushOwlButtons({buttons:i,onClick:e=>{Je.subscribeIfNotAlready({enableHintScreen:"false"!==e.target.dataset.pushowlOverlay,websitePushId:t.config.website_push_id,browserHandler:t.browserHandler}).then((()=>{var t=e.target.dataset.pushowlPostSubscriptionMessage;t&&(e.target.innerText=t)}),null)},isSubscribed:this.isSubscribed({context:t})})},priceDropButtons(e){var{context:t,onSuccess:n}=e,o=document.querySelectorAll(".js-pushowl--pd");o.length&&(be("".concat(o.length," custom price drop button(s) detected."),o),t.storeLib.getProductDetails().then((e=>{this.handlePushOwlButtons({buttons:o,onClick:o=>{var r=e.currentVariant();Je.subscribeProduct({context:t,automation:m.EVENT_API_PATH.PRICE_DROP,product:e,variant:r,source:i.CUSTOM_BUTTONS}).then((()=>{t.storageManager.price_drop.subscribe(r);var i=o.target.dataset.pushowlPostSubscriptionMessage;i&&(o.target.innerText=i),n(e)})).catch(ge)},isSubscribed:this.isSubscribed({context:t,product:e,featureStorageManager:t.storageManager.price_drop})})})))},backInStockButtons(e){var{context:t,onSuccess:n}=e,o=document.querySelectorAll(".js-pushowl--bis");o.length&&(be("".concat(o.length," custom back-in-stock button(s) detected."),o),t.storeLib.getProductDetails().then((e=>{this.handlePushOwlButtons({buttons:o,onClick:o=>{var r=e.currentVariant();Je.subscribeProduct({context:t,automation:m.EVENT_API_PATH.BACK_IN_STOCK,product:e,variant:r,source:i.CUSTOM_BUTTONS}).then((()=>{t.storageManager.back_in_stock.subscribe(r);var i=o.target.dataset.pushowlPostSubscriptionMessage;i&&(o.target.innerText=i),n(e)})).catch(ge)},isSubscribed:this.isSubscribed({context:t,product:e,featureStorageManager:t.storageManager.back_in_stock})})})))}};class Qe{constructor({endpoint:e,props:t}){this.endpoint=e,this.meta={},this.initVisitor(),this.setVisitorProperties(t);let i=null;W()?i=de("po_visitor"):le("po_visitor","/"),this.setVisitorProperties({sessionId:i,language:navigator.language})}initVisitor(){let e=null;W()?e=de("po_visitor"):le("po_visitor","/"),e||(this.meta.isNewVisitor=!0,e=ae(12),W()&&ue({name:"po_visitor",value:e,days:365})),this.visitorId=e}setVisitorProperties(e){this.properties=Object.assign(Object.assign({},this.properties),e)}track(e,t,i){if(W()&&this.visitorId&&this.properties.visitorToken)if(this.properties.wid)if(i){const i={sessionId:this.visitorId,sessionToken:this.properties.sessionToken,visitorToken:L.visitorToken,subdomain:Y.subdomain,wid:this.properties.wid,language:this.properties.language,flowId:t.flowId,formId:t.formId,nodeId:t.nodeId,channelType:t.channelType,optinType:t.optinType,formStepType:t.formStepType,event:e,platform:Y.platform,timestamp:(new Date).toISOString(),uuid:ae()};Pe.post({url:this.endpoint,payload:i,acceptType:"text/plain"})}else Pe.post({url:this.endpoint,payload:Object.assign(Object.assign({event:e,sessionId:this.visitorId,uuid:ae(15),properties:t},this.properties),{platform:Y.platform,timestamp:(new Date).toISOString()}),acceptType:"text/plain"});else Y.logToServer({message:"wid empty",subdomain:Y.subdomain,data:Object.assign(Object.assign({},t),{breadcrumbs:he})})}}const Ze=(e,t,i)=>{let n=i.replace("{{amount}}",parseFloat(t).toFixed(2));return e.replace("{{product_price}}",n).replace("{{variant_price}}",n)};var et={renderFlyout(e){var{flyoutHandler:t,title:i,buttonText:n,automationType:o,buttonListener:r,theme:s,position:a,overlay:c}=e;document.querySelectorAll(".pushowl-widget-node").forEach((e=>{e&&e.remove()})),i&&(t.setState({title:i,buttonText:n,buttonListener:r,theme:s,position:a,overlay:c}),be("Product flyout shown for: ",o),be("🟠 Optin prompt was not shown. Reason: Product flyout shown"))},renderOptin(e){var{rootContext:t,flyoutHandler:i}=e,n=t.config.home.flyout,{title:o,theme:r,position:s,buttonText:a,overlay:c}=n;i.setState({title:o,buttonText:a,theme:r,position:s,overlay:c,buttonListener:()=>{window.poSubscriptionSource=R,Je.subscribeIfNotAlready({enableHintScreen:c&&c.enabled,websitePushId:t.config.website_push_id,browserHandler:t.browserHandler,hintScreenData:c}).then((()=>{i.setState({title:n.postSubscriptionTitle,position:s,theme:r})})).catch((e=>{ge(e)}))}}),be("Flyout shown.","Config: ",n)},renderBackInStock(e){var{rootContext:t,flyoutHandler:n,product:o,variant:s}=e,a=new L,{back_in_stock:c,flyout_config:u}=t.config,d=c.enabled,l=a.back_in_stock.isSubscribed(s);if(d)if(window.Notification&&window.Notification.permission===m.NOTIFICATION_PERMISSION.GRANTED&&l){var p=Ze(c.postSubscriptionTitle,s.price,t.config.shop.money_format),{theme:h,position:b,overlay:w}=c.metadata;this.renderFlyout({flyoutHandler:n,title:p,theme:h,position:b,overlay:w,automationType:r.BACK_IN_STOCK})}else{var{theme:g,position:_,overlay:f}=c.metadata;this.renderFlyout({flyoutHandler:n,title:c.title,buttonText:c.buttonText,theme:g,position:_,overlay:f,buttonListener:()=>{n.setState({title:c.postSubscriptionTitle,position:_,theme:g});var{overlay:e}=c.metadata;window.Notification&&"default"===window.Notification.permission&&(window.poSubscriptionSource=k),Je.subscribeIfNotAlready({enableHintScreen:!!u.overlay,showHintScreenOnError:!!u.overlay,websitePushId:t.config.website_push_id,browserHandler:t.browserHandler,hintScreenData:e}).then((()=>{Je.update(m.EVENT_API_PATH.BACK_IN_STOCK,{product_id:o.id,product:o,variant:s,source:i.FLYOUT_WIDGET,permission:window.Notification&&window.Notification.permission}).then((e=>{a.back_in_stock.subscribe(s);var{token:t}=e.result;t&&(L.subscriberToken=t),be("Product subscribed for ".concat(m.EVENT_API_PATH.BACK_IN_STOCK,". Product ").concat(o.id,". Variant ").concat(s.id,". Source: ").concat(i.FLYOUT_WIDGET))})).catch((e=>{ge(e)}))}))},automationType:r.BACK_IN_STOCK})}},renderPriceDrop(e){var{rootContext:t,flyoutHandler:n,product:o,variant:s}=e,a=new L,{price_drop:c,flyout_config:u}=t.config,d=c.enabled,l=a.price_drop.isSubscribed(s);if(d)if(window.Notification&&window.Notification.permission===m.NOTIFICATION_PERMISSION.GRANTED&&l){var{theme:p,position:h,overlay:b}=c.metadata;this.renderFlyout({flyoutHandler:n,theme:p,position:h,overlay:b,title:c.postSubscriptionTitle,automationType:r.PRICE_DROP})}else{var w=t.config.price_drop.metadata,{theme:g,position:_,overlay:f}=w;this.renderFlyout({theme:g,position:_,overlay:f,flyoutHandler:n,title:Ze(c.title,s.price,t.config.shop.money_format),buttonText:c.buttonText,buttonListener:()=>{n.setState({title:c.postSubscriptionTitle,position:_,theme:g});var{overlay:e}=c.metadata;window.Notification&&"default"===window.Notification.permission&&(window.poSubscriptionSource=C),Je.subscribeIfNotAlready({enableHintScreen:!!u.overlay,showHintScreenOnError:!!u.overlay,websitePushId:t.config.website_push_id,browserHandler:t.browserHandler,hintScreenData:e}).then((()=>{Je.update(m.EVENT_API_PATH.PRICE_DROP,{product_id:o.id,product:o,variant:s,subscribed_price:s.price,source:i.FLYOUT_WIDGET,permission:window.Notification&&window.Notification.permission}).then((e=>{a.price_drop.subscribe(s);var{token:t}=e.result;t&&(L.subscriberToken=t),be("Product subscribed for ".concat(m.EVENT_API_PATH.PRICE_DROP,". Product ").concat(o.id,". Variant ").concat(s.id,". Source: ").concat(i.FLYOUT_WIDGET))})).catch((e=>{ge(e)}))}))},automationType:r.PRICE_DROP})}}};const tt={name:"Pushowl Web Notifications",short_name:"PushOwl",description:"",icons:[],start_url:"/",scope:"/",display:"standalone",orientation:"portrait",background_color:"#fff",theme_color:"#000000"};var it=e=>{var{channels:t,consent:i}=e;return t.every((e=>i.includes(e)))},nt=(e,t)=>ee()?void 0!==e.mobile?e.mobile:t:void 0!==e.default?e.default:t;const ot=({nodeId:e,flowId:t,channelType:i,optinType:n})=>({formId:o,event:r,stepType:s})=>{window.poAnalytics.track(r,{flowId:t,nodeId:e,formId:o,channelType:i,optinType:n,formStepType:s},!0)},rt=({event:e,optinType:t,flowId:i,nodeId:n,formId:o})=>{ot({optinType:t,channelType:["webpush"],flowId:i,nodeId:n})({stepType:"step_1",event:e,formId:o})},st=(e,t)=>{const i={};return Object.keys(e).forEach((n=>{t[n]&&(i[e[n].mapAttribute]=t[n])})),i};var at=e=>{e>0&&(L.optinDeferredUntil=Date.now()+86400*parseInt(e,10)*1e3)},ct={showNativePrompt(e){var{hintScreenConfig:t,subscribeCallback:i,source:n,nodeId:o,trackWebPushDenied:r,trackWebPushSubmission:s}=e;function a(){return window.poSubscriptionSource=P,i(t,n,o,r,s)}var{isSafari:c,isFirefox:u,isiOS:d}=oe();if(!c&&!u&&!d)return a();var l=document.querySelector("body");return be("This is Safari/Firefox browser. The prompt will only show after the website is clicked somewhere"),new Promise((e=>{l.addEventListener("click",(()=>{a().then(e)}))}))},oldRender(e){var i,{config:n,subscribeCallback:o}=e,r=new K;if(!r.isPermissionNotGranted&&window.Notification&&window.Notification.permission===m.NOTIFICATION_PERMISSION.DEFAULT){if(n.optin.type!==t.OFF){var s=n.optin.config,a=s.timeout,c=a.default,u=n.optin.type,d=s.overlay;ee()&&(c=a.mobile);var l=r.optinSeenCount;-1===c?be('🟠 Optin prompt was not shown. Reason: timeout set to "never"'):l>=s.maxCountPerSession?be("🟠 Optin prompt was not shown. Reason: maximum count per session limit reached (".concat(l," / ").concat(s.maxCountPerSession,")")):Date.now(){Notification.permission!==m.NOTIFICATION_PERMISSION.DEFAULT||L.isPermissionGranted?be("🟠 Optin prompt was not shown. Reason: permission not default"):u===t.TWO_STEP?Promise.all([import("./OptinPrompt-772efb61.js"),import("./NewCustomPrompt-e68b4956.js")]).then((e=>{var[{OptinPromptWidget:t},{NewCustomPromptWidget:i}]=e,{position:a}=s,c=t,u=new c;if(c===i)u.setState(ve(ve({},s),{},{logo:n.logo})),setTimeout((()=>{o(null),u.changeState(ee()?"mobile-fade":"down"),setTimeout(ee()?u.destroy.bind(u):()=>{u.changeState("fade-top"),setTimeout(u.destroy.bind(u),300)},5e3)}),5e3);else{var l=document.querySelector(".pushowl-optin");l&&(Y.logToServer({message:"duplicate custom prompt",subdomain:Y.subdomain,data:{breadcrumbs:he}}),l.remove()),u.setState({multilingual_title:s.multilingual_title,multilingual_description:s.multilingual_description,yesButton:s.yesButton,noButton:s.noButton,theme:s.theme,logo:n.logo,branding:n.branding,position:a,autoFocus:n.flags.custom_prompt_screenreader_support,yesButtonListener:()=>{o(d),setTimeout((()=>{u.destroy()}),100),window.poSubscriptionSource=N,n.optin_report_enabled&&window.poAnalytics.track("PNOptinAllowClicked",{optinSeenCount:r.optinSeenCount})},noButtonListener:()=>{setTimeout((()=>{u.destroy()}),100),r.isPermissionNotGranted=!0,n.optin_report_enabled&&window.poAnalytics.track("PNOptinLaterClicked",{optinSeenCount:r.optinSeenCount})}})}r.optinSeenCount+=1,n.optin_report_enabled&&window.poAnalytics.track("PNOptinShown",{optinSeenCount:r.optinSeenCount}),be("Custom Prompt shown. Config: ",n.optin),at(s.deferForDays)})).catch((e=>{be("Error encountered in loading Optin prompt: ".concat(e.message))})):(this.showNativePrompt({hintScreenConfig:d,subscribeCallback:o}),r.optinSeenCount+=1,be("Browser Prompt shown. Config: ",n.optin),at(s.deferForDays))}),1e3*c)}}else r.isPermissionNotGranted?i="prompt was dismissed in this session":window.Notification&&window.Notification.permission!==m.NOTIFICATION_PERMISSION.DEFAULT&&(i="permission already ".concat(window.Notification.permission)),be("🟠 Optin prompt was not shown. Reason: ".concat(i))},renderPopup:e=>ye((function*(){var{showNextForm:t,deferForDays:i,node:n,shouldIncrementFrequency:o,waitTime:r,flowId:s,openShadowDOM:a}=e;try{var{OptinForm:c}=yield import("./index-73c9f0c0.js"),u=new c(n,t,s,ot({nodeId:n.id,flowId:s,channelType:n.channels,optinType:"popup"}),a);if(setTimeout((()=>u.render()),1e3*r),at(i),o)(new K).optinSeenCount+=1}catch(e){be("Error encountered in loading New Optin: ".concat(e.message))}}))(),showBrowserPrompt(e){var{subscribeCallback:t,hintScreenConfig:i,shouldIncrementFrequency:n,deferForDays:o,waitTime:r,flowId:s,nodeId:a,formId:c}=e;if(We()){rt({event:"optin_viewed",optinType:"browser_webpush",flowId:s,nodeId:a,formId:c});var u=()=>rt({event:"optin_submitted",optinType:"browser_webpush",flowId:s,nodeId:a,formId:c}),d=()=>rt({event:"optin_denied",optinType:"browser_webpush",flowId:s,nodeId:a,formId:c});if(setTimeout((()=>{this.showNativePrompt({hintScreenConfig:i,subscribeCallback:t,source:"optin_flows",nodeId:a,trackWebPushDenied:d,trackWebPushSubmission:u})}),1e3*r),n)(new K).optinSeenCount+=1;at(o)}},showCustomPrompt:e=>ye((function*(){var{waitTime:t,shouldIncrementFrequency:i,flowId:n,deferForDays:o,config:r,subscribeCallback:s,custom_prompt_screenreader_support:a,nodeId:c,formId:u,logo:d}=e;try{if(!We())return;var{OptinPromptWidget:l}=yield import("./OptinPrompt-772efb61.js"),p=()=>rt({event:"optin_submitted",optinType:"custom_webpush",flowId:n,nodeId:c,formId:u}),h=()=>rt({event:"optin_denied",optinType:"custom_webpush",flowId:n,nodeId:c,formId:u}),b=new l,w=new K;if(setTimeout((()=>b.setState(ve(ve({},r),{},{autoFocus:a,yesButtonListener:()=>{s(r.overlay,"optin_flows",c,h,p),setTimeout((()=>{b.destroy()}),100),window.poSubscriptionSource=N},noButtonListener:()=>{h(),setTimeout((()=>{b.destroy()}),100),w.isPermissionNotGranted=!0},logo:d}))),1e3*t),rt({event:"optin_viewed",optinType:"custom_webpush",flowId:n,nodeId:c,formId:u}),at(o),i)(new K).optinSeenCount+=1}catch(e){be("Error encountered in loading Custom prompt: ".concat(e.message))}}))(),processNewConfig(e){var t=e.find((e=>"active"===e.status));if(!t)return[];for(var i=[],n=t.flow_nodes||[],o=0;o"active"===e.status))||{};if(o.flow_nodes){var{flow_nodes:r}=o,{activation_rule:s}=t,a=new K,{optinSeenCount:c}=a,{consent:u}=L,d=o&&r&&(e=>{var{activation_rule:t}=e;return!t||new ke(t).processUrlActivationRule()})({activation_rule:s})&&(e=>{var{deferForDays:t,shouldIncrementFrequency:i}=e;return!(i&&t>0&&Date.now(){var{frequency:t,optinSeenCount:i,shouldIncrementFrequency:n}=e;return!n||i{this.newRender({config:t,shouldIncrementFrequency:!1,subscribeCallback:n})},p=0;p{var i=n=>{be("PermissionData:",n.permission),"default"===n.permission?setTimeout((()=>window.safari.pushNotification.requestPermission(this.webServiceUrl(),this.webPushId,{domain:window.location.origin},i)),0):"denied"===n.permission?t(m.NOTIFICATION_PERMISSION.DENIED):"granted"===n.permission&&e(n.deviceToken)},n=window.safari.pushNotification.permission(this.webPushId);i(n)}))}}class dt{constructor(e){var{vapidPublicKey:t,integrations:i,serviceWorkerConfig:n}=e;this.getSubscription=this.getSubscription.bind(this),this.vapid_public_key=t,this.integrations=i,this.serviceWorkerConfig=n}getServiceWorkerParams(e){return this.serviceWorkerConfig?{url:this.serviceWorkerConfig.url,options:{scope:this.serviceWorkerConfig.scope}}:{url:Y.getServiceWorkerUrlWithIntergrations(Y.serviceWorkerUrl(e),this.integrations),options:{}}}getSubscription(e){return new Promise(((t,i)=>{("granted"===Notification.permission?Promise.resolve("granted"):Notification.requestPermission()).then((n=>{if(n===m.NOTIFICATION_PERMISSION.GRANTED){var o=this.getServiceWorkerParams(e),r=o.options;0!==o.url.indexOf("http")&&(o.url="".concat(location.protocol,"//").concat(location.host).concat(o.url)),navigator.serviceWorker.register(o.url,o.options).then((e=>{var n;"shopify"===Y.platform&&("/"===r.scope?navigator.serviceWorker.getRegistrations().then((function(e){e.forEach((function(e){e.scope.match(/pushowl\/sdks\//)&&(e.unregister(),be("Found stale service worker on subpath scope",e))}))})):navigator.serviceWorker.getRegistrations().then((function(e){e.forEach((function(e){e.active&&e.active.scriptURL.match(/pushowl/)&&!e.scope.match(/pushowl\//)&&(e.unregister(),be("Found stale service worker on root scope",e))}))}))),e.installing?n=e.installing:e.waiting?n=e.waiting:e.active&&(n=e.active),n&&("activated"===n.state?this._serviceWorkerSubscriber(e,t,i):n.addEventListener("statechange",(n=>{"activated"===n.target.state&&this._serviceWorkerSubscriber(e,t,i)})))})).catch((e=>{ge(e),i(e)}))}else n!==m.NOTIFICATION_PERMISSION.DENIED&&n!==m.NOTIFICATION_PERMISSION.DEFAULT||i(n)}))}))}_serviceWorkerSubscriber(e,t,i){var n={userVisibleOnly:!0,applicationServerKey:re(this.vapid_public_key)};e.pushManager.subscribe(n).then((e=>{t(e)})).catch((n=>{n.toString().indexOf("InvalidStateError")>=0?e.pushManager.getSubscription().then((n=>{n.unsubscribe().then((n=>{e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:re(this.vapid_public_key)}).then((e=>{t(e)})).catch((e=>{i(e)}))})).catch((e=>{i(e)}))})):(ge(n),i(n))}))}}class lt{constructor(e){var{flags:t,vapidPublicKey:i,integrations:n,websitePushId:o,wid:r,serviceWorkerConfig:s}=e;if(this.getSubscription=null,oe().isApnsSafari){var a=new ut({websitePushId:o,wid:r});this.getSubscription=a.getSubscription.bind(this,t)}else{var c=new dt({vapidPublicKey:i,integrations:n,serviceWorkerConfig:s});this.getSubscription=c.getSubscription.bind(this,t)}}get isPermissionGranted(){return window.Notification&&window.Notification.permission===m.NOTIFICATION_PERMISSION.GRANTED||L.isPermissionGranted}get isPermissionDefault(){return Y.isWorkerAvailable.then((e=>"default"===window.Notification.permission)).catch((()=>!1))}}function pt(e,t){window.sib&&window.sib[e]?window.sib[e](...t):window.sib.equeue.push({[e]:t})}if(!window.poAnalytics){var ht={storeConfigGUID:Y.guid,subdomain:Y.subdomain,visitorToken:L.visitorToken,sessionToken:L.sessionToken};window.poAnalytics=new Qe({endpoint:"".concat(Y.apiEndpoint,"/event/v1/events")}),window.poAnalytics.setVisitorProperties(ht),be("Analytics initialized with data: ",ht)}class bt extends class{constructor(){}get cartId(){return""}}{constructor(e){super(),this.token=e.token,this.checkout_token=e.checkout_token,this.item_count=e.item_count,this.items=e.items}get cartId(){const e=[this.token||this.checkout_token||""];let t=[];const i={};for(const e of this.items)t.push(e.variant_id),i[e.variant_id]=e.quantity;t=t.sort(((e,t)=>e-t));for(const n of t){const t=i[n];e.push(`${n}:${t}`)}return e.concat(e).join("-")}}var wt={decodeBase64Id(e){if(e&&"string"==typeof e){var t=e.split("::").shift();return window.atob(t).replace(/\?.*/,"").split("/").pop()}return e},detectAjaxCartUpdate(e){var t=window.XMLHttpRequest.prototype.open;window.XMLHttpRequest.prototype.open=function(i,n){this.addEventListener("readystatechange",(function(){var t=i.toUpperCase();("GET"===t&&"/cart/add.js"===n||"POST"===t&&("/cart/add.js"===n||"/cart/update.js"===n||"/cart/change.js"===n))&&4===this.readyState&&"function"==typeof e&&e()})),t.apply(this,arguments)}},detectAjaxCartUpdate2:e=>{var t=window.fetch;window.fetch=function(){var i=arguments.length<=0?void 0:arguments[0],n=t(...arguments);return i.match(/api\/.*\/graphql/)?(n.then((e=>e.clone())).then((t=>{try{t.json().then((t=>{var i;if(t&&t.data&&(t.data.checkoutLineItemsUpdate&&t.data.checkoutLineItemsUpdate.checkout?i=t.data.checkoutLineItemsUpdate.checkout:t.data.checkoutLineItemsAdd&&t.data.checkoutLineItemsAdd.checkout&&(i=t.data.checkoutLineItemsAdd.checkout),i)){var n=i.lineItems.edges.map((e=>({variant_id:parseInt(wt.decodeBase64Id(e.node.variant.id),10),product_id:parseInt(wt.decodeBase64Id(e.node.variant.product.id),10),quantity:e.node.quantity})));"function"==typeof e&&e({checkout_token:wt.decodeBase64Id(i.id),item_count:n.length,items:n,updated_at:(new Date).toISOString()})}}))}catch(e){}})),n):n}},detectAjaxCartUpdate3:e=>{var t=window.fetch;window.fetch=function(){var i=arguments.length<=0?void 0:arguments[0],n="string"==typeof i?i:i instanceof URL?i.pathname:i instanceof Request?i.url:"",o=(arguments.length<=1?void 0:arguments[1])||{},r=o.method||"GET",s=t(...arguments);return("GET"===r&&n.includes("/cart/add")||"POST"===r&&(n.includes("/cart/add")||n.includes("/cart/update")||n.includes("/cart/change")))&&s.then((()=>{e()})),s}},detectBigCAjaxCartUpdate:e=>{var t=window.fetch;window.fetch=function(){var i=(arguments.length<=0?void 0:arguments[0])||"",n=(arguments.length<=1?void 0:arguments[1])||{},o=n.method||"GET",r=t(...arguments);return"POST"===o&&(i.includes("/cart/add")||i.includes("/cart/update"))&&r.then((()=>{e()})),r}},detectBigCAjaxCartUpdate2:e=>{var t=window.XMLHttpRequest.prototype.open;window.XMLHttpRequest.prototype.open=function(i,n){this.addEventListener("readystatechange",(function(){"POST"===i.toUpperCase()&&(n.includes("/cart/add")||n.includes("/cart/update"))&&4===this.readyState&&"function"==typeof e&&e()})),t.apply(this,arguments)}}};class mt extends class{constructor(){var e;this.subdomain=Y.subdomain,this.environment=Y.environment,this.apiEndpoint=Y.apiEndpoint,this.apiClient=new Re,this.webPushId=Y.webPushId,this.config=null,this.storageManager=new L,this.sessionManager=new K,this.storeLib=new(this.getStoreLibClass()),this.subscriberTokenExists=!!L.subscriberToken,this.tokenType=this.subscriberTokenExists?"subscriber":"visitor",this.tokenValue=this.subscriberTokenExists?L.subscriberToken:L.visitorToken,this.customLog=console,window.sessionStorage&&navigator.serviceWorker&&(e=this.getConfig()).then((e=>{this.config=e,(({logoURL:e})=>{try{const t=Object.assign(Object.assign({},tt),{name:document.title,short_name:document.title}),i=document.querySelector('meta[name="theme-color"]');i&&(t.theme_color=i.getAttribute("content")||tt.theme_color);const n=document.querySelector('meta[property="og:site_name"]');if(n){const e=n.getAttribute("content")||document.title;t.name=e,t.short_name=e}const o=document.querySelector('meta[property="og:description"]');o&&(t.description=o.getAttribute("content")||"");const r=JSON.stringify(t),s=new Blob([r],{type:"application/json"}),a=URL.createObjectURL(s),c=document.createElement("link");c.rel="manifest",c.href=a;const u=document.getElementsByTagName("head")[0];document.querySelector("link[rel=manifest]")||u.insertBefore(c,u.firstChild);const d=document.querySelector("link[rel=apple-touch-icon]");if(e&&!d){const t=document.createElement("link");t.rel="apple-touch-icon",t.href=e,u.insertBefore(t,u.firstChild)}}catch(e){be("Unable to create manifest")}})({logoURL:e.logo}),we("Status",{ACR:e.abandoned_cart_enabled?"🟢":"🔴","Browse abandonment":e.browse_abandonment_enabled?"🟢":"🔴","Price drop":e.price_drop.enabled?"🟢":"🔴","Back in stock":e.back_in_stock.enabled?"🟢":"🔴","optin type":{off:"🔴",oneStep:"Browser prompt",twoStep:"Custom prompt"}[e.optin.type],"Notification permission":window.Notification?Notification.permission:null,"Store section":this.getStoreLibClass().section,"Notification Preferences":e.privacy.notification_preference.enabled?"🟢":"🔴"}),this.handleIOS(),this.load3PIntegrations()})),this.ready=new Promise((t=>{this.init(e).then((()=>{if((!this.config.flags||"disabled"!==this.config.flags.status)&&((this.environment!==m.ENVIRONMENT.production||!this.config.flags||!1!==this.config.flags.console_message&&"disabled"!==this.config.flags.console_message)&&this.customLog.log("[PushOwl Web Push Notifications] Starting up"),this.browserHandler=new lt({flags:this.config.flags,vapidPublicKey:this.config.vapid_public_key,integrations:this.config.integrations,websitePushId:this.config.website_push_id,wid:this.config.wid,serviceWorkerConfig:this.config.service_worker}),this.isAllowed())){var e={subdomain:this.subdomain,browserHandler:this.browserHandler,config:this.config,storeLib:this.storeLib,storageManager:this.storageManager,sessionManager:this.sessionManager};this.context=e,this.browserHandler.isPermissionGranted||!L.subscriberToken||L.hasRaisedUnsubscriptionEvent||(this.config.optin_report_enabled&&window.poAnalytics.track("Unsubscribed"),L.hasRaisedUnsubscriptionEvent=!0),this.browserHandler.isPermissionGranted?Je.verifySubscriber({browserHandler:this.browserHandler}).then((()=>{this.syncCustomerId(),this.onSubscriberVerifiedOnPageLoad()})).catch(((e,t)=>{be(e),e===o.NO_SUBSCRIBER_TOKEN||e===o.INVALID_SUBSCRIBER_TOKEN?Je.subscribe({browserHandler:this.browserHandler,websitePushId:this.config.website_push_id}).catch((e=>{ge(e)})):e===o.INVALID_STATE_ERROR&&Je.validateOrSyncSubscription({subscription:t,websitePushId:this.config.website_push_id})})):this.isBrevoEnabled()&&this.onSubscriberVerifiedOnPageLoad(),this.browserHandler.isPermissionDefault.then((e=>{e&&this.handlePushNotificationUnsubscription()})),this.customTasks(),ze.subscribeButtons({context:e}),this.checkPushowlSession(),this.onCanRun(),t()}})).catch((e=>{ge(e)}))})),this.debugCustomTask(),this.onScriptLoad(),G.run()}handlePushNotificationUnsubscription(){var{consent:e}=L;1===e.length&&"webpush"===e[0]&&(L.subscriberToken=null,X.del("pushowl_sw_subscriber_token")),L.isPermissionGranted=!1,L.consent=L.consent.filter((e=>"webpush"!==e))}isBrevoEnabled(){return"enabled"===this.config.flags.brevo_email&&!!this.config.brevo_ma_key}handleIOS(){var e;oe().isiOS&&navigator.standalone&&!L.subscriberToken&&!L.hasLoggediOSStandaloneMode&&(L.hasLoggediOSStandaloneMode=!0),this.isAllowed()&&oe().isiOS&&!navigator.standalone&&K.installPromptSeenCount<3&&!L.installPromptDismissed&&null!==(e=this.config.ios_prompt)&&void 0!==e&&e.enabled&&(import("./IOSInstallWidget-6792b8c3.js").then((e=>{var t,i,{IOSInstallWidget:n}=e,o=new n({title:null===(t=this.config.ios_prompt)||void 0===t?void 0:t.title,description:null===(i=this.config.ios_prompt)||void 0===i?void 0:i.description});setTimeout((()=>{o.init()}),2e3)})),K.installPromptSeenCount+=1)}get flyoutHandler(){return new Promise((e=>{import("./FlyoutWidgetHandler-d32f0bc5.js").then((t=>{var{FlyoutWidgetHandler:i}=t;e(new i(this.config.flyout_config))})).catch((e=>{be("Error encountered in loading Flyout widget: ".concat(e.message))}))}))}onScriptLoad(){}onConfigLoaded(){}onCanRun(){}onSubscriberVerifiedOnPageLoad(){}onSuccessfullSubscription(){}getStoreLibClass(){}getStoreCartClass(){}getCurrentProduct(){}isAllowed(){var{activation_rule:e}=this.config;return!e||e.processUrlActivationRule()}init(e){return new Promise((t=>{this.isEnabled().then((()=>{(e||this.getConfig()).then((e=>{this.config=e,"enabled"===e.flags.subscriber_tracking&&L.subscriberToken&&(window.poAnalytics.setVisitorProperties({wid:this.config.wid,pagePath:window.location.href,pageURL:window.location.origin+window.location.pathname,subscriberToken:L.subscriberToken,browserNotificationPermission:window.Notification?window.Notification.permission:null}),window.poAnalytics.track("subscriber_page_visited")),window.poAnalytics.setVisitorProperties({wid:this.config.wid,optinConfig:this.config.optin}),be("Analytics visitor props set: ",{wid:this.config.wid,optinConfig:this.config.optin}),window.poAnalytics.meta.isNewVisitor&&this.config.optin_report_enabled&&window.poAnalytics.track("SessionCreated"),t(e)}))})).catch((e=>{ge(e),be("🔴 Shutting down. Reason: ".concat(e))}))}))}getConfig(){return qe.get()}isEnabled(){return Ye({subdomain:this.subdomain})}debugCustomTask(){var e=ne("poTaskType");e===O&&(be("Task type",e),this.isEnabled().then((e=>{!function(e){var{subdomain:t,StoreLibClass:i,isEnabled:n}=e,o=m.STORAGE_KEYS,r=new K,s=new L,a=new Re,c={notification_permission:window.Notification&&window.Notification.permission};c.localStorage={[o.VISITOR_TOKEN]:L.visitorToken,[o.SESSION_TOKEN]:L.sessionToken,[o.SUBSCRIBER_TOKEN]:L.subscriberToken,[o.SUBSCRIPTION]:L.subscription,[o.BACK_IN_STOCK_SUBSCRIPTIONS]:s.back_in_stock.subscriptions,[o.PRICE_DROP_SUBSCRIPTIONS]:s.price_drop.subscriptions,[o.SYNCED_CART_JSON]:L.synced_cart_json,[o.SYNCED_CUSTOMER_ID]:L.syncedCustomerId,[o.SYNCED_AC_EVENTS]:L.ac_events,[o.OPTIN_DEFERRED_UNTIL]:L.optinDeferredUntil},c.sessionStorage={[r.subscriptionVerifiedKey]:r.subscriptionVerified,[r.permissionKey]:r.isPermissionNotGranted,[r.optinSeenCountKey]:r.optinSeenCount},c.subdomain=t,c.debug_url=window.location.href,c.user_agent=navigator.userAgent,c.logs=he,Promise.all([new Promise((e=>{navigator.serviceWorker.getRegistrations().then((function(t){e(t.map((function(e){return{scope:e.scope,active:e.active}})))}))})),n,i?i.getCart():Promise.resolve()]).then((e=>{var[t,i,n]=e;n&&(c.current_cart_json=n),t&&t.length&&(c.serviceWorkers=t),"string"==typeof i&&(c.pushowl_not_enabled_reason=i),a.debugLog(c),window.prompt("Send this to PushOwl Support",JSON.stringify(c,!1,2))}))}({subdomain:this.subdomain,StoreLibClass:this.getStoreLibClass(),isEnabled:e})})))}customTasks(){var e=ne("poTaskType");e&&(be("Task type",e),e===I?Je.subscribeIfNotAlready({enableHintScreen:!0,websitePushId:this.config.website_push_id,browserHandler:this.browserHandler}):e===y&&Je.unsubscribe(this.browserHandler))}checkPushowlSession(){"pushowl"===ne("utm_source")&&function(e){var{privacy:t}=e.config;if(t.notification_preference.enabled){var i=document.querySelector("body"),n={subdomain:e.subdomain,subscriberToken:L.subscriberToken};Promise.all([import("./NotificationPreference-99757379.js"),import("./NotificationPreferenceToggle-c006226f.js")]).then((e=>{var[{NotificationPreference:o},{NotificationPreferenceToggle:r}]=e,s=new o(i,n,t.notification_preference);new r(i,t.notification_preference,s).render(),be("Notification Preference shown.")})).catch((e=>{be("Error encountered in loading Notif preferences: ".concat(e.message))}))}}(this.context)}syncCustomerId(){var e=this.getStoreLibClass();if(e.customerId&&e.customerId!==L.syncedCustomerId&&this.config.privacy.customer_id){if(window.Shopify&&!L.subscriberToken){var t=de(m.STORAGE_KEYS.SUBSCRIBER_TOKEN);t&&(L.subscriberToken=t)}this.apiClient.syncSubscriber().then((()=>{L.syncedCustomerId=e.customerId})).catch((()=>{ge("Subscriber not synced")}))}}initiateDefaultPrompt(e,t,i,n,o){var r=!(!e||ee())&&e.enabled;return Y.isWorkerAvailable.then((s=>{if(s)return Je.subscribe({enableHintScreen:r,hintScreenData:e,websitePushId:this.config.website_push_id,browserHandler:this.browserHandler,source:t,source_id:i}).then((e=>{if(e&&e.subscriberToken){var{consent:t}=L;return L.consent=[...t,"webpush"],o&&o(),this.onSuccessfullSubscription(),e}return n&&n(),e})).catch((e=>{})).finally((()=>{var e=document.querySelector(".js-custom-prompt-2");e&&e.remove()}));var a=this.subdomain.replace(/\./g,"-");return window.open("https://".concat(a,".powl.co/subscribe?po_url=").concat(encodeURIComponent(window.location.href),"&env=").concat(this.environment,"&subdomain=").concat(this.subdomain,"&platform=").concat(Y.platform),"","width=700,height=500"),new Promise((e=>{window.addEventListener("message",(t=>{var i=t.data;if(i&&"subscriptionFinish"===i.type){var n=i.data;n&&"granted"===n.status&&(L.subscriberToken=n.subscriberToken,L.isPermissionGranted=!0,e({subscriberToken:n.subscriberToken}))}}))}))}))}render(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.getStoreLibClass();if(!this.config)throw"Pushowl Config not initialised";i.section===v.HOME?this.defaultRender(t):i.section===v.PRODUCT?this.storeLib.getProductDetails(e).then((e=>{this.productSectionRender(e)})):i.section===v.CHECKOUT?be("🟠 Optin prompt was not shown. Reason: Checkout page"):this.defaultRender(t)}optinFlows(e){ct.newRender({config:this.config,shouldIncrementFrequency:e,subscribeCallback:this.initiateDefaultPrompt.bind(this)})}defaultRender(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t={isOptinRendered:!1,isFlyoutRendered:!1};"sendinblue"===Y.platform?ct.oldRender({config:this.config,subscribeCallback:this.initiateDefaultPrompt.bind(this)}):this.optinFlows(e),t.isOptinRendered=!0;var i=this.config.home.flyout;return We()&&i.enabled&&window.Notification.permission!==m.NOTIFICATION_PERMISSION.GRANTED?(this.flyoutHandler.then((e=>{et.renderOptin({rootContext:{config:this.config,browserHandler:this.browserHandler},flyoutHandler:e})})),t.isFlyoutRendered=!0):be("Flyout was not shown. Reason: ".concat(i.enabled?"permission already granted":"flyout is disabled"),"Config: ",this.config.home.flyout),t}productSectionRender(e){if(We()){var t=e.currentVariant();we("Current product",{id:t.id,name:t.name,"Is in stock?":t.available?"✅":"❌",price:t.price});var{back_in_stock:i,price_drop:n}=this.config,o={config:this.config,browserHandler:this.browserHandler};this.flyoutHandler.then((r=>{var s={rootContext:o,flyoutHandler:r,product:e,variant:t};if(!t.available&&i.enabled)et.renderBackInStock(s);else if(t.available&&n.enabled)et.renderPriceDrop(s);else{var{isFlyoutRendered:a}=this.defaultRender();a||r.remove()}}))}}showBrowserPrompt(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{overlay:{enabled:!1}};return ct.showNativePrompt({hintScreenConfig:e,subscribeCallback:e=>this.initiateDefaultPrompt(e)})}showCustomPrompt(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;import("./OptinPrompt-772efb61.js").then((i=>{var{OptinPromptWidget:n}=i,o=this.config.optin.config,r=new n,s={multilingual_title:e.title?{default:e.title}:o.multilingual_title,multilingual_description:e.description?{default:e.description}:o.multilingual_description,yesButton:e.yesButton&&e.yesButton.label?{multilingual_label:{default:e.yesButton.label}}:o.yesButton,noButton:e.noButton&&e.noButton.label?{multilingual_label:{default:e.noButton.label}}:o.noButton};r.setState(ve(ve({},s),{},{theme:e.theme||o.theme,logo:e.logo||o.logo,position:e.position||o.position,autoFocus:this.config.flags.custom_prompt_screenreader_support,yesButtonListener:()=>{t&&(window.poSubscriptionSource=N,this.config.optin_report_enabled&&window.poAnalytics.track("PNOptinAllowClicked",{optinSeenCount:this.sessionManager.optinSeenCount})),this.initiateDefaultPrompt(void 0===e.overlay?o.overlay:e.overlay).then((()=>{"function"==typeof e.yesButtonListener&&e.yesButtonListener()})),setTimeout((()=>{r.destroy()}),100)},noButtonListener:()=>{setTimeout((()=>{r.destroy()}),100),this.sessionManager.isPermissionNotGranted=!0,t&&this.config.optin_report_enabled&&window.poAnalytics.track("PNOptinLaterClicked",{optinSeenCount:this.sessionManager.optinSeenCount}),"function"==typeof e.noButtonListener&&o.noButtonListener()}})),t&&this.config.optin_report_enabled&&window.poAnalytics.track("PNOptinShown",{optinSeenCount:this.sessionManager.optinSeenCount})})).catch((e=>{be("Error encountered in loading Optin Prompt widget (API): ".concat(e.message))}))}load3PIntegrations(){}klaviyoIntegration(){var e=function(){var e=ye((function*(e){var t=e&&e.detail&&e.detail.metaData&&e.detail.metaData.$email;"stepSubmit"===e.detail.type&&t&&(L.email=t,window.sendinblue&&window.sendinblue.identify(t))}));return function(t){return e.apply(this,arguments)}}();window.addEventListener("klaviyoForms",e)}trackPage(e){window.sendinblue&&(e?window.sendinblue.page(e):window.sendinblue.page())}loadBrevoTracker(){if("enabled"===this.config.flags.brevo_email&&this.config.brevo_ma_key&&(window.sib={equeue:[],client_key:this.config.brevo_ma_key},window.sendinblue={ecommerce:{}},L.email&&(window.sib.email_id=L.email),c.forEach((function(e){var t=e.name;e.isEcommerce?window.sendinblue.ecommerce[t]=function(){for(var e=arguments.length,i=new Array(e),n=0;n{!function(e){var{cartJson:t,CartClass:i,options:n={pushowl:!0,brevo:!1}}=e;if(t){var o=new i(t),r=new Re,s=o.token?"token":"checkout_token",a=["Cart Token:",o[s],"Cart Items",o.item_count,"Last synced Cart:",L.synced_cart_json,"AC Events:",L.ac_events],c=L.synced_cart_json,u=c?new i(c):null;t.updated_at=t.updated_at||(new Date).toISOString(),o.item_count>0&&(!u||o.cartId!==u.cartId)||0===o.item_count&&u&&u[s]===o[s]&&u.cartId!==o.cartId?(n.pushowl?r.syncCart(o).then((e=>{L.synced_cart_json=t,L.ac_events=e.result;var{token:i}=e.result;i&&(L.subscriberToken=i),be("Cart synced successfully. Response: ",e)})).catch((e=>{ge(e),be("🔴 Cart sync failed. Error: request failed. ",e,...a)})):L.synced_cart_json=t,n.brevo&&fe(t)):be("Cart was not synced. Reason: No change since last sync.",...a)}}({cartJson:e,CartClass:this.getStoreCartClass(),options:t})})).catch((e=>{ge(e),be("🔴 Cart sync failed. Error: cart could not be synced. ",e)}))}syncCart(e){this.browserHandler.isPermissionGranted&&this.config.abandoned_cart_enabled&&Je.verifySubscriber({browserHandler:this.browserHandler}).then((()=>{this.syncAbandonedCart(e,{pushowl:!0,brevo:this.isBrevoEnabled()})}))}syncProductView(){var e=this.getStoreLibClass(),t=this.config.browse_abandonment_enabled;e.section===v.PRODUCT&&this.getCurrentProduct().then((e=>{this.isBrevoEnabled()&&this.storeLib.getProductDetails().then((t=>{var i=t.currentVariant()||{};$({eventName:a.PRODUCT_VIEWED,eventData:{id:"".concat(e.id),data:ve(ve({},e),{},{title:t.title,featured_image:i.featured_image||t.featured_image,price:i.price||t.price,currency:window.Shopify?window.Shopify.currency.active:"",url:window.location.href})}}),window.sendinblue&&(i?window.sendinblue.ecommerce.viewProduct(String(i.id)):window.sendinblue.ecommerce.viewProduct(String(e.id)))})),t&&L.subscriberToken&&this.apiClient.syncProductView(e).then((e=>{var{token:t}=e.result;t&&(L.subscriberToken=t),be("Product synced",e)})).catch((e=>{ge(e)}))})).catch((e=>{ge(e)}))}subscriberLog(e){var t=Object.entries(e).map((e=>{var[t,i]=e;return"".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(i))})).join("&");return G.get({path:"/log/?".concat(t)})}setCustomerId(e){window.pushowl.customerId=e,this.browserHandler.isPermissionGranted&&Je.verifySubscriber({browserHandler:this.browserHandler}).then((()=>{this.syncCustomerId()}))}setCheckoutId(e){this.browserHandler.isPermissionGranted&&Je.verifySubscriber({browserHandler:this.browserHandler}).then((()=>{this.apiClient.syncSubscriberTokenAndCheckoutId(e)}))}showBackInStock(e,t){this.flyoutHandler.then((i=>{et.renderBackInStock({rootContext:this.context,flyoutHandler:i,product:e,variant:t})}))}showPriceDrop(e,t){this.flyoutHandler.then((i=>{et.renderPriceDrop({rootContext:this.context,flyoutHandler:i,product:e,variant:t})}))}identify(){return arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}}}{onCanRun(){this.processBrevoEmailParam();var{context:e}=this;this.render(),ze.backInStockButtons({context:e,onSuccess:e=>{this.productSectionRender(e)}}),ze.priceDropButtons({context:e,onSuccess:e=>{this.productSectionRender(e)}}),this.initAjaxCartDetection(),this.handleVariantChange(),this.watchForAnyPageChange()}watchForAnyPageChange(){var{pageName:e}=q;return"/"===window.location.pathname?this.trackPage("Homepage"):q.section===v.THANK_YOU?this.trackPage("Thank you"):e?this.trackPage(e):this.trackPage()}watchForViewCategoryPage(){var{collectionName:e,collectionId:t}=q;e&&"all"!==e&&void 0!==t&&window.sendinblue.ecommerce.viewCategory(String(t))}watchForViewSearchPage(){try{if("/search"!==window.location.path)return;var e=decodeURIComponent(window.location.search.replace(/\?q=/,"").replace(/\+/g," "));""!==e&&window.sendinblue.ecommerce.search(e,window.location.href)}catch(e){ge(e)}}processBrevoEmailParam(){try{var e=new URLSearchParams(window.location.search).get("_se"),t=e?window.atob(e):null,i=document.querySelector('meta[name="customer-email"]'),n=i?i.getAttribute("content"):null;t&&t!==L.email?(L.email=t,L.consent=[...L.consent,"email"]):n&&(L.email=n,L.consent=[...L.consent,"email"])}catch(e){be("Error in processing brevo email param",e)}}onSubscriberVerifiedOnPageLoad(){this.syncAbandonedCart(null,{pushowl:this.config.abandoned_cart_enabled,brevo:"enabled"===this.config.flags.brevo_email&&this.config.brevo_ma_key}),this.syncProductView()}onScriptLoad(){this.recoveredCartManager()}onSuccessfullSubscription(){this.render(!1,!1)}getStoreLibClass(){return q}getStoreCartClass(){return bt}getCurrentProduct(){return this.storeLib.getRawCurrentProductDetails()}isEnabled(){return Ye({subdomain:this.subdomain}).then((()=>"undefined"==typeof __st&&void 0===window.Shopify?Promise.reject(n.NOT_SHOPIFY):Promise.resolve()))}initAjaxCartDetection(){if(this.config.abandoned_cart_enabled||"enabled"===this.config.flags.brevo_email){var e=e=>{this.browserHandler.isPermissionGranted?Je.verifySubscriber({browserHandler:this.browserHandler}).then((()=>{be("[AJAX CART] Detected Add to Cart"),this.syncAbandonedCart(e,{brevo:this.isBrevoEnabled(),pushowl:this.config.abandoned_cart_enabled})})):this.isBrevoEnabled()&&this.syncAbandonedCart(e,{brevo:!0,pushowl:!1})};wt.detectAjaxCartUpdate(e),this.config.flags&&this.config.flags.enable_cart_detection_2&&wt.detectAjaxCartUpdate2(e),wt.detectAjaxCartUpdate3(e)}}handleVariantChange(){if(q.section===v.PRODUCT&&(this.config.back_in_stock.enabled||this.config.price_drop.enabled)){var e=document.querySelector('form[action$="cart/add"]'),t=document.querySelector('select[name="id"]');if(!e&&t&&(e=t.closest("form")),!e)return;var i=!1,n=()=>{i||(i=!0,setTimeout((()=>{be("In-page variant change detected"),this.render(),i=!1}),500))};e.addEventListener("change",n),e.onchange||(e.onchange=n)}}load3PIntegrations(){W&&this.loadBrevoTracker(),window.sendinblue&&(this.watchForViewCategoryPage(),this.watchForViewSearchPage()),this.klaviyoIntegration();var e=[];e.length?window.Notification&&window.Notification.permission===m.NOTIFICATION_PERMISSION.GRANTED||navigator.serviceWorker.register("".concat(Y.serviceWorkerUrl(),"&integrations=").concat(e.join(","))):window.Notification&&window.Notification.permission===m.NOTIFICATION_PERMISSION.GRANTED||navigator.serviceWorker.getRegistrations().then((function(e){e.forEach((e=>{e.active&&e.active.scriptURL.match(/pushowl/)&&e.unregister()}))}))}recoveredCartManager(){var e=ne("poCartData");if(e)try{var t=JSON.parse(window.atob(e));q.getCart().then((e=>{if(0===new bt(e).item_count){var{cart:i}=t;se({method:"POST",url:"/cart/update.js",payload:{updates:i}}).then((()=>{be("Cart Update Done"),window.location.href=window.location.origin+window.location.pathname}))}}))}catch(e){ge(e)}}identify(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{email:t,properties:i}=e;t&&(L.email=t,window.sendinblue&&window.sendinblue.identify(t,i||{}))}}var gt=Object.freeze({__proto__:null,PushowlShopify:mt,bootstrap:()=>{if(Y.isDisabled())be("Pushowl is disabled in your store");else{var e=new mt,t=(a=e,c={LOG_LEVELS:s,setLogLevel:e=>{L.logLevel=e,be("Log level set to: ".concat(e))},push(e){a.ready.then((()=>{e()}))},getSubdomain:()=>a.subdomain,isEnabled:()=>a.isEnabled(),subscriberLog:e=>a.subscriberLog(e),subscribe(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return Je.subscribeIfNotAlready({enableHintScreen:e,websitePushId:a.config.website_push_id,browserHandler:a.browserHandler})},registerForEvent(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((s,c)=>{Je.subscribeIfNotAlready({enableHintScreen:t,websitePushId:a.config.website_push_id,browserHandler:a.browserHandler}).then((()=>{a.storeLib.getProductDetails(!1,n.productAlias).then((t=>{var u=n.productVariantId?t.getVariant(n.productVariantId):t.currentVariant(),d=null,l=null;if(e===r.BACK_IN_STOCK)d=m.EVENT_API_PATH.BACK_IN_STOCK,l=a.storageManager.back_in_stock;else{if(e!==r.PRICE_DROP)return void c(o.UNKNOWN_EVENT);d=m.EVENT_API_PATH.PRICE_DROP,l=a.storageManager.price_drop}Je.update(d,{product_id:t.id,product:t,variant:u,source:i.PARTNER_JS_API,permission:window.Notification&&window.Notification.permission}).then((()=>{a.productSectionRender(t),l.subscribe(u);var e={};e[m.STORAGE_KEYS.SUBSCRIBER_TOKEN]=L.subscriberToken,s(e)})).catch((e=>{ge(e)}))}))})).catch((()=>{c({error_code:o.PERMISSION_NOT_GRANTED})}))}))},isProductVariantSubscribed:(e,t)=>"price_drop"===e?a.storageManager.price_drop.isSubscribed({id:t}):"back_in_stock"===e&&a.storageManager.back_in_stock.isSubscribed({id:t}),showBrowserPrompt(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{overlay:{enabled:!1}};return a.showBrowserPrompt(e)},showCustomPrompt(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.overlay=null,a.showCustomPrompt(e)},showWidget(e){var{type:t}=e,i=Te(e,Xe);switch(t){case"browserPrompt":return a.showBrowserPrompt(i);case"customPrompt":return a.showCustomPrompt(i,!0);case"priceDrop":return i.variant.name=i.variant.title,delete i.variant.title,a.showPriceDrop(i.product,i.variant);case"backInStock":return i.variant.name=i.variant.title,delete i.variant.title,a.showBackInStock(i.product,i.variant);case"optinFlows":return a.optinFlows(!0)}},syncCart:e=>(e.item_count=e.items.length,e.items.forEach((e=>{e.variantId&&(e.variant_id=e.variantId,delete e.variantId),e.productId&&(e.product_id=e.productId,delete e.productId)})),e.checkoutToken&&(e.checkout_token=e.checkoutToken,delete e.checkoutToken),a.syncCart(e)),syncPageName:e=>a.syncPageName(e),syncProductView:e=>(e.productId&&(e.product_id=e.productId,delete e.productId),a.syncProductView(e)),setCustomerId:e=>a.setCustomerId(e),setCheckoutId:e=>a.setCheckoutId(e),getCurrentPermission:()=>L.isPermissionGranted?Promise.resolve(m.NOTIFICATION_PERMISSION.GRANTED):window&&window.Notification?Promise.resolve(Notification.permission):void 0,identify:e=>a.identify(e),trackCategoryPage:e=>a.trackCategoryPage(e)},u={get(e,t){if(!e[t]&&a[t]){be("🟠 Internal property accessed: ".concat(t));var i=a[t];return"function"==typeof i?i.bind(a):i}return Reflect.get(...arguments)}},new Proxy(c,u)),n=[];window.pushowl&&(Array.isArray(window.pushowl)?be("Existing PushOwl found in queue mode with following tasks queued: ",n=window.pushowl):be("Existing PushOwl found and will be reused. Pushowl seems to be loading twice on this page. Please check page source.")),window.pushowl&&!Array.isArray(window.pushowl)||(window.poSubscriptionSource="",window.pushowl=t,be("PushOwl instance created"),K.windowVariablesForOwly=window.pushowlSubdomain),n.length&&e.ready.then((()=>{be("PushOwl ready to execute API functions."),n.forEach((e=>e())),be("Tasks from PushOwl queue executed. No. of tasks: ".concat(n.length))}))}var a,c,u}});export{Re as A,g as P,L as S,p as _,K as a,ee as b,me as c,be as d,oe as e,m as f,Q as g,st as h,pe as i,gt as j,Z as p};