Files
doneit-web/.angular/cache/14.2.12/babel-webpack/f17e39771b743bc21933a99f763edef7.json
T
Eudes Inácio 53b71ea16f its working
2023-06-30 09:54:21 +01:00

1 line
204 KiB
JSON

{"ast":null,"code":"import '@firebase/installations';\nimport { Component } from '@firebase/component';\nimport { ErrorFactory } from '@firebase/util';\nimport { __spreadArray, __read, __awaiter, __generator, __assign, __values } from 'tslib';\nimport { deleteDb, openDb } from 'idb';\nimport firebase from '@firebase/app';\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\nvar _a;\nvar ERROR_MAP = (_a = {}, _a[\"missing-app-config-values\" /* MISSING_APP_CONFIG_VALUES */] = 'Missing App configuration value: \"{$valueName}\"', _a[\"only-available-in-window\" /* AVAILABLE_IN_WINDOW */] = 'This method is available in a Window context.', _a[\"only-available-in-sw\" /* AVAILABLE_IN_SW */] = 'This method is available in a service worker context.', _a[\"permission-default\" /* PERMISSION_DEFAULT */] = 'The notification permission was not granted and dismissed instead.', _a[\"permission-blocked\" /* PERMISSION_BLOCKED */] = 'The notification permission was not granted and blocked instead.', _a[\"unsupported-browser\" /* UNSUPPORTED_BROWSER */] = \"This browser doesn't support the API's required to use the firebase SDK.\", _a[\"failed-service-worker-registration\" /* FAILED_DEFAULT_REGISTRATION */] = 'We are unable to register the default service worker. {$browserErrorMessage}', _a[\"token-subscribe-failed\" /* TOKEN_SUBSCRIBE_FAILED */] = 'A problem occurred while subscribing the user to FCM: {$errorInfo}', _a[\"token-subscribe-no-token\" /* TOKEN_SUBSCRIBE_NO_TOKEN */] = 'FCM returned no token when subscribing the user to push.', _a[\"token-unsubscribe-failed\" /* TOKEN_UNSUBSCRIBE_FAILED */] = 'A problem occurred while unsubscribing the ' + 'user from FCM: {$errorInfo}', _a[\"token-update-failed\" /* TOKEN_UPDATE_FAILED */] = 'A problem occurred while updating the user from FCM: {$errorInfo}', _a[\"token-update-no-token\" /* TOKEN_UPDATE_NO_TOKEN */] = 'FCM returned no token when updating the user to push.', _a[\"use-sw-after-get-token\" /* USE_SW_AFTER_GET_TOKEN */] = 'The useServiceWorker() method may only be called once and must be ' + 'called before calling getToken() to ensure your service worker is used.', _a[\"invalid-sw-registration\" /* INVALID_SW_REGISTRATION */] = 'The input to useServiceWorker() must be a ServiceWorkerRegistration.', _a[\"invalid-bg-handler\" /* INVALID_BG_HANDLER */] = 'The input to setBackgroundMessageHandler() must be a function.', _a[\"invalid-vapid-key\" /* INVALID_VAPID_KEY */] = 'The public VAPID key must be a string.', _a[\"use-vapid-key-after-get-token\" /* USE_VAPID_KEY_AFTER_GET_TOKEN */] = 'The usePublicVapidKey() method may only be called once and must be ' + 'called before calling getToken() to ensure your VAPID key is used.', _a);\nvar ERROR_FACTORY = new ErrorFactory('messaging', 'Messaging', ERROR_MAP);\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\nvar DEFAULT_SW_PATH = '/firebase-messaging-sw.js';\nvar DEFAULT_SW_SCOPE = '/firebase-cloud-messaging-push-scope';\nvar DEFAULT_VAPID_KEY = 'BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4';\nvar ENDPOINT = 'https://fcmregistrations.googleapis.com/v1';\n// Key of FCM Payload in Notification's data field.\nvar FCM_MSG = 'FCM_MSG';\nvar TAG = 'FirebaseMessaging: ';\n// Set to '1' if Analytics is enabled for the campaign\nvar CONSOLE_CAMPAIGN_ANALYTICS_ENABLED = 'google.c.a.e';\nvar CONSOLE_CAMPAIGN_ID = 'google.c.a.c_id';\nvar CONSOLE_CAMPAIGN_TIME = 'google.c.a.ts';\nvar CONSOLE_CAMPAIGN_NAME = 'google.c.a.c_l';\n// Due to the fact that onBackgroundMessage can't be awaited (to support rxjs), a silent push\n// warning might be shown by the browser if the callback fails to completes by the end of onPush.\n// Experiments were ran to determine the majority onBackground message clock time. This brief\n// blocking time would allow majority of the onBackgroundMessage callback to finish.\nvar BACKGROUND_HANDLE_EXECUTION_TIME_LIMIT_MS = 1000;\n// Preparation time for client to initialize and set up the message handler.\nvar FOREGROUND_HANDLE_PREPARATION_TIME_MS = 3000;\n\n/**\r\n * @license\r\n * Copyright 2018 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\r\n * in compliance with the License. You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software distributed under the License\r\n * is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r\n * or implied. See the License for the specific language governing permissions and limitations under\r\n * the License.\r\n */\nvar MessageType;\n(function (MessageType) {\n MessageType[\"PUSH_RECEIVED\"] = \"push-received\";\n MessageType[\"NOTIFICATION_CLICKED\"] = \"notification-clicked\";\n})(MessageType || (MessageType = {}));\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\nfunction arrayToBase64(array) {\n var uint8Array = new Uint8Array(array);\n var base64String = btoa(String.fromCharCode.apply(String, __spreadArray([], __read(uint8Array))));\n return base64String.replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_');\n}\nfunction base64ToArray(base64String) {\n var padding = '='.repeat((4 - base64String.length % 4) % 4);\n var base64 = (base64String + padding).replace(/\\-/g, '+').replace(/_/g, '/');\n var rawData = atob(base64);\n var outputArray = new Uint8Array(rawData.length);\n for (var i = 0; i < rawData.length; ++i) {\n outputArray[i] = rawData.charCodeAt(i);\n }\n return outputArray;\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\nvar OLD_DB_NAME = 'fcm_token_details_db';\n/**\r\n * The last DB version of 'fcm_token_details_db' was 4. This is one higher, so that the upgrade\r\n * callback is called for all versions of the old DB.\r\n */\nvar OLD_DB_VERSION = 5;\nvar OLD_OBJECT_STORE_NAME = 'fcm_token_object_Store';\nfunction migrateOldDatabase(senderId) {\n return __awaiter(this, void 0, void 0, function () {\n var databases, dbNames, tokenDetails, db;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!('databases' in indexedDB)) return [3 /*break*/, 2];\n return [4 /*yield*/, indexedDB.databases()];\n case 1:\n databases = _a.sent();\n dbNames = databases.map(function (db) {\n return db.name;\n });\n if (!dbNames.includes(OLD_DB_NAME)) {\n // old DB didn't exist, no need to open.\n return [2 /*return*/, null];\n }\n _a.label = 2;\n case 2:\n tokenDetails = null;\n return [4 /*yield*/, openDb(OLD_DB_NAME, OLD_DB_VERSION, function (db) {\n return __awaiter(_this, void 0, void 0, function () {\n var objectStore, value, oldDetails, oldDetails, oldDetails;\n var _a;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n if (db.oldVersion < 2) {\n // Database too old, skip migration.\n return [2 /*return*/];\n }\n\n if (!db.objectStoreNames.contains(OLD_OBJECT_STORE_NAME)) {\n // Database did not exist. Nothing to do.\n return [2 /*return*/];\n }\n\n objectStore = db.transaction.objectStore(OLD_OBJECT_STORE_NAME);\n return [4 /*yield*/, objectStore.index('fcmSenderId').get(senderId)];\n case 1:\n value = _b.sent();\n return [4 /*yield*/, objectStore.clear()];\n case 2:\n _b.sent();\n if (!value) {\n // No entry in the database, nothing to migrate.\n return [2 /*return*/];\n }\n\n if (db.oldVersion === 2) {\n oldDetails = value;\n if (!oldDetails.auth || !oldDetails.p256dh || !oldDetails.endpoint) {\n return [2 /*return*/];\n }\n\n tokenDetails = {\n token: oldDetails.fcmToken,\n createTime: (_a = oldDetails.createTime) !== null && _a !== void 0 ? _a : Date.now(),\n subscriptionOptions: {\n auth: oldDetails.auth,\n p256dh: oldDetails.p256dh,\n endpoint: oldDetails.endpoint,\n swScope: oldDetails.swScope,\n vapidKey: typeof oldDetails.vapidKey === 'string' ? oldDetails.vapidKey : arrayToBase64(oldDetails.vapidKey)\n }\n };\n } else if (db.oldVersion === 3) {\n oldDetails = value;\n tokenDetails = {\n token: oldDetails.fcmToken,\n createTime: oldDetails.createTime,\n subscriptionOptions: {\n auth: arrayToBase64(oldDetails.auth),\n p256dh: arrayToBase64(oldDetails.p256dh),\n endpoint: oldDetails.endpoint,\n swScope: oldDetails.swScope,\n vapidKey: arrayToBase64(oldDetails.vapidKey)\n }\n };\n } else if (db.oldVersion === 4) {\n oldDetails = value;\n tokenDetails = {\n token: oldDetails.fcmToken,\n createTime: oldDetails.createTime,\n subscriptionOptions: {\n auth: arrayToBase64(oldDetails.auth),\n p256dh: arrayToBase64(oldDetails.p256dh),\n endpoint: oldDetails.endpoint,\n swScope: oldDetails.swScope,\n vapidKey: arrayToBase64(oldDetails.vapidKey)\n }\n };\n }\n return [2 /*return*/];\n }\n });\n });\n })];\n\n case 3:\n db = _a.sent();\n db.close();\n // Delete all old databases.\n return [4 /*yield*/, deleteDb(OLD_DB_NAME)];\n case 4:\n // Delete all old databases.\n _a.sent();\n return [4 /*yield*/, deleteDb('fcm_vapid_details_db')];\n case 5:\n _a.sent();\n return [4 /*yield*/, deleteDb('undefined')];\n case 6:\n _a.sent();\n return [2 /*return*/, checkTokenDetails(tokenDetails) ? tokenDetails : null];\n }\n });\n });\n}\nfunction checkTokenDetails(tokenDetails) {\n if (!tokenDetails || !tokenDetails.subscriptionOptions) {\n return false;\n }\n var subscriptionOptions = tokenDetails.subscriptionOptions;\n return typeof tokenDetails.createTime === 'number' && tokenDetails.createTime > 0 && typeof tokenDetails.token === 'string' && tokenDetails.token.length > 0 && typeof subscriptionOptions.auth === 'string' && subscriptionOptions.auth.length > 0 && typeof subscriptionOptions.p256dh === 'string' && subscriptionOptions.p256dh.length > 0 && typeof subscriptionOptions.endpoint === 'string' && subscriptionOptions.endpoint.length > 0 && typeof subscriptionOptions.swScope === 'string' && subscriptionOptions.swScope.length > 0 && typeof subscriptionOptions.vapidKey === 'string' && subscriptionOptions.vapidKey.length > 0;\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\n// Exported for tests.\nvar DATABASE_NAME = 'firebase-messaging-database';\nvar DATABASE_VERSION = 1;\nvar OBJECT_STORE_NAME = 'firebase-messaging-store';\nvar dbPromise = null;\nfunction getDbPromise() {\n if (!dbPromise) {\n dbPromise = openDb(DATABASE_NAME, DATABASE_VERSION, function (upgradeDb) {\n // We don't use 'break' in this switch statement, the fall-through behavior is what we want,\n // because if there are multiple versions between the old version and the current version, we\n // want ALL the migrations that correspond to those versions to run, not only the last one.\n // eslint-disable-next-line default-case\n switch (upgradeDb.oldVersion) {\n case 0:\n upgradeDb.createObjectStore(OBJECT_STORE_NAME);\n }\n });\n }\n return dbPromise;\n}\n/** Gets record(s) from the objectStore that match the given key. */\nfunction dbGet(firebaseDependencies) {\n return __awaiter(this, void 0, void 0, function () {\n var key, db, tokenDetails, oldTokenDetails;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n key = getKey(firebaseDependencies);\n return [4 /*yield*/, getDbPromise()];\n case 1:\n db = _a.sent();\n return [4 /*yield*/, db.transaction(OBJECT_STORE_NAME).objectStore(OBJECT_STORE_NAME).get(key)];\n case 2:\n tokenDetails = _a.sent();\n if (!tokenDetails) return [3 /*break*/, 3];\n return [2 /*return*/, tokenDetails];\n case 3:\n return [4 /*yield*/, migrateOldDatabase(firebaseDependencies.appConfig.senderId)];\n case 4:\n oldTokenDetails = _a.sent();\n if (!oldTokenDetails) return [3 /*break*/, 6];\n return [4 /*yield*/, dbSet(firebaseDependencies, oldTokenDetails)];\n case 5:\n _a.sent();\n return [2 /*return*/, oldTokenDetails];\n case 6:\n return [2 /*return*/];\n }\n });\n });\n}\n/** Assigns or overwrites the record for the given key with the given value. */\nfunction dbSet(firebaseDependencies, tokenDetails) {\n return __awaiter(this, void 0, void 0, function () {\n var key, db, tx;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n key = getKey(firebaseDependencies);\n return [4 /*yield*/, getDbPromise()];\n case 1:\n db = _a.sent();\n tx = db.transaction(OBJECT_STORE_NAME, 'readwrite');\n return [4 /*yield*/, tx.objectStore(OBJECT_STORE_NAME).put(tokenDetails, key)];\n case 2:\n _a.sent();\n return [4 /*yield*/, tx.complete];\n case 3:\n _a.sent();\n return [2 /*return*/, tokenDetails];\n }\n });\n });\n}\n/** Removes record(s) from the objectStore that match the given key. */\nfunction dbRemove(firebaseDependencies) {\n return __awaiter(this, void 0, void 0, function () {\n var key, db, tx;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n key = getKey(firebaseDependencies);\n return [4 /*yield*/, getDbPromise()];\n case 1:\n db = _a.sent();\n tx = db.transaction(OBJECT_STORE_NAME, 'readwrite');\n return [4 /*yield*/, tx.objectStore(OBJECT_STORE_NAME).delete(key)];\n case 2:\n _a.sent();\n return [4 /*yield*/, tx.complete];\n case 3:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n}\n\nfunction getKey(_a) {\n var appConfig = _a.appConfig;\n return appConfig.appId;\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\nfunction requestGetToken(firebaseDependencies, subscriptionOptions) {\n return __awaiter(this, void 0, void 0, function () {\n var headers, body, subscribeOptions, responseData, response, err_1, message;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n return [4 /*yield*/, getHeaders(firebaseDependencies)];\n case 1:\n headers = _a.sent();\n body = getBody(subscriptionOptions);\n subscribeOptions = {\n method: 'POST',\n headers: headers,\n body: JSON.stringify(body)\n };\n _a.label = 2;\n case 2:\n _a.trys.push([2, 5,, 6]);\n return [4 /*yield*/, fetch(getEndpoint(firebaseDependencies.appConfig), subscribeOptions)];\n case 3:\n response = _a.sent();\n return [4 /*yield*/, response.json()];\n case 4:\n responseData = _a.sent();\n return [3 /*break*/, 6];\n case 5:\n err_1 = _a.sent();\n throw ERROR_FACTORY.create(\"token-subscribe-failed\" /* TOKEN_SUBSCRIBE_FAILED */, {\n errorInfo: err_1\n });\n case 6:\n if (responseData.error) {\n message = responseData.error.message;\n throw ERROR_FACTORY.create(\"token-subscribe-failed\" /* TOKEN_SUBSCRIBE_FAILED */, {\n errorInfo: message\n });\n }\n if (!responseData.token) {\n throw ERROR_FACTORY.create(\"token-subscribe-no-token\" /* TOKEN_SUBSCRIBE_NO_TOKEN */);\n }\n\n return [2 /*return*/, responseData.token];\n }\n });\n });\n}\nfunction requestUpdateToken(firebaseDependencies, tokenDetails) {\n return __awaiter(this, void 0, void 0, function () {\n var headers, body, updateOptions, responseData, response, err_2, message;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n return [4 /*yield*/, getHeaders(firebaseDependencies)];\n case 1:\n headers = _a.sent();\n body = getBody(tokenDetails.subscriptionOptions);\n updateOptions = {\n method: 'PATCH',\n headers: headers,\n body: JSON.stringify(body)\n };\n _a.label = 2;\n case 2:\n _a.trys.push([2, 5,, 6]);\n return [4 /*yield*/, fetch(getEndpoint(firebaseDependencies.appConfig) + \"/\" + tokenDetails.token, updateOptions)];\n case 3:\n response = _a.sent();\n return [4 /*yield*/, response.json()];\n case 4:\n responseData = _a.sent();\n return [3 /*break*/, 6];\n case 5:\n err_2 = _a.sent();\n throw ERROR_FACTORY.create(\"token-update-failed\" /* TOKEN_UPDATE_FAILED */, {\n errorInfo: err_2\n });\n case 6:\n if (responseData.error) {\n message = responseData.error.message;\n throw ERROR_FACTORY.create(\"token-update-failed\" /* TOKEN_UPDATE_FAILED */, {\n errorInfo: message\n });\n }\n if (!responseData.token) {\n throw ERROR_FACTORY.create(\"token-update-no-token\" /* TOKEN_UPDATE_NO_TOKEN */);\n }\n\n return [2 /*return*/, responseData.token];\n }\n });\n });\n}\nfunction requestDeleteToken(firebaseDependencies, token) {\n return __awaiter(this, void 0, void 0, function () {\n var headers, unsubscribeOptions, response, responseData, message, err_3;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n return [4 /*yield*/, getHeaders(firebaseDependencies)];\n case 1:\n headers = _a.sent();\n unsubscribeOptions = {\n method: 'DELETE',\n headers: headers\n };\n _a.label = 2;\n case 2:\n _a.trys.push([2, 5,, 6]);\n return [4 /*yield*/, fetch(getEndpoint(firebaseDependencies.appConfig) + \"/\" + token, unsubscribeOptions)];\n case 3:\n response = _a.sent();\n return [4 /*yield*/, response.json()];\n case 4:\n responseData = _a.sent();\n if (responseData.error) {\n message = responseData.error.message;\n throw ERROR_FACTORY.create(\"token-unsubscribe-failed\" /* TOKEN_UNSUBSCRIBE_FAILED */, {\n errorInfo: message\n });\n }\n return [3 /*break*/, 6];\n case 5:\n err_3 = _a.sent();\n throw ERROR_FACTORY.create(\"token-unsubscribe-failed\" /* TOKEN_UNSUBSCRIBE_FAILED */, {\n errorInfo: err_3\n });\n case 6:\n return [2 /*return*/];\n }\n });\n });\n}\n\nfunction getEndpoint(_a) {\n var projectId = _a.projectId;\n return ENDPOINT + \"/projects/\" + projectId + \"/registrations\";\n}\nfunction getHeaders(_a) {\n var appConfig = _a.appConfig,\n installations = _a.installations;\n return __awaiter(this, void 0, void 0, function () {\n var authToken;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n return [4 /*yield*/, installations.getToken()];\n case 1:\n authToken = _b.sent();\n return [2 /*return*/, new Headers({\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n 'x-goog-api-key': appConfig.apiKey,\n 'x-goog-firebase-installations-auth': \"FIS \" + authToken\n })];\n }\n });\n });\n}\nfunction getBody(_a) {\n var p256dh = _a.p256dh,\n auth = _a.auth,\n endpoint = _a.endpoint,\n vapidKey = _a.vapidKey;\n var body = {\n web: {\n endpoint: endpoint,\n auth: auth,\n p256dh: p256dh\n }\n };\n if (vapidKey !== DEFAULT_VAPID_KEY) {\n body.web.applicationPubKey = vapidKey;\n }\n return body;\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\n/** UpdateRegistration will be called once every week. */\nvar TOKEN_EXPIRATION_MS = 7 * 24 * 60 * 60 * 1000; // 7 days\nfunction getToken(firebaseDependencies, swRegistration, vapidKey) {\n return __awaiter(this, void 0, void 0, function () {\n var pushSubscription, tokenDetails, subscriptionOptions, e_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (Notification.permission !== 'granted') {\n throw ERROR_FACTORY.create(\"permission-blocked\" /* PERMISSION_BLOCKED */);\n }\n\n return [4 /*yield*/, getPushSubscription(swRegistration, vapidKey)];\n case 1:\n pushSubscription = _a.sent();\n return [4 /*yield*/, dbGet(firebaseDependencies)];\n case 2:\n tokenDetails = _a.sent();\n subscriptionOptions = {\n vapidKey: vapidKey,\n swScope: swRegistration.scope,\n endpoint: pushSubscription.endpoint,\n auth: arrayToBase64(pushSubscription.getKey('auth')),\n p256dh: arrayToBase64(pushSubscription.getKey('p256dh'))\n };\n if (!!tokenDetails) return [3 /*break*/, 3];\n // No token, get a new one.\n return [2 /*return*/, getNewToken(firebaseDependencies, subscriptionOptions)];\n case 3:\n if (!!isTokenValid(tokenDetails.subscriptionOptions, subscriptionOptions)) return [3 /*break*/, 8];\n _a.label = 4;\n case 4:\n _a.trys.push([4, 6,, 7]);\n return [4 /*yield*/, requestDeleteToken(firebaseDependencies, tokenDetails.token)];\n case 5:\n _a.sent();\n return [3 /*break*/, 7];\n case 6:\n e_1 = _a.sent();\n // Suppress errors because of #2364\n console.warn(e_1);\n return [3 /*break*/, 7];\n case 7:\n return [2 /*return*/, getNewToken(firebaseDependencies, subscriptionOptions)];\n case 8:\n if (Date.now() >= tokenDetails.createTime + TOKEN_EXPIRATION_MS) {\n // Weekly token refresh\n return [2 /*return*/, updateToken({\n token: tokenDetails.token,\n createTime: Date.now(),\n subscriptionOptions: subscriptionOptions\n }, firebaseDependencies, swRegistration)];\n } else {\n // Valid token, nothing to do.\n return [2 /*return*/, tokenDetails.token];\n }\n case 9:\n return [2 /*return*/];\n }\n });\n });\n}\n/**\r\n * This method deletes the token from the database, unsubscribes the token from FCM, and unregisters\r\n * the push subscription if it exists.\r\n */\nfunction deleteToken(firebaseDependencies, swRegistration) {\n return __awaiter(this, void 0, void 0, function () {\n var tokenDetails, pushSubscription;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n return [4 /*yield*/, dbGet(firebaseDependencies)];\n case 1:\n tokenDetails = _a.sent();\n if (!tokenDetails) return [3 /*break*/, 4];\n return [4 /*yield*/, requestDeleteToken(firebaseDependencies, tokenDetails.token)];\n case 2:\n _a.sent();\n return [4 /*yield*/, dbRemove(firebaseDependencies)];\n case 3:\n _a.sent();\n _a.label = 4;\n case 4:\n return [4 /*yield*/, swRegistration.pushManager.getSubscription()];\n case 5:\n pushSubscription = _a.sent();\n if (pushSubscription) {\n return [2 /*return*/, pushSubscription.unsubscribe()];\n }\n // If there's no SW, consider it a success.\n return [2 /*return*/, true];\n }\n });\n });\n}\nfunction updateToken(tokenDetails, firebaseDependencies, swRegistration) {\n return __awaiter(this, void 0, void 0, function () {\n var updatedToken, updatedTokenDetails, e_2;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 3,, 5]);\n return [4 /*yield*/, requestUpdateToken(firebaseDependencies, tokenDetails)];\n case 1:\n updatedToken = _a.sent();\n updatedTokenDetails = __assign(__assign({}, tokenDetails), {\n token: updatedToken,\n createTime: Date.now()\n });\n return [4 /*yield*/, dbSet(firebaseDependencies, updatedTokenDetails)];\n case 2:\n _a.sent();\n return [2 /*return*/, updatedToken];\n case 3:\n e_2 = _a.sent();\n return [4 /*yield*/, deleteToken(firebaseDependencies, swRegistration)];\n case 4:\n _a.sent();\n throw e_2;\n case 5:\n return [2 /*return*/];\n }\n });\n });\n}\n\nfunction getNewToken(firebaseDependencies, subscriptionOptions) {\n return __awaiter(this, void 0, void 0, function () {\n var token, tokenDetails;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n return [4 /*yield*/, requestGetToken(firebaseDependencies, subscriptionOptions)];\n case 1:\n token = _a.sent();\n tokenDetails = {\n token: token,\n createTime: Date.now(),\n subscriptionOptions: subscriptionOptions\n };\n return [4 /*yield*/, dbSet(firebaseDependencies, tokenDetails)];\n case 2:\n _a.sent();\n return [2 /*return*/, tokenDetails.token];\n }\n });\n });\n}\n/**\r\n * Gets a PushSubscription for the current user.\r\n */\nfunction getPushSubscription(swRegistration, vapidKey) {\n return __awaiter(this, void 0, void 0, function () {\n var subscription;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n return [4 /*yield*/, swRegistration.pushManager.getSubscription()];\n case 1:\n subscription = _a.sent();\n if (subscription) {\n return [2 /*return*/, subscription];\n }\n return [2 /*return*/, swRegistration.pushManager.subscribe({\n userVisibleOnly: true,\n // Chrome <= 75 doesn't support base64-encoded VAPID key. For backward compatibility, VAPID key\n // submitted to pushManager#subscribe must be of type Uint8Array.\n applicationServerKey: base64ToArray(vapidKey)\n })];\n }\n });\n });\n}\n/**\r\n * Checks if the saved tokenDetails object matches the configuration provided.\r\n */\nfunction isTokenValid(dbOptions, currentOptions) {\n var isVapidKeyEqual = currentOptions.vapidKey === dbOptions.vapidKey;\n var isEndpointEqual = currentOptions.endpoint === dbOptions.endpoint;\n var isAuthEqual = currentOptions.auth === dbOptions.auth;\n var isP256dhEqual = currentOptions.p256dh === dbOptions.p256dh;\n return isVapidKeyEqual && isEndpointEqual && isAuthEqual && isP256dhEqual;\n}\n\n/**\r\n * @license\r\n * Copyright 2020 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\nfunction externalizePayload(internalPayload) {\n var payload = {\n from: internalPayload.from,\n // eslint-disable-next-line camelcase\n collapseKey: internalPayload.collapse_key,\n // eslint-disable-next-line camelcase\n messageId: internalPayload.fcm_message_id\n };\n propagateNotificationPayload(payload, internalPayload);\n propagateDataPayload(payload, internalPayload);\n propagateFcmOptions(payload, internalPayload);\n return payload;\n}\nfunction propagateNotificationPayload(payload, messagePayloadInternal) {\n if (!messagePayloadInternal.notification) {\n return;\n }\n payload.notification = {};\n var title = messagePayloadInternal.notification.title;\n if (!!title) {\n payload.notification.title = title;\n }\n var body = messagePayloadInternal.notification.body;\n if (!!body) {\n payload.notification.body = body;\n }\n var image = messagePayloadInternal.notification.image;\n if (!!image) {\n payload.notification.image = image;\n }\n}\nfunction propagateDataPayload(payload, messagePayloadInternal) {\n if (!messagePayloadInternal.data) {\n return;\n }\n payload.data = messagePayloadInternal.data;\n}\nfunction propagateFcmOptions(payload, messagePayloadInternal) {\n if (!messagePayloadInternal.fcmOptions) {\n return;\n }\n payload.fcmOptions = {};\n var link = messagePayloadInternal.fcmOptions.link;\n if (!!link) {\n payload.fcmOptions.link = link;\n }\n // eslint-disable-next-line camelcase\n var analyticsLabel = messagePayloadInternal.fcmOptions.analytics_label;\n if (!!analyticsLabel) {\n payload.fcmOptions.analyticsLabel = analyticsLabel;\n }\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\nfunction isConsoleMessage(data) {\n // This message has a campaign ID, meaning it was sent using the Firebase Console.\n return typeof data === 'object' && !!data && CONSOLE_CAMPAIGN_ID in data;\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\n/** Returns a promise that resolves after given time passes. */\nfunction sleep(ms) {\n return new Promise(function (resolve) {\n setTimeout(resolve, ms);\n });\n}\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\nvar SwController = /** @class */function () {\n function SwController(firebaseDependencies) {\n var _this = this;\n this.firebaseDependencies = firebaseDependencies;\n // A boolean flag to determine wether an app is using onBackgroundMessage or\n // setBackgroundMessageHandler. onBackgroundMessage will receive a MessagePayload regardless of if\n // a notification is displayed. Whereas, setBackgroundMessageHandler will swallow the\n // MessagePayload if a NotificationPayload is included.\n this.isOnBackgroundMessageUsed = null;\n this.vapidKey = null;\n this.bgMessageHandler = null;\n self.addEventListener('push', function (e) {\n e.waitUntil(_this.onPush(e));\n });\n self.addEventListener('pushsubscriptionchange', function (e) {\n e.waitUntil(_this.onSubChange(e));\n });\n self.addEventListener('notificationclick', function (e) {\n e.waitUntil(_this.onNotificationClick(e));\n });\n }\n Object.defineProperty(SwController.prototype, \"app\", {\n get: function () {\n return this.firebaseDependencies.app;\n },\n enumerable: false,\n configurable: true\n });\n /**\r\n * @deprecated. Use onBackgroundMessage(nextOrObserver: NextFn<object> | Observer<object>):\r\n * Unsubscribe instead.\r\n *\r\n * Calling setBackgroundMessageHandler will opt in to some specific behaviors.\r\n *\r\n * 1.) If a notification doesn't need to be shown due to a window already being visible, then push\r\n * messages will be sent to the page. 2.) If a notification needs to be shown, and the message\r\n * contains no notification data this method will be called and the promise it returns will be\r\n * passed to event.waitUntil. If you do not set this callback then all push messages will let and\r\n * the developer can handle them in a their own 'push' event callback\r\n *\r\n * @param callback The callback to be called when a push message is received and a notification\r\n * must be shown. The callback will be given the data from the push message.\r\n */\n SwController.prototype.setBackgroundMessageHandler = function (callback) {\n this.isOnBackgroundMessageUsed = false;\n if (!callback || typeof callback !== 'function') {\n throw ERROR_FACTORY.create(\"invalid-bg-handler\" /* INVALID_BG_HANDLER */);\n }\n\n this.bgMessageHandler = callback;\n };\n SwController.prototype.onBackgroundMessage = function (nextOrObserver) {\n var _this = this;\n this.isOnBackgroundMessageUsed = true;\n this.bgMessageHandler = nextOrObserver;\n return function () {\n _this.bgMessageHandler = null;\n };\n };\n // TODO: Remove getToken from SW Controller. Calling this from an old SW can cause all kinds of\n // trouble.\n SwController.prototype.getToken = function () {\n var _a, _b;\n return __awaiter(this, void 0, void 0, function () {\n var tokenDetails;\n return __generator(this, function (_c) {\n switch (_c.label) {\n case 0:\n if (!!this.vapidKey) return [3 /*break*/, 2];\n return [4 /*yield*/, dbGet(this.firebaseDependencies)];\n case 1:\n tokenDetails = _c.sent();\n this.vapidKey = (_b = (_a = tokenDetails === null || tokenDetails === void 0 ? void 0 : tokenDetails.subscriptionOptions) === null || _a === void 0 ? void 0 : _a.vapidKey) !== null && _b !== void 0 ? _b : DEFAULT_VAPID_KEY;\n _c.label = 2;\n case 2:\n return [2 /*return*/, getToken(this.firebaseDependencies, self.registration, this.vapidKey)];\n }\n });\n });\n };\n // TODO: Remove deleteToken from SW Controller. Calling this from an old SW can cause all kinds of\n // trouble.\n SwController.prototype.deleteToken = function () {\n return deleteToken(this.firebaseDependencies, self.registration);\n };\n SwController.prototype.requestPermission = function () {\n throw ERROR_FACTORY.create(\"only-available-in-window\" /* AVAILABLE_IN_WINDOW */);\n };\n // TODO: Remove this together with getToken from SW Controller.\n SwController.prototype.usePublicVapidKey = function (vapidKey) {\n if (this.vapidKey !== null) {\n throw ERROR_FACTORY.create(\"use-vapid-key-after-get-token\" /* USE_VAPID_KEY_AFTER_GET_TOKEN */);\n }\n\n if (typeof vapidKey !== 'string' || vapidKey.length === 0) {\n throw ERROR_FACTORY.create(\"invalid-vapid-key\" /* INVALID_VAPID_KEY */);\n }\n\n this.vapidKey = vapidKey;\n };\n SwController.prototype.useServiceWorker = function () {\n throw ERROR_FACTORY.create(\"only-available-in-window\" /* AVAILABLE_IN_WINDOW */);\n };\n\n SwController.prototype.onMessage = function () {\n throw ERROR_FACTORY.create(\"only-available-in-window\" /* AVAILABLE_IN_WINDOW */);\n };\n\n SwController.prototype.onTokenRefresh = function () {\n throw ERROR_FACTORY.create(\"only-available-in-window\" /* AVAILABLE_IN_WINDOW */);\n };\n /**\r\n * A handler for push events that shows notifications based on the content of the payload.\r\n *\r\n * The payload must be a JSON-encoded Object with a `notification` key. The value of the\r\n * `notification` property will be used as the NotificationOptions object passed to\r\n * showNotification. Additionally, the `title` property of the notification object will be used as\r\n * the title.\r\n *\r\n * If there is no notification data in the payload then no notification will be shown.\r\n */\n SwController.prototype.onPush = function (event) {\n return __awaiter(this, void 0, void 0, function () {\n var internalPayload, clientList, isNotificationShown, payload;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n internalPayload = getMessagePayloadInternal(event);\n if (!internalPayload) {\n console.debug(TAG + 'failed to get parsed MessagePayload from the PushEvent. Skip handling the push.');\n return [2 /*return*/];\n }\n\n return [4 /*yield*/, getClientList()];\n case 1:\n clientList = _a.sent();\n if (hasVisibleClients(clientList)) {\n return [2 /*return*/, sendMessagePayloadInternalToWindows(clientList, internalPayload)];\n }\n isNotificationShown = false;\n if (!!!internalPayload.notification) return [3 /*break*/, 3];\n return [4 /*yield*/, showNotification(wrapInternalPayload(internalPayload))];\n case 2:\n _a.sent();\n isNotificationShown = true;\n _a.label = 3;\n case 3:\n // MessagePayload is only passed to `onBackgroundMessage`. Skip passing MessagePayload for\n // the legacy `setBackgroundMessageHandler` to preserve the SDK behaviors.\n if (isNotificationShown === true && this.isOnBackgroundMessageUsed === false) {\n return [2 /*return*/];\n }\n\n if (!!this.bgMessageHandler) {\n payload = externalizePayload(internalPayload);\n if (typeof this.bgMessageHandler === 'function') {\n this.bgMessageHandler(payload);\n } else {\n this.bgMessageHandler.next(payload);\n }\n }\n // wait briefly to allow onBackgroundMessage to complete\n return [4 /*yield*/, sleep(BACKGROUND_HANDLE_EXECUTION_TIME_LIMIT_MS)];\n case 4:\n // wait briefly to allow onBackgroundMessage to complete\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n\n SwController.prototype.onSubChange = function (event) {\n var _a, _b;\n return __awaiter(this, void 0, void 0, function () {\n var newSubscription, tokenDetails;\n return __generator(this, function (_c) {\n switch (_c.label) {\n case 0:\n newSubscription = event.newSubscription;\n if (!!newSubscription) return [3 /*break*/, 2];\n // Subscription revoked, delete token\n return [4 /*yield*/, deleteToken(this.firebaseDependencies, self.registration)];\n case 1:\n // Subscription revoked, delete token\n _c.sent();\n return [2 /*return*/];\n case 2:\n return [4 /*yield*/, dbGet(this.firebaseDependencies)];\n case 3:\n tokenDetails = _c.sent();\n return [4 /*yield*/, deleteToken(this.firebaseDependencies, self.registration)];\n case 4:\n _c.sent();\n return [4 /*yield*/, getToken(this.firebaseDependencies, self.registration, (_b = (_a = tokenDetails === null || tokenDetails === void 0 ? void 0 : tokenDetails.subscriptionOptions) === null || _a === void 0 ? void 0 : _a.vapidKey) !== null && _b !== void 0 ? _b : DEFAULT_VAPID_KEY)];\n case 5:\n _c.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n\n SwController.prototype.onNotificationClick = function (event) {\n var _a, _b;\n return __awaiter(this, void 0, void 0, function () {\n var internalPayload, link, url, originUrl, client;\n return __generator(this, function (_c) {\n switch (_c.label) {\n case 0:\n internalPayload = (_b = (_a = event.notification) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b[FCM_MSG];\n if (!internalPayload) {\n return [2 /*return*/];\n } else if (event.action) {\n // User clicked on an action button. This will allow developers to act on action button clicks\n // by using a custom onNotificationClick listener that they define.\n return [2 /*return*/];\n }\n // Prevent other listeners from receiving the event\n event.stopImmediatePropagation();\n event.notification.close();\n link = getLink(internalPayload);\n if (!link) {\n return [2 /*return*/];\n }\n\n url = new URL(link, self.location.href);\n originUrl = new URL(self.location.origin);\n if (url.host !== originUrl.host) {\n return [2 /*return*/];\n }\n\n return [4 /*yield*/, getWindowClient(url)];\n case 1:\n client = _c.sent();\n if (!!client) return [3 /*break*/, 4];\n return [4 /*yield*/, self.clients.openWindow(link)];\n case 2:\n client = _c.sent();\n // Wait three seconds for the client to initialize and set up the message handler so that it\n // can receive the message.\n return [4 /*yield*/, sleep(FOREGROUND_HANDLE_PREPARATION_TIME_MS)];\n case 3:\n // Wait three seconds for the client to initialize and set up the message handler so that it\n // can receive the message.\n _c.sent();\n return [3 /*break*/, 6];\n case 4:\n return [4 /*yield*/, client.focus()];\n case 5:\n client = _c.sent();\n _c.label = 6;\n case 6:\n if (!client) {\n // Window Client will not be returned if it's for a third party origin.\n return [2 /*return*/];\n }\n\n internalPayload.messageType = MessageType.NOTIFICATION_CLICKED;\n internalPayload.isFirebaseMessaging = true;\n return [2 /*return*/, client.postMessage(internalPayload)];\n }\n });\n });\n };\n return SwController;\n}();\nfunction wrapInternalPayload(internalPayload) {\n var _a;\n var wrappedInternalPayload = __assign({}, internalPayload.notification);\n // Put the message payload under FCM_MSG name so we can identify the notification as being an FCM\n // notification vs a notification from somewhere else (i.e. normal web push or developer generated\n // notification).\n wrappedInternalPayload.data = (_a = {}, _a[FCM_MSG] = internalPayload, _a);\n return wrappedInternalPayload;\n}\nfunction getMessagePayloadInternal(_a) {\n var data = _a.data;\n if (!data) {\n return null;\n }\n try {\n return data.json();\n } catch (err) {\n // Not JSON so not an FCM message.\n return null;\n }\n}\n/**\r\n * @param url The URL to look for when focusing a client.\r\n * @return Returns an existing window client or a newly opened WindowClient.\r\n */\nfunction getWindowClient(url) {\n return __awaiter(this, void 0, void 0, function () {\n var clientList, clientList_1, clientList_1_1, client, clientUrl;\n var e_1, _a;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n return [4 /*yield*/, getClientList()];\n case 1:\n clientList = _b.sent();\n try {\n for (clientList_1 = __values(clientList), clientList_1_1 = clientList_1.next(); !clientList_1_1.done; clientList_1_1 = clientList_1.next()) {\n client = clientList_1_1.value;\n clientUrl = new URL(client.url, self.location.href);\n if (url.host === clientUrl.host) {\n return [2 /*return*/, client];\n }\n }\n } catch (e_1_1) {\n e_1 = {\n error: e_1_1\n };\n } finally {\n try {\n if (clientList_1_1 && !clientList_1_1.done && (_a = clientList_1.return)) _a.call(clientList_1);\n } finally {\n if (e_1) throw e_1.error;\n }\n }\n return [2 /*return*/, null];\n }\n });\n });\n}\n/**\r\n * @returns If there is currently a visible WindowClient, this method will resolve to true,\r\n * otherwise false.\r\n */\nfunction hasVisibleClients(clientList) {\n return clientList.some(function (client) {\n return client.visibilityState === 'visible' &&\n // Ignore chrome-extension clients as that matches the background pages of extensions, which\n // are always considered visible for some reason.\n !client.url.startsWith('chrome-extension://');\n });\n}\nfunction sendMessagePayloadInternalToWindows(clientList, internalPayload) {\n var e_2, _a;\n internalPayload.isFirebaseMessaging = true;\n internalPayload.messageType = MessageType.PUSH_RECEIVED;\n try {\n for (var clientList_2 = __values(clientList), clientList_2_1 = clientList_2.next(); !clientList_2_1.done; clientList_2_1 = clientList_2.next()) {\n var client = clientList_2_1.value;\n client.postMessage(internalPayload);\n }\n } catch (e_2_1) {\n e_2 = {\n error: e_2_1\n };\n } finally {\n try {\n if (clientList_2_1 && !clientList_2_1.done && (_a = clientList_2.return)) _a.call(clientList_2);\n } finally {\n if (e_2) throw e_2.error;\n }\n }\n}\nfunction getClientList() {\n return self.clients.matchAll({\n type: 'window',\n includeUncontrolled: true\n // TS doesn't know that \"type: 'window'\" means it'll return WindowClient[]\n });\n}\n\nfunction showNotification(notificationPayloadInternal) {\n var _a;\n // Note: Firefox does not support the maxActions property.\n // https://developer.mozilla.org/en-US/docs/Web/API/notification/maxActions\n var actions = notificationPayloadInternal.actions;\n var maxActions = Notification.maxActions;\n if (actions && maxActions && actions.length > maxActions) {\n console.warn(\"This browser only supports \" + maxActions + \" actions. The remaining actions will not be displayed.\");\n }\n return self.registration.showNotification( /* title= */(_a = notificationPayloadInternal.title) !== null && _a !== void 0 ? _a : '', notificationPayloadInternal);\n}\nfunction getLink(payload) {\n var _a, _b, _c;\n // eslint-disable-next-line camelcase\n var link = (_b = (_a = payload.fcmOptions) === null || _a === void 0 ? void 0 : _a.link) !== null && _b !== void 0 ? _b : (_c = payload.notification) === null || _c === void 0 ? void 0 : _c.click_action;\n if (link) {\n return link;\n }\n if (isConsoleMessage(payload.data)) {\n // Notification created in the Firebase Console. Redirect to origin.\n return self.location.origin;\n } else {\n return null;\n }\n}\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\nvar WindowController = /** @class */function () {\n function WindowController(firebaseDependencies) {\n var _this = this;\n this.firebaseDependencies = firebaseDependencies;\n this.vapidKey = null;\n this.onMessageCallback = null;\n navigator.serviceWorker.addEventListener('message', function (e) {\n return _this.messageEventListener(e);\n });\n }\n Object.defineProperty(WindowController.prototype, \"app\", {\n get: function () {\n return this.firebaseDependencies.app;\n },\n enumerable: false,\n configurable: true\n });\n WindowController.prototype.messageEventListener = function (event) {\n return __awaiter(this, void 0, void 0, function () {\n var internalPayload, dataPayload;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n internalPayload = event.data;\n if (!internalPayload.isFirebaseMessaging) {\n return [2 /*return*/];\n }\n // onMessageCallback is either a function or observer/subscriber.\n // TODO: in the modularization release, have onMessage handle type MessagePayload as supposed to\n // the legacy payload where some fields are in snake cases.\n if (this.onMessageCallback && internalPayload.messageType === MessageType.PUSH_RECEIVED) {\n if (typeof this.onMessageCallback === 'function') {\n this.onMessageCallback(stripInternalFields(Object.assign({}, internalPayload)));\n } else {\n this.onMessageCallback.next(Object.assign({}, internalPayload));\n }\n }\n dataPayload = internalPayload.data;\n if (!(isConsoleMessage(dataPayload) && dataPayload[CONSOLE_CAMPAIGN_ANALYTICS_ENABLED] === '1')) return [3 /*break*/, 2];\n return [4 /*yield*/, this.logEvent(internalPayload.messageType, dataPayload)];\n case 1:\n _a.sent();\n _a.label = 2;\n case 2:\n return [2 /*return*/];\n }\n });\n });\n };\n\n WindowController.prototype.getVapidKey = function () {\n return this.vapidKey;\n };\n WindowController.prototype.getSwReg = function () {\n return this.swRegistration;\n };\n WindowController.prototype.getToken = function (options) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!(Notification.permission === 'default')) return [3 /*break*/, 2];\n return [4 /*yield*/, Notification.requestPermission()];\n case 1:\n _a.sent();\n _a.label = 2;\n case 2:\n if (Notification.permission !== 'granted') {\n throw ERROR_FACTORY.create(\"permission-blocked\" /* PERMISSION_BLOCKED */);\n }\n\n return [4 /*yield*/, this.updateVapidKey(options === null || options === void 0 ? void 0 : options.vapidKey)];\n case 3:\n _a.sent();\n return [4 /*yield*/, this.updateSwReg(options === null || options === void 0 ? void 0 : options.serviceWorkerRegistration)];\n case 4:\n _a.sent();\n return [2 /*return*/, getToken(this.firebaseDependencies, this.swRegistration, this.vapidKey)];\n }\n });\n });\n };\n WindowController.prototype.updateVapidKey = function (vapidKey) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n if (!!vapidKey) {\n this.vapidKey = vapidKey;\n } else if (!this.vapidKey) {\n this.vapidKey = DEFAULT_VAPID_KEY;\n }\n return [2 /*return*/];\n });\n });\n };\n\n WindowController.prototype.updateSwReg = function (swRegistration) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!(!swRegistration && !this.swRegistration)) return [3 /*break*/, 2];\n return [4 /*yield*/, this.registerDefaultSw()];\n case 1:\n _a.sent();\n _a.label = 2;\n case 2:\n if (!swRegistration && !!this.swRegistration) {\n return [2 /*return*/];\n }\n\n if (!(swRegistration instanceof ServiceWorkerRegistration)) {\n throw ERROR_FACTORY.create(\"invalid-sw-registration\" /* INVALID_SW_REGISTRATION */);\n }\n\n this.swRegistration = swRegistration;\n return [2 /*return*/];\n }\n });\n });\n };\n\n WindowController.prototype.registerDefaultSw = function () {\n return __awaiter(this, void 0, void 0, function () {\n var _a, e_1;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n _b.trys.push([0, 2,, 3]);\n _a = this;\n return [4 /*yield*/, navigator.serviceWorker.register(DEFAULT_SW_PATH, {\n scope: DEFAULT_SW_SCOPE\n })];\n case 1:\n _a.swRegistration = _b.sent();\n // The timing when browser updates sw when sw has an update is unreliable by my experiment. It\n // leads to version conflict when the SDK upgrades to a newer version in the main page, but sw\n // is stuck with the old version. For example,\n // https://github.com/firebase/firebase-js-sdk/issues/2590 The following line reliably updates\n // sw if there was an update.\n this.swRegistration.update().catch(function () {\n /* it is non blocking and we don't care if it failed */\n });\n return [3 /*break*/, 3];\n case 2:\n e_1 = _b.sent();\n throw ERROR_FACTORY.create(\"failed-service-worker-registration\" /* FAILED_DEFAULT_REGISTRATION */, {\n browserErrorMessage: e_1.message\n });\n case 3:\n return [2 /*return*/];\n }\n });\n });\n };\n\n WindowController.prototype.deleteToken = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!!this.swRegistration) return [3 /*break*/, 2];\n return [4 /*yield*/, this.registerDefaultSw()];\n case 1:\n _a.sent();\n _a.label = 2;\n case 2:\n return [2 /*return*/, deleteToken(this.firebaseDependencies, this.swRegistration)];\n }\n });\n });\n };\n /**\r\n * Request permission if it is not currently granted.\r\n *\r\n * @return Resolves if the permission was granted, rejects otherwise.\r\n *\r\n * @deprecated Use Notification.requestPermission() instead.\r\n * https://developer.mozilla.org/en-US/docs/Web/API/Notification/requestPermission\r\n */\n WindowController.prototype.requestPermission = function () {\n return __awaiter(this, void 0, void 0, function () {\n var permissionResult;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (Notification.permission === 'granted') {\n return [2 /*return*/];\n }\n\n return [4 /*yield*/, Notification.requestPermission()];\n case 1:\n permissionResult = _a.sent();\n if (permissionResult === 'granted') {\n return [2 /*return*/];\n } else if (permissionResult === 'denied') {\n throw ERROR_FACTORY.create(\"permission-blocked\" /* PERMISSION_BLOCKED */);\n } else {\n throw ERROR_FACTORY.create(\"permission-default\" /* PERMISSION_DEFAULT */);\n }\n }\n });\n });\n };\n /**\r\n * @deprecated. Use getToken(options?: {vapidKey?: string; serviceWorkerRegistration?:\r\n * ServiceWorkerRegistration;}): Promise<string> instead.\r\n */\n WindowController.prototype.usePublicVapidKey = function (vapidKey) {\n if (this.vapidKey !== null) {\n throw ERROR_FACTORY.create(\"use-vapid-key-after-get-token\" /* USE_VAPID_KEY_AFTER_GET_TOKEN */);\n }\n\n if (typeof vapidKey !== 'string' || vapidKey.length === 0) {\n throw ERROR_FACTORY.create(\"invalid-vapid-key\" /* INVALID_VAPID_KEY */);\n }\n\n this.vapidKey = vapidKey;\n };\n /**\r\n * @deprecated. Use getToken(options?: {vapidKey?: string; serviceWorkerRegistration?:\r\n * ServiceWorkerRegistration;}): Promise<string> instead.\r\n */\n WindowController.prototype.useServiceWorker = function (swRegistration) {\n if (!(swRegistration instanceof ServiceWorkerRegistration)) {\n throw ERROR_FACTORY.create(\"invalid-sw-registration\" /* INVALID_SW_REGISTRATION */);\n }\n\n if (this.swRegistration) {\n throw ERROR_FACTORY.create(\"use-sw-after-get-token\" /* USE_SW_AFTER_GET_TOKEN */);\n }\n\n this.swRegistration = swRegistration;\n };\n /**\r\n * @param nextOrObserver An observer object or a function triggered on message.\r\n *\r\n * @return The unsubscribe function for the observer.\r\n */\n WindowController.prototype.onMessage = function (nextOrObserver) {\n var _this = this;\n this.onMessageCallback = nextOrObserver;\n return function () {\n _this.onMessageCallback = null;\n };\n };\n WindowController.prototype.setBackgroundMessageHandler = function () {\n throw ERROR_FACTORY.create(\"only-available-in-sw\" /* AVAILABLE_IN_SW */);\n };\n\n WindowController.prototype.onBackgroundMessage = function () {\n throw ERROR_FACTORY.create(\"only-available-in-sw\" /* AVAILABLE_IN_SW */);\n };\n /**\r\n * @deprecated No-op. It was initially designed with token rotation requests from server in mind.\r\n * However, the plan to implement such feature was abandoned.\r\n */\n WindowController.prototype.onTokenRefresh = function () {\n return function () {};\n };\n WindowController.prototype.logEvent = function (messageType, data) {\n return __awaiter(this, void 0, void 0, function () {\n var eventType, analytics;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n eventType = getEventType(messageType);\n return [4 /*yield*/, this.firebaseDependencies.analyticsProvider.get()];\n case 1:\n analytics = _a.sent();\n analytics.logEvent(eventType, {\n /* eslint-disable camelcase */\n message_id: data[CONSOLE_CAMPAIGN_ID],\n message_name: data[CONSOLE_CAMPAIGN_NAME],\n message_time: data[CONSOLE_CAMPAIGN_TIME],\n message_device_time: Math.floor(Date.now() / 1000)\n /* eslint-enable camelcase */\n });\n\n return [2 /*return*/];\n }\n });\n });\n };\n\n return WindowController;\n}();\nfunction getEventType(messageType) {\n switch (messageType) {\n case MessageType.NOTIFICATION_CLICKED:\n return 'notification_open';\n case MessageType.PUSH_RECEIVED:\n return 'notification_foreground';\n default:\n throw new Error();\n }\n}\nfunction stripInternalFields(internalPayload) {\n delete internalPayload.messageType;\n delete internalPayload.isFirebaseMessaging;\n return internalPayload;\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\nfunction extractAppConfig(app) {\n var e_1, _a;\n if (!app || !app.options) {\n throw getMissingValueError('App Configuration Object');\n }\n if (!app.name) {\n throw getMissingValueError('App Name');\n }\n // Required app config keys\n var configKeys = ['projectId', 'apiKey', 'appId', 'messagingSenderId'];\n var options = app.options;\n try {\n for (var configKeys_1 = __values(configKeys), configKeys_1_1 = configKeys_1.next(); !configKeys_1_1.done; configKeys_1_1 = configKeys_1.next()) {\n var keyName = configKeys_1_1.value;\n if (!options[keyName]) {\n throw getMissingValueError(keyName);\n }\n }\n } catch (e_1_1) {\n e_1 = {\n error: e_1_1\n };\n } finally {\n try {\n if (configKeys_1_1 && !configKeys_1_1.done && (_a = configKeys_1.return)) _a.call(configKeys_1);\n } finally {\n if (e_1) throw e_1.error;\n }\n }\n return {\n appName: app.name,\n projectId: options.projectId,\n apiKey: options.apiKey,\n appId: options.appId,\n senderId: options.messagingSenderId\n };\n}\nfunction getMissingValueError(valueName) {\n return ERROR_FACTORY.create(\"missing-app-config-values\" /* MISSING_APP_CONFIG_VALUES */, {\n valueName: valueName\n });\n}\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\nvar MESSAGING_NAME = 'messaging';\nfunction factoryMethod(container) {\n // Dependencies.\n var app = container.getProvider('app').getImmediate();\n var appConfig = extractAppConfig(app);\n var installations = container.getProvider('installations').getImmediate();\n var analyticsProvider = container.getProvider('analytics-internal');\n var firebaseDependencies = {\n app: app,\n appConfig: appConfig,\n installations: installations,\n analyticsProvider: analyticsProvider\n };\n if (!isSupported()) {\n throw ERROR_FACTORY.create(\"unsupported-browser\" /* UNSUPPORTED_BROWSER */);\n }\n\n if (self && 'ServiceWorkerGlobalScope' in self) {\n // Running in ServiceWorker context\n return new SwController(firebaseDependencies);\n } else {\n // Assume we are in the window context.\n return new WindowController(firebaseDependencies);\n }\n}\nvar NAMESPACE_EXPORTS = {\n isSupported: isSupported\n};\nfirebase.INTERNAL.registerComponent(new Component(MESSAGING_NAME, factoryMethod, \"PUBLIC\" /* PUBLIC */).setServiceProps(NAMESPACE_EXPORTS));\nfunction isSupported() {\n if (self && 'ServiceWorkerGlobalScope' in self) {\n // Running in ServiceWorker context\n return isSWControllerSupported();\n } else {\n // Assume we are in the window context.\n return isWindowControllerSupported();\n }\n}\n/**\r\n * Checks to see if the required APIs exist.\r\n */\nfunction isWindowControllerSupported() {\n return 'indexedDB' in window && indexedDB !== null && navigator.cookieEnabled && 'serviceWorker' in navigator && 'PushManager' in window && 'Notification' in window && 'fetch' in window && ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') && PushSubscription.prototype.hasOwnProperty('getKey');\n}\n/**\r\n * Checks to see if the required APIs exist within SW Context.\r\n */\nfunction isSWControllerSupported() {\n return 'indexedDB' in self && indexedDB !== null && 'PushManager' in self && 'Notification' in self && ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') && PushSubscription.prototype.hasOwnProperty('getKey');\n}","map":{"version":3,"names":["Component","ErrorFactory","__spreadArray","__read","__awaiter","__generator","__assign","__values","deleteDb","openDb","firebase","_a","ERROR_MAP","ERROR_FACTORY","DEFAULT_SW_PATH","DEFAULT_SW_SCOPE","DEFAULT_VAPID_KEY","ENDPOINT","FCM_MSG","TAG","CONSOLE_CAMPAIGN_ANALYTICS_ENABLED","CONSOLE_CAMPAIGN_ID","CONSOLE_CAMPAIGN_TIME","CONSOLE_CAMPAIGN_NAME","BACKGROUND_HANDLE_EXECUTION_TIME_LIMIT_MS","FOREGROUND_HANDLE_PREPARATION_TIME_MS","MessageType","arrayToBase64","array","uint8Array","Uint8Array","base64String","btoa","String","fromCharCode","apply","replace","base64ToArray","padding","repeat","length","base64","rawData","atob","outputArray","i","charCodeAt","OLD_DB_NAME","OLD_DB_VERSION","OLD_OBJECT_STORE_NAME","migrateOldDatabase","senderId","databases","dbNames","tokenDetails","db","_this","label","indexedDB","sent","map","name","includes","objectStore","value","oldDetails","_b","oldVersion","objectStoreNames","contains","transaction","index","get","clear","auth","p256dh","endpoint","token","fcmToken","createTime","Date","now","subscriptionOptions","swScope","vapidKey","close","checkTokenDetails","DATABASE_NAME","DATABASE_VERSION","OBJECT_STORE_NAME","dbPromise","getDbPromise","upgradeDb","createObjectStore","dbGet","firebaseDependencies","key","oldTokenDetails","getKey","appConfig","dbSet","tx","put","complete","dbRemove","delete","appId","requestGetToken","headers","body","subscribeOptions","responseData","response","err_1","message","getHeaders","getBody","method","JSON","stringify","trys","push","fetch","getEndpoint","json","create","errorInfo","error","requestUpdateToken","updateOptions","err_2","requestDeleteToken","unsubscribeOptions","err_3","projectId","installations","authToken","getToken","Headers","Accept","apiKey","web","applicationPubKey","TOKEN_EXPIRATION_MS","swRegistration","pushSubscription","e_1","Notification","permission","getPushSubscription","scope","getNewToken","isTokenValid","console","warn","updateToken","deleteToken","pushManager","getSubscription","unsubscribe","updatedToken","updatedTokenDetails","e_2","subscription","subscribe","userVisibleOnly","applicationServerKey","dbOptions","currentOptions","isVapidKeyEqual","isEndpointEqual","isAuthEqual","isP256dhEqual","externalizePayload","internalPayload","payload","from","collapseKey","collapse_key","messageId","fcm_message_id","propagateNotificationPayload","propagateDataPayload","propagateFcmOptions","messagePayloadInternal","notification","title","image","data","fcmOptions","link","analyticsLabel","analytics_label","isConsoleMessage","sleep","ms","Promise","resolve","setTimeout","SwController","isOnBackgroundMessageUsed","bgMessageHandler","self","addEventListener","e","waitUntil","onPush","onSubChange","onNotificationClick","Object","defineProperty","prototype","app","enumerable","configurable","setBackgroundMessageHandler","callback","onBackgroundMessage","nextOrObserver","_c","registration","requestPermission","usePublicVapidKey","useServiceWorker","onMessage","onTokenRefresh","event","clientList","isNotificationShown","getMessagePayloadInternal","debug","getClientList","hasVisibleClients","sendMessagePayloadInternalToWindows","showNotification","wrapInternalPayload","next","newSubscription","url","originUrl","client","action","stopImmediatePropagation","getLink","URL","location","href","origin","host","getWindowClient","clients","openWindow","focus","messageType","NOTIFICATION_CLICKED","isFirebaseMessaging","postMessage","wrappedInternalPayload","err","clientList_1","clientList_1_1","clientUrl","done","e_1_1","return","call","some","visibilityState","startsWith","PUSH_RECEIVED","clientList_2","clientList_2_1","e_2_1","matchAll","type","includeUncontrolled","notificationPayloadInternal","actions","maxActions","click_action","WindowController","onMessageCallback","navigator","serviceWorker","messageEventListener","dataPayload","stripInternalFields","assign","logEvent","getVapidKey","getSwReg","options","updateVapidKey","updateSwReg","serviceWorkerRegistration","registerDefaultSw","ServiceWorkerRegistration","register","update","catch","browserErrorMessage","permissionResult","eventType","analytics","getEventType","analyticsProvider","message_id","message_name","message_time","message_device_time","Math","floor","Error","extractAppConfig","getMissingValueError","configKeys","configKeys_1","configKeys_1_1","keyName","appName","messagingSenderId","valueName","MESSAGING_NAME","factoryMethod","container","getProvider","getImmediate","isSupported","NAMESPACE_EXPORTS","INTERNAL","registerComponent","setServiceProps","isSWControllerSupported","isWindowControllerSupported","window","cookieEnabled","hasOwnProperty","PushSubscription"],"sources":["C:/Users/eudes.inacio/GabineteDigital/gabinete-digital-fo/node_modules/@firebase/messaging/dist/index.esm.js"],"sourcesContent":["import '@firebase/installations';\nimport { Component } from '@firebase/component';\nimport { ErrorFactory } from '@firebase/util';\nimport { __spreadArray, __read, __awaiter, __generator, __assign, __values } from 'tslib';\nimport { deleteDb, openDb } from 'idb';\nimport firebase from '@firebase/app';\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nvar _a;\r\nvar ERROR_MAP = (_a = {},\r\n _a[\"missing-app-config-values\" /* MISSING_APP_CONFIG_VALUES */] = 'Missing App configuration value: \"{$valueName}\"',\r\n _a[\"only-available-in-window\" /* AVAILABLE_IN_WINDOW */] = 'This method is available in a Window context.',\r\n _a[\"only-available-in-sw\" /* AVAILABLE_IN_SW */] = 'This method is available in a service worker context.',\r\n _a[\"permission-default\" /* PERMISSION_DEFAULT */] = 'The notification permission was not granted and dismissed instead.',\r\n _a[\"permission-blocked\" /* PERMISSION_BLOCKED */] = 'The notification permission was not granted and blocked instead.',\r\n _a[\"unsupported-browser\" /* UNSUPPORTED_BROWSER */] = \"This browser doesn't support the API's required to use the firebase SDK.\",\r\n _a[\"failed-service-worker-registration\" /* FAILED_DEFAULT_REGISTRATION */] = 'We are unable to register the default service worker. {$browserErrorMessage}',\r\n _a[\"token-subscribe-failed\" /* TOKEN_SUBSCRIBE_FAILED */] = 'A problem occurred while subscribing the user to FCM: {$errorInfo}',\r\n _a[\"token-subscribe-no-token\" /* TOKEN_SUBSCRIBE_NO_TOKEN */] = 'FCM returned no token when subscribing the user to push.',\r\n _a[\"token-unsubscribe-failed\" /* TOKEN_UNSUBSCRIBE_FAILED */] = 'A problem occurred while unsubscribing the ' +\r\n 'user from FCM: {$errorInfo}',\r\n _a[\"token-update-failed\" /* TOKEN_UPDATE_FAILED */] = 'A problem occurred while updating the user from FCM: {$errorInfo}',\r\n _a[\"token-update-no-token\" /* TOKEN_UPDATE_NO_TOKEN */] = 'FCM returned no token when updating the user to push.',\r\n _a[\"use-sw-after-get-token\" /* USE_SW_AFTER_GET_TOKEN */] = 'The useServiceWorker() method may only be called once and must be ' +\r\n 'called before calling getToken() to ensure your service worker is used.',\r\n _a[\"invalid-sw-registration\" /* INVALID_SW_REGISTRATION */] = 'The input to useServiceWorker() must be a ServiceWorkerRegistration.',\r\n _a[\"invalid-bg-handler\" /* INVALID_BG_HANDLER */] = 'The input to setBackgroundMessageHandler() must be a function.',\r\n _a[\"invalid-vapid-key\" /* INVALID_VAPID_KEY */] = 'The public VAPID key must be a string.',\r\n _a[\"use-vapid-key-after-get-token\" /* USE_VAPID_KEY_AFTER_GET_TOKEN */] = 'The usePublicVapidKey() method may only be called once and must be ' +\r\n 'called before calling getToken() to ensure your VAPID key is used.',\r\n _a);\r\nvar ERROR_FACTORY = new ErrorFactory('messaging', 'Messaging', ERROR_MAP);\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nvar DEFAULT_SW_PATH = '/firebase-messaging-sw.js';\r\nvar DEFAULT_SW_SCOPE = '/firebase-cloud-messaging-push-scope';\r\nvar DEFAULT_VAPID_KEY = 'BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4';\r\nvar ENDPOINT = 'https://fcmregistrations.googleapis.com/v1';\r\n// Key of FCM Payload in Notification's data field.\r\nvar FCM_MSG = 'FCM_MSG';\r\nvar TAG = 'FirebaseMessaging: ';\r\n// Set to '1' if Analytics is enabled for the campaign\r\nvar CONSOLE_CAMPAIGN_ANALYTICS_ENABLED = 'google.c.a.e';\r\nvar CONSOLE_CAMPAIGN_ID = 'google.c.a.c_id';\r\nvar CONSOLE_CAMPAIGN_TIME = 'google.c.a.ts';\r\nvar CONSOLE_CAMPAIGN_NAME = 'google.c.a.c_l';\r\n// Due to the fact that onBackgroundMessage can't be awaited (to support rxjs), a silent push\r\n// warning might be shown by the browser if the callback fails to completes by the end of onPush.\r\n// Experiments were ran to determine the majority onBackground message clock time. This brief\r\n// blocking time would allow majority of the onBackgroundMessage callback to finish.\r\nvar BACKGROUND_HANDLE_EXECUTION_TIME_LIMIT_MS = 1000;\r\n// Preparation time for client to initialize and set up the message handler.\r\nvar FOREGROUND_HANDLE_PREPARATION_TIME_MS = 3000;\n\n/**\r\n * @license\r\n * Copyright 2018 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\r\n * in compliance with the License. You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software distributed under the License\r\n * is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r\n * or implied. See the License for the specific language governing permissions and limitations under\r\n * the License.\r\n */\r\nvar MessageType;\r\n(function (MessageType) {\r\n MessageType[\"PUSH_RECEIVED\"] = \"push-received\";\r\n MessageType[\"NOTIFICATION_CLICKED\"] = \"notification-clicked\";\r\n})(MessageType || (MessageType = {}));\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nfunction arrayToBase64(array) {\r\n var uint8Array = new Uint8Array(array);\r\n var base64String = btoa(String.fromCharCode.apply(String, __spreadArray([], __read(uint8Array))));\r\n return base64String.replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_');\r\n}\r\nfunction base64ToArray(base64String) {\r\n var padding = '='.repeat((4 - (base64String.length % 4)) % 4);\r\n var base64 = (base64String + padding)\r\n .replace(/\\-/g, '+')\r\n .replace(/_/g, '/');\r\n var rawData = atob(base64);\r\n var outputArray = new Uint8Array(rawData.length);\r\n for (var i = 0; i < rawData.length; ++i) {\r\n outputArray[i] = rawData.charCodeAt(i);\r\n }\r\n return outputArray;\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nvar OLD_DB_NAME = 'fcm_token_details_db';\r\n/**\r\n * The last DB version of 'fcm_token_details_db' was 4. This is one higher, so that the upgrade\r\n * callback is called for all versions of the old DB.\r\n */\r\nvar OLD_DB_VERSION = 5;\r\nvar OLD_OBJECT_STORE_NAME = 'fcm_token_object_Store';\r\nfunction migrateOldDatabase(senderId) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var databases, dbNames, tokenDetails, db;\r\n var _this = this;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n if (!('databases' in indexedDB)) return [3 /*break*/, 2];\r\n return [4 /*yield*/, indexedDB.databases()];\r\n case 1:\r\n databases = _a.sent();\r\n dbNames = databases.map(function (db) { return db.name; });\r\n if (!dbNames.includes(OLD_DB_NAME)) {\r\n // old DB didn't exist, no need to open.\r\n return [2 /*return*/, null];\r\n }\r\n _a.label = 2;\r\n case 2:\r\n tokenDetails = null;\r\n return [4 /*yield*/, openDb(OLD_DB_NAME, OLD_DB_VERSION, function (db) { return __awaiter(_this, void 0, void 0, function () {\r\n var objectStore, value, oldDetails, oldDetails, oldDetails;\r\n var _a;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0:\r\n if (db.oldVersion < 2) {\r\n // Database too old, skip migration.\r\n return [2 /*return*/];\r\n }\r\n if (!db.objectStoreNames.contains(OLD_OBJECT_STORE_NAME)) {\r\n // Database did not exist. Nothing to do.\r\n return [2 /*return*/];\r\n }\r\n objectStore = db.transaction.objectStore(OLD_OBJECT_STORE_NAME);\r\n return [4 /*yield*/, objectStore.index('fcmSenderId').get(senderId)];\r\n case 1:\r\n value = _b.sent();\r\n return [4 /*yield*/, objectStore.clear()];\r\n case 2:\r\n _b.sent();\r\n if (!value) {\r\n // No entry in the database, nothing to migrate.\r\n return [2 /*return*/];\r\n }\r\n if (db.oldVersion === 2) {\r\n oldDetails = value;\r\n if (!oldDetails.auth || !oldDetails.p256dh || !oldDetails.endpoint) {\r\n return [2 /*return*/];\r\n }\r\n tokenDetails = {\r\n token: oldDetails.fcmToken,\r\n createTime: (_a = oldDetails.createTime) !== null && _a !== void 0 ? _a : Date.now(),\r\n subscriptionOptions: {\r\n auth: oldDetails.auth,\r\n p256dh: oldDetails.p256dh,\r\n endpoint: oldDetails.endpoint,\r\n swScope: oldDetails.swScope,\r\n vapidKey: typeof oldDetails.vapidKey === 'string'\r\n ? oldDetails.vapidKey\r\n : arrayToBase64(oldDetails.vapidKey)\r\n }\r\n };\r\n }\r\n else if (db.oldVersion === 3) {\r\n oldDetails = value;\r\n tokenDetails = {\r\n token: oldDetails.fcmToken,\r\n createTime: oldDetails.createTime,\r\n subscriptionOptions: {\r\n auth: arrayToBase64(oldDetails.auth),\r\n p256dh: arrayToBase64(oldDetails.p256dh),\r\n endpoint: oldDetails.endpoint,\r\n swScope: oldDetails.swScope,\r\n vapidKey: arrayToBase64(oldDetails.vapidKey)\r\n }\r\n };\r\n }\r\n else if (db.oldVersion === 4) {\r\n oldDetails = value;\r\n tokenDetails = {\r\n token: oldDetails.fcmToken,\r\n createTime: oldDetails.createTime,\r\n subscriptionOptions: {\r\n auth: arrayToBase64(oldDetails.auth),\r\n p256dh: arrayToBase64(oldDetails.p256dh),\r\n endpoint: oldDetails.endpoint,\r\n swScope: oldDetails.swScope,\r\n vapidKey: arrayToBase64(oldDetails.vapidKey)\r\n }\r\n };\r\n }\r\n return [2 /*return*/];\r\n }\r\n });\r\n }); })];\r\n case 3:\r\n db = _a.sent();\r\n db.close();\r\n // Delete all old databases.\r\n return [4 /*yield*/, deleteDb(OLD_DB_NAME)];\r\n case 4:\r\n // Delete all old databases.\r\n _a.sent();\r\n return [4 /*yield*/, deleteDb('fcm_vapid_details_db')];\r\n case 5:\r\n _a.sent();\r\n return [4 /*yield*/, deleteDb('undefined')];\r\n case 6:\r\n _a.sent();\r\n return [2 /*return*/, checkTokenDetails(tokenDetails) ? tokenDetails : null];\r\n }\r\n });\r\n });\r\n}\r\nfunction checkTokenDetails(tokenDetails) {\r\n if (!tokenDetails || !tokenDetails.subscriptionOptions) {\r\n return false;\r\n }\r\n var subscriptionOptions = tokenDetails.subscriptionOptions;\r\n return (typeof tokenDetails.createTime === 'number' &&\r\n tokenDetails.createTime > 0 &&\r\n typeof tokenDetails.token === 'string' &&\r\n tokenDetails.token.length > 0 &&\r\n typeof subscriptionOptions.auth === 'string' &&\r\n subscriptionOptions.auth.length > 0 &&\r\n typeof subscriptionOptions.p256dh === 'string' &&\r\n subscriptionOptions.p256dh.length > 0 &&\r\n typeof subscriptionOptions.endpoint === 'string' &&\r\n subscriptionOptions.endpoint.length > 0 &&\r\n typeof subscriptionOptions.swScope === 'string' &&\r\n subscriptionOptions.swScope.length > 0 &&\r\n typeof subscriptionOptions.vapidKey === 'string' &&\r\n subscriptionOptions.vapidKey.length > 0);\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n// Exported for tests.\r\nvar DATABASE_NAME = 'firebase-messaging-database';\r\nvar DATABASE_VERSION = 1;\r\nvar OBJECT_STORE_NAME = 'firebase-messaging-store';\r\nvar dbPromise = null;\r\nfunction getDbPromise() {\r\n if (!dbPromise) {\r\n dbPromise = openDb(DATABASE_NAME, DATABASE_VERSION, function (upgradeDb) {\r\n // We don't use 'break' in this switch statement, the fall-through behavior is what we want,\r\n // because if there are multiple versions between the old version and the current version, we\r\n // want ALL the migrations that correspond to those versions to run, not only the last one.\r\n // eslint-disable-next-line default-case\r\n switch (upgradeDb.oldVersion) {\r\n case 0:\r\n upgradeDb.createObjectStore(OBJECT_STORE_NAME);\r\n }\r\n });\r\n }\r\n return dbPromise;\r\n}\r\n/** Gets record(s) from the objectStore that match the given key. */\r\nfunction dbGet(firebaseDependencies) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var key, db, tokenDetails, oldTokenDetails;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n key = getKey(firebaseDependencies);\r\n return [4 /*yield*/, getDbPromise()];\r\n case 1:\r\n db = _a.sent();\r\n return [4 /*yield*/, db\r\n .transaction(OBJECT_STORE_NAME)\r\n .objectStore(OBJECT_STORE_NAME)\r\n .get(key)];\r\n case 2:\r\n tokenDetails = _a.sent();\r\n if (!tokenDetails) return [3 /*break*/, 3];\r\n return [2 /*return*/, tokenDetails];\r\n case 3: return [4 /*yield*/, migrateOldDatabase(firebaseDependencies.appConfig.senderId)];\r\n case 4:\r\n oldTokenDetails = _a.sent();\r\n if (!oldTokenDetails) return [3 /*break*/, 6];\r\n return [4 /*yield*/, dbSet(firebaseDependencies, oldTokenDetails)];\r\n case 5:\r\n _a.sent();\r\n return [2 /*return*/, oldTokenDetails];\r\n case 6: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\r\n/** Assigns or overwrites the record for the given key with the given value. */\r\nfunction dbSet(firebaseDependencies, tokenDetails) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var key, db, tx;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n key = getKey(firebaseDependencies);\r\n return [4 /*yield*/, getDbPromise()];\r\n case 1:\r\n db = _a.sent();\r\n tx = db.transaction(OBJECT_STORE_NAME, 'readwrite');\r\n return [4 /*yield*/, tx.objectStore(OBJECT_STORE_NAME).put(tokenDetails, key)];\r\n case 2:\r\n _a.sent();\r\n return [4 /*yield*/, tx.complete];\r\n case 3:\r\n _a.sent();\r\n return [2 /*return*/, tokenDetails];\r\n }\r\n });\r\n });\r\n}\r\n/** Removes record(s) from the objectStore that match the given key. */\r\nfunction dbRemove(firebaseDependencies) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var key, db, tx;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n key = getKey(firebaseDependencies);\r\n return [4 /*yield*/, getDbPromise()];\r\n case 1:\r\n db = _a.sent();\r\n tx = db.transaction(OBJECT_STORE_NAME, 'readwrite');\r\n return [4 /*yield*/, tx.objectStore(OBJECT_STORE_NAME).delete(key)];\r\n case 2:\r\n _a.sent();\r\n return [4 /*yield*/, tx.complete];\r\n case 3:\r\n _a.sent();\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\r\nfunction getKey(_a) {\r\n var appConfig = _a.appConfig;\r\n return appConfig.appId;\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nfunction requestGetToken(firebaseDependencies, subscriptionOptions) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var headers, body, subscribeOptions, responseData, response, err_1, message;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, getHeaders(firebaseDependencies)];\r\n case 1:\r\n headers = _a.sent();\r\n body = getBody(subscriptionOptions);\r\n subscribeOptions = {\r\n method: 'POST',\r\n headers: headers,\r\n body: JSON.stringify(body)\r\n };\r\n _a.label = 2;\r\n case 2:\r\n _a.trys.push([2, 5, , 6]);\r\n return [4 /*yield*/, fetch(getEndpoint(firebaseDependencies.appConfig), subscribeOptions)];\r\n case 3:\r\n response = _a.sent();\r\n return [4 /*yield*/, response.json()];\r\n case 4:\r\n responseData = _a.sent();\r\n return [3 /*break*/, 6];\r\n case 5:\r\n err_1 = _a.sent();\r\n throw ERROR_FACTORY.create(\"token-subscribe-failed\" /* TOKEN_SUBSCRIBE_FAILED */, {\r\n errorInfo: err_1\r\n });\r\n case 6:\r\n if (responseData.error) {\r\n message = responseData.error.message;\r\n throw ERROR_FACTORY.create(\"token-subscribe-failed\" /* TOKEN_SUBSCRIBE_FAILED */, {\r\n errorInfo: message\r\n });\r\n }\r\n if (!responseData.token) {\r\n throw ERROR_FACTORY.create(\"token-subscribe-no-token\" /* TOKEN_SUBSCRIBE_NO_TOKEN */);\r\n }\r\n return [2 /*return*/, responseData.token];\r\n }\r\n });\r\n });\r\n}\r\nfunction requestUpdateToken(firebaseDependencies, tokenDetails) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var headers, body, updateOptions, responseData, response, err_2, message;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, getHeaders(firebaseDependencies)];\r\n case 1:\r\n headers = _a.sent();\r\n body = getBody(tokenDetails.subscriptionOptions);\r\n updateOptions = {\r\n method: 'PATCH',\r\n headers: headers,\r\n body: JSON.stringify(body)\r\n };\r\n _a.label = 2;\r\n case 2:\r\n _a.trys.push([2, 5, , 6]);\r\n return [4 /*yield*/, fetch(getEndpoint(firebaseDependencies.appConfig) + \"/\" + tokenDetails.token, updateOptions)];\r\n case 3:\r\n response = _a.sent();\r\n return [4 /*yield*/, response.json()];\r\n case 4:\r\n responseData = _a.sent();\r\n return [3 /*break*/, 6];\r\n case 5:\r\n err_2 = _a.sent();\r\n throw ERROR_FACTORY.create(\"token-update-failed\" /* TOKEN_UPDATE_FAILED */, {\r\n errorInfo: err_2\r\n });\r\n case 6:\r\n if (responseData.error) {\r\n message = responseData.error.message;\r\n throw ERROR_FACTORY.create(\"token-update-failed\" /* TOKEN_UPDATE_FAILED */, {\r\n errorInfo: message\r\n });\r\n }\r\n if (!responseData.token) {\r\n throw ERROR_FACTORY.create(\"token-update-no-token\" /* TOKEN_UPDATE_NO_TOKEN */);\r\n }\r\n return [2 /*return*/, responseData.token];\r\n }\r\n });\r\n });\r\n}\r\nfunction requestDeleteToken(firebaseDependencies, token) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var headers, unsubscribeOptions, response, responseData, message, err_3;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, getHeaders(firebaseDependencies)];\r\n case 1:\r\n headers = _a.sent();\r\n unsubscribeOptions = {\r\n method: 'DELETE',\r\n headers: headers\r\n };\r\n _a.label = 2;\r\n case 2:\r\n _a.trys.push([2, 5, , 6]);\r\n return [4 /*yield*/, fetch(getEndpoint(firebaseDependencies.appConfig) + \"/\" + token, unsubscribeOptions)];\r\n case 3:\r\n response = _a.sent();\r\n return [4 /*yield*/, response.json()];\r\n case 4:\r\n responseData = _a.sent();\r\n if (responseData.error) {\r\n message = responseData.error.message;\r\n throw ERROR_FACTORY.create(\"token-unsubscribe-failed\" /* TOKEN_UNSUBSCRIBE_FAILED */, {\r\n errorInfo: message\r\n });\r\n }\r\n return [3 /*break*/, 6];\r\n case 5:\r\n err_3 = _a.sent();\r\n throw ERROR_FACTORY.create(\"token-unsubscribe-failed\" /* TOKEN_UNSUBSCRIBE_FAILED */, {\r\n errorInfo: err_3\r\n });\r\n case 6: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\r\nfunction getEndpoint(_a) {\r\n var projectId = _a.projectId;\r\n return ENDPOINT + \"/projects/\" + projectId + \"/registrations\";\r\n}\r\nfunction getHeaders(_a) {\r\n var appConfig = _a.appConfig, installations = _a.installations;\r\n return __awaiter(this, void 0, void 0, function () {\r\n var authToken;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0: return [4 /*yield*/, installations.getToken()];\r\n case 1:\r\n authToken = _b.sent();\r\n return [2 /*return*/, new Headers({\r\n 'Content-Type': 'application/json',\r\n Accept: 'application/json',\r\n 'x-goog-api-key': appConfig.apiKey,\r\n 'x-goog-firebase-installations-auth': \"FIS \" + authToken\r\n })];\r\n }\r\n });\r\n });\r\n}\r\nfunction getBody(_a) {\r\n var p256dh = _a.p256dh, auth = _a.auth, endpoint = _a.endpoint, vapidKey = _a.vapidKey;\r\n var body = {\r\n web: {\r\n endpoint: endpoint,\r\n auth: auth,\r\n p256dh: p256dh\r\n }\r\n };\r\n if (vapidKey !== DEFAULT_VAPID_KEY) {\r\n body.web.applicationPubKey = vapidKey;\r\n }\r\n return body;\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/** UpdateRegistration will be called once every week. */\r\nvar TOKEN_EXPIRATION_MS = 7 * 24 * 60 * 60 * 1000; // 7 days\r\nfunction getToken(firebaseDependencies, swRegistration, vapidKey) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var pushSubscription, tokenDetails, subscriptionOptions, e_1;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n if (Notification.permission !== 'granted') {\r\n throw ERROR_FACTORY.create(\"permission-blocked\" /* PERMISSION_BLOCKED */);\r\n }\r\n return [4 /*yield*/, getPushSubscription(swRegistration, vapidKey)];\r\n case 1:\r\n pushSubscription = _a.sent();\r\n return [4 /*yield*/, dbGet(firebaseDependencies)];\r\n case 2:\r\n tokenDetails = _a.sent();\r\n subscriptionOptions = {\r\n vapidKey: vapidKey,\r\n swScope: swRegistration.scope,\r\n endpoint: pushSubscription.endpoint,\r\n auth: arrayToBase64(pushSubscription.getKey('auth')),\r\n p256dh: arrayToBase64(pushSubscription.getKey('p256dh'))\r\n };\r\n if (!!tokenDetails) return [3 /*break*/, 3];\r\n // No token, get a new one.\r\n return [2 /*return*/, getNewToken(firebaseDependencies, subscriptionOptions)];\r\n case 3:\r\n if (!!isTokenValid(tokenDetails.subscriptionOptions, subscriptionOptions)) return [3 /*break*/, 8];\r\n _a.label = 4;\r\n case 4:\r\n _a.trys.push([4, 6, , 7]);\r\n return [4 /*yield*/, requestDeleteToken(firebaseDependencies, tokenDetails.token)];\r\n case 5:\r\n _a.sent();\r\n return [3 /*break*/, 7];\r\n case 6:\r\n e_1 = _a.sent();\r\n // Suppress errors because of #2364\r\n console.warn(e_1);\r\n return [3 /*break*/, 7];\r\n case 7: return [2 /*return*/, getNewToken(firebaseDependencies, subscriptionOptions)];\r\n case 8:\r\n if (Date.now() >= tokenDetails.createTime + TOKEN_EXPIRATION_MS) {\r\n // Weekly token refresh\r\n return [2 /*return*/, updateToken({\r\n token: tokenDetails.token,\r\n createTime: Date.now(),\r\n subscriptionOptions: subscriptionOptions\r\n }, firebaseDependencies, swRegistration)];\r\n }\r\n else {\r\n // Valid token, nothing to do.\r\n return [2 /*return*/, tokenDetails.token];\r\n }\r\n case 9: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\r\n/**\r\n * This method deletes the token from the database, unsubscribes the token from FCM, and unregisters\r\n * the push subscription if it exists.\r\n */\r\nfunction deleteToken(firebaseDependencies, swRegistration) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var tokenDetails, pushSubscription;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, dbGet(firebaseDependencies)];\r\n case 1:\r\n tokenDetails = _a.sent();\r\n if (!tokenDetails) return [3 /*break*/, 4];\r\n return [4 /*yield*/, requestDeleteToken(firebaseDependencies, tokenDetails.token)];\r\n case 2:\r\n _a.sent();\r\n return [4 /*yield*/, dbRemove(firebaseDependencies)];\r\n case 3:\r\n _a.sent();\r\n _a.label = 4;\r\n case 4: return [4 /*yield*/, swRegistration.pushManager.getSubscription()];\r\n case 5:\r\n pushSubscription = _a.sent();\r\n if (pushSubscription) {\r\n return [2 /*return*/, pushSubscription.unsubscribe()];\r\n }\r\n // If there's no SW, consider it a success.\r\n return [2 /*return*/, true];\r\n }\r\n });\r\n });\r\n}\r\nfunction updateToken(tokenDetails, firebaseDependencies, swRegistration) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var updatedToken, updatedTokenDetails, e_2;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n _a.trys.push([0, 3, , 5]);\r\n return [4 /*yield*/, requestUpdateToken(firebaseDependencies, tokenDetails)];\r\n case 1:\r\n updatedToken = _a.sent();\r\n updatedTokenDetails = __assign(__assign({}, tokenDetails), { token: updatedToken, createTime: Date.now() });\r\n return [4 /*yield*/, dbSet(firebaseDependencies, updatedTokenDetails)];\r\n case 2:\r\n _a.sent();\r\n return [2 /*return*/, updatedToken];\r\n case 3:\r\n e_2 = _a.sent();\r\n return [4 /*yield*/, deleteToken(firebaseDependencies, swRegistration)];\r\n case 4:\r\n _a.sent();\r\n throw e_2;\r\n case 5: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\r\nfunction getNewToken(firebaseDependencies, subscriptionOptions) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var token, tokenDetails;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, requestGetToken(firebaseDependencies, subscriptionOptions)];\r\n case 1:\r\n token = _a.sent();\r\n tokenDetails = {\r\n token: token,\r\n createTime: Date.now(),\r\n subscriptionOptions: subscriptionOptions\r\n };\r\n return [4 /*yield*/, dbSet(firebaseDependencies, tokenDetails)];\r\n case 2:\r\n _a.sent();\r\n return [2 /*return*/, tokenDetails.token];\r\n }\r\n });\r\n });\r\n}\r\n/**\r\n * Gets a PushSubscription for the current user.\r\n */\r\nfunction getPushSubscription(swRegistration, vapidKey) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var subscription;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, swRegistration.pushManager.getSubscription()];\r\n case 1:\r\n subscription = _a.sent();\r\n if (subscription) {\r\n return [2 /*return*/, subscription];\r\n }\r\n return [2 /*return*/, swRegistration.pushManager.subscribe({\r\n userVisibleOnly: true,\r\n // Chrome <= 75 doesn't support base64-encoded VAPID key. For backward compatibility, VAPID key\r\n // submitted to pushManager#subscribe must be of type Uint8Array.\r\n applicationServerKey: base64ToArray(vapidKey)\r\n })];\r\n }\r\n });\r\n });\r\n}\r\n/**\r\n * Checks if the saved tokenDetails object matches the configuration provided.\r\n */\r\nfunction isTokenValid(dbOptions, currentOptions) {\r\n var isVapidKeyEqual = currentOptions.vapidKey === dbOptions.vapidKey;\r\n var isEndpointEqual = currentOptions.endpoint === dbOptions.endpoint;\r\n var isAuthEqual = currentOptions.auth === dbOptions.auth;\r\n var isP256dhEqual = currentOptions.p256dh === dbOptions.p256dh;\r\n return isVapidKeyEqual && isEndpointEqual && isAuthEqual && isP256dhEqual;\r\n}\n\n/**\r\n * @license\r\n * Copyright 2020 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nfunction externalizePayload(internalPayload) {\r\n var payload = {\r\n from: internalPayload.from,\r\n // eslint-disable-next-line camelcase\r\n collapseKey: internalPayload.collapse_key,\r\n // eslint-disable-next-line camelcase\r\n messageId: internalPayload.fcm_message_id\r\n };\r\n propagateNotificationPayload(payload, internalPayload);\r\n propagateDataPayload(payload, internalPayload);\r\n propagateFcmOptions(payload, internalPayload);\r\n return payload;\r\n}\r\nfunction propagateNotificationPayload(payload, messagePayloadInternal) {\r\n if (!messagePayloadInternal.notification) {\r\n return;\r\n }\r\n payload.notification = {};\r\n var title = messagePayloadInternal.notification.title;\r\n if (!!title) {\r\n payload.notification.title = title;\r\n }\r\n var body = messagePayloadInternal.notification.body;\r\n if (!!body) {\r\n payload.notification.body = body;\r\n }\r\n var image = messagePayloadInternal.notification.image;\r\n if (!!image) {\r\n payload.notification.image = image;\r\n }\r\n}\r\nfunction propagateDataPayload(payload, messagePayloadInternal) {\r\n if (!messagePayloadInternal.data) {\r\n return;\r\n }\r\n payload.data = messagePayloadInternal.data;\r\n}\r\nfunction propagateFcmOptions(payload, messagePayloadInternal) {\r\n if (!messagePayloadInternal.fcmOptions) {\r\n return;\r\n }\r\n payload.fcmOptions = {};\r\n var link = messagePayloadInternal.fcmOptions.link;\r\n if (!!link) {\r\n payload.fcmOptions.link = link;\r\n }\r\n // eslint-disable-next-line camelcase\r\n var analyticsLabel = messagePayloadInternal.fcmOptions.analytics_label;\r\n if (!!analyticsLabel) {\r\n payload.fcmOptions.analyticsLabel = analyticsLabel;\r\n }\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nfunction isConsoleMessage(data) {\r\n // This message has a campaign ID, meaning it was sent using the Firebase Console.\r\n return typeof data === 'object' && !!data && CONSOLE_CAMPAIGN_ID in data;\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/** Returns a promise that resolves after given time passes. */\r\nfunction sleep(ms) {\r\n return new Promise(function (resolve) {\r\n setTimeout(resolve, ms);\r\n });\r\n}\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nvar SwController = /** @class */ (function () {\r\n function SwController(firebaseDependencies) {\r\n var _this = this;\r\n this.firebaseDependencies = firebaseDependencies;\r\n // A boolean flag to determine wether an app is using onBackgroundMessage or\r\n // setBackgroundMessageHandler. onBackgroundMessage will receive a MessagePayload regardless of if\r\n // a notification is displayed. Whereas, setBackgroundMessageHandler will swallow the\r\n // MessagePayload if a NotificationPayload is included.\r\n this.isOnBackgroundMessageUsed = null;\r\n this.vapidKey = null;\r\n this.bgMessageHandler = null;\r\n self.addEventListener('push', function (e) {\r\n e.waitUntil(_this.onPush(e));\r\n });\r\n self.addEventListener('pushsubscriptionchange', function (e) {\r\n e.waitUntil(_this.onSubChange(e));\r\n });\r\n self.addEventListener('notificationclick', function (e) {\r\n e.waitUntil(_this.onNotificationClick(e));\r\n });\r\n }\r\n Object.defineProperty(SwController.prototype, \"app\", {\r\n get: function () {\r\n return this.firebaseDependencies.app;\r\n },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n /**\r\n * @deprecated. Use onBackgroundMessage(nextOrObserver: NextFn<object> | Observer<object>):\r\n * Unsubscribe instead.\r\n *\r\n * Calling setBackgroundMessageHandler will opt in to some specific behaviors.\r\n *\r\n * 1.) If a notification doesn't need to be shown due to a window already being visible, then push\r\n * messages will be sent to the page. 2.) If a notification needs to be shown, and the message\r\n * contains no notification data this method will be called and the promise it returns will be\r\n * passed to event.waitUntil. If you do not set this callback then all push messages will let and\r\n * the developer can handle them in a their own 'push' event callback\r\n *\r\n * @param callback The callback to be called when a push message is received and a notification\r\n * must be shown. The callback will be given the data from the push message.\r\n */\r\n SwController.prototype.setBackgroundMessageHandler = function (callback) {\r\n this.isOnBackgroundMessageUsed = false;\r\n if (!callback || typeof callback !== 'function') {\r\n throw ERROR_FACTORY.create(\"invalid-bg-handler\" /* INVALID_BG_HANDLER */);\r\n }\r\n this.bgMessageHandler = callback;\r\n };\r\n SwController.prototype.onBackgroundMessage = function (nextOrObserver) {\r\n var _this = this;\r\n this.isOnBackgroundMessageUsed = true;\r\n this.bgMessageHandler = nextOrObserver;\r\n return function () {\r\n _this.bgMessageHandler = null;\r\n };\r\n };\r\n // TODO: Remove getToken from SW Controller. Calling this from an old SW can cause all kinds of\r\n // trouble.\r\n SwController.prototype.getToken = function () {\r\n var _a, _b;\r\n return __awaiter(this, void 0, void 0, function () {\r\n var tokenDetails;\r\n return __generator(this, function (_c) {\r\n switch (_c.label) {\r\n case 0:\r\n if (!!this.vapidKey) return [3 /*break*/, 2];\r\n return [4 /*yield*/, dbGet(this.firebaseDependencies)];\r\n case 1:\r\n tokenDetails = _c.sent();\r\n this.vapidKey =\r\n (_b = (_a = tokenDetails === null || tokenDetails === void 0 ? void 0 : tokenDetails.subscriptionOptions) === null || _a === void 0 ? void 0 : _a.vapidKey) !== null && _b !== void 0 ? _b : DEFAULT_VAPID_KEY;\r\n _c.label = 2;\r\n case 2: return [2 /*return*/, getToken(this.firebaseDependencies, self.registration, this.vapidKey)];\r\n }\r\n });\r\n });\r\n };\r\n // TODO: Remove deleteToken from SW Controller. Calling this from an old SW can cause all kinds of\r\n // trouble.\r\n SwController.prototype.deleteToken = function () {\r\n return deleteToken(this.firebaseDependencies, self.registration);\r\n };\r\n SwController.prototype.requestPermission = function () {\r\n throw ERROR_FACTORY.create(\"only-available-in-window\" /* AVAILABLE_IN_WINDOW */);\r\n };\r\n // TODO: Remove this together with getToken from SW Controller.\r\n SwController.prototype.usePublicVapidKey = function (vapidKey) {\r\n if (this.vapidKey !== null) {\r\n throw ERROR_FACTORY.create(\"use-vapid-key-after-get-token\" /* USE_VAPID_KEY_AFTER_GET_TOKEN */);\r\n }\r\n if (typeof vapidKey !== 'string' || vapidKey.length === 0) {\r\n throw ERROR_FACTORY.create(\"invalid-vapid-key\" /* INVALID_VAPID_KEY */);\r\n }\r\n this.vapidKey = vapidKey;\r\n };\r\n SwController.prototype.useServiceWorker = function () {\r\n throw ERROR_FACTORY.create(\"only-available-in-window\" /* AVAILABLE_IN_WINDOW */);\r\n };\r\n SwController.prototype.onMessage = function () {\r\n throw ERROR_FACTORY.create(\"only-available-in-window\" /* AVAILABLE_IN_WINDOW */);\r\n };\r\n SwController.prototype.onTokenRefresh = function () {\r\n throw ERROR_FACTORY.create(\"only-available-in-window\" /* AVAILABLE_IN_WINDOW */);\r\n };\r\n /**\r\n * A handler for push events that shows notifications based on the content of the payload.\r\n *\r\n * The payload must be a JSON-encoded Object with a `notification` key. The value of the\r\n * `notification` property will be used as the NotificationOptions object passed to\r\n * showNotification. Additionally, the `title` property of the notification object will be used as\r\n * the title.\r\n *\r\n * If there is no notification data in the payload then no notification will be shown.\r\n */\r\n SwController.prototype.onPush = function (event) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var internalPayload, clientList, isNotificationShown, payload;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n internalPayload = getMessagePayloadInternal(event);\r\n if (!internalPayload) {\r\n console.debug(TAG +\r\n 'failed to get parsed MessagePayload from the PushEvent. Skip handling the push.');\r\n return [2 /*return*/];\r\n }\r\n return [4 /*yield*/, getClientList()];\r\n case 1:\r\n clientList = _a.sent();\r\n if (hasVisibleClients(clientList)) {\r\n return [2 /*return*/, sendMessagePayloadInternalToWindows(clientList, internalPayload)];\r\n }\r\n isNotificationShown = false;\r\n if (!!!internalPayload.notification) return [3 /*break*/, 3];\r\n return [4 /*yield*/, showNotification(wrapInternalPayload(internalPayload))];\r\n case 2:\r\n _a.sent();\r\n isNotificationShown = true;\r\n _a.label = 3;\r\n case 3:\r\n // MessagePayload is only passed to `onBackgroundMessage`. Skip passing MessagePayload for\r\n // the legacy `setBackgroundMessageHandler` to preserve the SDK behaviors.\r\n if (isNotificationShown === true &&\r\n this.isOnBackgroundMessageUsed === false) {\r\n return [2 /*return*/];\r\n }\r\n if (!!this.bgMessageHandler) {\r\n payload = externalizePayload(internalPayload);\r\n if (typeof this.bgMessageHandler === 'function') {\r\n this.bgMessageHandler(payload);\r\n }\r\n else {\r\n this.bgMessageHandler.next(payload);\r\n }\r\n }\r\n // wait briefly to allow onBackgroundMessage to complete\r\n return [4 /*yield*/, sleep(BACKGROUND_HANDLE_EXECUTION_TIME_LIMIT_MS)];\r\n case 4:\r\n // wait briefly to allow onBackgroundMessage to complete\r\n _a.sent();\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n SwController.prototype.onSubChange = function (event) {\r\n var _a, _b;\r\n return __awaiter(this, void 0, void 0, function () {\r\n var newSubscription, tokenDetails;\r\n return __generator(this, function (_c) {\r\n switch (_c.label) {\r\n case 0:\r\n newSubscription = event.newSubscription;\r\n if (!!newSubscription) return [3 /*break*/, 2];\r\n // Subscription revoked, delete token\r\n return [4 /*yield*/, deleteToken(this.firebaseDependencies, self.registration)];\r\n case 1:\r\n // Subscription revoked, delete token\r\n _c.sent();\r\n return [2 /*return*/];\r\n case 2: return [4 /*yield*/, dbGet(this.firebaseDependencies)];\r\n case 3:\r\n tokenDetails = _c.sent();\r\n return [4 /*yield*/, deleteToken(this.firebaseDependencies, self.registration)];\r\n case 4:\r\n _c.sent();\r\n return [4 /*yield*/, getToken(this.firebaseDependencies, self.registration, (_b = (_a = tokenDetails === null || tokenDetails === void 0 ? void 0 : tokenDetails.subscriptionOptions) === null || _a === void 0 ? void 0 : _a.vapidKey) !== null && _b !== void 0 ? _b : DEFAULT_VAPID_KEY)];\r\n case 5:\r\n _c.sent();\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n SwController.prototype.onNotificationClick = function (event) {\r\n var _a, _b;\r\n return __awaiter(this, void 0, void 0, function () {\r\n var internalPayload, link, url, originUrl, client;\r\n return __generator(this, function (_c) {\r\n switch (_c.label) {\r\n case 0:\r\n internalPayload = (_b = (_a = event.notification) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b[FCM_MSG];\r\n if (!internalPayload) {\r\n return [2 /*return*/];\r\n }\r\n else if (event.action) {\r\n // User clicked on an action button. This will allow developers to act on action button clicks\r\n // by using a custom onNotificationClick listener that they define.\r\n return [2 /*return*/];\r\n }\r\n // Prevent other listeners from receiving the event\r\n event.stopImmediatePropagation();\r\n event.notification.close();\r\n link = getLink(internalPayload);\r\n if (!link) {\r\n return [2 /*return*/];\r\n }\r\n url = new URL(link, self.location.href);\r\n originUrl = new URL(self.location.origin);\r\n if (url.host !== originUrl.host) {\r\n return [2 /*return*/];\r\n }\r\n return [4 /*yield*/, getWindowClient(url)];\r\n case 1:\r\n client = _c.sent();\r\n if (!!client) return [3 /*break*/, 4];\r\n return [4 /*yield*/, self.clients.openWindow(link)];\r\n case 2:\r\n client = _c.sent();\r\n // Wait three seconds for the client to initialize and set up the message handler so that it\r\n // can receive the message.\r\n return [4 /*yield*/, sleep(FOREGROUND_HANDLE_PREPARATION_TIME_MS)];\r\n case 3:\r\n // Wait three seconds for the client to initialize and set up the message handler so that it\r\n // can receive the message.\r\n _c.sent();\r\n return [3 /*break*/, 6];\r\n case 4: return [4 /*yield*/, client.focus()];\r\n case 5:\r\n client = _c.sent();\r\n _c.label = 6;\r\n case 6:\r\n if (!client) {\r\n // Window Client will not be returned if it's for a third party origin.\r\n return [2 /*return*/];\r\n }\r\n internalPayload.messageType = MessageType.NOTIFICATION_CLICKED;\r\n internalPayload.isFirebaseMessaging = true;\r\n return [2 /*return*/, client.postMessage(internalPayload)];\r\n }\r\n });\r\n });\r\n };\r\n return SwController;\r\n}());\r\nfunction wrapInternalPayload(internalPayload) {\r\n var _a;\r\n var wrappedInternalPayload = __assign({}, internalPayload.notification);\r\n // Put the message payload under FCM_MSG name so we can identify the notification as being an FCM\r\n // notification vs a notification from somewhere else (i.e. normal web push or developer generated\r\n // notification).\r\n wrappedInternalPayload.data = (_a = {},\r\n _a[FCM_MSG] = internalPayload,\r\n _a);\r\n return wrappedInternalPayload;\r\n}\r\nfunction getMessagePayloadInternal(_a) {\r\n var data = _a.data;\r\n if (!data) {\r\n return null;\r\n }\r\n try {\r\n return data.json();\r\n }\r\n catch (err) {\r\n // Not JSON so not an FCM message.\r\n return null;\r\n }\r\n}\r\n/**\r\n * @param url The URL to look for when focusing a client.\r\n * @return Returns an existing window client or a newly opened WindowClient.\r\n */\r\nfunction getWindowClient(url) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var clientList, clientList_1, clientList_1_1, client, clientUrl;\r\n var e_1, _a;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0: return [4 /*yield*/, getClientList()];\r\n case 1:\r\n clientList = _b.sent();\r\n try {\r\n for (clientList_1 = __values(clientList), clientList_1_1 = clientList_1.next(); !clientList_1_1.done; clientList_1_1 = clientList_1.next()) {\r\n client = clientList_1_1.value;\r\n clientUrl = new URL(client.url, self.location.href);\r\n if (url.host === clientUrl.host) {\r\n return [2 /*return*/, client];\r\n }\r\n }\r\n }\r\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\r\n finally {\r\n try {\r\n if (clientList_1_1 && !clientList_1_1.done && (_a = clientList_1.return)) _a.call(clientList_1);\r\n }\r\n finally { if (e_1) throw e_1.error; }\r\n }\r\n return [2 /*return*/, null];\r\n }\r\n });\r\n });\r\n}\r\n/**\r\n * @returns If there is currently a visible WindowClient, this method will resolve to true,\r\n * otherwise false.\r\n */\r\nfunction hasVisibleClients(clientList) {\r\n return clientList.some(function (client) {\r\n return client.visibilityState === 'visible' &&\r\n // Ignore chrome-extension clients as that matches the background pages of extensions, which\r\n // are always considered visible for some reason.\r\n !client.url.startsWith('chrome-extension://');\r\n });\r\n}\r\nfunction sendMessagePayloadInternalToWindows(clientList, internalPayload) {\r\n var e_2, _a;\r\n internalPayload.isFirebaseMessaging = true;\r\n internalPayload.messageType = MessageType.PUSH_RECEIVED;\r\n try {\r\n for (var clientList_2 = __values(clientList), clientList_2_1 = clientList_2.next(); !clientList_2_1.done; clientList_2_1 = clientList_2.next()) {\r\n var client = clientList_2_1.value;\r\n client.postMessage(internalPayload);\r\n }\r\n }\r\n catch (e_2_1) { e_2 = { error: e_2_1 }; }\r\n finally {\r\n try {\r\n if (clientList_2_1 && !clientList_2_1.done && (_a = clientList_2.return)) _a.call(clientList_2);\r\n }\r\n finally { if (e_2) throw e_2.error; }\r\n }\r\n}\r\nfunction getClientList() {\r\n return self.clients.matchAll({\r\n type: 'window',\r\n includeUncontrolled: true\r\n // TS doesn't know that \"type: 'window'\" means it'll return WindowClient[]\r\n });\r\n}\r\nfunction showNotification(notificationPayloadInternal) {\r\n var _a;\r\n // Note: Firefox does not support the maxActions property.\r\n // https://developer.mozilla.org/en-US/docs/Web/API/notification/maxActions\r\n var actions = notificationPayloadInternal.actions;\r\n var maxActions = Notification.maxActions;\r\n if (actions && maxActions && actions.length > maxActions) {\r\n console.warn(\"This browser only supports \" + maxActions + \" actions. The remaining actions will not be displayed.\");\r\n }\r\n return self.registration.showNotification(\r\n /* title= */ (_a = notificationPayloadInternal.title) !== null && _a !== void 0 ? _a : '', notificationPayloadInternal);\r\n}\r\nfunction getLink(payload) {\r\n var _a, _b, _c;\r\n // eslint-disable-next-line camelcase\r\n var link = (_b = (_a = payload.fcmOptions) === null || _a === void 0 ? void 0 : _a.link) !== null && _b !== void 0 ? _b : (_c = payload.notification) === null || _c === void 0 ? void 0 : _c.click_action;\r\n if (link) {\r\n return link;\r\n }\r\n if (isConsoleMessage(payload.data)) {\r\n // Notification created in the Firebase Console. Redirect to origin.\r\n return self.location.origin;\r\n }\r\n else {\r\n return null;\r\n }\r\n}\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nvar WindowController = /** @class */ (function () {\r\n function WindowController(firebaseDependencies) {\r\n var _this = this;\r\n this.firebaseDependencies = firebaseDependencies;\r\n this.vapidKey = null;\r\n this.onMessageCallback = null;\r\n navigator.serviceWorker.addEventListener('message', function (e) {\r\n return _this.messageEventListener(e);\r\n });\r\n }\r\n Object.defineProperty(WindowController.prototype, \"app\", {\r\n get: function () {\r\n return this.firebaseDependencies.app;\r\n },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n WindowController.prototype.messageEventListener = function (event) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var internalPayload, dataPayload;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n internalPayload = event.data;\r\n if (!internalPayload.isFirebaseMessaging) {\r\n return [2 /*return*/];\r\n }\r\n // onMessageCallback is either a function or observer/subscriber.\r\n // TODO: in the modularization release, have onMessage handle type MessagePayload as supposed to\r\n // the legacy payload where some fields are in snake cases.\r\n if (this.onMessageCallback &&\r\n internalPayload.messageType === MessageType.PUSH_RECEIVED) {\r\n if (typeof this.onMessageCallback === 'function') {\r\n this.onMessageCallback(stripInternalFields(Object.assign({}, internalPayload)));\r\n }\r\n else {\r\n this.onMessageCallback.next(Object.assign({}, internalPayload));\r\n }\r\n }\r\n dataPayload = internalPayload.data;\r\n if (!(isConsoleMessage(dataPayload) &&\r\n dataPayload[CONSOLE_CAMPAIGN_ANALYTICS_ENABLED] === '1')) return [3 /*break*/, 2];\r\n return [4 /*yield*/, this.logEvent(internalPayload.messageType, dataPayload)];\r\n case 1:\r\n _a.sent();\r\n _a.label = 2;\r\n case 2: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n WindowController.prototype.getVapidKey = function () {\r\n return this.vapidKey;\r\n };\r\n WindowController.prototype.getSwReg = function () {\r\n return this.swRegistration;\r\n };\r\n WindowController.prototype.getToken = function (options) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n if (!(Notification.permission === 'default')) return [3 /*break*/, 2];\r\n return [4 /*yield*/, Notification.requestPermission()];\r\n case 1:\r\n _a.sent();\r\n _a.label = 2;\r\n case 2:\r\n if (Notification.permission !== 'granted') {\r\n throw ERROR_FACTORY.create(\"permission-blocked\" /* PERMISSION_BLOCKED */);\r\n }\r\n return [4 /*yield*/, this.updateVapidKey(options === null || options === void 0 ? void 0 : options.vapidKey)];\r\n case 3:\r\n _a.sent();\r\n return [4 /*yield*/, this.updateSwReg(options === null || options === void 0 ? void 0 : options.serviceWorkerRegistration)];\r\n case 4:\r\n _a.sent();\r\n return [2 /*return*/, getToken(this.firebaseDependencies, this.swRegistration, this.vapidKey)];\r\n }\r\n });\r\n });\r\n };\r\n WindowController.prototype.updateVapidKey = function (vapidKey) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n return __generator(this, function (_a) {\r\n if (!!vapidKey) {\r\n this.vapidKey = vapidKey;\r\n }\r\n else if (!this.vapidKey) {\r\n this.vapidKey = DEFAULT_VAPID_KEY;\r\n }\r\n return [2 /*return*/];\r\n });\r\n });\r\n };\r\n WindowController.prototype.updateSwReg = function (swRegistration) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n if (!(!swRegistration && !this.swRegistration)) return [3 /*break*/, 2];\r\n return [4 /*yield*/, this.registerDefaultSw()];\r\n case 1:\r\n _a.sent();\r\n _a.label = 2;\r\n case 2:\r\n if (!swRegistration && !!this.swRegistration) {\r\n return [2 /*return*/];\r\n }\r\n if (!(swRegistration instanceof ServiceWorkerRegistration)) {\r\n throw ERROR_FACTORY.create(\"invalid-sw-registration\" /* INVALID_SW_REGISTRATION */);\r\n }\r\n this.swRegistration = swRegistration;\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n WindowController.prototype.registerDefaultSw = function () {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var _a, e_1;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0:\r\n _b.trys.push([0, 2, , 3]);\r\n _a = this;\r\n return [4 /*yield*/, navigator.serviceWorker.register(DEFAULT_SW_PATH, {\r\n scope: DEFAULT_SW_SCOPE\r\n })];\r\n case 1:\r\n _a.swRegistration = _b.sent();\r\n // The timing when browser updates sw when sw has an update is unreliable by my experiment. It\r\n // leads to version conflict when the SDK upgrades to a newer version in the main page, but sw\r\n // is stuck with the old version. For example,\r\n // https://github.com/firebase/firebase-js-sdk/issues/2590 The following line reliably updates\r\n // sw if there was an update.\r\n this.swRegistration.update().catch(function () {\r\n /* it is non blocking and we don't care if it failed */\r\n });\r\n return [3 /*break*/, 3];\r\n case 2:\r\n e_1 = _b.sent();\r\n throw ERROR_FACTORY.create(\"failed-service-worker-registration\" /* FAILED_DEFAULT_REGISTRATION */, {\r\n browserErrorMessage: e_1.message\r\n });\r\n case 3: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n WindowController.prototype.deleteToken = function () {\r\n return __awaiter(this, void 0, void 0, function () {\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n if (!!this.swRegistration) return [3 /*break*/, 2];\r\n return [4 /*yield*/, this.registerDefaultSw()];\r\n case 1:\r\n _a.sent();\r\n _a.label = 2;\r\n case 2: return [2 /*return*/, deleteToken(this.firebaseDependencies, this.swRegistration)];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Request permission if it is not currently granted.\r\n *\r\n * @return Resolves if the permission was granted, rejects otherwise.\r\n *\r\n * @deprecated Use Notification.requestPermission() instead.\r\n * https://developer.mozilla.org/en-US/docs/Web/API/Notification/requestPermission\r\n */\r\n WindowController.prototype.requestPermission = function () {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var permissionResult;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n if (Notification.permission === 'granted') {\r\n return [2 /*return*/];\r\n }\r\n return [4 /*yield*/, Notification.requestPermission()];\r\n case 1:\r\n permissionResult = _a.sent();\r\n if (permissionResult === 'granted') {\r\n return [2 /*return*/];\r\n }\r\n else if (permissionResult === 'denied') {\r\n throw ERROR_FACTORY.create(\"permission-blocked\" /* PERMISSION_BLOCKED */);\r\n }\r\n else {\r\n throw ERROR_FACTORY.create(\"permission-default\" /* PERMISSION_DEFAULT */);\r\n }\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * @deprecated. Use getToken(options?: {vapidKey?: string; serviceWorkerRegistration?:\r\n * ServiceWorkerRegistration;}): Promise<string> instead.\r\n */\r\n WindowController.prototype.usePublicVapidKey = function (vapidKey) {\r\n if (this.vapidKey !== null) {\r\n throw ERROR_FACTORY.create(\"use-vapid-key-after-get-token\" /* USE_VAPID_KEY_AFTER_GET_TOKEN */);\r\n }\r\n if (typeof vapidKey !== 'string' || vapidKey.length === 0) {\r\n throw ERROR_FACTORY.create(\"invalid-vapid-key\" /* INVALID_VAPID_KEY */);\r\n }\r\n this.vapidKey = vapidKey;\r\n };\r\n /**\r\n * @deprecated. Use getToken(options?: {vapidKey?: string; serviceWorkerRegistration?:\r\n * ServiceWorkerRegistration;}): Promise<string> instead.\r\n */\r\n WindowController.prototype.useServiceWorker = function (swRegistration) {\r\n if (!(swRegistration instanceof ServiceWorkerRegistration)) {\r\n throw ERROR_FACTORY.create(\"invalid-sw-registration\" /* INVALID_SW_REGISTRATION */);\r\n }\r\n if (this.swRegistration) {\r\n throw ERROR_FACTORY.create(\"use-sw-after-get-token\" /* USE_SW_AFTER_GET_TOKEN */);\r\n }\r\n this.swRegistration = swRegistration;\r\n };\r\n /**\r\n * @param nextOrObserver An observer object or a function triggered on message.\r\n *\r\n * @return The unsubscribe function for the observer.\r\n */\r\n WindowController.prototype.onMessage = function (nextOrObserver) {\r\n var _this = this;\r\n this.onMessageCallback = nextOrObserver;\r\n return function () {\r\n _this.onMessageCallback = null;\r\n };\r\n };\r\n WindowController.prototype.setBackgroundMessageHandler = function () {\r\n throw ERROR_FACTORY.create(\"only-available-in-sw\" /* AVAILABLE_IN_SW */);\r\n };\r\n WindowController.prototype.onBackgroundMessage = function () {\r\n throw ERROR_FACTORY.create(\"only-available-in-sw\" /* AVAILABLE_IN_SW */);\r\n };\r\n /**\r\n * @deprecated No-op. It was initially designed with token rotation requests from server in mind.\r\n * However, the plan to implement such feature was abandoned.\r\n */\r\n WindowController.prototype.onTokenRefresh = function () {\r\n return function () { };\r\n };\r\n WindowController.prototype.logEvent = function (messageType, data) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var eventType, analytics;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n eventType = getEventType(messageType);\r\n return [4 /*yield*/, this.firebaseDependencies.analyticsProvider.get()];\r\n case 1:\r\n analytics = _a.sent();\r\n analytics.logEvent(eventType, {\r\n /* eslint-disable camelcase */\r\n message_id: data[CONSOLE_CAMPAIGN_ID],\r\n message_name: data[CONSOLE_CAMPAIGN_NAME],\r\n message_time: data[CONSOLE_CAMPAIGN_TIME],\r\n message_device_time: Math.floor(Date.now() / 1000)\r\n /* eslint-enable camelcase */\r\n });\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n return WindowController;\r\n}());\r\nfunction getEventType(messageType) {\r\n switch (messageType) {\r\n case MessageType.NOTIFICATION_CLICKED:\r\n return 'notification_open';\r\n case MessageType.PUSH_RECEIVED:\r\n return 'notification_foreground';\r\n default:\r\n throw new Error();\r\n }\r\n}\r\nfunction stripInternalFields(internalPayload) {\r\n delete internalPayload.messageType;\r\n delete internalPayload.isFirebaseMessaging;\r\n return internalPayload;\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nfunction extractAppConfig(app) {\r\n var e_1, _a;\r\n if (!app || !app.options) {\r\n throw getMissingValueError('App Configuration Object');\r\n }\r\n if (!app.name) {\r\n throw getMissingValueError('App Name');\r\n }\r\n // Required app config keys\r\n var configKeys = [\r\n 'projectId',\r\n 'apiKey',\r\n 'appId',\r\n 'messagingSenderId'\r\n ];\r\n var options = app.options;\r\n try {\r\n for (var configKeys_1 = __values(configKeys), configKeys_1_1 = configKeys_1.next(); !configKeys_1_1.done; configKeys_1_1 = configKeys_1.next()) {\r\n var keyName = configKeys_1_1.value;\r\n if (!options[keyName]) {\r\n throw getMissingValueError(keyName);\r\n }\r\n }\r\n }\r\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\r\n finally {\r\n try {\r\n if (configKeys_1_1 && !configKeys_1_1.done && (_a = configKeys_1.return)) _a.call(configKeys_1);\r\n }\r\n finally { if (e_1) throw e_1.error; }\r\n }\r\n return {\r\n appName: app.name,\r\n projectId: options.projectId,\r\n apiKey: options.apiKey,\r\n appId: options.appId,\r\n senderId: options.messagingSenderId\r\n };\r\n}\r\nfunction getMissingValueError(valueName) {\r\n return ERROR_FACTORY.create(\"missing-app-config-values\" /* MISSING_APP_CONFIG_VALUES */, {\r\n valueName: valueName\r\n });\r\n}\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nvar MESSAGING_NAME = 'messaging';\r\nfunction factoryMethod(container) {\r\n // Dependencies.\r\n var app = container.getProvider('app').getImmediate();\r\n var appConfig = extractAppConfig(app);\r\n var installations = container.getProvider('installations').getImmediate();\r\n var analyticsProvider = container.getProvider('analytics-internal');\r\n var firebaseDependencies = {\r\n app: app,\r\n appConfig: appConfig,\r\n installations: installations,\r\n analyticsProvider: analyticsProvider\r\n };\r\n if (!isSupported()) {\r\n throw ERROR_FACTORY.create(\"unsupported-browser\" /* UNSUPPORTED_BROWSER */);\r\n }\r\n if (self && 'ServiceWorkerGlobalScope' in self) {\r\n // Running in ServiceWorker context\r\n return new SwController(firebaseDependencies);\r\n }\r\n else {\r\n // Assume we are in the window context.\r\n return new WindowController(firebaseDependencies);\r\n }\r\n}\r\nvar NAMESPACE_EXPORTS = {\r\n isSupported: isSupported\r\n};\r\nfirebase.INTERNAL.registerComponent(new Component(MESSAGING_NAME, factoryMethod, \"PUBLIC\" /* PUBLIC */).setServiceProps(NAMESPACE_EXPORTS));\r\nfunction isSupported() {\r\n if (self && 'ServiceWorkerGlobalScope' in self) {\r\n // Running in ServiceWorker context\r\n return isSWControllerSupported();\r\n }\r\n else {\r\n // Assume we are in the window context.\r\n return isWindowControllerSupported();\r\n }\r\n}\r\n/**\r\n * Checks to see if the required APIs exist.\r\n */\r\nfunction isWindowControllerSupported() {\r\n return ('indexedDB' in window &&\r\n indexedDB !== null &&\r\n navigator.cookieEnabled &&\r\n 'serviceWorker' in navigator &&\r\n 'PushManager' in window &&\r\n 'Notification' in window &&\r\n 'fetch' in window &&\r\n ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&\r\n PushSubscription.prototype.hasOwnProperty('getKey'));\r\n}\r\n/**\r\n * Checks to see if the required APIs exist within SW Context.\r\n */\r\nfunction isSWControllerSupported() {\r\n return ('indexedDB' in self &&\r\n indexedDB !== null &&\r\n 'PushManager' in self &&\r\n 'Notification' in self &&\r\n ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&\r\n PushSubscription.prototype.hasOwnProperty('getKey'));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