LavaPack.loadBundle([[507,{"../../development/wdyr":510,"../../shared/constants/app":5463,"../../shared/constants/infura-project-id":5473,"../../shared/lib/trace":5563,"../../shared/modules/browser-runtime.utils":5572,"../../shared/modules/mv3.utils":5584,"../../ui":6865,"./lib/metaRPCClientFactory":210,"./lib/setup-initial-state-hooks":247,"./lib/stream-utils":264,"./lib/util":284,"./platforms/extension":496,"@lavamoat/lavadome-react":781,"@metamask/json-rpc-engine":1971,"@metamask/providers":2392,"extension-port-stream":4124,loglevel:4589,"react-devtools-core":3804,"webextension-polyfill":5446},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){e("@lavamoat/lavadome-react"),e("./lib/setup-initial-state-hooks"),e("../../development/wdyr"),e("../../shared/constants/infura-project-id");v(e("react-devtools-core"));var n=h(e("extension-port-stream")),a=h(e("webextension-polyfill")),o=e("@metamask/providers"),i=e("@metamask/json-rpc-engine"),s=h(e("loglevel")),l=v(e("../../ui")),c=e("../../shared/constants/app"),u=e("../../shared/modules/mv3.utils"),d=e("../../shared/modules/browser-runtime.utils"),m=e("../../shared/lib/trace"),p=h(e("./platforms/extension")),f=e("./lib/stream-utils"),g=e("./lib/util"),w=h(e("./lib/metaRPCClientFactory"));function h(e){return e&&e.__esModule?e:{default:e}}function b(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(b=function(e){return e?r:t})(e)}function v(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=b(t);if(r&&r.has(e))return r.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&{}.hasOwnProperty.call(e,o)){var i=a?Object.getOwnPropertyDescriptor(e,o):null;i&&(i.get||i.set)?Object.defineProperty(n,o,i):n[o]=e[o]}return n.default=e,r&&r.set(e,n),n}const y="phishing-warning-sw-registered",T=document.getElementById("app-content");class k extends Error{constructor(){super("Timeout failed")}}(async function(){const e=performance.now(),t=(0,m.trace)({name:m.TraceName.UIStartup,startTime:performance.timeOrigin});(0,m.trace)({name:m.TraceName.LoadScripts,startTime:performance.timeOrigin,parentContext:t}),(0,m.endTrace)({name:m.TraceName.LoadScripts,timestamp:performance.timeOrigin+e}),global.platform=new p.default;const r=(0,g.getEnvironmentType)(),h=a.default.runtime.connect({name:r}),b=new l.CriticalStartupErrorHandler(h,T);b.install();const v=function(e){const t=(0,f.setupMultiplex)(e),r=t.createStream("controller"),n=t.createStream("provider");return t.ignoreStream("background-liveness"),{controller:r,provider:n}}(new n.default(h)),P=(0,w.default)(v.controller);(0,l.connectToBackground)(P,async function(){(0,m.endTrace)({name:m.TraceName.BackgroundConnect}),b.uninstall(),await async function(e){const t=new o.StreamProvider(e,{rpcMiddleware:[(0,i.createIdRemapMiddleware)()]});e.on("error",console.error.bind(console)),t.on("error",console.error.bind(console)),await t.initialize(),global.ethereumProvider=t}(v.provider);const e=await async function(e){if(e!==c.ENVIRONMENT_TYPE_POPUP)return{};const t=await a.default.tabs.query({active:!0,currentWindow:!0}).catch(e=>{(0,d.checkForLastErrorAndLog)()||s.default.error(e)}),[r]=t,{id:n,title:o,url:i}=r,{origin:l,protocol:u}=i?new URL(i):{};return l&&"null"!==l?{id:n,title:o,origin:l,protocol:u,url:i}:{}}(r);await async function(e,t,r,n){try{const a=await async function(e,t,r){return await(0,l.default)({activeTab:e,container:T,backgroundConnection:t,traceContext:r})}(e,t,n);(0,m.endTrace)({name:m.TraceName.UIStartup});const o=a.getState(),{metamask:{completedOnboarding:i}={}}=o;i||r===c.ENVIRONMENT_TYPE_FULLSCREEN||global.platform.openExtensionInBrowser()}catch(e){await(0,l.displayCriticalError)(T,l.CriticalErrorTranslationKey.TroubleStarting,e)}}(e,P,r,t),u.isManifestV3&&await async function(){if((await a.default.storage.session.get(y))[y])return;const e=(0,g.getPlatform)();let t;try{const r=new URL("https://metamask.github.io/phishing-warning/v5.0.1/");let n,o;r.hash="#extensionStartup",t=window.document.createElement("iframe"),t.setAttribute("src",r.href),t.setAttribute("sandbox","allow-scripts allow-same-origin");const i=new Promise((e,t)=>{n=e,o=t});t.addEventListener("load",n),window.document.body.appendChild(t),setTimeout(()=>o(new k),1e3),await i,e===c.PLATFORM_FIREFOX?console.error("Firefox does not support required MV3 APIs: Phishing warning page iframe and service worker will reload each page refresh"):a.default.storage.session.set({[y]:!0})}catch(e){e instanceof k?console.warn("Phishing warning page timeout; page not guaranteed to work offline."):console.error("Failed to initialize phishing warning page",e)}finally{t&&t.remove()}}()}),(0,m.trace)({name:m.TraceName.BackgroundConnect,parentContext:t})})().catch(s.default.error)}}},{package:"$root$",file:"app/scripts/ui.js"}]],[507],{});