LavaPack.loadBundle([[924,{_process:6291},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=P){const n=t*Math.pow(r,e),o=Math.round(k*n*(Math.random()-.5)*2);return Math.min(I,n+o)}
/**
 * @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,o=e.sub||e.user_id;if(!o)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const i=Object.assign({iss:`https://securetoken.google.com/${r}`,aud:r,iat:n,exp:n+3600,auth_time:n,sub:o,user_id:o,firebase:{sign_in_provider:"custom",identities:{}}},e);return[l(JSON.stringify({alg:"none",type:"JWT"})),l(JSON.stringify(i)),""].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 O(e,t);return r.subscribe.bind(r)},r.decode=void 0,r.deepCopy=function(e){return f(undefined,e)},r.deepEqual=function e(t,r){if(t===r)return!0;const n=Object.keys(t),o=Object.keys(r);for(const i of n){if(!o.includes(i))return!1;const n=t[i],s=r[i];if(T(n)&&T(s)){if(!e(n,s))return!1}else if(n!==s)return!1}for(const e of o)if(!n.includes(e))return!1;return!0},r.deepExtend=f,r.errorPrefix=A,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=b,r.isAdmin=void 0,r.isBrowser=function(){return"undefined"!=typeof window||y()},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 b().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=b();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(b())},r.isNode=v,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!v()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")},r.isUWP=function(){return b().indexOf("MSAppHost/")>=0},r.isValidTimestamp=r.isValidFormat=void 0,r.isWebWorker=y,r.issuedAtTime=void 0,r.jsonEval=S,r.map=function(e,t,r){const n={};for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=t.call(r,e[o],o,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 g;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(A(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(A(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",o=self.indexedDB.open(n);o.onsuccess=()=>{o.result.close(),r||self.indexedDB.deleteDatabase(n),e(!0)},o.onupgradeneeded=()=>{r=!1},o.onerror=()=>{var e;t((null===(e=o.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(A(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 o(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 o=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=o;const i=function(e){const t=[];let r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=63&o|128):55296==(64512&o)&&n+1<e.length&&56320==(64512&e.charCodeAt(n+1))?(o=65536+((1023&o)<<10)+(1023&e.charCodeAt(++n)),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=63&o|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=63&o|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 o=e[t],i=t+1<e.length,s=i?e[t+1]:0,a=t+2<e.length,c=a?e[t+2]:0,l=o>>2,u=(3&o)<<4|s>>4;let f=(15&s)<<2|c>>6,d=63&c;a||(d=64,i||(f=64)),n.push(r[l],r[u],r[f],r[d])}return n.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(i(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 o=e[r++];if(o<128)t[n++]=String.fromCharCode(o);else if(o>191&&o<224){const i=e[r++];t[n++]=String.fromCharCode((31&o)<<6|63&i)}else if(o>239&&o<365){const i=((7&o)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536;t[n++]=String.fromCharCode(55296+(i>>10)),t[n++]=String.fromCharCode(56320+(1023&i))}else{const i=e[r++],s=e[r++];t[n++]=String.fromCharCode((15&o)<<12|(63&i)<<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 o=r[e.charAt(t++)],i=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==o||null==i||null==s||null==c)throw new a;const l=o<<2|i>>4;if(n.push(l),64!==s){const e=i<<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 a extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}r.DecodeBase64StringError=a;const c=function(e){const t=i(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 f(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)&&d(r)&&(e[r]=f(e[r],t[r]));return e}function d(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 m=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=m;r.getDefaultEmulatorHostnameAndPort=e=>{const t=m(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 g{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 b(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function v(){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 y(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}r.Deferred=g;class E extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name="FirebaseError",Object.setPrototypeOf(this,E.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,_.prototype.create)}}r.FirebaseError=E;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}`,o=this.errors[e],i=o?function(e,t){return e.replace(w,(e,r)=>{const n=t[r];return null!=n?String(n):`<${r}?>`})}(o,r):"Error",s=`${this.serviceName}: ${i} (${n}).`;return new E(n,s,r)}}r.ErrorFactory=_;const w=/\{\$([^}]+)}/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 S(e){return JSON.parse(e)}const M=function(e){let t={},r={},n={},o="";try{const i=e.split(".");t=S(u(i[0])||""),r=S(u(i[1])||""),o=i[2],n=r.d||{},delete r.d}catch(e){}return{header:t,claims:r,data:n,signature:o}};r.decode=M;r.isValidTimestamp=function(e){const t=M(e).claims,r=Math.floor((new Date).getTime()/1e3);let n=0,o=0;return"object"==typeof t&&(t.hasOwnProperty("nbf")?n=t.nbf:t.hasOwnProperty("iat")&&(n=t.iat),o=t.hasOwnProperty("exp")?t.exp:n+86400),!!r&&!!n&&!!o&&r>=n&&r<=o};r.issuedAtTime=function(e){const t=M(e).claims;return"object"==typeof t&&t.hasOwnProperty("iat")?t.iat:null};r.isValidFormat=function(e){const t=M(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=M(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,o,i=this.chain_[0],s=this.chain_[1],a=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&(a^c),o=1518500249):(n=s^a^c,o=1859775393):e<60?(n=s&a|c&(s|a),o=2400959708):(n=s^a^c,o=3395469782);const t=(i<<5|i>>>27)+n+l+o+r[e]&4294967295;l=c,c=a,a=4294967295&(s<<30|s>>>2),s=i,i=t}this.chain_[0]=this.chain_[0]+i&4294967295,this.chain_[1]=this.chain_[1]+s&4294967295,this.chain_[2]=this.chain_[2]+a&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 o=this.buf_;let i=this.inbuf_;for(;n<t;){if(0===i)for(;n<=r;)this.compress_(e,n),n+=this.blockSize;if("string"==typeof e){for(;n<t;)if(o[i]=e.charCodeAt(n),++i,++n,i===this.blockSize){this.compress_(o),i=0;break}}else for(;n<t;)if(o[i]=e[n],++i,++n,i===this.blockSize){this.compress_(o),i=0;break}}this.inbuf_=i,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 O{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 o=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),o}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 A(e,t){return`${e} failed: ${t} argument `}r.validateArgCount=function(e,t,r,n){let o;if(n<t?o="at least "+t:n>r&&(o=0===r?"none":"no more than "+r),o){throw new Error(e+" failed: Was called with "+n+(1===n?" argument.":" arguments.")+" Expects "+o+".")}};r.stringToByteArray=function(e){const t=[];let r=0;for(let o=0;o<e.length;o++){let i=e.charCodeAt(o);if(i>=55296&&i<=56319){const t=i-55296;o++,n(o<e.length,"Surrogate pair missing trail surrogate.");i=65536+(t<<10)+(e.charCodeAt(o)-56320)}i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):i<65536?(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|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,P=2,I=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"}],[925,{},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 o(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 i(e,t);e=e[t]}return e}}r.default=n;class o extends Error{constructor(e){super(`Invalid JSON Pointer: ${e}`),this.ptr=e}}r.InvalidPtrError=o;class i extends Error{constructor(e,t){super(`Error evaluating JSON Pointer: no attribute ${t} on ${e}`),this.instance=e,this.token=t}}r.EvalError=i}}},{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"}],[926,{"@json-schema-tools/reference-resolver":931,"@json-schema-tools/traverse":934,"fast-safe-stringify":5558},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.NonStringRefError=void 0;var a=s(e("@json-schema-tools/traverse")),c=s(e("@json-schema-tools/reference-resolver")),l=s(e("fast-safe-stringify")),u=function(e){this.name="NonStringRefError",this.message=["NonStringRefError","Found an improperly formatted $ref in schema. $ref must be a string","schema in question: ".concat((0,l.default)(e))].join("\n")};r.NonStringRefError=u;var f=function(e,t){if(e.$ref!==undefined&&Object.keys(e).length>1&&!0!==t&&!1!==t){var r=n(n({},t),e);return delete r.$ref,r}return t},d=function(){function e(e,t){var r;if(void 0===t&&(t={}),this.options=t,this.refCache={},r=!0===this.options.mutate||!0===e||!1===e?e:n({},e),this.options.recursive===undefined&&(this.options.recursive=!0),this.options.rootSchema===undefined&&(this.options.rootSchema=r),!0!==e&&!1!==e&&e.$id&&(this.options.rootSchema=r),this.options.refCache&&(this.refCache=this.options.refCache),this.options.protocolHandlerMap)for(var o=0,i=Object.keys(this.options.protocolHandlerMap);o<i.length;o++){var s=i[o];c.default.protocolHandlerMap[s]=this.options.protocolHandlerMap[s]}this.schema=r,this.refs=this.collectRefs()}return e.prototype.resolve=function(){return o(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this._resolve()];case 1:return e.sent(),delete this.schema.definitions,delete this.schema.components,[2,this.schema]}})})},e.prototype._resolve=function(){return o(this,void 0,void 0,function(){var t,r,o,s,l,u,d,p,h,m,g,b=this;return i(this,function(i){switch(i.label){case 0:if(!0===this.schema||!1===this.schema)return[2,Promise.resolve(this.schema)];if(0===this.refs.length)return[2,Promise.resolve(this.schema)];t=this.refs.filter(function(e){return b.refCache[e]===undefined}),r=[],o=0,s=t,i.label=1;case 1:return o<s.length?(l=s[o],u=void 0,this.refCache[l]===undefined?[3,2]:(u=this.refCache[l],[3,5])):[3,11];case 2:if("#"!==l)return[3,3];if(this.options.rootSchema===undefined)throw new Error("options.rootSchema was not provided, but one of the schemas references '#'");return u=this.options.rootSchema,[3,5];case 3:return d=c.default.resolve(l,this.options.rootSchema),r.push(d),[4,d];case 4:u=i.sent(),i.label=5;case 5:return!0!==this.options.recursive||!0===u||!1===u||"#"===l?[3,9]:(p=n(n({},this.options),{refCache:this.refCache}),0===(h=new e(u,p)).refs.length?[3,7]:(m=h._resolve(),r.push(m),[4,m]));case 6:return g=i.sent(),this.refCache[l]=f(u,g),[3,8];case 7:this.refCache[l]=u,i.label=8;case 8:return[3,10];case 9:this.refCache[l]=u,i.label=10;case 10:return o++,[3,1];case 11:return this.schema.$ref!==undefined?this.schema=f(this.schema,this.refCache[this.schema.$ref]):(0,a.default)(this.schema,function(e){if(!0===e||!1===e)return e;if(e.$ref!==undefined){var t=b.refCache[e.$ref];return f(e,t)}return e},{mutable:!0}),[4,Promise.all(r)];case 12:return i.sent(),[2,this.schema]}})})},e.prototype.collectRefs=function(){var e=[];return(0,a.default)(this.schema,function(t){if(!0===t||!1===t)return t;if(t.$ref&&-1===e.indexOf(t.$ref)){if("string"!=typeof t.$ref)throw new u(t);e.push(t.$ref)}return t}),e},e}();r.default=d}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer",file:"node_modules/@json-schema-tools/dereferencer/build/dereferencer.js"}],[927,{"./dereferencer":926},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.NonStringRefError=void 0;var o=n(e("./dereferencer")),i=e("./dereferencer");Object.defineProperty(r,"NonStringRefError",{enumerable:!0,get:function(){return i.NonStringRefError}}),r.default=o.default}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer",file:"node_modules/@json-schema-tools/dereferencer/build/index.js"}],[928,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.jsonSchema=void 0,r.jsonSchema={$schema:"https://meta.json-schema.tools/",$id:"https://meta.json-schema.tools/",title:"JSONSchema",default:{},oneOf:[{$ref:"#/definitions/JSONSchemaObject"},{$ref:"#/definitions/JSONSchemaBoolean"}],definitions:{JSONSchemaBoolean:{title:"JSONSchemaBoolean",description:"Always valid if true. Never valid if false. Is constant.",type:"boolean"},JSONSchemaObject:{title:"JSONSchemaObject",type:"object",properties:{$id:{title:"$id",type:"string",format:"uri-reference"},$schema:{title:"$schema",type:"string",format:"uri"},$ref:{title:"$ref",type:"string",format:"uri-reference"},$comment:{title:"$comment",type:"string"},title:{title:"title",type:"string"},description:{title:"description",type:"string"},default:!0,readOnly:{title:"readOnly",type:"boolean",default:!1},examples:{title:"examples",type:"array",items:!0},multipleOf:{title:"multipleOf",type:"number",exclusiveMinimum:0},maximum:{title:"maximum",type:"number"},exclusiveMaximum:{title:"exclusiveMaximum",type:"number"},minimum:{title:"minimum",type:"number"},exclusiveMinimum:{title:"exclusiveMinimum",type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{title:"pattern",type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{title:"items",anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{title:"uniqueItems",type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{title:"definitions",type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{title:"properties",type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{title:"patternProperties",type:"object",additionalProperties:{$ref:"#"},propertyNames:{title:"propertyNames",format:"regex"},default:{}},dependencies:{title:"dependencies",type:"object",additionalProperties:{title:"dependenciesSet",anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{title:"enum",type:"array",items:!0,minItems:1,uniqueItems:!0},type:{title:"type",anyOf:[{$ref:"#/definitions/simpleTypes"},{title:"arrayOfSimpleTypes",type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{title:"format",type:"string"},contentMediaType:{title:"contentMediaType",type:"string"},contentEncoding:{title:"contentEncoding",type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}}},schemaArray:{title:"schemaArray",type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{title:"nonNegativeInteger",type:"integer",minimum:0},nonNegativeIntegerDefault0:{title:"nonNegativeIntegerDefaultZero",type:"integer",minimum:0,default:0},simpleTypes:{title:"simpleTypes",type:"string",enum:["array","boolean","integer","null","number","object","string"]},stringArray:{title:"stringArray",type:"array",items:{type:"string"},uniqueItems:!0,default:[]}}},r.default=r.jsonSchema}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/meta-schema",file:"node_modules/@json-schema-tools/meta-schema/index.js"}],[929,{"./errors":930,"isomorphic-fetch":5787},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var s=e("./errors"),a=i(e("isomorphic-fetch")),c=function(e){return n(void 0,void 0,void 0,function(){var t,r;return o(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,(0,a.default)(e)];case 1:return t=n.sent(),[3,3];case 2:throw n.sent(),new s.InvalidRemoteURLError(e);case 3:return n.trys.push([3,5,,6]),[4,t.json()];case 4:return[2,n.sent()];case 5:throw r=n.sent(),new s.NonJsonRefError({$ref:e},r.message);case 6:return[2]}})})};r.default={https:c,http:c}}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver",file:"node_modules/@json-schema-tools/reference-resolver/build/default-protocol-handler-map.js"}],[93,{"../../../shared/lib/sentry":7563,"@metamask/messenger":2979},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.getRootMessenger=r.ROOT_MESSENGER_NAMESPACE=void 0;var n=e("@metamask/messenger"),o=e("../../../shared/lib/sentry");const i=r.ROOT_MESSENGER_NAMESPACE="Root";r.getRootMessenger=()=>new n.Messenger({namespace:i,captureException:o.captureException})}}},{package:"$root$",file:"app/scripts/lib/messenger.ts"}],[930,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidFileSystemPathError=r.InvalidRemoteURLError=r.NotResolvableError=r.NonJsonRefError=void 0;var n=function(e,t){this.name="NonJsonRefError",this.message=["NonJsonRefError","The resolved value at the reference: ".concat(e.$ref," was not JSON.parse 'able"),"The non-json content in question: ".concat(t)].join("\n")};r.NonJsonRefError=n;var o=function(e){this.name="NotResolvableError",this.message=["NotResolvableError","Could not resolve the reference: ".concat(e),"No protocol handler was found, and it was not found to be an internal reference"].join("\n")};r.NotResolvableError=o;var i=function(e){this.name="InvalidRemoteURLError",this.message=["InvalidRemoteURLError","The url was not resolvable: ".concat(e)].join("\n")};r.InvalidRemoteURLError=i;var s=function(e){this.name="InvalidFileSystemPathError",this.message=["InvalidFileSystemPathError","The path was not resolvable: ".concat(e)].join("\n")};r.InvalidFileSystemPathError=s}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver",file:"node_modules/@json-schema-tools/reference-resolver/build/errors.js"}],[931,{"./default-protocol-handler-map":929,"./reference-resolver":932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var a=s(e("./default-protocol-handler-map")),c=s(e("./reference-resolver")),l=n(n({},a.default),{file:function(){return o(void 0,void 0,void 0,function(){return i(this,function(e){return[2,undefined]})})}});r.default=new c.default(l)}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver",file:"node_modules/@json-schema-tools/reference-resolver/build/index-web.js"}],[932,{"./errors":930,"./resolve-pointer":933},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var s=e("./errors"),a=i(e("./resolve-pointer")),c=function(){function e(e){this.protocolHandlerMap=e}return e.prototype.resolve=function(e){return n(this,arguments,void 0,function(e,t){var r,n,i,c,l,u,f,d,p,h;return void 0===t&&(t={}),o(this,function(o){switch(o.label){case 0:if("#"===e[0])return[2,Promise.resolve((0,a.default)(e,t))];(r=e.split("#")).length>1&&(n=r[r.length-1]),i=r[0],o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.protocolHandlerMap.file(i,t)];case 2:return c=o.sent(),[3,4];case 3:throw l=o.sent(),new s.NonJsonRefError({$ref:e},l.message);case 4:if(c!==undefined)return h=c,n&&(h=(0,a.default)(n,h)),[2,h];if(!1===e.includes("://"))throw new s.InvalidFileSystemPathError(e);u=0,f=Object.keys(this.protocolHandlerMap),o.label=5;case 5:return u<f.length?(d=f[u],i.startsWith(d)?[4,this.protocolHandlerMap[d](i,t)]:[3,7]):[3,8];case 6:if((p=o.sent())!==undefined)return h=p,n&&(h=(0,a.default)(n,h)),[2,h];o.label=7;case 7:return u++,[3,5];case 8:throw new s.NotResolvableError(e)}})})},e}();r.default=c}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver",file:"node_modules/@json-schema-tools/reference-resolver/build/reference-resolver.js"}],[933,{"@json-schema-spec/json-pointer":925},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidJsonPointerRefError=void 0;var o=n(e("@json-schema-spec/json-pointer")),i=function(e,t){this.name="InvalidJsonPointerRefError",this.message=["InvalidJsonPointerRefError","The provided RFC6901 JSON Pointer is invalid: ".concat(e),"","addition info: ",t].join("\n")};r.InvalidJsonPointerRefError=i,r.default=function(e,t){try{var r=e.replace("#","");return o.default.parse(r).shmeval(t)}catch(t){throw new i(e,t.message)}}}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver",file:"node_modules/@json-schema-tools/reference-resolver/build/resolve-pointer.js"}],[934,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(r,"__esModule",{value:!0}),r.defaultOptions=void 0,r.defaultOptions={skipFirstMutation:!1,mutable:!1,bfs:!1};var i=function(e){return e.map(function(e){return""===e?"$":".".concat(e)}).join("")},s=function(e,t){var r=t.find(function(t){return t===e});return r||!1},a=function(e,t){return void 0===t&&(t=1),e[e.length-t]};r.default=function e(t,c,l,u,f,d,p,h,m){void 0===l&&(l=r.defaultOptions),void 0===u&&(u=0),void 0===f&&(f=[]),void 0===d&&(d=[]),void 0===p&&(p=[]),void 0===h&&(h=[]),void 0===m&&(m=[]);var g=n(n({},r.defaultOptions),l);if(0===u&&(p=[""]),"boolean"==typeof t||t instanceof Boolean)return!0===g.skipFirstMutation&&0===u?t:c(t,!1,i(p),a(d));var b=t;!1===g.mutable&&(b=n({},t)),d.push(b),!0===g.bfs&&(!1!==g.skipFirstMutation&&0===u||(b=c(b,!1,i(p),a(d,2)))),f.push(t),h.push([t,b]);var v=function(t,r){var n=s(t,f);return n?(m.push(n),!0===g.skipFirstMutation&&n===f[0]?c(t,!0,i(r),a(d)):h.find(function(e){var t=e[0];return n===t})[1]):e(t,c,l,u+1,f,d,r,h,m)};if(t.anyOf)b.anyOf=t.anyOf.map(function(e,t){return v(e,o(o([],p,!0),["anyOf[".concat(t,"]")],!1))});else if(t.allOf)b.allOf=t.allOf.map(function(e,t){return v(e,o(o([],p,!0),["allOf[".concat(t,"]")],!1))});else if(t.oneOf)b.oneOf=t.oneOf.map(function(e,t){return v(e,o(o([],p,!0),["oneOf[".concat(t,"]")],!1))});else{if(t.items)if(t.items instanceof Array)b.items=t.items.map(function(e,t){return v(e,o(o([],p,!0),["items[".concat(t,"]")],!1))});else{var y=s(t.items,f);if(y)if(m.push(y),!0===g.skipFirstMutation&&y===f[0])b.items=c(t.items,!0,i(p),a(d));else{var E=h.find(function(e){var t=e[0];return y===t})[1];b.items=E}else b.items=e(t.items,c,l,u+1,f,d,o(o([],p,!0),["items"],!1),h,m)}if(t.additionalItems!==undefined&&(b.additionalItems=v(t.additionalItems,o(o([],p,!0),["additionalItems"],!1))),t.properties!==undefined){var _=t.properties,w={};Object.keys(t.properties).forEach(function(e){w[e]=v(_[e],o(o([],p,!0),["properties",e.toString()],!1))}),b.properties=w}if(t.patternProperties!==undefined){var S=t.patternProperties,M={};Object.keys(t.patternProperties).forEach(function(e){M[e]=v(S[e],o(o([],p,!0),["patternProperties",e.toString()],!1))}),b.patternProperties=M}t.additionalProperties!==undefined&&!0==!!t.additionalProperties&&(b.additionalProperties=v(t.additionalProperties,o(o([],p,!0),["additionalProperties"],!1)))}if(!0===g.skipFirstMutation&&0===u)return b;if(!0===g.bfs)return d.pop(),b;var T=-1!==m.indexOf(t);return d.pop(),c(b,T,i(p),a(d))}}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer>@json-schema-tools/traverse",file:"node_modules/@json-schema-tools/traverse/build/index.js"}],[95,{"../util":186},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.createPendingNonceMiddleware=function({getPendingNonce:e}){return async({request:t,context:r,next:n})=>{const{method:o,params:i}=t;if("eth_getTransactionCount"!==o)return n();const[s,a]=i;return"pending"!==a?n():await e(s,r.get("networkClientId"))}},r.createPendingTxMiddleware=function({getPendingTransactionByHash:e}){return async({request:t,next:r})=>{const{method:o,params:i}=t;if("eth_getTransactionByHash"!==o)return r();const[s]=i,a=e(s);return a?(0,n.formatTxMetaForRpcResult)(a):r()}};var n=e("../util")}}},{package:"$root$",file:"app/scripts/lib/middleware/pending.ts"}],[96,{"../../../../shared/lib/stores/persistence-manager":7577,"@metamask/utils":4105,events:5538,loglevel:5985},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=a(e("events")),o=a(e("loglevel")),i=e("@metamask/utils"),s=e("../../../../shared/lib/stores/persistence-manager");function a(e){return e&&e.__esModule?e:{default:e}}class c extends n.default{constructor(e={}){super();const t=e.migrations||[];this.migrations=t.sort((e,t)=>e.version-t.version);const r=this.migrations.slice(-1)[0];this.defaultVersion=e.defaultVersion||r&&r.version||0}async migrateData(e=this.generateInitialState()){const t=(0,i.isObject)(e.data)&&e.meta.version<186?new Set(Object.keys(e.data)):new Set;let r=e;for(const e of this.migrations)if(s(e))try{let n;if(o.default.info(`Running migration ${e.version}...`),e.version<186)n=await e.migrate(r),a(n,e);else{n=structuredClone(r);const i=new Set,s=await e.migrate(n,i);if(a(n,e),void 0!==s)throw new Error("Migrator - migration returned value when none expected");if(0===i.size)o.default.debug(`Migrator - migration ${e.version} did not report any changes`);else for(const e of i)t.add(e)}r=n,o.default.info(`Migration ${e.version} complete`)}catch(t){const r=new AggregateError([t],`MetaMask Migration Error #${e.version}`);this.emit("error",r);break}const n=e.meta.version<186&&(0,i.isObject)(r.data)?new Set(Object.keys(r.data)):new Set;for(const e of t)n.add(e);return{state:r,changedKeys:n};function s(e){return e.version>r.meta.version}function a(e,t){if(!e.data)throw new Error("Migrator - migration returned empty data");if(e.version!==undefined&&e.meta.version!==t.version)throw new Error("Migrator - Migration did not update version number correctly")}}generateInitialState(e){return{data:e,meta:{storageKind:s.PersistenceManager.defaultStorageKind,version:this.defaultVersion}}}}r.default=c}}},{package:"$root$",file:"app/scripts/lib/migrator/index.js"}],[98,{"../../../../shared/constants/metametrics":7408,"../../../../shared/lib/only-keep-host":7547,"../util":186,"./utils":99,"@metamask/utils":4105,loglevel:5985},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.onRpcEndpointDegraded=function({chainId:e,endpointUrl:t,error:r,infuraProjectId:n,metaMetricsId:o,retryReason:i,rpcMethodName:a,trackEvent:c,type:l}){u(s.MetaMetricsEventName.RpcServiceDegraded,{chainId:e,endpointUrl:t,error:r,infuraProjectId:n,metaMetricsId:o,retryReason:i,rpcMethodName:a,trackEvent:c,type:l})},r.onRpcEndpointUnavailable=function({chainId:e,endpointUrl:t,error:r,infuraProjectId:n,metaMetricsId:o,trackEvent:i}){u(s.MetaMetricsEventName.RpcServiceUnavailable,{chainId:e,endpointUrl:t,error:r,infuraProjectId:n,metaMetricsId:o,trackEvent:i})},r.trackRpcEndpointEvent=u;var n,o=(n=e("loglevel"))&&n.__esModule?n:{default:n},i=e("@metamask/utils"),s=e("../../../../shared/constants/metametrics"),a=e("../../../../shared/lib/only-keep-host"),c=e("../util"),l=e("./utils");function u(e,{chainId:t,endpointUrl:r,error:n,infuraProjectId:u,retryReason:f,rpcMethodName:d,trackEvent:p,type:h,metaMetricsId:m}){if(!(0,l.shouldCreateRpcServiceEvents)({error:n,metaMetricsId:m}))return;const g=(0,c.isPublicEndpointUrl)(r,u)?(0,a.onlyKeepHost)(r):"custom",b={chain_id_caip:`eip155:${(0,i.hexToNumber)(t)}`,rpc_domain:g,rpc_endpoint_url:g,...d?{rpc_method_name:d}:{},...h?{type:h}:{},...f?{retry_reason:f}:{},...(0,i.isObject)(n)&&"httpStatus"in n&&(0,i.isValidJson)(n.httpStatus)?{http_status:n.httpStatus}:{}};o.default.debug(`Creating Segment event "${e}" with ${JSON.stringify(b)}`),p({category:s.MetaMetricsEventCategory.Network,event:e,properties:b})}}}},{package:"$root$",file:"app/scripts/lib/network-controller/messenger-action-handlers.ts"}],[99,{"../../../../development/build/constants":664,"@metamask/network-controller":3042,"@metamask/remote-feature-flag-controller":3400},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.PRODUCTION_LIKE_ENVIRONMENTS=void 0,r.shouldCreateRpcServiceEvents=function({error:e,metaMetricsId:t}){return(!e||!(0,n.isConnectionError)(e))&&t!==undefined&&null!==t&&function(e){if("pull-request"===undefined)return!1;if(a.includes("pull-request"))return(0,o.generateDeterministicRandomNumber)(e)<s;return!0}(t)};var n=e("@metamask/network-controller"),o=e("@metamask/remote-feature-flag-controller"),i=e("../../../../development/build/constants");const s=.01,a=r.PRODUCTION_LIKE_ENVIRONMENTS=[i.ENVIRONMENT.PRODUCTION,i.ENVIRONMENT.RELEASE_CANDIDATE]}}},{package:"$root$",file:"app/scripts/lib/network-controller/utils.ts"}],[9,{"../../shared/constants/app":7390,"../../shared/constants/defi-referrals":7396,"../../shared/constants/errors":7397,"../../shared/constants/infura-project-id":7402,"../../shared/constants/messages":7407,"../../shared/constants/metametrics":7408,"../../shared/constants/offscreen-communication":7414,"../../shared/constants/onboarding":7415,"../../shared/constants/start-up-errors":7427,"../../shared/constants/ui-initialization":7435,"../../shared/lib/browser-runtime.utils":7454,"../../shared/lib/caip-stream":7456,"../../shared/lib/deep-links/utils":7491,"../../shared/lib/fetch-with-timeout":7522,"../../shared/lib/get-first-preferred-lang-code":7529,"../../shared/lib/manifestFlags":7534,"../../shared/lib/mv3.utils":7543,"../../shared/lib/object.utils":7546,"../../shared/lib/promise-with-resolvers":7550,"../../shared/lib/selectors/networks":7559,"../../shared/lib/sentry":7563,"../../shared/lib/stores/persistence-manager":7577,"./constants/marketing-site-whitelist":10,"./constants/sentry-state":11,"./constants/snaps":12,"./constants/stream":13,"./first-time-state":50,"./lib/CronjobControllerStorageManager":54,"./lib/createDefiReferralMiddleware":63,"./lib/deep-links/deep-link-router":79,"./lib/deep-links/metrics":80,"./lib/ens-ipfs/setup":86,"./lib/extension-lazy-listener/extension-lazy-listener":87,"./lib/getIframeProperties":89,"./lib/getObjStructure":90,"./lib/migrator":96,"./lib/notification-manager":100,"./lib/safe-reload":129,"./lib/setup-initial-state-hooks":133,"./lib/start-up-errors/start-up-errors":145,"./lib/state-corruption/state-corruption-recovery":146,"./lib/stream-utils":149,"./lib/update-remote-feature-flags":184,"./lib/use-split-state-storage":185,"./lib/util":186,"./metamask-controller":407,"./migrations":645,"./offscreen":646,"./on-update":647,"./platforms/extension":648,"@metamask/base-controller":1564,"@metamask/design-tokens":2161,"@metamask/utils":4105,"extension-port-stream":5543,loglevel:5985,"readable-stream":6479,"webextension-polyfill":7301},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.loadStateFromPersistence=qe,r.setupController=et;var n=e("./lib/setup-initial-state-hooks");e("../../shared/constants/infura-project-id");var o=e("@metamask/design-tokens"),i=e("readable-stream"),s=ie(e("loglevel")),a=ie(e("webextension-polyfill")),c=e("@metamask/utils"),l=e("@metamask/base-controller"),u=e("extension-port-stream"),f=e("../../shared/lib/promise-with-resolvers"),d=e("../../shared/constants/onboarding"),p=e("../../shared/constants/app"),h=e("../../shared/constants/messages"),m=e("../../shared/constants/ui-initialization"),g=e("../../shared/constants/metametrics"),b=e("../../shared/lib/browser-runtime.utils"),v=e("../../shared/lib/mv3.utils"),y=e("../../shared/lib/object.utils"),E=(e("../../shared/constants/offscreen-communication"),e("../../shared/lib/sentry")),_=e("../../shared/lib/selectors/networks"),w=e("../../shared/lib/caip-stream"),S=ie(e("../../shared/lib/fetch-with-timeout")),M=e("../../shared/constants/errors"),T=ie(e("../../shared/lib/get-first-preferred-lang-code")),O=(e("../../shared/lib/manifestFlags"),e("../../shared/constants/start-up-errors")),C=e("../../shared/constants/defi-referrals"),A=e("../../shared/lib/deep-links/utils"),N=e("../../shared/lib/stores/persistence-manager"),P=e("./lib/state-corruption/state-corruption-recovery"),I=e("./lib/use-split-state-storage"),k=ie(e("./migrations")),j=ie(e("./lib/migrator")),R=e("./lib/update-remote-feature-flags"),D=ie(e("./platforms/extension")),L=e("./constants/sentry-state"),x=oe(e("./lib/notification-manager")),U=oe(e("./metamask-controller")),$=ie(e("./lib/getObjStructure")),F=ie(e("./lib/ens-ipfs/setup")),V=e("./lib/util"),B=e("./offscreen"),K=e("./lib/stream-utils"),W=ie(e("./first-time-state")),z=e("./on-update"),J=e("./constants/marketing-site-whitelist"),G=e("./constants/stream"),H=e("./constants/snaps"),q=e("./lib/extension-lazy-listener/extension-lazy-listener"),Y=e("./lib/deep-links/deep-link-router"),X=e("./lib/deep-links/metrics"),Q=e("./lib/safe-reload"),Z=e("./lib/start-up-errors/start-up-errors"),ee=e("./lib/CronjobControllerStorageManager"),te=e("./lib/createDefiReferralMiddleware"),re=e("./lib/getIframeProperties");function ne(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(ne=function(e){return e?r:t})(e)}function oe(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=ne(t);if(r&&r.has(e))return r.get(e);var n={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&{}.hasOwnProperty.call(e,i)){var s=o?Object.getOwnPropertyDescriptor(e,i):null;s&&(s.get||s.set)?Object.defineProperty(n,i,s):n[i]=e[i]}return n.default=e,r&&r.set(e,n),n}function ie(e){return e&&e.__esModule?e:{default:e}}const se=globalThis.stateHooks.lazyListener??new q.ExtensionLazyListener(a.default),ae="#0376C9",ce=o.lightTheme.colors.error.default,le=9,{safePersist:ue,requestSafeReload:fe,evacuate:de}=(0,Q.getRequestSafeReload)(n.persistenceManager);global.stateHooks.getMostRecentPersistedState=()=>n.persistenceManager.mostRecentRetrievedState,global.stateHooks.getStorageKind=()=>n.persistenceManager.storageKind,global.logEncryptedVault=()=>{n.persistenceManager.logEncryptedVault()};const{sentry:pe}=global;let he={...W.default};const me={[p.ENVIRONMENT_TYPE_POPUP]:!0,[p.ENVIRONMENT_TYPE_NOTIFICATION]:!0,[p.ENVIRONMENT_TYPE_FULLSCREEN]:!0},ge=["trezor-connect"];s.default.setLevel("info",!1);const be=new D.default,ve=new x.default,ye=(0,V.getPlatform)()===p.PLATFORM_FIREFOX,Ee=ye?p.POPUP_FILE:p.POPUP_INIT_FILE;function _e(e){const t=e.name,r=e.sender?.url?new URL(e.sender.url):null;let n;return n=ye?Boolean(me[t]):r?.origin===`chrome-extension://${a.default.runtime.id}`,{processName:t,senderUrl:r,isMetaMaskUIPort:n}}let we=0,Se=!1,Me=!1,Te=0,Oe=0;const Ce={},Ae={};let Ne;const Pe={},Ie={},ke={};const je=new URL("https://metamask.github.io/phishing-warning/v5.1.0/"),Re=je.toString();let De,Le,xe;function Ue(){const e=(0,f.withResolvers)();De=e.promise,Le=e.resolve,xe=e.reject}se.once("runtime","onInstalled").then(e=>{!async function([e]){if("install"===e.reason)await async function(){s.default.debug("First install detected"),be.openExtensionInBrowser();await rt()}();else if("update"===e.reason){const{previousVersion:t}=e;if(!t||t===be.getVersion())return;await De,(0,z.onUpdate)(Ne,be,t,fe)}}(e)}),Ue(),a.default?.sidePanel?.setPanelBehavior&&a.default.sidePanel.setPanelBehavior({openPanelOnActionClick:!0}).catch(()=>{});let $e,Fe,Ve,Be;const Ke=new P.CorruptionHandler,We=async e=>{try{e.postMessage({data:{method:m.BACKGROUND_LIVENESS_METHOD},name:"background-liveness"})}catch(e){return void s.default.error("MetaMask - background-liveness check: Failed to message to port",e)}try{await De,$e(e)}catch(t){if(pe?.captureException(t),_e(e).isMetaMaskUIPort)if((0,M.isStateCorruptionError)(t))await Ke.handleStateCorruptionError({port:e,error:t,database:n.persistenceManager,repairCallback:async e=>{Ue(),(0,P.hasVault)(e)?(await nt(e),Ne.onboardingController.setFirstTimeFlowType(d.FirstTimeFlowType.restore)):(await n.persistenceManager.reset(),await nt(null))}});else{const r=(0,c.isObject)(t)?{message:t.message??"Unknown error",name:t.name??"UnknownError",stack:t.stack,...t.sentryTags&&{sentryTags:t.sentryTags}}:{message:String(t),name:"UnknownError",stack:""};(0,Z.tryPostMessage)(e,O.DISPLAY_GENERAL_STARTUP_ERROR,{error:r,currentLocale:Ne?.preferencesController?.state?.currentLocale})}}},ze=()=>{se.addListener("runtime","onConnect",We)};function Je(){const e=(new Date).toISOString();a.default.storage.session.set({timestamp:e})}async function Ge(e){(0,V.initInstallType)();const t=v.isManifestV3?(0,B.createOffscreen)():null;let r=null,o=!1;v.isManifestV3&&(0,B.addOffscreenConnectivityListener)(e=>{if(o&&Ne.messengerClientApi.setConnectivityStatus){const t=e?"online":"offline";Ne.messengerClientApi.setConnectivityStatus(t)}else r=e});const i=await qe(e),s=i.data,c=await(0,T.default)();let l;if(v.isManifestV3){if(!1!==s.PreferencesController?.enableMV3TimestampSave){const e=2e3;Je(),setInterval(Je,e)}const e=await a.default.storage.session.get(["isFirstMetaMaskControllerSetup"]);l=e?.isFirstMetaMaskControllerSetup===undefined,await a.default.storage.session.set({isFirstMetaMaskControllerSetup:l})}const u={},f=await async function(){const e=(0,S.default)(),t=H.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 ee.CronjobControllerStorageManager;if(await d.init(),et(s,c,u,l,i.meta,t,f,d),Ne.metaMetricsController.updateTraits({[g.MetaMetricsUserTrait.StorageKind]:n.persistenceManager.storageKind}),function(e){async function t(e,t){try{const r=await a.default.tabs.get(e);return!(r.url&&r.url.startsWith("https://www.google.com/search")||(await a.default.tabs.update(e,{url:t}),0))}catch(e){return pe?.captureException(e),!1}}const r=!v.isManifestV3;a.default.webRequest.onBeforeRequest.addListener(n=>{if(n.tabId===a.default.tabs.TAB_ID_NONE)return{};const{completedOnboarding:o}=e.onboardingController.state;if(!o)return{};if(!e.preferencesController.state.usePhishDetect)return{};if(n.initiator&&"null"!==n.initiator&&new URL(n.initiator).host===je.host)return{};const{hostname:i,href:s,searchParams:c}=new URL(n.url);e.phishingController.maybeUpdateState();const l=e.phishingController.isBlockedRequest(n.url);let u,f;if("main_frame"!==n.type&&"sub_frame"!==n.type||(u=e.phishingController.test(n.url)),!u?.result&&!l.result)return{};let d,p=s;u?.result&&l.result?f=`${u.type} and ${l.type}`:u?.result?f=u.type:(f=l.type,p=n.initiator);try{d=new URL(p).hostname}catch{d=i,p=s}const h=new URLSearchParams({hostname:d,href:p}),m=new URL(Re);m.hash=h.toString();const b=m.toString(),v=()=>{ye||e.metaMetricsController.trackEvent({event:g.MetaMetricsEventName.PhishingPageDisplayed,category:g.MetaMetricsEventCategory.Phishing,properties:{url:p,referrer:{url:p},reason:f,requestDomain:l.result?i:undefined}},{excludeMetaMetricsId:!0})};return r?"main_frame"===n.type?(v(),{redirectUrl:b}):(t(n.tabId,b).then(e=>{e&&v()}),{cancel:!0}):(t(n.tabId,b).then(e=>{e&&v()}),{})},{urls:["http://*/*","https://*/*","ws://*/*","wss://*/*"]},r?["blocking"]:[])}(Ne),v.isManifestV3){if(o=!0,null!==r){const e=r?"online":"offline";Ne.messengerClientApi.setConnectivityStatus(e)}}else{const e=e=>{const t=e?"online":"offline";Ne.messengerClientApi.setConnectivityStatus(t)};e(globalThis.navigator.onLine),globalThis.addEventListener("online",()=>e(!0)),globalThis.addEventListener("offline",()=>e(!1))}v.isManifestV3||await async function(){let e;try{const t=new URL(Re);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 o=new Promise((e,t)=>{r=e,n=t});e.addEventListener("load",r),window.document.body.appendChild(e),setTimeout(()=>n(new He),1e3),await o}catch(e){e instanceof He?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 a.default.tabs.query({url:"<all_urls>",windowType:"normal"}).then(e=>((0,b.checkForLastErrorAndLog)(),e)).catch(()=>{(0,b.checkForLastErrorAndLog)()});for(const t of e)a.default.tabs.sendMessage(t.id,{name:h.EXTENSION_MESSAGES.READY}).then(()=>{(0,b.checkForLastErrorAndLog)()}).catch(()=>{(0,b.checkForLastErrorAndLog)()})})(),new Y.DeepLinkRouter({getExtensionURL:be.getExtensionURL,getState:Ne.getState.bind(Ne)}).on("navigate",async({url:e,parsed:t})=>{"redirectTo"in t||await Ne.metaMetricsController.trackEvent((0,X.createEvent)({signature:t.signature,url:e}))}).on("error",e=>pe?.captureException(e)).install()}ze(),a.default.runtime.onConnectExternal.addListener(async(...e)=>{await De,Fe(...e)});class He extends Error{constructor(){super("Timeout failed")}}async function qe(e){let t;if(e){t={data:{},meta:{}};for(const r of N.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:k.default,defaultVersion:null});r.on("error",e=>{console.warn(e);const r=(0,$.default)(t);pe?.captureException(e,{extra:{vaultStructure:r}})});let o=!1;t?.data||t?.meta||(o=!0,t=r.generateInitialState(he));const{state:i,changedKeys:a}=await r.migrateData(t),l=async r=>{const o=t?.meta?.version,s="number"==typeof o&&o>=157;let a=e?.AppMetadataController?.firstTimeInfo??i?.data?.AppMetadataController?.firstTimeInfo??i?.data?.firstTimeInfo??t?.data?.AppMetadataController?.firstTimeInfo??t?.data?.firstTimeInfo;if(!a)try{const e=await n.persistenceManager.getBackup();a=e?.AppMetadataController?.firstTimeInfo}catch{}const c=new Error(r);return c.sentryTags={"corruption.preMigrationVersion":String(o??"unknown"),"corruption.backupShouldExist":String(s),"corruption.installVersion":String(a?.version??"unknown"),"corruption.installDate":String(a?.date??"unknown")},c};if(!i)throw await l("MetaMask - migrator returned undefined");if(!(0,c.isObject)(i.meta))throw await l(`MetaMask - migrator metadata has invalid type '${typeof i.meta}'`);if("number"!=typeof i.meta.version)throw await l(`MetaMask - migrator metadata version has invalid type '${typeof i.meta.version}'`);if(!["data","split",undefined].includes(i.meta.storageKind))throw await l(`MetaMask - migrator metadata storageKind has invalid value '${i.meta.storageKind}'`);if(!(0,c.isObject)(i.data))throw await l(`MetaMask - migrator data has invalid type '${typeof i.data}'`);if(n.persistenceManager.setMetadata(i.meta),s.default.debug("[Split State]: Loaded data from persistence with storageKind '%s'",n.persistenceManager.storageKind),"data"===n.persistenceManager.storageKind){const e=!0===i.meta.platformSplitStateGradualRolloutAttempted,t=!e&&await(0,I.useSplitStateStorage)(i.data);s.default.debug("[Split State]: shouldUseSplitStateStorage: %s (alreadyTried: %s)",t,e),t&&(i.meta.platformSplitStateGradualRolloutAttempted=!0,n.persistenceManager.setMetadata(i.meta)),s.default.debug("[Split State]: Writing data to persistence with storageKind 'data'"),await n.persistenceManager.set(i.data),t&&(await n.persistenceManager.migrateToSplitState(i.data),i.meta=n.persistenceManager.getMetaData(),i.meta!==undefined&&(delete i.meta.platformSplitStateGradualRolloutAttempted,n.persistenceManager.setMetadata(i.meta)),await n.persistenceManager.persist())}else{if("split"!==n.persistenceManager.storageKind)throw new Error(`MetaMask - persistenceManager has invalid storageKind '${n.persistenceManager.storageKind}'`);if(o)for(const[e,t]of Object.entries(i.data))n.persistenceManager.update(e,t);else for(const e of a)n.persistenceManager.update(e,i.data[e]);await n.persistenceManager.persist()}return s.default.debug("[Split State]: Load complete."),i}function Ye(e,t,r){const{metaMetricsId:n}=Ne.metaMetricsController.state;if(!(0,V.shouldEmitDappViewedEvent)(n))return;const o=Ne.getPermittedAccounts(e).length;if(0===o)return;const i=Ne.controllerMessenger.call("AccountsController:getState"),s=Object.keys(i.internalAccounts.accounts).length,a=(0,re.getIframeProperties)({frameId:r,origin:e,mainFrameOrigin:t});Ne.metaMetricsController.trackEvent({event:g.MetaMetricsEventName.DappViewed,category:g.MetaMetricsEventCategory.InpageProvider,referrer:{url:e},properties:{is_first_visit:!1,number_of_accounts:s,number_of_accounts_connected:o,...a}},{excludeMetaMetricsId:!0})}function Xe(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,o=new URL(e.sender.tab.url),{origin:i}=o,{frameId:s}=e.sender;Object.keys(Pe).includes(t)||(Pe[t]=n),t in Ie||(Ie[t]=i),t in ke||(ke[t]=s);const a=Ne.controllerMessenger.call("PermissionController:hasPermissions",n),c="New Tab"!==e.sender.tab.title;a&&c&&Ye(n,i,s)}function Qe(e){const t=[p.ENVIRONMENT_TYPE_POPUP,p.ENVIRONMENT_TYPE_NOTIFICATION,p.ENVIRONMENT_TYPE_FULLSCREEN,p.ENVIRONMENT_TYPE_SIDEPANEL];!(Object.values(Ce).some(Boolean)||Se||we>0||Te>0)&&t.includes(e)&&function(e){const{metaMetricsId:t,participateInMetaMetrics:r}=Ne.metaMetricsController.state;(null!==t||r)&&Ne.metaMetricsController.trackEvent({event:g.MetaMetricsEventName.AppOpened,category:g.MetaMetricsEventCategory.App,environmentType:e})}(e)}const Ze=async e=>{if(await De,Ne)try{const t=e?{active:!0,windowId:e}:{active:!0,currentWindow:!0},r=await a.default.tabs.query(t);if(!r||0===r.length)return;const n=r[0],{id:o,title:i,url:s,favIconUrl:c}=n;if(!s)return void Ne.appStateController.clearAppActiveTab();const{origin:l,protocol:u,host:f,href:d}=new URL(s);if(!(0,V.isWebOrigin)(l))return void Ne.appStateController.clearAppActiveTab();Ne.appStateController.setAppActiveTab({id:o,title:i,origin:l,protocol:u,url:s,host:f,href:d,favIconUrl:c}),Ne.subjectMetadataController.addSubjectMetadata({origin:l,name:i||f||l,iconUrl:c||null,subjectType:"website"})}catch(e){console.log("Error refreshing appActiveTab:",e.message)}};function et(e,t,r,o,c,f,d,h){Ne=new U.default({infuraProjectId:globalThis.INFURA_PROJECT_ID,showUserConfirmation:tt,initState:e,initLangCode:t,platform:be,notificationManager:ve,browser:a.default,getRequestAccountTabIds:()=>Ae,getOpenMetamaskTabsIds:()=>Ce,overrides:r,isFirstMetaMaskControllerSetup:o,currentMigrationVersion:c.version,featureFlags:{},offscreenPromise:f,preinstalledSnaps:d,requestSafeReload:fe,cronjobControllerStorageManager:h}),n.persistenceManager.setOnSetFailed(e=>{Ne.appStateController.setStorageWriteErrorType(e)});const m=[],b=Ne.store.getState();for(const t of Object.keys(b)){const r=e[t]||{},n=b[t];if(null===n||"object"!=typeof n){(0,E.captureException)(new Error(`Invalid controller state for '${t}' of type '${null===n?"null":typeof n}'`));continue}const o=Object.keys(n);if(o.length===Object.keys(r).length){for(const e of o)if(n[e]!==r[e]){m.push(t);break}}else m.push(t)}var S;"split"===n.persistenceManager.storageKind?(m.length>0&&(s.default.info(`MetaMaskController state changed during configuration for controllers: ${m.join(", ")}. Persisting updated state.`),m.forEach(e=>{n.persistenceManager.update(e,b[e])}),ue().catch(e=>{s.default.error("Error persisting updated state:",e),pe?.captureException(e)})),Ne.store.on("stateChange",async({controllerKey:e,newState:t,_oldState:r,_patches:o})=>{n.persistenceManager.update(e,t),N.backedUpStateKeys.includes(e)&&N.backedUpStateKeys.forEach(t=>{if(t===e)return;const r=Ne.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 o=Ne.controllerMessenger.call(`${t}:getState`),i=(0,l.deriveStateFromMetadata)(o,r.metadata,"persist");n.persistenceManager.update(t,i)});try{await ue()}catch(e){s.default.error("Error persisting state change:",e),pe?.captureException(e)}})):(m.length>0&&(s.default.info(`MetaMaskController state changed during configuration for controllers: ${m.join(", ")}. Persisting updated state.`),ue(b).catch(e=>{s.default.error("Error persisting updated controller state:",e),pe?.captureException(e)})),Ne.store.on("update",ue)),Ne.store.on("error",e=>{s.default.error("MetaMask controller.store error:",e),pe?.captureException(e)}),(0,F.default)({getCurrentChainId:()=>(0,_.getCurrentChainId)({metamask:Ne.networkController.state}),getIpfsGateway:Ne.preferencesController.getIpfsGateway.bind(Ne.preferencesController),getUseAddressBarEnsResolution:()=>Ne.preferencesController.state.useAddressBarEnsResolution,provider:Ne.provider}),S=Ne,global.stateHooks.getSentryAppState=function(){const e=S.memStore.getState();return(0,y.maskObject)(e,L.SENTRY_BACKGROUND_STATE)};const M=()=>we>0||Boolean(Object.keys(Ce).length)||Se||Te>0||!1,T=(e,t)=>{if(!1===e)Ne.onClientClosed();else{if(t===p.ENVIRONMENT_TYPE_FULLSCREEN&&Boolean(Object.keys(Ce).length)||t===p.ENVIRONMENT_TYPE_SIDEPANEL&&Te>0)return;Ne.onEnvironmentTypeClosed(t)}};function O(e){const t=e?`${Ee}?tab=${e}`:Ee,r=e?`${p.SIDEPANEL_FILE}?tab=${e}`:p.SIDEPANEL_FILE;try{v.isManifestV3?(a.default.action.setPopup({popup:t}),a.default.sidePanel?.setOptions?.({path:r})):a.default.browserAction.setPopup({popup:t})}catch(e){console.error("Error setting extension action URLs:",e)}}function C(){M()||(Oe+=1,O("activity"),I())}function A(){Oe&&(Oe=0,O(),I())}function P(e,t){return e>t?`${t}+`:String(e)}function I(){const e=k();let t="",r=ae;e?t=P(e,le):Oe&&(t=P(Oe,le),r=ce);try{const e={text:t},n={color:r};v.isManifestV3?(a.default.action.setBadgeText(e),a.default.action.setBadgeBackgroundColor(n)):(a.default.browserAction.setBadgeText(e),a.default.browserAction.setBadgeBackgroundColor(n))}catch(e){console.error("Error updating browser badge:",e)}}function k(){try{return Ne.appStateController.waitingForUnlock.length+Ne.approvalController.getTotalApprovalCount()}catch(e){return console.error("Failed to get pending approval count:",e),0}}$e=e=>{if(ge.includes(e.name))return;const{processName:t,senderUrl:n,isMetaMaskUIPort:o}=_e(e);if(o){const n=r?.getPortStream?.(e)||new u.ExtensionPortStream(e),o=function({chunkSize:e}){Ne.metaMetricsController.trackEvent({event:g.MetaMetricsEventName.PortStreamChunked,category:g.MetaMetricsEventCategory.PortStream,properties:{chunkSize:e}})};if(e.onDisconnect.addListener(()=>n.off("message-too-large",o)),n.on("message-too-large",o),Ne.isClientOpen=!0,Ne.setupTrustedCommunication(n,e.sender),Qe(t),(0,R.updateRemoteFeatureFlags)(Ne),t===p.ENVIRONMENT_TYPE_POPUP&&(A(),we+=1,(0,i.finished)(n,()=>{we-=1;const e=M();Ne.isClientOpen=e,T(e,p.ENVIRONMENT_TYPE_POPUP)})),t===p.ENVIRONMENT_TYPE_SIDEPANEL&&(A(),Te+=1,Ze(),(0,i.finished)(n,()=>{Te=Math.max(Te-1,0);const e=M();Ne.isClientOpen=e,T(e,p.ENVIRONMENT_TYPE_SIDEPANEL)})),t===p.ENVIRONMENT_TYPE_NOTIFICATION&&(Se=!0,(0,i.finished)(n,()=>{Se=!1;const e=M();Ne.isClientOpen=e,T(e,p.ENVIRONMENT_TYPE_NOTIFICATION)})),t===p.ENVIRONMENT_TYPE_FULLSCREEN){const t=e.sender.tab.id;Ce[t]=!0,(0,i.finished)(n,()=>{delete Ce[t];const e=M();Ne.isClientOpen=e,T(e,p.ENVIRONMENT_TYPE_FULLSCREEN)})}}else if(n&&n.origin===je.origin&&n.pathname===je.pathname){const t=r?.getPortStream?.(e)||new u.ExtensionPortStream(e,{chunkSize:0});Ne.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;Xe(e),e.onMessage.addListener(e=>{e.data&&e.data.method===p.MESSAGE_TYPE.ETH_REQUEST_ACCOUNTS&&(Ae[n]=t)})}if(n&&J.COOKIE_ID_MARKETING_WHITELIST_ORIGINS.some(e=>e===n.origin)){const t=r?.getPortStream?.(e)||new u.ExtensionPortStream(e,{chunkSize:0});Ne.setUpCookieHandlerCommunication({connectionStream:t})}const t=r?.getPortStream?.(e)||new u.ExtensionPortStream(e,{chunkSize:0});if(Ve(t,e.sender),ye||!v.isManifestV3){const r=(0,K.setupMultiplex)(t);r.ignoreStream(G.METAMASK_EIP_1193_PROVIDER),Be(r.createStream(G.METAMASK_CAIP_MULTICHAIN_PROVIDER),e.sender)}}},Fe=e=>{const t=r?.getPortStream?.(e)||new u.ExtensionPortStream(e,{chunkSize:0});if(!e.sender.id){if(ge.includes(e.name))return;Xe(e),Be((0,w.createCaipStream)(t),e.sender)}else Ve(t,e.sender)},Ve=(e,t)=>{Ne.setupUntrustedCommunicationEip1193({connectionStream:e,sender:t})},Be=(e,t)=>{Ne.setupUntrustedCommunicationCaip({connectionStream:e,sender:t})},r?.registerConnectListeners&&r.registerConnectListeners($e,Ve),I(),Ne.controllerMessenger.subscribe(U.METAMASK_CONTROLLER_EVENTS.DECRYPT_MESSAGE_MANAGER_UPDATE_BADGE,I),Ne.controllerMessenger.subscribe(U.METAMASK_CONTROLLER_EVENTS.ENCRYPTION_PUBLIC_KEY_MANAGER_UPDATE_BADGE,I),Ne.signatureController.hub.on(U.METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE,I),Ne.controllerMessenger.subscribe(U.METAMASK_CONTROLLER_EVENTS.APP_STATE_UNLOCK_CHANGE,I),Ne.controllerMessenger.subscribe(U.METAMASK_CONTROLLER_EVENTS.APPROVAL_STATE_CHANGE,I),Ne.controllerMessenger.subscribe(U.METAMASK_CONTROLLER_EVENTS.METAMASK_NOTIFICATIONS_LIST_UPDATED,I),Ne.controllerMessenger.subscribe(U.METAMASK_CONTROLLER_EVENTS.METAMASK_NOTIFICATIONS_MARK_AS_READ,I),Ne.controllerMessenger.subscribe("TransactionController:transactionFailed",C),Ne.controllerMessenger.subscribe("TransactionController:transactionDropped",C),ve.on(x.NOTIFICATION_MANAGER_EVENTS.POPUP_CLOSED,({automaticallyClosed:e})=>{e?k()>0&&tt():(Ne.signatureController.rejectUnapproved(g.REJECT_NOTIFICATION_CLOSE_SIG),Ne.decryptMessageController.rejectUnapproved(g.REJECT_NOTIFICATION_CLOSE),Ne.encryptionPublicKeyController.rejectUnapproved(g.REJECT_NOTIFICATION_CLOSE),Ne.rejectAllPendingApprovals()),I()})}async function tt(){const e=await be.getActiveTabs(),t=Boolean(e.find(e=>Ce[e.id])),r=e.length>0&&e[0].extData&&e[0].extData.indexOf("vivaldi_tab")>-1;if(!Me&&(r||0===we)&&!t&&0===Te){Me=!0;try{const e=Ne.appStateController.getCurrentPopupId();await ve.showPopup(e=>Ne.appStateController.setCurrentPopupId(e),e)}finally{Me=!1}}}const rt=async()=>{if(Ne){Ne.metaMetricsController.updateTraits({[g.MetaMetricsUserTrait.InstallDateExt]:(new Date).toISOString().split("T")[0]});const e=await(0,A.getDeferredDeepLinkFromCookie)(),t={};return e&&(Ne.appStateController.setDeferredDeepLink(e),t.install_source="deeplink",t.deeplink_path=e.referringLink),void Ne.metaMetricsController.addEventBeforeMetricsOptIn({category:g.MetaMetricsEventCategory.App,event:g.MetaMetricsEventName.AppInstalled,properties:t})}setTimeout(async()=>{await rt()},500)};a.default.runtime.onUpdateAvailable.addListener(async function(e){await De,s.default.info("An update is available",e?.version),Ne.appStateController.setPendingExtensionVersion(e?.version??null)});(async()=>{if(a.default?.sidePanel)try{await De,await async function(){if(!a.default?.sidePanel?.setPanelBehavior)return;const e=Ne?.preferencesController?.state?.preferences?.useSidePanelAsDefault??!0;await a.default.sidePanel.setPanelBehavior({openPanelOnActionClick:e})}(),Ne?.controllerMessenger?.subscribe("PreferencesController:stateChange",e=>{a.default?.sidePanel?.setPanelBehavior&&a.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 nt(e){a.default.tabs.onActivated.addListener(e=>{if(Ne){const{tabId:t}=e,r=Pe[t],n=Ie[t];r&&Ne.permissionController.state.subjects[r]!==undefined&&Ye(r,n,ke[t]);const o=(0,C.getPartnerByOrigin)(n);o&&Ne.permissionController.state.subjects[n]!==undefined&&Ne.handleDefiReferral(o,t,te.ReferralTriggerType.OnNavigateConnectedTab).catch(e=>{s.default.error(`Failed to handle ${o.name} referral after navigation to connected tab: `,e)})}});try{await Ge(e),n.persistenceManager.cleanUpMostRecentRetrievedState(),s.default.info("MetaMask initialization complete."),Le()}catch(e){s.default.error(e),xe(e)}}(async()=>{await Ze()})(),a.default.tabs.onActivated.addListener(async({tabId:e})=>{if(await De,!Ne)return{};try{const t=await a.default.tabs.get(e),{id:r,title:n,url:o,favIconUrl:i}=t;if(!o)return Ne.appStateController.clearAppActiveTab(),{};const{origin:s,protocol:c,host:l,href:u}=new URL(o);if(!(0,V.isWebOrigin)(s))return Ne.appStateController.clearAppActiveTab(),{};Ne.appStateController.setAppActiveTab({id:r,title:n,origin:s,protocol:c,url:o,host:l,href:u,favIconUrl:i}),Ne.subjectMetadataController.addSubjectMetadata({origin:s,name:n||l||s,iconUrl:i||null,subjectType:"website"})}catch(e){console.log("Error in tabs.onActivated listener:",e.message)}return{}}),a.default.tabs.onUpdated.addListener(async(e,t,r)=>{if(await De,!Ne)return{};const n=t.url!==undefined,o="complete"===t.status;if(!n&&!o)return{};try{const t=r||await a.default.tabs.get(e),{id:i,title:s,url:c,favIconUrl:l}=t,u=Ne.appStateController.state.appActiveTab,f=u?.id===i;if(!c)return f&&Ne.appStateController.clearAppActiveTab(),{};const{origin:d,protocol:p,host:h,href:m}=new URL(c);if(!d||"null"===d||d.startsWith("chrome-extension://")||d.startsWith("moz-extension://"))return f&&Ne.appStateController.clearAppActiveTab(),{};let g=!1;try{g=(await a.default.tabs.query({active:!0,currentWindow:!0})).some(e=>e.id===i)}catch(e){g=f}(n||o)&&g&&(Ne.appStateController.setAppActiveTab({id:i,title:s,origin:d,protocol:p,url:c,host:h,href:m,favIconUrl:l}),Ne.subjectMetadataController.addSubjectMetadata({origin:d,name:s||h||d,iconUrl:l||null,subjectType:"website"}))}catch(e){console.log("Error in tabs.onUpdated listener:",e.message)}return{}}),a.default.windows.onFocusChanged.addListener(async e=>{e!==a.default.windows.WINDOW_ID_NONE&&await Ze(e)}),nt(null)}}},{package:"$root$",file:"app/scripts/background.js"}]],[9],{});