(globalThis.webpackChunk=globalThis.webpackChunk||[]).push([[8851],{241912(__unused_webpack_module,__unused_webpack___webpack_exports__,__webpack_require__){(function(){if(!this.ST)return()=>{};with(this.ST)with(this.RH)with(this.G)return function(){"use strict";var e=__webpack_require__(494708);__webpack_require__.n(e),__webpack_require__(61625),__webpack_require__(692796),__webpack_require__(254629);var t=__webpack_require__(38588);__webpack_require__.n(t);var r=__webpack_require__(413279);var n=__webpack_require__.n(r);var a=__webpack_require__(78279);var i=__webpack_require__(129385);var o=__webpack_require__(171097);var s=__webpack_require__.n(o);var l=__webpack_require__(48050);__webpack_require__.n(l);var c=__webpack_require__(46754);var u=__webpack_require__(796213);var m=__webpack_require__(650710);__webpack_require__.n(m);var p=__webpack_require__(299150);var d=__webpack_require__(163305);var g=__webpack_require__(574618);var h=__webpack_require__(627009);var w=__webpack_require__(367149);var v=__webpack_require__(809654);let f=1*1e3;let b="phishing-warning-sw-registered";let S=document.getElementById("app-content");class y extends Error{constructor(){super("Timeout failed")}}async function T(){if((await n().storage.session.get(b))[b])return;let e=(0,w.uo)();let t;try{let r=new URL("https://metamask.github.io/phishing-warning/v5.1.0/");r.hash="#extensionStartup",(t=window.document.createElement("iframe")).setAttribute("src",r.href),t.setAttribute("sandbox","allow-scripts allow-same-origin");let a;let i;let o=new Promise((e,t)=>{a=e,i=t});t.addEventListener("load",a),window.document.body.appendChild(t),setTimeout(()=>i(new y),f),await o,e===u.Yb?console.error("Firefox does not support required MV3 APIs: Phishing warning page iframe and service worker will reload each page refresh"):n().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()}}async function k(e,t,r,n,a){try{let i=await (0,c.b1)({activeTab:e,container:S,patchSubstream:t,traceContext:n,initialState:a});(0,d.t7)({name:d.dg.UIStartup});let{metamask:{completedOnboarding:o}={}}=i.getState();!o&&r!==u.t8&&globalThis.platform.openExtensionInBrowser()}catch(e){await (0,c.vJ)(S,c._2.TroubleStarting,e)}}async function x(e){if(!1,e!==u.YY&&e!==u.x$)return{};let[t]=await n().tabs.query({active:!0,currentWindow:!0}).catch(e=>{(0,p.L3)()||s().error(e)});let{id:r,title:a,url:i}=t;let{origin:o,protocol:l}=i?new URL(i):{};return!o||o==="null"?{}:(0,{id:r,title:a,origin:o,protocol:l,url:i})}function P(e){let t=(0,h.Q)(e);let r=t.createStream("controller");let n=t.createStream("provider");let a=t.createStream("patch-store");return t.ignoreStream("background-liveness"),t.ignoreStream("app-init-liveness"),{controller:r,provider:n,patch:a}}async function L(e){let t=new a.K(e,{rpcMiddleware:[(0,i.$)()]});e.on("error",console.error.bind(console)),t.on("error",console.error.bind(console)),await t.initialize(),globalThis.ethereumProvider=t}(async function e(){let e=performance.now();let t=(0,d.uP)({name:d.dg.UIStartup,startTime:performance.timeOrigin});(0,d.uP)({name:d.dg.LoadScripts,startTime:performance.timeOrigin,parentContext:t}),(0,d.t7)({name:d.dg.LoadScripts,timestamp:performance.timeOrigin+e}),globalThis.platform=new g.A;let r=(0,w.mc)();let a=n().runtime.connect({name:r});let i=new c.ZL(a,S);i.install();let o=P(new l.ExtensionPortStream(a));let s=(0,v.Ay)(o.controller);async function u(e){(0,d.t7)({name:d.dg.BackgroundConnect}),i.startUiSyncReceived(),i.uninstall(),await L(o.provider);let n=await x(r);await k(n,o.patch,r,t,e),m.isManifestV3&&await T()}(0,c.or)(s,u),(0,c.hz)(o.patch),(0,d.uP)({name:d.dg.BackgroundConnect,parentContext:t})})().catch(s().error)}}).call(__webpack_require__._LM_("$root$",{__webpack_require__}))()}}]);