LavaPack.loadBundle([[688,{"../../shared/constants/app":8559,"../../shared/constants/infura-project-id":8575,"../../shared/lib/browser-runtime.utils":8638,"../../shared/lib/mv3.utils":8726,"../../shared/lib/trace":8778,"../../ui":10324,"./development/wdyr":54,"./lib/metaRPCClientFactory":102,"./lib/setup-initial-state-hooks":142,"./lib/stream-utils":159,"./lib/util":198,"./platforms/extension":673,"@lavamoat/lavadome-react":1024,"@metamask/json-rpc-engine":2878,"@metamask/providers":3541,"extension-port-stream":6643,loglevel:7254,"react-devtools-core":6324,"webextension-polyfill":8546},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");!function(e,t){if("function"==typeof WeakMap)var r=new WeakMap,n=new WeakMap;(function(e,t){if(!t&&e&&e.__esModule)return e;var a,o,i={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return i;if(a=t?n:r){if(a.has(e))return a.get(e);a.set(e,i)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((o=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(o.get||o.set)?a(i,t,o):i[t]=e[t])})(e,t)}(e("react-devtools-core"));var n=h(e("webextension-polyfill")),a=e("@metamask/providers"),o=e("@metamask/json-rpc-engine"),i=h(e("loglevel")),s=e("extension-port-stream"),c=e("../../ui"),l=e("../../shared/constants/app"),u=e("../../shared/lib/mv3.utils"),d=e("../../shared/lib/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}}const b="phishing-warning-sw-registered",v=document.getElementById("app-content");class y 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=n.default.runtime.connect({name:r}),T=new c.CriticalStartupErrorHandler(h,v);T.install();const E=function(e){const t=(0,f.setupMultiplex)(e),r=t.createStream("controller"),n=t.createStream("provider");return t.ignoreStream("background-liveness"),t.ignoreStream("app-init-liveness"),{controller:r,provider:n}}(new s.ExtensionPortStream(h)),k=(0,w.default)(E.controller);(0,c.connectToBackground)(k,async function(e){(0,m.endTrace)({name:m.TraceName.BackgroundConnect}),T.startUiSyncReceived(),T.uninstall(),await async function(e){const t=new a.StreamProvider(e,{rpcMiddleware:[(0,o.createIdRemapMiddleware)()]});e.on("error",console.error.bind(console)),t.on("error",console.error.bind(console)),await t.initialize(),global.ethereumProvider=t}(E.provider);const s=await async function(e){if(e!==l.ENVIRONMENT_TYPE_POPUP&&e!==l.ENVIRONMENT_TYPE_SIDEPANEL)return{};const t=await n.default.tabs.query({active:!0,currentWindow:!0}).catch(e=>{(0,d.checkForLastErrorAndLog)()||i.default.error(e)}),[r]=t,{id:a,title:o,url:s}=r,{origin:c,protocol:u}=s?new URL(s):{};return c&&"null"!==c?{id:a,title:o,origin:c,protocol:u,url:s}:{}}(r);await async function(e,t,r,n,a){try{const o=await(0,c.launchMetamaskUi)({activeTab:e,container:v,backgroundConnection:t,traceContext:n,initialState:a});(0,m.endTrace)({name:m.TraceName.UIStartup});const i=o.getState(),{metamask:{completedOnboarding:s}={}}=i;s||r===l.ENVIRONMENT_TYPE_FULLSCREEN||global.platform.openExtensionInBrowser()}catch(e){await(0,c.displayCriticalErrorMessage)(v,c.CriticalErrorTranslationKey.TroubleStarting,e,undefined)}}(s,k,r,t,e),u.isManifestV3&&await async function(){if((await n.default.storage.session.get(b))[b])return;const e=(0,g.getPlatform)();let t;try{const r=new URL("https://metamask.github.io/phishing-warning/v5.1.0/");let a,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)=>{a=e,o=t});t.addEventListener("load",a),window.document.body.appendChild(t),setTimeout(()=>o(new y),1e3),await i,e===l.PLATFORM_FIREFOX?console.error("Firefox does not support required MV3 APIs: Phishing warning page iframe and service worker will reload each page refresh"):n.default.storage.session.set({[b]:!0})}catch(e){e instanceof y?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(i.default.error)}}},{package:"$root$",file:"app/scripts/ui.js"}]],[688],{});