firebase
Version:
Firebase JavaScript library for web and Node.js
3 lines (2 loc) • 25.8 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("@firebase/app-compat"),require("@firebase/app")):"function"==typeof define&&define.amd?define(["@firebase/app-compat","@firebase/app"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).firebase,e.firebase.INTERNAL.modularAPIs)}(this,function(Pe,Oe){"use strict";try{!(function(){function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u,t,r=e(Pe);function g(){return"object"==typeof indexedDB}class c extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name="FirebaseError",Object.setPrototypeOf(this,c.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,a.prototype.create)}}class a{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){var a,r=t[0]||{},i=`${this.service}/${e}`,s=this.errors[e],s=s?(a=r,s.replace(n,(e,t)=>{var r=a[t];return null!=r?String(r):`<${t}?>`})):"Error",s=`${this.serviceName}: ${s} (${i}).`;return new c(i,s,r)}}const n=/\{\$([^}]+)}/g;function s(e){return e&&e._delegate?e._delegate:e}function i(e,a){return new Promise((t,r)=>{e.onsuccess=e=>{t(e.target.result)},e.onerror=e=>{var t;r(`${a}: ${null===(t=e.target.error)||void 0===t?void 0:t.message}`)}})}class o{constructor(e){this._db=e,this.objectStoreNames=this._db.objectStoreNames}transaction(e,t="readonly"){return new l(this._db.transaction.call(this._db,e,t))}createObjectStore(e,t){return new h(this._db.createObjectStore(e,t))}close(){this._db.close()}}class l{constructor(e){this._transaction=e,this.complete=new Promise((e,t)=>{this._transaction.oncomplete=function(){e()},this._transaction.onerror=()=>{t(this._transaction.error)},this._transaction.onabort=()=>{t(this._transaction.error)}})}objectStore(e){return new h(this._transaction.objectStore(e))}}class h{constructor(e){this._store=e}index(e){return new d(this._store.index(e))}createIndex(e,t,r){return new d(this._store.createIndex(e,t,r))}get(e){return i(this._store.get(e),"Error reading from IndexedDB")}put(e,t){return i(this._store.put(e,t),"Error writing to IndexedDB")}delete(e){return i(this._store.delete(e),"Error deleting from IndexedDB")}clear(){return i(this._store.clear(),"Error clearing IndexedDB object store")}}class d{constructor(e){this._index=e}get(e){return i(this._index.get(e),"Error reading from IndexedDB")}}class f{constructor(e,t,r){this.name=e,this.instanceFactory=t,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}(t=u=u||{})[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT";const p={debug:u.DEBUG,verbose:u.VERBOSE,info:u.INFO,warn:u.WARN,error:u.ERROR,silent:u.SILENT},m=u.INFO,w={[u.DEBUG]:"log",[u.VERBOSE]:"log",[u.INFO]:"info",[u.WARN]:"warn",[u.ERROR]:"error"},v=(e,t,...r)=>{if(!(t<e.logLevel)){var a=(new Date).toISOString(),i=w[t];if(!i)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[i](`[${a}] ${e.name}:`,...r)}};class _{constructor(e){this.name=e,this._logLevel=m,this._logHandler=v,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in u))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?p[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,u.DEBUG,...e),this._logHandler(this,u.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,u.VERBOSE,...e),this._logHandler(this,u.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,u.INFO,...e),this._logHandler(this,u.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,u.WARN,...e),this._logHandler(this,u.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,u.ERROR,...e),this._logHandler(this,u.ERROR,...e)}}var b="@firebase/installations",S="0.5.8";const y=1e4,C=`w:${S}`,E="FIS_v2",I="https://firebaseinstallations.googleapis.com/v1",T=36e5;var L;const M=new a("installations","Installations",{"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."});function F(e){return e instanceof c&&e.code.includes("request-failed")}function P({projectId:e}){return`${I}/projects/${e}/installations`}function O(e){return{token:e.token,requestStatus:2,expiresIn:(e=e.expiresIn,Number(e.replace("s","000"))),creationTime:Date.now()}}async function k(e,t){var r=(await t.json()).error;return M.create("request-failed",{requestName:e,serverCode:r.code,serverMessage:r.message,serverStatus:r.status})}function N({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function j(e,{refreshToken:t}){const r=N(e);return r.append("Authorization",(t=t,`${E} ${t}`)),r}async function D(e){var t=await e();return 500<=t.status&&t.status<600?e():t}function R(t){return new Promise(e=>{setTimeout(e,t)})}const A=/^[cdef][\w-]{21}$/,$="";function x(){try{const t=new Uint8Array(17),r=self.crypto||self.msCrypto;r.getRandomValues(t),t[0]=112+t[0]%16;var e=function(e){const t=function(e){const t=btoa(String.fromCharCode(...e));return t.replace(/\+/g,"-").replace(/\//g,"_")}(e);return t.substr(0,22)}(t);return A.test(e)?e:$}catch(e){return $}}function B(e){return`${e.appName}!${e.appId}`}const H=new Map;function q(e,t){var r=B(e);V(r,t),function(e,t){const r=function(){!K&&"BroadcastChannel"in self&&(K=new BroadcastChannel("[Firebase] FID Change"),K.onmessage=e=>{V(e.data.key,e.data.fid)});return K}();r&&r.postMessage({key:e,fid:t});0===H.size&&K&&(K.close(),K=null)}(r,t)}function V(e,t){var r=H.get(e);if(r)for(const a of r)a(t)}let K=null;const U="firebase-installations-store";let z=null;function G(){var e,i,s;return z=z||(e="firebase-installations-database",i=1,s=(e,t)=>{0===t&&e.createObjectStore(U)},new Promise((t,r)=>{try{const a=indexedDB.open(e,i);a.onsuccess=e=>{t(new o(e.target.result))},a.onerror=e=>{var t;r(`Error opening indexedDB: ${null===(t=e.target.error)||void 0===t?void 0:t.message}`)},a.onupgradeneeded=e=>{s(new o(a.result),e.oldVersion,e.newVersion,new l(a.transaction))}}catch(e){r(`Error opening indexedDB: ${e.message}`)}})),z}async function W(e,t){var r=B(e);const a=await G(),i=a.transaction(U,"readwrite"),s=i.objectStore(U);var n=await s.get(r);return await s.put(t,r),await i.complete,n&&n.fid===t.fid||q(e,t.fid),t}async function J(e){var t=B(e);const r=await G(),a=r.transaction(U,"readwrite");await a.objectStore(U).delete(t),await a.complete}async function Y(e,t){var r=B(e);const a=await G(),i=a.transaction(U,"readwrite"),s=i.objectStore(U);var n=await s.get(r),o=t(n);return void 0===o?await s.delete(r):await s.put(o,r),await i.complete,!o||n&&n.fid===o.fid||q(e,o.fid),o}async function Z(r){let a;var e=await Y(r.appConfig,e=>{var t=X(e||{fid:x(),registrationStatus:0}),t=function(e,t){{if(0!==t.registrationStatus)return 1===t.registrationStatus?{installationEntry:t,registrationPromise:async function(e){let t=await Q(e.appConfig);for(;1===t.registrationStatus;)await R(100),t=await Q(e.appConfig);if(0!==t.registrationStatus)return t;{var{installationEntry:r,registrationPromise:a}=await Z(e);return a||r}}(e)}:{installationEntry:t};if(!navigator.onLine){var r=Promise.reject(M.create("app-offline"));return{installationEntry:t,registrationPromise:r}}var a={fid:t.fid,registrationStatus:1,registrationTime:Date.now()},r=async function(t,r){try{var e=await async function({appConfig:e,heartbeatServiceProvider:t},{fid:r}){const a=P(e),i=N(e),s=t.getImmediate({optional:!0});!s||(n=await s.getHeartbeatsHeader())&&i.append("x-firebase-client",n);var n={fid:r,authVersion:E,appId:e.appId,sdkVersion:C};const o={method:"POST",headers:i,body:JSON.stringify(n)},c=await D(()=>fetch(a,o));if(c.ok){n=await c.json();return{fid:n.fid||r,registrationStatus:2,refreshToken:n.refreshToken,authToken:O(n.authToken)}}throw await k("Create Installation",c)}(t,r);return W(t.appConfig,e)}catch(e){throw F(e)&&409===e.customData.serverCode?await J(t.appConfig):await W(t.appConfig,{fid:r.fid,registrationStatus:0}),e}}(e,a);return{installationEntry:a,registrationPromise:r}}}(r,t);return a=t.registrationPromise,t.installationEntry});return e.fid===$?{installationEntry:await a}:{installationEntry:e,registrationPromise:a}}function Q(e){return Y(e,e=>{if(!e)throw M.create("installation-not-found");return X(e)})}function X(e){return 1===(t=e).registrationStatus&&t.registrationTime+y<Date.now()?{fid:e.fid,registrationStatus:0}:e;var t}async function ee({appConfig:e,heartbeatServiceProvider:t},r){const a=([i,s]=[e,r["fid"]],`${P(i)}/${s}/authTokens:generate`);var i,s;const n=j(e,r),o=t.getImmediate({optional:!0});!o||(c=await o.getHeartbeatsHeader())&&n.append("x-firebase-client",c);var c={installation:{sdkVersion:C,appId:e.appId}};const l={method:"POST",headers:n,body:JSON.stringify(c)},u=await D(()=>fetch(a,l));if(u.ok)return O(await u.json());throw await k("Generate Auth Token",u)}async function te(a,i=!1){let s;var e=await Y(a.appConfig,e=>{if(!ae(e))throw M.create("not-registered");var t,r=e.authToken;if(i||2!==(t=r).requestStatus||function(e){var t=Date.now();return t<e.creationTime||e.creationTime+e.expiresIn<t+T}(t)){if(1===r.requestStatus)return s=async function(e,t){let r=await re(e.appConfig);for(;1===r.authToken.requestStatus;)await R(100),r=await re(e.appConfig);var a=r.authToken;return 0===a.requestStatus?te(e,t):a}(a,i),e;if(!navigator.onLine)throw M.create("app-offline");r=(t=e,r={requestStatus:1,requestTime:Date.now()},Object.assign(Object.assign({},t),{authToken:r}));return s=async function(t,r){try{var a=await ee(t,r),e=Object.assign(Object.assign({},r),{authToken:a});return await W(t.appConfig,e),a}catch(e){throw!F(e)||401!==e.customData.serverCode&&404!==e.customData.serverCode?(a=Object.assign(Object.assign({},r),{authToken:{requestStatus:0}}),await W(t.appConfig,a)):await J(t.appConfig),e}}(a,r),r}return e});return s?await s:e.authToken}function re(e){return Y(e,e=>{if(!ae(e))throw M.create("not-registered");var t,r=e.authToken;return 1===(t=r).requestStatus&&t.requestTime+y<Date.now()?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e})}function ae(e){return void 0!==e&&2===e.registrationStatus}async function ie(e,t=!1){var r,a=e;return await((r=(await Z(a)).registrationPromise)&&await r),(await te(a,t)).token}function se(e){return M.create("missing-app-config-values",{valueName:e})}const ne="installations",oe=e=>{var t=e.getProvider("app").getImmediate();return{app:t,appConfig:function(e){if(!e||!e.options)throw se("App Configuration");if(!e.name)throw se("App Name");for(const t of["projectId","apiKey","appId"])if(!e.options[t])throw se(t);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}(t),heartbeatServiceProvider:Oe._getProvider(t,"heartbeat"),_delete:()=>Promise.resolve()}},ce=e=>{var t=e.getProvider("app").getImmediate();const r=Oe._getProvider(t,ne).getImmediate();return{getId:()=>async function(e){var t=e;const{installationEntry:r,registrationPromise:a}=await Z(t);return(a||te(t)).catch(console.error),r.fid}(r),getToken:e=>ie(r,e)}};Oe._registerComponent(new f(ne,oe,"PUBLIC")),Oe._registerComponent(new f("installations-internal",ce,"PRIVATE")),Oe.registerVersion(b,S),Oe.registerVersion(b,S,"esm2017");const le="@firebase/remote-config";class ue{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}const ge=new a("remoteconfig","Remote Config",{"registration-window":"Undefined window object. This SDK only supports usage in a browser environment.","registration-project-id":"Undefined project identifier. Check Firebase app initialization.","registration-api-key":"Undefined API key. Check Firebase app initialization.","registration-app-id":"Undefined app identifier. Check Firebase app initialization.","storage-open":"Error thrown when opening storage. Original error: {$originalErrorMessage}.","storage-get":"Error thrown when reading from storage. Original error: {$originalErrorMessage}.","storage-set":"Error thrown when writing to storage. Original error: {$originalErrorMessage}.","storage-delete":"Error thrown when deleting from storage. Original error: {$originalErrorMessage}.","fetch-client-network":"Fetch client failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.","fetch-timeout":'The config fetch request timed out. Configure timeout using "fetchTimeoutMillis" SDK setting.',"fetch-throttle":'The config fetch request timed out while in an exponential backoff state. Configure timeout using "fetchTimeoutMillis" SDK setting. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.',"fetch-client-parse":"Fetch client could not parse response. Original error: {$originalErrorMessage}.","fetch-status":"Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.","indexed-db-unavailable":"Indexed DB is not supported by current browser"});const he=["1","true","t","yes","y","on"];class de{constructor(e,t=""){this._source=e,this._value=t}asString(){return this._value}asBoolean(){return"static"!==this._source&&0<=he.indexOf(this._value.toLowerCase())}asNumber(){if("static"===this._source)return 0;let e=Number(this._value);return isNaN(e)&&(e=0),e}getSource(){return this._source}}async function fe(e){const t=s(e);var[r,a]=await Promise.all([t._storage.getLastSuccessfulFetchResponse(),t._storage.getActiveConfigEtag()]);return!!(r&&r.config&&r.eTag&&r.eTag!==a)&&(await Promise.all([t._storageCache.setActiveConfig(r.config),t._storage.setActiveConfigEtag(r.eTag)]),!0)}function pe(e){const t=s(e);return t._initializePromise||(t._initializePromise=t._storageCache.loadFromStorage().then(()=>{t._isInitializationComplete=!0})),t._initializePromise}async function me(t){const r=s(t),e=new ue;setTimeout(async()=>{e.abort()},r.settings.fetchTimeoutMillis);try{await r._client.fetch({cacheMaxAgeMillis:r.settings.minimumFetchIntervalMillis,signal:e}),await r._storageCache.setLastFetchStatus("success")}catch(e){var a=(i="fetch-throttle",(t=e)instanceof c&&-1!==t.code.indexOf(i)?"throttle":"failure");throw await r._storageCache.setLastFetchStatus(a),e}var i}function we(r){const e=s(r);return[t={},a={}]=[e._storageCache.getActiveConfig(),e.defaultConfig],Object.keys(Object.assign(Object.assign({},t),a)).reduce((e,t)=>(e[t]=ve(r,t),e),{});var t,a}function ve(e,t){const r=s(e);r._isInitializationComplete||r._logger.debug(`A value was requested for key "${t}" before SDK initialization completed.`+" Await on ensureInitialized if the intent was to get a previously activated value.");var a=r._storageCache.getActiveConfig();return a&&void 0!==a[t]?new de("remote",a[t]):r.defaultConfig&&void 0!==r.defaultConfig[t]?new de("default",String(r.defaultConfig[t])):(r._logger.debug(`Returning static value for key "${t}".`+" Define a default or remote value if this is unintentional."),new de("static"))}class _e{constructor(e,t,r,a){this.client=e,this.storage=t,this.storageCache=r,this.logger=a}isCachedDataFresh(e,t){if(!t)return this.logger.debug("Config fetch cache check. Cache unpopulated."),!1;var r=Date.now()-t,a=r<=e;return this.logger.debug("Config fetch cache check."+` Cache age millis: ${r}.`+` Cache max age millis (minimumFetchIntervalMillis setting): ${e}.`+` Is cache hit: ${a}.`),a}async fetch(e){var[t,r]=await Promise.all([this.storage.getLastSuccessfulFetchTimestampMillis(),this.storage.getLastSuccessfulFetchResponse()]);if(r&&this.isCachedDataFresh(e.cacheMaxAgeMillis,t))return r;e.eTag=r&&r.eTag;r=await this.client.fetch(e);const a=[this.storageCache.setLastSuccessfulFetchTimestampMillis(Date.now())];return 200===r.status&&a.push(this.storage.setLastSuccessfulFetchResponse(r)),await Promise.all(a),r}}class be{constructor(e,t,r,a,i,s){this.firebaseInstallations=e,this.sdkVersion=t,this.namespace=r,this.projectId=a,this.apiKey=i,this.appId=s}async fetch(r){var e,[t,a]=await Promise.all([this.firebaseInstallations.getId(),this.firebaseInstallations.getToken()]),i=`${window.FIREBASE_REMOTE_CONFIG_URL_BASE||"https://firebaseremoteconfig.googleapis.com"}/v1/projects/${this.projectId}/namespaces/${this.namespace}:fetch?key=${this.apiKey}`,s={"Content-Type":"application/json","Content-Encoding":"gzip","If-None-Match":r.eTag||"*"},a={sdk_version:this.sdkVersion,app_instance_id:t,app_instance_id_token:a,app_id:this.appId,language_code:(e=navigator).languages&&e.languages[0]||e.language},a={method:"POST",headers:s,body:JSON.stringify(a)},i=fetch(i,a),a=new Promise((e,t)=>{r.signal.addEventListener(()=>{const e=new Error("The operation was aborted.");e.name="AbortError",t(e)})});let n;try{await Promise.race([i,a]),n=await i}catch(e){let t="fetch-client-network";throw"AbortError"===e.name&&(t="fetch-timeout"),ge.create(t,{originalErrorMessage:e.message})}let o=n.status;i=n.headers.get("ETag")||void 0;let c,l;if(200===n.status){let e;try{e=await n.json()}catch(e){throw ge.create("fetch-client-parse",{originalErrorMessage:e.message})}c=e.entries,l=e.state}if("INSTANCE_STATE_UNSPECIFIED"===l?o=500:"NO_CHANGE"===l?o=304:"NO_TEMPLATE"!==l&&"EMPTY_CONFIG"!==l||(c={}),304!==o&&200!==o)throw ge.create("fetch-status",{httpStatus:o});return{status:o,eTag:i,config:c}}}class Se{constructor(e,t){this.client=e,this.storage=t}async fetch(e){var t=await this.storage.getThrottleMetadata()||{backoffCount:0,throttleEndTimeMillis:Date.now()};return this.attemptFetch(e,t)}async attemptFetch(t,{throttleEndTimeMillis:r,backoffCount:a}){var i,s;i=t.signal,s=r,await new Promise((e,t)=>{var r=Math.max(s-Date.now(),0);const a=setTimeout(e,r);i.addEventListener(()=>{clearTimeout(a),t(ge.create("fetch-throttle",{throttleEndTimeMillis:s}))})});try{var n=await this.client.fetch(t);return await this.storage.deleteThrottleMetadata(),n}catch(e){if(!function(e){if(e instanceof c&&e.customData){var t=Number(e.customData.httpStatus);return 429===t||500===t||503===t||504===t}}(e))throw e;var o={throttleEndTimeMillis:Date.now()+(r=2,n=1e3*Math.pow(r,a),o=Math.round(.5*n*(Math.random()-.5)*2),Math.min(144e5,n+o)),backoffCount:a+1};return await this.storage.setThrottleMetadata(o),this.attemptFetch(t,o)}}}class ye{constructor(e,t,r,a,i){this.app=e,this._client=t,this._storageCache=r,this._storage=a,this._logger=i,this._isInitializationComplete=!1,this.settings={fetchTimeoutMillis:6e4,minimumFetchIntervalMillis:432e5},this.defaultConfig={}}get fetchTimeMillis(){return this._storageCache.getLastSuccessfulFetchTimestampMillis()||-1}get lastFetchStatus(){return this._storageCache.getLastFetchStatus()||"no-fetch-yet"}}function Ce(e,t){var r=e.target.error||void 0;return ge.create(t,{originalErrorMessage:r&&r.message})}const Ee="app_namespace_store";class Ie{constructor(e,t,r,a=function(){return new Promise((t,r)=>{try{const e=indexedDB.open("firebase_remote_config",1);e.onerror=e=>{r(Ce(e,"storage-open"))},e.onsuccess=e=>{t(e.target.result)},e.onupgradeneeded=e=>{const t=e.target.result;0===e.oldVersion&&t.createObjectStore(Ee,{keyPath:"compositeKey"})}}catch(e){r(ge.create("storage-open",{originalErrorMessage:e}))}})}()){this.appId=e,this.appName=t,this.namespace=r,this.openDbPromise=a}getLastFetchStatus(){return this.get("last_fetch_status")}setLastFetchStatus(e){return this.set("last_fetch_status",e)}getLastSuccessfulFetchTimestampMillis(){return this.get("last_successful_fetch_timestamp_millis")}setLastSuccessfulFetchTimestampMillis(e){return this.set("last_successful_fetch_timestamp_millis",e)}getLastSuccessfulFetchResponse(){return this.get("last_successful_fetch_response")}setLastSuccessfulFetchResponse(e){return this.set("last_successful_fetch_response",e)}getActiveConfig(){return this.get("active_config")}setActiveConfig(e){return this.set("active_config",e)}getActiveConfigEtag(){return this.get("active_config_etag")}setActiveConfigEtag(e){return this.set("active_config_etag",e)}getThrottleMetadata(){return this.get("throttle_metadata")}setThrottleMetadata(e){return this.set("throttle_metadata",e)}deleteThrottleMetadata(){return this.delete("throttle_metadata")}async get(n){const o=await this.openDbPromise;return new Promise((r,t)=>{const e=o.transaction([Ee],"readonly"),a=e.objectStore(Ee);var i=this.createCompositeKey(n);try{const s=a.get(i);s.onerror=e=>{t(Ce(e,"storage-get"))},s.onsuccess=e=>{var t=e.target.result;r(t?t.value:void 0)}}catch(e){t(ge.create("storage-get",{originalErrorMessage:e&&e.message}))}})}async set(n,o){const c=await this.openDbPromise;return new Promise((e,t)=>{const r=c.transaction([Ee],"readwrite"),a=r.objectStore(Ee);var i=this.createCompositeKey(n);try{const s=a.put({compositeKey:i,value:o});s.onerror=e=>{t(Ce(e,"storage-set"))},s.onsuccess=()=>{e()}}catch(e){t(ge.create("storage-set",{originalErrorMessage:e&&e.message}))}})}async delete(n){const o=await this.openDbPromise;return new Promise((e,t)=>{const r=o.transaction([Ee],"readwrite"),a=r.objectStore(Ee);var i=this.createCompositeKey(n);try{const s=a.delete(i);s.onerror=e=>{t(Ce(e,"storage-delete"))},s.onsuccess=()=>{e()}}catch(e){t(ge.create("storage-delete",{originalErrorMessage:e&&e.message}))}})}createCompositeKey(e){return[this.appId,this.appName,this.namespace,e].join()}}class Te{constructor(e){this.storage=e}getLastFetchStatus(){return this.lastFetchStatus}getLastSuccessfulFetchTimestampMillis(){return this.lastSuccessfulFetchTimestampMillis}getActiveConfig(){return this.activeConfig}async loadFromStorage(){var e=this.storage.getLastFetchStatus(),t=this.storage.getLastSuccessfulFetchTimestampMillis(),r=this.storage.getActiveConfig(),e=await e;e&&(this.lastFetchStatus=e);t=await t;t&&(this.lastSuccessfulFetchTimestampMillis=t);r=await r;r&&(this.activeConfig=r)}setLastFetchStatus(e){return this.lastFetchStatus=e,this.storage.setLastFetchStatus(e)}setLastSuccessfulFetchTimestampMillis(e){return this.lastSuccessfulFetchTimestampMillis=e,this.storage.setLastSuccessfulFetchTimestampMillis(e)}setActiveConfig(e){return this.activeConfig=e,this.storage.setActiveConfig(e)}}async function Le(){if(!g())return!1;try{return await new Promise((t,r)=>{try{let e=!0;const a="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(a);i.onsuccess=()=>{i.result.close(),e||self.indexedDB.deleteDatabase(a),t(!0)},i.onupgradeneeded=()=>{e=!1},i.onerror=()=>{var e;r((null===(e=i.error)||void 0===e?void 0:e.message)||"")}}catch(e){r(e)}})}catch(e){return!1}}Oe._registerComponent(new f("remote-config",function(e,{instanceIdentifier:t}){var r=e.getProvider("app").getImmediate(),a=e.getProvider("installations-internal").getImmediate();if("undefined"==typeof window)throw ge.create("registration-window");if(!g())throw ge.create("indexed-db-unavailable");var{projectId:i,apiKey:s,appId:n}=r.options;if(!i)throw ge.create("registration-project-id");if(!s)throw ge.create("registration-api-key");if(!n)throw ge.create("registration-app-id");t=t||"firebase";const o=new Ie(n,r.name,t),c=new Te(o),l=new _(le);l.logLevel=u.ERROR;n=new be(a,Oe.SDK_VERSION,t,i,s,n),n=new Se(n,o),n=new _e(n,o,c,l),n=new ye(r,n,c,o,l);return pe(n),n},"PUBLIC").setMultipleInstances(!0)),Oe.registerVersion(le,"0.3.7"),Oe.registerVersion(le,"0.3.7","esm2017");class Me{constructor(e,t){this.app=e,this._delegate=t}get defaultConfig(){return this._delegate.defaultConfig}set defaultConfig(e){this._delegate.defaultConfig=e}get fetchTimeMillis(){return this._delegate.fetchTimeMillis}get lastFetchStatus(){return this._delegate.lastFetchStatus}get settings(){return this._delegate.settings}set settings(e){this._delegate.settings=e}activate(){return fe(this._delegate)}ensureInitialized(){return pe(this._delegate)}fetch(){return me(this._delegate)}fetchAndActivate(){return async function(e){return await me(e=s(e)),fe(e)}(this._delegate)}getAll(){return we(this._delegate)}getBoolean(e){return ve(s(this._delegate),e).asBoolean()}getNumber(e){return ve(s(this._delegate),e).asNumber()}getString(e){return ve(s(this._delegate),e).asString()}getValue(e){return ve(this._delegate,e)}setLogLevel(e){!function(e,t){const r=s(e);switch(t){case"debug":r._logger.logLevel=u.DEBUG;break;case"silent":r._logger.logLevel=u.SILENT;break;default:r._logger.logLevel=u.ERROR}}(this._delegate,e)}}function Fe(e,{instanceIdentifier:t}){var r=e.getProvider("app-compat").getImmediate(),a=e.getProvider("remote-config").getImmediate({identifier:t});return new Me(r,a)}(L=r.default).INTERNAL.registerComponent(new f("remoteConfig-compat",Fe,"PUBLIC").setMultipleInstances(!0).setServiceProps({isSupported:Le})),L.registerVersion("@firebase/remote-config-compat","0.1.8")}).apply(this,arguments)}catch(e){throw console.error(e),new Error("Cannot instantiate firebase-remote-config-compat.js - be sure to load firebase-app.js first.")}});
//# sourceMappingURL=firebase-remote-config-compat.js.map