(globalThis.webpackChunk=globalThis.webpackChunk||[]).push([[285],{46754(__unused_webpack_module,__webpack_exports__,__webpack_require__){(function(){if(!this.ST)return()=>{};with(this.ST)with(this.RH)with(this.G)return function(){"use strict";__webpack_require__.d(__webpack_exports__,{ZL:()=>F.Z,_2:()=>J._2,b1:()=>R,or:()=>K,vJ:()=>J.vJ});var t=__webpack_require__(171097);var e=__webpack_require__.n(t);var a=__webpack_require__(860012);var r=__webpack_require__(9610);var n=__webpack_require__(413279);var o=__webpack_require__.n(n);var s=__webpack_require__(296639);var i=__webpack_require__(480021);var l=__webpack_require__(655204);var c=__webpack_require__(764130);var u=__webpack_require__(490335);var w=__webpack_require__(441670);var d=__webpack_require__(630496);var g=__webpack_require__(537324);var v=__webpack_require__(796213);var p=__webpack_require__(299150);var m=__webpack_require__(721127);var f=__webpack_require__(55638);var h=__webpack_require__(802870);var k=__webpack_require__(163305);var S=__webpack_require__(657218);var y=__webpack_require__(177540);var E=__webpack_require__(365337);var T=__webpack_require__(936007);var b=__webpack_require__(79222);var A=__webpack_require__(302764);var M=__webpack_require__(667855);var H=__webpack_require__(354779);var C=__webpack_require__(83432);var L=__webpack_require__(212814);var P=__webpack_require__(438174);var O=__webpack_require__(90260);var _=__webpack_require__(609654);var B=__webpack_require__(885830);var D=__webpack_require__(597436);var I=__webpack_require__(321505);var N=__webpack_require__(345791);var x=__webpack_require__(947266);var F=__webpack_require__(760264);var J=__webpack_require__(259016);e().setLevel(globalThis.METAMASK_DEBUG?"debug":"warn",!1);let U=new WeakMap;function Y(t,e){let a=U.get(e);!a&&(a=(0,r.H)(e),U.set(e,a)),a.render(t)}let $=(0,l.Y)();let K=(t,e)=>{(0,_.R3)(t),t.onNotification(async t=>{let{method:a}=t;if(a==="sendUpdate")(await $.promise).dispatch(b.M_O(t.params[0]));else if(a===m.c9)await e(t.params[0]);else if(a==="perpsStreamUpdate")(0,N.SB)().handleBackgroundUpdate(t.params[0]);else if(a!==y.g)throw new Error(`Internal JSON-RPC Notification Not Handled:

 ${JSON.stringify(t)}`)})};async function R(t){let{backgroundConnection:e,initialState:a}=t;let r=await j(a,t);return await e.startSendingPatches(),z(r),r}async function Z(t,e){!t.featureFlags&&(t.featureFlags={});let{currentLocaleMessages:a,enLocaleMessages:r}=await (0,h.UN)(t.currentLocale);t.textDirection==="rtl"&&(0,f.s)("rtl");let n={activeTab:e,metamask:t,appState:{},localeMessages:{currentLocale:t.currentLocale,current:a,en:r}};if((0,c.mc)()===v.YY||(0,c.mc)()===v.x$){let{origin:t}=n.activeTab;let e=(0,M.B4u)(n);let a=(0,E._)(n);let r=a&&(0,s.vI)(a,e);let o=(0,C.pm)(n);let i=(0,C.mD)(n);t&&i&&!o[t]&&e.length>0&&!r&&(n[u._1.unconnectedAccount]={state:H.nK.OPEN},b.dij(t))}let o=(0,A.Ay)(n);$.resolve(o);let i=(0,M.EcM)(t);let l=(0,O.A)(i,t.unapprovedPersonalMsgs,t.unapprovedDecryptMsgs,t.unapprovedEncryptionPublicKeyMsgs,t.unapprovedTypedMessages,t.networkId,(0,S.gr)({metamask:t}));return l.length>0&&o.dispatch(b.Z23({id:l[0].id})),o}async function j(t,e){let{traceContext:r}=e;(0,I.KO)();let n=(0,B.M)({metamask:t});let o=await (0,k.uP)({name:k.dg.SetupStore,parentContext:r,tags:n},()=>Z(t,e.activeTab));globalThis.metamask={updateCurrentLocale:t=>{o.dispatch(b.DAg(t))},setFeatureFlag:(t,e)=>{o.dispatch(b.B4g(t,e))}},await (0,k.uP)({name:k.dg.InitialActions,parentContext:r},()=>G(o));let s=(0,x._)();return(0,k.uP)({name:k.dg.FirstRender,parentContext:r},()=>Y(a.createElement(P.A,{store:o,uiMessenger:s}),e.container)),o}async function G(t){let a=t.getState();try{let r=(0,p.Y0)().toLowerCase();let{os:n}=a.metamask.browserEnvironment||{};n&&r&&t.dispatch(b.OdJ(n,r)).catch(t=>{e().error("Failed to update browser environment:",t)})}catch(t){e().error("Failed to get browser name:",t)}let r=(0,M.UyX)(a);if(r&&await t.dispatch(b.o$f(r)),(0,c.mc)()===v.YY){let e=Date.now();globalThis.metamask.id=e,await t.dispatch(b.AJb(e))}try{let e=async e=>{(0,L.QA)(e)&&await t.dispatch(b.s8B(!1,!1))};await e(a);let r=setInterval(()=>{let a=t.getState();let n=(0,M.SPM)(a);let o=(0,M.nT$)(a);if(n!==null&&!o){clearInterval(r);return}e(a)},D.a)}catch(t){e().error("[Metamask] checkIsSeedlessPasswordOutdated error",t)}}async function W(t){let e={...t.getState()};return e.version=globalThis.platform.getVersion(),e.browser=window.navigator.userAgent,e.metamask=(0,g.ao)({...e.metamask,socialLoginEmail:undefined}),e}function z(t){!0&&(window.stateHooks.throwTestError=async function(t="Test Error"){let e=new Error(t);throw e.name="TestError",e},window.stateHooks.captureTestError=async function(t="Test Error"){let e=new Error(t);e.name="TestError",(0,i.Cp)(e)},window.stateHooks.throwTestBackgroundError=async function(t="Test Error"){await b.LWm(t)},window.stateHooks.captureBackgroundError=async function(t="Test Error"){await b.PDE(t)}),window.stateHooks.reloadExtension=()=>{o().runtime.reload()},window.stateHooks.getCleanAppState=async function(){return W(t)},window.stateHooks.getSentryAppState=function(){let e=t.getState();return(0,w.c)({...e,metamask:(0,g.ao)(e.metamask)},d.z)},window.stateHooks.getLogs=function(){let{logs:e}=t.getState().metamask;return Object.values(e).sort((t,e)=>{return t.timestamp-e.timestamp})},(0,T.De)(!0?1:0),!0&&(0,T.Kf)(),!0&&(window.stateHooks.hasConsoleAccess=()=>__webpack_require__(948342).w())}window.logStateString=async function(){let t=await window.stateHooks.getCleanAppState();return t.logs=window.stateHooks.getLogs(),t.platform=await o().runtime.getPlatformInfo(),JSON.stringify(t,null,2)},window.logState=async function(t){try{let e=await window.logStateString();t?(await navigator.clipboard.writeText(e),console.log("State log copied")):console.log(e)}catch(t){console.error(t.message)}}}}).call(__webpack_require__._LM_("$root$",{__webpack_require__,__webpack_exports__}))()}}]);