LavaPack.loadBundle([[995,{_process:7374},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(e){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.Sha1=r.RANDOM_FACTOR=r.MAX_VALUE_MILLIS=r.FirebaseError=r.ErrorFactory=r.Deferred=r.DecodeBase64StringError=r.CONSTANTS=void 0,r.areCookiesEnabled=function(){if("undefined"==typeof navigator||!navigator.cookieEnabled)return!1;return!0}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */,r.assertionError=r.assert=void 0,r.async=function(e,t){return(...r)=>{Promise.resolve(!0).then(()=>{e(...r)}).catch(e=>{t&&t(e)})}},r.base64urlEncodeWithoutPadding=r.base64Encode=r.base64Decode=r.base64=void 0,r.calculateBackoffMillis=function(e,t=N,r=I){const n=t*Math.pow(r,e),a=Math.round(k*n*(Math.random()-.5)*2);return Math.min(P,n+a)}
/**
 * @license
 * Copyright 2020 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */,r.contains=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.createMockUserToken=function(e,t){if(e.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const r=t||"demo-project",n=e.iat||0,a=e.sub||e.user_id;if(!a)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o=Object.assign({iss:`https://securetoken.google.com/${r}`,aud:r,iat:n,exp:n+3600,auth_time:n,sub:a,user_id:a,firebase:{sign_in_provider:"custom",identities:{}}},e);return[l(JSON.stringify({alg:"none",type:"JWT"})),l(JSON.stringify(o)),""].join(".")}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */,r.createSubscribe=function(e,t){const r=new A(e,t);return r.subscribe.bind(r)},r.decode=void 0,r.deepCopy=function(e){return d(undefined,e)},r.deepEqual=function e(t,r){if(t===r)return!0;const n=Object.keys(t),a=Object.keys(r);for(const o of n){if(!a.includes(o))return!1;const n=t[o],s=r[o];if(T(n)&&T(s)){if(!e(n,s))return!1}else if(n!==s)return!1}for(const e of a)if(!n.includes(e))return!1;return!0},r.deepExtend=d,r.errorPrefix=O,r.extractQuerystring=function(e){const t=e.indexOf("?");if(!t)return"";const r=e.indexOf("#",t);return e.substring(t,r>0?r:undefined)}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */,r.getExperimentalSetting=r.getDefaults=r.getDefaultEmulatorHostnameAndPort=r.getDefaultEmulatorHost=r.getDefaultAppConfig=void 0,r.getGlobal=p,r.getModularInstance=
/**
 * @license
 * Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
function(e){return e&&e._delegate?e._delegate:e},r.getUA=m,r.isAdmin=void 0,r.isBrowser=function(){return"undefined"!=typeof window||S()},r.isBrowserExtension=function(){const e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:undefined;return"object"==typeof e&&e.id!==undefined},r.isCloudflareWorker=function(){return"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent},r.isElectron=function(){return m().indexOf("Electron/")>=0},r.isEmpty=function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0},r.isIE=function(){const e=m();return e.indexOf("MSIE ")>=0||e.indexOf("Trident/")>=0},r.isIndexedDBAvailable=function(){try{return"object"==typeof indexedDB}catch(e){return!1}},r.isMobileCordova=function(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(m())},r.isNode=E,r.isNodeSdk=function(){return!0===t.NODE_CLIENT||!0===t.NODE_ADMIN},r.isReactNative=function(){return"object"==typeof navigator&&"ReactNative"===navigator.product},r.isSafari=function(){return!E()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")},r.isUWP=function(){return m().indexOf("MSAppHost/")>=0},r.isValidTimestamp=r.isValidFormat=void 0,r.isWebWorker=S,r.issuedAtTime=void 0,r.jsonEval=v,r.map=function(e,t,r){const n={};for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=t.call(r,e[a],a,e));return n},r.ordinal=function(e){if(!Number.isFinite(e))return`${e}`;return e+function(e){e=Math.abs(e);const t=e%100;if(t>=10&&t<=20)return"th";const r=e%10;if(1===r)return"st";if(2===r)return"nd";if(3===r)return"rd";return"th"}(e)},r.promiseWithTimeout=
/**
 * @license
 * Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
function(e,t=2e3){const r=new b;return setTimeout(()=>r.reject("timeout!"),t),e.then(r.resolve,r.reject),r.promise}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */,r.querystring=function(e){const t=[];for(const[r,n]of Object.entries(e))Array.isArray(n)?n.forEach(e=>{t.push(encodeURIComponent(r)+"="+encodeURIComponent(e))}):t.push(encodeURIComponent(r)+"="+encodeURIComponent(n));return t.length?"&"+t.join("&"):""},r.querystringDecode=function(e){const t={},r=e.replace(/^\?/,"").split("&");return r.forEach(e=>{if(e){const[r,n]=e.split("=");t[decodeURIComponent(r)]=decodeURIComponent(n)}}),t},r.safeGet=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:undefined},r.stringToByteArray=r.stringLength=void 0,r.stringify=function(e){return JSON.stringify(e)}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */,r.validateArgCount=void 0,r.validateCallback=function(e,t,r,n){if(n&&!r)return;if("function"!=typeof r)throw new Error(O(e,t)+"must be a valid function.")},r.validateContextObject=function(e,t,r,n){if(n&&!r)return;if("object"!=typeof r||null===r)throw new Error(O(e,t)+"must be a valid context object.")}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */,r.validateIndexedDBOpenable=function(){return new Promise((e,t)=>{try{let r=!0;const n="validate-browser-context-for-indexeddb-analytics-module",a=self.indexedDB.open(n);a.onsuccess=()=>{a.result.close(),r||self.indexedDB.deleteDatabase(n),e(!0)},a.onupgradeneeded=()=>{r=!1},a.onerror=()=>{var e;t((null===(e=a.error)||void 0===e?void 0:e.message)||"")}}catch(e){t(e)}})},r.validateNamespace=function(e,t,r){if(r&&!t)return;if("string"!=typeof t)throw new Error(O(e,"namespace")+"must be a valid firebase namespace.")};
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const t=r.CONSTANTS={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},n=function(e,t){if(!e)throw a(t)};
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */r.assert=n;const a=function(e){return new Error("Firebase Database ("+t.SDK_VERSION+") INTERNAL ASSERT FAILED: "+e)};
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */r.assertionError=a;const o=function(e){const t=[];let r=0;for(let n=0;n<e.length;n++){let a=e.charCodeAt(n);a<128?t[r++]=a:a<2048?(t[r++]=a>>6|192,t[r++]=63&a|128):55296==(64512&a)&&n+1<e.length&&56320==(64512&e.charCodeAt(n+1))?(a=65536+((1023&a)<<10)+(1023&e.charCodeAt(++n)),t[r++]=a>>18|240,t[r++]=a>>12&63|128,t[r++]=a>>6&63|128,t[r++]=63&a|128):(t[r++]=a>>12|224,t[r++]=a>>6&63|128,t[r++]=63&a|128)}return t},s=r.base64={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();const r=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,n=[];for(let t=0;t<e.length;t+=3){const a=e[t],o=t+1<e.length,s=o?e[t+1]:0,i=t+2<e.length,c=i?e[t+2]:0,l=a>>2,u=(3&a)<<4|s>>4;let d=(15&s)<<2|c>>6,f=63&c;i||(f=64,o||(d=64)),n.push(r[l],r[u],r[d],r[f])}return n.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(o(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){const t=[];let r=0,n=0;for(;r<e.length;){const a=e[r++];if(a<128)t[n++]=String.fromCharCode(a);else if(a>191&&a<224){const o=e[r++];t[n++]=String.fromCharCode((31&a)<<6|63&o)}else if(a>239&&a<365){const o=((7&a)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536;t[n++]=String.fromCharCode(55296+(o>>10)),t[n++]=String.fromCharCode(56320+(1023&o))}else{const o=e[r++],s=e[r++];t[n++]=String.fromCharCode((15&a)<<12|(63&o)<<6|63&s)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();const r=t?this.charToByteMapWebSafe_:this.charToByteMap_,n=[];for(let t=0;t<e.length;){const a=r[e.charAt(t++)],o=t<e.length?r[e.charAt(t)]:0;++t;const s=t<e.length?r[e.charAt(t)]:64;++t;const c=t<e.length?r[e.charAt(t)]:64;if(++t,null==a||null==o||null==s||null==c)throw new i;const l=a<<2|o>>4;if(n.push(l),64!==s){const e=o<<4&240|s>>2;if(n.push(e),64!==c){const e=s<<6&192|c;n.push(e)}}}return n},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class i extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}r.DecodeBase64StringError=i;const c=function(e){const t=o(e);return s.encodeByteArray(t,!0)};r.base64Encode=c;const l=function(e){return c(e).replace(/\./g,"")};r.base64urlEncodeWithoutPadding=l;const u=function(e){try{return s.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function d(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:e===undefined&&(e={});break;case Array:e=[];break;default:return t}for(const r in t)t.hasOwnProperty(r)&&f(r)&&(e[r]=d(e[r],t[r]));return e}function f(e){return"__proto__"!==e}
/**
 * @license
 * Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function p(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("Unable to locate global object.")}
/**
 * @license
 * Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */r.base64Decode=u;const h=()=>{try{return p().__FIREBASE_DEFAULTS__||(()=>{if(void 0===e||void 0===e.env)return})()||(()=>{if("undefined"==typeof document)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}const t=e&&u(e[1]);return t&&JSON.parse(t)})()}catch(e){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`)}};r.getDefaults=h;const g=e=>{var t,r;return null===(r=null===(t=h())||void 0===t?void 0:t.emulatorHosts)||void 0===r?void 0:r[e]};r.getDefaultEmulatorHost=g;r.getDefaultEmulatorHostnameAndPort=e=>{const t=g(e);if(!t)return undefined;const r=t.lastIndexOf(":");if(r<=0||r+1===t.length)throw new Error(`Invalid host ${t} with no separate hostname and port!`);const n=parseInt(t.substring(r+1),10);return"["===t[0]?[t.substring(1,r-1),n]:[t.substring(0,r),n]};r.getDefaultAppConfig=()=>{var e;return null===(e=h())||void 0===e?void 0:e.config};
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
r.getExperimentalSetting=e=>{var t;return null===(t=h())||void 0===t?void 0:t[`_${e}`]};class b{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,r)=>{t?this.reject(t):this.resolve(r),"function"==typeof e&&(this.promise.catch(()=>{}),1===e.length?e(t):e(t,r))}}}
/**
 * @license
 * Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function m(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function E(){var e;const t=null===(e=h())||void 0===e?void 0:e.forceEnvironment;if("node"===t)return!0;if("browser"===t)return!1;try{return"[object process]"===Object.prototype.toString.call(global.process)}catch(e){return!1}}function S(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}r.Deferred=b;class y extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name="FirebaseError",Object.setPrototypeOf(this,y.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,_.prototype.create)}}r.FirebaseError=y;class _{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){const r=t[0]||{},n=`${this.service}/${e}`,a=this.errors[e],o=a?function(e,t){return e.replace(M,(e,r)=>{const n=t[r];return null!=n?String(n):`<${r}?>`})}(a,r):"Error",s=`${this.serviceName}: ${o} (${n}).`;return new y(n,s,r)}}r.ErrorFactory=_;const M=/\{\$([^}]+)}/g;
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function v(e){return JSON.parse(e)}const w=function(e){let t={},r={},n={},a="";try{const o=e.split(".");t=v(u(o[0])||""),r=v(u(o[1])||""),a=o[2],n=r.d||{},delete r.d}catch(e){}return{header:t,claims:r,data:n,signature:a}};r.decode=w;r.isValidTimestamp=function(e){const t=w(e).claims,r=Math.floor((new Date).getTime()/1e3);let n=0,a=0;return"object"==typeof t&&(t.hasOwnProperty("nbf")?n=t.nbf:t.hasOwnProperty("iat")&&(n=t.iat),a=t.hasOwnProperty("exp")?t.exp:n+86400),!!r&&!!n&&!!a&&r>=n&&r<=a};r.issuedAtTime=function(e){const t=w(e).claims;return"object"==typeof t&&t.hasOwnProperty("iat")?t.iat:null};r.isValidFormat=function(e){const t=w(e).claims;return!!t&&"object"==typeof t&&t.hasOwnProperty("iat")};function T(e){return null!==e&&"object"==typeof e}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
r.isAdmin=function(e){const t=w(e).claims;return"object"==typeof t&&!0===t.admin};r.Sha1=class{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(let e=1;e<this.blockSize;++e)this.pad_[e]=0;this.reset()}reset(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0}compress_(e,t){t||(t=0);const r=this.W_;if("string"==typeof e)for(let n=0;n<16;n++)r[n]=e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3),t+=4;else for(let n=0;n<16;n++)r[n]=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3],t+=4;for(let e=16;e<80;e++){const t=r[e-3]^r[e-8]^r[e-14]^r[e-16];r[e]=4294967295&(t<<1|t>>>31)}let n,a,o=this.chain_[0],s=this.chain_[1],i=this.chain_[2],c=this.chain_[3],l=this.chain_[4];for(let e=0;e<80;e++){e<40?e<20?(n=c^s&(i^c),a=1518500249):(n=s^i^c,a=1859775393):e<60?(n=s&i|c&(s|i),a=2400959708):(n=s^i^c,a=3395469782);const t=(o<<5|o>>>27)+n+l+a+r[e]&4294967295;l=c,c=i,i=4294967295&(s<<30|s>>>2),s=o,o=t}this.chain_[0]=this.chain_[0]+o&4294967295,this.chain_[1]=this.chain_[1]+s&4294967295,this.chain_[2]=this.chain_[2]+i&4294967295,this.chain_[3]=this.chain_[3]+c&4294967295,this.chain_[4]=this.chain_[4]+l&4294967295}update(e,t){if(null==e)return;t===undefined&&(t=e.length);const r=t-this.blockSize;let n=0;const a=this.buf_;let o=this.inbuf_;for(;n<t;){if(0===o)for(;n<=r;)this.compress_(e,n),n+=this.blockSize;if("string"==typeof e){for(;n<t;)if(a[o]=e.charCodeAt(n),++o,++n,o===this.blockSize){this.compress_(a),o=0;break}}else for(;n<t;)if(a[o]=e[n],++o,++n,o===this.blockSize){this.compress_(a),o=0;break}}this.inbuf_=o,this.total_+=t}digest(){const e=[];let t=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let e=this.blockSize-1;e>=56;e--)this.buf_[e]=255&t,t/=256;this.compress_(this.buf_);let r=0;for(let t=0;t<5;t++)for(let n=24;n>=0;n-=8)e[r]=this.chain_[t]>>n&255,++r;return e}};class A{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(e=>{this.error(e)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let n;if(e===undefined&&t===undefined&&r===undefined)throw new Error("Missing Observer.");n=function(e,t){if("object"!=typeof e||null===e)return!1;for(const r of t)if(r in e&&"function"==typeof e[r])return!0;return!1}(e,["next","error","complete"])?e:{next:e,error:t,complete:r},n.next===undefined&&(n.next=C),n.error===undefined&&(n.error=C),n.complete===undefined&&(n.complete=C);const a=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?n.error(this.finalError):n.complete()}catch(e){}}),this.observers.push(n),a}unsubscribeOne(e){this.observers!==undefined&&this.observers[e]!==undefined&&(delete this.observers[e],this.observerCount-=1,0===this.observerCount&&this.onNoObservers!==undefined&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(this.observers!==undefined&&this.observers[e]!==undefined)try{t(this.observers[e])}catch(e){"undefined"!=typeof console&&console.error&&console.error(e)}})}close(e){this.finalized||(this.finalized=!0,e!==undefined&&(this.finalError=e),this.task.then(()=>{this.observers=undefined,this.onNoObservers=undefined}))}}function C(){}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function O(e,t){return`${e} failed: ${t} argument `}r.validateArgCount=function(e,t,r,n){let a;if(n<t?a="at least "+t:n>r&&(a=0===r?"none":"no more than "+r),a){throw new Error(e+" failed: Was called with "+n+(1===n?" argument.":" arguments.")+" Expects "+a+".")}};r.stringToByteArray=function(e){const t=[];let r=0;for(let a=0;a<e.length;a++){let o=e.charCodeAt(a);if(o>=55296&&o<=56319){const t=o-55296;a++,n(a<e.length,"Surrogate pair missing trail surrogate.");o=65536+(t<<10)+(e.charCodeAt(a)-56320)}o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=63&o|128):o<65536?(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=63&o|128):(t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=63&o|128)}return t};
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
r.stringLength=function(e){let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);n<128?t++:n<2048?t+=2:n>=55296&&n<=56319?(t+=4,r++):t+=3}return t};const N=1e3,I=2,P=r.MAX_VALUE_MILLIS=144e5,k=r.RANDOM_FACTOR=.5}).call(this)}).call(this,e("_process"))}}},{package:"@metamask/notification-services-controller>firebase>@firebase/util",file:"node_modules/@firebase/util/dist/index.esm2017.js"}],[999,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});class n{static parse(e){if(""===e)return new n([]);if(!e.startsWith("/"))throw new a(e);const[,...t]=e.split("/");return new n(t.map(e=>e.replace(/~1/g,"/").replace(/~0/g,"~")))}constructor(e){this.tokens=e}toString(){if(0===this.tokens.length)return"";return`/${this.tokens.map(e=>e.replace(/~/g,"~0").replace(/\//g,"~1")).join("/")}`}shmeval(e){for(const t of this.tokens){if(!e.hasOwnProperty(t))throw new o(e,t);e=e[t]}return e}}r.default=n;class a extends Error{constructor(e){super(`Invalid JSON Pointer: ${e}`),this.ptr=e}}r.InvalidPtrError=a;class o extends Error{constructor(e,t){super(`Error evaluating JSON Pointer: no attribute ${t} on ${e}`),this.instance=e,this.token=t}}r.EvalError=o}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver>@json-schema-spec/json-pointer",file:"node_modules/@json-schema-spec/json-pointer/lib/index.js"}],[4,{"../../shared/constants/app":8396,"../../shared/constants/app-state":8395,"../../shared/constants/defi-referrals":8406,"../../shared/constants/errors":8407,"../../shared/constants/infura-project-id":8412,"../../shared/constants/messages":8417,"../../shared/constants/metametrics":8418,"../../shared/constants/offscreen-communication":8424,"../../shared/constants/onboarding":8425,"../../shared/constants/start-up-errors":8438,"../../shared/constants/ui-initialization":8446,"../../shared/lib/active-tab-domain-metrics":8463,"../../shared/lib/browser-runtime.utils":8480,"../../shared/lib/caip-stream":8483,"../../shared/lib/fetch-with-timeout":8535,"../../shared/lib/get-first-preferred-lang-code":8555,"../../shared/lib/install-attribution":8559,"../../shared/lib/manifestFlags":8561,"../../shared/lib/mv3.utils":8573,"../../shared/lib/object.utils":8576,"../../shared/lib/promise-with-resolvers":8586,"../../shared/lib/selectors/networks":8596,"../../shared/lib/sentry":8602,"../../shared/lib/stores/persistence-manager":8616,"./constants/background":5,"./constants/marketing-site-whitelist":6,"./constants/sentry-state":7,"./constants/snaps":8,"./constants/stream":9,"./controllers/analytics":14,"./first-time-state":58,"./lib/CronjobControllerStorageManager":62,"./lib/approval/utils":69,"./lib/critical-error/critical-error-recovery":84,"./lib/critical-error/critical-error-tab-handoff":85,"./lib/deep-links/deep-link-router":89,"./lib/deep-links/metrics":90,"./lib/defi-referrals/createDefiReferralMiddleware":91,"./lib/ens-ipfs/setup":99,"./lib/extension-lazy-listener/extension-lazy-listener":100,"./lib/getIframeProperties":102,"./lib/getObjStructure":103,"./lib/migrator":109,"./lib/notification-manager":112,"./lib/repair":126,"./lib/safe-reload":143,"./lib/setup-initial-state-hooks":147,"./lib/start-up-errors/start-up-errors":160,"./lib/state-corruption/state-corruption-recovery":161,"./lib/stream-utils":164,"./lib/update-remote-feature-flags":201,"./lib/use-split-state-storage":202,"./lib/util":203,"./metamask-controller":428,"./migrations":676,"./offscreen":677,"./on-update":678,"./platforms/extension":679,"@metamask/base-controller":1394,"@metamask/design-tokens":2063,"@metamask/utils":3930,"extension-port-stream":6489,loglevel:7090,"readable-stream":7567,"webextension-polyfill":8383},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.loadStateFromPersistence=ot,r.setupController=dt;var n=e("./lib/setup-initial-state-hooks");e("../../shared/constants/infura-project-id");var a=e("@metamask/design-tokens"),o=e("readable-stream"),s=fe(e("loglevel")),i=fe(e("webextension-polyfill")),c=e("@metamask/utils"),l=e("@metamask/base-controller"),u=e("extension-port-stream"),d=e("../../shared/lib/promise-with-resolvers"),f=e("../../shared/constants/onboarding"),p=e("../../shared/constants/app"),h=e("../../shared/constants/app-state"),g=e("../../shared/constants/messages"),b=e("../../shared/constants/ui-initialization"),m=e("../../shared/constants/metametrics"),E=e("../../shared/lib/active-tab-domain-metrics"),S=e("../../shared/lib/browser-runtime.utils"),y=e("../../shared/lib/mv3.utils"),_=e("../../shared/lib/object.utils"),M=(e("../../shared/constants/offscreen-communication"),e("../../shared/lib/sentry")),v=e("../../shared/lib/selectors/networks"),w=e("../../shared/lib/caip-stream"),T=fe(e("../../shared/lib/fetch-with-timeout")),A=e("../../shared/constants/errors"),C=fe(e("../../shared/lib/get-first-preferred-lang-code")),O=(e("../../shared/lib/manifestFlags"),e("../../shared/constants/start-up-errors")),N=e("../../shared/constants/defi-referrals"),I=e("../../shared/lib/install-attribution"),P=e("../../shared/lib/stores/persistence-manager"),k=e("./lib/critical-error/critical-error-recovery"),R=e("./lib/state-corruption/state-corruption-recovery"),L=e("./lib/approval/utils"),D=e("./lib/use-split-state-storage"),U=fe(e("./migrations")),j=fe(e("./lib/migrator")),x=e("./lib/update-remote-feature-flags"),B=fe(e("./platforms/extension")),V=e("./constants/sentry-state"),F=de(e("./lib/notification-manager")),K=de(e("./metamask-controller")),W=e("./controllers/analytics"),$=fe(e("./lib/getObjStructure")),z=fe(e("./lib/ens-ipfs/setup")),H=e("./lib/util"),G=e("./offscreen"),Y=e("./lib/stream-utils"),q=fe(e("./first-time-state")),J=e("./on-update"),X=e("./constants/marketing-site-whitelist"),Q=e("./constants/stream"),Z=e("./constants/snaps"),ee=e("./lib/extension-lazy-listener/extension-lazy-listener"),te=e("./lib/deep-links/deep-link-router"),re=e("./lib/deep-links/metrics"),ne=e("./lib/safe-reload"),ae=e("./lib/critical-error/critical-error-tab-handoff"),oe=e("./lib/repair"),se=e("./lib/start-up-errors/start-up-errors"),ie=e("./lib/CronjobControllerStorageManager"),ce=e("./lib/defi-referrals/createDefiReferralMiddleware"),le=e("./lib/getIframeProperties"),ue=e("./constants/background");function de(e,t){if("function"==typeof WeakMap)var r=new WeakMap,n=new WeakMap;return(de=function(e,t){if(!t&&e&&e.__esModule)return e;var a,o,s={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return s;if(a=t?n:r){if(a.has(e))return a.get(e);a.set(e,s)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((o=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(o.get||o.set)?a(s,t,o):s[t]=e[t]);return s})(e,t)}function fe(e){return e&&e.__esModule?e:{default:e}}const pe=globalThis.stateHooks.lazyListener??new ee.ExtensionLazyListener(i.default),he="#0376C9",ge=a.lightTheme.colors.error.default,be=9,me=99,Ee=!1;const Se=null,{safePersist:ye,requestSafeReload:_e,evacuate:Me}=(0,ne.getRequestSafeReload)(n.persistenceManager);global.stateHooks.getMostRecentPersistedState=()=>n.persistenceManager.mostRecentRetrievedState,global.stateHooks.getStorageKind=()=>n.persistenceManager.storageKind,global.logEncryptedVault=()=>{n.persistenceManager.logEncryptedVault()};const{sentry:ve}=global;let we={...q.default};const Te={[p.ENVIRONMENT_TYPE_POPUP]:!0,[p.ENVIRONMENT_TYPE_NOTIFICATION]:!0,[p.ENVIRONMENT_TYPE_FULLSCREEN]:!0};s.default.setLevel("info",!1);const Ae=new B.default,Ce=new F.default,Oe=(0,H.getPlatform)()===p.PLATFORM_FIREFOX;function Ne(e){const t=e.name,r=e.sender?.url?new URL(e.sender.url):null;let n;return n=Oe?Boolean(Te[t]):r?.origin===`chrome-extension://${i.default.runtime.id}`,{processName:t,senderUrl:r,isMetaMaskUIPort:n}}let Ie=0,Pe=!1,ke=!1,Re=0,Le=0;const De=new Set,Ue={},je={};let xe;const Be={},Ve={},Fe={};const Ke=new URL("https://metamask.github.io/phishing-warning/v5.1.0/"),We=Ke.toString();let $e,ze,He;function Ge(){const e=(0,d.withResolvers)();$e=e.promise,ze=e.resolve,He=e.reject}pe.once("runtime","onInstalled").then(e=>{!async function([e]){if("install"===e.reason)await async function(){s.default.debug("First install detected");const e=(0,I.getInstallAttribution)();Ae.openExtensionInBrowser();await $e,await pt(e)}();else if("update"===e.reason){const{previousVersion:t}=e;if(!t||t===Ae.getVersion())return;await $e,(0,J.onUpdate)(xe,Ae,t,_e)}}(e)}),Ge(),i.default?.sidePanel?.setPanelBehavior&&i.default.sidePanel.setPanelBehavior({openPanelOnActionClick:!0}).catch(()=>{});let Ye,qe,Je,Xe;const Qe=new R.CorruptionHandler,Ze=new k.CriticalErrorHandler,et=async e=>{const{isMetaMaskUIPort:t}=Ne(e);try{e.postMessage({data:{method:b.BACKGROUND_LIVENESS_METHOD},name:"background-liveness"})}catch(e){return void s.default.error("MetaMask - background-liveness check: Failed to message to port",e)}let r;t&&(Ze.registerPortForCriticalError({port:e,repairCallback:()=>(0,oe.requestRepair)(()=>(0,ae.openRestoringTabAndReload)(_e))}),r=()=>Ze.removeListenersForPort(e));try{if(await $e,t&&!(0,se.tryPostMessage)(e,b.BACKGROUND_INITIALIZED_METHOD))return;Ee,Ye(e,r)}catch(a){try{if(ve?.captureException(a),t)if((0,A.isStateCorruptionError)(a))await Qe.handleStateCorruptionError({port:e,error:a,database:n.persistenceManager,repairCallback:async e=>{Ge(),(0,P.hasVault)(e)?(await ht(e),xe.onboardingController.setFirstTimeFlowType(f.FirstTimeFlowType.restore)):(await n.persistenceManager.reset(),await ht(null))}});else{const t=(0,c.isObject)(a)?{message:a.message??"Unknown error",name:a.name??"UnknownError",stack:a.stack,...a.sentryTags&&{sentryTags:a.sentryTags}}:{message:String(a),name:"UnknownError",stack:""};(0,se.tryPostMessage)(e,O.DISPLAY_GENERAL_STARTUP_ERROR,{error:t,currentLocale:xe?.preferencesController?.state?.currentLocale})}}finally{r?.()}}},tt=()=>{pe.addListener("runtime","onConnect",et)};function rt(){const e=(new Date).toISOString();i.default.storage.session.set({timestamp:e})}async function nt(e){(0,H.initInstallType)();const t=y.isManifestV3?(0,G.createOffscreen)():null;let r=null,a=!1;y.isManifestV3&&(0,G.addOffscreenConnectivityListener)(e=>{if(a&&xe.connectivityAdapter){const t=e?"online":"offline";xe.connectivityAdapter.setStatus(t)}else r=e});const o=await ot(e),s=o.data,c=await(0,C.default)();let l;if(y.isManifestV3){if(!1!==s.PreferencesController?.enableMV3TimestampSave){const e=2e3;rt(),setInterval(rt,e)}const e=await i.default.storage.session.get(["isFirstMetaMaskControllerSetup"]);l=e?.isFirstMetaMaskControllerSetup===undefined,await i.default.storage.session.set({isFirstMetaMaskControllerSetup:l})}const u=await async function(){const e=(0,T.default)(),t=Z.PREINSTALLED_SNAPS_URLS.map(async t=>{const r=await e(t);if(t.pathname.endsWith(".json.gz")){const e=new DecompressionStream("gzip"),t=r.body.pipeThrough(e);return await new Response(t).json()}return await r.json()});return Promise.all(t)}(),d=new ie.CronjobControllerStorageManager;if(await d.init(),dt(s,c,l,o.meta,t,u,d),xe.metaMetricsController.updateTraits({[m.MetaMetricsUserTrait.StorageKind]:n.persistenceManager.storageKind}),function(e){async function t(e,t){try{const r=await i.default.tabs.get(e);return!(r.url&&r.url.startsWith("https://www.google.com/search")||(await i.default.tabs.update(e,{url:t}),0))}catch(e){return ve?.captureException(e),!1}}const r=!y.isManifestV3;i.default.webRequest.onBeforeRequest.addListener(n=>{if(n.tabId===i.default.tabs.TAB_ID_NONE)return{};const{completedOnboarding:a}=e.onboardingController.state;if(!a)return{};if(!e.preferencesController.state.usePhishDetect)return{};if(n.initiator&&"null"!==n.initiator&&new URL(n.initiator).host===Ke.host)return{};const{hostname:o,href:s,searchParams:c}=new URL(n.url);e.phishingController.maybeUpdateState();const l=e.phishingController.isBlockedRequest(n.url);let u,d;if("main_frame"!==n.type&&"sub_frame"!==n.type||(u=e.phishingController.test(n.url)),!u?.result&&!l.result)return{};let f,p=s;u?.result&&l.result?d=`${u.type} and ${l.type}`:u?.result?d=u.type:(d=l.type,p=n.initiator);try{f=new URL(p).hostname}catch{f=o,p=s}const h=new URLSearchParams({hostname:f,href:p}),g=new URL(We);g.hash=h.toString();const b=g.toString(),E=()=>{Oe||(0,W.trackEvent)((0,W.createEventBuilder)(m.MetaMetricsEventName.PhishingPageDisplayed).addCategory(m.MetaMetricsEventCategory.Phishing).addProperties({url:p,referrer:{url:p},reason:d,requestDomain:l.result?o:undefined}).build({excludeMetaMetricsId:!0}))};return r?"main_frame"===n.type?(E(),{redirectUrl:b}):(t(n.tabId,b).then(e=>{e&&E()}),{cancel:!0}):(t(n.tabId,b).then(e=>{e&&E()}),{})},{urls:["http://*/*","https://*/*","ws://*/*","wss://*/*"]},r?["blocking"]:[])}(xe),y.isManifestV3){if(a=!0,null!==r){const e=r?"online":"offline";xe.connectivityAdapter.setStatus(e)}}else{const e=e=>{const t=e?"online":"offline";xe.connectivityAdapter.setStatus(t)};e(globalThis.navigator.onLine),globalThis.addEventListener("online",()=>e(!0)),globalThis.addEventListener("offline",()=>e(!1))}y.isManifestV3||await async function(){let e;try{const t=new URL(We);let r,n;t.hash="#extensionStartup",e=window.document.createElement("iframe"),e.setAttribute("src",t.href),e.setAttribute("sandbox","allow-scripts allow-same-origin");const a=new Promise((e,t)=>{r=e,n=t});e.addEventListener("load",r),window.document.body.appendChild(e),setTimeout(()=>n(new at),1e3),await a}catch(e){e instanceof at?console.warn("Phishing warning page timeout; page not guaranteed to work offline."):console.error("Failed to initialize phishing warning page",e)}finally{e&&e.remove()}}(),await(async()=>{const e=await i.default.tabs.query({url:"<all_urls>",windowType:"normal"}).then(e=>((0,S.checkForLastErrorAndLog)(),e)).catch(()=>{(0,S.checkForLastErrorAndLog)()});for(const t of e)i.default.tabs.sendMessage(t.id,{name:g.EXTENSION_MESSAGES.READY}).then(()=>{(0,S.checkForLastErrorAndLog)()}).catch(()=>{(0,S.checkForLastErrorAndLog)()})})(),new te.DeepLinkRouter({getExtensionURL:Ae.getExtensionURL,getState:xe.getState.bind(xe)}).on("navigate",async({url:e,parsed:t})=>{"redirectTo"in t||(0,W.trackEvent)((0,re.createEvent)({signature:t.signature,url:e}))}).on("error",e=>ve?.captureException(e)).install()}tt(),i.default.runtime.onConnectExternal.addListener(async(...e)=>{await $e,qe(...e)});class at extends Error{constructor(){super("Timeout failed")}}async function ot(e){let t;if(e){t={data:{},meta:{}};for(const r of P.backedUpStateKeys)(0,c.hasProperty)(e,r)&&(t.data[r]=e[r]);(0,c.hasProperty)(e,"meta")&&(0,c.isObject)(e.meta)&&(t.meta=e.meta,"split"===e.meta.storageKind||"data"===e.meta.storageKind?n.persistenceManager.storageKind=e.meta.storageKind:n.persistenceManager.storageKind="data"),"number"!=typeof t.meta.version&&(s.default.error("The `backup`'s `meta.version` property was missing during backup restore."),t.meta.version=155)}else{const e=!0;t=await n.persistenceManager.get({validateVault:e})}const r=new j.default({migrations:U.default,defaultVersion:null});r.on("error",e=>{console.warn(e);const r=(0,$.default)(t);ve?.captureException(e,{extra:{vaultStructure:r}})});let a=!1;t?.data||t?.meta||(a=!0,t=r.generateInitialState(we));const{state:o,changedKeys:i}=await r.migrateData(t),l=async r=>{const a=t?.meta?.version,s="number"==typeof a&&a>=157;let i=e?.AppMetadataController?.firstTimeInfo??o?.data?.AppMetadataController?.firstTimeInfo??o?.data?.firstTimeInfo??t?.data?.AppMetadataController?.firstTimeInfo??t?.data?.firstTimeInfo;if(!i)try{const e=await n.persistenceManager.getBackup();i=e?.AppMetadataController?.firstTimeInfo}catch{}const c=new Error(r);return c.sentryTags={"corruption.preMigrationVersion":String(a??"unknown"),"corruption.backupShouldExist":String(s),"corruption.installVersion":String(i?.version??"unknown"),"corruption.installDate":String(i?.date??"unknown")},c};if(!o)throw await l("MetaMask - migrator returned undefined");if(!(0,c.isObject)(o.meta))throw await l(`MetaMask - migrator metadata has invalid type '${typeof o.meta}'`);if("number"!=typeof o.meta.version)throw await l(`MetaMask - migrator metadata version has invalid type '${typeof o.meta.version}'`);if(!["data","split",undefined].includes(o.meta.storageKind))throw await l(`MetaMask - migrator metadata storageKind has invalid value '${o.meta.storageKind}'`);if(!(0,c.isObject)(o.data))throw await l(`MetaMask - migrator data has invalid type '${typeof o.data}'`);if(n.persistenceManager.setMetadata(o.meta),s.default.debug("[Split State]: Loaded data from persistence with storageKind '%s'",n.persistenceManager.storageKind),"data"===n.persistenceManager.storageKind){const e=!0===o.meta.platformSplitStateGradualRolloutAttempted,t=!e&&await(0,D.useSplitStateStorage)(o.data);s.default.debug("[Split State]: shouldUseSplitStateStorage: %s (alreadyTried: %s)",t,e),t&&(o.meta.platformSplitStateGradualRolloutAttempted=!0,n.persistenceManager.setMetadata(o.meta)),s.default.debug("[Split State]: Writing data to persistence with storageKind 'data'"),await n.persistenceManager.set(o.data),t&&(await n.persistenceManager.migrateToSplitState(o.data),o.meta=n.persistenceManager.getMetaData(),o.meta!==undefined&&(delete o.meta.platformSplitStateGradualRolloutAttempted,n.persistenceManager.setMetadata(o.meta)),await n.persistenceManager.persist())}else{if("split"!==n.persistenceManager.storageKind)throw new Error(`MetaMask - persistenceManager has invalid storageKind '${n.persistenceManager.storageKind}'`);if(a)for(const[e,t]of Object.entries(o.data))n.persistenceManager.update(e,t);else for(const e of i)n.persistenceManager.update(e,o.data[e]);await n.persistenceManager.persist()}return s.default.debug("[Split State]: Load complete."),o}function st(e,t,r){const{analyticsId:n}=xe.getState();if(!(0,H.shouldEmitDappViewedEvent)(n))return;const a=xe.getPermittedAccounts(e).length;if(0===a)return;const o=xe.controllerMessenger.call("AccountsController:getState"),s=Object.keys(o.internalAccounts.accounts).length,i=(0,le.getIframeProperties)({frameId:r,origin:e,mainFrameOrigin:t});(0,W.trackEvent)((0,W.createEventBuilder)(m.MetaMetricsEventName.DappViewed).addCategory(m.MetaMetricsEventCategory.InpageProvider).addProperties({is_first_visit:!1,number_of_accounts:s,number_of_accounts_connected:a,...i}).build({referrer:{url:e},excludeMetaMetricsId:!0}))}function it(e){if(!e.sender?.tab||!e.sender?.url||!e.sender?.tab?.url)return;const t=e.sender.tab.id,r=new URL(e.sender.url),{origin:n}=r,a=new URL(e.sender.tab.url),{origin:o}=a,{frameId:s}=e.sender;Object.keys(Be).includes(t)||(Be[t]=n),t in Ve||(Ve[t]=o),t in Fe||(Fe[t]=s);const i=xe.controllerMessenger.call("PermissionController:hasPermissions",n),c="New Tab"!==e.sender.tab.title;i&&c&&st(n,o,s)}function ct(e){const{completedMetaMetricsOnboarding:t,optedIn:r}=xe.getState();if(!t||!r)return;const n=xe.appStateController.state.appActiveTab?.origin,a=(0,E.getActiveTabDomainAllowlist)(xe.remoteFeatureFlagController.state),o=(0,E.getActiveTabDomainForMetrics)(n,a);(0,W.trackEvent)((0,W.createEventBuilder)(m.MetaMetricsEventName.AppOpened).addCategory(m.MetaMetricsEventCategory.App).addProperties(o?{active_tab_domain:o}:{}).build({environmentType:e}))}function lt(e){const t=[p.ENVIRONMENT_TYPE_POPUP,p.ENVIRONMENT_TYPE_NOTIFICATION,p.ENVIRONMENT_TYPE_FULLSCREEN,p.ENVIRONMENT_TYPE_SIDEPANEL];return!(Object.values(Ue).some(Boolean)||Pe||Ie>0||Re>0)&&t.includes(e)}const ut=async e=>{if(await $e,xe)try{const t=e?{active:!0,windowId:e}:{active:!0,currentWindow:!0},r=await i.default.tabs.query(t);if(!r||0===r.length)return;const n=r[0],{id:a,title:o,url:s,favIconUrl:c}=n;if(!s)return void xe.appStateController.clearAppActiveTab();const{origin:l,protocol:u,host:d,href:f}=new URL(s);if(!(0,H.isWebOrigin)(l))return void xe.appStateController.clearAppActiveTab();xe.appStateController.setAppActiveTab({id:a,title:o,origin:l,protocol:u,url:s,host:d,href:f,favIconUrl:c}),xe.subjectMetadataController.addSubjectMetadata({origin:l,name:o||d||l,iconUrl:c||null,subjectType:"website"})}catch(e){console.log("Error refreshing appActiveTab:",e.message)}};function dt(e,t,r,a,c,d,f){xe=new K.default({infuraProjectId:globalThis.INFURA_PROJECT_ID,showUserConfirmation:ft,initState:e,initLangCode:t,platform:Ae,notificationManager:Ce,browser:i.default,getRequestAccountTabIds:()=>je,getOpenMetamaskTabsIds:()=>Ue,isFirstMetaMaskControllerSetup:r,currentMigrationVersion:a.version,featureFlags:{},offscreenPromise:c,preinstalledSnaps:d,requestSafeReload:_e,cronjobControllerStorageManager:f}),n.persistenceManager.setOnSetFailed(e=>{xe.appStateController.setStorageWriteErrorType(e)});const g=[],b=xe.store.getState();for(const t of Object.keys(b)){const r=e[t]||{},n=b[t];if(null===n||"object"!=typeof n){(0,M.captureException)(new Error(`Invalid controller state for '${t}' of type '${null===n?"null":typeof n}'`));continue}const a=Object.keys(n);if(a.length===Object.keys(r).length){for(const e of a)if(n[e]!==r[e]){g.push(t);break}}else g.push(t)}var E;"split"===n.persistenceManager.storageKind?(g.length>0&&(s.default.info(`MetaMaskController state changed during configuration for controllers: ${g.join(", ")}. Persisting updated state.`),g.forEach(e=>{n.persistenceManager.update(e,b[e])}),ye().catch(e=>{s.default.error("Error persisting updated state:",e),ve?.captureException(e)})),xe.store.on("stateChange",async({controllerKey:e,newState:t,_oldState:r,_patches:a})=>{n.persistenceManager.update(e,t),P.backedUpStateKeys.includes(e)&&P.backedUpStateKeys.forEach(t=>{if(t===e)return;const r=xe.store.config[t];if(!r?.metadata)throw new Error(`Cannot backup ${t}: controller metadata is required but not found. All controllers in backedUpStateKeys must extend BaseController and define metadata.`);const a=xe.controllerMessenger.call(`${t}:getState`),o=(0,l.deriveStateFromMetadata)(a,r.metadata,"persist");n.persistenceManager.update(t,o)});try{await ye()}catch(e){s.default.error("Error persisting state change:",e),ve?.captureException(e)}})):(g.length>0&&(s.default.info(`MetaMaskController state changed during configuration for controllers: ${g.join(", ")}. Persisting updated state.`),ye(b).catch(e=>{s.default.error("Error persisting updated controller state:",e),ve?.captureException(e)})),xe.store.on("update",ye)),xe.store.on("error",e=>{s.default.error("MetaMask controller.store error:",e),ve?.captureException(e)}),(0,z.default)({getCurrentChainId:()=>(0,v.getCurrentChainId)({metamask:xe.networkController.state}),getIpfsGateway:xe.preferencesController.getIpfsGateway.bind(xe.preferencesController),getUseAddressBarEnsResolution:()=>xe.preferencesController.state.useAddressBarEnsResolution,provider:xe.provider}),E=xe,global.stateHooks.getSentryAppState=function(){const e=E.memStore.getState();return(0,_.maskObject)(e,V.SENTRY_BACKGROUND_STATE)};const S=()=>Ie>0||Boolean(Object.keys(Ue).length)||Pe||Re>0||!1,T=()=>Ie>0||Re>0,A=()=>Pe&&!T(),C=(e,t)=>{if(!1===e)xe.onClientClosed();else{if(t===p.ENVIRONMENT_TYPE_FULLSCREEN&&Boolean(Object.keys(Ue).length)||t===p.ENVIRONMENT_TYPE_SIDEPANEL&&Re>0)return;xe.onEnvironmentTypeClosed(t)}};function O(e){try{xe.appStateController.setDefaultHomeActiveTabName(e??null)}catch(e){console.error("Error setting landing tab:",e)}}function N(){De.clear(),Le=0,k()}function I(e,t){return e>t?`${t}+`:String(e)}function k(){const e=R();let t="",r=he;Le>0&&!A()?(t=I(Le,be),r=ge):e>0&&(t=I(e,be));try{const e={text:t},n={color:r};y.isManifestV3?(i.default.action.setBadgeText(e),i.default.action.setBadgeBackgroundColor(n)):(i.default.browserAction.setBadgeText(e),i.default.browserAction.setBadgeBackgroundColor(n))}catch(e){console.error("Error updating browser badge:",e)}}function R(){try{return(0,L.getAttentionRequiredApprovalCount)({approvalController:xe.approvalController})}catch(e){return console.error("Failed to get pending approval count:",e),0}}Ye=(e,t)=>{if(ue.BLOCKED_PORTS.includes(e.name))return;const{processName:r,senderUrl:n,isMetaMaskUIPort:a}=Ne(e);if(a){const n=new u.ExtensionPortStream(e),a=function({chunkSize:e}){(0,W.trackEvent)((0,W.createEventBuilder)(m.MetaMetricsEventName.PortStreamChunked).addCategory(m.MetaMetricsEventCategory.PortStream).addProperties({chunkSize:e}).build())};e.onDisconnect.addListener(()=>n.off("message-too-large",a)),n.on("message-too-large",a),xe.isClientOpen=!0,xe.setupTrustedCommunication(n,e.sender).finally(()=>{t?.()});const i=r===p.ENVIRONMENT_TYPE_SIDEPANEL&&lt(p.ENVIRONMENT_TYPE_SIDEPANEL);if(r!==p.ENVIRONMENT_TYPE_SIDEPANEL&&lt(s=r)&&ct(s),(0,x.updateRemoteFeatureFlags)(xe),r===p.ENVIRONMENT_TYPE_POPUP&&(N(),Ie+=1,(0,o.finished)(n,()=>{Ie-=1;const e=S();xe.isClientOpen=e,C(e,p.ENVIRONMENT_TYPE_POPUP)})),r===p.ENVIRONMENT_TYPE_SIDEPANEL&&(N(),Re+=1,ut().then(()=>{i&&ct(p.ENVIRONMENT_TYPE_SIDEPANEL)}),(0,o.finished)(n,()=>{Re=Math.max(Re-1,0);const e=S();xe.isClientOpen=e,C(e,p.ENVIRONMENT_TYPE_SIDEPANEL)})),r===p.ENVIRONMENT_TYPE_NOTIFICATION&&(Pe=!0,(0,o.finished)(n,()=>{Pe=!1,Le>0&&O(h.AccountOverviewTabKey.Activity),k();const e=S();xe.isClientOpen=e,C(e,p.ENVIRONMENT_TYPE_NOTIFICATION)})),r===p.ENVIRONMENT_TYPE_FULLSCREEN){N();const t=e.sender.tab.id;Ue[t]=!0,(0,o.finished)(n,()=>{delete Ue[t];const e=S();xe.isClientOpen=e,C(e,p.ENVIRONMENT_TYPE_FULLSCREEN)})}}else if(n&&n.origin===Ke.origin&&n.pathname===Ke.pathname){const t=new u.ExtensionPortStream(e,{chunkSize:0});xe.setupPhishingCommunication({connectionStream:t})}else{if(e.sender&&e.sender.tab&&e.sender.url){const t=e.sender.tab.id,r=new URL(e.sender.url),{origin:n}=r;it(e),e.onMessage.addListener(e=>{e.data&&e.data.method===p.MESSAGE_TYPE.ETH_REQUEST_ACCOUNTS&&(je[n]=t)})}if(n&&X.COOKIE_ID_MARKETING_WHITELIST_ORIGINS.some(e=>e===n.origin)){const t=new u.ExtensionPortStream(e,{chunkSize:0});xe.setUpCookieHandlerCommunication({connectionStream:t})}const t=new u.ExtensionPortStream(e,{chunkSize:0});if(Je(t,e.sender),Oe||!y.isManifestV3){const r=(0,Y.setupMultiplex)(t);r.ignoreStream(Q.METAMASK_EIP_1193_PROVIDER),Xe(r.createStream(Q.METAMASK_CAIP_MULTICHAIN_PROVIDER),e.sender)}}var s},qe=e=>{const t=e.sender?.url;if(t){const{hostname:r}=new URL(t);if(ue.BLOCKED_HOSTNAMES.includes(r))return void e.disconnect()}const r=new u.ExtensionPortStream(e,{chunkSize:0});if(!e.sender.id){if(ue.BLOCKED_PORTS.includes(e.name))return;it(e),Xe((0,w.createCaipStream)(r),e.sender)}else Je(r,e.sender)},Je=(e,t)=>{xe.setupUntrustedCommunicationEip1193({connectionStream:e,sender:t})},Xe=(e,t)=>{xe.setupUntrustedCommunicationCaip({connectionStream:e,sender:t})},k(),xe.controllerMessenger.subscribe(K.METAMASK_CONTROLLER_EVENTS.DECRYPT_MESSAGE_MANAGER_UPDATE_BADGE,k),xe.controllerMessenger.subscribe(K.METAMASK_CONTROLLER_EVENTS.ENCRYPTION_PUBLIC_KEY_MANAGER_UPDATE_BADGE,k),xe.signatureController.hub.on(K.METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE,k),xe.controllerMessenger.subscribe(K.METAMASK_CONTROLLER_EVENTS.APP_STATE_UNLOCK_CHANGE,k),xe.controllerMessenger.subscribe(K.METAMASK_CONTROLLER_EVENTS.APPROVAL_STATE_CHANGE,k),xe.controllerMessenger.subscribe(K.METAMASK_CONTROLLER_EVENTS.METAMASK_NOTIFICATIONS_LIST_UPDATED,k),xe.controllerMessenger.subscribe(K.METAMASK_CONTROLLER_EVENTS.METAMASK_NOTIFICATIONS_MARK_AS_READ,k),xe.controllerMessenger.subscribe("TransactionController:transactionStatusUpdated",function({transactionMeta:e}){const{status:t,txParams:r,chainId:n}=e??{};if("failed"!==t&&"dropped"!==t)return;const{from:a,nonce:o}=r??{},s=a&&o!==undefined&&n?`${n}:${a.toLowerCase()}:${o}`:undefined;if(s&&De.has(s))return;if(T())return;s&&(De.size>=me&&De.clear(),De.add(s));Le+=1,A()||O(h.AccountOverviewTabKey.Activity);k()}),Ce.on(F.NOTIFICATION_MANAGER_EVENTS.POPUP_CLOSED,({automaticallyClosed:e})=>{e?R()>0&&ft():(xe.signatureController.rejectUnapproved(m.REJECT_NOTIFICATION_CLOSE_SIG),xe.decryptMessageController.rejectUnapproved(m.REJECT_NOTIFICATION_CLOSE),xe.encryptionPublicKeyController.rejectUnapproved(m.REJECT_NOTIFICATION_CLOSE),xe.legacyBackgroundApiService.rejectAllPendingApprovals()),k()})}async function ft(){const e=await Ae.getActiveTabs(),t=Boolean(e.find(e=>Ue[e.id])),r=e.length>0&&e[0].extData&&e[0].extData.indexOf("vivaldi_tab")>-1;if(!ke&&(r||0===Ie)&&!t&&0===Re){ke=!0;try{const e=xe.appStateController.getCurrentPopupId();await Ce.showPopup(e=>xe.appStateController.setCurrentPopupId(e),e)}finally{ke=!1}}}const pt=async e=>{const{deferredDeepLink:t,traits:r}=await e;xe.metaMetricsController.updateTraits({[m.MetaMetricsUserTrait.InstallDateExt]:(new Date).toISOString().split("T")[0],...r});const n={};t&&(xe.appStateController.setDeferredDeepLink(t),n.install_source="deeplink",n.deeplink_path=t.referringLink);const a={category:m.MetaMetricsEventCategory.App,event:m.MetaMetricsEventName.AppInstalled,properties:n},{completedMetaMetricsOnboarding:o,optedIn:s,analyticsId:i}=xe.getState();!0===o&&!1===s||(!0===o&&!0===s&&i?(0,W.trackEvent)((0,W.createEventBuilder)(m.MetaMetricsEventName.AppInstalled).addCategory(m.MetaMetricsEventCategory.App).addProperties(n).build()):xe.metaMetricsController.addEventBeforeMetricsOptIn(a))};i.default.runtime.onUpdateAvailable.addListener(async function(e){await $e,s.default.info("An update is available",e?.version),xe.appStateController.setPendingExtensionVersion(e?.version??null)});(async()=>{if(i.default?.sidePanel)try{await $e,await async function(){if(!i.default?.sidePanel?.setPanelBehavior)return;const e=xe?.preferencesController?.state?.preferences?.useSidePanelAsDefault??!0;await i.default.sidePanel.setPanelBehavior({openPanelOnActionClick:e})}(),xe?.controllerMessenger?.subscribe("PreferencesController:stateChange",e=>{i.default?.sidePanel?.setPanelBehavior&&i.default.sidePanel.setPanelBehavior({openPanelOnActionClick:e}).catch(e=>console.error("Error updating panel behavior:",e))},e=>e?.preferences?.useSidePanelAsDefault??!0)}catch(e){console.error("Error setting side panel toolbar behavior:",e)}})();async function ht(e){i.default.tabs.onActivated.addListener(e=>{if(xe){const{tabId:t}=e,r=Be[t],n=Ve[t];r&&xe.permissionController.state.subjects[r]!==undefined&&st(r,n,Fe[t]);const a=(0,N.getPartnerByOrigin)(n);a&&xe.permissionController.state.subjects[n]!==undefined&&xe.handleDefiReferral(a,t,ce.ReferralTriggerType.OnNavigateConnectedTab).catch(e=>{s.default.error(`Failed to handle ${a.name} referral after navigation to connected tab: `,e)})}});try{await nt(e),n.persistenceManager.cleanUpMostRecentRetrievedState(),s.default.info("MetaMask initialization complete."),ze()}catch(e){s.default.error(e),He(e)}}(async()=>{await ut()})(),i.default.tabs.onActivated.addListener(async({tabId:e})=>{if(await $e,!xe)return{};try{const t=await i.default.tabs.get(e),{id:r,title:n,url:a,favIconUrl:o}=t;if(!a)return xe.appStateController.clearAppActiveTab(),{};const{origin:s,protocol:c,host:l,href:u}=new URL(a);if(!(0,H.isWebOrigin)(s))return xe.appStateController.clearAppActiveTab(),{};xe.appStateController.setAppActiveTab({id:r,title:n,origin:s,protocol:c,url:a,host:l,href:u,favIconUrl:o}),xe.subjectMetadataController.addSubjectMetadata({origin:s,name:n||l||s,iconUrl:o||null,subjectType:"website"})}catch(e){console.log("Error in tabs.onActivated listener:",e.message)}return{}}),i.default.tabs.onUpdated.addListener(async(e,t,r)=>{if(await $e,!xe)return{};const n=t.url!==undefined,a="complete"===t.status;if(!n&&!a)return{};try{const t=r||await i.default.tabs.get(e),{id:o,title:s,url:c,favIconUrl:l}=t,u=xe.appStateController.state.appActiveTab,d=u?.id===o;if(!c)return d&&xe.appStateController.clearAppActiveTab(),{};const{origin:f,protocol:p,host:h,href:g}=new URL(c);if(!f||"null"===f||f.startsWith("chrome-extension://")||f.startsWith("moz-extension://"))return d&&xe.appStateController.clearAppActiveTab(),{};let b=!1;try{b=(await i.default.tabs.query({active:!0,currentWindow:!0})).some(e=>e.id===o)}catch(e){b=d}(n||a)&&b&&(xe.appStateController.setAppActiveTab({id:o,title:s,origin:f,protocol:p,url:c,host:h,href:g,favIconUrl:l}),xe.subjectMetadataController.addSubjectMetadata({origin:f,name:s||h||f,iconUrl:l||null,subjectType:"website"}))}catch(e){console.log("Error in tabs.onUpdated listener:",e.message)}return{}}),i.default.windows.onFocusChanged.addListener(async e=>{e!==i.default.windows.WINDOW_ID_NONE&&await ut(e)}),async function(){const e=await(0,ae.readCriticalErrorRestoreSession)(i.default),t=undefined;let r=null;(e||t?.simulateBackgroundStateSyncHang||t?.simulateBackgroundInitializationHang)&&(r=await n.persistenceManager.getBackup().catch(()=>null));const a=(0,P.hasVault)(r);if((t?.simulateBackgroundStateSyncHang||t?.simulateBackgroundInitializationHang)&&Se&&(Se.hasVaultAtStartup=a?Date.now():null),e&&(await(0,ae.clearCriticalErrorRestoreSession)(i.default),a)){Se&&(Se.restoreInProgress=!0);const t={tabId:e.tabId,tabUrl:e.tabUrl};ht(r);try{await $e}catch(e){return void s.default.error("critical-error-restore: initialization failed",e)}return xe.onboardingController.setFirstTimeFlowType(f.FirstTimeFlowType.restore),void await(0,ae.handoffRestoringTabToExtension)(Ae,t)}ht(null)}().catch(e=>{s.default.error("initOrRestoreBackground failed",e)})}}},{package:"$root$",file:"app/scripts/background.js"}]],[4],{});