1import b from"./Modal.4f38c16e.js";import{n as p,h as o,E as l}from"./vehicleNavigationOverlay.700ee384.js";import{firebaseWebNotificationHelpers as v}from"./firebaseWebNotificationHelpers.3124b5ac.js";import{o as c}from"./index.esm2017.50677bc7.js";import{y as g,l as w,m as d,a as f,C as u}from"./vendor.3765fd31.js";import{N as h,A as _,I as N}from"./index.048b20d9.js";const a=g("PushNotifications",{});var m;(function(t){t[t.Sunday=1]="Sunday",t[t.Monday=2]="Monday",t[t.Tuesday=3]="Tuesday",t[t.Wednesday=4]="Wednesday",t[t.Thursday=5]="Thursday",t[t.Friday=6]="Friday",t[t.Saturday=7]="Saturday"})(m||(m={}));const S=g("LocalNotifications",{web:()=>import("./web.688553c0.js").then(t=>new t.LocalNotificationsWeb)}),P={props:["browser"],async beforeCreate(){this.isDesktop=await o.methods.getOs()==="windows"||await o.methods.getOs()==="mac"},computed:{browserScreenShotsPaths(){var t;return(t=this.$data.browserScreenShots[this.browser.toLowerCase()])!=null?t:!1}},data(){return{browserScreenShots:{chrome:["/assets/img/browser-notification-enabling/chrome-blocked-1.png","/assets/img/browser-notification-enabling/chrome-blocked-2.png"],firefox:["/assets/img/browser-notification-enabling/firefox-blocked-1.png","/assets/img/browser-notification-enabling/firefox-blocked-2.png"],edge:["/assets/img/browser-notification-enabling/edge-blocked-1.png","/assets/img/browser-notification-enabling/edge-blocked-2.png"],safari:["/assets/img/browser-notification-enabling/safari-blocked.png"],firefoxandroid:[],firefoxios:[],edgeandroid:[],edgeios:[],chromeandroid:[],chromeios:[],opera:[],operaandroid:[],operaios:[],androidapp:[],iosapp:[]},isDesktop:null}}};var y=function(){var e=this,i=e._self._c;return i("div",[i("p",[e._v(e._s(e.browser==="iOSApp"||e.browser==="AndroidApp"?e.$t("To ensure you receive timely reminders about your saved events, please activate notifications in your device\u2019s settings. Here\u2019s how to do it:"):e.$t("To receive the reminders you've set for your car, please manually enable notifications.")))]),e.isDesktop?e._e():i("div",[e.browser==="iOSApp"?i("div",{staticClass:"mb-4"},[i("ol",[i("li",[e._v("1. "+e._s(e.$t("Open Settings on your device.")))]),i("li",[e._v("2. "+e._s(e.$t("Scroll down to Apps, and tap on WEBCAR.")))]),i("li",[e._v("3. "+e._s(e.$t('Select "Notifications".')))]),i("li",[e._v("4. "+e._s(e.$t('Toggle on "Allow Notifications."')))])]),i("p",[e._v(e._s(e.$t("Note: On certain iOS versions, you can also manage notifications from Settings > Notifications > WEBCAR.")))])]):e._e(),e.browser==="AndroidApp"?i("div",{staticClass:"mb-4"},[i("ol",[i("li",[e._v("1. "+e._s(e.$t("Open Settings on your device.")))]),i("li",[e._v("2. "+e._s(e.$t('Scroll to and tap "Apps" or "Applications."')))]),i("li",[e._v("3. "+e._s(e.$t("Find and select WEBCAR.")))]),i("li",[e._v("4. "+e._s(e.$t('Tap "Notifications" or "App Notifications."')))]),i("li",[e._v("5. "+e._s(e.$t('Toggle on "Allow Notifications" (or ensure that notifications are enabled).')))])]),i("p",[e._v(e._s(e.$t("Note: On some Android devices, the path may differ slightly. If you don\u2019t see these options, you might need to go to Settings > Notifications directly.")))])]):e._e()]),e._l(e.browserScreenShotsPaths,function(s){return e.browserScreenShotsPaths?i("div",{staticClass:"text-center mb-4"},[i("img",{directives:[{name:"lazy",rawName:"v-lazy",value:s,expression:"path"}],staticClass:"w-100",attrs:{alt:e.browser}})]):e._e()})],2)},A=[],T=p(P,y,A,!1,null,null,null,null);const O=T.exports,k={components:{Modal:b,PushNotificationsBrowserHelp:O},data(){return{firebaseWebNotificationsApp:null,firebaseWebNotificationsMessaging:null,isWebPermissionDenied:null,isEdgeBrowser:null,frontNotifications:[]}},computed:{canEnableNotificationWithPrompt(){return typeof navigator.serviceWorker<"u"&&this.isWebPermissionDenied!==!0&&o.methods.isWebPlatform()},isMobileApp(){return!o.methods.isWebPlatform()}},async mounted(){await this.setUpPushNotifications(),l.$on("USER_LOGGED_IN",this.setUpPushNotifications),l.$on("NOTIFICATION_SAVED",this.notificationSavedCallback),o.methods.isWebPlatform()?this.$messaging&&c(this.$messaging,t=>{this.frontNotifications.push(t)}):await this.addMobilePushNotificationListeners()},beforeDestroy(){l.$off("USER_LOGGED_IN",this.setUpPushNotifications),l.$off("NOTIFICATION_SAVED",this.notificationSavedCallback)},methods:{notificationSavedCallback(){!this.$page.props.auth.user||(this.$page.props.auth.user.last_notification_updated_at=new Date().toISOString(),this.setUpPushNotifications())},async setUpPushNotifications(){!this.shouldSetupPushNotifications()||(o.methods.isWebPlatform()?o.methods.isWebPlatform()&&(await this.handleWebNotificationSetup(),this.$messaging&&c(this.$messaging,t=>{this.frontNotifications.push(t)})):(await this.addMobilePushNotificationListeners(),await this.registerMobilePushNotifications(),o.methods.isAndroid()&&await this.createMyCarsNotificationChannel
1()))},shouldSetupPushNotifications(){return this.$page.props.auth.user!==null&&this.$page.props.auth.user.last_notification_updated_at!==null},showModal(){this.$root.$emit("bv::show::modal","requestPermissionsModal")},hideModal(){this.$root.$emit("bv::hide::modal","requestPermissionsModal")},saveDenialAndHideModal(){this.saveNotificationPermissionDeniedTime(),this.hideModal()},async requestWebPermission(){Notification.requestPermission().then(t=>{t==="granted"?this.handleWebTokenSave():this.saveNotificationPermissionDeniedTime(),this.hideModal()})},async handleWebNotificationSetup(){if(this.detectBrowser()==="Edge"&&(this.isEdgeBrowser=!0),Notification.permission==="granted"){await this.handleWebTokenSave();return}await this.shouldAskForNotificationPermission()!==!1&&(Notification.permission==="denied"&&(this.isWebPermissionDenied=!0),this.showModal())},async handleWebTokenSave(){var i,s;const t=await v.methods.getFirebaseToken(this.$messaging,"BOAEYIwEiVrkIKXwiWWrcMzNnmD6hnxVJt3T0xl9uqtlCW1e-xYGhKqDfYBU49GdAS2r0nq5JAZ3ZNt0EseXAAk"),e=(s=(i=this.$page.props.auth)==null?void 0:i.user)==null?void 0:s.id;await this.shouldSavePushToken(t,e)===!0&&this.savePushTokenToServer(t,e)},async shouldAskForNotificationPermission(){var e,i;if(!this.$page.props.auth.user||((e=this.$page.props.auth.user)==null?void 0:e.last_notification_updated_at)===null)return!1;const t=await this.getNotificationPermissionDeniedTime();return w.exports.isEmpty(t)?!0:d.utc((i=this.$page.props.auth.user)==null?void 0:i.last_notification_updated_at).local().isAfter(d(t))},saveNotificationPermissionDeniedTime(){o.methods.isWebPlatform()?localStorage.setItem("notificationPermissionDeniedTime",new Date().toISOString()):o.methods.storeObjectInStorage("notificationPermissionDeniedTime",new Date().toISOString())},async getNotificationPermissionDeniedTime(){return o.methods.isWebPlatform()?localStorage.getItem("notificationPermissionDeniedTime"):await o.methods.getObjectFromStorage("notificationPermissionDeniedTime")},async registerMobilePushNotifications(){let t=await a.checkPermissions();if(t.receive==="prompt"){if(await this.shouldAskForNotificationPermission()===!1)return;if(t=await a.requestPermissions(),t.receive!=="granted"){this.saveNotificationPermissionDeniedTime();return}}if(t.receive!=="granted"){await this.shouldAskForNotificationPermission()!==!1&&this.showModal();return}let e=await S.areEnabled(),i=await o.methods.getAndroidVersion();i>0&&i<13&&e.value===!1&&this.showModal(),await a.register()},async createMyCarsNotificationChannel(){await a.createChannel({id:"myCars-channel",name:"My Cars",description:"The channel for My Cars notifications",importance:5,visibility:1})},async addMobilePushNotificationListeners(){await a.addListener("registration",t=>{o.methods.storeObjectInStorage("pushToken",{value:t.value}),this.savePushToken(t.value)}),await a.addListener("registrationError",t=>{console.error("Registration error: ",t.error)}),await a.addListener("pushNotificationReceived",t=>{let e=this.getPathFromMobileNotificationData(t.data);f.get(e)}),await a.addListener("pushNotificationActionPerformed",t=>{t&&t.actionId==="tap"&&t.notification.data.pageToOpen&&this.openPathFromNotification(t.notification.data)})},async savePushToken(t=null){var i,s,n;if(t===null){let r=await o.methods.getObjectFromStorage("pushToken");r=(i=r==null?void 0:r.value)!=null?i:null}if(t===null)return;const e=(n=(s=this.$page.props.auth.user)==null?void 0:s.id)!=null?n:null;await this.shouldSavePushToken(t,e)===!0&&this.savePushTokenToServer(t,e)},async savePushTokenToServer(t,e){await f.post(this.bffPath("/user-notification-token"),{userId:e,tokenType:u.getPlatform()==="ios"?"apns":"fcm",tokenValue:t,platform:u.getPlatform(),browser:this.detectBrowser(),os:await this.detectOS(),osVersion:await this.getOsVersion()}).then(i=>{i.data.tokensFromDatabase&&this.storePushTokensReturnedFromServer(i.data.tokensFromDatabase)})},async storePushTokensReturnedFromServer(t){o.methods.isWebPlatform()?localStorage.pushTokens=JSON.stringify(t):o.methods.storeObjectInStorage("pushTokens",t)},async shouldSavePushToken(t,e){var s;if(!t===0||!t)return!1;let i=o.methods.isWebPlatform()?await JSON.parse((s=localStorage.pushTokens)!=null?s:"{}"):await o.methods.getObjectFromStorage("pushTokens");if(i&&i.length>0){let n=i.find(r=>r.fcm_token===t||r.apns_token===t);if(e!==null&&n&&n.user_id!==e)return!0;
1if(n&&n.updated_at&&new Date(n.updated_at).getTime()>new Date().getTime()-1e3*60*60*24)return!1}return!0},openPathFromNotification(t){this.openUrl(null,this.getPathFromMobileNotificationData(t))},getPathFromMobileNotificationData(t){if(!t.pageToOpen)return;let e=this.$pages.get(t.pageToOpen).path();return t.routeParameters&&t.routeParameters.split("|").forEach(s=>{e=e.replace("{"+s+"?}",t[s]).replace("{"+s+"}",t[s])}),t.queryParameters&&(e+=e.includes("?")?"&":"?",t.queryParameters.split("|").forEach(s=>{e+=s+"="+t[s]+"&"}),e=e.slice(0,-1)),e},detectBrowser(){if(o.methods.isIOS())return"iOSApp";if(o.methods.isAndroid())return"AndroidApp";const t=navigator.userAgent;return t.includes("Firefox")&&t.includes("Android")?"FirefoxAndroid":t.includes("Firefox")&&t.includes("like Mac OS")?"FirefoxIOS":t.includes("Firefox")?"Firefox":t.includes("Edg")&&t.includes("Android")?"EdgeAndroid":t.includes("Edg")&&t.includes("like Mac OS")?"EdgeIOS":t.includes("Edg")?"Edge":t.includes("Chrome")&&t.includes("Android")?"ChromeAndroid":t.includes("Chrome")&&t.includes("like Mac OS")?"ChromeIOS":t.includes("Chrome")?"Chrome":t.includes("Safari")&&!t.includes("Chrome")?"Safari":t.includes("Opera")&&t.includes("Android")?"OperaAndroid":t.includes("Opera")&&t.includes("like Mac OS")?"OperaIOS":t.includes("Opera")||t.includes("OPR")?"Opera":t.includes("MSIE")||t.includes("Trident")?"InternetExplorer":"UnknownBrowser"},async detectOS(){return await o.methods.getOs()},frontNotificationClicked(t){this.openPathFromNotification(t.data),this.removeAllFrontNotifications()},removeNotificationFromFrontNotifications(t){this.frontNotifications=this.frontNotifications.filter(e=>e!==t)},removeAllFrontNotifications(){this.frontNotifications=[]},async getOsVersion(){return o.methods.isWebPlatform()?null:await o.methods.getOsVersion()},async openSettings(){o.methods.isAndroid()?await h.openAndroid({option:_.ApplicationDetails}):o.methods.isIOS()?await h.openIOS({option:N.App}):this.hideModal()}}};var C=function(){var e=this,i=e._self._c;return i("div",[i("Modal",{attrs:{"modal-id":"requestPermissionsModal","modal-size":"lg"},scopedSlots:e._u([{key:"mainCaption",fn:function(){return[i("h4",{staticClass:"modal-title text-break no-hyphen mr-3"},[e._v(e._s(e.$t("Enable notifications")))])]},proxy:!0},{key:"body",fn:function(){return[e.canEnableNotificationWithPrompt?i("div",[i("p",[e._v(e._s(e.$t("Please enable notifications to receive the reminders you've set for your car.")))]),e.isEdgeBrowser?i("div",{staticClass:"text-center mb-4"},[i("img",{directives:[{name:"lazy",rawName:"v-lazy",value:"/assets/img/browser-notification-enabling/edge-prompt.png",expression:"'/assets/img/browser-notification-enabling/edge-prompt.png'"}],attrs:{alt:"Edge Prompt"}}),i("img",{directives:[{name:"lazy",rawName:"v-lazy",value:"/assets/img/browser-notification-enabling/edge-bell.png",expression:"'/assets/img/browser-notification-enabling/edge-bell.png'"}],attrs:{alt:"Edge Bell"}})]):e._e()]):i("PushNotificationsBrowserHelp",{attrs:{browser:e.detectBrowser()}})]},proxy:!0},{key:"footer",fn:function(){return[e.canEnableNotificationWithPrompt?[i("div",{staticClass:"btn-group flex-wrap justify-content-end w-100"},[i("button",{staticClass:"btn btn-link mr-2",attrs:{type:"button"},on:{click:e.saveDenialAndHideModal}},[e._v(e._s(e.$t("No Thanks")))]),i("button",{staticClass:"btn btn-secondary",on:{click:function(s){return s.preventDefault(),s.stopPropagation(),e.requestWebPermission.apply(null,arguments)}}},[e._v(e._s(e.$t("Allow Notifications")))])])]:[i("button",{staticClass:"btn btn-link mr-2",attrs:{type:"button"},on:{click:e.saveDenialAndHideModal}},[e._v(e._s(e.$t("No Thanks")))]),i("button",{staticClass:"btn btn-secondary",attrs:{type:"button"},on:{click:e.openSettings}},[e._v(e._s(e.isMobileApp?e.$t("Settings"):e.$t("OK")))])]]},proxy:!0}])}),e.frontNotifications.length>0?i("div",{staticClass:"web-push-notification-container"},e._l(e.frontNotifications,function(s){return i("b-card",{key:s.notification.title+Math.random().toString(16).slice(2),staticClass:"front-notification-card overflow-hidden mb-3",attrs:{"no-body":""},on:{click:function(n){return e.frontNotificationClicked(s)}}},[i("b-row",{attrs:{"no-gutters":""}},[s.notification.image?i("b-col",{staticClass:"py-3 pl-3 notification-img",attrs:{cols:"3"}},[i("b-card-img",{staticClass:"notification-close rounded-0",attrs:{src:s.notification.image,alt:"Image"}}
1)],1):e._e(),i("b-col",{attrs:{cols:"9"}},[i("button",{staticClass:"close p-3",attrs:{type:"button"},on:{click:function(n){return e.removeNotificationFromFrontNotifications(s)}}},[i("svg",{staticClass:"icon-muted icon-hw-16"},[i("use",{attrs:{"xlink:href":"#icon-close"}})])]),i("b-card-body",{staticClass:"px-3 pt-2 mb-3"},[i("b",[e._v(e._s(s.notification.title))]),i("p",{staticClass:"mb-0"},[e._v(e._s(s.notification.body))])])],1)],1)],1)}),1):e._e()],1)},$=[],M=p(k,C,$,!1,null,null,null,null);const B=M.exports;export{B as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.