1 | !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("@firebase/app")):"function"==typeof define&&define.amd?define(["@firebase/app"],e):e((t=t||self).firebase)}(this,function(xe){"use strict";try{(function(){xe=xe&&Object.prototype.hasOwnProperty.call(xe,"default")?xe.default:xe;var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var a=function(){return(a=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function l(t,a,s,u){return new(s=s||Promise)(function(e,n){function r(t){try{o(u.next(t))}catch(t){n(t)}}function i(t){try{o(u.throw(t))}catch(t){n(t)}}function o(t){t.done?e(t.value):function(e){return e instanceof s?e:new s(function(t){t(e)})}(t.value).then(r,i)}o((u=u.apply(t,a||[])).next())})}function p(n,r){var i,o,a,t,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,o&&(a=2&e[0]?o.return:e[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,e[1])).done)return a;switch(o=0,a&&(e=[2&e[0],a.value]),e[0]){case 0:case 1:a=e;break;case 4:return s.label++,{value:e[1],done:!1};case 5:s.label++,o=e[1],e=[0];continue;case 7:e=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){s=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){s.label=e[1];break}if(6===e[0]&&s.label<a[1]){s.label=a[1],a=e;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(e);break}a[2]&&s.ops.pop(),s.trys.pop();continue}e=r.call(n,s)}catch(t){e=[6,t],o=0}finally{i=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function r(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||0<e--)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function i(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}var t,e,o,h=(o=Error,n(t=c,e=o),void(t.prototype=null===e?Object.create(e):(u.prototype=e.prototype,new u)),c);function u(){this.constructor=t}function c(t,e){var n=o.call(this,e)||this;return n.code=t,n.name="FirebaseError",Object.setPrototypeOf(n,c.prototype),Error.captureStackTrace&&Error.captureStackTrace(n,f.prototype.create),n}var f=(d.prototype.create=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=e[0]||{},i=this.service+"/"+t,o=this.errors[t],a=o?function(t,r){return t.replace(g,function(t,e){var n=r[e];return null!=n?n.toString():"<"+e+"?>"})}(o,r):"Error",s=this.serviceName+": "+a+" ("+i+").",u=new h(i,s),c=0,f=Object.keys(r);c<f.length;c++){var l=f[c];"_"!==l.slice(-1)&&(l in u&&console.warn('Overwriting FirebaseError base field "'+l+'" can cause unexpected behavior.'),u[l]=r[l])}return u},d);function d(t,e,n){this.service=t,this.serviceName=e,this.errors=n}var g=/\{\$([^}]+)}/g,v=(m.prototype.setInstantiationMode=function(t){return this.instantiationMode=t,this},m.prototype.setMultipleInstances=function(t){return this.multipleInstances=t,this},m.prototype.setServiceProps=function(t){return this.serviceProps=t,this},m);function m(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY"}function y(n){return new Promise(function(t,e){n.onsuccess=function(){t(n.result)},n.onerror=function(){e(n.error)}})}function b(n,r,i){var o,t=new Promise(function(t,e){y(o=n[r].apply(n,i)).then(t,e)});return t.request=o,t}function _(t,n,e){e.forEach(function(e){Object.defineProperty(t.prototype,e,{get:function(){return this[n][e]},set:function(t){this[n][e]=t}})})}function w(e,n,r,t){t.forEach(function(t){t in r.prototype&&(e.prototype[t]=function(){return b(this[n],t,arguments)})})}function I(e,n,r,t){t.forEach(function(t){t in r.prototype&&(e.prototype[t]=function(){return this[n][t].apply(this[n],arguments)})})}function S(e,n,r,t){t.forEach(function(t){t in r.prototype&&(e.prototype[t]=function(){return function(t,e,n){var r=b(t,e,n);return r.then(function(t){if(t)return new T(t,r.request)})}(this[n],t,arguments)})})}function E(t){this._index=t}function T(t,e){this._cursor=t,this._request=e}function A(t){this._store=t}function O(n){this._tx=n,this.complete=new Promise(function(t,e){n.oncomplete=function(){t()},n.onerror=function(){e(n.error)},n.onabort=function(){e(n.error)}})}function N(t,e,n){this._db=t,this.oldVersion=e,this.transaction=new O(n)}function k(t){this._db=t}_(E,"_index",["name","keyPath","multiEntry","unique"]),w(E,"_index",IDBIndex,["get","getKey","getAll","getAllKeys","count"]),S(E,"_index",IDBIndex,["openCursor","openKeyCursor"]),_(T,"_cursor",["direction","key","primaryKey","value"]),w(T,"_cursor",IDBCursor,["update","delete"]),["advance","continue","continuePrimaryKey"].forEach(function(n){n in IDBCursor.prototype&&(T.prototype[n]=function(){var e=this,t=arguments;return Promise.resolve().then(function(){return e._cursor[n].apply(e._cursor,t),y(e._request).then(function(t){if(t)return new T(t,e._request)})})})}),A.prototype.createIndex=function(){return new E(this._store.createIndex.apply(this._store,arguments))},A.prototype.index=function(){return new E(this._store.index.apply(this._store,arguments))},_(A,"_store",["name","keyPath","indexNames","autoIncrement"]),w(A,"_store",IDBObjectStore,["put","add","delete","clear","get","getAll","getKey","getAllKeys","count"]),S(A,"_store",IDBObjectStore,["openCursor","openKeyCursor"]),I(A,"_store",IDBObjectStore,["deleteIndex"]),O.prototype.objectStore=function(){return new A(this._tx.objectStore.apply(this._tx,arguments))},_(O,"_tx",["objectStoreNames","mode"]),I(O,"_tx",IDBTransaction,["abort"]),N.prototype.createObjectStore=function(){return new A(this._db.createObjectStore.apply(this._db,arguments))},_(N,"_db",["name","version","objectStoreNames"]),I(N,"_db",IDBDatabase,["deleteObjectStore","close"]),k.prototype.transaction=function(){return new O(this._db.transaction.apply(this._db,arguments))},_(k,"_db",["name","version","objectStoreNames"]),I(k,"_db",IDBDatabase,["close"]),["openCursor","openKeyCursor"].forEach(function(i){[A,E].forEach(function(t){i in t.prototype&&(t.prototype[i.replace("open","iterate")]=function(){var t=function(t){return Array.prototype.slice.call(t)}(arguments),e=t[t.length-1],n=this._store||this._index,r=n[i].apply(n,t.slice(0,-1));r.onsuccess=function(){e(r.result)}})})}),[E,A].forEach(function(t){t.prototype.getAll||(t.prototype.getAll=function(t,n){var r=this,i=[];return new Promise(function(e){r.iterateCursor(t,function(t){t?(i.push(t.value),void 0===n||i.length!=n?t.continue():e(i)):e(i)})})})});var P,C="0.4.6",R=1e4,j="w:"+C,M="FIS_v2",B="https://firebaseinstallations.googleapis.com/v1",L=36e5,D=((P={})["missing-app-config-values"]='Missing App configuration value: "{$valueName}"',P["not-registered"]="Firebase Installation is not registered.",P["installation-not-found"]="Firebase Installation not found.",P["request-failed"]='{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',P["app-offline"]="Could not process request. Application offline.",P["delete-pending-registration"]="Can't delete installation while there is a pending registration request.",P),x=new f("installations","Installations",D);function q(t){return t instanceof h&&t.code.includes("request-failed")}function U(t){var e=t.projectId;return B+"/projects/"+e+"/installations"}function F(t){return{token:t.token,requestStatus:2,expiresIn:function(t){return Number(t.replace("s","000"))}(t.expiresIn),creationTime:Date.now()}}function H(r,i){return l(this,void 0,void 0,function(){var e,n;return p(this,function(t){switch(t.label){case 0:return[4,i.json()];case 1:return e=t.sent(),n=e.error,[2,x.create("request-failed",{requestName:r,serverCode:n.code,serverMessage:n.message,serverStatus:n.status})]}})})}function V(t){var e=t.apiKey;return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function K(t,e){var n=e.refreshToken,r=V(t);return r.append("Authorization",function(t){return M+" "+t}(n)),r}function W(n){return l(this,void 0,void 0,function(){var e;return p(this,function(t){switch(t.label){case 0:return[4,n()];case 1:return 500<=(e=t.sent()).status&&e.status<600?[2,n()]:[2,e]}})})}function $(e){return new Promise(function(t){setTimeout(t,e)})}function G(t){return btoa(String.fromCharCode.apply(String,function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(r(arguments[e]));return t}(t))).replace(/\+/g,"-").replace(/\//g,"_")}var J=/^[cdef][\w-]{21}$/,z="";function Z(){try{var t=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(t),t[0]=112+t[0]%16;var e=function(t){return G(t).substr(0,22)}(t);return J.test(e)?e:z}catch(t){return z}}function Y(t){return t.appName+"!"+t.appId}var Q=new Map;function X(t,e){var n=Y(t);tt(n,e),function(t,e){var n=nt();n&&n.postMessage({key:t,fid:e});rt()}(n,e)}function tt(t,e){var n,r,i=Q.get(t);if(i)try{for(var o=s(i),a=o.next();!a.done;a=o.next()){(0,a.value)(e)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}var et=null;function nt(){return!et&&"BroadcastChannel"in self&&((et=new BroadcastChannel("[Firebase] FID Change")).onmessage=function(t){tt(t.data.key,t.data.fid)}),et}function rt(){0===Q.size&&et&&(et.close(),et=null)}var it,ot,at,st,ut="firebase-installations-database",ct=1,ft="firebase-installations-store",lt=null;function pt(){return lt=lt||function(t,e,n){var r=b(indexedDB,"open",[t,e]),i=r.request;return i&&(i.onupgradeneeded=function(t){n&&n(new N(i.result,t.oldVersion,i.transaction))}),r.then(function(t){return new k(t)})}(ut,ct,function(t){switch(t.oldVersion){case 0:t.createObjectStore(ft)}})}function ht(a,s){return l(this,void 0,void 0,function(){var e,n,r,i,o;return p(this,function(t){switch(t.label){case 0:return e=Y(a),[4,pt()];case 1:return n=t.sent(),r=n.transaction(ft,"readwrite"),[4,(i=r.objectStore(ft)).get(e)];case 2:return o=t.sent(),[4,i.put(s,e)];case 3:return t.sent(),[4,r.complete];case 4:return t.sent(),o&&o.fid===s.fid||X(a,s.fid),[2,s]}})})}function dt(i){return l(this,void 0,void 0,function(){var e,n,r;return p(this,function(t){switch(t.label){case 0:return e=Y(i),[4,pt()];case 1:return n=t.sent(),[4,(r=n.transaction(ft,"readwrite")).objectStore(ft).delete(e)];case 2:return t.sent(),[4,r.complete];case 3:return t.sent(),[2]}})})}function gt(s,u){return l(this,void 0,void 0,function(){var e,n,r,i,o,a;return p(this,function(t){switch(t.label){case 0:return e=Y(s),[4,pt()];case 1:return n=t.sent(),r=n.transaction(ft,"readwrite"),[4,(i=r.objectStore(ft)).get(e)];case 2:return o=t.sent(),void 0!==(a=u(o))?[3,4]:[4,i.delete(e)];case 3:return t.sent(),[3,6];case 4:return[4,i.put(a,e)];case 5:t.sent(),t.label=6;case 6:return[4,r.complete];case 7:return t.sent(),!a||o&&o.fid===a.fid||X(s,a.fid),[2,a]}})})}function vt(i){return l(this,void 0,void 0,function(){var r,e,n;return p(this,function(t){switch(t.label){case 0:return[4,gt(i,function(t){var e=function(t){return yt(t||{fid:Z(),registrationStatus:0})}(t),n=function(t,e){{if(0!==e.registrationStatus)return 1===e.registrationStatus?{installationEntry:e,registrationPromise:function(o){return l(this,void 0,void 0,function(){var e,n,r,i;return p(this,function(t){switch(t.label){case 0:return[4,mt(o)];case 1:e=t.sent(),t.label=2;case 2:return 1!==e.registrationStatus?[3,5]:[4,$(100)];case 3:return t.sent(),[4,mt(o)];case 4:return e=t.sent(),[3,2];case 5:return 0!==e.registrationStatus?[3,7]:[4,vt(o)];case 6:return n=t.sent(),r=n.installationEntry,(i=n.registrationPromise)?[2,i]:[2,r];case 7:return[2,e]}})})}(t)}:{installationEntry:e};if(!navigator.onLine){var n=Promise.reject(x.create("app-offline"));return{installationEntry:e,registrationPromise:n}}var r={fid:e.fid,registrationStatus:1,registrationTime:Date.now()},i=function(r,i){return l(this,void 0,void 0,function(){var e,n;return p(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,7]),[4,function(s,t){var u=t.fid;return l(this,void 0,void 0,function(){var e,n,r,i,o,a;return p(this,function(t){switch(t.label){case 0:return e=U(s),n=V(s),r={fid:u,authVersion:M,appId:s.appId,sdkVersion:j},i={method:"POST",headers:n,body:JSON.stringify(r)},[4,W(function(){return fetch(e,i)})];case 1:return(o=t.sent()).ok?[4,o.json()]:[3,3];case 2:return a=t.sent(),[2,{fid:a.fid||u,registrationStatus:2,refreshToken:a.refreshToken,authToken:F(a.authToken)}];case 3:return[4,H("Create Installation",o)];case 4:throw t.sent()}})})}(r,i)];case 1:return e=t.sent(),[2,ht(r,e)];case 2:return q(n=t.sent())&&409===n.serverCode?[4,dt(r)]:[3,4];case 3:return t.sent(),[3,6];case 4:return[4,ht(r,{fid:i.fid,registrationStatus:0})];case 5:t.sent(),t.label=6;case 6:throw n;case 7:return[2]}})})}(t,r);return{installationEntry:r,registrationPromise:i}}}(i,e);return r=n.registrationPromise,n.installationEntry})];case 1:return(e=t.sent()).fid!==z?[3,3]:(n={},[4,r]);case 2:return[2,(n.installationEntry=t.sent(),n)];case 3:return[2,{installationEntry:e,registrationPromise:r}]}})})}function mt(t){return gt(t,function(t){if(!t)throw x.create("installation-not-found");return yt(t)})}function yt(t){return function(t){return 1===t.registrationStatus&&t.registrationTime+R<Date.now()}(t)?{fid:t.fid,registrationStatus:0}:t}function bt(t,u){var c=t.appConfig,f=t.platformLoggerProvider;return l(this,void 0,void 0,function(){var e,n,r,i,o,a,s;return p(this,function(t){switch(t.label){case 0:return e=function(t,e){var n=e.fid;return U(t)+"/"+n+"/authTokens:generate"}(c,u),n=K(c,u),(r=f.getImmediate({optional:!0}))&&n.append("x-firebase-client",r.getPlatformInfoString()),i={installation:{sdkVersion:j}},o={method:"POST",headers:n,body:JSON.stringify(i)},[4,W(function(){return fetch(e,o)})];case 1:return(a=t.sent()).ok?[4,a.json()]:[3,3];case 2:return s=t.sent(),[2,F(s)];case 3:return[4,H("Generate Auth Token",a)];case 4:throw t.sent()}})})}function _t(i,o){return void 0===o&&(o=!1),l(this,void 0,void 0,function(){var r,e,n;return p(this,function(t){switch(t.label){case 0:return[4,gt(i.appConfig,function(t){if(!It(t))throw x.create("not-registered");var e=t.authToken;if(!o&&function(t){return 2===t.requestStatus&&!function(t){var e=Date.now();return e<t.creationTime||t.creationTime+t.expiresIn<e+L}(t)}(e))return t;if(1===e.requestStatus)return r=function(r,i){return l(this,void 0,void 0,function(){var e,n;return p(this,function(t){switch(t.label){case 0:return[4,wt(r.appConfig)];case 1:e=t.sent(),t.label=2;case 2:return 1!==e.authToken.requestStatus?[3,5]:[4,$(100)];case 3:return t.sent(),[4,wt(r.appConfig)];case 4:return e=t.sent(),[3,2];case 5:return 0===(n=e.authToken).requestStatus?[2,_t(r,i)]:[2,n]}})})}(i,o),t;if(!navigator.onLine)throw x.create("app-offline");var n=function(t){var e={requestStatus:1,requestTime:Date.now()};return a(a({},t),{authToken:e})}(t);return r=function(i,o){return l(this,void 0,void 0,function(){var e,n,r;return p(this,function(t){switch(t.label){case 0:return t.trys.push([0,3,,8]),[4,bt(i,o)];case 1:return e=t.sent(),r=a(a({},o),{authToken:e}),[4,ht(i.appConfig,r)];case 2:return t.sent(),[2,e];case 3:return!q(n=t.sent())||401!==n.serverCode&&404!==n.serverCode?[3,5]:[4,dt(i.appConfig)];case 4:return t.sent(),[3,7];case 5:return r=a(a({},o),{authToken:{requestStatus:0}}),[4,ht(i.appConfig,r)];case 6:t.sent(),t.label=7;case 7:throw n;case 8:return[2]}})})}(i,n),n})];case 1:return e=t.sent(),r?[4,r]:[3,3];case 2:return n=t.sent(),[3,4];case 3:n=e.authToken,t.label=4;case 4:return[2,n]}})})}function wt(t){return gt(t,function(t){if(!It(t))throw x.create("not-registered");return function(t){return 1===t.requestStatus&&t.requestTime+R<Date.now()}(t.authToken)?a(a({},t),{authToken:{requestStatus:0}}):t})}function It(t){return void 0!==t&&2===t.registrationStatus}function St(e,n){return void 0===n&&(n=!1),l(this,void 0,void 0,function(){return p(this,function(t){switch(t.label){case 0:return[4,function(n){return l(this,void 0,void 0,function(){var e;return p(this,function(t){switch(t.label){case 0:return[4,vt(n)];case 1:return(e=t.sent().registrationPromise)?[4,e]:[3,3];case 2:t.sent(),t.label=3;case 3:return[2]}})})}(e.appConfig)];case 1:return t.sent(),[4,_t(e,n)];case 2:return[2,t.sent().token]}})})}function Et(o,a){return l(this,void 0,void 0,function(){var e,n,r,i;return p(this,function(t){switch(t.label){case 0:return e=function(t,e){var n=e.fid;return U(t)+"/"+n}(o,a),n=K(o,a),r={method:"DELETE",headers:n},[4,W(function(){return fetch(e,r)})];case 1:return(i=t.sent()).ok?[3,3]:[4,H("Delete Installation",i)];case 2:throw t.sent();case 3:return[2]}})})}function Tt(t,e){var n=t.appConfig;return function(t,e){nt();var n=Y(t),r=Q.get(n);r||(r=new Set,Q.set(n,r)),r.add(e)}(n,e),function(){!function(t,e){var n=Y(t),r=Q.get(n);r&&(r.delete(e),0===r.size&&Q.delete(n),rt())}(n,e)}}function At(t){return x.create("missing-app-config-values",{valueName:t})}function Ot(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}(it=xe).INTERNAL.registerComponent(new v("installations",function(t){var e=t.getProvider("app").getImmediate(),n={appConfig:function(t){var e,n;if(!t||!t.options)throw At("App Configuration");if(!t.name)throw At("App Name");try{for(var r=s(["projectId","apiKey","appId"]),i=r.next();!i.done;i=r.next()){var o=i.value;if(!t.options[o])throw At(o)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return{appName:t.name,projectId:t.options.projectId,apiKey:t.options.apiKey,appId:t.options.appId}}(e),platformLoggerProvider:t.getProvider("platform-logger")};return{app:e,getId:function(){return function(i){return l(this,void 0,void 0,function(){var e,n,r;return p(this,function(t){switch(t.label){case 0:return[4,vt(i.appConfig)];case 1:return e=t.sent(),n=e.installationEntry,(r=e.registrationPromise)?r.catch(console.error):_t(i).catch(console.error),[2,n.fid]}})})}(n)},getToken:function(t){return St(n,t)},delete:function(){return function(r){return l(this,void 0,void 0,function(){var e,n;return p(this,function(t){switch(t.label){case 0:return[4,gt(e=r.appConfig,function(t){if(!t||0!==t.registrationStatus)return t})];case 1:if(!(n=t.sent()))return[3,6];if(1!==n.registrationStatus)return[3,2];throw x.create("delete-pending-registration");case 2:if(2!==n.registrationStatus)return[3,6];if(navigator.onLine)return[3,3];throw x.create("app-offline");case 3:return[4,Et(e,n)];case 4:return t.sent(),[4,dt(e)];case 5:t.sent(),t.label=6;case 6:return[2]}})})}(n)},onIdChange:function(t){return Tt(n,t)}}},"PUBLIC")),it.registerVersion("@firebase/installations",C),(st=at=at||{})[st.DEBUG=0]="DEBUG",st[st.VERBOSE=1]="VERBOSE",st[st.INFO=2]="INFO",st[st.WARN=3]="WARN",st[st.ERROR=4]="ERROR",st[st.SILENT=5]="SILENT";at.DEBUG,at.VERBOSE,at.INFO,at.WARN,at.ERROR,at.SILENT;function Nt(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(!(e<t.logLevel)){var i=(new Date).toISOString(),o=Pt[e];if(!o)throw new Error("Attempted to log a message with an invalid logType (value: "+e+")");console[o].apply(console,Ot(["["+i+"] "+t.name+":"],n))}}var kt=at.INFO,Pt=((ot={})[at.DEBUG]="log",ot[at.VERBOSE]="log",ot[at.INFO]="info",ot[at.WARN]="warn",ot[at.ERROR]="error",ot),Ct=(Object.defineProperty(Rt.prototype,"logLevel",{get:function(){return this._logLevel},set:function(t){if(!(t in at))throw new TypeError("Invalid value assigned to `logLevel`");this._logLevel=t},enumerable:!0,configurable:!0}),Object.defineProperty(Rt.prototype,"logHandler",{get:function(){return this._logHandler},set:function(t){if("function"!=typeof t)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t},enumerable:!0,configurable:!0}),Object.defineProperty(Rt.prototype,"userLogHandler",{get:function(){return this._userLogHandler},set:function(t){this._userLogHandler=t},enumerable:!0,configurable:!0}),Rt.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,Ot([this,at.DEBUG],t)),this._logHandler.apply(this,Ot([this,at.DEBUG],t))},Rt.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,Ot([this,at.VERBOSE],t)),this._logHandler.apply(this,Ot([this,at.VERBOSE],t))},Rt.prototype.info=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,Ot([this,at.INFO],t)),this._logHandler.apply(this,Ot([this,at.INFO],t))},Rt.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,Ot([this,at.WARN],t)),this._logHandler.apply(this,Ot([this,at.WARN],t))},Rt.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,Ot([this,at.ERROR],t)),this._logHandler.apply(this,Ot([this,at.ERROR],t))},Rt);function Rt(t){this.name=t,this._logLevel=kt,this._logHandler=Nt,this._userLogHandler=null}var jt,Mt,Bt,Lt,Dt="0.2.36",xt="FB-PERF-TRACE-MEASURE",qt="@firebase/performance/config",Ut="@firebase/performance/configexpire",Ft="Performance",Ht=((jt={})["trace started"]="Trace {$traceName} was started before.",jt["trace stopped"]="Trace {$traceName} is not running.",jt["no window"]="Window is not available.",jt["no app id"]="App id is not available.",jt["no project id"]="Project id is not available.",jt["no api key"]="Api key is not available.",jt["invalid cc log"]="Attempted to queue invalid cc event",jt["FB not default"]="Performance can only start when Firebase app instance is the default one.",jt["RC response not ok"]="RC response is not ok",jt["invalid attribute name"]="Attribute name {$attributeName} is invalid.",jt["invalid attribute value"]="Attribute value {$attributeValue} is invalid.",jt["invalide custom metric name"]="Custom metric name {$customMetricName} is invalid",jt),Vt=new f("performance",Ft,Ht),Kt=(Wt.prototype.getUrl=function(){return this.windowLocation.href.split("?")[0]},Wt.prototype.mark=function(t){this.performance&&this.performance.mark&&this.performance.mark(t)},Wt.prototype.measure=function(t,e,n){this.performance&&this.performance.measure&&this.performance.measure(t,e,n)},Wt.prototype.getEntriesByType=function(t){return this.performance&&this.performance.getEntriesByType?this.performance.getEntriesByType(t):[]},Wt.prototype.getEntriesByName=function(t){return this.performance&&this.performance.getEntriesByName?this.performance.getEntriesByName(t):[]},Wt.prototype.getTimeOrigin=function(){return this.performance&&(this.performance.timeOrigin||this.performance.timing.navigationStart)},Wt.prototype.requiredApisAvailable=function(){return!!(fetch&&Promise&&this.navigator&&this.navigator.cookieEnabled)},Wt.prototype.setupObserver=function(t,i){this.PerformanceObserver&&new this.PerformanceObserver(function(t){for(var e=0,n=t.getEntries();e<n.length;e++){var r=n[e];i(r)}}).observe({entryTypes:[t]})},Wt.getInstance=function(){return void 0===Mt&&(Mt=new Wt(Bt)),Mt},Wt);function Wt(t){if(!(this.window=t))throw Vt.create("no window");this.performance=t.performance,this.PerformanceObserver=t.PerformanceObserver,this.windowLocation=t.location,this.navigator=t.navigator,this.document=t.document,this.navigator&&this.navigator.cookieEnabled&&(this.localStorage=t.localStorage),t.perfMetrics&&t.perfMetrics.onFirstInputDelay&&(this.onFirstInputDelay=t.perfMetrics.onFirstInputDelay)}var $t,Gt,Jt,zt=(Zt.prototype.getAppId=function(){var t=this.firebaseAppInstance&&this.firebaseAppInstance.options&&this.firebaseAppInstance.options.appId;if(!t)throw Vt.create("no app id");return t},Zt.prototype.getProjectId=function(){var t=this.firebaseAppInstance&&this.firebaseAppInstance.options&&this.firebaseAppInstance.options.projectId;if(!t)throw Vt.create("no project id");return t},Zt.prototype.getApiKey=function(){var t=this.firebaseAppInstance&&this.firebaseAppInstance.options&&this.firebaseAppInstance.options.apiKey;if(!t)throw Vt.create("no api key");return t},Zt.getInstance=function(){return void 0===Lt&&(Lt=new Zt),Lt},Zt);function Zt(){this.instrumentationEnabled=!0,this.dataCollectionEnabled=!0,this.loggingEnabled=!1,this.tracesSamplingRate=1,this.networkRequestsSamplingRate=1,this.logEndPointUrl="https://firebaselogging.googleapis.com/v0cc/log?format=json_proto",this.logSource=462,this.logTraceAfterSampling=!1,this.logNetworkAfterSampling=!1,this.configTimeToLive=12}function Yt(){return $t}(Jt=Gt=Gt||{})[Jt.UNKNOWN=0]="UNKNOWN",Jt[Jt.VISIBLE=1]="VISIBLE",Jt[Jt.HIDDEN=2]="HIDDEN";var Qt=["firebase_","google_","ga_"],Xt=new RegExp("^[a-zA-Z]\\w*$");function te(){switch(Kt.getInstance().document.visibilityState){case"visible":return Gt.VISIBLE;case"hidden":return Gt.HIDDEN;default:return Gt.UNKNOWN}}var ee=new Ct(Ft);ee.logLevel=at.INFO;var ne="0.0.1",re={loggingEnabled:!0},ie="FIREBASE_INSTALLATIONS_AUTH";function oe(t){var e=function(){var t=Kt.getInstance().localStorage;if(!t)return;var e=t.getItem(Ut);if(!e||!function(t){return Number(t)>Date.now()}(e))return;var n=t.getItem(qt);if(!n)return;try{return JSON.parse(n)}catch(t){return}}();return e?(se(e),Promise.resolve()):function(r){return function(){var t=zt.getInstance().installationsService.getToken();return t.then(function(t){}),t}().then(function(t){var e="https://firebaseremoteconfig.googleapis.com/v1/projects/"+zt.getInstance().getProjectId()+"/namespaces/fireperf:fetch?key="+zt.getInstance().getApiKey(),n=new Request(e,{method:"POST",headers:{Authorization:ie+" "+t},body:JSON.stringify({app_instance_id:r,app_instance_id_token:t,app_id:zt.getInstance().getAppId(),app_version:Dt,sdk_version:ne})});return fetch(n).then(function(t){if(t.ok)return t.json();throw Vt.create("RC response not ok")})}).catch(function(){ee.info(ae)})}(t).then(function(t){return se(t)}).then(function(t){return function(t){var e=Kt.getInstance().localStorage;if(!t||!e)return;e.setItem(qt,JSON.stringify(t)),e.setItem(Ut,String(Date.now()+60*zt.getInstance().configTimeToLive*60*1e3))}(t)},function(){})}var ae="Could not fetch config, will use default configs";function se(t){if(!t)return t;var e=zt.getInstance(),n=t.entries||{};return void 0!==n.fpr_enabled?e.loggingEnabled="true"===String(n.fpr_enabled):e.loggingEnabled=re.loggingEnabled,n.fpr_log_source&&(e.logSource=Number(n.fpr_log_source)),n.fpr_log_endpoint_url&&(e.logEndPointUrl=n.fpr_log_endpoint_url),void 0!==n.fpr_vc_network_request_sampling_rate&&(e.networkRequestsSamplingRate=Number(n.fpr_vc_network_request_sampling_rate)),void 0!==n.fpr_vc_trace_sampling_rate&&(e.tracesSamplingRate=Number(n.fpr_vc_trace_sampling_rate)),e.logTraceAfterSampling=ue(e.tracesSamplingRate),e.logNetworkAfterSampling=ue(e.networkRequestsSamplingRate),t}function ue(t){return Math.random()<=t}var ce,fe=1;function le(){return fe=2,ce=ce||function(){var n=Kt.getInstance().document;return new Promise(function(t){if(n&&"complete"!==n.readyState){var e=function(){"complete"===n.readyState&&(n.removeEventListener("readystatechange",e),t())};n.addEventListener("readystatechange",e)}else t()})}().then(function(){return function(){var t=zt.getInstance().installationsService.getId();return t.then(function(t){$t=t}),t}()}).then(function(t){return oe(t)}).then(function(){return pe()},function(){return pe()})}function pe(){fe=3}var he,de=1e4,ge=5500,ve=3,me=ve,ye=[],be=!1;function _e(){be||(!function r(t){setTimeout(function(){if(0!==me){if(!ye.length)return r(de);var t=i(ye);ye=[];var e=t.map(function(t){return{source_extension_json_proto3:t.message,event_time_ms:String(t.eventTime)}}),n={request_time_ms:String(Date.now()),client_info:{client_type:1,js_client_info:{}},log_source:zt.getInstance().logSource,log_event:e};fetch(zt.getInstance().logEndPointUrl,{method:"POST",body:JSON.stringify(n)}).then(function(t){return t.ok||ee.info("Call to Firebase backend failed."),t.json()}).then(function(t){var e=Number(t.next_request_wait_millis),n=isNaN(e)?de:Math.max(de,e);me=ve,r(n)}).catch(function(){ye=i(t,ye),me--,ee.info("Tries left: "+me+"."),r(de)})}},t)}(ge),be=!0)}function we(n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];!function(t){if(!t.eventTime||!t.message)throw Vt.create("invalid cc log");ye=i(ye,[t])}({message:n.apply(void 0,t),eventTime:Date.now()})}}function Ie(t,e){(he=he||we(Te))(t,e)}function Se(t){var e=zt.getInstance();!e.instrumentationEnabled&&t.isAuto||(e.dataCollectionEnabled||t.isAuto)&&Kt.getInstance().requiredApisAvailable()&&(t.isAuto&&te()!==Gt.VISIBLE||e.loggingEnabled&&e.logTraceAfterSampling&&(3===fe?Ee(t):le().then(function(){return Ee(t)},function(){return Ee(t)})))}function Ee(t){Yt()&&setTimeout(function(){return Ie(t,1)},0)}function Te(t,e){return 0===e?function(t){var e={url:t.url,http_method:t.httpMethod||0,http_response_code:200,response_payload_bytes:t.responsePayloadBytes,client_start_time_us:t.startTimeUs,time_to_response_initiated_us:t.timeToResponseInitiatedUs,time_to_response_completed_us:t.timeToResponseCompletedUs},n={application_info:Ae(),network_request_metric:e};return JSON.stringify(n)}(t):function(t){var e={name:t.name,is_auto:t.isAuto,client_start_time_us:t.startTimeUs,duration_us:t.durationUs};0!==Object.keys(t.counters).length&&(e.counters=t.counters);var n=t.getAttributes();0!==Object.keys(n).length&&(e.custom_attributes=n);var r={application_info:Ae(),trace_metric:e};return JSON.stringify(r)}(t)}function Ae(){return{google_app_id:zt.getInstance().getAppId(),app_instance_id:Yt(),web_app_info:{sdk_version:Dt,page_url:Kt.getInstance().getUrl(),service_worker_status:function(){var t=Kt.getInstance().navigator;return"serviceWorker"in t?t.serviceWorker.controller?2:3:1}(),visibility_state:te(),effective_connection_type:function(){var t=Kt.getInstance().navigator.connection;switch(t&&t.effectiveType){case"slow-2g":return 1;case"2g":return 2;case"3g":return 3;case"4g":return 4;default:return 0}}()},application_process_state:0}}var Oe=["_fp","_fcp","_fid"];var Ne=(ke.prototype.start=function(){if(1!==this.state)throw Vt.create("trace started",{traceName:this.name});this.api.mark(this.traceStartMark),this.state=2},ke.prototype.stop=function(){if(2!==this.state)throw Vt.create("trace stopped",{traceName:this.name});this.state=3,this.api.mark(this.traceStopMark),this.api.measure(this.traceMeasure,this.traceStartMark,this.traceStopMark),this.calculateTraceMetrics(),Se(this)},ke.prototype.record=function(t,e,n){if(this.durationUs=Math.floor(1e3*e),this.startTimeUs=Math.floor(1e3*t),n&&n.attributes&&(this.customAttributes=a({},n.attributes)),n&&n.metrics)for(var r=0,i=Object.keys(n.metrics);r<i.length;r++){var o=i[r];isNaN(Number(n.metrics[o]))||(this.counters[o]=Number(Math.floor(n.metrics[o])))}Se(this)},ke.prototype.incrementMetric=function(t,e){void 0===e&&(e=1),void 0===this.counters[t]&&this.putMetric(t,0),this.counters[t]+=e},ke.prototype.putMetric=function(t,e){if(!function(t,e){return!(0===t.length||100<t.length)&&(e&&e.startsWith("_wt_")&&-1<Oe.indexOf(t)||!t.startsWith("_"))}(t,this.name))throw Vt.create("invalide custom metric name",{customMetricName:t});this.counters[t]=e},ke.prototype.getMetric=function(t){return this.counters[t]||0},ke.prototype.putAttribute=function(t,e){var n=function(e){return!(0===e.length||40<e.length||Qt.some(function(t){return e.startsWith(t)})||!e.match(Xt))}(t),r=function(t){return 0!==t.length&&t.length<=100}(e);if(n&&r)this.customAttributes[t]=e;else{if(!n)throw Vt.create("invalid attribute name",{attributeName:t});if(!r)throw Vt.create("invalid attribute value",{attributeValue:e})}},ke.prototype.getAttribute=function(t){return this.customAttributes[t]},ke.prototype.removeAttribute=function(t){void 0!==this.customAttributes[t]&&delete this.customAttributes[t]},ke.prototype.getAttributes=function(){return a({},this.customAttributes)},ke.prototype.setStartTime=function(t){this.startTimeUs=t},ke.prototype.setDuration=function(t){this.durationUs=t},ke.prototype.calculateTraceMetrics=function(){var t=this.api.getEntriesByName(this.traceMeasure),e=t&&t[0];e&&(this.durationUs=Math.floor(1e3*e.duration),this.startTimeUs=Math.floor(1e3*(e.startTime+this.api.getTimeOrigin())))},ke.createOobTrace=function(t,e,n){var r=Kt.getInstance().getUrl();if(r){var i=new ke("_wt_"+r,!0),o=Math.floor(1e3*Kt.getInstance().getTimeOrigin());if(i.setStartTime(o),t&&t[0]&&(i.setDuration(Math.floor(1e3*t[0].duration)),i.putMetric("domInteractive",Math.floor(1e3*t[0].domInteractive)),i.putMetric("domContentLoadedEventEnd",Math.floor(1e3*t[0].domContentLoadedEventEnd)),i.putMetric("loadEventEnd",Math.floor(1e3*t[0].loadEventEnd))),e){var a=e.find(function(t){return"first-paint"===t.name});a&&a.startTime&&i.putMetric("_fp",Math.floor(1e3*a.startTime));var s=e.find(function(t){return"first-contentful-paint"===t.name});s&&s.startTime&&i.putMetric("_fcp",Math.floor(1e3*s.startTime)),n&&i.putMetric("_fid",Math.floor(1e3*n))}Se(i)}},ke.createUserTimingTrace=function(t){Se(new ke(t,!1,t))},ke);function ke(t,e,n){void 0===e&&(e=!1),this.name=t,this.isAuto=e,this.state=1,this.customAttributes={},this.counters={},this.api=Kt.getInstance(),this.randomId=Math.floor(1e6*Math.random()),this.isAuto||(this.traceStartMark="FB-PERF-TRACE-START-"+this.randomId+"-"+this.name,this.traceStopMark="FB-PERF-TRACE-STOP-"+this.randomId+"-"+this.name,this.traceMeasure=n||xt+"-"+this.randomId+"-"+this.name,n&&this.calculateTraceMetrics())}function Pe(t){var e=t;if(e&&void 0!==e.responseStart){var n=Kt.getInstance().getTimeOrigin(),r=Math.floor(1e3*(e.startTime+n)),i=e.responseStart?Math.floor(1e3*(e.responseStart-e.startTime)):void 0,o=Math.floor(1e3*(e.responseEnd-e.startTime));!function(t){var e=zt.getInstance();e.instrumentationEnabled&&t.url!==e.logEndPointUrl.split("?")[0]&&e.loggingEnabled&&e.logNetworkAfterSampling&&setTimeout(function(){return Ie(t,0)},0)}({url:e.name&&e.name.split("?")[0],responsePayloadBytes:e.transferSize,startTimeUs:r,timeToResponseInitiatedUs:i,timeToResponseCompletedUs:o})}}var Ce=5e3;function Re(){Yt()&&(setTimeout(function(){return function(){var t=Kt.getInstance(),e=t.getEntriesByType("navigation"),n=t.getEntriesByType("paint");if(t.onFirstInputDelay){var r=setTimeout(function(){Ne.createOobTrace(e,n),r=void 0},Ce);t.onFirstInputDelay(function(t){r&&(clearTimeout(r),Ne.createOobTrace(e,n,t))})}else Ne.createOobTrace(e,n)}()},0),setTimeout(function(){return function(){for(var t=Kt.getInstance(),e=t.getEntriesByType("resource"),n=0,r=e;n<r.length;n++){Pe(r[n])}t.setupObserver("resource",Pe)}()},0),setTimeout(function(){return function(){for(var t=Kt.getInstance(),e=t.getEntriesByType("measure"),n=0,r=e;n<r.length;n++){je(r[n])}t.setupObserver("measure",je)}()},0))}function je(t){var e=t.name;e.substring(0,xt.length)!==xt&&Ne.createUserTimingTrace(e)}var Me=(Be.prototype.trace=function(t){return new Ne(t)},Object.defineProperty(Be.prototype,"instrumentationEnabled",{get:function(){return zt.getInstance().instrumentationEnabled},set:function(t){zt.getInstance().instrumentationEnabled=t},enumerable:!0,configurable:!0}),Object.defineProperty(Be.prototype,"dataCollectionEnabled",{get:function(){return zt.getInstance().dataCollectionEnabled},set:function(t){zt.getInstance().dataCollectionEnabled=t},enumerable:!0,configurable:!0}),Be);function Be(t){this.app=t,Kt.getInstance().requiredApisAvailable()?(_e(),le().then(Re,Re)):ee.info("Firebase Performance cannot start if browser does not support fetch and Promise or cookie is disabled.")}var Le;function De(t,e){if("[DEFAULT]"!==t.name)throw Vt.create("FB not default");if("undefined"==typeof window)throw Vt.create("no window");return function(t){Bt=t}(window),zt.getInstance().firebaseAppInstance=t,zt.getInstance().installationsService=e,new Me(t)}(Le=xe).INTERNAL.registerComponent(new v("performance",function(t){var e=t.getProvider("app").getImmediate(),n=t.getProvider("installations").getImmediate();return De(e,n)},"PUBLIC")),Le.registerVersion("@firebase/performance","0.2.36")}).apply(this,arguments)}catch(t){throw console.error(t),new Error("Cannot instantiate firebase-performance.js - be sure to load firebase-app.js first.")}});
|