"use strict";(self.webpackChunkapp_container=self.webpackChunkapp_container||[]).push([[5906],{5906:(i,o,n)=>{n.a(i,(async(i,e)=>{try{n.r(o),n.d(o,{requestNotificationPermission:()=>u,sendSubscriptionToServer:()=>d,urlBase64ToUint8Array:()=>l});const t=await n.e(1139).then(n.bind(n,1139)).then((i=>i.LinkUser));function l(i){const o=(i+"=".repeat((4-i.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(o),e=new Uint8Array(n.length);for(let i=0;i{var o,n,e;const t="-1"!==(null===(o=window)||void 0===o||null===(o=o.flitsThemeAppExtensionObjects)||void 0===o||null===(o=o.customer)||void 0===o?void 0:o.customer_id)&&""!==(null===(n=window)||void 0===n||null===(n=n.flitsThemeAppExtensionObjects)||void 0===n||null===(n=n.customer)||void 0===n?void 0:n.customer_id);return!!(!t&&Object.keys(i).length<=0||t&&(Object.keys(i).length<=0||!i[null===(e=window)||void 0===e||null===(e=e.flitsThemeAppExtensionObjects)||void 0===e||null===(e=e.customer)||void 0===e?void 0:e.customer_id]))};async function d(i,o,n,e,l){var d,u,c,r,v,a;if(!s(null!==(d=o("Notification"))&&void 0!==d?d:{}))return;let p={event:"notification_registration",permission:"granted",subscription_info:i};var m;"-1"!==(null===(u=window)||void 0===u||null===(u=u.flitsThemeAppExtensionObjects)||void 0===u||null===(u=u.customer)||void 0===u?void 0:u.customer_id)&&""!==(null===(c=window)||void 0===c||null===(c=c.flitsThemeAppExtensionObjects)||void 0===c||null===(c=c.customer)||void 0===c?void 0:c.customer_id)&&(p.customer_id=null===(m=window)||void 0===m||null===(m=m.flitsThemeAppExtensionObjects)||void 0===m||null===(m=m.customer)||void 0===m?void 0:m.customer_id);const w=await e.notification.subscribeInfo(p,l);let h=null!==(r=o("Notification"))&&void 0!==r?r:{};var f,b,_,A;w&&(h={...h,[null===(f=window)||void 0===f||null===(f=f.flitsThemeAppExtensionObjects)||void 0===f||null===(f=f.customer)||void 0===f?void 0:f.customer_id]:{userId:w,shopDomain:null===(b=window)||void 0===b||null===(b=b.location)||void 0===b?void 0:b.host,subscription:i,customerId:null===(_=window)||void 0===_||null===(_=_.flitsThemeAppExtensionObjects)||void 0===_||null===(_=_.customer)||void 0===_?void 0:_.customer_id}},n("Notification",h)),"-1"!==(null===(v=window)||void 0===v||null===(v=v.flitsThemeAppExtensionObjects)||void 0===v||null===(v=v.customer)||void 0===v?void 0:v.customer_id)&&""!==(null===(a=window)||void 0===a||null===(a=a.flitsThemeAppExtensionObjects)||void 0===a||null===(a=a.customer)||void 0===a?void 0:a.customer_id)&&t(n,h,e,h[null===(A=window)||void 0===A||null===(A=A.flitsThemeAppExtensionObjects)||void 0===A||null===(A=A.customer)||void 0===A?void 0:A.customer_id],l)}const u=async(i,o,n,e)=>{try{n("NotificationPrompt",(new Date).getTime()),Notification.requestPermission().then((async function(t){var s,u,c,r,v;"granted"===t&&(null!==(s=window)&&void 0!==s&&null!==(s=s.navigator)&&void 0!==s&&s.standalone&&n("isCustomPromptAlreadyAllowd","true"),navigator.serviceWorker.register("/apps/".concat(null===(u=window)||void 0===u||null===(u=u.flitsThemeAppExtensionObjects)||void 0===u?void 0:u.proxy_name,"/api/1/").concat(null===(c=window)||void 0===c||null===(c=c.flitsThemeAppExtensionObjects)||void 0===c?void 0:c.shop_id,"/notifications/web_push/service_worker.js?token=").concat(null===(r=window)||void 0===r||null===(r=r.flitsThemeAppExtensionObjects)||void 0===r?void 0:r.shop_token,"&theme_id=").concat(null===(v=window)||void 0===v||null===(v=v.flitsThemeAppExtensionObjects)||void 0===v||null===(v=v.theme)||void 0===v?void 0:v.id)).then((function(t){t.pushManager.getSubscription().then((async function(s){s?d(s,o,n,i,e):t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:l("BMrMbGJXWgHltXsPCtghebExtKhu1FsjJ5DFORr_yWqw6dyx7Aseno0DO_2atslR4rBbLiKo7qqzCvVuyj9qO6Q")}).then((async function(t){d(t,o,n,i,e)})).catch((function(i){}))}))})))}))}catch(i){}};e()}catch(c){e(c)}}),1)}}]);