@dcl/explore-site 0.0.1-24138829632.commit-0946e16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/HomePage-CbNrtXMa.js +3 -0
- package/assets/QueryClientProvider-DUSjZ_J_.js +2 -0
- package/assets/RoobertPRO-Bold-DDyOqNrI.woff2 +0 -0
- package/assets/RoobertPRO-Bold-zQ2qeH97.ttf +0 -0
- package/assets/SensorsRounded-Ci-z6t1A.js +15 -0
- package/assets/___vite-browser-external_commonjs-proxy-BqV5D26a.js +1 -0
- package/assets/__federation_expose_App-BckrSixU.js +1 -0
- package/assets/__federation_fn_import-WDa0gv1I.js +1 -0
- package/assets/__federation_shared_@dcl/hooks-BmGk-LAU.js +535 -0
- package/assets/__federation_shared_@dcl/schemas-FcJQcJ28.js +1 -0
- package/assets/__federation_shared_@emotion/react-oi_M7gMJ.js +1 -0
- package/assets/__federation_shared_@emotion/styled-YrTPT9q1.js +1 -0
- package/assets/__federation_shared_@reduxjs/toolkit-R1Ell7gI.js +1 -0
- package/assets/__federation_shared_decentraland-ui2-D5N7yacO.js +357 -0
- package/assets/__federation_shared_react-B3tlNTLg.js +1 -0
- package/assets/__federation_shared_react-dom-Dsn5WX9N.js +1 -0
- package/assets/__federation_shared_react-redux-DMak3BVq.js +13 -0
- package/assets/__federation_shared_react-router-dom-CSW28ZSI.js +49 -0
- package/assets/__federation_shared_viem-DsDw7lUr.js +2 -0
- package/assets/__federation_shared_wagmi-h3zhLZbR.js +17 -0
- package/assets/__vite-optional-peer-dep_lottie-react_decentraland-ui2-BIHI7g3E.js +1 -0
- package/assets/_commonjsHelpers-C4iS2aBk.js +1 -0
- package/assets/add-Ccyt7YRh.js +15 -0
- package/assets/all-wallets-BIOtzF11.js +6 -0
- package/assets/app-store-BqACXnTM.js +17 -0
- package/assets/apple-zIEkvR7h.js +18 -0
- package/assets/arrow-bottom-CxQ54WH1.js +8 -0
- package/assets/arrow-bottom-circle-BjCA11Rn.js +11 -0
- package/assets/arrow-left-CsFQBdFD.js +8 -0
- package/assets/arrow-right-jT5LSgqq.js +8 -0
- package/assets/arrow-top-CA_1oaHw.js +8 -0
- package/assets/auto-track-UOggKKzv.js +1 -0
- package/assets/bank-81NjtLlm.js +14 -0
- package/assets/basic-CvR9b359.js +2128 -0
- package/assets/brotli_wasm_bg-NfWIZley.wasm +0 -0
- package/assets/browser-BjIqaPVu.js +14 -0
- package/assets/card-BJomEEgV.js +14 -0
- package/assets/ccip-DotuofV0.js +1 -0
- package/assets/checkmark-Cz0VZAkr.js +11 -0
- package/assets/checkmark-bold-blkVLUov.js +8 -0
- package/assets/chevron-bottom-ClawczSo.js +8 -0
- package/assets/chevron-left-DfJ9r4mv.js +8 -0
- package/assets/chevron-right-CrxmyW0K.js +8 -0
- package/assets/chevron-top-BVIfb-H3.js +8 -0
- package/assets/chrome-store-Cb5xVI0B.js +61 -0
- package/assets/clock-Bx-Kyhh-.js +8 -0
- package/assets/close-DOjpWTZi.js +8 -0
- package/assets/coinPlaceholder-BqONZM6Q.js +8 -0
- package/assets/compass-ByyIpxD6.js +8 -0
- package/assets/copy-BOu2-Xgv.js +15 -0
- package/assets/core-BGxUaCGc.js +907 -0
- package/assets/create-submenu-Bu20F8-Z.webp +0 -0
- package/assets/createClient-CSnZgvsb.js +1 -0
- package/assets/cursor-BqYz2L6D.js +3 -0
- package/assets/cursor-transparent-CWCRGDtx.js +12 -0
- package/assets/custom-welcome-background-BxlFQma9.webp +0 -0
- package/assets/defineChain-7I0Ce1VT.js +1 -0
- package/assets/desktop-Cd_vx0kT.js +9 -0
- package/assets/disconnect-D5AICJhj.js +8 -0
- package/assets/discord-26Vqbq7c.js +17 -0
- package/assets/emotion-react.browser.esm-5OnyV0Sh.js +8 -0
- package/assets/emotion-use-insertion-effect-with-fallbacks.browser.esm-B75LdcJS.js +1 -0
- package/assets/etherscan--DKVcYrP.js +6 -0
- package/assets/exclamation-triangle-DOsYf3fQ.js +4 -0
- package/assets/explore-submenu-BFVuYMi9.webp +0 -0
- package/assets/extension-DEaO3Zvk.js +8 -0
- package/assets/external-link-DcpG6wpM.js +8 -0
- package/assets/facebook-ByV0OclL.js +26 -0
- package/assets/farcaster-DI6fsEyh.js +12 -0
- package/assets/filters-Djn1aDVs.js +8 -0
- package/assets/github-B3p0LLP5.js +18 -0
- package/assets/google-ae7qga4R.js +18 -0
- package/assets/governance-submenu-VTIKvCIL.webp +0 -0
- package/assets/help-circle-BmzUA_Be.js +12 -0
- package/assets/hooks.module-Dz_XB4AG.js +1 -0
- package/assets/id-2hYEZqNH.js +12 -0
- package/assets/image-mDqi4ffo.js +4 -0
- package/assets/index-9zCVakoE.js +1 -0
- package/assets/index-BKLT1eit.js +2 -0
- package/assets/index-Biwg5bHN.js +1 -0
- package/assets/index-BzXoRVC1.js +1 -0
- package/assets/index-C05H8NDX.js +1 -0
- package/assets/index-CGCGB-at.js +1 -0
- package/assets/index-CNMKbeE1.js +5 -0
- package/assets/index-CVdhIPEJ.js +1 -0
- package/assets/index-CdOcIHYV.js +395 -0
- package/assets/index-CdrMQoR6.js +1 -0
- package/assets/index-Ctl4brHr.js +2 -0
- package/assets/index-D6O4pjzC.js +12 -0
- package/assets/index-D6ZMQedT.js +1 -0
- package/assets/index-DGVKdsht.js +1 -0
- package/assets/index-D_fJMF1A.js +1 -0
- package/assets/index-Dy0yjznp.js +1 -0
- package/assets/index-Dy0yjznp__bundled.js +9 -0
- package/assets/index-JFBsW0Hp.js +1 -0
- package/assets/index-OQ3TYt4p.js +7 -0
- package/assets/index-VfkM29PH.js +1 -0
- package/assets/index-VfkM29PH__bundled.js +24 -0
- package/assets/index-nibyPLVP.js +1 -0
- package/assets/index-pEp_vRda.js +8 -0
- package/assets/index.es-D_4_VpXc.js +38 -0
- package/assets/index.umd-6zndRFhB.js +1 -0
- package/assets/info-Bhf5PLdi.js +3 -0
- package/assets/info-circle-CZ5iih32.js +12 -0
- package/assets/inherits_browser-BlmhoU4v.js +1 -0
- package/assets/is-plan-event-enabled-DeNtQvA5.js +1 -0
- package/assets/jsx-runtime-B1l0k91v.js +1 -0
- package/assets/jsx-runtime-B1l0k91v__bundled.js +9 -0
- package/assets/learn-submenu-sfxVP5Db.webp +0 -0
- package/assets/lightbulb-CA3e26a0.js +3 -0
- package/assets/localBatchGatewayRequest-vExM5jac.js +1 -0
- package/assets/logo-pattern-D4X-bvlg.webp +0 -0
- package/assets/mail-BktjMbEk.js +8 -0
- package/assets/man-default1-BEO13leF.png +0 -0
- package/assets/marketplace-submenu-CixWTv8_.webp +0 -0
- package/assets/mobile-zfEM0JzU.js +9 -0
- package/assets/more-Dg45xuT9.js +11 -0
- package/assets/native-CJ5et6AR.js +1 -0
- package/assets/network-placeholder-duQhExzj.js +14 -0
- package/assets/nftPlaceholder-C3kMYu-p.js +8 -0
- package/assets/off-Cz636L92.js +8 -0
- package/assets/play-store-Cch0eiCp.js +32 -0
- package/assets/plus-orAhHwVf.js +13 -0
- package/assets/preload-helper-BrYcp76J.js +1 -0
- package/assets/qr-code-7plug-hj.js +6 -0
- package/assets/recycle-horizontal-B6ivY9Sz.js +9 -0
- package/assets/refresh-CqfvjhXq.js +8 -0
- package/assets/remoteEntry.js +1 -0
- package/assets/reown-logo-DGoAljI9.js +12 -0
- package/assets/reselect-BfUrOuXx.js +1 -0
- package/assets/rich-text-react-renderer_decentraland-ui2-BIHI7g3E.js +1 -0
- package/assets/search-nNK2K8mD.js +8 -0
- package/assets/secp256k1-D6s48BOl.js +1 -0
- package/assets/send-BPz2SBvc.js +15 -0
- package/assets/swapHorizontal-TvVHlgjl.js +8 -0
- package/assets/swapHorizontalBold-BTw_LG1-.js +8 -0
- package/assets/swapHorizontalMedium-C3jJnFs_.js +16 -0
- package/assets/swapHorizontalRoundedBold-nTFwdVeT.js +8 -0
- package/assets/swapVertical-CHKvPR_7.js +8 -0
- package/assets/telegram-C552IoSr.js +16 -0
- package/assets/three-dots-Nyfa4nYF.js +5 -0
- package/assets/top_background-Bnd2vX_F.webp +0 -0
- package/assets/tslib.es6-DbvBTznf.js +1 -0
- package/assets/twitch-7SJKGXSa.js +18 -0
- package/assets/twitterIcon-BBg9ypIU.js +6 -0
- package/assets/uid-CX4a_w4r.js +44 -0
- package/assets/verify-BwQ9FKM1.js +8 -0
- package/assets/verify-filled-BAdDAZxZ.js +8 -0
- package/assets/w3m-modal-BqXXR9rX.js +642 -0
- package/assets/wallet-DJsa1d3M.js +8 -0
- package/assets/wallet-placeholder-DPIkQ5vM.js +14 -0
- package/assets/walletconnect-osdnzzVU.js +30 -0
- package/assets/warning-circle-BQ9uHGTL.js +12 -0
- package/assets/webSocket-CIn5Ftst.js +3 -0
- package/assets/x-5oycQ-0v.js +12 -0
- package/dcl-logo.svg +1 -0
- package/index.html +41 -0
- package/package.json +21 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{importShared as ye}from"./__federation_fn_import-WDa0gv1I.js";import{B as tr,_ as q,h as mi,y as nc}from"./hooks.module-Dz_XB4AG.js";import{E as rc}from"./index-CdrMQoR6.js";import{a as ic,s as Mn,p as ac,c as sc}from"./createClient-CSnZgvsb.js";import{a as bt,cm as Pe,ak as J,aR as oc,bu as cc,e as Dn,ay as He,al as nr,cW as uc,y as Re,aj as Aa,B as N,fN as dc,fL as yi,d as lc,eP as fc,aw as pc,av as hc,ag as ln,w as $r,ao as mc,cD as yc,x as Gr,z as _a,cw as gc,aS as bc,bq as wc,s as vc,bv as xc,bw as Ec,bD as Ia}from"./uid-CX4a_w4r.js";import{c as Sc,g as kc,d as Ac,s as _c}from"./index-nibyPLVP.js";import{a as Ic}from"./_commonjsHelpers-C4iS2aBk.js";function Oa(e,t){let n;try{n=e()}catch{return}return{getItem:i=>{var a;const s=c=>c===null?null:JSON.parse(c,void 0),o=(a=n.getItem(i))!=null?a:null;return o instanceof Promise?o.then(s):s(o)},setItem:(i,a)=>n.setItem(i,JSON.stringify(a,void 0)),removeItem:i=>n.removeItem(i)}}const rr=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return rr(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return rr(r)(n)}}}},Oc=(e,t)=>(n,r,i)=>{let a={storage:Oa(()=>localStorage),partialize:h=>h,version:0,merge:(h,v)=>({...v,...h}),...t},s=!1;const o=new Set,c=new Set;let u=a.storage;if(!u)return e((...h)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...h)},r,i);const p=()=>{const h=a.partialize({...r()});return u.setItem(a.name,{state:h,version:a.version})},f=i.setState;i.setState=(h,v)=>{f(h,v),p()};const l=e((...h)=>{n(...h),p()},r,i);i.getInitialState=()=>l;let d;const g=()=>{var h,v;if(!u)return;s=!1,o.forEach(P=>{var x;return P((x=r())!=null?x:l)});const k=((v=a.onRehydrateStorage)==null?void 0:v.call(a,(h=r())!=null?h:l))||void 0;return rr(u.getItem.bind(u))(a.name).then(P=>{if(P)if(typeof P.version=="number"&&P.version!==a.version){if(a.migrate){const x=a.migrate(P.state,P.version);return x instanceof Promise?x.then(I=>[!0,I]):[!0,x]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,P.state];return[!1,void 0]}).then(P=>{var x;const[I,D]=P;if(d=a.merge(D,(x=r())!=null?x:l),n(d,!0),I)return p()}).then(()=>{k?.(d,void 0),d=r(),s=!0,c.forEach(P=>P(d))}).catch(P=>{k?.(void 0,P)})};return i.persist={setOptions:h=>{a={...a,...h},h.storage&&(u=h.storage)},clearStorage:()=>{u?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>g(),hasHydrated:()=>s,onHydrate:h=>(o.add(h),()=>{o.delete(h)}),onFinishHydration:h=>(c.add(h),()=>{c.delete(h)})},a.skipHydration||g(),d||l},Pc=Oc,gi=e=>{let t;const n=new Set,r=(u,p)=>{const f=typeof u=="function"?u(t):u;if(!Object.is(f,t)){const l=t;t=p??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(d=>d(t,l))}},i=()=>t,o={setState:r,getState:i,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u))},c=t=e(r,i,o);return o},Fr=e=>e?gi(e):gi;function Pa(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=Pa(e[t]))&&(r&&(r+=" "),r+=n);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function Dt(){for(var e,t,n=0,r="";n<arguments.length;)(e=arguments[n++])&&(t=Pa(e))&&(r&&(r+=" "),r+=t);return r}const Cc=[{inputs:[{name:"preOpGas",type:"uint256"},{name:"paid",type:"uint256"},{name:"validAfter",type:"uint48"},{name:"validUntil",type:"uint48"},{name:"targetSuccess",type:"bool"},{name:"targetResult",type:"bytes"}],name:"ExecutionResult",type:"error"},{inputs:[{name:"opIndex",type:"uint256"},{name:"reason",type:"string"}],name:"FailedOp",type:"error"},{inputs:[{name:"sender",type:"address"}],name:"SenderAddressResult",type:"error"},{inputs:[{name:"aggregator",type:"address"}],name:"SignatureValidationFailed",type:"error"},{inputs:[{components:[{name:"preOpGas",type:"uint256"},{name:"prefund",type:"uint256"},{name:"sigFailed",type:"bool"},{name:"validAfter",type:"uint48"},{name:"validUntil",type:"uint48"},{name:"paymasterContext",type:"bytes"}],name:"returnInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"senderInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"factoryInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"paymasterInfo",type:"tuple"}],name:"ValidationResult",type:"error"},{inputs:[{components:[{name:"preOpGas",type:"uint256"},{name:"prefund",type:"uint256"},{name:"sigFailed",type:"bool"},{name:"validAfter",type:"uint48"},{name:"validUntil",type:"uint48"},{name:"paymasterContext",type:"bytes"}],name:"returnInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"senderInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"factoryInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"paymasterInfo",type:"tuple"},{components:[{name:"aggregator",type:"address"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"stakeInfo",type:"tuple"}],name:"aggregatorInfo",type:"tuple"}],name:"ValidationResultWithAggregation",type:"error"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!1,name:"factory",type:"address"},{indexed:!1,name:"paymaster",type:"address"}],name:"AccountDeployed",type:"event"},{anonymous:!1,inputs:[],name:"BeforeExecution",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"totalDeposit",type:"uint256"}],name:"Deposited",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"aggregator",type:"address"}],name:"SignatureAggregatorChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"totalStaked",type:"uint256"},{indexed:!1,name:"unstakeDelaySec",type:"uint256"}],name:"StakeLocked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawTime",type:"uint256"}],name:"StakeUnlocked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawAddress",type:"address"},{indexed:!1,name:"amount",type:"uint256"}],name:"StakeWithdrawn",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!0,name:"paymaster",type:"address"},{indexed:!1,name:"nonce",type:"uint256"},{indexed:!1,name:"success",type:"bool"},{indexed:!1,name:"actualGasCost",type:"uint256"},{indexed:!1,name:"actualGasUsed",type:"uint256"}],name:"UserOperationEvent",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!1,name:"nonce",type:"uint256"},{indexed:!1,name:"revertReason",type:"bytes"}],name:"UserOperationRevertReason",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawAddress",type:"address"},{indexed:!1,name:"amount",type:"uint256"}],name:"Withdrawn",type:"event"},{inputs:[],name:"SIG_VALIDATION_FAILED",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"initCode",type:"bytes"},{name:"sender",type:"address"},{name:"paymasterAndData",type:"bytes"}],name:"_validateSenderAndPaymaster",outputs:[],stateMutability:"view",type:"function"},{inputs:[{name:"unstakeDelaySec",type:"uint32"}],name:"addStake",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"account",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"address"}],name:"depositTo",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"",type:"address"}],name:"deposits",outputs:[{name:"deposit",type:"uint112"},{name:"staked",type:"bool"},{name:"stake",type:"uint112"},{name:"unstakeDelaySec",type:"uint32"},{name:"withdrawTime",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"address"}],name:"getDepositInfo",outputs:[{components:[{name:"deposit",type:"uint112"},{name:"staked",type:"bool"},{name:"stake",type:"uint112"},{name:"unstakeDelaySec",type:"uint32"},{name:"withdrawTime",type:"uint48"}],name:"info",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{name:"sender",type:"address"},{name:"key",type:"uint192"}],name:"getNonce",outputs:[{name:"nonce",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"initCode",type:"bytes"}],name:"getSenderAddress",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"getUserOpHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{components:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOps",type:"tuple[]"},{name:"aggregator",type:"address"},{name:"signature",type:"bytes"}],name:"opsPerAggregator",type:"tuple[]"},{name:"beneficiary",type:"address"}],name:"handleAggregatedOps",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"ops",type:"tuple[]"},{name:"beneficiary",type:"address"}],name:"handleOps",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"key",type:"uint192"}],name:"incrementNonce",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"callData",type:"bytes"},{components:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"paymaster",type:"address"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"}],name:"mUserOp",type:"tuple"},{name:"userOpHash",type:"bytes32"},{name:"prefund",type:"uint256"},{name:"contextOffset",type:"uint256"},{name:"preOpGas",type:"uint256"}],name:"opInfo",type:"tuple"},{name:"context",type:"bytes"}],name:"innerHandleOp",outputs:[{name:"actualGasCost",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"",type:"address"},{name:"",type:"uint192"}],name:"nonceSequenceNumber",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"op",type:"tuple"},{name:"target",type:"address"},{name:"targetCallData",type:"bytes"}],name:"simulateHandleOp",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"simulateValidation",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"unlockStake",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"withdrawAddress",type:"address"}],name:"withdrawStake",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"withdrawAddress",type:"address"},{name:"withdrawAmount",type:"uint256"}],name:"withdrawTo",outputs:[],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}],Tc="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789";function Ca(e,t={}){const{forHash:n}=t,{authorization:r,factory:i,factoryData:a}=e;return n&&(i==="0x7702"||i==="0x7702000000000000000000000000000000000000")?r?bt([r.address,a??"0x"]):"0x7702000000000000000000000000000000000000":i?bt([i,a??"0x"]):"0x"}const bi="0x22e325a297439656";function Ta(e,t={}){const{callGasLimit:n,callData:r,maxPriorityFeePerGas:i,maxFeePerGas:a,paymaster:s,paymasterData:o,paymasterPostOpGasLimit:c,paymasterSignature:u,paymasterVerificationGasLimit:p,sender:f,signature:l="0x",verificationGasLimit:d}=e,g=bt([Pe(J(d||0n),{size:16}),Pe(J(n||0n),{size:16})]),h=Ca(e,t),v=bt([Pe(J(i||0n),{size:16}),Pe(J(a||0n),{size:16})]),k=e.nonce??0n,P=s?bt([s,Pe(J(p||0n),{size:16}),Pe(J(c||0n),{size:16}),o||"0x",...u?t.forHash?[bi]:[u,Pe(J(oc(u)),{size:2}),bi]:[]]):"0x",x=e.preVerificationGas??0n;return{accountGasLimits:g,callData:r,initCode:h,gasFees:v,nonce:k,paymasterAndData:P,preVerificationGas:x,sender:f,signature:l}}const Bc={PackedUserOperation:[{type:"address",name:"sender"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"bytes32",name:"accountGasLimits"},{type:"uint256",name:"preVerificationGas"},{type:"bytes32",name:"gasFees"},{type:"bytes",name:"paymasterAndData"}]};function Lc(e){const{chainId:t,entryPointAddress:n,userOperation:r}=e,i=Ta(r,{forHash:!0});return{types:Bc,primaryType:"PackedUserOperation",domain:{name:"ERC4337",version:"1",chainId:t,verifyingContract:n},message:i}}function jc(e){const{chainId:t,entryPointAddress:n,entryPointVersion:r}=e,i=e.userOperation,{authorization:a,callData:s="0x",callGasLimit:o,maxFeePerGas:c,maxPriorityFeePerGas:u,nonce:p,paymasterAndData:f="0x",preVerificationGas:l,sender:d,verificationGasLimit:g}=i;if(r==="0.8"||r==="0.9")return cc(Lc({chainId:t,entryPointAddress:n,userOperation:i}));const h=(()=>{if(r==="0.6"){const v=i.initCode?.slice(0,42),k=i.initCode?.slice(42),P=Ca({authorization:a,factory:v,factoryData:k},{forHash:!0});return Dn([{type:"address"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"bytes32"}],[d,p,He(P),He(s),o,g,l,c,u,He(f)])}if(r==="0.7"){const v=Ta(i,{forHash:!0});return Dn([{type:"address"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"},{type:"bytes32"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"}],[v.sender,v.nonce,He(v.initCode),He(v.callData),v.accountGasLimits,v.preVerificationGas,v.gasFees,He(v.paymasterAndData)])}throw new Error(`entryPointVersion "${r}" not supported.`)})();return He(Dn([{type:"bytes32"},{type:"address"},{type:"uint256"}],[He(h),n,BigInt(t)]))}async function Mc(e){const{extend:t,nonceKeyManager:n=ic({source:{get(){return Date.now()},set(){}}}),...r}=e;let i=!1;const a=await e.getAddress();return{...t,...r,address:a,async getFactoryArgs(){return"isDeployed"in this&&await this.isDeployed()?{factory:void 0,factoryData:void 0}:e.getFactoryArgs()},async getNonce(s){const o=s?.key??BigInt(await n.consume({address:a,chainId:e.client.chain.id,client:e.client}));return e.getNonce?await e.getNonce({...s,key:o}):await nr(e.client,{abi:uc(["function getNonce(address, uint192) pure returns (uint256)"]),address:e.entryPoint.address,functionName:"getNonce",args:[a,o]})},async isDeployed(){return i?!0:(i=!!await Re(e.client,Aa,"getCode")({address:a}),i)},...e.sign?{async sign(s){const[{factory:o,factoryData:c},u]=await Promise.all([this.getFactoryArgs(),e.sign(s)]);return o&&c?Mn({address:o,data:c,signature:u}):u}}:{},async signMessage(s){const[{factory:o,factoryData:c},u]=await Promise.all([this.getFactoryArgs(),e.signMessage(s)]);return o&&c&&o!=="0x7702"?Mn({address:o,data:c,signature:u}):u},async signTypedData(s){const[{factory:o,factoryData:c},u]=await Promise.all([this.getFactoryArgs(),e.signTypedData(s)]);return o&&c&&o!=="0x7702"?Mn({address:o,data:c,signature:u}):u},type:"smart"}}class ir extends N{constructor({cause:t}){super("Smart Account is not deployed.",{cause:t,metaMessages:["This could arise when:","- No `factory`/`factoryData` or `initCode` properties are provided for Smart Account deployment.","- An incorrect `sender` address is provided."],name:"AccountNotDeployedError"})}}Object.defineProperty(ir,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa20/});class kt extends N{constructor({cause:t,data:n,message:r}={}){const i=r?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${i?`with reason: ${i}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=n}}Object.defineProperty(kt,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32521});Object.defineProperty(kt,"message",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class ar extends N{constructor({cause:t}){super("Failed to send funds to beneficiary.",{cause:t,name:"FailedToSendToBeneficiaryError"})}}Object.defineProperty(ar,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa91/});class sr extends N{constructor({cause:t}){super("Gas value overflowed.",{cause:t,metaMessages:["This could arise when:","- one of the gas values exceeded 2**120 (uint120)"].filter(Boolean),name:"GasValuesOverflowError"})}}Object.defineProperty(sr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa94/});class or extends N{constructor({cause:t}){super("The `handleOps` function was called by the Bundler with a gas limit too low.",{cause:t,name:"HandleOpsOutOfGasError"})}}Object.defineProperty(or,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa95/});class cr extends N{constructor({cause:t,factory:n,factoryData:r,initCode:i}){super("Failed to simulate deployment for Smart Account.",{cause:t,metaMessages:["This could arise when:","- Invalid `factory`/`factoryData` or `initCode` properties are present","- Smart Account deployment execution ran out of gas (low `verificationGasLimit` value)",`- Smart Account deployment execution reverted with an error
|
|
2
|
+
`,n&&`factory: ${n}`,r&&`factoryData: ${r}`,i&&`initCode: ${i}`].filter(Boolean),name:"InitCodeFailedError"})}}Object.defineProperty(cr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa13/});class ur extends N{constructor({cause:t,factory:n,factoryData:r,initCode:i}){super("Smart Account initialization implementation did not create an account.",{cause:t,metaMessages:["This could arise when:","- `factory`/`factoryData` or `initCode` properties are invalid",`- Smart Account initialization implementation is incorrect
|
|
3
|
+
`,n&&`factory: ${n}`,r&&`factoryData: ${r}`,i&&`initCode: ${i}`].filter(Boolean),name:"InitCodeMustCreateSenderError"})}}Object.defineProperty(ur,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa15/});class dr extends N{constructor({cause:t,factory:n,factoryData:r,initCode:i,sender:a}){super("Smart Account initialization implementation does not return the expected sender.",{cause:t,metaMessages:["This could arise when:",`Smart Account initialization implementation does not return a sender address
|
|
4
|
+
`,n&&`factory: ${n}`,r&&`factoryData: ${r}`,i&&`initCode: ${i}`,a&&`sender: ${a}`].filter(Boolean),name:"InitCodeMustReturnSenderError"})}}Object.defineProperty(dr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa14/});class lr extends N{constructor({cause:t}){super("Smart Account does not have sufficient funds to execute the User Operation.",{cause:t,metaMessages:["This could arise when:","- the Smart Account does not have sufficient funds to cover the required prefund, or","- a Paymaster was not provided"].filter(Boolean),name:"InsufficientPrefundError"})}}Object.defineProperty(lr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa21/});class fr extends N{constructor({cause:t}){super("Bundler attempted to call an invalid function on the EntryPoint.",{cause:t,name:"InternalCallOnlyError"})}}Object.defineProperty(fr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa92/});class pr extends N{constructor({cause:t}){super("Bundler used an invalid aggregator for handling aggregated User Operations.",{cause:t,name:"InvalidAggregatorError"})}}Object.defineProperty(pr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa96/});class hr extends N{constructor({cause:t,nonce:n}){super("Invalid Smart Account nonce used for User Operation.",{cause:t,metaMessages:[n&&`nonce: ${n}`].filter(Boolean),name:"InvalidAccountNonceError"})}}Object.defineProperty(hr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa25/});class mr extends N{constructor({cause:t}){super("Bundler has not set a beneficiary address.",{cause:t,name:"InvalidBeneficiaryError"})}}Object.defineProperty(mr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa90/});class fn extends N{constructor({cause:t}){super("Invalid fields set on User Operation.",{cause:t,name:"InvalidFieldsError"})}}Object.defineProperty(fn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class yr extends N{constructor({cause:t,paymasterAndData:n}){super("Paymaster properties provided are invalid.",{cause:t,metaMessages:["This could arise when:","- the `paymasterAndData` property is of an incorrect length\n",n&&`paymasterAndData: ${n}`].filter(Boolean),name:"InvalidPaymasterAndDataError"})}}Object.defineProperty(yr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa93/});class it extends N{constructor({cause:t}){super("Paymaster deposit for the User Operation is too low.",{cause:t,metaMessages:["This could arise when:","- the Paymaster has deposited less than the expected amount via the `deposit` function"].filter(Boolean),name:"PaymasterDepositTooLowError"})}}Object.defineProperty(it,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32508});Object.defineProperty(it,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa31/});class gr extends N{constructor({cause:t}){super("The `validatePaymasterUserOp` function on the Paymaster reverted.",{cause:t,name:"PaymasterFunctionRevertedError"})}}Object.defineProperty(gr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa33/});class br extends N{constructor({cause:t}){super("The Paymaster contract has not been deployed.",{cause:t,name:"PaymasterNotDeployedError"})}}Object.defineProperty(br,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa30/});class pn extends N{constructor({cause:t}){super("UserOperation rejected because paymaster (or signature aggregator) is throttled/banned.",{cause:t,name:"PaymasterRateLimitError"})}}Object.defineProperty(pn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32504});class hn extends N{constructor({cause:t}){super("UserOperation rejected because paymaster (or signature aggregator) is throttled/banned.",{cause:t,name:"PaymasterStakeTooLowError"})}}Object.defineProperty(hn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32505});class wr extends N{constructor({cause:t}){super("Paymaster `postOp` function reverted.",{cause:t,name:"PaymasterPostOpFunctionRevertedError"})}}Object.defineProperty(wr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa50/});class vr extends N{constructor({cause:t,factory:n,factoryData:r,initCode:i}){super("Smart Account has already been deployed.",{cause:t,metaMessages:["Remove the following properties and try again:",n&&"`factory`",r&&"`factoryData`",i&&"`initCode`"].filter(Boolean),name:"SenderAlreadyConstructedError"})}}Object.defineProperty(vr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa10/});class mn extends N{constructor({cause:t}){super("UserOperation rejected because account signature check failed (or paymaster signature, if the paymaster uses its data as signature).",{cause:t,name:"SignatureCheckFailedError"})}}Object.defineProperty(mn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32507});class xr extends N{constructor({cause:t}){super("The `validateUserOp` function on the Smart Account reverted.",{cause:t,name:"SmartAccountFunctionRevertedError"})}}Object.defineProperty(xr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa23/});class yn extends N{constructor({cause:t}){super("UserOperation rejected because account specified unsupported signature aggregator.",{cause:t,name:"UnsupportedSignatureAggregatorError"})}}Object.defineProperty(yn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32506});class Er extends N{constructor({cause:t}){super("User Operation expired.",{cause:t,metaMessages:["This could arise when:","- the `validAfter` or `validUntil` values returned from `validateUserOp` on the Smart Account are not satisfied"].filter(Boolean),name:"UserOperationExpiredError"})}}Object.defineProperty(Er,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa22/});class Sr extends N{constructor({cause:t}){super("Paymaster for User Operation expired.",{cause:t,metaMessages:["This could arise when:","- the `validAfter` or `validUntil` values returned from `validatePaymasterUserOp` on the Paymaster are not satisfied"].filter(Boolean),name:"UserOperationPaymasterExpiredError"})}}Object.defineProperty(Sr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa32/});class kr extends N{constructor({cause:t}){super("Signature provided for the User Operation is invalid.",{cause:t,metaMessages:["This could arise when:","- the `signature` for the User Operation is incorrectly computed, and unable to be verified by the Smart Account"].filter(Boolean),name:"UserOperationSignatureError"})}}Object.defineProperty(kr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa24/});class Ar extends N{constructor({cause:t}){super("Signature provided for the User Operation is invalid.",{cause:t,metaMessages:["This could arise when:","- the `signature` for the User Operation is incorrectly computed, and unable to be verified by the Paymaster"].filter(Boolean),name:"UserOperationPaymasterSignatureError"})}}Object.defineProperty(Ar,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa34/});class gn extends N{constructor({cause:t}){super("User Operation rejected by EntryPoint's `simulateValidation` during account creation or validation.",{cause:t,name:"UserOperationRejectedByEntryPointError"})}}Object.defineProperty(gn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32500});class bn extends N{constructor({cause:t}){super("User Operation rejected by Paymaster's `validatePaymasterUserOp`.",{cause:t,name:"UserOperationRejectedByPaymasterError"})}}Object.defineProperty(bn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32501});class wn extends N{constructor({cause:t}){super("User Operation rejected with op code validation error.",{cause:t,name:"UserOperationRejectedByOpCodeError"})}}Object.defineProperty(wn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32502});class vn extends N{constructor({cause:t}){super("UserOperation out of time-range: either wallet or paymaster returned a time-range, and it is already expired (or will expire soon).",{cause:t,name:"UserOperationOutOfTimeRangeError"})}}Object.defineProperty(vn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32503});class Dc extends N{constructor({cause:t}){super(`An error occurred while executing user operation: ${t?.shortMessage}`,{cause:t,name:"UnknownBundlerError"})}}class _r extends N{constructor({cause:t}){super("User Operation verification gas limit exceeded.",{cause:t,metaMessages:["This could arise when:","- the gas used for verification exceeded the `verificationGasLimit`"].filter(Boolean),name:"VerificationGasLimitExceededError"})}}Object.defineProperty(_r,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa40/});class Ir extends N{constructor({cause:t}){super("User Operation verification gas limit is too low.",{cause:t,metaMessages:["This could arise when:","- the `verificationGasLimit` is too low to verify the User Operation"].filter(Boolean),name:"VerificationGasLimitTooLowError"})}}Object.defineProperty(Ir,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa41/});class Nc extends N{constructor(t,{callData:n,callGasLimit:r,docsPath:i,factory:a,factoryData:s,initCode:o,maxFeePerGas:c,maxPriorityFeePerGas:u,nonce:p,paymaster:f,paymasterAndData:l,paymasterData:d,paymasterPostOpGasLimit:g,paymasterVerificationGasLimit:h,preVerificationGas:v,sender:k,signature:P,verificationGasLimit:x}){const I=dc({callData:n,callGasLimit:r,factory:a,factoryData:s,initCode:o,maxFeePerGas:typeof c<"u"&&`${yi(c)} gwei`,maxPriorityFeePerGas:typeof u<"u"&&`${yi(u)} gwei`,nonce:p,paymaster:f,paymasterAndData:l,paymasterData:d,paymasterPostOpGasLimit:g,paymasterVerificationGasLimit:h,preVerificationGas:v,sender:k,signature:P,verificationGasLimit:x});super(t.shortMessage,{cause:t,docsPath:i,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Request Arguments:",I].filter(Boolean),name:"UserOperationExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t}}class Rc extends N{constructor({hash:t}){super(`User Operation receipt with hash "${t}" could not be found. The User Operation may not have been processed yet.`,{name:"UserOperationReceiptNotFoundError"})}}class Uc extends N{constructor({hash:t}){super(`User Operation with hash "${t}" could not be found.`,{name:"UserOperationNotFoundError"})}}class wi extends N{constructor({hash:t}){super(`Timed out while waiting for User Operation with hash "${t}" to be confirmed.`,{name:"WaitForUserOperationReceiptTimeoutError"})}}const Hc=[kt,fn,it,pn,hn,mn,yn,vn,gn,bn,wn];function $c(e,t){const n=(e.details||"").toLowerCase();if(ir.message.test(n))return new ir({cause:e});if(ar.message.test(n))return new ar({cause:e});if(sr.message.test(n))return new sr({cause:e});if(or.message.test(n))return new or({cause:e});if(cr.message.test(n))return new cr({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(ur.message.test(n))return new ur({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(dr.message.test(n))return new dr({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode,sender:t.sender});if(lr.message.test(n))return new lr({cause:e});if(fr.message.test(n))return new fr({cause:e});if(hr.message.test(n))return new hr({cause:e,nonce:t.nonce});if(pr.message.test(n))return new pr({cause:e});if(mr.message.test(n))return new mr({cause:e});if(yr.message.test(n))return new yr({cause:e});if(it.message.test(n))return new it({cause:e});if(gr.message.test(n))return new gr({cause:e});if(br.message.test(n))return new br({cause:e});if(wr.message.test(n))return new wr({cause:e});if(xr.message.test(n))return new xr({cause:e});if(vr.message.test(n))return new vr({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(Er.message.test(n))return new Er({cause:e});if(Sr.message.test(n))return new Sr({cause:e});if(Ar.message.test(n))return new Ar({cause:e});if(kr.message.test(n))return new kr({cause:e});if(_r.message.test(n))return new _r({cause:e});if(Ir.message.test(n))return new Ir({cause:e});const r=e.walk(i=>Hc.some(a=>a.code===i.code));if(r){if(r.code===kt.code)return new kt({cause:e,data:r.data,message:r.details});if(r.code===fn.code)return new fn({cause:e});if(r.code===it.code)return new it({cause:e});if(r.code===pn.code)return new pn({cause:e});if(r.code===hn.code)return new hn({cause:e});if(r.code===mn.code)return new mn({cause:e});if(r.code===yn.code)return new yn({cause:e});if(r.code===vn.code)return new vn({cause:e});if(r.code===gn.code)return new gn({cause:e});if(r.code===bn.code)return new bn({cause:e});if(r.code===wn.code)return new wn({cause:e})}return new Dc({cause:e})}function Ba(e,{calls:t,docsPath:n,...r}){const i=(()=>{const a=$c(e,r);if(t&&a instanceof kt){const s=Gc(a),o=t?.filter(c=>c.abi);if(s&&o.length>0)return Fc({calls:o,revertData:s})}return a})();return new Nc(i,{docsPath:n,...r})}function Gc(e){let t;return e.walk(n=>{const r=n;if(typeof r.data=="string"||typeof r.data?.revertData=="string"||!(r instanceof N)&&typeof r.message=="string"){const i=(r.data?.revertData||r.data||r.message).match?.(/(0x[A-Za-z0-9]*)/);if(i)return t=i[1],!0}return!1}),t}function Fc(e){const{calls:t,revertData:n}=e,{abi:r,functionName:i,args:a,to:s}=(()=>{const c=t?.filter(p=>!!p.abi);if(c.length===1)return c[0];const u=c.filter(p=>{try{return!!lc({abi:p.abi,data:n})}catch{return!1}});return u.length===1?u[0]:{abi:[],functionName:c.reduce((p,f)=>`${p?`${p} | `:""}${f.functionName}`,""),args:void 0,to:void 0}})(),o=n==="0x"?new fc({functionName:i}):new pc({abi:r,data:n,functionName:i});return new hc(o,{abi:r,args:a,contractAddress:s,functionName:i})}function zc(e){const t={};return e.callGasLimit&&(t.callGasLimit=BigInt(e.callGasLimit)),e.preVerificationGas&&(t.preVerificationGas=BigInt(e.preVerificationGas)),e.verificationGasLimit&&(t.verificationGasLimit=BigInt(e.verificationGasLimit)),e.paymasterPostOpGasLimit&&(t.paymasterPostOpGasLimit=BigInt(e.paymasterPostOpGasLimit)),e.paymasterVerificationGasLimit&&(t.paymasterVerificationGasLimit=BigInt(e.paymasterVerificationGasLimit)),t}function In(e){const t={};return typeof e.callData<"u"&&(t.callData=e.callData),typeof e.callGasLimit<"u"&&(t.callGasLimit=J(e.callGasLimit)),typeof e.factory<"u"&&(t.factory=e.factory),typeof e.factoryData<"u"&&(t.factoryData=e.factoryData),typeof e.initCode<"u"&&(t.initCode=e.initCode),typeof e.maxFeePerGas<"u"&&(t.maxFeePerGas=J(e.maxFeePerGas)),typeof e.maxPriorityFeePerGas<"u"&&(t.maxPriorityFeePerGas=J(e.maxPriorityFeePerGas)),typeof e.nonce<"u"&&(t.nonce=J(e.nonce)),typeof e.paymaster<"u"&&(t.paymaster=e.paymaster),typeof e.paymasterAndData<"u"&&(t.paymasterAndData=e.paymasterAndData||"0x"),typeof e.paymasterData<"u"&&(t.paymasterData=e.paymasterData),typeof e.paymasterPostOpGasLimit<"u"&&(t.paymasterPostOpGasLimit=J(e.paymasterPostOpGasLimit)),typeof e.paymasterSignature<"u"&&(t.paymasterSignature=e.paymasterSignature),typeof e.paymasterVerificationGasLimit<"u"&&(t.paymasterVerificationGasLimit=J(e.paymasterVerificationGasLimit)),typeof e.preVerificationGas<"u"&&(t.preVerificationGas=J(e.preVerificationGas)),typeof e.sender<"u"&&(t.sender=e.sender),typeof e.signature<"u"&&(t.signature=e.signature),typeof e.verificationGasLimit<"u"&&(t.verificationGasLimit=J(e.verificationGasLimit)),typeof e.authorization<"u"&&(t.eip7702Auth=qc(e.authorization)),t}function qc(e){return{address:e.address,chainId:J(e.chainId),nonce:J(e.nonce),r:e.r?J(BigInt(e.r),{size:32}):Pe("0x",{size:32}),s:e.s?J(BigInt(e.s),{size:32}):Pe("0x",{size:32}),yParity:e.yParity?J(e.yParity,{size:1}):Pe("0x",{size:32})}}async function Wc(e,t){const{chainId:n,entryPointAddress:r,context:i,...a}=t,s=In(a),{paymasterPostOpGasLimit:o,paymasterVerificationGasLimit:c,...u}=await e.request({method:"pm_getPaymasterData",params:[{...s,callGasLimit:s.callGasLimit??"0x0",verificationGasLimit:s.verificationGasLimit??"0x0",preVerificationGas:s.preVerificationGas??"0x0"},r,J(n),i]});return{...u,...o&&{paymasterPostOpGasLimit:ln(o)},...c&&{paymasterVerificationGasLimit:ln(c)}}}async function Vc(e,t){const{chainId:n,entryPointAddress:r,context:i,...a}=t,s=In(a),{paymasterPostOpGasLimit:o,paymasterVerificationGasLimit:c,...u}=await e.request({method:"pm_getPaymasterStubData",params:[{...s,callGasLimit:s.callGasLimit??"0x0",verificationGasLimit:s.verificationGasLimit??"0x0",preVerificationGas:s.preVerificationGas??"0x0"},r,J(n),i]});return{...u,...o&&{paymasterPostOpGasLimit:ln(o)},...c&&{paymasterVerificationGasLimit:ln(c)}}}const Kc=["factory","fees","gas","paymaster","nonce","signature","authorization"];async function zr(e,t){const n=t,{account:r=e.account,parameters:i=Kc,stateOverride:a}=n;if(!r)throw new $r;const s=Gr(r),o=e,c=n.paymaster??o?.paymaster,u=typeof c=="string"?c:void 0,{getPaymasterStubData:p,getPaymasterData:f}=(()=>{if(c===!0)return{getPaymasterStubData:T=>Re(o,Vc,"getPaymasterStubData")(T),getPaymasterData:T=>Re(o,Wc,"getPaymasterData")(T)};if(typeof c=="object"){const{getPaymasterStubData:T,getPaymasterData:G}=c;return{getPaymasterStubData:G&&T?T:G,getPaymasterData:G&&T?G:void 0}}return{getPaymasterStubData:void 0,getPaymasterData:void 0}})(),l=n.paymasterContext?n.paymasterContext:o?.paymasterContext;let d={...n,paymaster:u,sender:s.address};const[g,h,v,k,P]=await Promise.all([(async()=>n.calls?s.encodeCalls(n.calls.map(T=>{const G=T;return G.abi?{data:mc(G),to:G.to,value:G.value}:G})):n.callData)(),(async()=>{if(!i.includes("factory"))return;if(n.initCode)return{initCode:n.initCode};if(n.factory&&n.factoryData)return{factory:n.factory,factoryData:n.factoryData};const{factory:T,factoryData:G}=await s.getFactoryArgs();return s.entryPoint.version==="0.6"?{initCode:T&&G?bt([T,G]):void 0}:{factory:T,factoryData:G}})(),(async()=>{if(i.includes("fees")){if(typeof n.maxFeePerGas=="bigint"&&typeof n.maxPriorityFeePerGas=="bigint")return d;if(o?.userOperation?.estimateFeesPerGas){const T=await o.userOperation.estimateFeesPerGas({account:s,bundlerClient:o,userOperation:d});return{...d,...T}}try{const T=o.client??e,G=await Re(T,yc,"estimateFeesPerGas")({chain:T.chain,type:"eip1559"});return{maxFeePerGas:typeof n.maxFeePerGas=="bigint"?n.maxFeePerGas:BigInt(2n*G.maxFeePerGas),maxPriorityFeePerGas:typeof n.maxPriorityFeePerGas=="bigint"?n.maxPriorityFeePerGas:BigInt(2n*G.maxPriorityFeePerGas)}}catch{return}}})(),(async()=>{if(i.includes("nonce"))return typeof n.nonce=="bigint"?n.nonce:s.getNonce()})(),(async()=>{if(i.includes("authorization")){if(typeof n.authorization=="object")return n.authorization;if(s.authorization&&!await s.isDeployed())return{...await ac(s.client,s.authorization),r:"0xfffffffffffffffffffffffffffffff000000000000000000000000000000000",s:"0x7aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",yParity:1}}})()]);typeof g<"u"&&(d.callData=g),typeof h<"u"&&(d={...d,...h}),typeof v<"u"&&(d={...d,...v}),typeof k<"u"&&(d.nonce=k),typeof P<"u"&&(d.authorization=P),i.includes("signature")&&(typeof n.signature<"u"?d.signature=n.signature:d.signature=await s.getStubSignature(d)),s.entryPoint.version==="0.6"&&!d.initCode&&(d.initCode="0x");let x;async function I(){return x||(e.chain?e.chain.id:(x=await Re(e,_a,"getChainId")({}),x))}let D=!1;if(i.includes("paymaster")&&p&&!u&&!n.paymasterAndData){const{isFinal:T=!1,sponsor:G,...K}=await p({chainId:await I(),entryPointAddress:s.entryPoint.address,context:l,...d});D=T,d={...d,...K}}if(s.entryPoint.version==="0.6"&&!d.paymasterAndData&&(d.paymasterAndData="0x"),i.includes("gas")){if(s.userOperation?.estimateGas){const T=await s.userOperation.estimateGas(d);d={...d,...T}}if(typeof d.callGasLimit>"u"||typeof d.preVerificationGas>"u"||typeof d.verificationGasLimit>"u"||d.paymaster&&typeof d.paymasterPostOpGasLimit>"u"||d.paymaster&&typeof d.paymasterVerificationGasLimit>"u"){const T=await Re(o,La,"estimateUserOperationGas")({account:s,callGasLimit:0n,preVerificationGas:0n,verificationGasLimit:0n,stateOverride:a,...d.paymaster?{paymasterPostOpGasLimit:0n,paymasterVerificationGasLimit:0n}:{},...d});d={...d,callGasLimit:d.callGasLimit??T.callGasLimit,preVerificationGas:d.preVerificationGas??T.preVerificationGas,verificationGasLimit:d.verificationGasLimit??T.verificationGasLimit,paymasterPostOpGasLimit:d.paymasterPostOpGasLimit??T.paymasterPostOpGasLimit,paymasterVerificationGasLimit:d.paymasterVerificationGasLimit??T.paymasterVerificationGasLimit}}}if(i.includes("paymaster")&&f&&!u&&!n.paymasterAndData&&!D){const T=await f({chainId:await I(),entryPointAddress:s.entryPoint.address,context:l,...d});d={...d,...T}}return delete d.calls,delete d.parameters,delete d.paymasterContext,typeof d.paymaster!="string"&&delete d.paymaster,d}async function La(e,t){const{account:n=e.account,entryPointAddress:r,stateOverride:i}=t;if(!n&&!t.sender)throw new $r;const a=n?Gr(n):void 0,s=gc(i),o=a?await Re(e,zr,"prepareUserOperation")({...t,parameters:["authorization","factory","nonce","paymaster","signature"]}):t;try{const c=[In(o),r??a?.entryPoint?.address],u=await e.request({method:"eth_estimateUserOperationGas",params:s?[...c,s]:[...c]});return zc(u)}catch(c){const u=t.calls;throw Ba(c,{...o,...u?{calls:u}:{}})}}function Zc(e){return e.request({method:"eth_supportedEntryPoints"})}function Yc(e){const t={...e};return e.callGasLimit&&(t.callGasLimit=BigInt(e.callGasLimit)),e.maxFeePerGas&&(t.maxFeePerGas=BigInt(e.maxFeePerGas)),e.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=BigInt(e.maxPriorityFeePerGas)),e.nonce&&(t.nonce=BigInt(e.nonce)),e.paymasterPostOpGasLimit&&(t.paymasterPostOpGasLimit=BigInt(e.paymasterPostOpGasLimit)),e.paymasterVerificationGasLimit&&(t.paymasterVerificationGasLimit=BigInt(e.paymasterVerificationGasLimit)),e.preVerificationGas&&(t.preVerificationGas=BigInt(e.preVerificationGas)),e.verificationGasLimit&&(t.verificationGasLimit=BigInt(e.verificationGasLimit)),t}async function Jc(e,{hash:t}){const n=await e.request({method:"eth_getUserOperationByHash",params:[t]},{dedupe:!0});if(!n)throw new Uc({hash:t});const{blockHash:r,blockNumber:i,entryPoint:a,transactionHash:s,userOperation:o}=n;return{blockHash:r,blockNumber:BigInt(i),entryPoint:a,transactionHash:s,userOperation:Yc(o)}}function Qc(e){const t={...e};return e.actualGasCost&&(t.actualGasCost=BigInt(e.actualGasCost)),e.actualGasUsed&&(t.actualGasUsed=BigInt(e.actualGasUsed)),e.logs&&(t.logs=e.logs.map(n=>bc(n))),e.receipt&&(t.receipt=wc(t.receipt)),t}async function ja(e,{hash:t}){const n=await e.request({method:"eth_getUserOperationReceipt",params:[t]},{dedupe:!0});if(!n)throw new Rc({hash:t});return Qc(n)}async function Xc(e,t){const{account:n=e.account,entryPointAddress:r}=t;if(!n&&!t.sender)throw new $r;const i=n?Gr(n):void 0,a=i?await Re(e,zr,"prepareUserOperation")(t):t,s=t.signature||await i?.signUserOperation?.(a),o=In({...a,signature:s});try{return await e.request({method:"eth_sendUserOperation",params:[o,r??i?.entryPoint?.address]},{retryCount:0})}catch(c){const u=t.calls;throw Ba(c,{...a,...u?{calls:u}:{},signature:s})}}function eu(e,t){const{hash:n,pollingInterval:r=e.pollingInterval,retryCount:i,timeout:a=12e4}=t;let s=0;const o=vc(["waitForUserOperationReceipt",e.uid,n]);return new Promise((c,u)=>{const p=xc(o,{resolve:c,reject:u},f=>{const l=h=>{g(),h(),p()},d=a?setTimeout(()=>l(()=>f.reject(new wi({hash:n}))),a):void 0,g=Ec(async()=>{i&&s>=i&&(clearTimeout(d),l(()=>f.reject(new wi({hash:n}))));try{const h=await Re(e,ja,"getUserOperationReceipt")({hash:n});clearTimeout(d),l(()=>f.resolve(h))}catch(h){const v=h;v.name!=="UserOperationReceiptNotFoundError"&&(clearTimeout(d),l(()=>f.reject(v)))}s++},{emitOnBegin:!0,interval:r});return g})})}function tu(e){return{estimateUserOperationGas:t=>La(e,t),getChainId:()=>_a(e),getSupportedEntryPoints:()=>Zc(e),getUserOperation:t=>Jc(e,t),getUserOperationReceipt:t=>ja(e,t),prepareUserOperation:t=>zr(e,t),sendUserOperation:t=>Xc(e,t),waitForUserOperationReceipt:t=>eu(e,t)}}function nu(e){const{client:t,key:n="bundler",name:r="Bundler Client",paymaster:i,paymasterContext:a,transport:s,userOperation:o}=e;return Object.assign(sc({...e,chain:e.chain??t?.chain,key:n,name:r,transport:s,type:"bundlerClient"}),{client:t,paymaster:i,paymasterContext:a,userOperation:o}).extend(tu)}const ru="0.1.1";function iu(){return ru}let ee=class Or extends Error{constructor(t,n={}){const r=(()=>{if(n.cause instanceof Or){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause?.message?n.cause.message:n.details})(),i=n.cause instanceof Or&&n.cause.docsPath||n.docsPath,s=`https://oxlib.sh${i??""}`,o=[t||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r||i?["",r?`Details: ${r}`:void 0,i?`See: ${s}`:void 0]:[]].filter(c=>typeof c=="string").join(`
|
|
5
|
+
`);super(o,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${iu()}`}),this.cause=n.cause,this.details=r,this.docs=s,this.docsPath=i,this.shortMessage=t}walk(t){return Ma(this,t)}};function Ma(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause?Ma(e.cause,t):t?null:e}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function au(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function qr(e,...t){if(!au(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function vi(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function su(e,t){qr(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Pr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Nn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ke(e,t){return e<<32-t|e>>>t}function ou(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Da(e){return typeof e=="string"&&(e=ou(e)),qr(e),e}let cu=class{};function uu(e){const t=r=>e().update(Da(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function du(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const i=BigInt(32),a=BigInt(4294967295),s=Number(n>>i&a),o=Number(n&a),c=r?4:0,u=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+u,o,r)}function lu(e,t,n){return e&t^~e&n}function fu(e,t,n){return e&t^e&n^t&n}let pu=class extends cu{constructor(t,n,r,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(t),this.view=Nn(this.buffer)}update(t){vi(this),t=Da(t),qr(t);const{view:n,buffer:r,blockLen:i}=this,a=t.length;for(let s=0;s<a;){const o=Math.min(i-this.pos,a-s);if(o===i){const c=Nn(t);for(;i<=a-s;s+=i)this.process(c,s);continue}r.set(t.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===i&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){vi(this),su(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:i,isLE:a}=this;let{pos:s}=this;n[s++]=128,Pr(this.buffer.subarray(s)),this.padOffset>i-s&&(this.process(r,0),s=0);for(let f=s;f<i;f++)n[f]=0;du(r,i-8,BigInt(this.length*8),a),this.process(r,0);const o=Nn(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,p=this.get();if(u>p.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<u;f++)o.setUint32(4*f,p[f],a)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:i,finished:a,destroyed:s,pos:o}=this;return t.destroyed=s,t.finished=a,t.length=i,t.pos=o,i%n&&t.buffer.set(r),t}clone(){return this._cloneInto()}};const $e=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),hu=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ge=new Uint32Array(64);let mu=class extends pu{constructor(t=32){super(64,t,8,!1),this.A=$e[0]|0,this.B=$e[1]|0,this.C=$e[2]|0,this.D=$e[3]|0,this.E=$e[4]|0,this.F=$e[5]|0,this.G=$e[6]|0,this.H=$e[7]|0}get(){const{A:t,B:n,C:r,D:i,E:a,F:s,G:o,H:c}=this;return[t,n,r,i,a,s,o,c]}set(t,n,r,i,a,s,o,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=i|0,this.E=a|0,this.F=s|0,this.G=o|0,this.H=c|0}process(t,n){for(let f=0;f<16;f++,n+=4)Ge[f]=t.getUint32(n,!1);for(let f=16;f<64;f++){const l=Ge[f-15],d=Ge[f-2],g=ke(l,7)^ke(l,18)^l>>>3,h=ke(d,17)^ke(d,19)^d>>>10;Ge[f]=h+Ge[f-7]+g+Ge[f-16]|0}let{A:r,B:i,C:a,D:s,E:o,F:c,G:u,H:p}=this;for(let f=0;f<64;f++){const l=ke(o,6)^ke(o,11)^ke(o,25),d=p+l+lu(o,c,u)+hu[f]+Ge[f]|0,h=(ke(r,2)^ke(r,13)^ke(r,22))+fu(r,i,a)|0;p=u,u=c,c=o,o=s+d|0,s=a,a=i,i=r,r=d+h|0}r=r+this.A|0,i=i+this.B|0,a=a+this.C|0,s=s+this.D|0,o=o+this.E|0,c=c+this.F|0,u=u+this.G|0,p=p+this.H|0,this.set(r,i,a,s,o,c,u,p)}roundClean(){Pr(Ge)}destroy(){this.set(0,0,0,0,0,0,0,0),Pr(this.buffer)}};const yu=uu(()=>new mu),gu=yu,lt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function On(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Cr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ut(e,...t){if(!On(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Na(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Cr(e.outputLen),Cr(e.blockLen)}function xn(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function bu(e,t){ut(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function At(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Rn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ae(e,t){return e<<32-t|e>>>t}const Ra=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",wu=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function wt(e){if(ut(e),Ra)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=wu[e[n]];return t}const Te={_0:48,_9:57,A:65,F:70,a:97,f:102};function xi(e){if(e>=Te._0&&e<=Te._9)return e-Te._0;if(e>=Te.A&&e<=Te.F)return e-(Te.A-10);if(e>=Te.a&&e<=Te.f)return e-(Te.a-10)}function En(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Ra)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let i=0,a=0;i<n;i++,a+=2){const s=xi(e.charCodeAt(a)),o=xi(e.charCodeAt(a+1));if(s===void 0||o===void 0){const c=e[a]+e[a+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+a)}r[i]=s*16+o}return r}function vu(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Wr(e){return typeof e=="string"&&(e=vu(e)),ut(e),e}function Je(...e){let t=0;for(let r=0;r<e.length;r++){const i=e[r];ut(i),t+=i.length}const n=new Uint8Array(t);for(let r=0,i=0;r<e.length;r++){const a=e[r];n.set(a,i),i+=a.length}return n}let Ua=class{};function Vr(e){const t=r=>e().update(Wr(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Ha(e=32){if(lt&&typeof lt.getRandomValues=="function")return lt.getRandomValues(new Uint8Array(e));if(lt&&typeof lt.randomBytes=="function")return Uint8Array.from(lt.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Kr=BigInt(0),Tr=BigInt(1);function Sn(e,t=""){if(typeof e!="boolean"){const n=t&&`"${t}"`;throw new Error(n+"expected boolean, got type="+typeof e)}return e}function at(e,t,n=""){const r=On(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){const s=n&&`"${n}" `,o=a?` of length ${t}`:"",c=r?`length=${i}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+o+", got "+c)}return e}function Wt(e){const t=e.toString(16);return t.length&1?"0"+t:t}function $a(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?Kr:BigInt("0x"+e)}function Pn(e){return $a(wt(e))}function Ga(e){return ut(e),$a(wt(Uint8Array.from(e).reverse()))}function Zr(e,t){return En(e.toString(16).padStart(t*2,"0"))}function Fa(e,t){return Zr(e,t).reverse()}function le(e,t,n){let r;if(typeof t=="string")try{r=En(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(On(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");return r.length,r}const Un=e=>typeof e=="bigint"&&Kr<=e;function xu(e,t,n){return Un(e)&&Un(t)&&Un(n)&&t<=e&&e<n}function Eu(e,t,n,r){if(!xu(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function za(e){let t;for(t=0;e>Kr;e>>=Tr,t+=1);return t}const Ft=e=>(Tr<<BigInt(e))-Tr;function Su(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");const r=d=>new Uint8Array(d),i=d=>Uint8Array.of(d);let a=r(e),s=r(e),o=0;const c=()=>{a.fill(1),s.fill(0),o=0},u=(...d)=>n(s,a,...d),p=(d=r(0))=>{s=u(i(0),d),a=u(),d.length!==0&&(s=u(i(1),d),a=u())},f=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let d=0;const g=[];for(;d<t;){a=u();const h=a.slice();g.push(h),d+=a.length}return Je(...g)};return(d,g)=>{c(),p(d);let h;for(;!(h=g(f()));)p();return c(),h}}function Yr(e,t,n={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function r(i,a,s){const o=e[i];if(s&&o===void 0)return;const c=typeof o;if(c!==a||o===null)throw new Error(`param "${i}" is invalid: expected ${a}, got ${c}`)}Object.entries(t).forEach(([i,a])=>r(i,a,!1)),Object.entries(n).forEach(([i,a])=>r(i,a,!0))}function Ei(e){const t=new WeakMap;return(n,...r)=>{const i=t.get(n);if(i!==void 0)return i;const a=e(n,...r);return t.set(n,a),a}}const ku="#__bigint";function Cn(e,t,n){return JSON.stringify(e,(r,i)=>typeof i=="bigint"?i.toString()+ku:i,n)}function Au(e,t){if(It(e)>t)throw new $u({givenSize:It(e),maxSize:t})}function _u(e,t){if(typeof t=="number"&&t>0&&t>It(e)-1)throw new Xa({offset:t,position:"start",size:It(e)})}function Iu(e,t,n){if(typeof t=="number"&&typeof n=="number"&&It(e)!==n-t)throw new Xa({offset:n,position:"end",size:It(e)})}const Be={zero:48,nine:57,A:65,F:70,a:97,f:102};function Si(e){if(e>=Be.zero&&e<=Be.nine)return e-Be.zero;if(e>=Be.A&&e<=Be.F)return e-(Be.A-10);if(e>=Be.a&&e<=Be.f)return e-(Be.a-10)}function Jr(e,t){if(Xe(e)>t)throw new Nu({givenSize:Xe(e),maxSize:t})}function Ou(e,t){if(typeof t=="number"&&t>0&&t>Xe(e)-1)throw new Za({offset:t,position:"start",size:Xe(e)})}function Pu(e,t,n){if(typeof t=="number"&&typeof n=="number"&&Xe(e)!==n-t)throw new Za({offset:n,position:"end",size:Xe(e)})}function qa(e,t={}){const{dir:n,size:r=32}=t;if(r===0)return e;const i=e.replace("0x","");if(i.length>r*2)throw new Ru({size:Math.ceil(i.length/2),targetSize:r,type:"Hex"});return`0x${i[n==="right"?"padEnd":"padStart"](r*2,"0")}`}const Cu=new TextEncoder,Tu=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Bu(e,t={}){const{strict:n=!1}=t;if(!e)throw new ki(e);if(typeof e!="string")throw new ki(e);if(n&&!/^0x[0-9a-fA-F]*$/.test(e))throw new Ai(e);if(!e.startsWith("0x"))throw new Ai(e)}function Tn(...e){return`0x${e.reduce((t,n)=>t+n.replace("0x",""),"")}`}function Wa(e){return e instanceof Uint8Array?_t(e):Array.isArray(e)?_t(new Uint8Array(e)):e}function _t(e,t={}){let n="";for(let i=0;i<e.length;i++)n+=Tu[e[i]];const r=`0x${n}`;return typeof t.size=="number"?(Jr(r,t.size),Ka(r,t.size)):r}function Qe(e,t={}){const{signed:n,size:r}=t,i=BigInt(e);let a;r?n?a=(1n<<BigInt(r)*8n-1n)-1n:a=2n**(BigInt(r)*8n)-1n:typeof e=="number"&&(a=BigInt(Number.MAX_SAFE_INTEGER));const s=typeof a=="bigint"&&n?-a-1n:0;if(a&&i>a||i<s){const u=typeof e=="bigint"?"n":"";throw new Du({max:a?`${a}${u}`:void 0,min:`${s}${u}`,signed:n,size:r,value:`${e}${u}`})}const c=`0x${(n&&i<0?(1n<<BigInt(r*8))+BigInt(i):i).toString(16)}`;return r?Lu(c,r):c}function Va(e,t={}){return _t(Cu.encode(e),t)}function Lu(e,t){return qa(e,{dir:"left",size:t})}function Ka(e,t){return qa(e,{dir:"right",size:t})}function be(e,t,n,r={}){const{strict:i}=r;Ou(e,t);const a=`0x${e.replace("0x","").slice((t??0)*2,(n??e.length)*2)}`;return i&&Pu(a,t,n),a}function Xe(e){return Math.ceil((e.length-2)/2)}function ju(e,t={}){const{signed:n}=t;t.size&&Jr(e,t.size);const r=BigInt(e);if(!n)return r;const i=(e.length-2)/2,a=(1n<<BigInt(i)*8n)-1n,s=a>>1n;return r<=s?r:r-a-1n}function Mu(e,t={}){const{strict:n=!1}=t;try{return Bu(e,{strict:n}),!0}catch{return!1}}class Du extends ee{constructor({max:t,min:n,signed:r,size:i,value:a}){super(`Number \`${a}\` is not in safe${i?` ${i*8}-bit`:""}${r?" signed":" unsigned"} integer range ${t?`(\`${n}\` to \`${t}\`)`:`(above \`${n}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class ki extends ee{constructor(t){super(`Value \`${typeof t=="object"?Cn(t):t}\` of type \`${typeof t}\` is an invalid hex type.`,{metaMessages:['Hex types must be represented as `"0x${string}"`.']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexTypeError"})}}class Ai extends ee{constructor(t){super(`Value \`${t}\` is an invalid hex value.`,{metaMessages:['Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexValueError"})}}let Nu=class extends ee{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed \`${n}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}},Za=class extends ee{constructor({offset:t,position:n,size:r}){super(`Slice ${n==="start"?"starting":"ending"} at offset \`${t}\` is out-of-bounds (size: \`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}};class Ru extends ee{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}function Uu(e){if(!(e instanceof Uint8Array)){if(!e)throw new Vt(e);if(typeof e!="object")throw new Vt(e);if(!("BYTES_PER_ELEMENT"in e))throw new Vt(e);if(e.BYTES_PER_ELEMENT!==1||e.constructor.name!=="Uint8Array")throw new Vt(e)}}function Ya(e){return e instanceof Uint8Array?e:typeof e=="string"?Qa(e):Ja(e)}function Ja(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function Qa(e,t={}){const{size:n}=t;let r=e;n&&(Jr(e,n),r=Ka(e,n));let i=r.slice(2);i.length%2&&(i=`0${i}`);const a=i.length/2,s=new Uint8Array(a);for(let o=0,c=0;o<a;o++){const u=Si(i.charCodeAt(c++)),p=Si(i.charCodeAt(c++));if(u===void 0||p===void 0)throw new ee(`Invalid byte sequence ("${i[c-2]}${i[c-1]}" in "${i}").`);s[o]=u*16+p}return s}function It(e){return e.length}function _i(e,t,n,r={}){const{strict:i}=r;_u(e,t);const a=e.slice(t,n);return i&&Iu(a,t,n),a}function Ii(e,t={}){const{size:n}=t;typeof n<"u"&&Au(e,n);const r=_t(e,t);return ju(r,t)}function Hu(e){try{return Uu(e),!0}catch{return!1}}class Vt extends ee{constructor(t){super(`Value \`${typeof t=="object"?Cn(t):t}\` of type \`${typeof t}\` is an invalid Bytes value.`,{metaMessages:["Bytes values must be of type `Bytes`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesTypeError"})}}class $u extends ee{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed \`${n}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class Xa extends ee{constructor({offset:t,position:n,size:r}){super(`Slice ${n==="start"?"starting":"ending"} at offset \`${t}\` is out-of-bounds (size: \`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SliceOffsetOutOfBoundsError"})}}function es(e,t={}){const{as:n=typeof e=="string"?"Hex":"Bytes"}=t,r=gu(Ya(e));return n==="Bytes"?r:_t(r)}function ts(e,t={}){const{compressed:n}=t,{prefix:r,x:i,y:a}=e;if(n===!1||typeof i=="bigint"&&typeof a=="bigint"){if(r!==4)throw new Oi({prefix:r,cause:new Wu});return}if(n===!0||typeof i=="bigint"&&typeof a>"u"){if(r!==3&&r!==2)throw new Oi({prefix:r,cause:new qu});return}throw new zu({publicKey:e})}function Gu(e){const t=(()=>{if(Mu(e))return ns(e);if(Hu(e))return Fu(e);const{prefix:n,x:r,y:i}=e;return typeof r=="bigint"&&typeof i=="bigint"?{prefix:n??4,x:r,y:i}:{prefix:n,x:r}})();return ts(t),t}function Fu(e){return ns(_t(e))}function ns(e){if(e.length!==132&&e.length!==130&&e.length!==68)throw new Vu({publicKey:e});if(e.length===130){const r=BigInt(be(e,0,32)),i=BigInt(be(e,32,64));return{prefix:4,x:r,y:i}}if(e.length===132){const r=Number(be(e,0,1)),i=BigInt(be(e,1,33)),a=BigInt(be(e,33,65));return{prefix:r,x:i,y:a}}const t=Number(be(e,0,1)),n=BigInt(be(e,1,33));return{prefix:t,x:n}}function Qr(e,t={}){ts(e);const{prefix:n,x:r,y:i}=e,{includePrefix:a=!0}=t;return Tn(a?Qe(n,{size:1}):"0x",Qe(r,{size:32}),typeof i=="bigint"?Qe(i,{size:32}):"0x")}class zu extends ee{constructor({publicKey:t}){super(`Value \`${Cn(t)}\` is not a valid public key.`,{metaMessages:["Public key must contain:","- an `x` and `prefix` value (compressed)","- an `x`, `y`, and `prefix` value (uncompressed)"]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidError"})}}class Oi extends ee{constructor({prefix:t,cause:n}){super(`Prefix "${t}" is invalid.`,{cause:n}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidPrefixError"})}}class qu extends ee{constructor(){super("Prefix must be 2 or 3 for compressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidCompressedPrefixError"})}}class Wu extends ee{constructor(){super("Prefix must be 4 for uncompressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidUncompressedPrefixError"})}}let Vu=class extends ee{constructor({publicKey:t}){super(`Value \`${t}\` is an invalid public key size.`,{metaMessages:["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).",`Received ${Xe(Wa(t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidSerializedSizeError"})}};const Pi=2n**256n-1n;function Ku(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const i=BigInt(32),a=BigInt(4294967295),s=Number(n>>i&a),o=Number(n&a),c=r?4:0,u=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+u,o,r)}function Zu(e,t,n){return e&t^~e&n}function Yu(e,t,n){return e&t^e&n^t&n}let rs=class extends Ua{constructor(t,n,r,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(t),this.view=Rn(this.buffer)}update(t){xn(this),t=Wr(t),ut(t);const{view:n,buffer:r,blockLen:i}=this,a=t.length;for(let s=0;s<a;){const o=Math.min(i-this.pos,a-s);if(o===i){const c=Rn(t);for(;i<=a-s;s+=i)this.process(c,s);continue}r.set(t.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===i&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){xn(this),bu(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:i,isLE:a}=this;let{pos:s}=this;n[s++]=128,At(this.buffer.subarray(s)),this.padOffset>i-s&&(this.process(r,0),s=0);for(let f=s;f<i;f++)n[f]=0;Ku(r,i-8,BigInt(this.length*8),a),this.process(r,0);const o=Rn(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,p=this.get();if(u>p.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<u;f++)o.setUint32(4*f,p[f],a)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:i,finished:a,destroyed:s,pos:o}=this;return t.destroyed=s,t.finished=a,t.length=i,t.pos=o,i%n&&t.buffer.set(r),t}clone(){return this._cloneInto()}};const Fe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),se=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),oe=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Kt=BigInt(2**32-1),Ci=BigInt(32);function Ju(e,t=!1){return t?{h:Number(e&Kt),l:Number(e>>Ci&Kt)}:{h:Number(e>>Ci&Kt)|0,l:Number(e&Kt)|0}}function Qu(e,t=!1){const n=e.length;let r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){const{h:s,l:o}=Ju(e[a],t);[r[a],i[a]]=[s,o]}return[r,i]}const Ti=(e,t,n)=>e>>>n,Bi=(e,t,n)=>e<<32-n|t>>>n,ft=(e,t,n)=>e>>>n|t<<32-n,pt=(e,t,n)=>e<<32-n|t>>>n,Zt=(e,t,n)=>e<<64-n|t>>>n-32,Yt=(e,t,n)=>e>>>n-32|t<<64-n;function Le(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}const Xu=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),ed=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,td=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),nd=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,rd=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),id=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0,ad=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ze=new Uint32Array(64);let sd=class extends rs{constructor(t=32){super(64,t,8,!1),this.A=Fe[0]|0,this.B=Fe[1]|0,this.C=Fe[2]|0,this.D=Fe[3]|0,this.E=Fe[4]|0,this.F=Fe[5]|0,this.G=Fe[6]|0,this.H=Fe[7]|0}get(){const{A:t,B:n,C:r,D:i,E:a,F:s,G:o,H:c}=this;return[t,n,r,i,a,s,o,c]}set(t,n,r,i,a,s,o,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=i|0,this.E=a|0,this.F=s|0,this.G=o|0,this.H=c|0}process(t,n){for(let f=0;f<16;f++,n+=4)ze[f]=t.getUint32(n,!1);for(let f=16;f<64;f++){const l=ze[f-15],d=ze[f-2],g=Ae(l,7)^Ae(l,18)^l>>>3,h=Ae(d,17)^Ae(d,19)^d>>>10;ze[f]=h+ze[f-7]+g+ze[f-16]|0}let{A:r,B:i,C:a,D:s,E:o,F:c,G:u,H:p}=this;for(let f=0;f<64;f++){const l=Ae(o,6)^Ae(o,11)^Ae(o,25),d=p+l+Zu(o,c,u)+ad[f]+ze[f]|0,h=(Ae(r,2)^Ae(r,13)^Ae(r,22))+Yu(r,i,a)|0;p=u,u=c,c=o,o=s+d|0,s=a,a=i,i=r,r=d+h|0}r=r+this.A|0,i=i+this.B|0,a=a+this.C|0,s=s+this.D|0,o=o+this.E|0,c=c+this.F|0,u=u+this.G|0,p=p+this.H|0,this.set(r,i,a,s,o,c,u,p)}roundClean(){At(ze)}destroy(){this.set(0,0,0,0,0,0,0,0),At(this.buffer)}};const is=Qu(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),od=is[0],cd=is[1],qe=new Uint32Array(80),We=new Uint32Array(80);class as extends rs{constructor(t=64){super(128,t,16,!1),this.Ah=oe[0]|0,this.Al=oe[1]|0,this.Bh=oe[2]|0,this.Bl=oe[3]|0,this.Ch=oe[4]|0,this.Cl=oe[5]|0,this.Dh=oe[6]|0,this.Dl=oe[7]|0,this.Eh=oe[8]|0,this.El=oe[9]|0,this.Fh=oe[10]|0,this.Fl=oe[11]|0,this.Gh=oe[12]|0,this.Gl=oe[13]|0,this.Hh=oe[14]|0,this.Hl=oe[15]|0}get(){const{Ah:t,Al:n,Bh:r,Bl:i,Ch:a,Cl:s,Dh:o,Dl:c,Eh:u,El:p,Fh:f,Fl:l,Gh:d,Gl:g,Hh:h,Hl:v}=this;return[t,n,r,i,a,s,o,c,u,p,f,l,d,g,h,v]}set(t,n,r,i,a,s,o,c,u,p,f,l,d,g,h,v){this.Ah=t|0,this.Al=n|0,this.Bh=r|0,this.Bl=i|0,this.Ch=a|0,this.Cl=s|0,this.Dh=o|0,this.Dl=c|0,this.Eh=u|0,this.El=p|0,this.Fh=f|0,this.Fl=l|0,this.Gh=d|0,this.Gl=g|0,this.Hh=h|0,this.Hl=v|0}process(t,n){for(let x=0;x<16;x++,n+=4)qe[x]=t.getUint32(n),We[x]=t.getUint32(n+=4);for(let x=16;x<80;x++){const I=qe[x-15]|0,D=We[x-15]|0,T=ft(I,D,1)^ft(I,D,8)^Ti(I,D,7),G=pt(I,D,1)^pt(I,D,8)^Bi(I,D,7),K=qe[x-2]|0,j=We[x-2]|0,we=ft(K,j,19)^Zt(K,j,61)^Ti(K,j,6),fe=pt(K,j,19)^Yt(K,j,61)^Bi(K,j,6),b=td(G,fe,We[x-7],We[x-16]),m=nd(b,T,we,qe[x-7],qe[x-16]);qe[x]=m|0,We[x]=b|0}let{Ah:r,Al:i,Bh:a,Bl:s,Ch:o,Cl:c,Dh:u,Dl:p,Eh:f,El:l,Fh:d,Fl:g,Gh:h,Gl:v,Hh:k,Hl:P}=this;for(let x=0;x<80;x++){const I=ft(f,l,14)^ft(f,l,18)^Zt(f,l,41),D=pt(f,l,14)^pt(f,l,18)^Yt(f,l,41),T=f&d^~f&h,G=l&g^~l&v,K=rd(P,D,G,cd[x],We[x]),j=id(K,k,I,T,od[x],qe[x]),we=K|0,fe=ft(r,i,28)^Zt(r,i,34)^Zt(r,i,39),b=pt(r,i,28)^Yt(r,i,34)^Yt(r,i,39),m=r&a^r&o^a&o,w=i&s^i&c^s&c;k=h|0,P=v|0,h=d|0,v=g|0,d=f|0,g=l|0,{h:f,l}=Le(u|0,p|0,j|0,we|0),u=o|0,p=c|0,o=a|0,c=s|0,a=r|0,s=i|0;const y=Xu(we,b,w);r=ed(y,j,fe,m),i=y|0}({h:r,l:i}=Le(this.Ah|0,this.Al|0,r|0,i|0)),{h:a,l:s}=Le(this.Bh|0,this.Bl|0,a|0,s|0),{h:o,l:c}=Le(this.Ch|0,this.Cl|0,o|0,c|0),{h:u,l:p}=Le(this.Dh|0,this.Dl|0,u|0,p|0),{h:f,l}=Le(this.Eh|0,this.El|0,f|0,l|0),{h:d,l:g}=Le(this.Fh|0,this.Fl|0,d|0,g|0),{h,l:v}=Le(this.Gh|0,this.Gl|0,h|0,v|0),{h:k,l:P}=Le(this.Hh|0,this.Hl|0,k|0,P|0),this.set(r,i,a,s,o,c,u,p,f,l,d,g,h,v,k,P)}roundClean(){At(qe,We)}destroy(){At(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class ud extends as{constructor(){super(48),this.Ah=se[0]|0,this.Al=se[1]|0,this.Bh=se[2]|0,this.Bl=se[3]|0,this.Ch=se[4]|0,this.Cl=se[5]|0,this.Dh=se[6]|0,this.Dl=se[7]|0,this.Eh=se[8]|0,this.El=se[9]|0,this.Fh=se[10]|0,this.Fl=se[11]|0,this.Gh=se[12]|0,this.Gl=se[13]|0,this.Hh=se[14]|0,this.Hl=se[15]|0}}const dd=Vr(()=>new sd),ld=Vr(()=>new as),fd=Vr(()=>new ud);class ss extends Ua{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,Na(t);const r=Wr(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,a=new Uint8Array(i);a.set(r.length>i?t.create().update(r).digest():r);for(let s=0;s<a.length;s++)a[s]^=54;this.iHash.update(a),this.oHash=t.create();for(let s=0;s<a.length;s++)a[s]^=106;this.oHash.update(a),At(a)}update(t){return xn(this),this.iHash.update(t),this}digestInto(t){xn(this),ut(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:i,destroyed:a,blockLen:s,outputLen:o}=this;return t=t,t.finished=i,t.destroyed=a,t.blockLen=s,t.outputLen=o,t.oHash=n._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const os=(e,t,n)=>new ss(e,t).update(n).digest();os.create=(e,t)=>new ss(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const he=BigInt(0),ue=BigInt(1),st=BigInt(2),cs=BigInt(3),us=BigInt(4),ds=BigInt(5),pd=BigInt(7),ls=BigInt(8),hd=BigInt(9),fs=BigInt(16);function xe(e,t){const n=e%t;return n>=he?n:t+n}function Li(e,t){if(e===he)throw new Error("invert: expected non-zero number");if(t<=he)throw new Error("invert: expected positive modulus, got "+t);let n=xe(e,t),r=t,i=he,a=ue;for(;n!==he;){const o=r/n,c=r%n,u=i-a*o;r=n,n=c,i=a,a=u}if(r!==ue)throw new Error("invert: does not exist");return xe(i,t)}function Xr(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function ps(e,t){const n=(e.ORDER+ue)/us,r=e.pow(t,n);return Xr(e,r,t),r}function md(e,t){const n=(e.ORDER-ds)/ls,r=e.mul(t,st),i=e.pow(r,n),a=e.mul(t,i),s=e.mul(e.mul(a,st),i),o=e.mul(a,e.sub(s,e.ONE));return Xr(e,o,t),o}function yd(e){const t=dt(e),n=hs(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),s=(e+pd)/fs;return(o,c)=>{let u=o.pow(c,s),p=o.mul(u,r);const f=o.mul(u,i),l=o.mul(u,a),d=o.eql(o.sqr(p),c),g=o.eql(o.sqr(f),c);u=o.cmov(u,p,d),p=o.cmov(l,f,g);const h=o.eql(o.sqr(p),c),v=o.cmov(u,p,h);return Xr(o,v,c),v}}function hs(e){if(e<cs)throw new Error("sqrt is not defined for small field");let t=e-ue,n=0;for(;t%st===he;)t/=st,n++;let r=st;const i=dt(e);for(;ji(i,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return ps;let a=i.pow(r,t);const s=(t+ue)/st;return function(c,u){if(c.is0(u))return u;if(ji(c,u)!==1)throw new Error("Cannot find square root");let p=n,f=c.mul(c.ONE,a),l=c.pow(u,t),d=c.pow(u,s);for(;!c.eql(l,c.ONE);){if(c.is0(l))return c.ZERO;let g=1,h=c.sqr(l);for(;!c.eql(h,c.ONE);)if(g++,h=c.sqr(h),g===p)throw new Error("Cannot find square root");const v=ue<<BigInt(p-g-1),k=c.pow(f,v);p=g,f=c.sqr(k),l=c.mul(l,f),d=c.mul(d,k)}return d}}function gd(e){return e%us===cs?ps:e%ls===ds?md:e%fs===hd?yd(e):hs(e)}const bd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function wd(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=bd.reduce((r,i)=>(r[i]="function",r),t);return Yr(e,n),e}function vd(e,t,n){if(n<he)throw new Error("invalid exponent, negatives unsupported");if(n===he)return e.ONE;if(n===ue)return t;let r=e.ONE,i=t;for(;n>he;)n&ue&&(r=e.mul(r,i)),i=e.sqr(i),n>>=ue;return r}function ms(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),i=t.reduce((s,o,c)=>e.is0(o)?s:(r[c]=s,e.mul(s,o)),e.ONE),a=e.inv(i);return t.reduceRight((s,o,c)=>e.is0(o)?s:(r[c]=e.mul(s,r[c]),e.mul(s,o)),a),r}function ji(e,t){const n=(e.ORDER-ue)/st,r=e.pow(t,n),i=e.eql(r,e.ONE),a=e.eql(r,e.ZERO),s=e.eql(r,e.neg(e.ONE));if(!i&&!a&&!s)throw new Error("invalid Legendre symbol result");return i?1:a?0:-1}function ys(e,t){t!==void 0&&Cr(t);const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function dt(e,t,n=!1,r={}){if(e<=he)throw new Error("invalid field: expected ORDER > 0, got "+e);let i,a,s=!1,o;if(typeof t=="object"&&t!=null){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const l=t;l.BITS&&(i=l.BITS),l.sqrt&&(a=l.sqrt),typeof l.isLE=="boolean"&&(n=l.isLE),typeof l.modFromBytes=="boolean"&&(s=l.modFromBytes),o=l.allowedLengths}else typeof t=="number"&&(i=t),r.sqrt&&(a=r.sqrt);const{nBitLength:c,nByteLength:u}=ys(e,i);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let p;const f=Object.freeze({ORDER:e,isLE:n,BITS:c,BYTES:u,MASK:Ft(c),ZERO:he,ONE:ue,allowedLengths:o,create:l=>xe(l,e),isValid:l=>{if(typeof l!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof l);return he<=l&&l<e},is0:l=>l===he,isValidNot0:l=>!f.is0(l)&&f.isValid(l),isOdd:l=>(l&ue)===ue,neg:l=>xe(-l,e),eql:(l,d)=>l===d,sqr:l=>xe(l*l,e),add:(l,d)=>xe(l+d,e),sub:(l,d)=>xe(l-d,e),mul:(l,d)=>xe(l*d,e),pow:(l,d)=>vd(f,l,d),div:(l,d)=>xe(l*Li(d,e),e),sqrN:l=>l*l,addN:(l,d)=>l+d,subN:(l,d)=>l-d,mulN:(l,d)=>l*d,inv:l=>Li(l,e),sqrt:a||(l=>(p||(p=gd(e)),p(f,l))),toBytes:l=>n?Fa(l,u):Zr(l,u),fromBytes:(l,d=!0)=>{if(o){if(!o.includes(l.length)||l.length>u)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+l.length);const h=new Uint8Array(u);h.set(l,n?0:h.length-l.length),l=h}if(l.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+l.length);let g=n?Ga(l):Pn(l);if(s&&(g=xe(g,e)),!d&&!f.isValid(g))throw new Error("invalid field element: outside of range 0..ORDER");return g},invertBatch:l=>ms(f,l),cmov:(l,d,g)=>g?d:l});return Object.freeze(f)}function gs(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function bs(e){const t=gs(e);return t+Math.ceil(t/2)}function xd(e,t,n=!1){const r=e.length,i=gs(t),a=bs(t);if(r<16||r<a||r>1024)throw new Error("expected "+a+"-1024 bytes of input, got "+r);const s=n?Ga(e):Pn(e),o=xe(s,t-ue)+ue;return n?Fa(o,i):Zr(o,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ot=BigInt(0),ot=BigInt(1);function kn(e,t){const n=t.negate();return e?n:t}function Hn(e,t){const n=ms(e.Fp,t.map(r=>r.Z));return t.map((r,i)=>e.fromAffine(r.toAffine(n[i])))}function ws(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function $n(e,t){ws(e,t);const n=Math.ceil(t/e)+1,r=2**(e-1),i=2**e,a=Ft(e),s=BigInt(e);return{windows:n,windowSize:r,mask:a,maxNumber:i,shiftBy:s}}function Mi(e,t,n){const{windowSize:r,mask:i,maxNumber:a,shiftBy:s}=n;let o=Number(e&i),c=e>>s;o>r&&(o-=a,c+=ot);const u=t*r,p=u+Math.abs(o)-1,f=o===0,l=o<0,d=t%2!==0;return{nextN:c,offset:p,isZero:f,isNeg:l,isNegF:d,offsetF:u}}function Ed(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((n,r)=>{if(!(n instanceof t))throw new Error("invalid point at index "+r)})}function Sd(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,r)=>{if(!t.isValid(n))throw new Error("invalid scalar at index "+r)})}const Gn=new WeakMap,vs=new WeakMap;function Fn(e){return vs.get(e)||1}function Di(e){if(e!==Ot)throw new Error("invalid wNAF")}class kd{constructor(t,n){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=n}_unsafeLadder(t,n,r=this.ZERO){let i=t;for(;n>Ot;)n&ot&&(r=r.add(i)),i=i.double(),n>>=ot;return r}precomputeWindow(t,n){const{windows:r,windowSize:i}=$n(n,this.bits),a=[];let s=t,o=s;for(let c=0;c<r;c++){o=s,a.push(o);for(let u=1;u<i;u++)o=o.add(s),a.push(o);s=o.double()}return a}wNAF(t,n,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let i=this.ZERO,a=this.BASE;const s=$n(t,this.bits);for(let o=0;o<s.windows;o++){const{nextN:c,offset:u,isZero:p,isNeg:f,isNegF:l,offsetF:d}=Mi(r,o,s);r=c,p?a=a.add(kn(l,n[d])):i=i.add(kn(f,n[u]))}return Di(r),{p:i,f:a}}wNAFUnsafe(t,n,r,i=this.ZERO){const a=$n(t,this.bits);for(let s=0;s<a.windows&&r!==Ot;s++){const{nextN:o,offset:c,isZero:u,isNeg:p}=Mi(r,s,a);if(r=o,!u){const f=n[c];i=i.add(p?f.negate():f)}}return Di(r),i}getPrecomputes(t,n,r){let i=Gn.get(n);return i||(i=this.precomputeWindow(n,t),t!==1&&(typeof r=="function"&&(i=r(i)),Gn.set(n,i))),i}cached(t,n,r){const i=Fn(t);return this.wNAF(i,this.getPrecomputes(i,t,r),n)}unsafe(t,n,r,i){const a=Fn(t);return a===1?this._unsafeLadder(t,n,i):this.wNAFUnsafe(a,this.getPrecomputes(a,t,r),n,i)}createCache(t,n){ws(n,this.bits),vs.set(t,n),Gn.delete(t)}hasCache(t){return Fn(t)!==1}}function Ad(e,t,n,r){let i=t,a=e.ZERO,s=e.ZERO;for(;n>Ot||r>Ot;)n&ot&&(a=a.add(i)),r&ot&&(s=s.add(i)),i=i.double(),n>>=ot,r>>=ot;return{p1:a,p2:s}}function _d(e,t,n,r){Ed(n,e),Sd(r,t);const i=n.length,a=r.length;if(i!==a)throw new Error("arrays of points and scalars must have equal length");const s=e.ZERO,o=za(BigInt(i));let c=1;o>12?c=o-3:o>4?c=o-2:o>0&&(c=2);const u=Ft(c),p=new Array(Number(u)+1).fill(s),f=Math.floor((t.BITS-1)/c)*c;let l=s;for(let d=f;d>=0;d-=c){p.fill(s);for(let h=0;h<a;h++){const v=r[h],k=Number(v>>BigInt(d)&u);p[k]=p[k].add(n[h])}let g=s;for(let h=p.length-1,v=s;h>0;h--)v=v.add(p[h]),g=g.add(v);if(l=l.add(g),d!==0)for(let h=0;h<c;h++)l=l.double()}return l}function Ni(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return wd(t),t}else return dt(e,{isLE:n})}function Id(e,t,n={},r){if(r===void 0&&(r=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(const c of["p","n","h"]){const u=t[c];if(!(typeof u=="bigint"&&u>Ot))throw new Error(`CURVE.${c} must be positive bigint`)}const i=Ni(t.p,n.Fp,r),a=Ni(t.n,n.Fn,r),o=["Gx","Gy","a","b"];for(const c of o)if(!i.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:a}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ri=(e,t)=>(e+(e>=0?t:-t)/xs)/t;function Od(e,t,n){const[[r,i],[a,s]]=t,o=Ri(s*e,n),c=Ri(-i*e,n);let u=e-o*r-c*a,p=-o*i-c*s;const f=u<Ue,l=p<Ue;f&&(u=-u),l&&(p=-p);const d=Ft(Math.ceil(za(n)/2))+vt;if(u<Ue||u>=d||p<Ue||p>=d)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:u,k2neg:l,k2:p}}function Br(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function zn(e,t){const n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return Sn(n.lowS,"lowS"),Sn(n.prehash,"prehash"),n.format!==void 0&&Br(n.format),n}class Pd extends Error{constructor(t=""){super(t)}}const Me={Err:Pd,_tlv:{encode:(e,t)=>{const{Err:n}=Me;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length&1)throw new n("tlv.encode: unpadded data");const r=t.length/2,i=Wt(r);if(i.length/2&128)throw new n("tlv.encode: long form length too big");const a=r>127?Wt(i.length/2|128):"";return Wt(e)+a+i+t},decode(e,t){const{Err:n}=Me;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const i=t[r++],a=!!(i&128);let s=0;if(!a)s=i;else{const c=i&127;if(!c)throw new n("tlv.decode(long): indefinite length not supported");if(c>4)throw new n("tlv.decode(long): byte length is too big");const u=t.subarray(r,r+c);if(u.length!==c)throw new n("tlv.decode: length bytes not complete");if(u[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const p of u)s=s<<8|p;if(r+=c,s<128)throw new n("tlv.decode(long): not minimal encoding")}const o=t.subarray(r,r+s);if(o.length!==s)throw new n("tlv.decode: wrong value length");return{v:o,l:t.subarray(r+s)}}},_int:{encode(e){const{Err:t}=Me;if(e<Ue)throw new t("integer: negative integers are not allowed");let n=Wt(e);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=Me;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Pn(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=Me,i=le("signature",e),{v:a,l:s}=r.decode(48,i);if(s.length)throw new t("invalid signature: left bytes after parsing");const{v:o,l:c}=r.decode(2,a),{v:u,l:p}=r.decode(2,c);if(p.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(o),s:n.decode(u)}},hexFromSig(e){const{_tlv:t,_int:n}=Me,r=t.encode(2,n.encode(e.r)),i=t.encode(2,n.encode(e.s)),a=r+i;return t.encode(48,a)}},Ue=BigInt(0),vt=BigInt(1),xs=BigInt(2),Jt=BigInt(3),Cd=BigInt(4);function yt(e,t){const{BYTES:n}=e;let r;if(typeof t=="bigint")r=t;else{let i=le("private key",t);try{r=e.fromBytes(i)}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function Td(e,t={}){const n=Id("weierstrass",e,t),{Fp:r,Fn:i}=n;let a=n.CURVE;const{h:s,n:o}=a;Yr(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:c}=t;if(c&&(!r.is0(a.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const u=Ss(r,i);function p(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function f(b,m,w){const{x:y,y:E}=m.toAffine(),_=r.toBytes(y);if(Sn(w,"isCompressed"),w){p();const B=!r.isOdd(E);return Je(Es(B),_)}else return Je(Uint8Array.of(4),_,r.toBytes(E))}function l(b){at(b,void 0,"Point");const{publicKey:m,publicKeyUncompressed:w}=u,y=b.length,E=b[0],_=b.subarray(1);if(y===m&&(E===2||E===3)){const B=r.fromBytes(_);if(!r.isValid(B))throw new Error("bad point: is not on curve, wrong x");const C=h(B);let O;try{O=r.sqrt(C)}catch(te){const V=te instanceof Error?": "+te.message:"";throw new Error("bad point: is not on curve, sqrt error"+V)}p();const M=r.isOdd(O);return(E&1)===1!==M&&(O=r.neg(O)),{x:B,y:O}}else if(y===w&&E===4){const B=r.BYTES,C=r.fromBytes(_.subarray(0,B)),O=r.fromBytes(_.subarray(B,B*2));if(!v(C,O))throw new Error("bad point: is not on curve");return{x:C,y:O}}else throw new Error(`bad point: got length ${y}, expected compressed=${m} or uncompressed=${w}`)}const d=t.toBytes||f,g=t.fromBytes||l;function h(b){const m=r.sqr(b),w=r.mul(m,b);return r.add(r.add(w,r.mul(b,a.a)),a.b)}function v(b,m){const w=r.sqr(m),y=h(b);return r.eql(w,y)}if(!v(a.Gx,a.Gy))throw new Error("bad curve params: generator point");const k=r.mul(r.pow(a.a,Jt),Cd),P=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(k,P)))throw new Error("bad curve params: a or b");function x(b,m,w=!1){if(!r.isValid(m)||w&&r.is0(m))throw new Error(`bad point coordinate ${b}`);return m}function I(b){if(!(b instanceof j))throw new Error("ProjectivePoint expected")}function D(b){if(!c||!c.basises)throw new Error("no endo");return Od(b,c.basises,i.ORDER)}const T=Ei((b,m)=>{const{X:w,Y:y,Z:E}=b;if(r.eql(E,r.ONE))return{x:w,y};const _=b.is0();m==null&&(m=_?r.ONE:r.inv(E));const B=r.mul(w,m),C=r.mul(y,m),O=r.mul(E,m);if(_)return{x:r.ZERO,y:r.ZERO};if(!r.eql(O,r.ONE))throw new Error("invZ was invalid");return{x:B,y:C}}),G=Ei(b=>{if(b.is0()){if(t.allowInfinityPoint&&!r.is0(b.Y))return;throw new Error("bad point: ZERO")}const{x:m,y:w}=b.toAffine();if(!r.isValid(m)||!r.isValid(w))throw new Error("bad point: x or y not field elements");if(!v(m,w))throw new Error("bad point: equation left != right");if(!b.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function K(b,m,w,y,E){return w=new j(r.mul(w.X,b),w.Y,w.Z),m=kn(y,m),w=kn(E,w),m.add(w)}class j{constructor(m,w,y){this.X=x("x",m),this.Y=x("y",w,!0),this.Z=x("z",y),Object.freeze(this)}static CURVE(){return a}static fromAffine(m){const{x:w,y}=m||{};if(!m||!r.isValid(w)||!r.isValid(y))throw new Error("invalid affine point");if(m instanceof j)throw new Error("projective point not allowed");return r.is0(w)&&r.is0(y)?j.ZERO:new j(w,y,r.ONE)}static fromBytes(m){const w=j.fromAffine(g(at(m,void 0,"point")));return w.assertValidity(),w}static fromHex(m){return j.fromBytes(le("pointHex",m))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(m=8,w=!0){return fe.createCache(this,m),w||this.multiply(Jt),this}assertValidity(){G(this)}hasEvenY(){const{y:m}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(m)}equals(m){I(m);const{X:w,Y:y,Z:E}=this,{X:_,Y:B,Z:C}=m,O=r.eql(r.mul(w,C),r.mul(_,E)),M=r.eql(r.mul(y,C),r.mul(B,E));return O&&M}negate(){return new j(this.X,r.neg(this.Y),this.Z)}double(){const{a:m,b:w}=a,y=r.mul(w,Jt),{X:E,Y:_,Z:B}=this;let C=r.ZERO,O=r.ZERO,M=r.ZERO,R=r.mul(E,E),te=r.mul(_,_),V=r.mul(B,B),z=r.mul(E,_);return z=r.add(z,z),M=r.mul(E,B),M=r.add(M,M),C=r.mul(m,M),O=r.mul(y,V),O=r.add(C,O),C=r.sub(te,O),O=r.add(te,O),O=r.mul(C,O),C=r.mul(z,C),M=r.mul(y,M),V=r.mul(m,V),z=r.sub(R,V),z=r.mul(m,z),z=r.add(z,M),M=r.add(R,R),R=r.add(M,R),R=r.add(R,V),R=r.mul(R,z),O=r.add(O,R),V=r.mul(_,B),V=r.add(V,V),R=r.mul(V,z),C=r.sub(C,R),M=r.mul(V,te),M=r.add(M,M),M=r.add(M,M),new j(C,O,M)}add(m){I(m);const{X:w,Y:y,Z:E}=this,{X:_,Y:B,Z:C}=m;let O=r.ZERO,M=r.ZERO,R=r.ZERO;const te=a.a,V=r.mul(a.b,Jt);let z=r.mul(w,_),Z=r.mul(y,B),ne=r.mul(E,C),de=r.add(w,y),Y=r.add(_,B);de=r.mul(de,Y),Y=r.add(z,Z),de=r.sub(de,Y),Y=r.add(w,E);let ae=r.add(_,C);return Y=r.mul(Y,ae),ae=r.add(z,ne),Y=r.sub(Y,ae),ae=r.add(y,E),O=r.add(B,C),ae=r.mul(ae,O),O=r.add(Z,ne),ae=r.sub(ae,O),R=r.mul(te,Y),O=r.mul(V,ne),R=r.add(O,R),O=r.sub(Z,R),R=r.add(Z,R),M=r.mul(O,R),Z=r.add(z,z),Z=r.add(Z,z),ne=r.mul(te,ne),Y=r.mul(V,Y),Z=r.add(Z,ne),ne=r.sub(z,ne),ne=r.mul(te,ne),Y=r.add(Y,ne),z=r.mul(Z,Y),M=r.add(M,z),z=r.mul(ae,Y),O=r.mul(de,O),O=r.sub(O,z),z=r.mul(de,Z),R=r.mul(ae,R),R=r.add(R,z),new j(O,M,R)}subtract(m){return this.add(m.negate())}is0(){return this.equals(j.ZERO)}multiply(m){const{endo:w}=t;if(!i.isValidNot0(m))throw new Error("invalid scalar: out of range");let y,E;const _=B=>fe.cached(this,B,C=>Hn(j,C));if(w){const{k1neg:B,k1:C,k2neg:O,k2:M}=D(m),{p:R,f:te}=_(C),{p:V,f:z}=_(M);E=te.add(z),y=K(w.beta,R,V,B,O)}else{const{p:B,f:C}=_(m);y=B,E=C}return Hn(j,[y,E])[0]}multiplyUnsafe(m){const{endo:w}=t,y=this;if(!i.isValid(m))throw new Error("invalid scalar: out of range");if(m===Ue||y.is0())return j.ZERO;if(m===vt)return y;if(fe.hasCache(this))return this.multiply(m);if(w){const{k1neg:E,k1:_,k2neg:B,k2:C}=D(m),{p1:O,p2:M}=Ad(j,y,_,C);return K(w.beta,O,M,E,B)}else return fe.unsafe(y,m)}multiplyAndAddUnsafe(m,w,y){const E=this.multiplyUnsafe(w).add(m.multiplyUnsafe(y));return E.is0()?void 0:E}toAffine(m){return T(this,m)}isTorsionFree(){const{isTorsionFree:m}=t;return s===vt?!0:m?m(j,this):fe.unsafe(this,o).is0()}clearCofactor(){const{clearCofactor:m}=t;return s===vt?this:m?m(j,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(m=!0){return Sn(m,"isCompressed"),this.assertValidity(),d(j,this,m)}toHex(m=!0){return wt(this.toBytes(m))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(m=!0){return this.toBytes(m)}_setWindowSize(m){this.precompute(m)}static normalizeZ(m){return Hn(j,m)}static msm(m,w){return _d(j,i,m,w)}static fromPrivateKey(m){return j.BASE.multiply(yt(i,m))}}j.BASE=new j(a.Gx,a.Gy,r.ONE),j.ZERO=new j(r.ZERO,r.ONE,r.ZERO),j.Fp=r,j.Fn=i;const we=i.BITS,fe=new kd(j,t.endo?Math.ceil(we/2):we);return j.BASE.precompute(8),j}function Es(e){return Uint8Array.of(e?2:3)}function Ss(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Bd(e,t={}){const{Fn:n}=e,r=t.randomBytes||Ha,i=Object.assign(Ss(e.Fp,n),{seed:bs(n.ORDER)});function a(d){try{return!!yt(n,d)}catch{return!1}}function s(d,g){const{publicKey:h,publicKeyUncompressed:v}=i;try{const k=d.length;return g===!0&&k!==h||g===!1&&k!==v?!1:!!e.fromBytes(d)}catch{return!1}}function o(d=r(i.seed)){return xd(at(d,i.seed,"seed"),n.ORDER)}function c(d,g=!0){return e.BASE.multiply(yt(n,d)).toBytes(g)}function u(d){const g=o(d);return{secretKey:g,publicKey:c(g)}}function p(d){if(typeof d=="bigint")return!1;if(d instanceof e)return!0;const{secretKey:g,publicKey:h,publicKeyUncompressed:v}=i;if(n.allowedLengths||g===h)return;const k=le("key",d).length;return k===h||k===v}function f(d,g,h=!0){if(p(d)===!0)throw new Error("first arg must be private key");if(p(g)===!1)throw new Error("second arg must be public key");const v=yt(n,d);return e.fromHex(g).multiply(v).toBytes(h)}return Object.freeze({getPublicKey:c,getSharedSecret:f,keygen:u,Point:e,utils:{isValidSecretKey:a,isValidPublicKey:s,randomSecretKey:o,isValidPrivateKey:a,randomPrivateKey:o,normPrivateKeyToScalar:d=>yt(n,d),precompute(d=8,g=e.BASE){return g.precompute(d,!1)}},lengths:i})}function Ld(e,t,n={}){Na(t),Yr(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||Ha,i=n.hmac||((w,...y)=>os(t,w,Je(...y))),{Fp:a,Fn:s}=e,{ORDER:o,BITS:c}=s,{keygen:u,getPublicKey:p,getSharedSecret:f,utils:l,lengths:d}=Bd(e,n),g={prehash:!1,lowS:typeof n.lowS=="boolean"?n.lowS:!1,format:void 0,extraEntropy:!1},h="compact";function v(w){const y=o>>vt;return w>y}function k(w,y){if(!s.isValidNot0(y))throw new Error(`invalid signature ${w}: out of range 1..Point.Fn.ORDER`);return y}function P(w,y){Br(y);const E=d.signature,_=y==="compact"?E:y==="recovered"?E+1:void 0;return at(w,_,`${y} signature`)}class x{constructor(y,E,_){this.r=k("r",y),this.s=k("s",E),_!=null&&(this.recovery=_),Object.freeze(this)}static fromBytes(y,E=h){P(y,E);let _;if(E==="der"){const{r:M,s:R}=Me.toSig(at(y));return new x(M,R)}E==="recovered"&&(_=y[0],E="compact",y=y.subarray(1));const B=s.BYTES,C=y.subarray(0,B),O=y.subarray(B,B*2);return new x(s.fromBytes(C),s.fromBytes(O),_)}static fromHex(y,E){return this.fromBytes(En(y),E)}addRecoveryBit(y){return new x(this.r,this.s,y)}recoverPublicKey(y){const E=a.ORDER,{r:_,s:B,recovery:C}=this;if(C==null||![0,1,2,3].includes(C))throw new Error("recovery id invalid");if(o*xs<E&&C>1)throw new Error("recovery id is ambiguous for h>1 curve");const M=C===2||C===3?_+o:_;if(!a.isValid(M))throw new Error("recovery id 2 or 3 invalid");const R=a.toBytes(M),te=e.fromBytes(Je(Es((C&1)===0),R)),V=s.inv(M),z=D(le("msgHash",y)),Z=s.create(-z*V),ne=s.create(B*V),de=e.BASE.multiplyUnsafe(Z).add(te.multiplyUnsafe(ne));if(de.is0())throw new Error("point at infinify");return de.assertValidity(),de}hasHighS(){return v(this.s)}toBytes(y=h){if(Br(y),y==="der")return En(Me.hexFromSig(this));const E=s.toBytes(this.r),_=s.toBytes(this.s);if(y==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return Je(Uint8Array.of(this.recovery),E,_)}return Je(E,_)}toHex(y){return wt(this.toBytes(y))}assertValidity(){}static fromCompact(y){return x.fromBytes(le("sig",y),"compact")}static fromDER(y){return x.fromBytes(le("sig",y),"der")}normalizeS(){return this.hasHighS()?new x(this.r,s.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return wt(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return wt(this.toBytes("compact"))}}const I=n.bits2int||function(y){if(y.length>8192)throw new Error("input is too large");const E=Pn(y),_=y.length*8-c;return _>0?E>>BigInt(_):E},D=n.bits2int_modN||function(y){return s.create(I(y))},T=Ft(c);function G(w){return Eu("num < 2^"+c,w,Ue,T),s.toBytes(w)}function K(w,y){return at(w,void 0,"message"),y?at(t(w),void 0,"prehashed message"):w}function j(w,y,E){if(["recovered","canonical"].some(Z=>Z in E))throw new Error("sign() legacy options not supported");const{lowS:_,prehash:B,extraEntropy:C}=zn(E,g);w=K(w,B);const O=D(w),M=yt(s,y),R=[G(M),G(O)];if(C!=null&&C!==!1){const Z=C===!0?r(d.secretKey):C;R.push(le("extraEntropy",Z))}const te=Je(...R),V=O;function z(Z){const ne=I(Z);if(!s.isValidNot0(ne))return;const de=s.inv(ne),Y=e.BASE.multiply(ne).toAffine(),ae=s.create(Y.x);if(ae===Ue)return;const qt=s.create(de*s.create(V+ae*M));if(qt===Ue)return;let pi=(Y.x===ae?0:2)|Number(Y.y&vt),hi=qt;return _&&v(qt)&&(hi=s.neg(qt),pi^=1),new x(ae,hi,pi)}return{seed:te,k2sig:z}}function we(w,y,E={}){w=le("message",w);const{seed:_,k2sig:B}=j(w,y,E);return Su(t.outputLen,s.BYTES,i)(_,B)}function fe(w){let y;const E=typeof w=="string"||On(w),_=!E&&w!==null&&typeof w=="object"&&typeof w.r=="bigint"&&typeof w.s=="bigint";if(!E&&!_)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(_)y=new x(w.r,w.s);else if(E){try{y=x.fromBytes(le("sig",w),"der")}catch(B){if(!(B instanceof Me.Err))throw B}if(!y)try{y=x.fromBytes(le("sig",w),"compact")}catch{return!1}}return y||!1}function b(w,y,E,_={}){const{lowS:B,prehash:C,format:O}=zn(_,g);if(E=le("publicKey",E),y=K(le("message",y),C),"strict"in _)throw new Error("options.strict was renamed to lowS");const M=O===void 0?fe(w):x.fromBytes(le("sig",w),O);if(M===!1)return!1;try{const R=e.fromBytes(E);if(B&&M.hasHighS())return!1;const{r:te,s:V}=M,z=D(y),Z=s.inv(V),ne=s.create(z*Z),de=s.create(te*Z),Y=e.BASE.multiplyUnsafe(ne).add(R.multiplyUnsafe(de));return Y.is0()?!1:s.create(Y.x)===te}catch{return!1}}function m(w,y,E={}){const{prehash:_}=zn(E,g);return y=K(y,_),x.fromBytes(w,"recovered").recoverPublicKey(y).toBytes()}return Object.freeze({keygen:u,getPublicKey:p,getSharedSecret:f,utils:l,lengths:d,Point:e,sign:we,verify:b,recoverPublicKey:m,Signature:x,hash:t})}function jd(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(s=>Math.ceil(s/2)))):void 0;const i=dt(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),a={Fp:n,Fn:i,allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes};return{CURVE:t,curveOpts:a}}function Md(e){const{CURVE:t,curveOpts:n}=jd(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}function Dd(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,ys(n.Fn.ORDER,n.Fn.BITS))})}function Nd(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:i}=Md(e),a=Td(t,n),s=Ld(a,r,i);return Dd(e,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ei(e,t){const n=r=>Nd({...e,hash:r});return{...n(t),create:n}}function Rd(e,t={}){const{recovered:n}=t;if(typeof e.r>"u")throw new qn({signature:e});if(typeof e.s>"u")throw new qn({signature:e});if(n&&typeof e.yParity>"u")throw new qn({signature:e});if(e.r<0n||e.r>Pi)throw new Fd({value:e.r});if(e.s<0n||e.s>Pi)throw new zd({value:e.s});if(typeof e.yParity=="number"&&e.yParity!==0&&e.yParity!==1)throw new ti({value:e.yParity})}function ks(e){if(e.length!==130&&e.length!==132)throw new Gd({signature:e});const t=BigInt(be(e,0,32)),n=BigInt(be(e,32,64)),r=(()=>{const i=+`0x${e.slice(130)}`;if(!Number.isNaN(i))try{return Hd(i)}catch{throw new ti({value:i})}})();return typeof r>"u"?{r:t,s:n}:{r:t,s:n,yParity:r}}function Ud(e){Rd(e);const t=e.r,n=e.s;return Tn(Qe(t,{size:32}),Qe(n,{size:32}),typeof e.yParity=="number"?Qe($d(e.yParity),{size:1}):"0x")}function Hd(e){if(e===0||e===27)return 0;if(e===1||e===28)return 1;if(e>=35)return e%2===0?1:0;throw new qd({value:e})}function $d(e){if(e===0)return 27;if(e===1)return 28;throw new ti({value:e})}class Gd extends ee{constructor({signature:t}){super(`Value \`${t}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${Xe(Wa(t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class qn extends ee{constructor({signature:t}){super(`Signature \`${Cn(t)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class Fd extends ee{constructor({value:t}){super(`Value \`${t}\` is an invalid r value. r must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidRError"})}}class zd extends ee{constructor({value:t}){super(`Value \`${t}\` is an invalid s value. s must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSError"})}}class ti extends ee{constructor({value:t}){super(`Value \`${t}\` is an invalid y-parity value. Y-parity must be 0 or 1.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidYParityError"})}}class qd extends ee{constructor({value:t}){super(`Value \`${t}\` is an invalid v value. v must be 27, 28 or >=35.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidVError"})}}const Wd=new TextDecoder,Qt=Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((e,t)=>[t,e.charCodeAt(0)]));({...Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((e,t)=>[e.charCodeAt(0),t]))});function Vd(e,t={}){const{pad:n=!0,url:r=!1}=t,i=new Uint8Array(Math.ceil(e.length/3)*4);for(let c=0,u=0;u<e.length;c+=4,u+=3){const p=(e[u]<<16)+(e[u+1]<<8)+(e[u+2]|0);i[c]=Qt[p>>18],i[c+1]=Qt[p>>12&63],i[c+2]=Qt[p>>6&63],i[c+3]=Qt[p&63]}const a=e.length%3,s=Math.floor(e.length/3)*4+(a&&a+1);let o=Wd.decode(new Uint8Array(i.buffer,0,s));return n&&a===1&&(o+="=="),n&&a===2&&(o+="="),r&&(o=o.replaceAll("+","-").replaceAll("/","_")),o}function Kd(e,t={}){return Vd(Qa(e),t)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const As={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},_s={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},Is={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")},Zd=dt(As.p),Yd=dt(_s.p),Jd=dt(Is.p),Qd=ei({...As,Fp:Zd,lowS:!1},dd);ei({..._s,Fp:Yd,lowS:!1},fd);ei({...Is,Fp:Jd,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},ld);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ui=Qd;Uint8Array.from([105,171,180,181,160,222,75,198,42,42,32,31,141,37,186,233]);function Xd(e={}){const{flag:t=5,rpId:n=window.location.hostname,signCount:r=0}=e,i=es(Va(n)),a=Qe(t,{size:1}),s=Qe(r,{size:4});return Tn(i,a,s)}function el(e){const{challenge:t,crossOrigin:n=!1,extraClientData:r,origin:i=window.location.origin}=e;return JSON.stringify({type:"webauthn.get",challenge:Kd(t,{url:!0,pad:!1}),origin:i,crossOrigin:n,...r})}function tl(e){const{challenge:t,crossOrigin:n,extraClientData:r,flag:i,origin:a,rpId:s,signCount:o,userVerification:c="required"}=e,u=Xd({flag:i,rpId:s,signCount:o}),p=el({challenge:t,crossOrigin:n,extraClientData:r,origin:a}),f=es(Va(p)),l=p.indexOf('"challenge"'),d=p.indexOf('"type"'),g={authenticatorData:u,clientDataJSON:p,challengeIndex:l,typeIndex:d,userVerificationRequired:c==="required"},h=Tn(u,f);return{metadata:g,payload:h}}async function nl(e={}){const{extractable:t=!1}=e,n=await globalThis.crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},t,["sign","verify"]),r=await globalThis.crypto.subtle.exportKey("raw",n.publicKey),i=Gu(new Uint8Array(r));return{privateKey:n.privateKey,publicKey:i}}async function rl(e){const{payload:t,privateKey:n}=e,r=await globalThis.crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},n,Ya(t)),i=Ja(new Uint8Array(r)),a=Ii(_i(i,0,32));let s=Ii(_i(i,32,64));return s>Ui.CURVE.n/2n&&(s=Ui.CURVE.n-s),{r:a,s}}const Ct="4.3.6",Os="@coinbase/wallet-sdk",il=()=>({chains:[]}),al=()=>({keys:{}}),sl=()=>({account:{}}),ol=()=>({subAccount:void 0}),cl=()=>({subAccountConfig:{}}),ul=()=>({spendPermissions:[]}),dl=()=>({config:{version:Ct}}),X=Fr(Pc((...e)=>Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},il(...e)),al(...e)),sl(...e)),ol(...e)),ul(...e)),dl(...e)),cl(...e)),{name:"cbwsdk.store",storage:Oa(()=>localStorage),partialize:e=>({chains:e.chains,keys:e.keys,account:e.account,subAccount:e.subAccount,spendPermissions:e.spendPermissions,config:e.config})})),ll={get:()=>X.getState().subAccountConfig,set:e=>{X.setState(t=>({subAccountConfig:Object.assign(Object.assign({},t.subAccountConfig),e)}))},clear:()=>{X.setState({subAccountConfig:{}})}},fl={get:()=>X.getState().subAccount,set:e=>{X.setState(t=>({subAccount:t.subAccount?Object.assign(Object.assign({},t.subAccount),e):Object.assign({address:e.address},e)}))},clear:()=>{X.setState({subAccount:void 0})}},pl={get:()=>X.getState().spendPermissions,set:e=>{X.setState({spendPermissions:e})},clear:()=>{X.setState({spendPermissions:[]})}},hl={get:()=>X.getState().account,set:e=>{X.setState(t=>({account:Object.assign(Object.assign({},t.account),e)}))},clear:()=>{X.setState({account:{}})}},ml={get:()=>X.getState().chains,set:e=>{X.setState({chains:e})},clear:()=>{X.setState({chains:[]})}},yl={get:e=>X.getState().keys[e],set:(e,t)=>{X.setState(n=>({keys:Object.assign(Object.assign({},n.keys),{[e]:t})}))},clear:()=>{X.setState({keys:{}})}},Ps={get:()=>X.getState().config,set:e=>{X.setState(t=>({config:Object.assign(Object.assign({},t.config),e)}))}},gl={subAccounts:fl,subAccountsConfig:ll,spendPermissions:pl,account:hl,chains:ml,keys:yl,config:Ps},A=Object.assign(Object.assign({},X),gl),bl='!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ClientAnalytics=t():e.ClientAnalytics=t()}(this,(function(){return(()=>{var e={792:e=>{var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}};e.exports=t},562:e=>{var t,n;t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];e>0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,r=0;n<e.length;n++,r+=8)t[r>>>5]|=e[n]<<24-r%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},bytesToBase64:function(e){for(var n=[],r=0;r<e.length;r+=3)for(var i=e[r]<<16|e[r+1]<<8|e[r+2],a=0;a<4;a++)8*r+6*a<=8*e.length?n.push(t.charAt(i>>>6*(3-a)&63)):n.push("=");return n.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\\/]/gi,"");for(var n=[],r=0,i=0;r<e.length;i=++r%4)0!=i&&n.push((t.indexOf(e.charAt(r-1))&Math.pow(2,-2*i+8)-1)<<2*i|t.indexOf(e.charAt(r))>>>6-2*i);return n}},e.exports=n},335:e=>{function t(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}e.exports=function(e){return null!=e&&(t(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&t(e.slice(0,0))}(e)||!!e._isBuffer)}},762:(e,t,n)=>{var r,i,a,o,s;r=n(562),i=n(792).utf8,a=n(335),o=n(792).bin,(s=function(e,t){e.constructor==String?e=t&&"binary"===t.encoding?o.stringToBytes(e):i.stringToBytes(e):a(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=r.bytesToWords(e),c=8*e.length,u=1732584193,l=-271733879,d=-1732584194,p=271733878,m=0;m<n.length;m++)n[m]=16711935&(n[m]<<8|n[m]>>>24)|4278255360&(n[m]<<24|n[m]>>>8);n[c>>>5]|=128<<c%32,n[14+(c+64>>>9<<4)]=c;var f=s._ff,v=s._gg,g=s._hh,b=s._ii;for(m=0;m<n.length;m+=16){var h=u,w=l,y=d,T=p;u=f(u,l,d,p,n[m+0],7,-680876936),p=f(p,u,l,d,n[m+1],12,-389564586),d=f(d,p,u,l,n[m+2],17,606105819),l=f(l,d,p,u,n[m+3],22,-1044525330),u=f(u,l,d,p,n[m+4],7,-176418897),p=f(p,u,l,d,n[m+5],12,1200080426),d=f(d,p,u,l,n[m+6],17,-1473231341),l=f(l,d,p,u,n[m+7],22,-45705983),u=f(u,l,d,p,n[m+8],7,1770035416),p=f(p,u,l,d,n[m+9],12,-1958414417),d=f(d,p,u,l,n[m+10],17,-42063),l=f(l,d,p,u,n[m+11],22,-1990404162),u=f(u,l,d,p,n[m+12],7,1804603682),p=f(p,u,l,d,n[m+13],12,-40341101),d=f(d,p,u,l,n[m+14],17,-1502002290),u=v(u,l=f(l,d,p,u,n[m+15],22,1236535329),d,p,n[m+1],5,-165796510),p=v(p,u,l,d,n[m+6],9,-1069501632),d=v(d,p,u,l,n[m+11],14,643717713),l=v(l,d,p,u,n[m+0],20,-373897302),u=v(u,l,d,p,n[m+5],5,-701558691),p=v(p,u,l,d,n[m+10],9,38016083),d=v(d,p,u,l,n[m+15],14,-660478335),l=v(l,d,p,u,n[m+4],20,-405537848),u=v(u,l,d,p,n[m+9],5,568446438),p=v(p,u,l,d,n[m+14],9,-1019803690),d=v(d,p,u,l,n[m+3],14,-187363961),l=v(l,d,p,u,n[m+8],20,1163531501),u=v(u,l,d,p,n[m+13],5,-1444681467),p=v(p,u,l,d,n[m+2],9,-51403784),d=v(d,p,u,l,n[m+7],14,1735328473),u=g(u,l=v(l,d,p,u,n[m+12],20,-1926607734),d,p,n[m+5],4,-378558),p=g(p,u,l,d,n[m+8],11,-2022574463),d=g(d,p,u,l,n[m+11],16,1839030562),l=g(l,d,p,u,n[m+14],23,-35309556),u=g(u,l,d,p,n[m+1],4,-1530992060),p=g(p,u,l,d,n[m+4],11,1272893353),d=g(d,p,u,l,n[m+7],16,-155497632),l=g(l,d,p,u,n[m+10],23,-1094730640),u=g(u,l,d,p,n[m+13],4,681279174),p=g(p,u,l,d,n[m+0],11,-358537222),d=g(d,p,u,l,n[m+3],16,-722521979),l=g(l,d,p,u,n[m+6],23,76029189),u=g(u,l,d,p,n[m+9],4,-640364487),p=g(p,u,l,d,n[m+12],11,-421815835),d=g(d,p,u,l,n[m+15],16,530742520),u=b(u,l=g(l,d,p,u,n[m+2],23,-995338651),d,p,n[m+0],6,-198630844),p=b(p,u,l,d,n[m+7],10,1126891415),d=b(d,p,u,l,n[m+14],15,-1416354905),l=b(l,d,p,u,n[m+5],21,-57434055),u=b(u,l,d,p,n[m+12],6,1700485571),p=b(p,u,l,d,n[m+3],10,-1894986606),d=b(d,p,u,l,n[m+10],15,-1051523),l=b(l,d,p,u,n[m+1],21,-2054922799),u=b(u,l,d,p,n[m+8],6,1873313359),p=b(p,u,l,d,n[m+15],10,-30611744),d=b(d,p,u,l,n[m+6],15,-1560198380),l=b(l,d,p,u,n[m+13],21,1309151649),u=b(u,l,d,p,n[m+4],6,-145523070),p=b(p,u,l,d,n[m+11],10,-1120210379),d=b(d,p,u,l,n[m+2],15,718787259),l=b(l,d,p,u,n[m+9],21,-343485551),u=u+h>>>0,l=l+w>>>0,d=d+y>>>0,p=p+T>>>0}return r.endian([u,l,d,p])})._ff=function(e,t,n,r,i,a,o){var s=e+(t&n|~t&r)+(i>>>0)+o;return(s<<a|s>>>32-a)+t},s._gg=function(e,t,n,r,i,a,o){var s=e+(t&r|n&~r)+(i>>>0)+o;return(s<<a|s>>>32-a)+t},s._hh=function(e,t,n,r,i,a,o){var s=e+(t^n^r)+(i>>>0)+o;return(s<<a|s>>>32-a)+t},s._ii=function(e,t,n,r,i,a,o){var s=e+(n^(t|~r))+(i>>>0)+o;return(s<<a|s>>>32-a)+t},s._blocksize=16,s._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);var n=r.wordsToBytes(s(e,t));return t&&t.asBytes?n:t&&t.asString?o.bytesToString(n):r.bytesToHex(n)}},2:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Perfume:()=>ze,incrementUjNavigation:()=>Le,markStep:()=>Re,markStepOnce:()=>qe});var r,i,a={isResourceTiming:!1,isElementTiming:!1,maxTime:3e4,reportOptions:{},enableNavigationTracking:!0},o=window,s=o.console,c=o.navigator,u=o.performance,l=function(){return c.deviceMemory},d=function(){return c.hardwareConcurrency},p="mark.",m=function(){return u&&!!u.getEntriesByType&&!!u.now&&!!u.mark},f="4g",v=!1,g={},b={value:0},h={value:{beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0}},w={value:0},y={value:0},T={},k={isHidden:!1,didChange:!1},_=function(){k.isHidden=!1,document.hidden&&(k.isHidden=document.hidden,k.didChange=!0)},S=function(e,t){try{var n=new PerformanceObserver((function(e){t(e.getEntries())}));return n.observe({type:e,buffered:!0}),n}catch(e){s.warn("Perfume.js:",e)}return null},E=function(){return!!(d()&&d()<=4)||!!(l()&&l()<=4)},x=function(e,t){switch(e){case"slow-2g":case"2g":case"3g":return!0;default:return E()||t}},O=function(e){return parseFloat(e.toFixed(4))},j=function(e){return"number"!=typeof e?null:O(e/Math.pow(1024,2))},N=function(e,t,n,r,i){var s,u=function(){a.analyticsTracker&&(k.isHidden&&!["CLS","INP"].includes(e)||a.analyticsTracker({attribution:r,metricName:e,data:t,navigatorInformation:c?{deviceMemory:l()||0,hardwareConcurrency:d()||0,serviceWorkerStatus:"serviceWorker"in c?c.serviceWorker.controller?"controlled":"supported":"unsupported",isLowEndDevice:E(),isLowEndExperience:x(f,v)}:{},rating:n,navigationType:i}))};["CLS","INP"].includes(e)?u():(s=u,"requestIdleCallback"in o?o.requestIdleCallback(s,{timeout:3e3}):s())},I=function(e){e.forEach((function(e){if(!("self"!==e.name||e.startTime<b.value)){var t=e.duration-50;t>0&&(w.value+=t,y.value+=t)}}))};!function(e){e.instant="instant",e.quick="quick",e.moderate="moderate",e.slow="slow",e.unavoidable="unavoidable"}(r||(r={}));var P,M,B,C,D,A=((i={})[r.instant]={vitalsThresholds:[100,200],maxOutlierThreshold:1e4},i[r.quick]={vitalsThresholds:[200,500],maxOutlierThreshold:1e4},i[r.moderate]={vitalsThresholds:[500,1e3],maxOutlierThreshold:1e4},i[r.slow]={vitalsThresholds:[1e3,2e3],maxOutlierThreshold:1e4},i[r.unavoidable]={vitalsThresholds:[2e3,5e3],maxOutlierThreshold:2e4},i),L={RT:[100,200],TBT:[200,600],NTBT:[200,600]},U=function(e,t){return L[e]?t<=L[e][0]?"good":t<=L[e][1]?"needsImprovement":"poor":null},R=function(e,t,n){Object.keys(t).forEach((function(e){"number"==typeof t[e]&&(t[e]=O(t[e]))})),N(e,t,null,n||{})},q=function(e){var t=e.attribution,n=e.name,r=e.rating,i=e.value,o=e.navigationType;"FCP"===n&&(b.value=i),["FCP","LCP"].includes(n)&&!T[0]&&(T[0]=S("longtask",I)),"FID"===n&&setTimeout((function(){k.didChange||(q({attribution:t,name:"TBT",rating:U("TBT",w.value),value:w.value,navigationType:o}),R("dataConsumption",h.value))}),1e4);var s=O(i);s<=a.maxTime&&s>=0&&N(n,s,r,t,o)},F=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},z=function(e){if("loading"===document.readyState)return"loading";var t=F();if(t){if(e<t.domInteractive)return"loading";if(0===t.domContentLoadedEventStart||e<t.domContentLoadedEventStart)return"dom-interactive";if(0===t.domComplete||e<t.domComplete)return"dom-content-loaded"}return"complete"},K=function(e){var t=e.nodeName;return 1===e.nodeType?t.toLowerCase():t.toUpperCase().replace(/^#/,"")},$=function(e,t){var n="";try{for(;e&&9!==e.nodeType;){var r=e,i=r.id?"#"+r.id:K(r)+(r.className&&r.className.length?"."+r.className.replace(/\\s+/g,"."):"");if(n.length+i.length>(t||100)-1)return n||i;if(n=n?i+">"+n:i,r.id)break;e=r.parentNode}}catch(e){}return n},Q=-1,W=function(){return Q},H=function(e){addEventListener("pageshow",(function(t){t.persisted&&(Q=t.timeStamp,e(t))}),!0)},V=function(){var e=F();return e&&e.activationStart||0},J=function(e,t){var n=F(),r="navigate";return W()>=0?r="back-forward-cache":n&&(r=document.prerendering||V()>0?"prerender":document.wasDiscarded?"restore":n.type.replace(/_/g,"-")),{name:e,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v3-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:r}},X=function(e,t,n){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var r=new PerformanceObserver((function(e){Promise.resolve().then((function(){t(e.getEntries())}))}));return r.observe(Object.assign({type:e,buffered:!0},n||{})),r}}catch(e){}},G=function(e,t){var n=function n(r){"pagehide"!==r.type&&"hidden"!==document.visibilityState||(e(r),t&&(removeEventListener("visibilitychange",n,!0),removeEventListener("pagehide",n,!0)))};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},Z=function(e,t,n,r){var i,a;return function(o){t.value>=0&&(o||r)&&((a=t.value-(i||0))||void 0===i)&&(i=t.value,t.delta=a,t.rating=function(e,t){return e>t[1]?"poor":e>t[0]?"needs-improvement":"good"}(t.value,n),e(t))}},Y=function(e){requestAnimationFrame((function(){return requestAnimationFrame((function(){return e()}))}))},ee=function(e){document.prerendering?addEventListener("prerenderingchange",(function(){return e()}),!0):e()},te=-1,ne=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},re=function(e){"hidden"===document.visibilityState&&te>-1&&(te="visibilitychange"===e.type?e.timeStamp:0,ae())},ie=function(){addEventListener("visibilitychange",re,!0),addEventListener("prerenderingchange",re,!0)},ae=function(){removeEventListener("visibilitychange",re,!0),removeEventListener("prerenderingchange",re,!0)},oe=function(){return te<0&&(te=ne(),ie(),H((function(){setTimeout((function(){te=ne(),ie()}),0)}))),{get firstHiddenTime(){return te}}},se=function(e,t){t=t||{},ee((function(){var n,r=[1800,3e3],i=oe(),a=J("FCP"),o=X("paint",(function(e){e.forEach((function(e){"first-contentful-paint"===e.name&&(o.disconnect(),e.startTime<i.firstHiddenTime&&(a.value=Math.max(e.startTime-V(),0),a.entries.push(e),n(!0)))}))}));o&&(n=Z(e,a,r,t.reportAllChanges),H((function(i){a=J("FCP"),n=Z(e,a,r,t.reportAllChanges),Y((function(){a.value=performance.now()-i.timeStamp,n(!0)}))})))}))},ce={passive:!0,capture:!0},ue=new Date,le=function(e,t){P||(P=t,M=e,B=new Date,me(removeEventListener),de())},de=function(){if(M>=0&&M<B-ue){var e={entryType:"first-input",name:P.type,target:P.target,cancelable:P.cancelable,startTime:P.timeStamp,processingStart:P.timeStamp+M};C.forEach((function(t){t(e)})),C=[]}},pe=function(e){if(e.cancelable){var t=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,t){var n=function(){le(e,t),i()},r=function(){i()},i=function(){removeEventListener("pointerup",n,ce),removeEventListener("pointercancel",r,ce)};addEventListener("pointerup",n,ce),addEventListener("pointercancel",r,ce)}(t,e):le(t,e)}},me=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return e(t,pe,ce)}))},fe=0,ve=1/0,ge=0,be=function(e){e.forEach((function(e){e.interactionId&&(ve=Math.min(ve,e.interactionId),ge=Math.max(ge,e.interactionId),fe=ge?(ge-ve)/7+1:0)}))},he=function(){return D?fe:performance.interactionCount||0},we=0,ye=function(){return he()-we},Te=[],ke={},_e=function(e){var t=Te[Te.length-1],n=ke[e.interactionId];if(n||Te.length<10||e.duration>t.latency){if(n)n.entries.push(e),n.latency=Math.max(n.latency,e.duration);else{var r={id:e.interactionId,latency:e.duration,entries:[e]};ke[r.id]=r,Te.push(r)}Te.sort((function(e,t){return t.latency-e.latency})),Te.splice(10).forEach((function(e){delete ke[e.id]}))}},Se={},Ee=function e(t){document.prerendering?ee((function(){return e(t)})):"complete"!==document.readyState?addEventListener("load",(function(){return e(t)}),!0):setTimeout(t,0)},xe=function(e,t){t=t||{};var n=[800,1800],r=J("TTFB"),i=Z(e,r,n,t.reportAllChanges);Ee((function(){var a=F();if(a){var o=a.responseStart;if(o<=0||o>performance.now())return;r.value=Math.max(o-V(),0),r.entries=[a],i(!0),H((function(){r=J("TTFB",0),(i=Z(e,r,n,t.reportAllChanges))(!0)}))}}))},Oe=function(e){e.forEach((function(e){e.identifier&&q({attribution:{identifier:e.identifier},name:"ET",rating:null,value:e.startTime})}))},je=function(e){e.forEach((function(e){if(a.isResourceTiming&&R("resourceTiming",e),e.decodedBodySize&&e.initiatorType){var t=e.decodedBodySize/1e3;h.value[e.initiatorType]+=t,h.value.total+=t}}))},Ne=function(){!function(e,t){xe((function(e){!function(e){if(e.entries.length){var t=e.entries[0],n=t.activationStart||0,r=Math.max(t.domainLookupStart-n,0),i=Math.max(t.connectStart-n,0),a=Math.max(t.requestStart-n,0);e.attribution={waitingTime:r,dnsTime:i-r,connectionTime:a-i,requestTime:e.value-a,navigationEntry:t}}else e.attribution={waitingTime:0,dnsTime:0,connectionTime:0,requestTime:0}}(e),function(e){e.value>0&&q(e)}(e)}),t)}(0,a.reportOptions.ttfb),function(e,t){!function(e,t){t=t||{},ee((function(){var e,n=[.1,.25],r=J("CLS"),i=-1,a=0,o=[],s=function(e){i>-1&&function(e){!function(e){if(e.entries.length){var t=e.entries.reduce((function(e,t){return e&&e.value>t.value?e:t}));if(t&&t.sources&&t.sources.length){var n=(r=t.sources).find((function(e){return e.node&&1===e.node.nodeType}))||r[0];if(n)return void(e.attribution={largestShiftTarget:$(n.node),largestShiftTime:t.startTime,largestShiftValue:t.value,largestShiftSource:n,largestShiftEntry:t,loadState:z(t.startTime)})}}var r;e.attribution={}}(e),function(e){q(e)}(e)}(e)},c=function(t){t.forEach((function(t){if(!t.hadRecentInput){var n=o[0],i=o[o.length-1];a&&t.startTime-i.startTime<1e3&&t.startTime-n.startTime<5e3?(a+=t.value,o.push(t)):(a=t.value,o=[t]),a>r.value&&(r.value=a,r.entries=o,e())}}))},u=X("layout-shift",c);u&&(e=Z(s,r,n,t.reportAllChanges),se((function(t){i=t.value,r.value<0&&(r.value=0,e())})),G((function(){c(u.takeRecords()),e(!0)})),H((function(){a=0,i=-1,r=J("CLS",0),e=Z(s,r,n,t.reportAllChanges),Y((function(){return e()}))})))}))}(0,t)}(0,a.reportOptions.cls),function(e,t){se((function(e){!function(e){if(e.entries.length){var t=F(),n=e.entries[e.entries.length-1];if(t){var r=t.activationStart||0,i=Math.max(0,t.responseStart-r);return void(e.attribution={timeToFirstByte:i,firstByteToFCP:e.value-i,loadState:z(e.entries[0].startTime),navigationEntry:t,fcpEntry:n})}}e.attribution={timeToFirstByte:0,firstByteToFCP:e.value,loadState:z(W())}}(e),function(e){q(e)}(e)}),t)}(0,a.reportOptions.fcp),function(e,t){!function(e,t){t=t||{},ee((function(){var n,r=[100,300],i=oe(),a=J("FID"),o=function(e){e.startTime<i.firstHiddenTime&&(a.value=e.processingStart-e.startTime,a.entries.push(e),n(!0))},s=function(e){e.forEach(o)},c=X("first-input",s);n=Z(e,a,r,t.reportAllChanges),c&&G((function(){s(c.takeRecords()),c.disconnect()}),!0),c&&H((function(){var i;a=J("FID"),n=Z(e,a,r,t.reportAllChanges),C=[],M=-1,P=null,me(addEventListener),i=o,C.push(i),de()}))}))}((function(e){!function(e){var t=e.entries[0];e.attribution={eventTarget:$(t.target),eventType:t.name,eventTime:t.startTime,eventEntry:t,loadState:z(t.startTime)}}(e),function(e){q(e)}(e)}),t)}(0,a.reportOptions.fid),function(e,t){!function(e,t){t=t||{},ee((function(){var n,r=[2500,4e3],i=oe(),a=J("LCP"),o=function(e){var t=e[e.length-1];if(t){var r=Math.max(t.startTime-V(),0);r<i.firstHiddenTime&&(a.value=r,a.entries=[t],n())}},s=X("largest-contentful-paint",o);if(s){n=Z(e,a,r,t.reportAllChanges);var c=function(){Se[a.id]||(o(s.takeRecords()),s.disconnect(),Se[a.id]=!0,n(!0))};["keydown","click"].forEach((function(e){addEventListener(e,c,{once:!0,capture:!0})})),G(c,!0),H((function(i){a=J("LCP"),n=Z(e,a,r,t.reportAllChanges),Y((function(){a.value=performance.now()-i.timeStamp,Se[a.id]=!0,n(!0)}))}))}}))}((function(e){!function(e){if(e.entries.length){var t=F();if(t){var n=t.activationStart||0,r=e.entries[e.entries.length-1],i=r.url&&performance.getEntriesByType("resource").filter((function(e){return e.name===r.url}))[0],a=Math.max(0,t.responseStart-n),o=Math.max(a,i?(i.requestStart||i.startTime)-n:0),s=Math.max(o,i?i.responseEnd-n:0),c=Math.max(s,r?r.startTime-n:0),u={element:$(r.element),timeToFirstByte:a,resourceLoadDelay:o-a,resourceLoadTime:s-o,elementRenderDelay:c-s,navigationEntry:t,lcpEntry:r};return r.url&&(u.url=r.url),i&&(u.lcpResourceEntry=i),void(e.attribution=u)}}e.attribution={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadTime:0,elementRenderDelay:e.value}}(e),function(e){q(e)}(e)}),t)}(0,a.reportOptions.lcp),function(e,t){!function(e,t){t=t||{},ee((function(){var n=[200,500];"interactionCount"in performance||D||(D=X("event",be,{type:"event",buffered:!0,durationThreshold:0}));var r,i=J("INP"),a=function(e){e.forEach((function(e){e.interactionId&&_e(e),"first-input"===e.entryType&&!Te.some((function(t){return t.entries.some((function(t){return e.duration===t.duration&&e.startTime===t.startTime}))}))&&_e(e)}));var t,n=(t=Math.min(Te.length-1,Math.floor(ye()/50)),Te[t]);n&&n.latency!==i.value&&(i.value=n.latency,i.entries=n.entries,r())},o=X("event",a,{durationThreshold:t.durationThreshold||40});r=Z(e,i,n,t.reportAllChanges),o&&(o.observe({type:"first-input",buffered:!0}),G((function(){a(o.takeRecords()),i.value<0&&ye()>0&&(i.value=0,i.entries=[]),r(!0)})),H((function(){Te=[],we=he(),i=J("INP"),r=Z(e,i,n,t.reportAllChanges)})))}))}((function(t){!function(e){if(e.entries.length){var t=e.entries.sort((function(e,t){return t.duration-e.duration||t.processingEnd-t.processingStart-(e.processingEnd-e.processingStart)}))[0];e.attribution={eventTarget:$(t.target),eventType:t.name,eventTime:t.startTime,eventEntry:t,loadState:z(t.startTime)}}else e.attribution={}}(t),e(t)}),t)}((function(e){return q(e)}),a.reportOptions.inp),a.isResourceTiming&&S("resource",je),a.isElementTiming&&S("element",Oe)},Ie=function(e){var t="usageDetails"in e?e.usageDetails:{};R("storageEstimate",{quota:j(e.quota),usage:j(e.usage),caches:j(t.caches),indexedDB:j(t.indexedDB),serviceWorker:j(t.serviceWorkerRegistrations)})},Pe={finalMarkToStepsMap:{},startMarkToStepsMap:{},active:{},navigationSteps:{}},Me=function(e){delete Pe.active[e]},Be=function(){return Pe.navigationSteps},Ce=function(e){var t;return null!==(t=Be()[e])&&void 0!==t?t:{}},De=function(e,t,n){var r="step."+e,i=u.getEntriesByName(p+t).length>0;if(u.getEntriesByName(p+n).length>0&&a.steps){var o=A[a.steps[e].threshold],s=o.maxOutlierThreshold,c=o.vitalsThresholds;if(i){var l=u.measure(r,p+t,p+n),d=l.duration;if(d<=s){var m=function(e,t){return e<=t[0]?"good":e<=t[1]?"needsImprovement":"poor"}(d,c);d>=0&&(N("userJourneyStep",d,m,{stepName:e},void 0),u.measure("step.".concat(e,"_vitals_").concat(m),{start:l.startTime+l.duration,end:l.startTime+l.duration,detail:{type:"stepVital",duration:d}}))}}}},Ae=function(){var e=Be(),t=Pe.startMarkToStepsMap,n=Object.keys(e).length;if(0===n)return{};var r={},i=n-1,a=Ce(i);if(Object.keys(a).forEach((function(e){var n,i=null!==(n=t[e])&&void 0!==n?n:[];Object.keys(i).forEach((function(e){r[e]=!0}))})),n>1){var o=Ce(i-1);Object.keys(o).forEach((function(e){var n,i=null!==(n=t[e])&&void 0!==n?n:[];Object.keys(i).forEach((function(e){r[e]=!0}))}))}return r},Le=function(){var e,t=Object.keys(Pe.navigationSteps).length;Pe.navigationSteps[t]={};var n=Ae();null===(e=a.onMarkStep)||void 0===e||e.call(a,"",Object.keys(n))},Ue=function(e){var t,n,r,i,o,s,c;if(Pe.finalMarkToStepsMap[e]){!function(e){var t=Pe.navigationSteps,n=Pe.finalMarkToStepsMap,r=Object.keys(t).length;if(0!==r){var i=r-1,a=Ce(i);if(a&&n[e]){var o=n[e];o&&Object.keys(o).forEach((function(e){if(a[e]){var n=Ce(i)||{};n[e]=!1,t[i]=n}if(r>1){var o=i-1,s=Ce(o);s[e]&&(s[e]=!1,t[o]=s)}}))}}}(e);var u=Pe.finalMarkToStepsMap[e];Object.keys(u).forEach((function(t){var n=u[t];n.forEach(Me),Promise.all(n.map((function(n){return function(e,t,n,r){return new(n||(n=Promise))((function(e,t){function i(e){try{o(r.next(e))}catch(e){t(e)}}function a(e){try{o(r.throw(e))}catch(e){t(e)}}function o(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n((function(e){e(r)}))).then(i,a)}o((r=r.apply(undefined,[])).next())}))}(0,0,void 0,(function(){return function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}(this,(function(r){switch(r.label){case 0:return[4,De(n,t,e)];case 1:return r.sent(),[2]}}))}))}))).catch((function(){}))}))}else r=e,i=Pe.navigationSteps,o=Object.keys(i).length,(c=Ce(s=(o>0?o:1)-1)||[])[r]=!0,i[s]=c,function(e){var t,n=null!==(t=Pe.startMarkToStepsMap[e])&&void 0!==t?t:[];Object.keys(n).forEach((function(e){Pe.active[e]||(Pe.active[e]=!0)}))}(e);if(a.enableNavigationTracking){var l=Ae();null===(t=a.onMarkStep)||void 0===t||t.call(a,e,Object.keys(l))}else null===(n=a.onMarkStep)||void 0===n||n.call(a,e,Object.keys(Pe.active))},Re=function(e){u.mark(p+e),Ue(e)},qe=function(e){0===u.getEntriesByName(p+e).length&&(u.mark(p+e),Ue(e))},Fe=0,ze=function(){function e(e){if(void 0===e&&(e={}),this.v="9.0.0-rc.3",a.analyticsTracker=e.analyticsTracker,a.isResourceTiming=!!e.resourceTiming,a.isElementTiming=!!e.elementTiming,a.maxTime=e.maxMeasureTime||a.maxTime,a.reportOptions=e.reportOptions||a.reportOptions,a.steps=e.steps,a.onMarkStep=e.onMarkStep,a.enableNavigationTracking=e.enableNavigationTracking,m()){"PerformanceObserver"in o&&Ne(),void 0!==document.hidden&&document.addEventListener("visibilitychange",_);var t=function(){if(!m())return{};var e=u.getEntriesByType("navigation")[0];if(!e)return{};var t=e.responseStart,n=e.responseEnd;return{fetchTime:n-e.fetchStart,workerTime:e.workerStart>0?n-e.workerStart:0,totalTime:n-e.requestStart,downloadTime:n-t,timeToFirstByte:t-e.requestStart,headerSize:e.transferSize-e.encodedBodySize||0,dnsLookupTime:e.domainLookupEnd-e.domainLookupStart,redirectTime:e.redirectEnd-e.redirectStart}}();R("navigationTiming",t),t.redirectTime&&q({attribution:{},name:"RT",rating:U("RT",t.redirectTime),value:t.redirectTime}),R("networkInformation",function(){if("connection"in c){var e=c.connection;return"object"!=typeof e?{}:(f=e.effectiveType,v=!!e.saveData,{downlink:e.downlink,effectiveType:e.effectiveType,rtt:e.rtt,saveData:!!e.saveData})}return{}}()),c&&c.storage&&"function"==typeof c.storage.estimate&&c.storage.estimate().then(Ie),a.steps&&a.steps&&(Pe.startMarkToStepsMap={},Pe.finalMarkToStepsMap={},Pe.active={},Pe.navigationSteps={},Object.entries(a.steps).forEach((function(e){var t,n,r=e[0],i=e[1].marks,a=i[0],o=i[1],s=null!==(n=Pe.startMarkToStepsMap[a])&&void 0!==n?n:{};if(s[r]=!0,Pe.startMarkToStepsMap[a]=s,Pe.finalMarkToStepsMap[o]){var c=Pe.finalMarkToStepsMap[o][a]||[];c.push(r),Pe.finalMarkToStepsMap[o][a]=c}else Pe.finalMarkToStepsMap[o]=((t={})[a]=[r],t)})))}}return e.prototype.start=function(e){m()&&!g[e]&&(g[e]=!0,u.mark("mark_".concat(e,"_start")))},e.prototype.end=function(e,t,n){if(void 0===t&&(t={}),void 0===n&&(n=!0),m()&&g[e]){u.mark("mark_".concat(e,"_end")),delete g[e];var r=function(e){u.measure(e,"mark_".concat(e,"_start"),"mark_".concat(e,"_end"));var t=u.getEntriesByName(e).pop();return t&&"measure"===t.entryType?t.duration:-1}(e);n&&R(e,O(r),t)}},e.prototype.endPaint=function(e,t){var n=this;setTimeout((function(){n.end(e,t)}))},e.prototype.clear=function(e){delete g[e],u.clearMarks&&(u.clearMarks("mark_".concat(e,"_start")),u.clearMarks("mark_".concat(e,"_end")))},e.prototype.markNTBT=function(){var e=this;this.start("ntbt"),y.value=0,clearTimeout(Fe),Fe=setTimeout((function(){e.end("ntbt",{},!1),q({attribution:{},name:"NTBT",rating:U("NTBT",y.value),value:y.value}),y.value=0}),2e3)},e}()},426:(e,t)=>{"use strict";Symbol.for("react.element"),Symbol.for("react.portal"),Symbol.for("react.fragment"),Symbol.for("react.strict_mode"),Symbol.for("react.profiler"),Symbol.for("react.provider"),Symbol.for("react.context"),Symbol.for("react.forward_ref"),Symbol.for("react.suspense"),Symbol.for("react.memo"),Symbol.for("react.lazy"),Symbol.iterator;var n={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},r=Object.assign,i={};function a(e,t,r){this.props=e,this.context=t,this.refs=i,this.updater=r||n}function o(){}function s(e,t,r){this.props=e,this.context=t,this.refs=i,this.updater=r||n}a.prototype.isReactComponent={},a.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},a.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},o.prototype=a.prototype;var c=s.prototype=new o;c.constructor=s,r(c,a.prototype),c.isPureReactComponent=!0;Array.isArray,Object.prototype.hasOwnProperty;var u={current:null};t.useCallback=function(e,t){return u.current.useCallback(e,t)},t.useEffect=function(e,t){return u.current.useEffect(e,t)},t.useRef=function(e){return u.current.useRef(e)}},784:(e,t,n)=>{"use strict";e.exports=n(426)},353:function(e,t,n){var r;!function(i,a){"use strict";var o="function",s="undefined",c="object",u="string",l="major",d="model",p="name",m="type",f="vendor",v="version",g="architecture",b="console",h="mobile",w="tablet",y="smarttv",T="wearable",k="embedded",_="Amazon",S="Apple",E="ASUS",x="BlackBerry",O="Browser",j="Chrome",N="Firefox",I="Google",P="Huawei",M="LG",B="Microsoft",C="Motorola",D="Opera",A="Samsung",L="Sharp",U="Sony",R="Xiaomi",q="Zebra",F="Facebook",z="Chromium OS",K="Mac OS",$=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},Q=function(e,t){return typeof e===u&&-1!==W(t).indexOf(W(e))},W=function(e){return e.toLowerCase()},H=function(e,t){if(typeof e===u)return e=e.replace(/^\\s\\s*/,""),typeof t===s?e:e.substring(0,350)},V=function(e,t){for(var n,r,i,s,u,l,d=0;d<t.length&&!u;){var p=t[d],m=t[d+1];for(n=r=0;n<p.length&&!u&&p[n];)if(u=p[n++].exec(e))for(i=0;i<m.length;i++)l=u[++r],typeof(s=m[i])===c&&s.length>0?2===s.length?typeof s[1]==o?this[s[0]]=s[1].call(this,l):this[s[0]]=s[1]:3===s.length?typeof s[1]!==o||s[1].exec&&s[1].test?this[s[0]]=l?l.replace(s[1],s[2]):a:this[s[0]]=l?s[1].call(this,l,s[2]):a:4===s.length&&(this[s[0]]=l?s[3].call(this,l.replace(s[1],s[2])):a):this[s]=l||a;d+=2}},J=function(e,t){for(var n in t)if(typeof t[n]===c&&t[n].length>0){for(var r=0;r<t[n].length;r++)if(Q(t[n][r],e))return"?"===n?a:n}else if(Q(t[n],e))return"?"===n?a:n;return e},X={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},G={browser:[[/\\b(?:crmo|crios)\\/([\\w\\.]+)/i],[v,[p,"Chrome"]],[/edg(?:e|ios|a)?\\/([\\w\\.]+)/i],[v,[p,"Edge"]],[/(opera mini)\\/([-\\w\\.]+)/i,/(opera [mobiletab]{3,6})\\b.+version\\/([-\\w\\.]+)/i,/(opera)(?:.+version\\/|[\\/ ]+)([\\w\\.]+)/i],[p,v],[/opios[\\/ ]+([\\w\\.]+)/i],[v,[p,D+" Mini"]],[/\\bopr\\/([\\w\\.]+)/i],[v,[p,D]],[/(kindle)\\/([\\w\\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\\/ ]?([\\w\\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\\/ ]?([\\w\\.]*)/i,/(ba?idubrowser)[\\/ ]?([\\w\\.]+)/i,/(?:ms|\\()(ie) ([\\w\\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\\/([-\\w\\.]+)/i,/(heytap|ovi)browser\\/([\\d\\.]+)/i,/(weibo)__([\\d\\.]+)/i],[p,v],[/(?:\\buc? ?browser|(?:juc.+)ucweb)[\\/ ]?([\\w\\.]+)/i],[v,[p,"UC"+O]],[/microm.+\\bqbcore\\/([\\w\\.]+)/i,/\\bqbcore\\/([\\w\\.]+).+microm/i],[v,[p,"WeChat(Win) Desktop"]],[/micromessenger\\/([\\w\\.]+)/i],[v,[p,"WeChat"]],[/konqueror\\/([\\w\\.]+)/i],[v,[p,"Konqueror"]],[/trident.+rv[: ]([\\w\\.]{1,9})\\b.+like gecko/i],[v,[p,"IE"]],[/ya(?:search)?browser\\/([\\w\\.]+)/i],[v,[p,"Yandex"]],[/(avast|avg)\\/([\\w\\.]+)/i],[[p,/(.+)/,"$1 Secure "+O],v],[/\\bfocus\\/([\\w\\.]+)/i],[v,[p,N+" Focus"]],[/\\bopt\\/([\\w\\.]+)/i],[v,[p,D+" Touch"]],[/coc_coc\\w+\\/([\\w\\.]+)/i],[v,[p,"Coc Coc"]],[/dolfin\\/([\\w\\.]+)/i],[v,[p,"Dolphin"]],[/coast\\/([\\w\\.]+)/i],[v,[p,D+" Coast"]],[/miuibrowser\\/([\\w\\.]+)/i],[v,[p,"MIUI "+O]],[/fxios\\/([-\\w\\.]+)/i],[v,[p,N]],[/\\bqihu|(qi?ho?o?|360)browser/i],[[p,"360 "+O]],[/(oculus|samsung|sailfish|huawei)browser\\/([\\w\\.]+)/i],[[p,/(.+)/,"$1 "+O],v],[/(comodo_dragon)\\/([\\w\\.]+)/i],[[p,/_/g," "],v],[/(electron)\\/([\\w\\.]+) safari/i,/(tesla)(?: qtcarbrowser|\\/(20\\d\\d\\.[-\\w\\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\\/ ]?([\\w\\.]+)/i],[p,v],[/(metasr)[\\/ ]?([\\w\\.]+)/i,/(lbbrowser)/i,/\\[(linkedin)app\\]/i],[p],[/((?:fban\\/fbios|fb_iab\\/fb4a)(?!.+fbav)|;fbav\\/([\\w\\.]+);)/i],[[p,F],v],[/(kakao(?:talk|story))[\\/ ]([\\w\\.]+)/i,/(naver)\\(.*?(\\d+\\.[\\w\\.]+).*\\)/i,/safari (line)\\/([\\w\\.]+)/i,/\\b(line)\\/([\\w\\.]+)\\/iab/i,/(chromium|instagram)[\\/ ]([-\\w\\.]+)/i],[p,v],[/\\bgsa\\/([\\w\\.]+) .*safari\\//i],[v,[p,"GSA"]],[/musical_ly(?:.+app_?version\\/|_)([\\w\\.]+)/i],[v,[p,"TikTok"]],[/headlesschrome(?:\\/([\\w\\.]+)| )/i],[v,[p,j+" Headless"]],[/ wv\\).+(chrome)\\/([\\w\\.]+)/i],[[p,j+" WebView"],v],[/droid.+ version\\/([\\w\\.]+)\\b.+(?:mobile safari|safari)/i],[v,[p,"Android "+O]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\\/v?([\\w\\.]+)/i],[p,v],[/version\\/([\\w\\.\\,]+) .*mobile\\/\\w+ (safari)/i],[v,[p,"Mobile Safari"]],[/version\\/([\\w(\\.|\\,)]+) .*(mobile ?safari|safari)/i],[v,p],[/webkit.+?(mobile ?safari|safari)(\\/[\\w\\.]+)/i],[p,[v,J,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\\/([\\w\\.]+)/i],[p,v],[/(navigator|netscape\\d?)\\/([-\\w\\.]+)/i],[[p,"Netscape"],v],[/mobile vr; rv:([\\w\\.]+)\\).+firefox/i],[v,[p,N+" Reality"]],[/ekiohf.+(flow)\\/([\\w\\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\\/ ]?([\\w\\.\\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\\/([-\\w\\.]+)$/i,/(firefox)\\/([\\w\\.]+)/i,/(mozilla)\\/([\\w\\.]+) .+rv\\:.+gecko\\/\\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\\. ]?browser)[-\\/ ]?v?([\\w\\.]+)/i,/(links) \\(([\\w\\.]+)/i,/panasonic;(viera)/i],[p,v],[/(cobalt)\\/([\\w\\.]+)/i],[p,[v,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\\)]/i],[[g,"amd64"]],[/(ia32(?=;))/i],[[g,W]],[/((?:i[346]|x)86)[;\\)]/i],[[g,"ia32"]],[/\\b(aarch64|arm(v?8e?l?|_?64))\\b/i],[[g,"arm64"]],[/\\b(arm(?:v[67])?ht?n?[fl]p?)\\b/i],[[g,"armhf"]],[/windows (ce|mobile); ppc;/i],[[g,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\\))/i],[[g,/ower/,"",W]],[/(sun4\\w)[;\\)]/i],[[g,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\\))|\\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\\b|pa-risc)/i],[[g,W]]],device:[[/\\b(sch-i[89]0\\d|shw-m380s|sm-[ptx]\\w{2,4}|gt-[pn]\\d{2,4}|sgh-t8[56]9|nexus 10)/i],[d,[f,A],[m,w]],[/\\b((?:s[cgp]h|gt|sm)-\\w+|sc[g-]?[\\d]+a?|galaxy nexus)/i,/samsung[- ]([-\\w]+)/i,/sec-(sgh\\w+)/i],[d,[f,A],[m,h]],[/(?:\\/|\\()(ip(?:hone|od)[\\w, ]*)(?:\\/|;)/i],[d,[f,S],[m,h]],[/\\((ipad);[-\\w\\),; ]+apple/i,/applecoremedia\\/[\\w\\.]+ \\((ipad)/i,/\\b(ipad)\\d\\d?,\\d\\d?[;\\]].+ios/i],[d,[f,S],[m,w]],[/(macintosh);/i],[d,[f,S]],[/\\b(sh-?[altvz]?\\d\\d[a-ekm]?)/i],[d,[f,L],[m,h]],[/\\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\\d{2})\\b(?!.+d\\/s)/i],[d,[f,P],[m,w]],[/(?:huawei|honor)([-\\w ]+)[;\\)]/i,/\\b(nexus 6p|\\w{2,4}e?-[atu]?[ln][\\dx][012359c][adn]?)\\b(?!.+d\\/s)/i],[d,[f,P],[m,h]],[/\\b(poco[\\w ]+)(?: bui|\\))/i,/\\b; (\\w+) build\\/hm\\1/i,/\\b(hm[-_ ]?note?[_ ]?(?:\\d\\w)?) bui/i,/\\b(redmi[\\-_ ]?(?:note|k)?[\\w_ ]+)(?: bui|\\))/i,/\\b(mi[-_ ]?(?:a\\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\\d?\\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\\))/i],[[d,/_/g," "],[f,R],[m,h]],[/\\b(mi[-_ ]?(?:pad)(?:[\\w_ ]+))(?: bui|\\))/i],[[d,/_/g," "],[f,R],[m,w]],[/; (\\w+) bui.+ oppo/i,/\\b(cph[12]\\d{3}|p(?:af|c[al]|d\\w|e[ar])[mt]\\d0|x9007|a101op)\\b/i],[d,[f,"OPPO"],[m,h]],[/vivo (\\w+)(?: bui|\\))/i,/\\b(v[12]\\d{3}\\w?[at])(?: bui|;)/i],[d,[f,"Vivo"],[m,h]],[/\\b(rmx[12]\\d{3})(?: bui|;|\\))/i],[d,[f,"Realme"],[m,h]],[/\\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\\b[\\w ]+build\\//i,/\\bmot(?:orola)?[- ](\\w*)/i,/((?:moto[\\w\\(\\) ]+|xt\\d{3,4}|nexus 6)(?= bui|\\)))/i],[d,[f,C],[m,h]],[/\\b(mz60\\d|xoom[2 ]{0,2}) build\\//i],[d,[f,C],[m,w]],[/((?=lg)?[vl]k\\-?\\d{3}) bui| 3\\.[-\\w; ]{10}lg?-([06cv9]{3,4})/i],[d,[f,M],[m,w]],[/(lm(?:-?f100[nv]?|-[\\w\\.]+)(?= bui|\\))|nexus [45])/i,/\\blg[-e;\\/ ]+((?!browser|netcast|android tv)\\w+)/i,/\\blg-?([\\d\\w]+) bui/i],[d,[f,M],[m,h]],[/(ideatab[-\\w ]+)/i,/lenovo ?(s[56]000[-\\w]+|tab(?:[\\w ]+)|yt[-\\d\\w]{6}|tb[-\\d\\w]{6})/i],[d,[f,"Lenovo"],[m,w]],[/(?:maemo|nokia).*(n900|lumia \\d+)/i,/nokia[-_ ]?([-\\w\\.]*)/i],[[d,/_/g," "],[f,"Nokia"],[m,h]],[/(pixel c)\\b/i],[d,[f,I],[m,w]],[/droid.+; (pixel[\\daxl ]{0,6})(?: bui|\\))/i],[d,[f,I],[m,h]],[/droid.+ (a?\\d[0-2]{2}so|[c-g]\\d{4}|so[-gl]\\w+|xq-a\\w[4-7][12])(?= bui|\\).+chrome\\/(?![1-6]{0,1}\\d\\.))/i],[d,[f,U],[m,h]],[/sony tablet [ps]/i,/\\b(?:sony)?sgp\\w+(?: bui|\\))/i],[[d,"Xperia Tablet"],[f,U],[m,w]],[/ (kb2005|in20[12]5|be20[12][59])\\b/i,/(?:one)?(?:plus)? (a\\d0\\d\\d)(?: b|\\))/i],[d,[f,"OnePlus"],[m,h]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\\))/i,/(kf[a-z]+)( bui|\\)).+silk\\//i],[d,[f,_],[m,w]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\\)).+silk\\//i],[[d,/(.+)/g,"Fire Phone $1"],[f,_],[m,h]],[/(playbook);[-\\w\\),; ]+(rim)/i],[d,f,[m,w]],[/\\b((?:bb[a-f]|st[hv])100-\\d)/i,/\\(bb10; (\\w+)/i],[d,[f,x],[m,h]],[/(?:\\b|asus_)(transfo[prime ]{4,10} \\w+|eeepc|slider \\w+|nexus 7|padfone|p00[cj])/i],[d,[f,E],[m,w]],[/ (z[bes]6[027][012][km][ls]|zenfone \\d\\w?)\\b/i],[d,[f,E],[m,h]],[/(nexus 9)/i],[d,[f,"HTC"],[m,w]],[/(htc)[-;_ ]{1,2}([\\w ]+(?=\\)| bui)|\\w+)/i,/(zte)[- ]([\\w ]+?)(?: bui|\\/|\\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\\.))|sony(?!-bra))[-_ ]?([-\\w]*)/i],[f,[d,/_/g," "],[m,h]],[/droid.+; ([ab][1-7]-?[0178a]\\d\\d?)/i],[d,[f,"Acer"],[m,w]],[/droid.+; (m[1-5] note) bui/i,/\\bmz-([-\\w]{2,})/i],[d,[f,"Meizu"],[m,h]],[/(blackberry|benq|palm(?=\\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\\w]*)/i,/(hp) ([\\w ]+\\w)/i,/(asus)-?(\\w+)/i,/(microsoft); (lumia[\\w ]+)/i,/(lenovo)[-_ ]?([-\\w]+)/i,/(jolla)/i,/(oppo) ?([\\w ]+) bui/i],[f,d,[m,h]],[/(kobo)\\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\\/([\\w\\.]+)/i,/(nook)[\\w ]+build\\/(\\w+)/i,/(dell) (strea[kpr\\d ]*[\\dko])/i,/(le[- ]+pan)[- ]+(\\w{1,9}) bui/i,/(trinity)[- ]*(t\\d{3}) bui/i,/(gigaset)[- ]+(q\\w{1,9}) bui/i,/(vodafone) ([\\w ]+)(?:\\)| bui)/i],[f,d,[m,w]],[/(surface duo)/i],[d,[f,B],[m,w]],[/droid [\\d\\.]+; (fp\\du?)(?: b|\\))/i],[d,[f,"Fairphone"],[m,h]],[/(u304aa)/i],[d,[f,"AT&T"],[m,h]],[/\\bsie-(\\w*)/i],[d,[f,"Siemens"],[m,h]],[/\\b(rct\\w+) b/i],[d,[f,"RCA"],[m,w]],[/\\b(venue[\\d ]{2,7}) b/i],[d,[f,"Dell"],[m,w]],[/\\b(q(?:mv|ta)\\w+) b/i],[d,[f,"Verizon"],[m,w]],[/\\b(?:barnes[& ]+noble |bn[rt])([\\w\\+ ]*) b/i],[d,[f,"Barnes & Noble"],[m,w]],[/\\b(tm\\d{3}\\w+) b/i],[d,[f,"NuVision"],[m,w]],[/\\b(k88) b/i],[d,[f,"ZTE"],[m,w]],[/\\b(nx\\d{3}j) b/i],[d,[f,"ZTE"],[m,h]],[/\\b(gen\\d{3}) b.+49h/i],[d,[f,"Swiss"],[m,h]],[/\\b(zur\\d{3}) b/i],[d,[f,"Swiss"],[m,w]],[/\\b((zeki)?tb.*\\b) b/i],[d,[f,"Zeki"],[m,w]],[/\\b([yr]\\d{2}) b/i,/\\b(dragon[- ]+touch |dt)(\\w{5}) b/i],[[f,"Dragon Touch"],d,[m,w]],[/\\b(ns-?\\w{0,9}) b/i],[d,[f,"Insignia"],[m,w]],[/\\b((nxa|next)-?\\w{0,9}) b/i],[d,[f,"NextBook"],[m,w]],[/\\b(xtreme\\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[f,"Voice"],d,[m,h]],[/\\b(lvtel\\-)?(v1[12]) b/i],[[f,"LvTel"],d,[m,h]],[/\\b(ph-1) /i],[d,[f,"Essential"],[m,h]],[/\\b(v(100md|700na|7011|917g).*\\b) b/i],[d,[f,"Envizen"],[m,w]],[/\\b(trio[-\\w\\. ]+) b/i],[d,[f,"MachSpeed"],[m,w]],[/\\btu_(1491) b/i],[d,[f,"Rotor"],[m,w]],[/(shield[\\w ]+) b/i],[d,[f,"Nvidia"],[m,w]],[/(sprint) (\\w+)/i],[f,d,[m,h]],[/(kin\\.[onetw]{3})/i],[[d,/\\./g," "],[f,B],[m,h]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\\)/i],[d,[f,q],[m,w]],[/droid.+; (ec30|ps20|tc[2-8]\\d[kx])\\)/i],[d,[f,q],[m,h]],[/smart-tv.+(samsung)/i],[f,[m,y]],[/hbbtv.+maple;(\\d+)/i],[[d,/^/,"SmartTV"],[f,A],[m,y]],[/(nux; netcast.+smarttv|lg (netcast\\.tv-201\\d|android tv))/i],[[f,M],[m,y]],[/(apple) ?tv/i],[f,[d,S+" TV"],[m,y]],[/crkey/i],[[d,j+"cast"],[f,I],[m,y]],[/droid.+aft(\\w)( bui|\\))/i],[d,[f,_],[m,y]],[/\\(dtv[\\);].+(aquos)/i,/(aquos-tv[\\w ]+)\\)/i],[d,[f,L],[m,y]],[/(bravia[\\w ]+)( bui|\\))/i],[d,[f,U],[m,y]],[/(mitv-\\w{5}) bui/i],[d,[f,R],[m,y]],[/Hbbtv.*(technisat) (.*);/i],[f,d,[m,y]],[/\\b(roku)[\\dx]*[\\)\\/]((?:dvp-)?[\\d\\.]*)/i,/hbbtv\\/\\d+\\.\\d+\\.\\d+ +\\([\\w\\+ ]*; *([\\w\\d][^;]*);([^;]*)/i],[[f,H],[d,H],[m,y]],[/\\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\\b/i],[[m,y]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[f,d,[m,b]],[/droid.+; (shield) bui/i],[d,[f,"Nvidia"],[m,b]],[/(playstation [345portablevi]+)/i],[d,[f,U],[m,b]],[/\\b(xbox(?: one)?(?!; xbox))[\\); ]/i],[d,[f,B],[m,b]],[/((pebble))app/i],[f,d,[m,T]],[/(watch)(?: ?os[,\\/]|\\d,\\d\\/)[\\d\\.]+/i],[d,[f,S],[m,T]],[/droid.+; (glass) \\d/i],[d,[f,I],[m,T]],[/droid.+; (wt63?0{2,3})\\)/i],[d,[f,q],[m,T]],[/(quest( 2| pro)?)/i],[d,[f,F],[m,T]],[/(tesla)(?: qtcarbrowser|\\/[-\\w\\.]+)/i],[f,[m,k]],[/(aeobc)\\b/i],[d,[f,_],[m,k]],[/droid .+?; ([^;]+?)(?: bui|\\) applew).+? mobile safari/i],[d,[m,h]],[/droid .+?; ([^;]+?)(?: bui|\\) applew).+?(?! mobile) safari/i],[d,[m,w]],[/\\b((tablet|tab)[;\\/]|focus\\/\\d(?!.+mobile))/i],[[m,w]],[/(phone|mobile(?:[;\\/]| [ \\w\\/\\.]*safari)|pda(?=.+windows ce))/i],[[m,h]],[/(android[-\\w\\. ]{0,9});.+buil/i],[d,[f,"Generic"]]],engine:[[/windows.+ edge\\/([\\w\\.]+)/i],[v,[p,"EdgeHTML"]],[/webkit\\/537\\.36.+chrome\\/(?!27)([\\w\\.]+)/i],[v,[p,"Blink"]],[/(presto)\\/([\\w\\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\\/([\\w\\.]+)/i,/ekioh(flow)\\/([\\w\\.]+)/i,/(khtml|tasman|links)[\\/ ]\\(?([\\w\\.]+)/i,/(icab)[\\/ ]([23]\\.[\\d\\.]+)/i,/\\b(libweb)/i],[p,v],[/rv\\:([\\w\\.]{1,9})\\b.+(gecko)/i],[v,p]],os:[[/microsoft (windows) (vista|xp)/i],[p,v],[/(windows) nt 6\\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\\/ ]?([\\d\\.\\w ]*)/i,/(windows)[\\/ ]?([ntce\\d\\. ]+\\w)(?!.+xbox)/i],[p,[v,J,X]],[/(win(?=3|9|n)|win 9x )([nt\\d\\.]+)/i],[[p,"Windows"],[v,J,X]],[/ip[honead]{2,4}\\b(?:.*os ([\\w]+) like mac|; opera)/i,/ios;fbsv\\/([\\d\\.]+)/i,/cfnetwork\\/.+darwin/i],[[v,/_/g,"."],[p,"iOS"]],[/(mac os x) ?([\\w\\. ]*)/i,/(macintosh|mac_powerpc\\b)(?!.+haiku)/i],[[p,K],[v,/_/g,"."]],[/droid ([\\w\\.]+)\\b.+(android[- ]x86|harmonyos)/i],[v,p],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\\/ ]?([\\w\\.]*)/i,/(blackberry)\\w*\\/([\\w\\.]*)/i,/(tizen|kaios)[\\/ ]([\\w\\.]+)/i,/\\((series40);/i],[p,v],[/\\(bb(10);/i],[v,[p,x]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\\/ ]?([\\w\\.]*)/i],[v,[p,"Symbian"]],[/mozilla\\/[\\d\\.]+ \\((?:mobile|tablet|tv|mobile; [\\w ]+); rv:.+ gecko\\/([\\w\\.]+)/i],[v,[p,N+" OS"]],[/web0s;.+rt(tv)/i,/\\b(?:hp)?wos(?:browser)?\\/([\\w\\.]+)/i],[v,[p,"webOS"]],[/watch(?: ?os[,\\/]|\\d,\\d\\/)([\\d\\.]+)/i],[v,[p,"watchOS"]],[/crkey\\/([\\d\\.]+)/i],[v,[p,j+"cast"]],[/(cros) [\\w]+(?:\\)| ([\\w\\.]+)\\b)/i],[[p,z],v],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\\/(\\d+\\.[\\w\\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\\);]+)/i,/\\b(joli|palm)\\b ?(?:os)?\\/?([\\w\\.]*)/i,/(mint)[\\/\\(\\) ]?(\\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\\/ ]?(?!chrom|package)([-\\w\\.]*)/i,/(hurd|linux) ?([\\w\\.]*)/i,/(gnu) ?([\\w\\.]*)/i,/\\b([-frentopcghs]{0,5}bsd|dragonfly)[\\/ ]?(?!amd|[ix346]{1,2}86)([\\w\\.]*)/i,/(haiku) (\\w+)/i],[p,v],[/(sunos) ?([\\w\\.\\d]*)/i],[[p,"Solaris"],v],[/((?:open)?solaris)[-\\/ ]?([\\w\\.]*)/i,/(aix) ((\\d)(?=\\.|\\)| )[\\w\\.])*/i,/\\b(beos|os\\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\\w\\.]*)/i],[p,v]]},Z=function(e,t){if(typeof e===c&&(t=e,e=a),!(this instanceof Z))return new Z(e,t).getResult();var n=typeof i!==s&&i.navigator?i.navigator:a,r=e||(n&&n.userAgent?n.userAgent:""),b=n&&n.userAgentData?n.userAgentData:a,y=t?function(e,t){var n={};for(var r in e)t[r]&&t[r].length%2==0?n[r]=t[r].concat(e[r]):n[r]=e[r];return n}(G,t):G,T=n&&n.userAgent==r;return this.getBrowser=function(){var e,t={};return t[p]=a,t[v]=a,V.call(t,r,y.browser),t[l]=typeof(e=t[v])===u?e.replace(/[^\\d\\.]/g,"").split(".")[0]:a,T&&n&&n.brave&&typeof n.brave.isBrave==o&&(t[p]="Brave"),t},this.getCPU=function(){var e={};return e[g]=a,V.call(e,r,y.cpu),e},this.getDevice=function(){var e={};return e[f]=a,e[d]=a,e[m]=a,V.call(e,r,y.device),T&&!e[m]&&b&&b.mobile&&(e[m]=h),T&&"Macintosh"==e[d]&&n&&typeof n.standalone!==s&&n.maxTouchPoints&&n.maxTouchPoints>2&&(e[d]="iPad",e[m]=w),e},this.getEngine=function(){var e={};return e[p]=a,e[v]=a,V.call(e,r,y.engine),e},this.getOS=function(){var e={};return e[p]=a,e[v]=a,V.call(e,r,y.os),T&&!e[p]&&b&&"Unknown"!=b.platform&&(e[p]=b.platform.replace(/chrome os/i,z).replace(/macos/i,K)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return r},this.setUA=function(e){return r=typeof e===u&&e.length>350?H(e,350):e,this},this.setUA(r),this};Z.VERSION="1.0.35",Z.BROWSER=$([p,v,l]),Z.CPU=$([g]),Z.DEVICE=$([d,f,m,b,h,y,w,T,k]),Z.ENGINE=Z.OS=$([p,v]),typeof t!==s?(e.exports&&(t=e.exports=Z),t.UAParser=Z):n.amdO?(r=function(){return Z}.call(t,n,t,e))===a||(e.exports=r):typeof i!==s&&(i.UAParser=Z);var Y=typeof i!==s&&(i.jQuery||i.Zepto);if(Y&&!Y.ua){var ee=new Z;Y.ua=ee.getResult(),Y.ua.get=function(){return ee.getUA()},Y.ua.set=function(e){ee.setUA(e);var t=ee.getResult();for(var n in t)Y.ua[n]=t[n]}}}("object"==typeof window?window:this)}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var a=t[r]={exports:{}};return e[r].call(a.exports,a,a.exports,n),a.exports}n.amdO={},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{ActionType:()=>f,AmplitudePlatformName:()=>g,AnalyticsEventImportance:()=>l,AnalyticsQueries:()=>e,AuthStatus:()=>b,ComponentType:()=>m,IThresholdTier:()=>Jt,MetricType:()=>d,PlatformName:()=>v,SessionActions:()=>h,SessionAutomatedEvents:()=>w,SessionRank:()=>y,SubjectType:()=>p,UserTypeCommerce:()=>c,UserTypeInsto:()=>i,UserTypeRetail:()=>t,UserTypeRetailBusinessBanking:()=>s,UserTypeRetailEmployeeInternal:()=>a,UserTypeRetailEmployeePersonal:()=>o,UserTypeWallet:()=>u,automatedEvents:()=>xn,automatedMappingConfig:()=>In,clearMarkEntry:()=>Vn,clearPerformanceMarkEntries:()=>Xn,config:()=>A,createEventConfig:()=>On,createNewSpan:()=>Ln,createNewTrace:()=>Un,device:()=>W,endPerfMark:()=>Jn,exposeExperiment:()=>wn,flushQueue:()=>or,generateUUID:()=>V,getAnalyticsHeaders:()=>sr,getReferrerData:()=>le,getTracingHeaders:()=>An,getTracingId:()=>Dn,getUrlHostname:()=>pe,getUrlParams:()=>me,getUrlPathname:()=>fe,getUserContext:()=>ar,identify:()=>Tn,identifyFlow:()=>xe,identity:()=>H,identityFlow:()=>Se,incrementUjNavigation:()=>an,init:()=>yn,initNextJsTrackPageview:()=>_n,initTrackPageview:()=>kn,isEventKeyFormatValid:()=>we,isSessionEnded:()=>pt,location:()=>re,logEvent:()=>$t,logMetric:()=>Ht,logPageView:()=>on,logTrace:()=>Rn,markNTBT:()=>tn,markStep:()=>nn,markStepOnce:()=>rn,onVisibilityChange:()=>ln,optIn:()=>En,optOut:()=>Sn,perfMark:()=>Wn,persistentData:()=>oe,postMessage:()=>K,recordSessionDuration:()=>pn,removeFromIdentifyFlow:()=>Ee,savePersistentData:()=>st,sendScheduledEvents:()=>Bt,setBreadcrumbs:()=>ie,setConfig:()=>U,setLocation:()=>ae,setPagePath:()=>ve,setPageview:()=>Kt,setPersistentData:()=>se,setSessionStart:()=>dt,setTime:()=>Ue,startPerfMark:()=>Hn,timeStone:()=>Le,useEventLogger:()=>Yn,useLogEventOnMount:()=>tr,usePerformanceMarks:()=>rr});let e=function(e){return e.fbclid="fbclid",e.gclid="gclid",e.msclkid="msclkid",e.ptclid="ptclid",e.ttclid="ttclid",e.utm_source="utm_source",e.utm_medium="utm_medium",e.utm_campaign="utm_campaign",e.utm_term="utm_term",e.utm_content="utm_content",e}({});const t=0,i=1,a=2,o=3,s=4,c=5,u=6;let l=function(e){return e.low="low",e.high="high",e}({}),d=function(e){return e.count="count",e.rate="rate",e.gauge="gauge",e.distribution="distribution",e.histogram="histogram",e}({}),p=function(e){return e.commerce_merchant="commerce_merchant",e.device="device",e.edp_fingerprint_id="edp_fingerprint_id",e.nft_user="nft_user",e.user="user",e.wallet_user="wallet_user",e.uuid="user_uuid",e}({}),m=function(e){return e.unknown="unknown",e.banner="banner",e.button="button",e.card="card",e.chart="chart",e.content_script="content_script",e.dropdown="dropdown",e.link="link",e.page="page",e.modal="modal",e.table="table",e.search_bar="search_bar",e.service_worker="service_worker",e.text="text",e.text_input="text_input",e.tray="tray",e.checkbox="checkbox",e.icon="icon",e}({}),f=function(e){return e.unknown="unknown",e.blur="blur",e.click="click",e.change="change",e.dismiss="dismiss",e.focus="focus",e.hover="hover",e.select="select",e.measurement="measurement",e.move="move",e.process="process",e.render="render",e.scroll="scroll",e.view="view",e.search="search",e.keyPress="keyPress",e}({}),v=function(e){return e.unknown="unknown",e.web="web",e.android="android",e.ios="ios",e.mobile_web="mobile_web",e.tablet_web="tablet_web",e.server="server",e.windows="windows",e.macos="macos",e.extension="extension",e}({}),g=function(e){return e.web="Web",e.ios="iOS",e.android="Android",e}({}),b=function(e){return e[e.notLoggedIn=0]="notLoggedIn",e[e.loggedIn=1]="loggedIn",e}({}),h=function(e){return e.ac="ac",e.af="af",e.ah="ah",e.al="al",e.am="am",e.ar="ar",e.as="as",e}({}),w=function(e){return e.pv="pv",e}({}),y=function(e){return e.xs="xs",e.s="s",e.m="m",e.l="l",e.xl="xl",e.xxl="xxl",e}({});const T="https://analytics-service-dev.cbhq.net",k=3e5,_=5e3,S="analytics-db",E="experiment-exposure-db",x="Analytics SDK:",O=Object.values(e),j="pageview",N="session_duration",I={navigationTiming:{eventName:"perf_navigation_timing"},redirectTime:{eventName:"perf_redirect_time"},RT:{eventName:"perf_redirect_time"},TTFB:{eventName:"perf_time_to_first_byte"},networkInformation:{eventName:"perf_network_information"},storageEstimate:{eventName:"perf_storage_estimate"},FCP:{eventName:"perf_first_contentful_paint"},FID:{eventName:"perf_first_input_delay"},LCP:{eventName:"perf_largest_contentful_paint"},CLS:{eventName:"perf_cumulative_layout_shift"},TBT:{eventName:"perf_total_blocking_time"},NTBT:{eventName:"perf_navigation_total_blocking_time"},INP:{eventName:"perf_interact_to_next_paint"},ET:{eventName:"perf_element_timing"},userJourneyStep:{eventName:"perf_user_journey_step"}},P="1",M="web";function B(){return B=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},B.apply(this,arguments)}const C=/^(https?:\\/\\/)/;function D(e){return{eventsEndpoint:e+"/amp",metricsEndPoint:e+"/metrics",exposureEndpoint:e+"/track-exposures",tracesEndpoint:e+"/traces"}}const A=B({authCookie:"logged_in",amplitudeApiKey:"",batchEventsPeriod:_,batchEventsThreshold:30,batchMetricsPeriod:_,batchMetricsThreshold:30,batchTracesPeriod:_,batchTracesThreshold:30,headers:{},interactionManager:null,isAlwaysAuthed:!1,isProd:!1,isInternalApplication:!1,onError:(e,t)=>{console.error(x,e,t)},platform:v.unknown,projectName:"",ricTimeoutScheduleEvent:1e3,ricTimeoutSetDevice:500,showDebugLogging:!1,trackUserId:!1,version:null,apiEndpoint:T},D(T),{steps:{}}),L=[].reduce(((e,t)=>n=>e(t(n))),(e=>{if(!e.isProd)return e.isInternalApplication?(e.apiEndpoint="https://analytics-service-internal-dev.cbhq.net",B({},e,D(e.apiEndpoint))):e;const t=(e=>e.apiEndpoint?C.test(e.apiEndpoint)?e.apiEndpoint:`https://${e.apiEndpoint}`:e.isInternalApplication?"https://analytics-service-internal.cbhq.net":"https://as.coinbase.com")(e);return B({},e,{apiEndpoint:t},D(t))})),U=e=>{const{batchEventsThreshold:t,batchMetricsThreshold:n,batchTracesThreshold:r}=e,i=[t,n,r];for(const e of i)if((e||0)>30){console.warn("You are setting the threshhold for the batch limit to be greater than 30. This may cause request overload.");break}Object.assign(A,L(e))},R=[v.web,v.mobile_web,v.tablet_web];function q(){return"android"===A.platform}function F(){return"ios"===A.platform}function z(){return R.includes(A.platform)}function K(e){if(z()&&navigator&&"serviceWorker"in navigator&&navigator.serviceWorker.controller)try{navigator.serviceWorker.controller.postMessage(e)}catch(e){e instanceof Error&&A.onError(e)}}var $=n(353),Q=n.n($);const W={amplitudeOSName:null,amplitudeOSVersion:null,amplitudeDeviceModel:null,amplitudePlatform:null,browserName:null,browserMajor:null,osName:null,userAgent:null,width:null,height:null},H={countryCode:null,deviceId:null,device_os:null,isOptOut:!1,languageCode:null,locale:null,jwt:null,session_lcc_id:null,userAgent:null,userId:null},V=e=>e?(e^16*Math.random()>>e/4).toString(16):"10000000-1000-4000-8000-100000000000".replace(/[018]/g,V),J=()=>A.isAlwaysAuthed||!!H.userId,X=()=>{const e={};return H.countryCode&&(e.country_code=H.countryCode),e},G=()=>{const{platform:e}=A;if(e===v.web)switch(!0){case window.matchMedia("(max-width: 560px)").matches:return v.mobile_web;case window.matchMedia("(max-width: 1024px, min-width: 561px)").matches:return v.tablet_web}return e},Z=()=>{var e,t,n,r,i;z()?("requestIdleCallback"in window?window.requestIdleCallback(ne,{timeout:A.ricTimeoutSetDevice}):ne(),W.amplitudePlatform=g.web,W.userAgent=(null==(e=window)||null==(e=e.navigator)?void 0:e.userAgent)||null,ee({height:null!=(t=null==(n=window)?void 0:n.innerHeight)?t:null,width:null!=(r=null==(i=window)?void 0:i.innerWidth)?r:null})):F()?(W.amplitudePlatform=g.ios,W.userAgent=H.userAgent,W.userAgent&&ne()):q()&&(W.userAgent=H.userAgent,W.amplitudePlatform=g.android,W.userAgent&&ne())},Y=e=>{Object.assign(H,e),z()&&K({identity:{isAuthed:!!H.userId,locale:H.locale||null}})},ee=e=>{W.height=e.height,W.width=e.width},te=()=>{U({platform:G()}),z()&&K({config:{platform:A.platform}})},ne=()=>{var e;performance.mark&&performance.mark("ua_parser_start");const t=new(Q())(null!=(e=W.userAgent)?e:"").getResult();W.browserName=t.browser.name||null,W.browserMajor=t.browser.major||null,W.osName=t.os.name||null,W.amplitudeOSName=W.browserName,W.amplitudeOSVersion=W.browserMajor,W.amplitudeDeviceModel=W.osName,K({device:{browserName:W.browserName,osName:W.osName}}),performance.mark&&(performance.mark("ua_parser_end"),performance.measure("ua_parser","ua_parser_start","ua_parser_end"))},re={breadcrumbs:[],initialUAAData:{},pageKey:"",pageKeyRegex:{},pagePath:"",prevPageKey:"",prevPagePath:""};function ie(e){Object.assign(re,{breadcrumbs:e})}function ae(e){Object.assign(re,e)}const oe={eventId:0,sequenceNumber:0,sessionId:0,lastEventTime:0,sessionStart:0,sessionUUID:null,userId:null,ac:0,af:0,ah:0,al:0,am:0,ar:0,as:0,pv:0};function se(e){Object.assign(oe,e)}function ce(){var e,t;return null!=(e=null==(t=document)?void 0:t.referrer)?e:""}function ue(){return ue=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ue.apply(this,arguments)}const le=()=>{const e=ce();if(!e)return{};const t=new URL(e);return t.hostname===pe()?{}:{referrer:e,referring_domain:t.hostname}},de=()=>{const e=new URLSearchParams(me()),t={};return O.forEach((n=>{e.has(n)&&(t[n]=(e.get(n)||"").toLowerCase())})),t},pe=()=>{var e;return(null==(e=window)||null==(e=e.location)?void 0:e.hostname)||""},me=()=>{var e;return(null==(e=window)||null==(e=e.location)?void 0:e.search)||""},fe=()=>{var e;return(null==(e=window)||null==(e=e.location)?void 0:e.pathname)||""},ve=()=>{const e=A.overrideWindowLocation?re.pagePath:fe()+me();e&&e!==re.pagePath&&(e!==re.pagePath&&ge(),re.pagePath=e,re.pageKeyRegex&&Object.keys(re.pageKeyRegex).some((e=>{if(re.pageKeyRegex[e].test(re.pagePath))return re.pageKey=e,!0})))},ge=()=>{if(z()){const e=ce();if(!re.prevPagePath&&e){const t=new URL(e);if(t.hostname===pe())return void(re.prevPagePath=t.pathname)}}re.prevPagePath=re.pagePath,re.prevPageKey=re.pageKey},be=e=>{z()&&Object.assign(e,z()?(Object.keys(re.initialUAAData).length>0||(new URLSearchParams(me()),re.initialUAAData=ue({},(()=>{const e={};return O.forEach((t=>{oe[t]&&(e[t]=oe[t])})),e})(),de(),le())),re.initialUAAData):re.initialUAAData)},he=/^[a-zd]+(_[a-zd]+)*$/;function we(e){return he.test(e)}function ye(){return ye=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ye.apply(this,arguments)}const Te=["action","component_type","component_name","context","logging_id"],ke=["num_non_hardware_accounts","ujs"],_e="ujs_",Se={};function Ee(e){e.forEach((e=>{ke.includes(e)&&delete Se[e]}))}function xe(e){var t;const n=Object.entries(e).reduce(((e,t)=>{const[n,r]=t;return!Te.includes(n)&&ke.includes(n)?we(n)?ye({},e,{[n]:r}):(A.onError(new Error("IdentityFlow property names must have snake case format"),{[n]:r}),e):e}),{});null!=(t=n.ujs)&&t.length&&(n.ujs=n.ujs.map((e=>`${_e}${e}`))),Object.assign(Se,n)}function Oe(){return A.platform!==v.unknown||(A.onError(new Error("SDK platform not initialized")),!1)}const je={eventsQueue:[],eventsScheduled:!1,metricsQueue:[],metricsScheduled:!1,tracesQueue:[],tracesScheduled:!1};function Ne(e){Object.assign(je,e)}const Ie={ac:0,af:0,ah:0,al:0,am:0,ar:0,as:0,pv:0,sqs:0},Pe={ac:20,af:5,ah:1,al:1,am:0,ar:10,as:20},Me={pv:25},Be={xs:0,s:1,m:1,l:2,xl:2,xxl:2},Ce=e=>e<15?y.xs:e<60?y.s:e<240?y.m:e<960?y.l:e<3840?y.xl:y.xxl,De=e=>{Object.assign(Ie,e)};function Ae(){return(new Date).getTime()}const Le={timeStart:Ae(),timeOnPagePath:0,timeOnPageKey:0,prevTimeOnPagePath:0,prevTimeOnPageKey:0,sessionDuration:0,sessionEnd:0,sessionStart:0,prevSessionDuration:0};function Ue(e){Object.assign(Le,e)}const Re=(e,t)=>t.some((t=>e instanceof t));let qe,Fe;const ze=new WeakMap,Ke=new WeakMap,$e=new WeakMap,Qe=new WeakMap,We=new WeakMap;let He={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return Ke.get(e);if("objectStoreNames"===t)return e.objectStoreNames||$e.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Je(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function Ve(e){return"function"==typeof e?(t=e)!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(Fe||(Fe=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(Xe(this),e),Je(ze.get(this))}:function(...e){return Je(t.apply(Xe(this),e))}:function(e,...n){const r=t.call(Xe(this),e,...n);return $e.set(r,e.sort?e.sort():[e]),Je(r)}:(e instanceof IDBTransaction&&function(e){if(Ke.has(e))return;const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("complete",i),e.removeEventListener("error",a),e.removeEventListener("abort",a)},i=()=>{t(),r()},a=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",i),e.addEventListener("error",a),e.addEventListener("abort",a)}));Ke.set(e,t)}(e),Re(e,qe||(qe=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,He):e);var t}function Je(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("success",i),e.removeEventListener("error",a)},i=()=>{t(Je(e.result)),r()},a=()=>{n(e.error),r()};e.addEventListener("success",i),e.addEventListener("error",a)}));return t.then((t=>{t instanceof IDBCursor&&ze.set(t,e)})).catch((()=>{})),We.set(t,e),t}(e);if(Qe.has(e))return Qe.get(e);const t=Ve(e);return t!==e&&(Qe.set(e,t),We.set(t,e)),t}const Xe=e=>We.get(e),Ge=["get","getKey","getAll","getAllKeys","count"],Ze=["put","add","delete","clear"],Ye=new Map;function et(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(Ye.get(t))return Ye.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,i=Ze.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!i&&!Ge.includes(n))return;const a=async function(e,...t){const a=this.transaction(e,i?"readwrite":"readonly");let o=a.store;return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&&a.done]))[0]};return Ye.set(t,a),a}var tt;tt=He,He={...tt,get:(e,t,n)=>et(e,t)||tt.get(e,t,n),has:(e,t)=>!!et(e,t)||tt.has(e,t)};const nt={isReady:!1,idbKeyval:null};function rt(e){Object.assign(nt,e)}const it={},at=async e=>{if(!nt.idbKeyval)return Promise.resolve(null);try{return await nt.idbKeyval.get(e)}catch(e){return A.onError(new Error("IndexedDB:Get:InternalError")),Promise.resolve(null)}},ot=async(e,t)=>{if(nt.idbKeyval)try{await nt.idbKeyval.set(e,t)}catch(e){A.onError(new Error("IndexedDB:Set:InternalError"))}},st=()=>{"server"!==A.platform&&(se({sessionStart:Le.sessionStart,ac:Ie.ac,af:Ie.af,ah:Ie.ah,al:Ie.al,am:Ie.am,ar:Ie.ar,as:Ie.as,pv:Ie.pv}),H.userId&&se({userId:H.userId}),ot(S,oe))},ct="rgb(5,177,105)",ut=e=>{const{metricName:t,data:n}=e,r=e.importance||l.low;if(!A.showDebugLogging||!console)return;const i=`%c ${x}`,a=`color:${ct};font-size:11px;`,o=`Importance: ${r}`;console.group(i,a,t,o),n.forEach((e=>{e.event_type?console.log(e.event_type,e):console.log(e)})),console.groupEnd()},lt=e=>{const{metricName:t,data:n}=e,r=e.importance||l.low;if(!A.showDebugLogging||!console)return;const i=`color:${ct};font-size:11px;`,a=`%c ${x}`,o=`Importance: ${r}`;console.log(a,i,t,n,o)},dt=()=>{const e=Ae();oe.sessionId&&oe.lastEventTime&&oe.sessionUUID&&!pt(e)||(oe.sessionId=e,oe.sessionUUID=V(),Ue({sessionStart:e}),lt({metricName:"Started new session:",data:{persistentData:oe,timeStone:Le}})),oe.lastEventTime=e},pt=e=>e-oe.lastEventTime>18e5;function mt(){return mt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},mt.apply(this,arguments)}const ft=e=>{var t;(e=>{switch(e.action){case f.click:Ie.ac+=1;break;case f.focus:Ie.af+=1;break;case f.hover:Ie.ah+=1;break;case f.move:Ie.am+=1;break;case f.scroll:Ie.al+=1;break;case f.search:Ie.ar+=1;break;case f.select:Ie.as+=1}})(t=e),t.event_type!==j?t.event_type===N&&((e=>{if(!e.session_rank)return;const t=e.session_rank;Object.values(h).forEach((e=>{Ie.sqs+=Ie[e]*Pe[e]})),Object.values(w).forEach((e=>{Ie.sqs+=Ie[e]*Me[e]})),Ie.sqs*=Be[t]})(t),Object.assign(t,Ie),De({ac:0,af:0,ah:0,al:0,am:0,ar:0,as:0,pv:0,sqs:0})):Ie.pv+=1;const n=e.event_type;delete e.event_type;const r=e.deviceId?e.deviceId:null,i=e.timestamp;return delete e.timestamp,se({eventId:oe.eventId+1}),se({sequenceNumber:oe.sequenceNumber+1}),dt(),st(),{device_id:H.deviceId||r||null,user_id:H.userId,timestamp:i,event_id:oe.eventId,session_id:oe.sessionId||-1,event_type:n,version_name:A.version||null,platform:W.amplitudePlatform,os_name:W.amplitudeOSName,os_version:W.amplitudeOSVersion,device_model:W.amplitudeDeviceModel,language:H.languageCode,event_properties:mt({},e,{session_uuid:oe.sessionUUID,height:W.height,width:W.width}),user_properties:X(),uuid:V(),library:{name:"@cbhq/client-analytics",version:"10.6.0"},sequence_number:oe.sequenceNumber,user_agent:W.userAgent||H.userAgent}},vt=e=>e.map((e=>ft(e)));function gt(){return gt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},gt.apply(this,arguments)}const bt=e=>e.map((e=>(e=>{const t=e.tags||{},n=gt({authed:J()?"true":"false",platform:A.platform},t,{project_name:A.projectName,version_name:A.version||null});return{metric_name:e.metricName,page_path:e.pagePath||null,value:e.value,tags:n,type:e.metricType}})(e))),ht=e=>0!==je.metricsQueue.length&&(je.metricsQueue.length>=A.batchMetricsThreshold||(je.metricsScheduled||(je.metricsScheduled=!0,setTimeout((()=>{je.metricsScheduled=!1,e(bt(je.metricsQueue)),je.metricsQueue=[]}),A.batchMetricsPeriod)),!1)),wt=e=>0!==je.tracesQueue.length&&(je.tracesQueue.length>=A.batchTracesThreshold||(je.tracesScheduled||(je.tracesScheduled=!0,setTimeout((()=>{je.tracesScheduled=!1,e(je.tracesQueue),je.tracesQueue=[]}),A.batchTracesPeriod)),!1)),yt=e=>{var t;z()&&null!=(t=window)&&t.requestIdleCallback?window.requestIdleCallback(e,{timeout:A.ricTimeoutScheduleEvent}):(q()||F())&&A.interactionManager?A.interactionManager.runAfterInteractions(e):e()};function Tt(){return Tt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Tt.apply(this,arguments)}const kt="application/x-www-form-urlencoded; charset=UTF-8",_t=e=>{const{data:t,importance:n,isJSON:r,onError:i,url:a}=e,o=r?"application/json":kt,s=n||l.low,c=r?JSON.stringify(t):new URLSearchParams(t).toString();function u(){const e=new XMLHttpRequest;e.open("POST",a,!0),Object.keys(A.headers||{}).forEach((t=>{e.setRequestHeader(t,A.headers[t])})),e.setRequestHeader("Content-Type",kt),H.jwt&&e.setRequestHeader("authorization",`Bearer ${H.jwt}`),e.send(c)}if(!z()||r||!("sendBeacon"in navigator)||s!==l.low||A.headers&&0!==Object.keys(A.headers).length)if(z()&&!r)u();else{const e=Tt({},A.headers,{"Content-Type":o});H.jwt&&(e.Authorization=`Bearer ${H.jwt}`),fetch(a,{method:"POST",mode:"no-cors",headers:e,body:c}).catch((e=>{i(e,{context:"AnalyticsSDKApiError"})}))}else{const e=new Blob([c],{type:kt});try{navigator.sendBeacon.bind(navigator)(a,e)||u()}catch(e){console.error(e),u()}}};var St=n(762),Et=n.n(St);const xt=(e,t,n)=>{const r=e||"";return Et()("2"+r+t+n)};function Ot(){return Ot=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ot.apply(this,arguments)}class jt extends Error{constructor(e){super(e),this.name="CircularJsonReference",this.message=e,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error(e).stack}}class Nt extends jt{constructor(...e){super(...e),this.name="DomReferenceInAnalyticsEvent"}}function It(){return It=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},It.apply(this,arguments)}const Pt=(e,t=l.low)=>{var n;e&&je.eventsQueue.push(e),nt.isReady&&(!A.trackUserId||H.userId?(t===l.high||(n=Mt,0!==je.eventsQueue.length&&(je.eventsQueue.length>=A.batchEventsThreshold||(je.eventsScheduled||(je.eventsScheduled=!0,setTimeout((()=>{je.eventsScheduled=!1,n(vt(je.eventsQueue)),je.eventsQueue=[]}),A.batchEventsPeriod)),0))))&&Bt():je.eventsQueue.length>10&&(A.trackUserId=!1,A.onError(new Error("userId not set in Logged-in"))))},Mt=(e,t=l.low)=>{if(H.isOptOut||0===e.length)return;let n;try{n=JSON.stringify(e)}catch(t){const r=e.map((e=>e.event_type)).join(", "),[i,a]=(e=>{try{const n=[];for(const r of e){const e=Ot({},r);r.event_properties&&(e.event_properties=Ot({},e.event_properties,{currentTarget:null,target:null,relatedTarget:null,_dispatchInstances:null,_targetInst:null,view:(t=r.event_properties.view,["string","number","boolean"].includes(typeof t)?r.event_properties.view:null)})),n.push(e)}return[!0,JSON.stringify(n)]}catch(e){return[!1,""]}var t})(e);if(!i)return void A.onError(new jt(t instanceof Error?t.message:"unknown"),{listEventType:r});n=a,A.onError(new Nt("Found DOM element reference"),{listEventType:r,stringifiedEventData:n})}const r=Ae().toString(),i=It({},{e:n,v:"2",upload_time:r},{client:A.amplitudeApiKey,checksum:xt(A.amplitudeApiKey,n,r)});_t({url:A.eventsEndpoint,data:i,importance:t,onError:A.onError}),ut({metricName:"Batch Events",data:e,importance:t})},Bt=()=>{Mt(vt(je.eventsQueue)),Ne({eventsQueue:[]})};function Ct(){return Ct=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ct.apply(this,arguments)}const Dt=Object.values(f),At=Object.values(m),Lt=e=>Dt.includes(e)?e:f.unknown,Ut=e=>At.includes(e)?e:m.unknown,Rt=(e,t,n)=>{const r={auth:J()?b.loggedIn:b.notLoggedIn,action:Lt(e),component_type:Ut(t),logging_id:n,platform:A.platform,project_name:A.projectName};return"number"==typeof H.userTypeEnum&&(r.user_type_enum=H.userTypeEnum),r},qt=e=>{const t=Ae();if(!e)return A.onError(new Error("missing logData")),Ct({},Rt(f.unknown,m.unknown),{locale:H.locale,session_lcc_id:H.session_lcc_id,timestamp:t,time_start:Le.timeStart});const n=Ct({},e,Rt(e.action,e.componentType,e.loggingId),{locale:H.locale,session_lcc_id:H.session_lcc_id,timestamp:t,time_start:Le.timeStart});return delete n.componentType,delete n.loggingId,n},Ft={blacklistRegex:[],isEnabled:!1};function zt(){return{page_key:re.pageKey,page_path:re.pagePath,prev_page_key:re.prevPageKey,prev_page_path:re.prevPagePath}}function Kt(e){Object.assign(Ft,e)}function $t(e,t,n=l.low){if(H.isOptOut)return;if(!Oe())return;const r=qt(t);!function(e){Ft.isEnabled&&(ve(),Object.assign(e,zt()))}(r),be(r),function(e){Object.keys(Se).length>0&&Object.assign(e,Se)}(r),r.has_double_fired=!1,r.event_type=e,n===l.high?Pt(r,n):yt((()=>{Pt(r)}))}function Qt(e,t=!1){t?_t({url:A.metricsEndPoint,data:{metrics:e},isJSON:!0,onError:A.onError}):yt((()=>{_t({url:A.metricsEndPoint,data:{metrics:e},isJSON:!0,onError:A.onError})})),ut({metricName:"Batch Metrics",data:e})}function Wt(){return Wt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Wt.apply(this,arguments)}function Ht(e){if(!Oe())return;v.server!==A.platform&&!e.pagePath&&re.pagePath&&(e.pagePath=re.pagePath);const t=Object.keys(Se).length?Wt({},e.tags,Se):e.tags;t&&Object.assign(e,{tags:t}),je.metricsQueue.push(e),ht(Qt)&&(Qt(bt(je.metricsQueue)),je.metricsQueue=[])}function Vt(){return Vt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Vt.apply(this,arguments)}let Jt=function(e){return e.instant="instant",e.quick="quick",e.moderate="moderate",e.slow="slow",e.unavoidable="unavoidable",e}({});function Xt(e){return e.toLowerCase()}let Gt={};const Zt=(e,t)=>{null!=A&&A.onMarkStep&&A.onMarkStep(e,t),xe({ujs:t})};let Yt;const en={Perfume:()=>{},markStep:e=>{},markStepOnce:e=>{},incrementUjNavigation:()=>{}},tn=()=>{z()&&Yt&&Yt.markNTBT&&Yt.markNTBT()},nn=e=>{z()&&Yt&&en.markStep&&en.markStep(e)},rn=e=>{z()&&Yt&&en.markStepOnce&&en.markStepOnce(e)},an=()=>{z()&&Yt&&en.incrementUjNavigation&&en.incrementUjNavigation()};function on(e={callMarkNTBT:!0}){"unknown"!==A.platform&&(Ft.blacklistRegex.some((e=>e.test(fe())))||($t(j,{action:f.render,componentType:m.page}),e.callMarkNTBT&&tn()))}let sn=!1,cn=!1;const un=e=>{sn=!e.persisted},ln=(e,t="hidden",n=!1)=>{cn||(addEventListener("pagehide",un),addEventListener("beforeunload",(()=>{})),cn=!0),addEventListener("visibilitychange",(({timeStamp:n})=>{document.visibilityState===t&&e({timeStamp:n,isUnloading:sn})}),{capture:!0,once:n})},dn=36e3;function pn(){const e=pt(Ae());if(e&&(O.forEach((e=>{oe[e]&&delete oe[e]})),st()),!oe.lastEventTime||!Le.sessionStart||!e)return;const t=Math.round((oe.lastEventTime-Le.sessionStart)/1e3);if(t<1||t>dn)return;const n=Ce(t);$t(N,{action:f.measurement,componentType:m.page,session_duration:t,session_end:oe.lastEventTime,session_start:Le.sessionStart,session_rank:n})}function mn(){return mn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},mn.apply(this,arguments)}const fn=[],vn=[],gn=()=>{const e=fn.shift();e&&e()},bn=()=>{const e=vn.shift();e&&e()};let hn={};function wn(e){const t=function(e){return{test_name:e.testName,group_name:e.group,subject_id:e.subjectId,exposed_at:Ae(),subject_type:e.subjectType,platform:A.platform}}(e);hn[e.testName]=hn[e.testName]||0,hn[e.testName]+k>Ae()?lt({metricName:`Event: exposeExperiment ${e.testName} not sent`,data:t}):(hn[e.testName]=Ae(),ot(E,hn),lt({metricName:`Event: exposeExperiment ${e.testName} sent`,data:t}),_t({url:A.exposureEndpoint,data:[t],onError:(t,n)=>{hn[e.testName]=0,ot(E,hn),A.onError(t,n)},isJSON:!0,importance:l.high}))}const yn=e=>{var t,r,i;U(e),z()&&(H.languageCode=(null==(t=navigator)?void 0:t.languages[0])||(null==(r=navigator)?void 0:r.language)||""),te(),(()=>{var e;if(z()&&null!=(e=window)&&e.indexedDB){const e=function(e,t,{blocked:n,upgrade:r,blocking:i,terminated:a}={}){const o=indexedDB.open(e,t),s=Je(o);return r&&o.addEventListener("upgradeneeded",(e=>{r(Je(o.result),e.oldVersion,e.newVersion,Je(o.transaction),e)})),n&&o.addEventListener("blocked",(e=>n(e.oldVersion,e.newVersion,e))),s.then((e=>{a&&e.addEventListener("close",(()=>a())),i&&e.addEventListener("versionchange",(e=>i(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),s}("keyval-store",1,{upgrade(e){e.createObjectStore("keyval")}});rt({idbKeyval:{get:async t=>(await e).get("keyval",t),set:async(t,n)=>(await e).put("keyval",n,t),delete:async t=>(await e).delete("keyval",t),keys:async()=>(await e).getAllKeys("keyval")}})}else rt({idbKeyval:{get:async e=>new Promise((t=>{t(it[e])})),set:async(e,t)=>new Promise((n=>{it[e]=t,n(e)})),delete:async e=>new Promise((()=>{delete it[e]})),keys:async()=>new Promise((e=>{e(Object.keys(it))}))}})})(),lt({metricName:"Initialized Analytics:",data:{deviceId:H.deviceId}}),fn.push((()=>{Pt()})),(async()=>{const e=await at(S);rt({isReady:!0}),gn(),e&&(bn(),se({eventId:e.eventId||oe.eventId,sequenceNumber:e.sequenceNumber||oe.sequenceNumber,sessionId:e.sessionId||oe.sessionId,lastEventTime:e.lastEventTime||oe.lastEventTime,sessionUUID:e.sessionUUID||oe.sessionUUID}),function(e){se(mn({},function(e){const t={};return O.forEach((n=>{e[n]&&(t[n]=e[n])})),t}(e),de()))}(e),Ue({sessionStart:e.sessionStart||oe.sessionStart}),De({ac:e.ac||Ie.ac,af:e.af||Ie.af,ah:e.ah||Ie.ah,al:e.al||Ie.al,am:e.am||Ie.am,ar:e.ar||Ie.ar,as:e.as||Ie.as,pv:e.pv||Ie.pv}),A.trackUserId&&Y({userId:e.userId||H.userId}),pn(),lt({metricName:"Initialized Analytics IndexedDB:",data:e}))})(),async function(){at(E).then((e=>{hn=null!=e?e:{}})).catch((e=>{e instanceof Error&&A.onError(e)}))}(),Z(),z()&&(ln((()=>{se({lastEventTime:Ae()}),st(),Bt()}),"hidden"),ln((()=>{pn()}),"visible")),z()&&(i=()=>{var e,t,n,r;te(),ee({width:null!=(e=null==(t=window)?void 0:t.innerWidth)?e:null,height:null!=(n=null==(r=window)?void 0:r.innerHeight)?n:null})},addEventListener("resize",(()=>{requestAnimationFrame((()=>{i()}))}))),(()=>{if(z())try{const e=n(2);en.markStep=e.markStep,en.markStepOnce=e.markStepOnce,en.incrementUjNavigation=e.incrementUjNavigation,Yt=new e.Perfume({analyticsTracker:e=>{const{data:t,attribution:n,metricName:r,navigatorInformation:i,rating:a}=e,o=I[r],s=(null==n?void 0:n.category)||null;if(!o&&!s)return;const c=(null==i?void 0:i.deviceMemory)||0,u=(null==i?void 0:i.hardwareConcurrency)||0,l=(null==i?void 0:i.isLowEndDevice)||!1,p=(null==i?void 0:i.isLowEndExperience)||!1,v=(null==i?void 0:i.serviceWorkerStatus)||"unsupported",g=Vt({deviceMemory:c,hardwareConcurrency:u,isLowEndDevice:l,isLowEndExperience:p,serviceWorkerStatus:v},Gt),b={is_low_end_device:l,is_low_end_experience:p,page_key:re.pageKey||"",save_data:t.saveData||!1,service_worker:v,is_perf_metric:!0};if("navigationTiming"===r)t&&"number"==typeof t.redirectTime&&Ht({metricName:I.redirectTime.eventName,metricType:d.histogram,tags:b,value:t.redirectTime||0});else if("TTFB"===r)$t(o.eventName,Vt({action:f.measurement,componentType:m.page,duration:t||null,vitalsScore:a||null},g)),Ht({metricName:I.TTFB.eventName,metricType:d.histogram,tags:Vt({},b),value:t}),a&&Ht({metricName:`perf_web_vitals_ttfb_${a}`,metricType:d.count,tags:b,value:1});else if("networkInformation"===r)null!=t&&t.effectiveType&&(Gt=t,$t(o.eventName,{action:f.measurement,componentType:m.page,networkInformationDownlink:t.downlink,networkInformationEffectiveType:t.effectiveType,networkInformationRtt:t.rtt,networkInformationSaveData:t.saveData,navigatorDeviceMemory:c,navigatorHardwareConcurrency:u}));else if("storageEstimate"===r)$t(o.eventName,Vt({action:f.measurement,componentType:m.page},t,g)),Ht({metricName:"perf_storage_estimate_caches",metricType:d.histogram,tags:b,value:t.caches}),Ht({metricName:"perf_storage_estimate_indexed_db",metricType:d.histogram,tags:b,value:t.indexedDB});else if("CLS"===r)$t(o.eventName,Vt({action:f.measurement,componentType:m.page,score:100*t||null,vitalsScore:a||null},g)),a&&Ht({metricName:`perf_web_vitals_cls_${a}`,metricType:d.count,tags:b,value:1});else if("FID"===r){const e=(null==n?void 0:n.performanceEntry)||null,r=parseInt((null==e?void 0:e.processingStart)||"");$t(o.eventName,Vt({action:f.measurement,componentType:m.page,duration:t||null,processingStart:null!=e&&e.processingStart?r:null,startTime:null!=e&&e.startTime?parseInt(e.startTime):null,vitalsScore:a||null},g)),a&&Ht({metricName:`perf_web_vitals_fidVitals_${a}`,metricType:d.count,tags:b,value:1})}else"userJourneyStep"===r?($t("perf_user_journey_step",Vt({action:f.measurement,componentType:m.page,duration:t||null,rating:null!=a?a:null,step_name:(null==n?void 0:n.stepName)||""},g)),Ht({metricName:`user_journey_step.${A.projectName}.${A.platform}.${(null==n?void 0:n.stepName)||""}_vitals_${a}`,metricType:d.count,tags:b,value:1}),Ht({metricName:`user_journey_step.${A.projectName}.${A.platform}.${(null==n?void 0:n.stepName)||""}`,metricType:d.distribution,tags:b,value:t||null})):I[r]&&t&&($t(o.eventName,Vt({action:f.measurement,componentType:m.page,duration:t||null,vitalsScore:a||null},g)),a&&(Ht({metricName:`perf_web_vitals_${Xt(r)}_${a}`,metricType:d.count,tags:b,value:1}),"LCP"===r&&Ht({metricName:`perf_web_vitals_${Xt(r)}`,metricType:d.distribution,tags:b,value:t})))},maxMeasureTime:3e4,steps:A.steps,onMarkStep:Zt})}catch(e){e instanceof Error&&A.onError(e)}})()},Tn=e=>{Y(e),e.userAgent&&Z(),lt({metricName:"Identify:",data:{countryCode:H.countryCode,deviceId:H.deviceId,userId:H.userId}})},kn=({blacklistRegex:e,pageKeyRegex:t,browserHistory:n})=>{Kt({blacklistRegex:e||[],isEnabled:!0}),ae({pageKeyRegex:t}),on({callMarkNTBT:!1}),n.listen((()=>{on()}))},_n=({blacklistRegex:e,pageKeyRegex:t,nextJsRouter:n})=>{Kt({blacklistRegex:e||[],isEnabled:!0}),ae({pageKeyRegex:t}),on({callMarkNTBT:!1}),n.events.on("routeChangeComplete",(()=>{on()}))},Sn=()=>{Y({isOptOut:!0}),ot(S,{})},En=()=>{Y({isOptOut:!1})},xn={Button:{label:"cb_button",uuid:"e921a074-40e6-4371-8700-134d5cd633e6",componentType:m.button}};function On(e,t,n){return{componentName:e,actions:t,data:n}}function jn(){return jn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},jn.apply(this,arguments)}function Nn(e,t,n){const{componentName:r,data:i}=n;$t(e.label,jn({componentType:e.componentType,action:t,loggingId:e.uuid,component_name:r},i))}const In={actionMapping:{onPress:f.click,onHover:f.hover},handlers:{Button:{[f.click]:e=>Nn(xn.Button,f.click,e),[f.hover]:e=>Nn(xn.Button,f.hover,e)}}};function Pn(e,t=!1){t?_t({url:A.tracesEndpoint,data:{traces:e},isJSON:!0,onError:A.onError}):yt((()=>{_t({url:A.tracesEndpoint,data:{traces:e},isJSON:!0,onError:A.onError})})),ut({metricName:"Batch Traces",data:e})}function Mn(){return Mn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Mn.apply(this,arguments)}const Bn=1e6;function Cn(e){return e*Bn}function Dn(e=function(){var e;return null==(e=window)?void 0:e.crypto}()){const t=new Uint32Array(2);return null==e||e.getRandomValues(t),((BigInt(t[0])<<BigInt(32))+BigInt(t[1])).toString()}function An(e,t){return{"x-datadog-origin":"rum","x-datadog-parent-id":t,"x-datadog-sampling-priority":"1","x-datadog-trace-id":e}}function Ln(e){var t;const{name:n,traceId:r,spanId:i,start:a,duration:o,resource:s,meta:c}=e;return{duration:o?Cn(o):0,name:n,resource:s,service:A.projectName,span_id:null!=i?i:Dn(),start:a?Cn(a):0,trace_id:null!=r?r:Dn(),parent_id:P,type:M,meta:Mn({platform:A.platform},re.pageKey?{page_key:re.pageKey}:{},null!=(t=Se.ujs)&&t.length?{last_ujs:Se.ujs[Se.ujs.length-1]}:{},null!=c?c:{})}}function Un(e){return[Ln(e)]}function Rn(e,t){Oe()&&function(e){return e.length>0}(e)&&(t&&function(e,t){e.forEach((e=>function(e,t){const n=Mn({},e.meta,t.meta),r={start:t.start?Cn(t.start):e.start,duration:t.duration?Cn(t.duration):e.duration};Object.assign(e,t,Mn({meta:n},r))}(e,t)))}(e,t),je.tracesQueue.push(e),wt(Pn)&&(Pn(je.tracesQueue),je.tracesQueue=[]))}function qn(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}function Fn(){return Fn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Fn.apply(this,arguments)}function zn(){return void 0!==typeof window&&"performance"in window&&"mark"in performance&&"getEntriesByName"in performance}function Kn(e,t){return`perf_${e}${null!=t&&t.label?`_${t.label}`:""}`}function $n(e,t,n){return`${Kn(e,n)}__${t}`}let Qn={};function Wn(e,t,n){if(!zn())return;const r=$n(e,t,n);if(performance.mark(r),"end"===t){const t=Kn(e,n);!function(e,t,n){try{performance.measure(e,t,n)}catch(e){A.onError(e)}}(t,$n(e,"start",n),r);const i=performance.getEntriesByName(t).pop();i&&Ht(Fn({metricName:e,metricType:d.distribution,value:i.duration},null!=n&&n.tags?{tags:n.tags}:{}))}}function Hn(e,t){if(!zn())return;const n=$n(e,"start",t);Qn[n]||(Wn(e,"start",t),Qn[n]=!0)}function Vn(e,t){const n=$n(e,"start",t),r=function(e,t){if(null==e)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(Qn,[n].map(qn));Qn=r}function Jn(e,t){if(!zn())return;const n=$n(e,"start",t);Qn[n]&&(Wn(e,"end",t),Vn(e,t))}function Xn(){zn()&&(performance.clearMarks(),Qn={})}var Gn=n(784);function Zn(){return Zn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Zn.apply(this,arguments)}function Yn(e,t,n=l.low){const r=(0,Gn.useRef)(t);return(0,Gn.useEffect)((()=>{r.current=t}),[t]),(0,Gn.useCallback)((t=>{$t(e,Zn({},r.current,t),n)}),[e,n])}function er(){return er=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},er.apply(this,arguments)}function tr(e,t,n=l.low){(0,Gn.useEffect)((()=>{const r=er({},t,{action:f.render});$t(e,r,n)}),[])}function nr(){return nr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},nr.apply(this,arguments)}const rr=function(e,t){return{markStartPerf:(0,Gn.useCallback)((()=>Hn(e,t)),[e,t]),markEndPerf:(0,Gn.useCallback)((n=>Jn(e,nr({},t,n))),[e,t])}};function ir(){return ir=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ir.apply(this,arguments)}function ar(){return Object.entries(ir({},Se,zt(),{sessionUUID:oe.sessionUUID,userId:oe.userId})).reduce(((e,t)=>{return null!=(n=t[1])&&""!==n?ir({},e,{[t[0]]:t[1]}):e;var n}),{})}async function or(){return new Promise((e=>{Mt(vt(je.eventsQueue)),Qt(bt(je.metricsQueue),!0),Pn(je.tracesQueue,!0),Ne({eventsQueue:[],metricsQueue:[],tracesQueue:[]}),e()}))}function sr(){return{"X-CB-Device-ID":H.deviceId||"unknown","X-CB-Is-Logged-In":H.userId?"true":"false","X-CB-Pagekey":re.pageKey||"unknown","X-CB-UJS":(e=Se.ujs,void 0===e||0===e.length?"":e.join(",")),"X-CB-Platform":A.platform||"unknown","X-CB-Project-Name":A.projectName||"unknown","X-CB-Session-UUID":oe.sessionUUID||"unknown","X-CB-Version-Name":A.version?String(A.version):"unknown"};var e}})(),r})()}));',wl=()=>new Promise((e,t)=>{if(window.ClientAnalytics)return e();try{const n=document.createElement("script");n.textContent=bl,n.type="text/javascript",document.head.appendChild(n),vl(),document.head.removeChild(n),e()}catch{console.error("Failed to execute inlined telemetry script"),t()}}),vl=()=>{var e,t,n;if(typeof window<"u"){const r=(n=(e=A.config.get().deviceId)!==null&&e!==void 0?e:(t=window.crypto)===null||t===void 0?void 0:t.randomUUID())!==null&&n!==void 0?n:"";if(window.ClientAnalytics){const{init:i,identify:a,PlatformName:s}=window.ClientAnalytics;i({isProd:!0,amplitudeApiKey:"c66737ad47ec354ced777935b0af822e",platform:s.web,projectName:"base_account_sdk",showDebugLogging:!1,version:"1.0.0",apiEndpoint:"https://cca-lite.coinbase.com"}),a({deviceId:r}),A.config.set({deviceId:r})}}},Q={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902}},Lr={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}},Cs="Unspecified error message.",xl="Unspecified server error.";function ni(e,t=Cs){if(e&&Number.isInteger(e)){const n=e.toString();if(jr(Lr,n))return Lr[n].message;if(Ts(e))return xl}return t}function El(e){if(!Number.isInteger(e))return!1;const t=e.toString();return!!(Lr[t]||Ts(e))}function Sl(e,{shouldIncludeStack:t=!1}={}){const n={};if(e&&typeof e=="object"&&!Array.isArray(e)&&jr(e,"code")&&El(e.code)){const r=e;n.code=r.code,r.message&&typeof r.message=="string"?(n.message=r.message,jr(r,"data")&&(n.data=r.data)):(n.message=ni(n.code),n.data={originalError:Hi(e)})}else n.code=Q.rpc.internal,n.message=$i(e,"message")?e.message:Cs,n.data={originalError:Hi(e)};return t&&(n.stack=$i(e,"stack")?e.stack:void 0),n}function Ts(e){return e>=-32099&&e<=-32e3}function Hi(e){return e&&typeof e=="object"&&!Array.isArray(e)?Object.assign({},e):e}function jr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function $i(e,t){return typeof e=="object"&&e!==null&&t in e&&typeof e[t]=="string"}const S={rpc:{parse:e=>ge(Q.rpc.parse,e),invalidRequest:e=>ge(Q.rpc.invalidRequest,e),invalidParams:e=>ge(Q.rpc.invalidParams,e),methodNotFound:e=>ge(Q.rpc.methodNotFound,e),internal:e=>ge(Q.rpc.internal,e),server:e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:t}=e;if(!Number.isInteger(t)||t>-32005||t<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return ge(t,e)},invalidInput:e=>ge(Q.rpc.invalidInput,e),resourceNotFound:e=>ge(Q.rpc.resourceNotFound,e),resourceUnavailable:e=>ge(Q.rpc.resourceUnavailable,e),transactionRejected:e=>ge(Q.rpc.transactionRejected,e),methodNotSupported:e=>ge(Q.rpc.methodNotSupported,e),limitExceeded:e=>ge(Q.rpc.limitExceeded,e)},provider:{userRejectedRequest:e=>ht(Q.provider.userRejectedRequest,e),unauthorized:e=>ht(Q.provider.unauthorized,e),unsupportedMethod:e=>ht(Q.provider.unsupportedMethod,e),disconnected:e=>ht(Q.provider.disconnected,e),chainDisconnected:e=>ht(Q.provider.chainDisconnected,e),unsupportedChain:e=>ht(Q.provider.unsupportedChain,e),custom:e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:t,message:n,data:r}=e;if(!n||typeof n!="string")throw new Error('"message" must be a nonempty string');return new Ls(t,n,r)}}};function ge(e,t){const[n,r]=Bs(t);return new ri(e,n||ni(e),r)}function ht(e,t){const[n,r]=Bs(t);return new Ls(e,n||ni(e),r)}function Bs(e){if(e){if(typeof e=="string")return[e];if(typeof e=="object"&&!Array.isArray(e)){const{message:t,data:n}=e;if(t&&typeof t!="string")throw new Error("Must specify string message.");return[t||void 0,n]}}return[]}class ri extends Error{constructor(t,n,r){if(!Number.isInteger(t))throw new Error('"code" must be an integer.');if(!n||typeof n!="string")throw new Error('"message" must be a nonempty string.');super(n),this.code=t,r!==void 0&&(this.data=r)}}class Ls extends ri{constructor(t,n,r){if(!kl(t))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(t,n,r)}}function kl(e){return Number.isInteger(e)&&e>=1e3&&e<=4999}function Gi(e){return typeof e=="object"&&e!==null&&"code"in e&&"data"in e&&e.code===-32090&&typeof e.data=="object"&&e.data!==null&&"type"in e.data&&e.data.type==="INSUFFICIENT_FUNDS"}function js(e){return typeof e=="object"&&e!==null&&"details"in e}function Al(e){try{const t=JSON.parse(e.details);return new ri(t.code,t.message,t.data)}catch{return null}}function Ms(){return e=>e}const $t=Ms(),_l=Ms();function De(e){return Math.floor(e)}const Ds=/^[0-9]*$/,Ns=/^[a-f0-9]*$/;function tt(e){return ii(crypto.getRandomValues(new Uint8Array(e)))}function ii(e){return[...e].map(t=>t.toString(16).padStart(2,"0")).join("")}function dn(e){return new Uint8Array(e.match(/.{1,2}/g).map(t=>Number.parseInt(t,16)))}function Nt(e,t=!1){const n=e.toString("hex");return $t(t?`0x${n}`:n)}function Wn(e){return Nt(Dr(e),!0)}function _e(e){return _l(e.toString(10))}function gt(e){return $t(`0x${BigInt(e).toString(16)}`)}function Rs(e){return e.startsWith("0x")||e.startsWith("0X")}function ai(e){return Rs(e)?e.slice(2):e}function Us(e){return Rs(e)?`0x${e.slice(2)}`:`0x${e}`}function Bn(e){if(typeof e!="string")return!1;const t=ai(e).toLowerCase();return Ns.test(t)}function Mr(e,t=!1){if(typeof e=="string"){const n=ai(e).toLowerCase();if(Ns.test(n))return $t(t?`0x${n}`:n)}throw S.rpc.invalidParams(`"${String(e)}" is not a hexadecimal string`)}function si(e,t=!1){let n=Mr(e,!1);return n.length%2===1&&(n=$t(`0${n}`)),t?$t(`0x${n}`):n}function Ve(e){if(typeof e=="string"){const t=ai(e).toLowerCase();if(Bn(t)&&t.length===40)return Us(t)}throw S.rpc.invalidParams(`Invalid Ethereum address: ${String(e)}`)}function Dr(e){if(Buffer.isBuffer(e))return e;if(typeof e=="string"){if(Bn(e)){const t=si(e,!1);return Buffer.from(t,"hex")}return Buffer.from(e,"utf8")}throw S.rpc.invalidParams(`Not binary data: ${String(e)}`)}function Rt(e){if(typeof e=="number"&&Number.isInteger(e))return De(e);if(typeof e=="string"){if(Ds.test(e))return De(Number(e));if(Bn(e))return De(Number(BigInt(si(e,!0))))}throw S.rpc.invalidParams(`Not an integer: ${String(e)}`)}function Tt(e){if(e!==null&&(typeof e=="bigint"||Ol(e)))return BigInt(e.toString(10));if(typeof e=="number")return BigInt(Rt(e));if(typeof e=="string"){if(Ds.test(e))return BigInt(e);if(Bn(e))return BigInt(si(e,!0))}throw S.rpc.invalidParams(`Not an integer: ${String(e)}`)}function Il(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw S.rpc.invalidParams(`Not a JSON string or an object: ${String(e)}`)}function Ol(e){if(e==null||typeof e.constructor!="function")return!1;const{constructor:t}=e;return typeof t.config=="function"&&typeof t.EUCLID=="number"}const Pl=`Coinbase Wallet SDK requires the Cross-Origin-Opener-Policy header to not be set to 'same-origin'. This is to ensure that the SDK can communicate with the Coinbase Smart Wallet app.
|
|
6
|
+
|
|
7
|
+
Please see https://www.smartwallet.dev/guides/tips/popup-tips#cross-origin-opener-policy for more information.`,Cl=()=>{let e;return{getCrossOriginOpenerPolicy:()=>e===void 0?"undefined":e,checkCrossOriginOpenerPolicy:async()=>{if(typeof window>"u"){e="non-browser-env";return}try{const t=`${window.location.origin}${window.location.pathname}`,n=await fetch(t,{method:"HEAD"});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const r=n.headers.get("Cross-Origin-Opener-Policy");e=r??"null",e==="same-origin"&&console.error(Pl)}catch(t){console.error("Error checking Cross-Origin-Opener-Policy:",t.message),e="error"}}}},{checkCrossOriginOpenerPolicy:Tl,getCrossOriginOpenerPolicy:Bl}=Cl();async function Ut(e,t){const n=Object.assign(Object.assign({},e),{jsonrpc:"2.0",id:crypto.randomUUID()}),r=await window.fetch(t,{method:"POST",body:JSON.stringify(n),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":Ct,"X-Cbw-Sdk-Platform":Os}}),{result:i,error:a}=await r.json();if(a)throw a;return i}function Ll(){return globalThis.coinbaseWalletExtension}function jl(){var e,t;try{const n=globalThis;return(e=n.ethereum)!==null&&e!==void 0?e:(t=n.top)===null||t===void 0?void 0:t.ethereum}catch{return}}function Ml({metadata:e,preference:t}){var n,r;const{appName:i,appLogoUrl:a,appChainIds:s}=e;if(t.options!=="smartWalletOnly"){const c=Ll();if(c)return(n=c.setAppInfo)===null||n===void 0||n.call(c,i,a,s,t),c}const o=jl();if(o?.isCoinbaseBrowser)return(r=o.setAppInfo)===null||r===void 0||r.call(o,i,a,s,t),o}function Dl(e){if(!e||typeof e!="object"||Array.isArray(e))throw S.rpc.invalidParams({message:"Expected a single, non-array, object argument.",data:e});const{method:t,params:n}=e;if(typeof t!="string"||t.length===0)throw S.rpc.invalidParams({message:"'args.method' must be a non-empty string.",data:e});if(n!==void 0&&!Array.isArray(n)&&(typeof n!="object"||n===null))throw S.rpc.invalidParams({message:"'args.params' must be an object or array if provided.",data:e});switch(t){case"eth_sign":case"eth_signTypedData_v2":case"eth_subscribe":case"eth_unsubscribe":throw S.provider.unsupportedMethod()}}function Nl(e){if(e){if(!["all","smartWalletOnly","eoaOnly"].includes(e.options))throw new Error(`Invalid options: ${e.options}`);if(e.attribution&&e.attribution.auto!==void 0&&e.attribution.dataSuffix!==void 0)throw new Error("Attribution cannot contain both auto and dataSuffix properties");if(e.telemetry&&typeof e.telemetry!="boolean")throw new Error("Telemetry must be a boolean")}}function Fi(e){if(typeof e!="function")throw new Error("toAccount is not a function")}const Rl="https://keys.coinbase.com/connect",Hs="https://rpc.wallet.coinbase.com",zi="https://www.walletlink.org",Ul="https://go.cb-w.com/walletlink";var U;(function(e){e.unknown="unknown",e.banner="banner",e.button="button",e.card="card",e.chart="chart",e.content_script="content_script",e.dropdown="dropdown",e.link="link",e.page="page",e.modal="modal",e.table="table",e.search_bar="search_bar",e.service_worker="service_worker",e.text="text",e.text_input="text_input",e.tray="tray",e.checkbox="checkbox",e.icon="icon"})(U||(U={}));var H;(function(e){e.unknown="unknown",e.blur="blur",e.click="click",e.change="change",e.dismiss="dismiss",e.focus="focus",e.hover="hover",e.select="select",e.measurement="measurement",e.move="move",e.process="process",e.render="render",e.scroll="scroll",e.view="view",e.search="search",e.keyPress="keyPress",e.error="error"})(H||(H={}));var $;(function(e){e.low="low",e.high="high"})($||($={}));function F(e,t,n){var r,i,a,s;window.ClientAnalytics&&((r=window.ClientAnalytics)===null||r===void 0||r.logEvent(e,Object.assign(Object.assign({},t),{sdkVersion:Ct,appName:(a=(i=A.config.get().metadata)===null||i===void 0?void 0:i.appName)!==null&&a!==void 0?a:"",appOrigin:window.location.origin,appPreferredSigner:(s=A.config.get().preference)===null||s===void 0?void 0:s.options}),n))}const Hl=()=>{F("communicator.popup_setup.started",{action:H.unknown,componentType:U.unknown},$.high)},$l=()=>{F("communicator.popup_setup.completed",{action:H.unknown,componentType:U.unknown},$.high)},Gl=()=>{F("communicator.popup_unload.received",{action:H.unknown,componentType:U.unknown},$.high)},oi=({snackbarContext:e})=>{F(`snackbar.${e}.shown`,{action:H.render,componentType:U.modal,snackbarContext:e},$.high)},xt=({snackbarContext:e,snackbarAction:t})=>{F(`snackbar.${e}.action_clicked`,{action:H.click,componentType:U.button,snackbarContext:e,snackbarAction:t},$.high)},Fl='@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}';function $s(){const e=document.createElement("style");e.type="text/css",e.appendChild(document.createTextNode(Fl)),document.documentElement.appendChild(e)}function zl(){try{return window.frameElement!==null}catch{return!1}}function ql(){try{return zl()&&window.top?window.top.location:window.location}catch{return window.location}}function Wl(){var e;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((e=window?.navigator)===null||e===void 0?void 0:e.userAgent)}function Gs(){var e,t;return(t=(e=window?.matchMedia)===null||e===void 0?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)!==null&&t!==void 0?t:!1}const Vl=".-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}",Kl="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+",Zl="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=";class Fs{constructor(){this.items=new Map,this.nextItemKey=0,this.root=null,this.darkMode=Gs()}attach(t){this.root=document.createElement("div"),this.root.className="-cbwsdk-snackbar-root",t.appendChild(this.root),this.render()}presentItem(t){const n=this.nextItemKey++;return this.items.set(n,t),this.render(),()=>{this.items.delete(n),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&tr(q("div",null,q(zs,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([t,n])=>q(Yl,Object.assign({},n,{key:t}))))),this.root)}}const zs=e=>q("div",{class:Dt("-cbwsdk-snackbar-container")},q("style",null,Vl),q("div",{class:"-cbwsdk-snackbar"},e.children)),Yl=({autoExpand:e,message:t,menuItems:n})=>{const[r,i]=mi(!0),[a,s]=mi(e??!1);nc(()=>{const c=[window.setTimeout(()=>{i(!1)},1),window.setTimeout(()=>{s(!0)},1e4)];return()=>{c.forEach(window.clearTimeout)}});const o=()=>{s(!a)};return q("div",{class:Dt("-cbwsdk-snackbar-instance",r&&"-cbwsdk-snackbar-instance-hidden",a&&"-cbwsdk-snackbar-instance-expanded")},q("div",{class:"-cbwsdk-snackbar-instance-header",onClick:o},q("img",{src:Kl,class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",q("div",{class:"-cbwsdk-snackbar-instance-header-message"},t),q("div",{class:"-gear-container"},!a&&q("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},q("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),q("img",{src:Zl,class:"-gear-icon",title:"Expand"}))),n&&n.length>0&&q("div",{class:"-cbwsdk-snackbar-instance-menu"},n.map((c,u)=>q("div",{class:Dt("-cbwsdk-snackbar-instance-menu-item",c.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:c.onClick,key:u},q("svg",{width:c.svgWidth,height:c.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},q("path",{"fill-rule":c.defaultFillRule,"clip-rule":c.defaultClipRule,d:c.path,fill:"#AAAAAA"})),q("span",{class:Dt("-cbwsdk-snackbar-instance-menu-item-info",c.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},c.info)))))},qs="M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z";class Jl{constructor(){this.attached=!1,this.snackbar=new Fs}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const t=document.documentElement,n=document.createElement("div");n.className="-cbwsdk-css-reset",t.appendChild(n),this.snackbar.attach(n),this.attached=!0,$s()}showConnecting(t){let n;return t.isUnlinkedErrorState?n={autoExpand:!0,message:"Connection lost",menuItems:[{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:t.onResetConnection}]}:n={message:"Confirm on phone",menuItems:[{isRed:!0,info:"Cancel transaction",svgWidth:"11",svgHeight:"11",path:"M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",defaultFillRule:"inherit",defaultClipRule:"inherit",onClick:t.onCancel},{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:qs,defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:t.onResetConnection}]},this.snackbar.presentItem(n)}}const qi=420,Wi=700,Ql={isRed:!1,info:"Retry",svgWidth:"10",svgHeight:"11",path:qs,defaultFillRule:"evenodd",defaultClipRule:"evenodd"},Xl="Popup was blocked. Try again.";let Xt=null;function ef(e){const t=(window.innerWidth-qi)/2+window.screenX,n=(window.innerHeight-Wi)/2+window.screenY;nf(e);function r(){const a=`wallet_${crypto.randomUUID()}`,s=window.open(e,a,`width=${qi}, height=${Wi}, left=${t}, top=${n}`);return s?.focus(),s||null}let i=r();if(!i){const a=ci();return new Promise((s,o)=>{oi({snackbarContext:"popup_blocked"}),a.presentItem({autoExpand:!0,message:Xl,menuItems:[Object.assign(Object.assign({},Ql),{onClick:()=>{xt({snackbarContext:"popup_blocked",snackbarAction:"confirm"}),i=r(),i?s(i):o(S.rpc.internal("Popup window was blocked")),a.clear()}})]})})}return Promise.resolve(i)}function tf(e){e&&!e.closed&&e.close()}function nf(e){const t={sdkName:Os,sdkVersion:Ct,origin:window.location.origin,coop:Bl()};for(const[n,r]of Object.entries(t))e.searchParams.has(n)||e.searchParams.append(n,r.toString())}function ci(){if(!Xt){const e=document.createElement("div");e.className="-cbwsdk-css-reset",document.body.appendChild(e),Xt=new Fs,Xt.attach(e)}return Xt}class rf{constructor({url:t=Rl,metadata:n,preference:r}){this.popup=null,this.listeners=new Map,this.postMessage=async i=>{(await this.waitForPopupLoaded()).postMessage(i,this.url.origin)},this.postRequestAndWaitForResponse=async i=>{const a=this.onMessage(({requestId:s})=>s===i.id);return this.postMessage(i),await a},this.onMessage=async i=>new Promise((a,s)=>{const o=c=>{if(c.origin!==this.url.origin)return;const u=c.data;i(u)&&(a(u),window.removeEventListener("message",o),this.listeners.delete(o))};window.addEventListener("message",o),this.listeners.set(o,{reject:s})}),this.disconnect=()=>{tf(this.popup),this.popup=null,this.listeners.forEach(({reject:i},a)=>{i(S.provider.userRejectedRequest("Request rejected")),window.removeEventListener("message",a)}),this.listeners.clear()},this.waitForPopupLoaded=async()=>this.popup&&!this.popup.closed?(this.popup.focus(),this.popup):(Hl(),this.popup=await ef(this.url),this.onMessage(({event:i})=>i==="PopupUnload").then(()=>{this.disconnect(),Gl()}).catch(()=>{}),this.onMessage(({event:i})=>i==="PopupLoaded").then(i=>{this.postMessage({requestId:i.id,data:{version:Ct,metadata:this.metadata,preference:this.preference,location:window.location.toString()}})}).then(()=>{if(!this.popup)throw S.rpc.internal();return $l(),this.popup})),this.url=new URL(t),this.metadata=n,this.preference=r}}function ie(e){return e.errorMessage!==void 0}function af(e){const t=Sl(sf(e),{shouldIncludeStack:!0}),n=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");return n.searchParams.set("version",Ct),n.searchParams.set("code",t.code.toString()),n.searchParams.set("message",t.message),Object.assign(Object.assign({},t),{docUrl:n.href})}function sf(e){var t;if(typeof e=="string")return{message:e,code:Q.rpc.internal};if(ie(e)){const n=e.errorMessage,r=(t=e.errorCode)!==null&&t!==void 0?t:n.match(/(denied|rejected)/i)?Q.provider.userRejectedRequest:void 0;return Object.assign(Object.assign({},e),{message:n,code:r,data:{method:e.method}})}return e}class of extends rc{}class ct{constructor(t,n){this.scope=t,this.module=n}storeObject(t,n){this.setItem(t,JSON.stringify(n))}loadObject(t){const n=this.getItem(t);return n?JSON.parse(n):void 0}setItem(t,n){localStorage.setItem(this.scopedKey(t),n)}getItem(t){return localStorage.getItem(this.scopedKey(t))}removeItem(t){localStorage.removeItem(this.scopedKey(t))}clear(){const t=this.scopedKey(""),n=[];for(let r=0;r<localStorage.length;r++){const i=localStorage.key(r);typeof i=="string"&&i.startsWith(t)&&n.push(i)}n.forEach(r=>localStorage.removeItem(r))}scopedKey(t){return`-${this.scope}${this.module?`:${this.module}`:""}:${t}`}static clearAll(){new ct("CBWSDK").clear(),new ct("walletlink").clear()}}const cf=({signerType:e})=>{F("provider.signer.loaded_from_storage",{action:H.measurement,componentType:U.unknown,signerType:e},$.low)},uf=({method:e,correlationId:t})=>{F("provider.request.started",{action:H.unknown,componentType:U.unknown,method:e,correlationId:t},$.high)},df=({method:e,correlationId:t,signerType:n,errorMessage:r})=>{F("provider.request.error",{action:H.error,componentType:U.unknown,method:e,signerType:n,correlationId:t,errorMessage:r},$.high)},lf=({method:e,signerType:t,correlationId:n})=>{F("provider.request.responded",{action:H.unknown,componentType:U.unknown,method:e,signerType:t,correlationId:n},$.high)},ff=()=>{F("provider.enable_function.called",{action:H.measurement,componentType:U.unknown},$.high)},pf=()=>{F("signer.selection.requested",{action:H.unknown,componentType:U.unknown},$.high)},hf=e=>{F("signer.selection.responded",{action:H.unknown,componentType:U.unknown,signerType:e},$.high)},en=Fr(()=>({correlationIds:new Map})),Ee={get:e=>en.getState().correlationIds.get(e),set:(e,t)=>{en.setState(n=>{const r=new Map(n.correlationIds);return r.set(e,t),{correlationIds:r}})},delete:e=>{en.setState(t=>{const n=new Map(t.correlationIds);return n.delete(e),{correlationIds:n}})},clear:()=>{en.setState({correlationIds:new Map})}},mf=({method:e,correlationId:t})=>{var n;F("scw_signer.handshake.started",{action:H.unknown,componentType:U.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=A.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},$.high)},yf=({method:e,correlationId:t,errorMessage:n})=>{var r;F("scw_signer.handshake.error",{action:H.error,componentType:U.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=A.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},$.high)},gf=({method:e,correlationId:t})=>{var n;F("scw_signer.handshake.completed",{action:H.unknown,componentType:U.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=A.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},$.high)},bf=({method:e,correlationId:t})=>{var n;F("scw_signer.request.started",{action:H.unknown,componentType:U.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=A.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},$.high)},wf=({method:e,correlationId:t,errorMessage:n})=>{var r;F("scw_signer.request.error",{action:H.error,componentType:U.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=A.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},$.high)},vf=({method:e,correlationId:t})=>{var n;F("scw_signer.request.completed",{action:H.unknown,componentType:U.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=A.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},$.high)},xf=({method:e,correlationId:t})=>{var n;F("scw_sub_account.request.started",{action:H.unknown,componentType:U.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=A.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},$.high)},Ef=({method:e,correlationId:t})=>{var n;F("scw_sub_account.request.completed",{action:H.unknown,componentType:U.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=A.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},$.high)},Sf=({method:e,correlationId:t,errorMessage:n})=>{var r;F("scw_sub_account.request.error",{action:H.error,componentType:U.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=A.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},$.high)},kf=({method:e,correlationId:t})=>{var n;F("scw_sub_account.add_owner.started",{action:H.unknown,componentType:U.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=A.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},$.high)},Af=({method:e,correlationId:t})=>{var n;F("scw_sub_account.add_owner.completed",{action:H.unknown,componentType:U.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=A.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},$.high)},_f=({method:e,correlationId:t,errorMessage:n})=>{var r;F("scw_sub_account.add_owner.error",{action:H.error,componentType:U.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=A.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},$.high)},If=({method:e,correlationId:t})=>{var n;F("scw_sub_account.insufficient_balance.error_handling.started",{action:H.unknown,componentType:U.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=A.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},$.high)},Of=({method:e,correlationId:t})=>{var n;F("scw_sub_account.insufficient_balance.error_handling.completed",{action:H.unknown,componentType:U.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=A.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},$.high)},Pf=({method:e,correlationId:t,errorMessage:n})=>{var r;F("scw_sub_account.insufficient_balance.error_handling.error",{action:H.error,componentType:U.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=A.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},$.high)},nt=e=>"message"in e&&typeof e.message=="string"?e.message:"",Ws=Fr(()=>({})),{createPublicClient:Cf,defineChain:Tf,http:Vi}=await ye("viem");function Ki(e){e.forEach(t=>{var n,r,i,a,s,o,c,u;if(!t.rpcUrl)return;const p=Tf({id:t.id,rpcUrls:{default:{http:[t.rpcUrl]}},name:(r=(n=t.nativeCurrency)===null||n===void 0?void 0:n.name)!==null&&r!==void 0?r:"",nativeCurrency:{name:(a=(i=t.nativeCurrency)===null||i===void 0?void 0:i.name)!==null&&a!==void 0?a:"",symbol:(o=(s=t.nativeCurrency)===null||s===void 0?void 0:s.symbol)!==null&&o!==void 0?o:"",decimals:(u=(c=t.nativeCurrency)===null||c===void 0?void 0:c.decimal)!==null&&u!==void 0?u:18}}),f=Cf({chain:p,transport:Vi(t.rpcUrl)}),l=nu({client:f,transport:Vi(t.rpcUrl)});Ws.setState({[t.id]:{client:f,bundlerClient:l}})})}function Vs(e){var t;return(t=Ws.getState()[e])===null||t===void 0?void 0:t.client}function me(e,t,n){if(e==null)throw t??S.rpc.invalidParams({message:"value must be present",data:e})}function Ye(e,t){if(!Array.isArray(e))throw S.rpc.invalidParams({message:t??"value must be an array",data:e})}const{isAddress:Zi,isHex:Bf}=await ye("viem");function tn(e){if(typeof e!="object"||e===null)throw S.rpc.internal("sub account info is not an object");if(!("address"in e))throw S.rpc.internal("sub account is invalid");if("address"in e&&typeof e.address=="string"&&!Zi(e.address))throw S.rpc.internal("sub account address is invalid");if("factory"in e&&typeof e.factory=="string"&&!Zi(e.factory))throw S.rpc.internal("sub account factory address is invalid");if("factoryData"in e&&typeof e.factoryData=="string"&&!Bf(e.factoryData))throw S.rpc.internal("sub account factory data is invalid")}async function Lf(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"])}async function jf(e,t){return crypto.subtle.deriveKey({name:"ECDH",public:t},e,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function Mf(e,t){const n=crypto.getRandomValues(new Uint8Array(12)),r=await crypto.subtle.encrypt({name:"AES-GCM",iv:n},e,new TextEncoder().encode(t));return{iv:n,cipherText:r}}async function Df(e,{iv:t,cipherText:n}){const r=await crypto.subtle.decrypt({name:"AES-GCM",iv:t},e,n);return new TextDecoder().decode(r)}function Ks(e){switch(e){case"public":return"spki";case"private":return"pkcs8"}}async function Zs(e,t){const n=Ks(e),r=await crypto.subtle.exportKey(n,t);return ii(new Uint8Array(r))}async function Ys(e,t){const n=Ks(e),r=dn(t).buffer;return await crypto.subtle.importKey(n,new Uint8Array(r),{name:"ECDH",namedCurve:"P-256"},!0,e==="private"?["deriveKey"]:[])}async function Nf(e,t){const n=JSON.stringify(e,(r,i)=>{if(!(i instanceof Error))return i;const a=i;return Object.assign(Object.assign({},a.code?{code:a.code}:{}),{message:a.message})});return Mf(t,n)}async function Rf(e,t){return JSON.parse(await Df(t,e))}function Uf(e,t){const n=typeof indexedDB<"u"?Sc(e,t):void 0;return{getItem:async r=>{const i=await kc(r,n);return i||null},removeItem:async r=>Ac(r,n),setItem:async(r,i)=>_c(r,i,n)}}const{hashMessage:Hf,hashTypedData:$f}=await ye("viem"),Gf="cbwsdk",Ff="keys",ui="activeId",Pt=Uf(Gf,Ff);async function zf(){const e=await nl({extractable:!1}),t=be(Qr(e.publicKey),1);return await Pt.setItem(t,e),await Pt.setItem(ui,t),e}async function qf(){const e=await Pt.getItem(ui);if(!e)return null;const t=await Pt.getItem(e);return t||null}async function Wf(){const e=await qf();if(!e){const t=await zf(),n=be(Qr(t.publicKey),1);return await Pt.setItem(n,t),await Pt.setItem(ui,n),t}return e}async function Vf(){const e=await Wf(),t=be(Qr(e.publicKey),1),n=async r=>{const{payload:i,metadata:a}=tl({challenge:r,origin:"https://keys.coinbase.com",userVerification:"preferred"}),s=await rl({payload:i,privateKey:e.privateKey});return{signature:Ud(s),raw:{},webauthn:a}};return{id:t,publicKey:t,async sign({hash:r}){return n(r)},async signMessage({message:r}){return n(Hf(r))},async signTypedData(r){return n($f(r))},type:"webAuthn"}}async function Nr(){return{account:await Vf()}}const Yi={storageKey:"ownPrivateKey",keyType:"private"},Ji={storageKey:"ownPublicKey",keyType:"public"},Qi={storageKey:"peerPublicKey",keyType:"public"};class Kf{constructor(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null}async getOwnPublicKey(){return await this.loadKeysIfNeeded(),this.ownPublicKey}async getSharedSecret(){return await this.loadKeysIfNeeded(),this.sharedSecret}async setPeerPublicKey(t){this.sharedSecret=null,this.peerPublicKey=t,await this.storeKey(Qi,t),await this.loadKeysIfNeeded()}async clear(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null,A.keys.clear()}async generateKeyPair(){const t=await Lf();this.ownPrivateKey=t.privateKey,this.ownPublicKey=t.publicKey,await this.storeKey(Yi,t.privateKey),await this.storeKey(Ji,t.publicKey)}async loadKeysIfNeeded(){if(this.ownPrivateKey===null&&(this.ownPrivateKey=await this.loadKey(Yi)),this.ownPublicKey===null&&(this.ownPublicKey=await this.loadKey(Ji)),(this.ownPrivateKey===null||this.ownPublicKey===null)&&await this.generateKeyPair(),this.peerPublicKey===null&&(this.peerPublicKey=await this.loadKey(Qi)),this.sharedSecret===null){if(this.ownPrivateKey===null||this.peerPublicKey===null)return;this.sharedSecret=await jf(this.ownPrivateKey,this.peerPublicKey)}}async loadKey(t){const n=A.keys.get(t.storageKey);return n?Ys(t.keyType,n):null}async storeKey(t,n){const r=await Zs(t.keyType,n);A.keys.set(t.storageKey,r)}}function Mt(e,t){if(!(typeof e!="object"||e===null))return t.split(/[.[\]]+/).filter(Boolean).reduce((n,r)=>{if(typeof n=="object"&&n!==null)return n[r]},e)}const Js="0x0ba5ed0c6aa8c49038f819e587e2633c4a9f428a",Qs="0xf85210B21cC50302F477BA56686d2019dC9b67Ad",Se=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{name:"owner",type:"bytes"}],name:"AlreadyOwner",type:"error"},{inputs:[],name:"Initialized",type:"error"},{inputs:[{name:"owner",type:"bytes"}],name:"InvalidEthereumAddressOwner",type:"error"},{inputs:[{name:"key",type:"uint256"}],name:"InvalidNonceKey",type:"error"},{inputs:[{name:"owner",type:"bytes"}],name:"InvalidOwnerBytesLength",type:"error"},{inputs:[],name:"LastOwner",type:"error"},{inputs:[{name:"index",type:"uint256"}],name:"NoOwnerAtIndex",type:"error"},{inputs:[{name:"ownersRemaining",type:"uint256"}],name:"NotLastOwner",type:"error"},{inputs:[{name:"selector",type:"bytes4"}],name:"SelectorNotAllowed",type:"error"},{inputs:[],name:"Unauthorized",type:"error"},{inputs:[],name:"UnauthorizedCallContext",type:"error"},{inputs:[],name:"UpgradeFailed",type:"error"},{inputs:[{name:"index",type:"uint256"},{name:"expectedOwner",type:"bytes"},{name:"actualOwner",type:"bytes"}],name:"WrongOwnerAtIndex",type:"error"},{anonymous:!1,inputs:[{indexed:!0,name:"index",type:"uint256"},{indexed:!1,name:"owner",type:"bytes"}],name:"AddOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"index",type:"uint256"},{indexed:!1,name:"owner",type:"bytes"}],name:"RemoveOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"implementation",type:"address"}],name:"Upgraded",type:"event"},{stateMutability:"payable",type:"fallback"},{inputs:[],name:"REPLAYABLE_NONCE_KEY",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"owner",type:"address"}],name:"addOwnerAddress",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"addOwnerPublicKey",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"functionSelector",type:"bytes4"}],name:"canSkipChainIdValidation",outputs:[{name:"",type:"bool"}],stateMutability:"pure",type:"function"},{inputs:[],name:"domainSeparator",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"eip712Domain",outputs:[{name:"fields",type:"bytes1"},{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"},{name:"salt",type:"bytes32"},{name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"entryPoint",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"}],name:"execute",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"executeBatch",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"calls",type:"bytes[]"}],name:"executeWithoutChainIdValidation",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"getUserOpHashWithoutChainId",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"implementation",outputs:[{name:"$",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{name:"owners",type:"bytes[]"}],name:"initialize",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"account",type:"address"}],name:"isOwnerAddress",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"bytes"}],name:"isOwnerBytes",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"isOwnerPublicKey",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],name:"isValidSignature",outputs:[{name:"result",type:"bytes4"}],stateMutability:"view",type:"function"},{inputs:[],name:"nextOwnerIndex",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"index",type:"uint256"}],name:"ownerAtIndex",outputs:[{name:"",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[],name:"ownerCount",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"proxiableUUID",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{name:"index",type:"uint256"},{name:"owner",type:"bytes"}],name:"removeLastOwner",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"index",type:"uint256"},{name:"owner",type:"bytes"}],name:"removeOwnerAtIndex",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"removedOwnersCount",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"hash",type:"bytes32"}],name:"replaySafeHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{name:"newImplementation",type:"address"},{name:"data",type:"bytes"}],name:"upgradeToAndCall",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"},{name:"userOpHash",type:"bytes32"},{name:"missingAccountFunds",type:"uint256"}],name:"validateUserOp",outputs:[{name:"validationData",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}],Xs=[{inputs:[{name:"implementation_",type:"address"}],stateMutability:"payable",type:"constructor"},{inputs:[],name:"OwnerRequired",type:"error"},{inputs:[{name:"owners",type:"bytes[]"},{name:"nonce",type:"uint256"}],name:"createAccount",outputs:[{name:"account",type:"address"}],stateMutability:"payable",type:"function"},{inputs:[{name:"owners",type:"bytes[]"},{name:"nonce",type:"uint256"}],name:"getAddress",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"implementation",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"initCodeHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"}],{hexToBigInt:Vn,isAddress:Zf}=await ye("viem"),{keccak256:Yf,numberToHex:eo,slice:Jf,toHex:Qf}=await ye("viem");function Xi(e){var t;if(!Array.isArray(e.params))return null;switch(e.method){case"personal_sign":return e.params[1];case"eth_signTypedData_v4":return e.params[0];case"eth_signTransaction":case"eth_sendTransaction":case"wallet_sendCalls":return(t=e.params[0])===null||t===void 0?void 0:t.from;default:return null}}function Xf(e,t){if(!Array.isArray(e.params))throw S.rpc.invalidParams();const n=[...e.params];switch(e.method){case"eth_signTransaction":case"eth_sendTransaction":case"wallet_sendCalls":n[0].from=t;break;case"eth_signTypedData_v4":n[0]=t;break;case"personal_sign":n[1]=t;break}return Object.assign(Object.assign({},e),{params:n})}function ea(e){var t;if(!e||!Array.isArray(e)||!(!((t=e[0])===null||t===void 0)&&t.chainId)||typeof e[0].chainId!="string"&&typeof e[0].chainId!="number")throw S.rpc.invalidParams()}function ep(e){if(!e||!Array.isArray(e)||e.length!==1&&e.length!==2||typeof e[0]!="string"||!Zf(e[0]))throw S.rpc.invalidParams();if(e.length===2){if(!Array.isArray(e[1]))throw S.rpc.invalidParams();for(const t of e[1])if(typeof t!="string"||!t.startsWith("0x"))throw S.rpc.invalidParams()}}function An(e,t){const n=Object.assign({},e);if(t&&e.method.startsWith("wallet_")){let r=Mt(n,"params.0.capabilities");if(typeof r>"u"&&(r={}),typeof r!="object")throw S.rpc.invalidParams();r=Object.assign(Object.assign({},t),r),n.params&&Array.isArray(n.params)&&(n.params[0]=Object.assign(Object.assign({},n.params[0]),{capabilities:r}))}return n}async function Kn(){var e;const t=(e=A.subAccountsConfig.get())!==null&&e!==void 0?e:{},n={};if(t.enableAutoSubAccounts){const{account:r}=t.toOwnerAccount?await t.toOwnerAccount():await Nr();if(!r)throw S.provider.unauthorized("No owner account found");n.addSubAccount={account:{type:"create",keys:[{type:r.address?"address":"webauthn-p256",publicKey:r.address||r.publicKey}]}}}A.subAccountsConfig.set({capabilities:n})}function tp(e){if(!(e.method==="coinbase_fetchPermissions"&&e.params===void 0)){if(e.method==="coinbase_fetchPermissions"&&Array.isArray(e.params)&&e.params.length===1&&typeof e.params[0]=="object"){if(typeof e.params[0].account!="string"||!e.params[0].chainId.startsWith("0x"))throw S.rpc.invalidParams("FetchPermissions - Invalid params: params[0].account must be a hex string");if(typeof e.params[0].chainId!="string"||!e.params[0].chainId.startsWith("0x"))throw S.rpc.invalidParams("FetchPermissions - Invalid params: params[0].chainId must be a hex string");if(typeof e.params[0].spender!="string"||!e.params[0].spender.startsWith("0x"))throw S.rpc.invalidParams("FetchPermissions - Invalid params: params[0].spender must be a hex string");return}throw S.rpc.invalidParams()}}function np(e){var t,n,r;if(e.params!==void 0)return e;const i=(t=A.getState().account.accounts)===null||t===void 0?void 0:t[0],a=(n=A.getState().account.chain)===null||n===void 0?void 0:n.id,s=(r=A.getState().subAccount)===null||r===void 0?void 0:r.address;if(!i||!s||!a)throw S.rpc.invalidParams("FetchPermissions - one or more of account, sub account, or chain id is missing, connect to sub account via wallet_connect first");return{method:"coinbase_fetchPermissions",params:[{account:i,chainId:eo(a),spender:s}]}}function rp({spendPermission:e,chainId:t}){return{domain:{name:"Spend Permission Manager",version:"1",chainId:t,verifyingContract:Qs},types:{SpendPermission:[{name:"account",type:"address"},{name:"spender",type:"address"},{name:"token",type:"address"},{name:"allowance",type:"uint160"},{name:"period",type:"uint48"},{name:"start",type:"uint48"},{name:"end",type:"uint48"},{name:"salt",type:"uint256"},{name:"extraData",type:"bytes"}]},primaryType:"SpendPermission",message:{account:e.account,spender:e.spender,token:e.token,allowance:e.allowance,period:e.period,start:e.start,end:e.end,salt:e.salt,extraData:e.extraData}}}function ip({spendPermissionBatch:e,chainId:t}){return{domain:{name:"Spend Permission Manager",version:"1",chainId:t,verifyingContract:Qs},types:{SpendPermissionBatch:[{name:"account",type:"address"},{name:"period",type:"uint48"},{name:"start",type:"uint48"},{name:"end",type:"uint48"},{name:"permissions",type:"PermissionDetails[]"}],PermissionDetails:[{name:"spender",type:"address"},{name:"token",type:"address"},{name:"allowance",type:"uint160"},{name:"salt",type:"uint256"},{name:"extraData",type:"bytes"}]},primaryType:"SpendPermissionBatch",message:{account:e.account,period:e.period,start:e.start,end:e.end,permissions:e.permissions.map(n=>({spender:n.spender,token:n.token,allowance:n.allowance,salt:n.salt,extraData:n.extraData}))}}}async function to({client:e,id:t}){var n;const r=await Ia(e,{id:t});if(r.status==="success")return(n=r.receipts)===null||n===void 0?void 0:n[0].transactionHash;throw S.rpc.internal("failed to send transaction")}function no({calls:e,from:t,chainId:n,capabilities:r}){const i=Ps.get().paymasterUrls;let a={method:"wallet_sendCalls",params:[{version:"1.0",calls:e,chainId:eo(n),from:t,atomicRequired:!0,capabilities:r}]};return i?.[n]&&(a=An(a,{paymasterService:{url:i?.[n]}})),a}async function ap(){const e=ci();return await new Promise(n=>{oi({snackbarContext:"sub_account_insufficient_balance"}),e.presentItem({autoExpand:!0,message:"Insufficient spend permission. Choose how to proceed:",menuItems:[{isRed:!1,info:"Create new Spend Permission",svgWidth:"10",svgHeight:"11",path:"",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:()=>{xt({snackbarContext:"sub_account_insufficient_balance",snackbarAction:"create_permission"}),e.clear(),n("update_permission")}},{isRed:!1,info:"Continue in Popup",svgWidth:"10",svgHeight:"11",path:"",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:()=>{xt({snackbarContext:"sub_account_insufficient_balance",snackbarAction:"continue_in_popup"}),e.clear(),n("continue_popup")}},{isRed:!0,info:"Cancel",svgWidth:"10",svgHeight:"11",path:"",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:()=>{xt({snackbarContext:"sub_account_insufficient_balance",snackbarAction:"cancel"}),e.clear(),n("cancel")}}]})})}function sp({errorData:e,sourceAddress:t}){var n;const r=[];for(const[i,{amount:a,sources:s}]of Object.entries((n=e?.required)!==null&&n!==void 0?n:{})){if(s.filter(c=>Vn(c.balance)>=Vn(a)&&c.address.toLowerCase()===t?.toLowerCase()).length===0)throw new Error("Source address has insufficient balance for a token");r.push({token:i,requiredAmount:Vn(a)})}return r}function op(e){return typeof e=="object"&&e!==null&&"calls"in e}function cp(e){return Array.isArray(e)&&e.length===1&&typeof e[0]=="object"&&e[0]!==null&&"to"in e[0]}function up(e){return Jf(Yf(Qf(e)),0,16)}function dp({attribution:e,dappOrigin:t}){if(e){if("auto"in e&&e.auto&&t)return up(t);if("dataSuffix"in e)return e.dataSuffix}}function lp(e,t){var n;if(!Array.isArray(e?.params))return!1;const r=(n=e.params[0])===null||n===void 0?void 0:n.capabilities;return!r||typeof r!="object"?!1:t in r}function nn(e,t){const n=e.filter(r=>r!==t);return[t,...n]}function rn(e,t){return[...e.filter(r=>r!==t),t]}async function fp(){const e=A.spendPermissions.get(),t=A.subAccounts.get(),n=A.account.get().accounts;return n?{accounts:n?.map(i=>({address:i,capabilities:{subAccounts:t?[t]:void 0,spendPermissions:e.length>0?{permissions:e}:void 0}}))}:null}const{hexToBytes:Rr,numberToHex:ta,stringToBytes:na,trim:ra}=await ye("viem");function pp(e){return e.replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}function an(e){const t=btoa(String.fromCharCode(...new Uint8Array(e)));return pp(t)}function hp({webauthn:e,signature:t,id:n}){const r=ks(t);return{id:n,rawId:an(na(n)),response:{authenticatorData:an(Rr(e.authenticatorData)),clientDataJSON:an(na(e.clientDataJSON)),signature:an(mp(r.r,r.s))},type:JSON.parse(e.clientDataJSON).type}}function mp(e,t){const n=Rr(ra(ta(e))),r=Rr(ra(ta(t))),i=n.length,a=r.length,s=i+a+4,o=new Uint8Array(s+2);return o[0]=48,o[1]=s,o[2]=2,o[3]=i,o.set(n,4),o[i+4]=2,o[i+5]=a,o.set(r,i+6),o}var yp=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const{BaseError:ro,decodeFunctionData:gp,encodeAbiParameters:io,encodeFunctionData:ia,encodePacked:bp,hashMessage:wp,hashTypedData:ao,parseSignature:vp,size:xp,stringToHex:Ep}=await ye("viem");async function Sp(e){const{owner:t,ownerIndex:n,address:r,client:i,factoryData:a}=e,s={abi:Cc,address:Tc,version:"0.6"},o={abi:Xs,address:Js};return Mc({client:i,entryPoint:s,extend:{abi:Se,factory:o},async decodeCalls(c){const u=gp({abi:Se,data:c});if(u.functionName==="execute")return[{to:u.args[0],value:u.args[1],data:u.args[2]}];if(u.functionName==="executeBatch")return u.args[0].map(p=>({to:p.target,value:p.value,data:p.data}));throw new ro(`unable to decode calls for "${u.functionName}"`)},async encodeCalls(c){var u,p;return c.length===1?ia({abi:Se,functionName:"execute",args:[c[0].to,(u=c[0].value)!==null&&u!==void 0?u:BigInt(0),(p=c[0].data)!==null&&p!==void 0?p:"0x"]}):ia({abi:Se,functionName:"executeBatch",args:[c.map(f=>{var l,d;return{data:(l=f.data)!==null&&l!==void 0?l:"0x",target:f.to,value:(d=f.value)!==null&&d!==void 0?d:BigInt(0)}})]})},async getAddress(){return r},async getFactoryArgs(){return a?{factory:o.address,factoryData:a}:{factory:o.address,factoryData:a}},async getStubSignature(){return t.type==="webAuthn"?"0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000001949fc7c88032b9fcb5f6efc7a7b8c63668eae9871b765e23123bb473ff57aa831a7c0d9276168ebcc29f2875a0239cffdf2a9cd1c2007c5c77c071db9264df1d000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008a7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a2273496a396e6164474850596759334b7156384f7a4a666c726275504b474f716d59576f4d57516869467773222c226f726967696e223a2268747470733a2f2f7369676e2e636f696e626173652e636f6d222c2263726f73734f726967696e223a66616c73657d00000000000000000000000000000000000000000000":Bt({ownerIndex:n,signature:"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"})},async sign(c){const u=await this.getAddress(),p=Zn({address:u,chainId:i.chain.id,hash:c.hash}),f=await sn({hash:p,owner:t});return Bt({ownerIndex:n,signature:f})},async signMessage(c){const{message:u}=c,p=await this.getAddress(),f=Zn({address:p,chainId:i.chain.id,hash:wp(u)}),l=await sn({hash:f,owner:t});return Bt({ownerIndex:n,signature:l})},async signTypedData(c){const{domain:u,types:p,primaryType:f,message:l}=c,d=await this.getAddress(),g=Zn({address:d,chainId:i.chain.id,hash:ao({domain:u,message:l,primaryType:f,types:p})}),h=await sn({hash:g,owner:t});return Bt({ownerIndex:n,signature:h})},async signUserOperation(c){const{chainId:u=i.chain.id}=c,p=yp(c,["chainId"]),f=await this.getAddress(),l=jc({chainId:u,entryPointAddress:s.address,entryPointVersion:s.version,userOperation:Object.assign(Object.assign({},p),{sender:f})}),d=await sn({hash:l,owner:t});return Bt({ownerIndex:n,signature:d})},userOperation:{async estimateGas(c){var u;if(t.type==="webAuthn")return{verificationGasLimit:BigInt(Math.max(Number((u=c.verificationGasLimit)!==null&&u!==void 0?u:BigInt(0)),8e5))}}}})}async function sn({hash:e,owner:t}){if(t.type==="webAuthn"){const{signature:n,webauthn:r}=await t.sign({hash:e});return kp({signature:n,webauthn:r})}if(t.sign)return t.sign({hash:e});throw new ro("`owner` does not support raw sign.")}function Zn({address:e,chainId:t,hash:n}){return ao({domain:{chainId:t,name:"Coinbase Smart Wallet",verifyingContract:e,version:"1"},types:{CoinbaseSmartWalletMessage:[{name:"hash",type:"bytes32"}]},primaryType:"CoinbaseSmartWalletMessage",message:{hash:n}})}function kp({webauthn:e,signature:t}){const{r:n,s:r}=ks(t);return io([{components:[{name:"authenticatorData",type:"bytes"},{name:"clientDataJSON",type:"bytes"},{name:"challengeIndex",type:"uint256"},{name:"typeIndex",type:"uint256"},{name:"r",type:"uint256"},{name:"s",type:"uint256"}],type:"tuple"}],[{authenticatorData:e.authenticatorData,clientDataJSON:Ep(e.clientDataJSON),challengeIndex:BigInt(e.challengeIndex),typeIndex:BigInt(e.typeIndex),r:n,s:r}])}function Bt(e){const{ownerIndex:t=0}=e,n=(()=>{if(xp(e.signature)!==65)return e.signature;const r=vp(e.signature);return bp(["bytes32","bytes32","uint8"],[r.r,r.s,r.yParity===0?27:28])})();return io([{components:[{name:"ownerIndex",type:"uint8"},{name:"signatureData",type:"bytes"}],type:"tuple"}],[{ownerIndex:t,signatureData:n}])}const{hexToString:aa,isHex:Lt,numberToHex:Ap}=await ye("viem");async function _p({address:e,client:t,factory:n,factoryData:r,owner:i,ownerIndex:a,parentAddress:s,attribution:o}){var c;const u={address:e,factory:n,factoryData:r},p=(c=t.chain)===null||c===void 0?void 0:c.id;if(!p)throw S.rpc.internal("chainId not found");const f=await Sp({owner:i,ownerIndex:a??1,address:e,client:t,factoryData:r}),l=async d=>{var g,h,v,k,P,x;try{switch(d.method){case"wallet_addSubAccount":return u;case"eth_accounts":return[u.address];case"eth_coinbase":return u.address;case"net_version":return p.toString();case"eth_chainId":return Ap(p);case"eth_sendTransaction":{Ye(d.params);const I=d.params[0];me(I.to,S.rpc.invalidParams("to is required"));const D={to:I.to,data:Mr((g=I.data)!==null&&g!==void 0?g:"0x",!0),value:Mr((h=I.value)!==null&&h!==void 0?h:"0x",!0),from:(v=I.from)!==null&&v!==void 0?v:u.address},T=no({calls:[D],chainId:p,from:D.from}),G=await l(T);return to({client:t,id:G})}case"wallet_sendCalls":{Ye(d.params);const I=Mt(d.params[0],"chainId");if(!I)throw S.rpc.invalidParams("chainId is required");if(!Lt(I))throw S.rpc.invalidParams("chainId must be a hex encoded integer");if(!d.params[0])throw S.rpc.invalidParams("params are required");if(!("calls"in d.params[0]))throw S.rpc.invalidParams("calls are required");let D={method:"wallet_prepareCalls",params:[{version:"1.0",calls:d.params[0].calls,chainId:I,from:u.address,capabilities:"capabilities"in d.params[0]?d.params[0].capabilities:{}}]};s&&(D=An(D,{funding:[{type:"spendPermission",data:{autoApply:!0,sources:[s],preference:"PREFER_DIRECT_BALANCE"}}]}));let T=await l(D);const G=await((P=(k=i).sign)===null||P===void 0?void 0:P.call(k,{hash:aa(T.signatureRequest.hash)}));let K;if(!G)throw S.rpc.internal("signature not found");return Lt(G)?K={type:"secp256k1",data:{address:i.address,signature:G}}:K={type:"webauthn",data:{signature:JSON.stringify(hp(Object.assign({id:(x=i.id)!==null&&x!==void 0?x:"1"},G))),publicKey:i.publicKey}},(await l({method:"wallet_sendPreparedCalls",params:[{version:"1.0",type:T.type,data:T.userOp,chainId:T.chainId,signature:K}]}))[0]}case"wallet_sendPreparedCalls":{Ye(d.params);const I=Mt(d.params[0],"chainId");if(!I)throw S.rpc.invalidParams("chainId is required");if(!Lt(I))throw S.rpc.invalidParams("chainId must be a hex encoded integer");return await t.request({method:"wallet_sendPreparedCalls",params:d.params})}case"wallet_prepareCalls":{Ye(d.params);const I=Mt(d.params[0],"chainId");if(!I)throw S.rpc.invalidParams("chainId is required");if(!Lt(I))throw S.rpc.invalidParams("chainId must be a hex encoded integer");if(!d.params[0])throw S.rpc.invalidParams("params are required");if(!Mt(d.params[0],"calls"))throw S.rpc.invalidParams("calls are required");const D=d.params[0];return o&&D.capabilities&&!("attribution"in D.capabilities)&&(D.capabilities.attribution=o),await t.request({method:"wallet_prepareCalls",params:[Object.assign(Object.assign({},d.params[0]),{chainId:I})]})}case"personal_sign":{if(Ye(d.params),!Lt(d.params[0]))throw S.rpc.invalidParams("message must be a hex encoded string");const I=aa(d.params[0]);return f.signMessage({message:I})}case"eth_signTypedData_v4":{Ye(d.params);const I=typeof d.params[1]=="string"?JSON.parse(d.params[1]):d.params[1];return f.signTypedData(I)}case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"wallet_addEthereumChain":case"wallet_switchEthereumChain":default:throw S.rpc.methodNotSupported()}}catch(I){if(js(I)){const D=Al(I);if(D)throw D}throw I}};return{request:l}}const{decodeFunctionData:Ip,getAddress:sa,isAddress:Op,pad:Pp}=await ye("viem");async function so({address:e,client:t,publicKey:n,factory:r,factoryData:i}){if(!await Aa(t,{address:e})&&r&&i){if(sa(r)!==sa(Js))throw S.rpc.internal("unknown factory address");const o=Ip({abi:Xs,data:i});if(o.functionName!=="createAccount")throw S.rpc.internal("unknown factory function");const[c]=o.args;return c.findIndex(u=>u.toLowerCase()===oa(n).toLowerCase())}const s=await nr(t,{address:e,abi:Se,functionName:"ownerCount"});for(let o=Number(s)-1;o>=0;o--){const c=await nr(t,{address:e,abi:Se,functionName:"ownerAtIndex",args:[BigInt(o)]}),u=oa(n);if(c.toLowerCase()===u.toLowerCase())return o}return-1}function oa(e){return Op(e)?Pp(e):e}async function Cp(){const e=ci();return new Promise(t=>{oi({snackbarContext:"sub_account_add_owner"}),e.presentItem({autoExpand:!0,message:"App requires a signer update",menuItems:[{isRed:!1,info:"Confirm",svgWidth:"10",svgHeight:"11",path:"",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:()=>{xt({snackbarContext:"sub_account_add_owner",snackbarAction:"confirm"}),e.clear(),t("authenticate")}},{isRed:!0,info:"Cancel",svgWidth:"10",svgHeight:"11",path:"",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:()=>{xt({snackbarContext:"sub_account_add_owner",snackbarAction:"cancel"}),e.clear(),t("cancel")}}]})})}const{decodeAbiParameters:Tp,encodeFunctionData:ca,numberToHex:Bp,toHex:ua}=await ye("viem");async function Lp({ownerAccount:e,globalAccountRequest:t}){var n,r;const i=A.account.get(),a=A.subAccounts.get(),s=(n=i.accounts)===null||n===void 0?void 0:n.find(g=>g.toLowerCase()!==a?.address.toLowerCase());me(s,S.provider.unauthorized("no global account")),me((r=i.chain)===null||r===void 0?void 0:r.id,S.provider.unauthorized("no chain id")),me(a?.address,S.provider.unauthorized("no sub account"));const o=[];if(e.type==="local"&&e.address&&o.push({to:a.address,data:ca({abi:Se,functionName:"addOwnerAddress",args:[e.address]}),value:ua(0)}),e.publicKey){const[g,h]=Tp([{type:"bytes32"},{type:"bytes32"}],e.publicKey);o.push({to:a.address,data:ca({abi:Se,functionName:"addOwnerPublicKey",args:[g,h]}),value:ua(0)})}const c={method:"wallet_sendCalls",params:[{version:"1",calls:o,chainId:Bp(84532),from:s}]};if(await Cp()==="cancel")throw S.provider.unauthorized("user cancelled");const p=await t(c),f=Vs(i.chain.id);if(me(f,S.rpc.internal(`client not found for chainId ${i.chain.id}`)),(await Ia(f,{id:p})).status!=="success")throw S.rpc.internal("add owner call failed");const d=await so({address:a.address,publicKey:e.type==="local"&&e.address?e.address:e.publicKey,client:f});if(d===-1)throw S.rpc.internal("failed to find owner index");return d}const{encodeFunctionData:da,erc20Abi:jp,hexToBigInt:Mp,numberToHex:on}=await ye("viem");async function Dp({errorData:e,globalAccountAddress:t,subAccountAddress:n,client:r,request:i,subAccountRequest:a,globalAccountRequest:s}){var o;const c=(o=r.chain)===null||o===void 0?void 0:o.id;me(c,S.rpc.internal("invalid chainId"));const u=sp({errorData:e,sourceAddress:t}),p=await ap();if(p==="cancel")throw new Error("User cancelled funding");let f;const l=60*60*24,d=3;if(p==="update_permission"){if(u.length===1){const x=u[0],I=rp({spendPermission:{token:x.token,allowance:on(x.requiredAmount*BigInt(d)),period:l,account:t,spender:n,start:0,end:0xffffffffffff,salt:on(BigInt(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),extraData:"0x"},chainId:c});f={method:"eth_signTypedData_v4",params:[t,I]}}else{const x=ip({spendPermissionBatch:{account:t,period:l,start:0,end:0xffffffffffff,permissions:u.map(I=>({token:I.token,allowance:on(I.requiredAmount*BigInt(d)),period:l,account:t,spender:n,salt:"0x0",extraData:"0x"}))},chainId:c});f={method:"eth_signTypedData_v4",params:[t,x]}}try{await s(f)}catch(x){throw console.error(x),new Error("User denied spend permission request")}return a(i)}const g=u.map(x=>x.token.toLowerCase()==="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE".toLowerCase()?{to:n,value:on(x.requiredAmount),data:"0x"}:{to:x.token,value:"0x0",data:da({abi:jp,functionName:"transfer",args:[n,x.requiredAmount]})});let h;if(i.method==="wallet_sendCalls"&&op(i.params))h=i.params[0];else if(i.method==="eth_sendTransaction"&&cp(i.params))h=no({calls:[i.params[0]],chainId:c,from:i.params[0].from}).params[0];else throw new Error("Could not get original call");const v=da({abi:Se,functionName:"executeBatch",args:[h.calls.map(x=>{var I,D;return{target:x.to,value:Mp((I=x.value)!==null&&I!==void 0?I:"0x0"),data:(D=x.data)!==null&&D!==void 0?D:"0x"}})]}),k=[...g,{data:v,to:n,value:"0x0"}],P=await s({method:"wallet_sendCalls",params:[Object.assign(Object.assign({},h),{calls:k,from:t})]});return i.method==="eth_sendTransaction"?to({client:r,id:P}):P}const{hexToNumber:Yn,isAddressEqual:Np,numberToHex:Jn}=await ye("viem");class oo{constructor(t){var n,r,i,a;this.communicator=t.communicator,this.callback=t.callback,this.keyManager=new Kf;const{account:s,chains:o}=A.getState();this.accounts=(n=s.accounts)!==null&&n!==void 0?n:[],this.chain=(r=s.chain)!==null&&r!==void 0?r:{id:(a=(i=t.metadata.appChainIds)===null||i===void 0?void 0:i[0])!==null&&a!==void 0?a:1},o&&Ki(o)}async handshake(t){var n,r,i;const a=Ee.get(t);mf({method:t.method,correlationId:a});try{await((r=(n=this.communicator).waitForPopupLoaded)===null||r===void 0?void 0:r.call(n));const s=await this.createRequestMessage({handshake:{method:t.method,params:(i=t.params)!==null&&i!==void 0?i:[]}},a),o=await this.communicator.postRequestAndWaitForResponse(s);if("failure"in o.content)throw o.content.failure;const c=await Ys("public",o.sender);await this.keyManager.setPeerPublicKey(c);const u=await this.decryptResponseMessage(o);this.handleResponse(t,u),gf({method:t.method,correlationId:a})}catch(s){throw yf({method:t.method,correlationId:a,errorMessage:nt(s)}),s}}async request(t){const n=Ee.get(t);bf({method:t.method,correlationId:n});try{const r=await this._request(t);return vf({method:t.method,correlationId:n}),r}catch(r){throw wf({method:t.method,correlationId:n,errorMessage:nt(r)}),r}}async _request(t){var n,r,i,a,s,o,c,u,p,f,l,d,g,h;if(this.accounts.length===0)switch(t.method){case"eth_requestAccounts":return await((r=(n=this.communicator).waitForPopupLoaded)===null||r===void 0?void 0:r.call(n)),await Kn(),await this.request({method:"wallet_connect",params:[{version:"1",capabilities:Object.assign({},(a=(i=A.subAccountsConfig.get())===null||i===void 0?void 0:i.capabilities)!==null&&a!==void 0?a:{})}]}),this.accounts;case"wallet_switchEthereumChain":{ea(t.params),this.chain.id=Number(t.params[0].chainId);return}case"wallet_connect":{await((o=(s=this.communicator).waitForPopupLoaded)===null||o===void 0?void 0:o.call(s)),await Kn();let v={};lp(t,"addSubAccount")&&(v=(u=(c=A.subAccountsConfig.get())===null||c===void 0?void 0:c.capabilities)!==null&&u!==void 0?u:{});const k=An(t,v);return this.sendRequestToPopup(k)}case"wallet_sendCalls":case"wallet_sign":return this.sendRequestToPopup(t);default:throw S.provider.unauthorized()}if(this.shouldRequestUseSubAccountSigner(t)){const v=Ee.get(t);xf({method:t.method,correlationId:v});try{const k=await this.sendRequestToSubAccountSigner(t);return Ef({method:t.method,correlationId:v}),k}catch(k){throw Sf({method:t.method,correlationId:v,errorMessage:nt(k)}),k}}switch(t.method){case"eth_requestAccounts":case"eth_accounts":{const v=A.subAccounts.get(),k=A.subAccountsConfig.get();return v?.address&&(this.accounts=k?.enableAutoSubAccounts?nn(this.accounts,v.address):rn(this.accounts,v.address)),(p=this.callback)===null||p===void 0||p.call(this,"connect",{chainId:Jn(this.chain.id)}),this.accounts}case"eth_coinbase":return this.accounts[0];case"net_version":return this.chain.id;case"eth_chainId":return Jn(this.chain.id);case"wallet_getCapabilities":return this.handleGetCapabilitiesRequest(t);case"wallet_switchEthereumChain":return this.handleSwitchChainRequest(t);case"eth_ecRecover":case"personal_sign":case"wallet_sign":case"personal_ecRecover":case"eth_signTransaction":case"eth_sendTransaction":case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"eth_signTypedData_v4":case"eth_signTypedData":case"wallet_addEthereumChain":case"wallet_watchAsset":case"wallet_sendCalls":case"wallet_showCallsStatus":case"wallet_grantPermissions":return this.sendRequestToPopup(t);case"wallet_connect":{const v=await fp();if(v)return v;await((l=(f=this.communicator).waitForPopupLoaded)===null||l===void 0?void 0:l.call(f)),await Kn();const k=A.subAccountsConfig.get(),P=An(t,(d=k?.capabilities)!==null&&d!==void 0?d:{});return(g=this.callback)===null||g===void 0||g.call(this,"connect",{chainId:Jn(this.chain.id)}),this.sendRequestToPopup(P)}case"wallet_getSubAccounts":{const v=A.subAccounts.get();if(v?.address)return{subAccounts:[v]};if(!this.chain.rpcUrl)throw S.rpc.internal("No RPC URL set for chain");const k=await Ut(t,this.chain.rpcUrl);if(Ye(k.subAccounts,"subAccounts"),k.subAccounts.length>0){tn(k.subAccounts[0]);const P=k.subAccounts[0];A.subAccounts.set({address:P.address,factory:P.factory,factoryData:P.factoryData})}return k}case"wallet_addSubAccount":return this.addSubAccount(t);case"coinbase_fetchPermissions":{tp(t);const v=np(t),k=await Ut(v,Hs),P=Yn((h=v.params)===null||h===void 0?void 0:h[0].chainId);return A.spendPermissions.set(k.permissions.map(x=>Object.assign(Object.assign({},x),{chainId:P}))),k}default:if(!this.chain.rpcUrl)throw S.rpc.internal("No RPC URL set for chain");return Ut(t,this.chain.rpcUrl)}}async sendRequestToPopup(t){var n,r;await((r=(n=this.communicator).waitForPopupLoaded)===null||r===void 0?void 0:r.call(n));const i=await this.sendEncryptedRequest(t),a=await this.decryptResponseMessage(i);return this.handleResponse(t,a)}async handleResponse(t,n){var r,i,a,s,o;const c=n.result;if("error"in c)throw c.error;switch(t.method){case"eth_requestAccounts":{const u=c.value;this.accounts=u,A.account.set({accounts:u,chain:this.chain}),(r=this.callback)===null||r===void 0||r.call(this,"accountsChanged",u);break}case"wallet_connect":{const u=c.value,p=u.accounts.map(k=>k.address);this.accounts=p,A.account.set({accounts:p});const f=u.accounts.at(0),l=f?.capabilities;if(l?.subAccounts){const k=l?.subAccounts;Ye(k,"subAccounts"),tn(k[0]),A.subAccounts.set({address:k[0].address,factory:k[0].factory,factoryData:k[0].factoryData})}let d=[this.accounts[0]];const g=A.subAccounts.get(),h=A.subAccountsConfig.get();g?.address&&(this.accounts=h?.enableAutoSubAccounts?nn(this.accounts,g.address):rn(this.accounts,g.address));const v=(a=(i=u?.accounts)===null||i===void 0?void 0:i[0].capabilities)===null||a===void 0?void 0:a.spendPermissions;v&&"permissions"in v&&A.spendPermissions.set(v?.permissions),(s=this.callback)===null||s===void 0||s.call(this,"accountsChanged",d);break}case"wallet_addSubAccount":{tn(c.value);const u=c.value;A.subAccounts.set(u);const p=A.subAccountsConfig.get();this.accounts=p?.enableAutoSubAccounts?nn(this.accounts,u.address):rn(this.accounts,u.address),(o=this.callback)===null||o===void 0||o.call(this,"accountsChanged",this.accounts);break}}return c.value}async cleanup(){var t,n;const r=A.config.get().metadata;await this.keyManager.clear(),A.account.clear(),A.subAccounts.clear(),A.spendPermissions.clear(),A.chains.clear(),this.accounts=[],this.chain={id:(n=(t=r?.appChainIds)===null||t===void 0?void 0:t[0])!==null&&n!==void 0?n:1}}async handleSwitchChainRequest(t){ea(t.params);const n=Rt(t.params[0].chainId);if(this.updateChain(n))return null;const i=await this.sendRequestToPopup(t);return i===null&&this.updateChain(n),i}async handleGetCapabilitiesRequest(t){ep(t.params);const n=t.params[0],r=t.params[1];if(!this.accounts.some(o=>Np(o,n)))throw S.provider.unauthorized("no active account found when getting capabilities");const i=A.getState().account.capabilities;if(!i)return{};if(!r||r.length===0)return i;const a=new Set(r.map(o=>Yn(o)));return Object.fromEntries(Object.entries(i).filter(([o])=>{try{const c=Yn(o);return a.has(c)}catch{return!1}}))}async sendEncryptedRequest(t){const n=await this.keyManager.getSharedSecret();if(!n)throw S.provider.unauthorized("No shared secret found when encrypting request");const r=await Nf({action:t,chainId:this.chain.id},n),i=Ee.get(t),a=await this.createRequestMessage({encrypted:r},i);return this.communicator.postRequestAndWaitForResponse(a)}async createRequestMessage(t,n){const r=await Zs("public",await this.keyManager.getOwnPublicKey());return{id:crypto.randomUUID(),correlationId:n,sender:r,content:t,timestamp:new Date}}async decryptResponseMessage(t){var n,r,i;const a=t.content;if("failure"in a)throw a.failure;const s=await this.keyManager.getSharedSecret();if(!s)throw S.provider.unauthorized("Invalid session: no shared secret found when decrypting response");const o=await Rf(a.encrypted,s),c=(n=o.data)===null||n===void 0?void 0:n.chains;if(c){const p=(r=o.data)===null||r===void 0?void 0:r.nativeCurrencies,f=Object.entries(c).map(([l,d])=>{const g=p?.[Number(l)];return Object.assign({id:Number(l),rpcUrl:d},g?{nativeCurrency:g}:{})});A.chains.set(f),this.updateChain(this.chain.id,f),Ki(f)}const u=(i=o.data)===null||i===void 0?void 0:i.capabilities;return u&&A.account.set({capabilities:u}),o}updateChain(t,n){var r;const i=A.getState(),a=n??i.chains,s=a?.find(o=>o.id===t);return s?(s!==this.chain&&(this.chain=s,A.account.set({chain:s}),(r=this.callback)===null||r===void 0||r.call(this,"chainChanged",gt(s.id))),!0):!1}async addSubAccount(t){var n,r,i,a;const o=A.getState().subAccount,c=A.subAccountsConfig.get();if(o?.address)return this.accounts=c?.enableAutoSubAccounts?nn(this.accounts,o.address):rn(this.accounts,o.address),(n=this.callback)===null||n===void 0||n.call(this,"accountsChanged",this.accounts),o;if(await((i=(r=this.communicator).waitForPopupLoaded)===null||i===void 0?void 0:i.call(r)),Array.isArray(t.params)&&t.params.length>0&&t.params[0].account&&t.params[0].account.type==="create"){let p;if(t.params[0].account.keys&&t.params[0].account.keys.length>0)p=t.params[0].account.keys;else{const f=(a=A.subAccountsConfig.get())!==null&&a!==void 0?a:{},{account:l}=f.toOwnerAccount?await f.toOwnerAccount():await Nr();if(!l)throw S.provider.unauthorized("could not get subaccount owner account when adding sub account");p=[{type:l.address?"address":"webauthn-p256",publicKey:l.address||l.publicKey}]}t.params[0].account.keys=p}const u=await this.sendRequestToPopup(t);return tn(u),u}shouldRequestUseSubAccountSigner(t){const n=Xi(t),r=A.subAccounts.get();return n?n.toLowerCase()===r?.address.toLowerCase():!1}async sendRequestToSubAccountSigner(t){var n;const r=A.subAccounts.get(),i=A.subAccountsConfig.get(),a=A.config.get();me(r?.address,S.provider.unauthorized("no active sub account when sending request to sub account signer"));const s=i?.toOwnerAccount?await i.toOwnerAccount():await Nr();me(s?.account,S.provider.unauthorized("no active sub account owner when sending request to sub account signer")),Xi(t)===void 0&&(t=Xf(t,r.address));const c=Vs(this.chain.id);me(c,S.rpc.internal(`client not found for chainId ${this.chain.id} when sending request to sub account signer`));const u=this.accounts.find(g=>g.toLowerCase()!==r.address.toLowerCase());me(u,S.provider.unauthorized("no global account found when sending request to sub account signer"));const p=dp({attribution:(n=a.preference)===null||n===void 0?void 0:n.attribution,dappOrigin:window.location.origin}),f=s.account.type==="local"?s.account.address:s.account.publicKey;let l=await so({address:r.address,factory:r.factory,factoryData:r.factoryData,publicKey:f,client:c});if(l===-1){const g=Ee.get(t);kf({method:t.method,correlationId:g});try{l=await Lp({ownerAccount:s.account,globalAccountRequest:this.sendRequestToPopup.bind(this)}),Af({method:t.method,correlationId:g})}catch(h){return _f({method:t.method,correlationId:g,errorMessage:nt(h)}),S.provider.unauthorized("failed to add sub account owner when sending request to sub account signer")}}const{request:d}=await _p({address:r.address,owner:s.account,client:c,factory:r.factory,factoryData:r.factoryData,parentAddress:u,attribution:p?{suffix:p}:void 0,ownerIndex:l});try{return await d(t)}catch(g){let h;if(js(g))h=JSON.parse(g.details);else if(Gi(g))h=g;else throw g;if(!(Gi(h)&&h.data)||!h.data)throw g;const v=Ee.get(t);If({method:t.method,correlationId:v});try{const k=await Dp({errorData:h.data,globalAccountAddress:u,subAccountAddress:r.address,client:c,request:t,subAccountRequest:d,globalAccountRequest:this.request.bind(this)});return Of({method:t.method,correlationId:v}),k}catch(k){throw console.error(k),Pf({method:t.method,correlationId:v,errorMessage:nt(k)}),g}}}}const Rp=({method:e,correlationId:t})=>{F("walletlink_signer.handshake.started",{action:H.unknown,componentType:U.unknown,method:e,correlationId:t},$.high)},Up=({method:e,correlationId:t,errorMessage:n})=>{F("walletlink_signer.handshake.error",{action:H.error,componentType:U.unknown,method:e,correlationId:t,errorMessage:n},$.high)},Hp=({method:e,correlationId:t})=>{F("walletlink_signer.handshake.completed",{action:H.unknown,componentType:U.unknown,method:e,correlationId:t},$.high)},$p=({method:e,correlationId:t})=>{F("walletlink_signer.request.started",{action:H.unknown,componentType:U.unknown,method:e,correlationId:t},$.high)},Gp=({method:e,correlationId:t,errorMessage:n})=>{F("walletlink_signer.request.error",{action:H.error,componentType:U.unknown,method:e,correlationId:t,errorMessage:n},$.high)},Fp=({method:e,correlationId:t})=>{F("walletlink_signer.request.completed",{action:H.unknown,componentType:U.unknown,method:e,correlationId:t},$.high)},la=()=>{F("walletlink_signer.walletlink_connection.connection_failed",{action:H.measurement,componentType:U.unknown},$.high)},zp=()=>{F("walletlink_signer.walletlink_connection.fetch_unseen_events_failed",{action:H.measurement,componentType:U.unknown},$.high)};var W={},re={};Object.defineProperty(re,"__esModule",{value:!0});re.output=re.exists=re.hash=re.bytes=re.bool=re.number=re.isBytes=void 0;function _n(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}re.number=_n;function co(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}re.bool=co;function uo(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}re.isBytes=uo;function di(e,...t){if(!uo(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}re.bytes=di;function lo(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");_n(e.outputLen),_n(e.blockLen)}re.hash=lo;function fo(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}re.exists=fo;function po(e,t){di(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}re.output=po;const qp={number:_n,bool:co,bytes:di,hash:lo,exists:fo,output:po};re.default=qp;var L={};Object.defineProperty(L,"__esModule",{value:!0});L.add5L=L.add5H=L.add4H=L.add4L=L.add3H=L.add3L=L.add=L.rotlBL=L.rotlBH=L.rotlSL=L.rotlSH=L.rotr32L=L.rotr32H=L.rotrBL=L.rotrBH=L.rotrSL=L.rotrSH=L.shrSL=L.shrSH=L.toBig=L.split=L.fromBig=void 0;const cn=BigInt(2**32-1),Ur=BigInt(32);function li(e,t=!1){return t?{h:Number(e&cn),l:Number(e>>Ur&cn)}:{h:Number(e>>Ur&cn)|0,l:Number(e&cn)|0}}L.fromBig=li;function ho(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:a,l:s}=li(e[i],t);[n[i],r[i]]=[a,s]}return[n,r]}L.split=ho;const mo=(e,t)=>BigInt(e>>>0)<<Ur|BigInt(t>>>0);L.toBig=mo;const yo=(e,t,n)=>e>>>n;L.shrSH=yo;const go=(e,t,n)=>e<<32-n|t>>>n;L.shrSL=go;const bo=(e,t,n)=>e>>>n|t<<32-n;L.rotrSH=bo;const wo=(e,t,n)=>e<<32-n|t>>>n;L.rotrSL=wo;const vo=(e,t,n)=>e<<64-n|t>>>n-32;L.rotrBH=vo;const xo=(e,t,n)=>e>>>n-32|t<<64-n;L.rotrBL=xo;const Eo=(e,t)=>t;L.rotr32H=Eo;const So=(e,t)=>e;L.rotr32L=So;const ko=(e,t,n)=>e<<n|t>>>32-n;L.rotlSH=ko;const Ao=(e,t,n)=>t<<n|e>>>32-n;L.rotlSL=Ao;const _o=(e,t,n)=>t<<n-32|e>>>64-n;L.rotlBH=_o;const Io=(e,t,n)=>e<<n-32|t>>>64-n;L.rotlBL=Io;function Oo(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}L.add=Oo;const Po=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0);L.add3L=Po;const Co=(e,t,n,r)=>t+n+r+(e/2**32|0)|0;L.add3H=Co;const To=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0);L.add4L=To;const Bo=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0;L.add4H=Bo;const Lo=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0);L.add5L=Lo;const jo=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0;L.add5H=jo;const Wp={fromBig:li,split:ho,toBig:mo,shrSH:yo,shrSL:go,rotrSH:bo,rotrSL:wo,rotrBH:vo,rotrBL:xo,rotr32H:Eo,rotr32L:So,rotlSH:ko,rotlSL:Ao,rotlBH:_o,rotlBL:Io,add:Oo,add3L:Po,add3H:Co,add4L:To,add4H:Bo,add5H:jo,add5L:Lo};L.default=Wp;var Mo={},Ln={};Object.defineProperty(Ln,"__esModule",{value:!0});Ln.crypto=void 0;Ln.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;(function(e){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const t=Ln,n=re;function r(b){return b instanceof Uint8Array||b!=null&&typeof b=="object"&&b.constructor.name==="Uint8Array"}e.isBytes=r;const i=b=>new Uint8Array(b.buffer,b.byteOffset,b.byteLength);e.u8=i;const a=b=>new Uint32Array(b.buffer,b.byteOffset,Math.floor(b.byteLength/4));e.u32=a;const s=b=>new DataView(b.buffer,b.byteOffset,b.byteLength);e.createView=s;const o=(b,m)=>b<<32-m|b>>>m;e.rotr=o;const c=(b,m)=>b<<m|b>>>32-m>>>0;e.rotl=c,e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const u=b=>b<<24&4278190080|b<<8&16711680|b>>>8&65280|b>>>24&255;e.byteSwap=u,e.byteSwapIfBE=e.isLE?b=>b:b=>(0,e.byteSwap)(b);function p(b){for(let m=0;m<b.length;m++)b[m]=(0,e.byteSwap)(b[m])}e.byteSwap32=p;const f=Array.from({length:256},(b,m)=>m.toString(16).padStart(2,"0"));function l(b){(0,n.bytes)(b);let m="";for(let w=0;w<b.length;w++)m+=f[b[w]];return m}e.bytesToHex=l;const d={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function g(b){if(b>=d._0&&b<=d._9)return b-d._0;if(b>=d._A&&b<=d._F)return b-(d._A-10);if(b>=d._a&&b<=d._f)return b-(d._a-10)}function h(b){if(typeof b!="string")throw new Error("hex string expected, got "+typeof b);const m=b.length,w=m/2;if(m%2)throw new Error("padded hex string expected, got unpadded hex of length "+m);const y=new Uint8Array(w);for(let E=0,_=0;E<w;E++,_+=2){const B=g(b.charCodeAt(_)),C=g(b.charCodeAt(_+1));if(B===void 0||C===void 0){const O=b[_]+b[_+1];throw new Error('hex string expected, got non-hex character "'+O+'" at index '+_)}y[E]=B*16+C}return y}e.hexToBytes=h;const v=async()=>{};e.nextTick=v;async function k(b,m,w){let y=Date.now();for(let E=0;E<b;E++){w(E);const _=Date.now()-y;_>=0&&_<m||(await(0,e.nextTick)(),y+=_)}}e.asyncLoop=k;function P(b){if(typeof b!="string")throw new Error(`utf8ToBytes expected string, got ${typeof b}`);return new Uint8Array(new TextEncoder().encode(b))}e.utf8ToBytes=P;function x(b){return typeof b=="string"&&(b=P(b)),(0,n.bytes)(b),b}e.toBytes=x;function I(...b){let m=0;for(let y=0;y<b.length;y++){const E=b[y];(0,n.bytes)(E),m+=E.length}const w=new Uint8Array(m);for(let y=0,E=0;y<b.length;y++){const _=b[y];w.set(_,E),E+=_.length}return w}e.concatBytes=I;class D{clone(){return this._cloneInto()}}e.Hash=D;const T={}.toString;function G(b,m){if(m!==void 0&&T.call(m)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(b,m)}e.checkOpts=G;function K(b){const m=y=>b().update(x(y)).digest(),w=b();return m.outputLen=w.outputLen,m.blockLen=w.blockLen,m.create=()=>b(),m}e.wrapConstructor=K;function j(b){const m=(y,E)=>b(E).update(x(y)).digest(),w=b({});return m.outputLen=w.outputLen,m.blockLen=w.blockLen,m.create=y=>b(y),m}e.wrapConstructorWithOpts=j;function we(b){const m=(y,E)=>b(E).update(x(y)).digest(),w=b({});return m.outputLen=w.outputLen,m.blockLen=w.blockLen,m.create=y=>b(y),m}e.wrapXOFConstructorWithOpts=we;function fe(b=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(b));throw new Error("crypto.getRandomValues must be defined")}e.randomBytes=fe})(Mo);Object.defineProperty(W,"__esModule",{value:!0});W.shake256=W.shake128=W.keccak_512=W.keccak_384=W.keccak_256=W.keccak_224=W.sha3_512=W.sha3_384=W.sha3_256=W.sha3_224=W.Keccak=W.keccakP=void 0;const mt=re,Gt=L,je=Mo,Do=[],No=[],Ro=[],Vp=BigInt(0),jt=BigInt(1),Kp=BigInt(2),Zp=BigInt(7),Yp=BigInt(256),Jp=BigInt(113);for(let e=0,t=jt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Do.push(2*(5*r+n)),No.push((e+1)*(e+2)/2%64);let i=Vp;for(let a=0;a<7;a++)t=(t<<jt^(t>>Zp)*Jp)%Yp,t&Kp&&(i^=jt<<(jt<<BigInt(a))-jt);Ro.push(i)}const[Qp,Xp]=(0,Gt.split)(Ro,!0),fa=(e,t,n)=>n>32?(0,Gt.rotlBH)(e,t,n):(0,Gt.rotlSH)(e,t,n),pa=(e,t,n)=>n>32?(0,Gt.rotlBL)(e,t,n):(0,Gt.rotlSL)(e,t,n);function Uo(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let s=0;s<10;s++)n[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){const o=(s+8)%10,c=(s+2)%10,u=n[c],p=n[c+1],f=fa(u,p,1)^n[o],l=pa(u,p,1)^n[o+1];for(let d=0;d<50;d+=10)e[s+d]^=f,e[s+d+1]^=l}let i=e[2],a=e[3];for(let s=0;s<24;s++){const o=No[s],c=fa(i,a,o),u=pa(i,a,o),p=Do[s];i=e[p],a=e[p+1],e[p]=c,e[p+1]=u}for(let s=0;s<50;s+=10){for(let o=0;o<10;o++)n[o]=e[s+o];for(let o=0;o<10;o++)e[s+o]^=~n[(o+2)%10]&n[(o+4)%10]}e[0]^=Qp[r],e[1]^=Xp[r]}n.fill(0)}W.keccakP=Uo;class zt extends je.Hash{constructor(t,n,r,i=!1,a=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=i,this.rounds=a,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,mt.number)(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,je.u32)(this.state)}keccak(){je.isLE||(0,je.byteSwap32)(this.state32),Uo(this.state32,this.rounds),je.isLE||(0,je.byteSwap32)(this.state32),this.posOut=0,this.pos=0}update(t){(0,mt.exists)(this);const{blockLen:n,state:r}=this;t=(0,je.toBytes)(t);const i=t.length;for(let a=0;a<i;){const s=Math.min(n-this.pos,i-a);for(let o=0;o<s;o++)r[this.pos++]^=t[a++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:i}=this;t[r]^=n,n&128&&r===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){(0,mt.exists)(this,!1),(0,mt.bytes)(t),this.finish();const n=this.state,{blockLen:r}=this;for(let i=0,a=t.length;i<a;){this.posOut>=r&&this.keccak();const s=Math.min(r-this.posOut,a-i);t.set(n.subarray(this.posOut,this.posOut+s),i),this.posOut+=s,i+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return(0,mt.number)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,mt.output)(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:s}=this;return t||(t=new zt(n,r,i,s,a)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=s,t.destroyed=this.destroyed,t}}W.Keccak=zt;const et=(e,t,n)=>(0,je.wrapConstructor)(()=>new zt(t,e,n));W.sha3_224=et(6,144,224/8);W.sha3_256=et(6,136,256/8);W.sha3_384=et(6,104,384/8);W.sha3_512=et(6,72,512/8);W.keccak_224=et(1,144,224/8);W.keccak_256=et(1,136,256/8);W.keccak_384=et(1,104,384/8);W.keccak_512=et(1,72,512/8);const Ho=(e,t,n)=>(0,je.wrapXOFConstructorWithOpts)((r={})=>new zt(t,e,r.dkLen===void 0?n:r.dkLen,!0));W.shake128=Ho(31,168,128/8);W.shake256=Ho(31,136,256/8);const{keccak_256:eh}=W;function $o(e){return Buffer.allocUnsafe(e).fill(0)}function th(e){return`0x${e.toString(16)}`}function nh(e){const t=th(e);return new Buffer(zo(t.slice(2)),"hex")}function rh(e){return e.toString(2).length}function Go(e,t){let n=e.toString(16);n.length%2!==0&&(n="0"+n);const r=n.match(/.{1,2}/g).map(i=>parseInt(i,16));for(;r.length<t;)r.unshift(0);return Buffer.from(r)}function ih(e,t){const n=e<0n;let r;if(n){const i=(1n<<BigInt(t))-1n;r=(~e&i)+1n}else r=e;return r&=(1n<<BigInt(t))-1n,r}function Fo(e,t,n){const r=$o(t);return e=jn(e),n?e.length<t?(e.copy(r),r):e.slice(0,t):e.length<t?(e.copy(r,t-e.length),r):e.slice(-t)}function ah(e,t){return Fo(e,t,!0)}function jn(e){if(!Buffer.isBuffer(e))if(Array.isArray(e))e=Buffer.from(e);else if(typeof e=="string")qo(e)?e=Buffer.from(zo(Wo(e)),"hex"):e=Buffer.from(e);else if(typeof e=="number")e=nh(e);else if(e==null)e=Buffer.allocUnsafe(0);else if(typeof e=="bigint")e=Go(e);else if(e.toArray)e=Buffer.from(e.toArray());else throw new Error("invalid type");return e}function sh(e){return e=jn(e),"0x"+e.toString("hex")}function oh(e,t){if(e=jn(e),t||(t=256),t!==256)throw new Error("unsupported");return Buffer.from(eh(new Uint8Array(e)))}function zo(e){return e.length%2?"0"+e:e}function qo(e){return typeof e=="string"&&e.match(/^0x[0-9A-Fa-f]*$/)}function Wo(e){return typeof e=="string"&&e.startsWith("0x")?e.slice(2):e}var Vo={zeros:$o,setLength:Fo,setLengthRight:ah,isHexString:qo,stripHexPrefix:Wo,toBuffer:jn,bufferToHex:sh,keccak:oh,bitLengthFromBigInt:rh,bufferBEFromBigInt:Go,twosFromBigInt:ih};const ce=Vo;function Ko(e){return e.startsWith("int[")?"int256"+e.slice(3):e==="int"?"int256":e.startsWith("uint[")?"uint256"+e.slice(4):e==="uint"?"uint256":e.startsWith("fixed[")?"fixed128x128"+e.slice(5):e==="fixed"?"fixed128x128":e.startsWith("ufixed[")?"ufixed128x128"+e.slice(6):e==="ufixed"?"ufixed128x128":e}function Et(e){return Number.parseInt(/^\D+(\d+)$/.exec(e)[1],10)}function ha(e){var t=/^\D+(\d+)x(\d+)$/.exec(e);return[Number.parseInt(t[1],10),Number.parseInt(t[2],10)]}function Zo(e){var t=e.match(/(.*)\[(.*?)\]$/);return t?t[2]===""?"dynamic":Number.parseInt(t[2],10):null}function rt(e){var t=typeof e;if(t==="string"||t==="number")return BigInt(e);if(t==="bigint")return e;throw new Error("Argument is not a number")}function Oe(e,t){var n,r,i,a;if(e==="address")return Oe("uint160",rt(t));if(e==="bool")return Oe("uint8",t?1:0);if(e==="string")return Oe("bytes",new Buffer(t,"utf8"));if(uh(e)){if(typeof t.length>"u")throw new Error("Not an array?");if(n=Zo(e),n!=="dynamic"&&n!==0&&t.length>n)throw new Error("Elements exceed array size: "+n);i=[],e=e.slice(0,e.lastIndexOf("[")),typeof t=="string"&&(t=JSON.parse(t));for(a in t)i.push(Oe(e,t[a]));if(n==="dynamic"){var s=Oe("uint256",t.length);i.unshift(s)}return Buffer.concat(i)}else{if(e==="bytes")return t=new Buffer(t),i=Buffer.concat([Oe("uint256",t.length),t]),t.length%32!==0&&(i=Buffer.concat([i,ce.zeros(32-t.length%32)])),i;if(e.startsWith("bytes")){if(n=Et(e),n<1||n>32)throw new Error("Invalid bytes<N> width: "+n);return ce.setLengthRight(t,32)}else if(e.startsWith("uint")){if(n=Et(e),n%8||n<8||n>256)throw new Error("Invalid uint<N> width: "+n);r=rt(t);const o=ce.bitLengthFromBigInt(r);if(o>n)throw new Error("Supplied uint exceeds width: "+n+" vs "+o);if(r<0)throw new Error("Supplied uint is negative");return ce.bufferBEFromBigInt(r,32)}else if(e.startsWith("int")){if(n=Et(e),n%8||n<8||n>256)throw new Error("Invalid int<N> width: "+n);r=rt(t);const o=ce.bitLengthFromBigInt(r);if(o>n)throw new Error("Supplied int exceeds width: "+n+" vs "+o);const c=ce.twosFromBigInt(r,256);return ce.bufferBEFromBigInt(c,32)}else if(e.startsWith("ufixed")){if(n=ha(e),r=rt(t),r<0)throw new Error("Supplied ufixed is negative");return Oe("uint256",r*BigInt(2)**BigInt(n[1]))}else if(e.startsWith("fixed"))return n=ha(e),Oe("int256",rt(t)*BigInt(2)**BigInt(n[1]))}throw new Error("Unsupported or invalid type: "+e)}function ch(e){return e==="string"||e==="bytes"||Zo(e)==="dynamic"}function uh(e){return e.lastIndexOf("]")===e.length-1}function dh(e,t){var n=[],r=[],i=32*e.length;for(var a in e){var s=Ko(e[a]),o=t[a],c=Oe(s,o);ch(s)?(n.push(Oe("uint256",i)),r.push(c),i+=c.length):n.push(c)}return Buffer.concat(n.concat(r))}function Yo(e,t){if(e.length!==t.length)throw new Error("Number of types are not matching the values");for(var n,r,i=[],a=0;a<e.length;a++){var s=Ko(e[a]),o=t[a];if(s==="bytes")i.push(o);else if(s==="string")i.push(new Buffer(o,"utf8"));else if(s==="bool")i.push(new Buffer(o?"01":"00","hex"));else if(s==="address")i.push(ce.setLength(o,20));else if(s.startsWith("bytes")){if(n=Et(s),n<1||n>32)throw new Error("Invalid bytes<N> width: "+n);i.push(ce.setLengthRight(o,n))}else if(s.startsWith("uint")){if(n=Et(s),n%8||n<8||n>256)throw new Error("Invalid uint<N> width: "+n);r=rt(o);const c=ce.bitLengthFromBigInt(r);if(c>n)throw new Error("Supplied uint exceeds width: "+n+" vs "+c);i.push(ce.bufferBEFromBigInt(r,n/8))}else if(s.startsWith("int")){if(n=Et(s),n%8||n<8||n>256)throw new Error("Invalid int<N> width: "+n);r=rt(o);const c=ce.bitLengthFromBigInt(r);if(c>n)throw new Error("Supplied int exceeds width: "+n+" vs "+c);const u=ce.twosFromBigInt(r,n);i.push(ce.bufferBEFromBigInt(u,n/8))}else throw new Error("Unsupported or invalid type: "+s)}return Buffer.concat(i)}function lh(e,t){return ce.keccak(Yo(e,t))}var fh={rawEncode:dh,solidityPack:Yo,soliditySHA3:lh};const ve=Vo,Ht=fh,Jo={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},Qn={encodeData(e,t,n,r=!0){const i=["bytes32"],a=[this.hashType(e,n)];if(r){const s=(o,c,u)=>{if(n[c]!==void 0)return["bytes32",u==null?"0x0000000000000000000000000000000000000000000000000000000000000000":ve.keccak(this.encodeData(c,u,n,r))];if(u===void 0)throw new Error(`missing value for field ${o} of type ${c}`);if(c==="bytes")return["bytes32",ve.keccak(u)];if(c==="string")return typeof u=="string"&&(u=Buffer.from(u,"utf8")),["bytes32",ve.keccak(u)];if(c.lastIndexOf("]")===c.length-1){const p=c.slice(0,c.lastIndexOf("[")),f=u.map(l=>s(o,p,l));return["bytes32",ve.keccak(Ht.rawEncode(f.map(([l])=>l),f.map(([,l])=>l)))]}return[c,u]};for(const o of n[e]){const[c,u]=s(o.name,o.type,t[o.name]);i.push(c),a.push(u)}}else for(const s of n[e]){let o=t[s.name];if(o!==void 0)if(s.type==="bytes")i.push("bytes32"),o=ve.keccak(o),a.push(o);else if(s.type==="string")i.push("bytes32"),typeof o=="string"&&(o=Buffer.from(o,"utf8")),o=ve.keccak(o),a.push(o);else if(n[s.type]!==void 0)i.push("bytes32"),o=ve.keccak(this.encodeData(s.type,o,n,r)),a.push(o);else{if(s.type.lastIndexOf("]")===s.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");i.push(s.type),a.push(o)}}return Ht.rawEncode(i,a)},encodeType(e,t){let n="",r=this.findTypeDependencies(e,t).filter(i=>i!==e);r=[e].concat(r.sort());for(const i of r){if(!t[i])throw new Error("No type definition specified: "+i);n+=i+"("+t[i].map(({name:s,type:o})=>o+" "+s).join(",")+")"}return n},findTypeDependencies(e,t,n=[]){if(e=e.match(/^\w*/)[0],n.includes(e)||t[e]===void 0)return n;n.push(e);for(const r of t[e])for(const i of this.findTypeDependencies(r.type,t,n))!n.includes(i)&&n.push(i);return n},hashStruct(e,t,n,r=!0){return ve.keccak(this.encodeData(e,t,n,r))},hashType(e,t){return ve.keccak(this.encodeType(e,t))},sanitizeData(e){const t={};for(const n in Jo.properties)e[n]&&(t[n]=e[n]);return t.types&&(t.types=Object.assign({EIP712Domain:[]},t.types)),t},hash(e,t=!0){const n=this.sanitizeData(e),r=[Buffer.from("1901","hex")];return r.push(this.hashStruct("EIP712Domain",n.domain,n.types,t)),n.primaryType!=="EIP712Domain"&&r.push(this.hashStruct(n.primaryType,n.message,n.types,t)),ve.keccak(Buffer.concat(r))}};var ph={TYPED_MESSAGE_SCHEMA:Jo,TypedDataUtils:Qn,hashForSignTypedDataLegacy:function(e){return hh(e.data)},hashForSignTypedData_v3:function(e){return Qn.hash(e.data,!1)},hashForSignTypedData_v4:function(e){return Qn.hash(e.data)}};function hh(e){const t=new Error("Expect argument to be non-empty array");if(typeof e!="object"||!e.length)throw t;const n=e.map(function(a){return a.type==="bytes"?ve.toBuffer(a.value):a.value}),r=e.map(function(a){return a.type}),i=e.map(function(a){if(!a.name)throw t;return a.type+" "+a.name});return Ht.soliditySHA3(["bytes32","bytes32"],[Ht.soliditySHA3(new Array(e.length).fill("string"),i),Ht.soliditySHA3(r,n)])}const un=Ic(ph),mh="walletUsername",Hr="Addresses",yh="AppVersion";class gh{constructor(t){this.secret=t}async encrypt(t){const n=this.secret;if(n.length!==64)throw new Error("secret must be 256 bits");const r=crypto.getRandomValues(new Uint8Array(12)),i=await crypto.subtle.importKey("raw",dn(n),{name:"aes-gcm"},!1,["encrypt","decrypt"]),a=new TextEncoder,s=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:r},i,a.encode(t)),o=16,c=s.slice(s.byteLength-o),u=s.slice(0,s.byteLength-o),p=new Uint8Array(c),f=new Uint8Array(u),l=new Uint8Array([...r,...p,...f]);return ii(l)}async decrypt(t){const n=this.secret;if(n.length!==64)throw new Error("secret must be 256 bits");return new Promise((r,i)=>{(async()=>{const a=await crypto.subtle.importKey("raw",dn(n),{name:"aes-gcm"},!1,["encrypt","decrypt"]),s=dn(t),o=s.slice(0,12),c=s.slice(12,28),u=s.slice(28),p=new Uint8Array([...u,...c]),f={name:"AES-GCM",iv:new Uint8Array(o)};try{const l=await window.crypto.subtle.decrypt(f,a,p),d=new TextDecoder;r(d.decode(l))}catch(l){i(l)}})()})}}class bh{constructor(t,n,r){this.linkAPIUrl=t,this.sessionId=n;const i=`${n}:${r}`;this.auth=`Basic ${btoa(i)}`}async markUnseenEventsAsSeen(t){return Promise.all(t.map(n=>fetch(`${this.linkAPIUrl}/events/${n.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(n=>console.error("Unable to mark events as seen:",n))}async fetchUnseenEvents(){var t;const n=await fetch(`${this.linkAPIUrl}/events?unseen=true`,{headers:{Authorization:this.auth}});if(n.ok){const{events:r,error:i}=await n.json();if(i)throw new Error(`Check unseen events failed: ${i}`);const a=(t=r?.filter(s=>s.event==="Web3Response").map(s=>({type:"Event",sessionId:this.sessionId,eventId:s.id,event:s.event,data:s.data})))!==null&&t!==void 0?t:[];return this.markUnseenEventsAsSeen(a),a}throw new Error(`Check unseen events failed: ${n.status}`)}}var Ce;(function(e){e[e.DISCONNECTED=0]="DISCONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.CONNECTED=2]="CONNECTED"})(Ce||(Ce={}));class pe{setConnectionStateListener(t){this.connectionStateListener=t}setIncomingDataListener(t){this.incomingDataListener=t}constructor(t,n=WebSocket){this.WebSocketClass=n,this.webSocket=null,this.isDisconnecting=!1,this.url=t.replace(/^http/,"ws"),this.instanceId=pe.instanceCounter++,pe.activeInstances.add(this.instanceId)}async connect(){if(this.webSocket)throw new Error("webSocket object is not null");if(this.isDisconnecting)throw new Error("WebSocket is disconnecting, cannot reconnect on same instance");return new Promise((t,n)=>{var r;let i;try{this.webSocket=i=new this.WebSocketClass(this.url)}catch(a){n(a);return}(r=this.connectionStateListener)===null||r===void 0||r.call(this,Ce.CONNECTING),i.onclose=a=>{var s;this.clearWebSocket(),i.readyState!==WebSocket.OPEN&&n(new Error(`websocket error ${a.code}: ${a.reason}`)),(s=this.connectionStateListener)===null||s===void 0||s.call(this,Ce.DISCONNECTED)},i.onopen=a=>{var s;t(),(s=this.connectionStateListener)===null||s===void 0||s.call(this,Ce.CONNECTED),pe.pendingData.length>0&&([...pe.pendingData].forEach(c=>this.sendData(c)),pe.pendingData=[])},i.onmessage=a=>{var s,o;if(a.data==="h")(s=this.incomingDataListener)===null||s===void 0||s.call(this,{type:"Heartbeat"});else try{const c=JSON.parse(a.data);(o=this.incomingDataListener)===null||o===void 0||o.call(this,c)}catch{}}})}disconnect(){var t;const{webSocket:n}=this;if(n){this.isDisconnecting=!0,this.clearWebSocket(),(t=this.connectionStateListener)===null||t===void 0||t.call(this,Ce.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{n.close()}catch{}}}sendData(t){const{webSocket:n}=this;if(!n){pe.pendingData.push(t),this.isDisconnecting||this.connect();return}if(n.readyState!==WebSocket.OPEN){pe.pendingData.push(t);return}n.send(t)}clearWebSocket(){const{webSocket:t}=this;t&&(this.webSocket=null,t.onclose=null,t.onerror=null,t.onmessage=null,t.onopen=null)}cleanup(){pe.activeInstances.delete(this.instanceId)}}pe.instanceCounter=0;pe.activeInstances=new Set;pe.pendingData=[];const ma=1e4,wh=6e4;class vh{constructor({session:t,linkAPIUrl:n,listener:r}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=De(1),this.reconnectAttempts=0,this.isReconnecting=!1,this._connected=!1,this._linked=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=a=>{if(!a)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",o=>a.JsonRpcUrl&&this.handleChainUpdated(o,a.JsonRpcUrl)]]).forEach((o,c)=>{const u=a[c];u!==void 0&&o(u)})},this.handleDestroyed=a=>{var s;a==="1"&&((s=this.listener)===null||s===void 0||s.resetAndReload())},this.handleAccountUpdated=async a=>{var s;try{const o=await this.cipher.decrypt(a);(s=this.listener)===null||s===void 0||s.accountUpdated(o)}catch{}},this.handleMetadataUpdated=async(a,s)=>{var o;try{const c=await this.cipher.decrypt(s);(o=this.listener)===null||o===void 0||o.metadataUpdated(a,c)}catch{}},this.handleWalletUsernameUpdated=async a=>{this.handleMetadataUpdated(mh,a)},this.handleAppVersionUpdated=async a=>{this.handleMetadataUpdated(yh,a)},this.handleChainUpdated=async(a,s)=>{var o;try{const c=await this.cipher.decrypt(a),u=await this.cipher.decrypt(s);(o=this.listener)===null||o===void 0||o.chainUpdated(c,u)}catch{}},this.session=t,this.cipher=new gh(t.secret),this.listener=r,this.linkAPIUrl=n,this.WebSocketClass=WebSocket;const i=this.createWebSocket();this.ws=i,this.http=new bh(n,t.id,t.key),this.setupVisibilityChangeHandler()}createWebSocket(){const t=new pe(`${this.linkAPIUrl}/rpc`,this.WebSocketClass);return this.activeWsInstance=t,t.setConnectionStateListener(async n=>{if(t!==this.activeWsInstance)return;let r=!1;switch(n){case Ce.DISCONNECTED:this.heartbeatIntervalId&&(clearInterval(this.heartbeatIntervalId),this.heartbeatIntervalId=void 0),this.lastHeartbeatResponse=0,r=!1,this.destroyed||(async()=>{if(this.isReconnecting)return;this.isReconnecting=!0;const a=this.reconnectAttempts===0?0:3e3;await new Promise(s=>setTimeout(s,a)),!this.destroyed&&t===this.activeWsInstance?(this.reconnectAttempts++,"cleanup"in this.ws&&typeof this.ws.cleanup=="function"&&this.ws.cleanup(),this.ws=this.createWebSocket(),this.ws.connect().catch(()=>{la()}).finally(()=>{this.isReconnecting=!1})):this.isReconnecting=!1})();break;case Ce.CONNECTED:this.reconnectAttempts=0;try{r=await this.handleConnected(),this.fetchUnseenEventsAPI().catch(()=>{})}catch{break}this.connected=r,this.updateLastHeartbeat(),this.heartbeatIntervalId&&clearInterval(this.heartbeatIntervalId),this.heartbeatIntervalId=window.setInterval(()=>{this.heartbeat()},ma),setTimeout(()=>{this.heartbeat()},100);break;case Ce.CONNECTING:break}n!==Ce.CONNECTED&&(this.connected=r)}),t.setIncomingDataListener(n=>{var r;switch(n.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const i=n.type==="IsLinkedOK"?n.linked:void 0;this.linked=i||n.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{this.handleSessionMetadataUpdated(n.metadata);break}case"Event":{this.handleIncomingEvent(n);break}}n.id!==void 0&&((r=this.requestResolutions.get(n.id))===null||r===void 0||r(n))}),t}setupVisibilityChangeHandler(){this.visibilityChangeHandler=()=>{!document.hidden&&!this.destroyed&&(this.connected?this.heartbeat():this.reconnectWithFreshWebSocket())},this.focusHandler=()=>{!this.destroyed&&!this.connected&&this.reconnectWithFreshWebSocket()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),window.addEventListener("focus",this.focusHandler),window.addEventListener("pageshow",t=>{t.persisted&&this.focusHandler&&this.focusHandler()})}reconnectWithFreshWebSocket(){if(this.destroyed)return;const t=this.ws;this.activeWsInstance=void 0,t.disconnect(),"cleanup"in t&&typeof t.cleanup=="function"&&t.cleanup(),this.ws=this.createWebSocket(),this.ws.connect().catch(()=>{la()})}connect(){if(this.destroyed)throw new Error("instance is destroyed");this.ws.connect()}async destroy(){this.destroyed||(await this.makeRequest({type:"SetSessionConfig",id:De(this.nextReqId++),sessionId:this.session.id,metadata:{__destroyed:"1"}},{timeout:1e3}),this.destroyed=!0,this.activeWsInstance=void 0,this.heartbeatIntervalId&&(clearInterval(this.heartbeatIntervalId),this.heartbeatIntervalId=void 0),this.visibilityChangeHandler&&document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.focusHandler&&window.removeEventListener("focus",this.focusHandler),this.ws.disconnect(),"cleanup"in this.ws&&typeof this.ws.cleanup=="function"&&this.ws.cleanup(),this.listener=void 0)}get connected(){return this._connected}set connected(t){this._connected=t}get linked(){return this._linked}set linked(t){var n,r;this._linked=t,t&&((n=this.onceLinked)===null||n===void 0||n.call(this)),(r=this.listener)===null||r===void 0||r.linkedUpdated(t)}setOnceLinked(t){return new Promise(n=>{this.linked?t().then(n):this.onceLinked=()=>{t().then(n),this.onceLinked=void 0}})}async handleIncomingEvent(t){var n;if(!(t.type!=="Event"||t.event!=="Web3Response"))try{const r=await this.cipher.decrypt(t.data),i=JSON.parse(r);if(i.type!=="WEB3_RESPONSE")return;(n=this.listener)===null||n===void 0||n.handleWeb3ResponseMessage(i.id,i.response)}catch{}}async checkUnseenEvents(){await new Promise(t=>setTimeout(t,250));try{await this.fetchUnseenEventsAPI()}catch(t){console.error("Unable to check for unseen events",t)}}async fetchUnseenEventsAPI(){try{(await this.http.fetchUnseenEvents()).forEach(n=>{this.handleIncomingEvent(n)})}catch{zp()}}async publishEvent(t,n,r=!1){const i=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},n),{origin:location.origin,location:location.href,relaySource:"coinbaseWalletExtension"in window&&window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),a={type:"PublishEvent",id:De(this.nextReqId++),sessionId:this.session.id,event:t,data:i,callWebhook:r};return this.setOnceLinked(async()=>{const s=await this.makeRequest(a);if(s.type==="Fail")throw new Error(s.error||"failed to publish event");return s.eventId})}sendData(t){this.ws.sendData(JSON.stringify(t))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>ma*2){this.ws.disconnect();return}if(this.connected)try{this.ws.sendData("h")}catch{}}async makeRequest(t,n={timeout:wh}){const r=t.id;this.sendData(t);let i;return Promise.race([new Promise((a,s)=>{i=window.setTimeout(()=>{s(new Error(`request ${r} timed out`))},n.timeout)}),new Promise(a=>{this.requestResolutions.set(r,s=>{clearTimeout(i),a(s),this.requestResolutions.delete(r)})})])}async handleConnected(){return(await this.makeRequest({type:"HostSession",id:De(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key})).type==="Fail"?!1:(this.sendData({type:"IsLinked",id:De(this.nextReqId++),sessionId:this.session.id}),this.sendData({type:"GetSessionConfig",id:De(this.nextReqId++),sessionId:this.session.id}),!0)}}class xh{constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%2147483647;const t=this._nextRequestId,n=Us(t.toString(16));return this.callbacks.get(n)&&this.callbacks.delete(n),t}}function Eh(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function fi(e,...t){if(!Eh(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function ya(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Sh(e,t){fi(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Xn=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Ie=(e,t)=>e<<32-t|e>>>t;new Uint8Array(new Uint32Array([287454020]).buffer)[0];const kh=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ah(e){fi(e);let t="";for(let n=0;n<e.length;n++)t+=kh[e[n]];return t}function _h(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Qo(e){return typeof e=="string"&&(e=_h(e)),fi(e),e}class Ih{clone(){return this._cloneInto()}}function Oh(e){const t=r=>e().update(Qo(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Ph(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const i=BigInt(32),a=BigInt(4294967295),s=Number(n>>i&a),o=Number(n&a),c=r?4:0,u=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+u,o,r)}const Ch=(e,t,n)=>e&t^~e&n,Th=(e,t,n)=>e&t^e&n^t&n;class Bh extends Ih{constructor(t,n,r,i){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Xn(this.buffer)}update(t){ya(this);const{view:n,buffer:r,blockLen:i}=this;t=Qo(t);const a=t.length;for(let s=0;s<a;){const o=Math.min(i-this.pos,a-s);if(o===i){const c=Xn(t);for(;i<=a-s;s+=i)this.process(c,s);continue}r.set(t.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===i&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ya(this),Sh(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:i,isLE:a}=this;let{pos:s}=this;n[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(r,0),s=0);for(let f=s;f<i;f++)n[f]=0;Ph(r,i-8,BigInt(this.length*8),a),this.process(r,0);const o=Xn(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,p=this.get();if(u>p.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<u;f++)o.setUint32(4*f,p[f],a)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:i,finished:a,destroyed:s,pos:o}=this;return t.length=i,t.pos=o,t.finished=a,t.destroyed=s,i%n&&t.buffer.set(r),t}}const Lh=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ke=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ze=new Uint32Array(64);class jh extends Bh{constructor(){super(64,32,8,!1),this.A=Ke[0]|0,this.B=Ke[1]|0,this.C=Ke[2]|0,this.D=Ke[3]|0,this.E=Ke[4]|0,this.F=Ke[5]|0,this.G=Ke[6]|0,this.H=Ke[7]|0}get(){const{A:t,B:n,C:r,D:i,E:a,F:s,G:o,H:c}=this;return[t,n,r,i,a,s,o,c]}set(t,n,r,i,a,s,o,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=i|0,this.E=a|0,this.F=s|0,this.G=o|0,this.H=c|0}process(t,n){for(let f=0;f<16;f++,n+=4)Ze[f]=t.getUint32(n,!1);for(let f=16;f<64;f++){const l=Ze[f-15],d=Ze[f-2],g=Ie(l,7)^Ie(l,18)^l>>>3,h=Ie(d,17)^Ie(d,19)^d>>>10;Ze[f]=h+Ze[f-7]+g+Ze[f-16]|0}let{A:r,B:i,C:a,D:s,E:o,F:c,G:u,H:p}=this;for(let f=0;f<64;f++){const l=Ie(o,6)^Ie(o,11)^Ie(o,25),d=p+l+Ch(o,c,u)+Lh[f]+Ze[f]|0,h=(Ie(r,2)^Ie(r,13)^Ie(r,22))+Th(r,i,a)|0;p=u,u=c,c=o,o=s+d|0,s=a,a=i,i=r,r=d+h|0}r=r+this.A|0,i=i+this.B|0,a=a+this.C|0,s=s+this.D|0,o=o+this.E|0,c=c+this.F|0,u=u+this.G|0,p=p+this.H|0,this.set(r,i,a,s,o,c,u,p)}roundClean(){Ze.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Mh=Oh(()=>new jh),ga="session:id",ba="session:secret",wa="session:linked";class St{constructor(t,n,r,i=!1){this.storage=t,this.id=n,this.secret=r,this.key=Ah(Mh(`${n}, ${r} WalletLink`)),this._linked=!!i}static create(t){const n=tt(16),r=tt(32);return new St(t,n,r).save()}static load(t){const n=t.getItem(ga),r=t.getItem(wa),i=t.getItem(ba);return n&&i?new St(t,n,i,r==="1"):null}get linked(){return this._linked}set linked(t){this._linked=t,this.persistLinked()}save(){return this.storage.setItem(ga,this.id),this.storage.setItem(ba,this.secret),this.persistLinked(),this}persistLinked(){this.storage.setItem(wa,this._linked?"1":"0")}}const Dh=".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}";class Nh{constructor(){this.root=null,this.darkMode=Gs()}attach(){const t=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",t.appendChild(this.root),$s()}present(t){this.render(t)}clear(){this.render(null)}render(t){this.root&&(tr(null,this.root),t&&tr(q(Rh,Object.assign({},t,{onDismiss:()=>{this.clear()},darkMode:this.darkMode})),this.root))}}const Rh=({title:e,buttonText:t,darkMode:n,onButtonClick:r,onDismiss:i})=>{const a=n?"dark":"light";return q(zs,{darkMode:n},q("div",{class:"-cbwsdk-redirect-dialog"},q("style",null,Dh),q("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:i}),q("div",{class:Dt("-cbwsdk-redirect-dialog-box",a)},q("p",null,e),q("button",{onClick:r},t))))};class va{constructor(){this.attached=!1,this.redirectDialog=new Nh}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");this.redirectDialog.attach(),this.attached=!0}redirectToCoinbaseWallet(t){const n=new URL(Ul);n.searchParams.append("redirect_url",ql().href),t&&n.searchParams.append("wl_url",t);const r=document.createElement("a");r.target="cbw-opener",r.href=n.href,r.rel="noreferrer noopener",r.click()}openCoinbaseWalletDeeplink(t){this.redirectToCoinbaseWallet(t),setTimeout(()=>{this.redirectDialog.present({title:"Redirecting to Coinbase Wallet...",buttonText:"Open",onButtonClick:()=>{this.redirectToCoinbaseWallet(t)}})},99)}showConnecting(t){return()=>{this.redirectDialog.clear()}}}class Ne{constructor(t){this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.isMobileWeb=Wl(),this.linkedUpdated=a=>{this.isLinked=a;const s=this.storage.getItem(Hr);if(a&&(this._session.linked=a),this.isUnlinkedErrorState=!1,s){const o=s.split(" "),c=this.storage.getItem("IsStandaloneSigning")==="true";o[0]!==""&&!a&&this._session.linked&&!c&&(this.isUnlinkedErrorState=!0)}},this.metadataUpdated=(a,s)=>{this.storage.setItem(a,s)},this.chainUpdated=(a,s)=>{this.chainCallbackParams.chainId===a&&this.chainCallbackParams.jsonRpcUrl===s||(this.chainCallbackParams={chainId:a,jsonRpcUrl:s},this.chainCallback&&this.chainCallback(s,Number.parseInt(a,10)))},this.accountUpdated=a=>{this.accountsCallback&&this.accountsCallback([a]),Ne.accountRequestCallbackIds.size>0&&(Array.from(Ne.accountRequestCallbackIds.values()).forEach(s=>{this.invokeCallback(s,{method:"requestEthereumAccounts",result:[a]})}),Ne.accountRequestCallbackIds.clear())},this.resetAndReload=this.resetAndReload.bind(this),this.linkAPIUrl=t.linkAPIUrl,this.storage=t.storage,this.metadata=t.metadata,this.accountsCallback=t.accountsCallback,this.chainCallback=t.chainCallback;const{session:n,ui:r,connection:i}=this.subscribe();this._session=n,this.connection=i,this.relayEventManager=new xh,this.ui=r,this.ui.attach()}subscribe(){const t=St.load(this.storage)||St.create(this.storage),{linkAPIUrl:n}=this,r=new vh({session:t,linkAPIUrl:n,listener:this}),i=this.isMobileWeb?new va:new Jl;return r.connect(),{session:t,ui:i,connection:r}}resetAndReload(){this.connection.destroy().then(()=>{const t=St.load(this.storage);t?.id===this._session.id&&ct.clearAll(),document.location.reload()}).catch(t=>{})}signEthereumTransaction(t){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:t.fromAddress,toAddress:t.toAddress,weiValue:_e(t.weiValue),data:Nt(t.data,!0),nonce:t.nonce,gasPriceInWei:t.gasPriceInWei?_e(t.gasPriceInWei):null,maxFeePerGas:t.gasPriceInWei?_e(t.gasPriceInWei):null,maxPriorityFeePerGas:t.gasPriceInWei?_e(t.gasPriceInWei):null,gasLimit:t.gasLimit?_e(t.gasLimit):null,chainId:t.chainId,shouldSubmit:!1}})}signAndSubmitEthereumTransaction(t){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:t.fromAddress,toAddress:t.toAddress,weiValue:_e(t.weiValue),data:Nt(t.data,!0),nonce:t.nonce,gasPriceInWei:t.gasPriceInWei?_e(t.gasPriceInWei):null,maxFeePerGas:t.maxFeePerGas?_e(t.maxFeePerGas):null,maxPriorityFeePerGas:t.maxPriorityFeePerGas?_e(t.maxPriorityFeePerGas):null,gasLimit:t.gasLimit?_e(t.gasLimit):null,chainId:t.chainId,shouldSubmit:!0}})}submitEthereumTransaction(t,n){return this.sendRequest({method:"submitEthereumTransaction",params:{signedTransaction:Nt(t,!0),chainId:n}})}getWalletLinkSession(){return this._session}sendRequest(t){let n=null;const r=tt(8),i=a=>{this.publishWeb3RequestCanceledEvent(r),this.handleErrorResponse(r,t.method,a),n?.()};return new Promise((a,s)=>{n=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:i,onResetConnection:this.resetAndReload}),this.relayEventManager.callbacks.set(r,o=>{if(n?.(),ie(o))return s(new Error(o.errorMessage));a(o)}),this.publishWeb3RequestEvent(r,t)})}publishWeb3RequestEvent(t,n){const r={type:"WEB3_REQUEST",id:t,request:n};this.publishEvent("Web3Request",r,!0).then(i=>{}).catch(i=>{this.handleWeb3ResponseMessage(r.id,{method:n.method,errorMessage:i.message})}),this.isMobileWeb&&this.openCoinbaseWalletDeeplink(n.method)}openCoinbaseWalletDeeplink(t){if(this.ui instanceof va)switch(t){case"requestEthereumAccounts":case"switchEthereumChain":return;default:window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{this.connection.checkUnseenEvents()},{once:!0})},{once:!0}),this.ui.openCoinbaseWalletDeeplink();break}}publishWeb3RequestCanceledEvent(t){const n={type:"WEB3_REQUEST_CANCELED",id:t};this.publishEvent("Web3RequestCanceled",n,!1).then()}publishEvent(t,n,r){return this.connection.publishEvent(t,n,r)}handleWeb3ResponseMessage(t,n){if(n.method==="requestEthereumAccounts"){Ne.accountRequestCallbackIds.forEach(r=>this.invokeCallback(r,n)),Ne.accountRequestCallbackIds.clear();return}this.invokeCallback(t,n)}handleErrorResponse(t,n,r){var i;const a=(i=r?.message)!==null&&i!==void 0?i:"Unspecified error message.";this.handleWeb3ResponseMessage(t,{method:n,errorMessage:a})}invokeCallback(t,n){const r=this.relayEventManager.callbacks.get(t);r&&(r(n),this.relayEventManager.callbacks.delete(t))}requestEthereumAccounts(){const{appName:t,appLogoUrl:n}=this.metadata,r={method:"requestEthereumAccounts",params:{appName:t,appLogoUrl:n}},i=tt(8);return new Promise((a,s)=>{this.relayEventManager.callbacks.set(i,o=>{if(ie(o))return s(new Error(o.errorMessage));a(o)}),Ne.accountRequestCallbackIds.add(i),this.publishWeb3RequestEvent(i,r)})}watchAsset(t,n,r,i,a,s){const o={method:"watchAsset",params:{type:t,options:{address:n,symbol:r,decimals:i,image:a},chainId:s}};let c=null;const u=tt(8),p=f=>{this.publishWeb3RequestCanceledEvent(u),this.handleErrorResponse(u,o.method,f),c?.()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:p,onResetConnection:this.resetAndReload}),new Promise((f,l)=>{this.relayEventManager.callbacks.set(u,d=>{if(c?.(),ie(d))return l(new Error(d.errorMessage));f(d)}),this.publishWeb3RequestEvent(u,o)})}addEthereumChain(t,n,r,i,a,s){const o={method:"addEthereumChain",params:{chainId:t,rpcUrls:n,blockExplorerUrls:i,chainName:a,iconUrls:r,nativeCurrency:s}};let c=null;const u=tt(8),p=f=>{this.publishWeb3RequestCanceledEvent(u),this.handleErrorResponse(u,o.method,f),c?.()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:p,onResetConnection:this.resetAndReload}),new Promise((f,l)=>{this.relayEventManager.callbacks.set(u,d=>{if(c?.(),ie(d))return l(new Error(d.errorMessage));f(d)}),this.publishWeb3RequestEvent(u,o)})}switchEthereumChain(t,n){const r={method:"switchEthereumChain",params:Object.assign({chainId:t},{address:n})};let i=null;const a=tt(8),s=o=>{this.publishWeb3RequestCanceledEvent(a),this.handleErrorResponse(a,r.method,o),i?.()};return i=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:s,onResetConnection:this.resetAndReload}),new Promise((o,c)=>{this.relayEventManager.callbacks.set(a,u=>{if(i?.(),ie(u)&&u.errorCode)return c(S.provider.custom({code:u.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."}));if(ie(u))return c(new Error(u.errorMessage));o(u)}),this.publishWeb3RequestEvent(a,r)})}}Ne.accountRequestCallbackIds=new Set;const xa="DefaultChainId",Ea="DefaultJsonRpcUrl";class Xo{constructor(t){this._relay=null,this._addresses=[],this.metadata=t.metadata,this._storage=new ct("walletlink",zi),this.callback=t.callback||null;const n=this._storage.getItem(Hr);if(n){const r=n.split(" ");r[0]!==""&&(this._addresses=r.map(i=>Ve(i)))}this.initializeRelay()}getSession(){const t=this.initializeRelay(),{id:n,secret:r}=t.getWalletLinkSession();return{id:n,secret:r}}async handshake(t){const n="eth_requestAccounts",r=Ee.get(t);Rp({method:n,correlationId:r});try{await this._eth_requestAccounts(),Hp({method:n,correlationId:r})}catch(i){throw Up({method:n,correlationId:r,errorMessage:nt(i)}),i}}get selectedAddress(){return this._addresses[0]||void 0}get jsonRpcUrl(){var t;return(t=this._storage.getItem(Ea))!==null&&t!==void 0?t:void 0}set jsonRpcUrl(t){this._storage.setItem(Ea,t)}updateProviderInfo(t,n){var r;this.jsonRpcUrl=t;const i=this.getChainId();this._storage.setItem(xa,n.toString(10)),Rt(n)!==i&&((r=this.callback)===null||r===void 0||r.call(this,"chainChanged",gt(n)))}async watchAsset(t){const n=Array.isArray(t)?t[0]:t;if(!n.type)throw S.rpc.invalidParams("Type is required");if(n?.type!=="ERC20")throw S.rpc.invalidParams(`Asset of type '${n.type}' is not supported`);if(!n?.options)throw S.rpc.invalidParams("Options are required");if(!n?.options.address)throw S.rpc.invalidParams("Address is required");const r=this.getChainId(),{address:i,symbol:a,image:s,decimals:o}=n.options,u=await this.initializeRelay().watchAsset(n.type,i,a,o,s,r?.toString());return ie(u)?!1:!!u.result}async addEthereumChain(t){var n,r;const i=t[0];if(((n=i.rpcUrls)===null||n===void 0?void 0:n.length)===0)throw S.rpc.invalidParams("please pass in at least 1 rpcUrl");if(!i.chainName||i.chainName.trim()==="")throw S.rpc.invalidParams("chainName is a required field");if(!i.nativeCurrency)throw S.rpc.invalidParams("nativeCurrency is a required field");const a=Number.parseInt(i.chainId,16);if(a===this.getChainId())return!1;const s=this.initializeRelay(),{rpcUrls:o=[],blockExplorerUrls:c=[],chainName:u,iconUrls:p=[],nativeCurrency:f}=i,l=await s.addEthereumChain(a.toString(),o,p,c,u,f);if(ie(l))return!1;if(((r=l.result)===null||r===void 0?void 0:r.isApproved)===!0)return this.updateProviderInfo(o[0],a),null;throw S.rpc.internal("unable to add ethereum chain")}async switchEthereumChain(t){const n=t[0],r=Number.parseInt(n.chainId,16),a=await this.initializeRelay().switchEthereumChain(r.toString(10),this.selectedAddress||void 0);if(ie(a))throw a;const s=a.result;return s.isApproved&&s.rpcUrl.length>0&&this.updateProviderInfo(s.rpcUrl,r),null}async cleanup(){this.callback=null,this._relay&&this._relay.resetAndReload(),this._storage.clear()}_setAddresses(t,n){var r;if(!Array.isArray(t))throw new Error("addresses is not an array");const i=t.map(a=>Ve(a));JSON.stringify(i)!==JSON.stringify(this._addresses)&&(this._addresses=i,(r=this.callback)===null||r===void 0||r.call(this,"accountsChanged",i),this._storage.setItem(Hr,i.join(" ")))}async request(t){const n=Ee.get(t);$p({method:t.method,correlationId:n});try{const r=await this._request(t);return Fp({method:t.method,correlationId:n}),r}catch(r){throw Gp({method:t.method,correlationId:n,errorMessage:nt(r)}),r}}async _request(t){const n=t.params||[];switch(t.method){case"eth_accounts":return[...this._addresses];case"eth_coinbase":return this.selectedAddress||null;case"net_version":return this.getChainId().toString(10);case"eth_chainId":return gt(this.getChainId());case"eth_requestAccounts":return this._eth_requestAccounts();case"eth_ecRecover":case"personal_ecRecover":return this.ecRecover(t);case"personal_sign":return this.personalSign(t);case"eth_signTransaction":return this._eth_signTransaction(n);case"eth_sendRawTransaction":return this._eth_sendRawTransaction(n);case"eth_sendTransaction":return this._eth_sendTransaction(n);case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"eth_signTypedData_v4":case"eth_signTypedData":return this.signTypedData(t);case"wallet_addEthereumChain":return this.addEthereumChain(n);case"wallet_switchEthereumChain":return this.switchEthereumChain(n);case"wallet_watchAsset":return this.watchAsset(n);default:if(!this.jsonRpcUrl)throw S.rpc.internal("No RPC URL set for chain");return Ut(t,this.jsonRpcUrl)}}_ensureKnownAddress(t){const n=Ve(t);if(!this._addresses.map(i=>Ve(i)).includes(n))throw new Error("Unknown Ethereum address")}_prepareTransactionParams(t){const n=t.from?Ve(t.from):this.selectedAddress;if(!n)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(n);const r=t.to?Ve(t.to):null,i=t.value!=null?Tt(t.value):BigInt(0),a=t.data?Dr(t.data):Buffer.alloc(0),s=t.nonce!=null?Rt(t.nonce):null,o=t.gasPrice!=null?Tt(t.gasPrice):null,c=t.maxFeePerGas!=null?Tt(t.maxFeePerGas):null,u=t.maxPriorityFeePerGas!=null?Tt(t.maxPriorityFeePerGas):null,p=t.gas!=null?Tt(t.gas):null,f=t.chainId?Rt(t.chainId):this.getChainId();return{fromAddress:n,toAddress:r,weiValue:i,data:a,nonce:s,gasPriceInWei:o,maxFeePerGas:c,maxPriorityFeePerGas:u,gasLimit:p,chainId:f}}async ecRecover(t){const{method:n,params:r}=t;if(!Array.isArray(r))throw S.rpc.invalidParams();const a=await this.initializeRelay().sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:Wn(r[0]),signature:Wn(r[1]),addPrefix:n==="personal_ecRecover"}});if(ie(a))throw a;return a.result}getChainId(){var t;return Number.parseInt((t=this._storage.getItem(xa))!==null&&t!==void 0?t:"1",10)}async _eth_requestAccounts(){var t,n;if(this._addresses.length>0)return(t=this.callback)===null||t===void 0||t.call(this,"connect",{chainId:gt(this.getChainId())}),this._addresses;const i=await this.initializeRelay().requestEthereumAccounts();if(ie(i))throw i;if(!i.result)throw new Error("accounts received is empty");return this._setAddresses(i.result),(n=this.callback)===null||n===void 0||n.call(this,"connect",{chainId:gt(this.getChainId())}),this._addresses}async personalSign({params:t}){if(!Array.isArray(t))throw S.rpc.invalidParams();const n=t[1],r=t[0];this._ensureKnownAddress(n);const a=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:Ve(n),message:Wn(r),addPrefix:!0,typedDataJson:null}});if(ie(a))throw a;return a.result}async _eth_signTransaction(t){const n=this._prepareTransactionParams(t[0]||{}),i=await this.initializeRelay().signEthereumTransaction(n);if(ie(i))throw i;return i.result}async _eth_sendRawTransaction(t){const n=Dr(t[0]),i=await this.initializeRelay().submitEthereumTransaction(n,this.getChainId());if(ie(i))throw i;return i.result}async _eth_sendTransaction(t){const n=this._prepareTransactionParams(t[0]||{}),i=await this.initializeRelay().signAndSubmitEthereumTransaction(n);if(ie(i))throw i;return i.result}async signTypedData(t){const{method:n,params:r}=t;if(!Array.isArray(r))throw S.rpc.invalidParams();const i=u=>{const p={eth_signTypedData_v1:un.hashForSignTypedDataLegacy,eth_signTypedData_v3:un.hashForSignTypedData_v3,eth_signTypedData_v4:un.hashForSignTypedData_v4,eth_signTypedData:un.hashForSignTypedData_v4};return Nt(p[n]({data:Il(u)}),!0)},a=r[n==="eth_signTypedData_v1"?1:0],s=r[n==="eth_signTypedData_v1"?0:1];this._ensureKnownAddress(a);const c=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:Ve(a),message:i(s),typedDataJson:JSON.stringify(s,null,2),addPrefix:!1}});if(ie(c))throw c;return c.result}initializeRelay(){return this._relay||(this._relay=new Ne({linkAPIUrl:zi,storage:this._storage,metadata:this.metadata,accountsCallback:this._setAddresses.bind(this),chainCallback:this.updateProviderInfo.bind(this)})),this._relay}}const ec="SignerType",tc=new ct("CBWSDK","SignerConfigurator");function Uh(){return tc.getItem(ec)}function Hh(e){tc.setItem(ec,e)}function Sa(e){if(e)return e instanceof oo?"scw":"walletlink"}async function $h(e){const{communicator:t,metadata:n,handshakeRequest:r,callback:i}=e;Fh(t,n,i,r).catch(()=>{});const a={id:crypto.randomUUID(),event:"selectSignerType",data:Object.assign(Object.assign({},e.preference),{handshakeRequest:r})},{data:s}=await t.postRequestAndWaitForResponse(a);return s}function Gh(e){const{signerType:t,metadata:n,communicator:r,callback:i}=e;switch(t){case"scw":return new oo({metadata:n,callback:i,communicator:r});case"walletlink":return new Xo({metadata:n,callback:i})}}async function Fh(e,t,n,r){await e.onMessage(({event:a})=>a==="WalletLinkSessionRequest");const i=new Xo({metadata:t,callback:n});e.postMessage({event:"WalletLinkUpdate",data:{session:i.getSession()}}),await i.handshake(r),e.postMessage({event:"WalletLinkUpdate",data:{connected:!0}})}var zh=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};class qh extends of{constructor(t){var{metadata:n}=t,r=t.preference,{keysUrl:i}=r,a=zh(r,["keysUrl"]);super(),this.signer=null,this.isCoinbaseWallet=!0,this.metadata=n,this.preference=a,this.communicator=new rf({url:i,metadata:n,preference:a});const s=Uh();s&&(this.signer=this.initSigner(s),cf({signerType:s}))}async request(t){const n=crypto.randomUUID();Ee.set(t,n),uf({method:t.method,correlationId:n});try{const r=await this._request(t);return lf({method:t.method,signerType:Sa(this.signer),correlationId:n}),r}catch(r){throw df({method:t.method,correlationId:n,signerType:Sa(this.signer),errorMessage:r instanceof Error?r.message:""}),r}finally{Ee.delete(t)}}async _request(t){try{if(Dl(t),!this.signer)switch(t.method){case"eth_requestAccounts":{let r;const i=A.subAccountsConfig.get();i?.enableAutoSubAccounts?r="scw":r=await this.requestSignerSelection(t);const a=this.initSigner(r);r==="scw"&&i?.enableAutoSubAccounts?(await a.handshake({method:"handshake"}),await a.request(t)):await a.handshake(t),this.signer=a,Hh(r);break}case"wallet_connect":{const r=this.initSigner("scw");await r.handshake({method:"handshake"});const i=await r.request(t);return this.signer=r,i}case"wallet_sendCalls":case"wallet_sign":{const r=this.initSigner("scw");await r.handshake({method:"handshake"});const i=await r.request(t);return await r.cleanup(),i}case"wallet_getCallsStatus":return await Ut(t,Hs);case"net_version":return 1;case"eth_chainId":return gt(1);default:throw S.provider.unauthorized("Must call 'eth_requestAccounts' before other methods")}return await this.signer.request(t)}catch(n){const{code:r}=n;return r===Q.provider.unauthorized&&this.disconnect(),Promise.reject(af(n))}}async enable(){return console.warn('.enable() has been deprecated. Please use .request({ method: "eth_requestAccounts" }) instead.'),ff(),await this.request({method:"eth_requestAccounts"})}async disconnect(){var t;await((t=this.signer)===null||t===void 0?void 0:t.cleanup()),this.signer=null,ct.clearAll(),Ee.clear(),this.emit("disconnect",S.provider.disconnected("User initiated disconnection"))}async requestSignerSelection(t){pf();const n=await $h({communicator:this.communicator,preference:this.preference,metadata:this.metadata,handshakeRequest:t,callback:this.emit.bind(this)});return hf(n),n}initSigner(t){return Gh({signerType:t,metadata:this.metadata,communicator:this.communicator,callback:this.emit.bind(this)})}}function Wh(e){var t;const n={metadata:e.metadata,preference:e.preference};return(t=Ml(n))!==null&&t!==void 0?t:new qh(n)}const{decodeAbiParameters:Vh,encodeFunctionData:ka,toHex:er}=await ye("viem"),Kh={options:"all"};function l0(e){var t,n,r,i;const a={metadata:{appName:e.appName||"Dapp",appLogoUrl:e.appLogoUrl||"",appChainIds:e.appChainIds||[]},preference:Object.assign(Kh,(t=e.preference)!==null&&t!==void 0?t:{}),paymasterUrls:e.paymasterUrls};!((n=e.subAccounts)===null||n===void 0)&&n.toOwnerAccount&&Fi(e.subAccounts.toOwnerAccount),A.subAccountsConfig.set({toOwnerAccount:(r=e.subAccounts)===null||r===void 0?void 0:r.toOwnerAccount,enableAutoSubAccounts:(i=e.subAccounts)===null||i===void 0?void 0:i.enableAutoSubAccounts}),A.config.set(a),A.persist.rehydrate(),Tl(),a.preference.telemetry!==!1&&wl(),Nl(a.preference);let s=null;const o={getProvider(){return s||(s=Wh(a)),s.sdk=o,s},subAccount:{async create(c){var u,p;const f=A.getState();return me((u=f.subAccount)===null||u===void 0?void 0:u.address,new Error("subaccount already exists")),await((p=o.getProvider())===null||p===void 0?void 0:p.request({method:"wallet_addSubAccount",params:[{version:"1",account:c}]}))},async get(){var c,u;const p=A.subAccounts.get();if(p?.address)return p;const l=(u=(await((c=o.getProvider())===null||c===void 0?void 0:c.request({method:"wallet_connect",params:[{version:"1",capabilities:{}}]}))).accounts[0].capabilities)===null||u===void 0?void 0:u.subAccounts;return Array.isArray(l)?l[0]:null},async addOwner({address:c,publicKey:u,chainId:p}){var f,l;const d=A.subAccounts.get(),g=A.account.get();me(g,new Error("account does not exist")),me(d?.address,new Error("subaccount does not exist"));const h=[];if(u){const[v,k]=Vh([{type:"bytes32"},{type:"bytes32"}],u);h.push({to:d.address,data:ka({abi:Se,functionName:"addOwnerPublicKey",args:[v,k]}),value:er(0)})}return c&&h.push({to:d.address,data:ka({abi:Se,functionName:"addOwnerAddress",args:[c]}),value:er(0)}),await((f=o.getProvider())===null||f===void 0?void 0:f.request({method:"wallet_sendCalls",params:[{calls:h,chainId:er(p),from:(l=g.accounts)===null||l===void 0?void 0:l[0],version:"1"}]}))},setToOwnerAccount(c){Fi(c),A.subAccountsConfig.set({toOwnerAccount:c})}}};return o}export{l0 as createCoinbaseWalletSDK,Nr as getCryptoKeyAccount};
|