Maksya

Untitled

Jun 24th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 26.26 KB | None | 0 0
  1. /*! @license Firebase v3.9.0
  2. Build: rev-cc77c9e
  3. Terms: https://firebase.google.com/terms/ */
  4. (function() {
  5.     var f = function(a, b) {
  6.             function c() {}
  7.             c.prototype = b.prototype;
  8.             a.u = b.prototype;
  9.             a.prototype = new c;
  10.             for (var d in b)
  11.                 if (Object.defineProperties) {
  12.                     var e = Object.getOwnPropertyDescriptor(b, d);
  13.                     e && Object.defineProperty(a, d, e)
  14.                 } else a[d] = b[d]
  15.         },
  16.         g = this,
  17.         h = function(a) {
  18.             var b = typeof a;
  19.             if ("object" == b)
  20.                 if (a) {
  21.                     if (a instanceof Array) return "array";
  22.                     if (a instanceof Object) return b;
  23.                     var c = Object.prototype.toString.call(a);
  24.                     if ("[object Window]" == c) return "object";
  25.                     if ("[object Array]" == c || "number" == typeof a.length && "undefined" != typeof a.splice &&
  26.                         "undefined" != typeof a.propertyIsEnumerable && !a.propertyIsEnumerable("splice")) return "array";
  27.                     if ("[object Function]" == c || "undefined" != typeof a.call && "undefined" != typeof a.propertyIsEnumerable && !a.propertyIsEnumerable("call")) return "function"
  28.                 } else return "null";
  29.             else if ("function" == b && "undefined" == typeof a.call) return "object";
  30.             return b
  31.         },
  32.         k = function(a, b) {
  33.             function c() {}
  34.             c.prototype = b.prototype;
  35.             a.u = b.prototype;
  36.             a.prototype = new c;
  37.             a.v = function(a, c, n) {
  38.                 for (var d = Array(arguments.length - 2), e = 2; e < arguments.length; e++) d[e -
  39.                     2] = arguments[e];
  40.                 return b.prototype[c].apply(a, d)
  41.             }
  42.         };
  43.     var m = function(a) {
  44.         if (Error.captureStackTrace) Error.captureStackTrace(this, m);
  45.         else {
  46.             var b = Error().stack;
  47.             b && (this.stack = b)
  48.         }
  49.         a && (this.message = String(a))
  50.     };
  51.     k(m, Error);
  52.     var p = function(a, b) {
  53.         for (var c = a.split("%s"), d = "", e = Array.prototype.slice.call(arguments, 1); e.length && 1 < c.length;) d += c.shift() + e.shift();
  54.         return d + c.join("%s")
  55.     };
  56.     var q = function(a, b) {
  57.         b.unshift(a);
  58.         m.call(this, p.apply(null, b));
  59.         b.shift()
  60.     };
  61.     k(q, m);
  62.     var r = function(a, b, c) {
  63.         if (!a) {
  64.             var d = "Assertion failed";
  65.             if (b) var d = d + (": " + b),
  66.                 e = Array.prototype.slice.call(arguments, 2);
  67.             throw new q("" + d, e || []);
  68.         }
  69.     };
  70.     var t = null;
  71.     var v = function(a) {
  72.         a = new Uint8Array(a);
  73.         var b = h(a);
  74.         r("array" == b || "object" == b && "number" == typeof a.length, "encodeByteArray takes an array as a parameter");
  75.         if (!t)
  76.             for (t = {}, b = 0; 65 > b; b++) t[b] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(b);
  77.         for (var b = t, c = [], d = 0; d < a.length; d += 3) {
  78.             var e = a[d],
  79.                 n = d + 1 < a.length,
  80.                 l = n ? a[d + 1] : 0,
  81.                 z = d + 2 < a.length,
  82.                 u = z ? a[d + 2] : 0,
  83.                 M = e >> 2,
  84.                 e = (e & 3) << 4 | l >> 4,
  85.                 l = (l & 15) << 2 | u >> 6,
  86.                 u = u & 63;
  87.             z || (u = 64, n || (l = 64));
  88.             c.push(b[M], b[e], b[l], b[u])
  89.         }
  90.         return c.join("").replace(/\+/g, "-").replace(/\//g,
  91.             "_").replace(/=+$/, "")
  92.     };
  93.     var w = {},
  94.         x = (w["only-available-in-window"] = "This method is available in a Window context.", w["only-available-in-sw"] = "This method is available in a service worker context.", w["should-be-overriden"] = "This method should be overriden by extended classes.", w["bad-sender-id"] = "Please ensure that 'messagingSenderId' is set correctly in the options passed into firebase.initializeApp().", w["permission-default"] = "The required permissions were not granted and dismissed instead.", w["permission-blocked"] = "The required permissions were not granted and blocked instead.",
  95.             w["unsupported-browser"] = "This browser doesn't support the API's required to use the firebase SDK.", w["notifications-blocked"] = "Notifications have been blocked.", w["failed-serviceworker-registration"] = "We are unable to register the default service worker. {$browserErrorMessage}", w["sw-registration-expected"] = "A service worker registration was the expected input.", w["get-subscription-failed"] = "There was an error when trying to get any existing Push Subscriptions.", w["invalid-saved-token"] = "Unable to access details of the saved token.",
  96.             w["sw-reg-redundant"] = "The service worker being used for push was made redundant.", w["token-subscribe-failed"] = "A problem occured while subscribing the user to FCM: {$message}", w["token-subscribe-no-token"] = "FCM returned no token when subscribing the user to push.", w["token-subscribe-no-push-set"] = "FCM returned an invalid response when getting an FCM token.", w["use-sw-before-get-token"] = "You must call useServiceWorker() before calling getToken() to ensure your service worker is used.", w["invalid-delete-token"] =
  97.             "You must pass a valid token into deleteToken(), i.e. the token from getToken().", w["delete-token-not-found"] = "The deletion attempt for token could not be performed as the token was not found.", w["delete-scope-not-found"] = "The deletion attempt for service worker scope could not be performed as the scope was not found.", w["bg-handler-function-expected"] = "The input to setBackgroundMessageHandler() must be a function.", w["no-window-client-to-msg"] = "An attempt was made to message a non-existant window client.",
  98.             w["unable-to-resubscribe"] = "There was an error while re-subscribing the FCM token for push messaging. Will have to resubscribe the user on next visit. {$message}", w["no-fcm-token-for-resubscribe"] = "Could not find an FCM token and as a result, unable to resubscribe. Will have to resubscribe the user on next visit.", w["failed-to-delete-token"] = "Unable to delete the currently saved token.", w["no-sw-in-reg"] = "Even though the service worker registration was successful, there was a problem accessing the service worker itself.",
  99.             w["incorrect-gcm-sender-id"] = "Please change your web app manifest's 'gcm_sender_id' value to '103953800507' to use Firebase messaging.", w["bad-scope"] = "The service worker scope must be a string with at least one character.", w["bad-vapid-key"] = "The public VAPID key must be a string with at least one character.", w["bad-subscription"] = "The subscription must be a valid PushSubscription.", w["bad-token"] = "The FCM Token used for storage / lookup was not a valid token string.", w["bad-push-set"] = "The FCM push set used for storage / lookup was not not a valid push set string.",
  100.             w["failed-delete-vapid-key"] = "The VAPID key could not be deleted.", w);
  101.     var y = {
  102.         userVisibleOnly: !0,
  103.         applicationServerKey: new Uint8Array([4, 51, 148, 247, 223, 161, 235, 177, 220, 3, 162, 94, 21, 113, 219, 72, 211, 46, 237, 237, 178, 52, 219, 183, 71, 58, 12, 143, 196, 204, 225, 111, 60, 140, 132, 223, 171, 182, 102, 62, 242, 12, 212, 139, 254, 227, 249, 118, 47, 20, 28, 99, 8, 106, 111, 45, 177, 26, 149, 176, 206, 55, 192, 156, 110])
  104.     };
  105.     var A = new firebase.INTERNAL.ErrorFactory("messaging", "Messaging", x),
  106.         B = function() {
  107.             this.a = null
  108.         },
  109.         C = function(a) {
  110.             if (a.a) return a.a;
  111.             a.a = new Promise(function(a, c) {
  112.                 var b = g.indexedDB.open("fcm_token_details_db", 1);
  113.                 b.onerror = function(a) {
  114.                     c(a.target.error)
  115.                 };
  116.                 b.onsuccess = function(b) {
  117.                     a(b.target.result)
  118.                 };
  119.                 b.onupgradeneeded = function(a) {
  120.                     a = a.target.result.createObjectStore("fcm_token_object_Store", {
  121.                         keyPath: "swScope"
  122.                     });
  123.                     a.createIndex("fcmSenderId", "fcmSenderId", {
  124.                         unique: !1
  125.                     });
  126.                     a.createIndex("fcmToken", "fcmToken", {
  127.                         unique: !0
  128.                     })
  129.                 }
  130.             });
  131.             return a.a
  132.         },
  133.         D = function(a) {
  134.             a.a ? a.a.then(function(b) {
  135.                 b.close();
  136.                 a.a = null
  137.             }) : Promise.resolve()
  138.         },
  139.         E = function(a, b) {
  140.             return C(a).then(function(a) {
  141.                 return new Promise(function(c, e) {
  142.                     var d = a.transaction(["fcm_token_object_Store"]).objectStore("fcm_token_object_Store").index("fcmToken").get(b);
  143.                     d.onerror = function(a) {
  144.                         e(a.target.error)
  145.                     };
  146.                     d.onsuccess = function(a) {
  147.                         c(a.target.result)
  148.                     }
  149.                 })
  150.             })
  151.         },
  152.         F = function(a, b) {
  153.             return C(a).then(function(a) {
  154.                 return new Promise(function(c, e) {
  155.                     var d = [],
  156.                         l = a.transaction(["fcm_token_object_Store"]).objectStore("fcm_token_object_Store").openCursor();
  157.                     l.onerror = function(a) {
  158.                         e(a.target.error)
  159.                     };
  160.                     l.onsuccess = function(a) {
  161.                         (a = a.target.result) ? (a.value.fcmSenderId === b && d.push(a.value), a.continue()) : c(d)
  162.                     }
  163.                 })
  164.             })
  165.         },
  166.         G = function(a, b, c) {
  167.             var d = v(b.getKey("p256dh")),
  168.                 e = v(b.getKey("auth"));
  169.             a = "authorized_entity=" + a + "&" + ("endpoint=" + b.endpoint + "&") + ("encryption_key=" + d + "&") + ("encryption_auth=" + e);
  170.             c && (a += "&pushSet=" + c);
  171.             c = new Headers;
  172.             c.append("Content-Type", "application/x-www-form-urlencoded");
  173.             return fetch("https://fcm.googleapis.com/fcm/connect/subscribe", {
  174.                 method: "POST",
  175.                 headers: c,
  176.                 body: a
  177.             }).then(function(a) {
  178.                 return a.json()
  179.             }).then(function(a) {
  180.                 if (a.error) throw A.create("token-subscribe-failed", {
  181.                     message: a.error.message
  182.                 });
  183.                 if (!a.token) throw A.create("token-subscribe-no-token");
  184.                 if (!a.pushSet) throw A.create("token-subscribe-no-push-set");
  185.                 return {
  186.                     token: a.token,
  187.                     pushSet: a.pushSet
  188.                 }
  189.             })
  190.         },
  191.         H = function(a, b, c, d, e, n) {
  192.             var l = {
  193.                 swScope: c.scope,
  194.                 endpoint: d.endpoint,
  195.                 auth: v(d.getKey("auth")),
  196.                 p256dh: v(d.getKey("p256dh")),
  197.                 fcmToken: e,
  198.                 fcmPushSet: n,
  199.                 fcmSenderId: b
  200.             };
  201.             return C(a).then(function(a) {
  202.                 return new Promise(function(b,
  203.                     c) {
  204.                     var d = a.transaction(["fcm_token_object_Store"], "readwrite").objectStore("fcm_token_object_Store").put(l);
  205.                     d.onerror = function(a) {
  206.                         c(a.target.error)
  207.                     };
  208.                     d.onsuccess = function() {
  209.                         b()
  210.                     }
  211.                 })
  212.             })
  213.         };
  214.     B.prototype.i = function(a, b) {
  215.         return b instanceof ServiceWorkerRegistration ? "string" !== typeof a || 0 === a.length ? Promise.reject(A.create("bad-sender-id")) : F(this, a).then(function(c) {
  216.             if (0 !== c.length) {
  217.                 var d = c.findIndex(function(c) {
  218.                     return b.scope === c.swScope && a === c.fcmSenderId
  219.                 });
  220.                 if (-1 !== d) return c[d]
  221.             }
  222.         }).then(function(a) {
  223.             if (a) return b.pushManager.getSubscription().catch(function() {
  224.                 throw A.create("get-subscription-failed");
  225.             }).then(function(b) {
  226.                 var c;
  227.                 if (c = b) c = b.endpoint === a.endpoint && v(b.getKey("auth")) === a.auth &&
  228.                     v(b.getKey("p256dh")) === a.p256dh;
  229.                 if (c) return a.fcmToken
  230.             })
  231.         }) : Promise.reject(A.create("sw-registration-expected"))
  232.     };
  233.     B.prototype.getSavedToken = B.prototype.i;
  234.     B.prototype.h = function(a, b) {
  235.         var c = this;
  236.         return "string" !== typeof a || 0 === a.length ? Promise.reject(A.create("bad-sender-id")) : b instanceof ServiceWorkerRegistration ? b.pushManager.getSubscription().then(function(a) {
  237.             return a ? a : b.pushManager.subscribe(y)
  238.         }).then(function(d) {
  239.             return G(a, d).then(function(e) {
  240.                 return H(c, a, b, d, e.token, e.pushSet).then(function() {
  241.                     return e.token
  242.                 })
  243.             })
  244.         }) : Promise.reject(A.create("sw-registration-expected"))
  245.     };
  246.     B.prototype.createToken = B.prototype.h;
  247.     B.prototype.deleteToken = function(a) {
  248.         var b = this;
  249.         return "string" !== typeof a || 0 === a.length ? Promise.reject(A.create("invalid-delete-token")) : E(this, a).then(function(a) {
  250.             if (!a) throw A.create("delete-token-not-found");
  251.             return C(b).then(function(b) {
  252.                 return new Promise(function(c, d) {
  253.                     var e = b.transaction(["fcm_token_object_Store"], "readwrite").objectStore("fcm_token_object_Store").delete(a.swScope);
  254.                     e.onerror = function(a) {
  255.                         d(a.target.error)
  256.                     };
  257.                     e.onsuccess = function(b) {
  258.                         0 === b.target.result ? d(A.create("failed-to-delete-token")) :
  259.                             c(a)
  260.                     }
  261.                 })
  262.             })
  263.         })
  264.     };
  265.     var I = function(a) {
  266.         var b = this;
  267.         this.a = new firebase.INTERNAL.ErrorFactory("messaging", "Messaging", x);
  268.         if (!a.options.messagingSenderId || "string" !== typeof a.options.messagingSenderId) throw this.a.create("bad-sender-id");
  269.         this.l = a.options.messagingSenderId;
  270.         this.c = new B;
  271.         this.app = a;
  272.         this.INTERNAL = {};
  273.         this.INTERNAL.delete = function() {
  274.             return b.delete
  275.         }
  276.     };
  277.     I.prototype.getToken = function() {
  278.         var a = this,
  279.             b = Notification.permission;
  280.         return "granted" !== b ? "denied" === b ? Promise.reject(this.a.create("notifications-blocked")) : Promise.resolve(null) : this.f().then(function(b) {
  281.             return a.c.i(a.l, b).then(function(c) {
  282.                 return c ? c : a.c.h(a.l, b)
  283.             })
  284.         })
  285.     };
  286.     I.prototype.getToken = I.prototype.getToken;
  287.     I.prototype.deleteToken = function(a) {
  288.         var b = this;
  289.         return this.c.deleteToken(a).then(function() {
  290.             return b.f()
  291.         }).then(function(a) {
  292.             return a ? a.pushManager.getSubscription() : null
  293.         }).then(function(a) {
  294.             if (a) return a.unsubscribe()
  295.         })
  296.     };
  297.     I.prototype.deleteToken = I.prototype.deleteToken;
  298.     I.prototype.f = function() {
  299.         throw this.a.create("should-be-overriden");
  300.     };
  301.     I.prototype.requestPermission = function() {
  302.         throw this.a.create("only-available-in-window");
  303.     };
  304.     I.prototype.useServiceWorker = function() {
  305.         throw this.a.create("only-available-in-window");
  306.     };
  307.     I.prototype.useServiceWorker = I.prototype.useServiceWorker;
  308.     I.prototype.onMessage = function() {
  309.         throw this.a.create("only-available-in-window");
  310.     };
  311.     I.prototype.onMessage = I.prototype.onMessage;
  312.     I.prototype.onTokenRefresh = function() {
  313.         throw this.a.create("only-available-in-window");
  314.     };
  315.     I.prototype.onTokenRefresh = I.prototype.onTokenRefresh;
  316.     I.prototype.setBackgroundMessageHandler = function() {
  317.         throw this.a.create("only-available-in-sw");
  318.     };
  319.     I.prototype.setBackgroundMessageHandler = I.prototype.setBackgroundMessageHandler;
  320.     I.prototype.delete = function() {
  321.         D(this.c)
  322.     };
  323.     var J = function(a, b) {
  324.         var c = {};
  325.         return c["firebase-messaging-msg-type"] = a, c["firebase-messaging-msg-data"] = b, c
  326.     };
  327.     var K = self,
  328.         P = function(a) {
  329.             I.call(this, a);
  330.             var b = this;
  331.             this.a = new firebase.INTERNAL.ErrorFactory("messaging", "Messaging", x);
  332.             K.addEventListener("push", function(a) {
  333.                 return L(b, a)
  334.             }, !1);
  335.             K.addEventListener("pushsubscriptionchange", function(a) {
  336.                 return N(b, a)
  337.             }, !1);
  338.             K.addEventListener("notificationclick", function(a) {
  339.                 return O(b, a)
  340.             }, !1);
  341.             this.b = null
  342.         };
  343.     f(P, I);
  344.     var L = function(a, b) {
  345.             var c;
  346.             try {
  347.                 c = b.data.json()
  348.             } catch (e) {
  349.                 return
  350.             }
  351.             var d = Q().then(function(b) {
  352.                 if (b) {
  353.                     if (c.notification || a.b) return R(a, c)
  354.                 } else {
  355.                     if ((b = c) && "object" === typeof b.notification) {
  356.                         var d = Object.assign({}, b.notification),
  357.                             e = {};
  358.                         d.data = (e.FCM_MSG = b, e);
  359.                         b = d
  360.                     } else b = void 0;
  361.                     if (b) return K.registration.showNotification(b.title || "", b);
  362.                     if (a.b) return a.b(c)
  363.                 }
  364.             });
  365.             b.waitUntil(d)
  366.         },
  367.         N = function(a, b) {
  368.             var c = a.getToken().then(function(b) {
  369.                 if (!b) throw a.a.create("no-fcm-token-for-resubscribe");
  370.                 var c = a.c;
  371.                 return E(c, b).then(function(b) {
  372.                     if (!b) throw a.a.create("invalid-saved-token");
  373.                     return K.registration.pushManager.subscribe(y).then(function(a) {
  374.                         return G(b.A, a, b.w)
  375.                     }).catch(function(d) {
  376.                         return c.deleteToken(b.B).then(function() {
  377.                             throw a.a.create("unable-to-resubscribe", {
  378.                                 message: d
  379.                             });
  380.                         })
  381.                     })
  382.                 })
  383.             });
  384.             b.waitUntil(c)
  385.         },
  386.         O = function(a, b) {
  387.             if (b.notification && b.notification.data && b.notification.data.FCM_MSG) {
  388.                 b.stopImmediatePropagation();
  389.                 b.notification.close();
  390.                 var c = b.notification.data.FCM_MSG,
  391.                     d = c.notification.click_action;
  392.                 if (d) {
  393.                     var e = S(d).then(function(a) {
  394.                         return a ? a : K.clients.openWindow(d)
  395.                     }).then(function(b) {
  396.                         if (b) return delete c.notification,
  397.                             T(a, b, J("notification-clicked", c))
  398.                     });
  399.                     b.waitUntil(e)
  400.                 }
  401.             }
  402.         };
  403.     P.prototype.setBackgroundMessageHandler = function(a) {
  404.         if (a && "function" !== typeof a) throw this.a.create("bg-handler-function-expected");
  405.         this.b = a
  406.     };
  407.     P.prototype.setBackgroundMessageHandler = P.prototype.setBackgroundMessageHandler;
  408.     var S = function(a) {
  409.             var b = (new URL(a)).href;
  410.             return K.clients.matchAll({
  411.                 type: "window",
  412.                 includeUncontrolled: !0
  413.             }).then(function(a) {
  414.                 for (var c = null, e = 0; e < a.length; e++)
  415.                     if ((new URL(a[e].url)).href === b) {
  416.                         c = a[e];
  417.                         break
  418.                     }
  419.                 if (c) return c.focus(), c
  420.             })
  421.         },
  422.         T = function(a, b, c) {
  423.             return new Promise(function(d, e) {
  424.                 if (!b) return e(a.a.create("no-window-client-to-msg"));
  425.                 b.postMessage(c);
  426.                 d()
  427.             })
  428.         },
  429.         Q = function() {
  430.             return K.clients.matchAll({
  431.                 type: "window",
  432.                 includeUncontrolled: !0
  433.             }).then(function(a) {
  434.                 return a.some(function(a) {
  435.                     return "visible" ===
  436.                         a.visibilityState
  437.                 })
  438.             })
  439.         },
  440.         R = function(a, b) {
  441.             return K.clients.matchAll({
  442.                 type: "window",
  443.                 includeUncontrolled: !0
  444.             }).then(function(c) {
  445.                 var d = J("push-msg-received", b);
  446.                 return Promise.all(c.map(function(b) {
  447.                     return T(a, b, d)
  448.                 }))
  449.             })
  450.         };
  451.     P.prototype.f = function() {
  452.         return Promise.resolve(K.registration)
  453.     };
  454.     var V = function(a) {
  455.         I.call(this, a);
  456.         var b = this;
  457.         this.j = null;
  458.         this.m = firebase.INTERNAL.createSubscribe(function(a) {
  459.             b.j = a
  460.         });
  461.         this.s = null;
  462.         this.o = firebase.INTERNAL.createSubscribe(function(a) {
  463.             b.s = a
  464.         });
  465.         U(this)
  466.     };
  467.     f(V, I);
  468.     V.prototype.getToken = function() {
  469.         var a = this;
  470.         return "serviceWorker" in navigator && "PushManager" in window && "Notification" in window && ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification") && PushSubscription.prototype.hasOwnProperty("getKey") ? W(this).then(function() {
  471.             return I.prototype.getToken.call(a)
  472.         }) : Promise.reject(this.a.create("unsupported-browser"))
  473.     };
  474.     V.prototype.getToken = V.prototype.getToken;
  475.     var W = function(a) {
  476.         if (a.g) return a.g;
  477.         var b = document.querySelector('link[rel="manifest"]');
  478.         b ? a.g = fetch(b.href).then(function(a) {
  479.             return a.json()
  480.         }).catch(function() {
  481.             return Promise.resolve()
  482.         }).then(function(b) {
  483.             if (b && b.gcm_sender_id && "103953800507" !== b.gcm_sender_id) throw a.a.create("incorrect-gcm-sender-id");
  484.         }) : a.g = Promise.resolve();
  485.         return a.g
  486.     };
  487.     V.prototype.requestPermission = function() {
  488.         var a = this;
  489.         return "granted" === Notification.permission ? Promise.resolve() : new Promise(function(b, c) {
  490.             var d = function(d) {
  491.                     return "granted" === d ? b() : "denied" === d ? c(a.a.create("permission-blocked")) : c(a.a.create("permission-default"))
  492.                 },
  493.                 e = Notification.requestPermission(function(a) {
  494.                     e || d(a)
  495.                 });
  496.             e && e.then(d)
  497.         })
  498.     };
  499.     V.prototype.requestPermission = V.prototype.requestPermission;
  500.     V.prototype.useServiceWorker = function(a) {
  501.         if (!(a instanceof ServiceWorkerRegistration)) throw this.a.create("sw-registration-expected");
  502.         if ("undefined" !== typeof this.b) throw this.a.create("use-sw-before-get-token");
  503.         this.b = a
  504.     };
  505.     V.prototype.useServiceWorker = V.prototype.useServiceWorker;
  506.     V.prototype.onMessage = function(a, b, c) {
  507.         return this.m(a, b, c)
  508.     };
  509.     V.prototype.onMessage = V.prototype.onMessage;
  510.     V.prototype.onTokenRefresh = function(a, b, c) {
  511.         return this.o(a, b, c)
  512.     };
  513.     V.prototype.onTokenRefresh = V.prototype.onTokenRefresh;
  514.     var X = function(a, b) {
  515.         var c = b.installing || b.waiting || b.active;
  516.         return new Promise(function(d, e) {
  517.             if (c)
  518.                 if ("activated" === c.state) d(b);
  519.                 else if ("redundant" === c.state) e(a.a.create("sw-reg-redundant"));
  520.             else {
  521.                 var n = function() {
  522.                     if ("activated" === c.state) d(b);
  523.                     else if ("redundant" === c.state) e(a.a.create("sw-reg-redundant"));
  524.                     else return;
  525.                     c.removeEventListener("statechange", n)
  526.                 };
  527.                 c.addEventListener("statechange", n)
  528.             } else e(a.a.create("no-sw-in-reg"))
  529.         })
  530.     };
  531.     V.prototype.f = function() {
  532.         var a = this;
  533.         if (this.b) return X(this, this.b);
  534.         this.b = null;
  535.         return navigator.serviceWorker.register("/firebase-messaging-sw.js", {
  536.             scope: "/firebase-cloud-messaging-push-scope"
  537.         }).catch(function(b) {
  538.             throw a.a.create("failed-serviceworker-registration", {
  539.                 browserErrorMessage: b.message
  540.             });
  541.         }).then(function(b) {
  542.             return X(a, b).then(function() {
  543.                 a.b = b;
  544.                 b.update();
  545.                 return b
  546.             })
  547.         })
  548.     };
  549.     var U = function(a) {
  550.         "serviceWorker" in navigator && navigator.serviceWorker.addEventListener("message", function(b) {
  551.             if (b.data && b.data["firebase-messaging-msg-type"]) switch (b = b.data, b["firebase-messaging-msg-type"]) {
  552.                 case "push-msg-received":
  553.                 case "notification-clicked":
  554.                     a.j.next(b["firebase-messaging-msg-data"])
  555.             }
  556.         }, !1)
  557.     };
  558.     if (!(firebase && firebase.INTERNAL && firebase.INTERNAL.registerService)) throw Error("Cannot install Firebase Messaging - be sure to load firebase-app.js first.");
  559.     firebase.INTERNAL.registerService("messaging", function(a) {
  560.         return self && "ServiceWorkerGlobalScope" in self ? new P(a) : new V(a)
  561.     }, {
  562.         Messaging: V
  563.     });
  564.     new firebase.INTERNAL.ErrorFactory("messaging", "Messaging", x);
  565.     new firebase.INTERNAL.ErrorFactory("messaging", "Messaging", x);
  566.     new firebase.INTERNAL.ErrorFactory("messaging", "Messaging", x);
  567. }).call(this);
Advertisement
Add Comment
Please, Sign In to add comment