{"version":3,"sources":["webpack:///./node_modules/@capacitor/local-notifications/dist/esm/web.js"],"names":["LocalNotificationsWeb","super","arguments","this","pending","deliveredNotifications","hasNotificationSupport","window","Notification","requestPermission","permission","e","name","deliveredSchemas","notification","deliveredSchema","title","id","parseInt","tag","body","push","notifications","delivered","toRemove","found","find","n","String","close","filter","unimplemented","options","unavailable","sendNotification","map","display","checkPermissions","value","transformNotificationPermission","_a","now","Date","getTime","schedule","at","buildNotification","diff","setTimeout","sendPending","localNotification","addEventListener","onClick","bind","onShow","data","actionId","notifyListeners"],"mappings":"kHAAA,6EACO,MAAMA,UAA8B,OACvC,cACIC,SAASC,WACTC,KAAKC,QAAU,GACfD,KAAKE,uBAAyB,GAC9BF,KAAKG,uBAAyB,KAC1B,KAAM,iBAAkBC,UAAYC,aAAaC,kBAC7C,OAAO,EAEX,GAAgC,YAA5BD,aAAaE,WAGb,IACI,IAAIF,aAAa,IAErB,MAAOG,GACH,GAAc,aAAVA,EAAEC,KACF,OAAO,EAInB,OAAO,GAGf,kCACI,MAAMC,EAAmB,GACzB,IAAK,MAAMC,KAAgBX,KAAKE,uBAAwB,CACpD,MAAMU,EAAkB,CACpBC,MAAOF,EAAaE,MACpBC,GAAIC,SAASJ,EAAaK,KAC1BC,KAAMN,EAAaM,MAEvBP,EAAiBQ,KAAKN,GAE1B,MAAO,CACHO,cAAeT,GAGvB,mCAAmCU,GAC/B,IAAK,MAAMC,KAAYD,EAAUD,cAAe,CAC5C,MAAMG,EAAQtB,KAAKE,uBAAuBqB,KAAKC,GAAKA,EAAER,MAAQS,OAAOJ,EAASP,KACpE,OAAVQ,QAA4B,IAAVA,GAA4BA,EAAMI,QACpD1B,KAAKE,uBAAyBF,KAAKE,uBAAuByB,OAAO,KAAOL,IAGhF,wCACI,IAAK,MAAMX,KAAgBX,KAAKE,uBAC5BS,EAAae,QAEjB1B,KAAKE,uBAAyB,GAElC,sBACI,MAAMF,KAAK4B,cAAc,2BAE7B,sBACI,MAAM5B,KAAK4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AAiBA,GACb,IAAI0B,EACJ,GAAqC,QAAhCA,EAAK1B,EAAa8B,gBAA6B,IAAPJ,OAAgB,EAASA,EAAGK,GAAI,CACzE,MAAME,EAAOjC,EAAa8B,SAASC,GAAGF,WAAY,IAAID,MAAOC,UAK7D,OAJAxC,KAAKC,QAAQiB,KAAKP,QAClBkC,WAAW,KACP7C,KAAK8C,eACNF,GAGP5C,KAAK2C,kBAAkBhC,GAE3B,kBAAkBA,GACd,MAAMoC,EAAoB,IAAI1C,aAAaM,EAAaE,MAAO,CAC3DI,KAAMN,EAAaM,KACnBD,IAAKS,OAAOd,EAAaG,MAQ7B,OANAiC,EAAkBC,iBAAiB,QAAShD,KAAKiD,QAAQC,KAAKlD,KAAMW,IAAe,GACnFoC,EAAkBC,iBAAiB,OAAQhD,KAAKmD,OAAOD,KAAKlD,KAAMW,IAAe,GACjFoC,EAAkBC,iBAAiB,QAAS,KACxChD,KAAKE,uBAAyBF,KAAKE,uBAAuByB,OAAO,KAAO3B,QACzE,GACHA,KAAKE,uBAAuBgB,KAAK6B,GAC1BA,EAEX,QAAQpC,GACJ,MAAMyC,EAAO,CACTC,SAAU,MACV1C,gBAEJX,KAAKsD,gBAAgB,mCAAoCF,GAE7D,OAAOzC,GACHX,KAAKsD,gBAAgB,4BAA6B3C","file":"js/chunk-2d0bd7bb.4d86569b.js","sourcesContent":["import { WebPlugin } from '@capacitor/core';\nexport class LocalNotificationsWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.pending = [];\n this.deliveredNotifications = [];\n this.hasNotificationSupport = () => {\n if (!('Notification' in window) || !Notification.requestPermission) {\n return false;\n }\n if (Notification.permission !== 'granted') {\n // don't test for `new Notification` if permission has already been granted\n // otherwise this sends a real notification on supported browsers\n try {\n new Notification('');\n }\n catch (e) {\n if (e.name == 'TypeError') {\n return false;\n }\n }\n }\n return true;\n };\n }\n async getDeliveredNotifications() {\n const deliveredSchemas = [];\n for (const notification of this.deliveredNotifications) {\n const deliveredSchema = {\n title: notification.title,\n id: parseInt(notification.tag),\n body: notification.body,\n };\n deliveredSchemas.push(deliveredSchema);\n }\n return {\n notifications: deliveredSchemas,\n };\n }\n async removeDeliveredNotifications(delivered) {\n for (const toRemove of delivered.notifications) {\n const found = this.deliveredNotifications.find(n => n.tag === String(toRemove.id));\n found === null || found === void 0 ? void 0 : found.close();\n this.deliveredNotifications = this.deliveredNotifications.filter(() => !found);\n }\n }\n async removeAllDeliveredNotifications() {\n for (const notification of this.deliveredNotifications) {\n notification.close();\n }\n this.deliveredNotifications = [];\n }\n async createChannel() {\n throw this.unimplemented('Not implemented on web.');\n }\n async deleteChannel() {\n throw this.unimplemented('Not implemented on web.');\n }\n async listChannels() {\n throw this.unimplemented('Not implemented on web.');\n }\n async schedule(options) {\n if (!this.hasNotificationSupport()) {\n throw this.unavailable('Notifications not supported in this browser.');\n }\n for (const notification of options.notifications) {\n this.sendNotification(notification);\n }\n return {\n notifications: options.notifications.map(notification => ({\n id: notification.id,\n })),\n };\n }\n async getPending() {\n return {\n notifications: this.pending,\n };\n }\n async registerActionTypes() {\n throw this.unimplemented('Not implemented on web.');\n }\n async cancel(pending) {\n this.pending = this.pending.filter(notification => !pending.notifications.find(n => n.id === notification.id));\n }\n async areEnabled() {\n const { display } = await this.checkPermissions();\n return {\n value: display === 'granted',\n };\n }\n async requestPermissions() {\n if (!this.hasNotificationSupport()) {\n throw this.unavailable('Notifications not supported in this browser.');\n }\n const display = this.transformNotificationPermission(await Notification.requestPermission());\n return { display };\n }\n async checkPermissions() {\n if (!this.hasNotificationSupport()) {\n throw this.unavailable('Notifications not supported in this browser.');\n }\n const display = this.transformNotificationPermission(Notification.permission);\n return { display };\n }\n transformNotificationPermission(permission) {\n switch (permission) {\n case 'granted':\n return 'granted';\n case 'denied':\n return 'denied';\n default:\n return 'prompt';\n }\n }\n sendPending() {\n var _a;\n const toRemove = [];\n const now = new Date().getTime();\n for (const notification of this.pending) {\n if (((_a = notification.schedule) === null || _a === void 0 ? void 0 : _a.at) &&\n notification.schedule.at.getTime() <= now) {\n this.buildNotification(notification);\n toRemove.push(notification);\n }\n }\n this.pending = this.pending.filter(notification => !toRemove.find(n => n === notification));\n }\n sendNotification(notification) {\n var _a;\n if ((_a = notification.schedule) === null || _a === void 0 ? void 0 : _a.at) {\n const diff = notification.schedule.at.getTime() - new Date().getTime();\n this.pending.push(notification);\n setTimeout(() => {\n this.sendPending();\n }, diff);\n return;\n }\n this.buildNotification(notification);\n }\n buildNotification(notification) {\n const localNotification = new Notification(notification.title, {\n body: notification.body,\n tag: String(notification.id),\n });\n localNotification.addEventListener('click', this.onClick.bind(this, notification), false);\n localNotification.addEventListener('show', this.onShow.bind(this, notification), false);\n localNotification.addEventListener('close', () => {\n this.deliveredNotifications = this.deliveredNotifications.filter(() => !this);\n }, false);\n this.deliveredNotifications.push(localNotification);\n return localNotification;\n }\n onClick(notification) {\n const data = {\n actionId: 'tap',\n notification,\n };\n this.notifyListeners('localNotificationActionPerformed', data);\n }\n onShow(notification) {\n this.notifyListeners('localNotificationReceived', notification);\n }\n}\n//# sourceMappingURL=web.js.map"],"sourceRoot":""}